pub struct SpiffeId { /* private fields */ }
Expand description
Represents a SPIFFE ID.
Implementations§
Source§impl SpiffeId
impl SpiffeId
Sourcepub fn new(id: &str) -> Result<Self, SpiffeIdError>
pub fn new(id: &str) -> Result<Self, SpiffeIdError>
Attempts to parse a SPIFFE ID from the given id string.
§Arguments
id
- A SPIFFE ID, e.g. ‘spiffe://trustdomain/path/other’
§Errors
If the function cannot parse the input as a SPIFFE ID, a SpiffeIdError
variant will be returned.
§Examples
use spiffe::SpiffeId;
let spiffe_id = SpiffeId::new("spiffe://trustdomain/path").unwrap();
assert_eq!("trustdomain", spiffe_id.trust_domain().to_string());
assert_eq!("/path", spiffe_id.path());
Sourcepub fn from_segments(
trust_domain: TrustDomain,
segments: &[&str],
) -> Result<Self, SpiffeIdError>
pub fn from_segments( trust_domain: TrustDomain, segments: &[&str], ) -> Result<Self, SpiffeIdError>
Returns a new SPIFFE ID in the given trust domain with joined path segments. The path segments must be valid according to the SPIFFE specification and must not contain path separators. See https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE-ID.md#22-path
§Arguments
trust_domain
- ATrustDomain
object.segments
- A slice of path segments.
§Errors
If the segments contain not allowed characters, a SpiffeIdError
variant will be returned.
§Examples
use spiffe::{SpiffeId, TrustDomain};
let trust_domain = TrustDomain::new("trustdomain").unwrap();
let spiffe_id = SpiffeId::from_segments(trust_domain, &["path1", "path2", "path3"]).unwrap();
assert_eq!(
"spiffe://trustdomain/path1/path2/path3",
spiffe_id.to_string()
);
Sourcepub fn trust_domain(&self) -> &TrustDomain
pub fn trust_domain(&self) -> &TrustDomain
Returns the trust domain of the SPIFFE ID.
Sourcepub fn is_member_of(&self, trust_domain: &TrustDomain) -> bool
pub fn is_member_of(&self, trust_domain: &TrustDomain) -> bool
Returns true
if this SPIFFE ID has the given TrustDomain.
Trait Implementations§
Source§impl Ord for SpiffeId
impl Ord for SpiffeId
Source§impl PartialOrd for SpiffeId
impl PartialOrd for SpiffeId
impl Eq for SpiffeId
impl StructuralPartialEq for SpiffeId
Auto Trait Implementations§
impl Freeze for SpiffeId
impl RefUnwindSafe for SpiffeId
impl Send for SpiffeId
impl Sync for SpiffeId
impl Unpin for SpiffeId
impl UnwindSafe for SpiffeId
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request