Skip to main content

Name

Struct Name 

Source
pub struct Name<'a> { /* private fields */ }
Expand description

A distinguished name, as the sequence of parts the certificate holds.

Implementations§

Source§

impl<'a> Name<'a>

Source

pub fn as_bytes(&self) -> &'a [u8] ⓘ

The name exactly as it was encoded, which is what identity is.

Source

pub fn parts(&self) -> &[RelativeName<'a>]

The parts, outermost first, as the certificate wrote them.

Source

pub fn is_empty(&self) -> bool

Whether the name has no parts at all, which a certificate is allowed to do when the subject is named somewhere else instead.

Source

pub fn try_copy(&self, execution: &Memory) -> Result<Self>

Copies descriptors into the current domain; document bytes remain borrowed.

§Errors

Returns a located resource error before unfunded copying or allocation.

Source

pub fn attributes(&self) -> impl Iterator<Item = &Attribute<'a>>

Every attribute, in the order the name holds them. The caller admits its own traversal of this borrowed view.

Source

pub fn attributes_of<'n, 'q>( &'n self, kind: Oid<'q>, execution: &'q Memory, ) -> impl Iterator<Item = Result<&'n Attribute<'a>>> + 'q
where 'n: 'q,

The attributes of one kind, in order. Several is not an error: a name can carry more than one organizational unit, and which one matters is not this layer’s decision. Each search step is admitted in the current execution domain. A refusal is yielded once, after which repeated next() calls do no further work. Returned references borrow the name, independently of the budget borrow.

Source

pub fn attribute( &self, kind: Oid<'_>, execution: &Memory, ) -> Result<Option<&Attribute<'a>>>

The first attribute of one kind.

Source

pub fn common_name(&self, execution: &Memory) -> Result<Option<&Attribute<'a>>>

The common name, which describes the subject and does not identify it.

Source

pub fn organization_identifier( &self, execution: &Memory, ) -> Result<Option<&Attribute<'a>>>

The organization identifier, which is how a legal entity is identified rather than described, and is the attribute an attribution decision may rest on where the common name is not.

Source

pub fn matches(&self, other: &Name<'_>, execution: &Memory) -> Result<bool>

Whether two names are the same name, by the profile’s rule: the same parts in the same order, each holding the same attributes, with strings compared ignoring case and runs of whitespace.

Strings are compared after the preparation the profile requires (RFC 5280 7.1, over RFC 4518): the characters that carry no meaning are dropped, case is folded in full, the value is normalized to form KC, and runs of space count as one between words and none at the edges. A value the profile prohibits, or one wider than the preparation is bounded to, is not prepared at all and takes part in identity as its bytes, which the profile names as a sufficient matching rule. The same holds for a value the direction step refuses.

§Errors

Returns a located resource error before unfunded comparison work.

Source

pub fn order(&self, other: &Name<'_>, execution: &Memory) -> Result<Ordering>

A total order over names that calls two of them equal exactly when Name::matches does.

It exists so that a set of names can be searched rather than walked. A caller holding many certificates and asking which one a name belongs to otherwise compares against every one of them, and comparing names is where the profile’s folding lives; ordering them once turns that into a search. Answering the same question two ways is only safe because this is the same comparison: it is built from the ordering the multiset matching already uses, not from a second reading of what identity is.

Preparation and comparison use the current execution domain. Unicode scratch storage is released when this comparison returns.

§Errors

Returns a located resource error before unfunded preparation or comparison.

Source

pub fn ordered(&self, execution: &Memory) -> Result<Ordered<'a>>

Prepares this name once for repeated comparisons.

Encoded values remain borrowed. Sorted descriptors and any Unicode canonical text retain their storage charge until this result is dropped. Comparisons subsequently use the execution domain passed to them.

§Errors

Returns a located resource error if preparation cannot be financed.

Source

pub fn starts_with(&self, base: &Name<'_>, execution: &Memory) -> Result<bool>

Whether this name sits below another one: the parts of the other, in order, from the top down, and anything at all after them.

This is the containment a name-constraint subtree asks about, where the base “specifies a subtree of the X.500 directory tree” and a name is within it when it begins with the base (RFC 5280 4.2.1.10). A base of no parts is the root of the tree and holds every name. Parts are compared by the rule identity uses, so a name sits below itself.

§Errors

Returns a located resource error before unfunded prefix preparation.

Trait Implementations§

Source§

impl<'a> Debug for Name<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for Name<'a>

§

impl<'a> RefUnwindSafe for Name<'a>

§

impl<'a> Send for Name<'a>

§

impl<'a> Sync for Name<'a>

§

impl<'a> Unpin for Name<'a>

§

impl<'a> UnsafeUnpin for Name<'a>

§

impl<'a> UnwindSafe for Name<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.