Skip to content

Refactor: Introduce spire_enum #1623

@ikhyunAn

Description

@ikhyunAn

From #1620 , @aawsome suggested using the crate spire_enum.
This is a follow-up Issue for discussing this refactoring / new crate integration and to a later PR submission.
Inviting others to join this thread.

Original Comment:

I do think that the crate spire_enum should be able to derive this impl.
However, it introduces quite some build-dependencies. On the other hand, it could be also useful for rustic_core, so maybe we'll just use it...

Referring to:
src/config/progress_options.rs lines 312-352

impl Progress for RusticProgress {
    fn is_hidden(&self) -> bool {
        match self {
            Self::Hidden(p) => p.is_hidden(),
            Self::Interactive(p) => p.is_hidden(),
            Self::NonInteractive(p) => p.is_hidden(),
        }
    }

    fn set_length(&self, len: u64) {
        match self {
            Self::Hidden(p) => p.set_length(len),
            Self::Interactive(p) => p.set_length(len),
            Self::NonInteractive(p) => p.set_length(len),
        }
    }

    fn set_title(&self, title: &'static str) {
        match self {
            Self::Hidden(p) => p.set_title(title),
            Self::Interactive(p) => p.set_title(title),
            Self::NonInteractive(p) => p.set_title(title),
        }
    }

    fn inc(&self, inc: u64) {
        match self {
            Self::Hidden(p) => p.inc(inc),
            Self::Interactive(p) => p.inc(inc),
            Self::NonInteractive(p) => p.inc(inc),
        }
    }

    fn finish(&self) {
        match self {
            Self::Hidden(p) => p.finish(),
            Self::Interactive(p) => p.finish(),
            Self::NonInteractive(p) => p.finish(),
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-triageStatus: Waiting for a maintainer to triage this issue/PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions