pub struct Address(/* private fields */);Expand description
An ordered, non-empty sequence of Segments — a session’s alias.
Displays and parses dot-joined (work.akeyless.build). Non-empty
is an invariant of the type, not a runtime check: every constructor
is fallible or takes at least one segment, and Address::depth
returns NonZeroUsize so the guarantee is visible in the
signature.
Implementations§
Source§impl Address
impl Address
Sourcepub fn parse(s: &str) -> Result<Self, AddressError>
pub fn parse(s: &str) -> Result<Self, AddressError>
Parse a dot-joined address. An empty string is
AddressError::Empty; any bad segment surfaces with its
position.
Sourcepub fn from_segments<I>(segments: I) -> Result<Self, AddressError>where
I: IntoIterator<Item = Segment>,
pub fn from_segments<I>(segments: I) -> Result<Self, AddressError>where
I: IntoIterator<Item = Segment>,
Build from already-validated segments. Fails only on an empty iterator — there is nothing left to check.
Sourcepub fn root(segment: Segment) -> Self
pub fn root(segment: Segment) -> Self
A one-segment address. Infallible: one segment is already non-empty.
Sourcepub fn depth(&self) -> NonZeroUsize
pub fn depth(&self) -> NonZeroUsize
How many segments. Typed NonZeroUsize because an address
with zero segments does not exist.
Sourcepub fn parent(&self) -> Option<Self>
pub fn parent(&self) -> Option<Self>
This address with its last segment dropped. None at depth 1 —
a root has no parent, and the empty address is unrepresentable.
Sourcepub fn starts_with(&self, prefix: &Self) -> bool
pub fn starts_with(&self, prefix: &Self) -> bool
Whether prefix is a segment-wise prefix of this address.
Segment-wise, never string-wise: work.helm is NOT a prefix of
work.helm-charts.