pub struct ResourceKey { /* private fields */ }Expand description
Stable identity for a desired external resource.
Implementations§
Source§impl ResourceKey
impl ResourceKey
Sourcepub fn new(key: impl Into<Box<str>>) -> Self
pub fn new(key: impl Into<Box<str>>) -> Self
Creates a single-segment resource key from deterministic host-chosen identity.
Sourcepub fn from_segments<I, S>(segments: I) -> Self
pub fn from_segments<I, S>(segments: I) -> Self
Creates a resource key from ordered identity segments.
Prefer this for product identifiers with multiple parts. Hosts can recover the exact segments from close commands without parsing a flattened string.
§Panics
Panics when called with no segments. Use Self::try_from_segments when
the segment list may be empty.
Sourcepub fn try_from_segments<I, S>(segments: I) -> Option<Self>
pub fn try_from_segments<I, S>(segments: I) -> Option<Self>
Creates a resource key from ordered identity segments, returning None
when the segment list is empty.
Sourcepub fn wildcard(key: impl AsRef<str>) -> Self
pub fn wildcard(key: impl AsRef<str>) -> Self
Creates an explicit broad-resource key.
Core treats this as an opaque identity; tests and applications decide whether the key represents a forbidden fallback or wildcard resource.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns this key’s deterministic encoded representation.
Use Self::segments or Self::segment when application code needs
product identity back from a resource command. Single-segment keys return
the segment directly unless it is in core’s reserved diagnostic namespace.
Sourcepub fn segments(&self) -> impl ExactSizeIterator<Item = &str> + '_
pub fn segments(&self) -> impl ExactSizeIterator<Item = &str> + '_
Returns this key’s ordered identity segments.
Sourcepub fn segment_count(&self) -> usize
pub fn segment_count(&self) -> usize
Returns the number of identity segments.
Trait Implementations§
Source§impl Clone for ResourceKey
impl Clone for ResourceKey
Source§fn clone(&self) -> ResourceKey
fn clone(&self) -> ResourceKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourceKey
impl Debug for ResourceKey
impl Eq for ResourceKey
Source§impl Hash for ResourceKey
impl Hash for ResourceKey
Source§impl Ord for ResourceKey
impl Ord for ResourceKey
Source§fn cmp(&self, other: &ResourceKey) -> Ordering
fn cmp(&self, other: &ResourceKey) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ResourceKey
impl PartialEq for ResourceKey
Source§fn eq(&self, other: &ResourceKey) -> bool
fn eq(&self, other: &ResourceKey) -> bool
self and other values to be equal, and is used by ==.