Skip to main content

link_assistant_router/cli/
targets.rs

1//! Which router each subcommand acts on.
2//!
3//! Split from `cli.rs` to keep that file within the repository's 1000-line
4//! limit. Every state-touching family answers the same question the same way,
5//! which is the point of issue #294 — one rule rather than a table an operator
6//! has to memorise.
7
8use super::{AccountOp, AuthTarget, LogsOp, ProviderOp, TokenOp};
9
10impl TokenOp {
11    /// Which router this token operation acts on.
12    #[must_use]
13    pub const fn target(&self) -> &AuthTarget {
14        match self {
15            Self::Issue { target, .. }
16            | Self::Rotate { target, .. }
17            | Self::List { target, .. }
18            | Self::Revoke { target, .. }
19            | Self::Expire { target, .. }
20            | Self::Show { target, .. }
21            | Self::RecoverAdmin { target, .. } => target,
22        }
23    }
24}
25
26impl AccountOp {
27    /// Which router this account operation acts on.
28    #[must_use]
29    pub const fn target(&self) -> &AuthTarget {
30        match self {
31            Self::List { target, .. } => target,
32        }
33    }
34}
35
36impl ProviderOp {
37    /// Which router this provider operation acts on.
38    #[must_use]
39    pub const fn target(&self) -> &AuthTarget {
40        match self {
41            Self::List { target, .. }
42            | Self::Add { target, .. }
43            | Self::Show { target, .. }
44            | Self::Remove { target, .. }
45            | Self::Import { target, .. } => target,
46        }
47    }
48}
49
50impl LogsOp {
51    /// Which router this log query acts on.
52    #[must_use]
53    pub const fn target(&self) -> &AuthTarget {
54        match self {
55            Self::Summary { target, .. }
56            | Self::Anomalies { target, .. }
57            | Self::Show { target, .. } => target,
58        }
59    }
60}