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>
impl<'a> Name<'a>
Sourcepub fn as_bytes(&self) -> &'a [u8] ⓘ
pub fn as_bytes(&self) -> &'a [u8] ⓘ
The name exactly as it was encoded, which is what identity is.
Sourcepub fn parts(&self) -> &[RelativeName<'a>]
pub fn parts(&self) -> &[RelativeName<'a>]
The parts, outermost first, as the certificate wrote them.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn try_copy(&self, execution: &Memory) -> Result<Self>
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.
Sourcepub fn attributes(&self) -> impl Iterator<Item = &Attribute<'a>>
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.
Sourcepub fn attributes_of<'n, 'q>(
&'n self,
kind: Oid<'q>,
execution: &'q Memory,
) -> impl Iterator<Item = Result<&'n Attribute<'a>>> + 'qwhere
'n: 'q,
pub fn attributes_of<'n, 'q>(
&'n self,
kind: Oid<'q>,
execution: &'q Memory,
) -> impl Iterator<Item = Result<&'n Attribute<'a>>> + 'qwhere
'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.
Sourcepub fn attribute(
&self,
kind: Oid<'_>,
execution: &Memory,
) -> Result<Option<&Attribute<'a>>>
pub fn attribute( &self, kind: Oid<'_>, execution: &Memory, ) -> Result<Option<&Attribute<'a>>>
The first attribute of one kind.
Sourcepub fn common_name(&self, execution: &Memory) -> Result<Option<&Attribute<'a>>>
pub fn common_name(&self, execution: &Memory) -> Result<Option<&Attribute<'a>>>
The common name, which describes the subject and does not identify it.
Sourcepub fn organization_identifier(
&self,
execution: &Memory,
) -> Result<Option<&Attribute<'a>>>
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.
Sourcepub fn matches(&self, other: &Name<'_>, execution: &Memory) -> Result<bool>
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.
Sourcepub fn order(&self, other: &Name<'_>, execution: &Memory) -> Result<Ordering>
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.
Sourcepub fn ordered(&self, execution: &Memory) -> Result<Ordered<'a>>
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.
Sourcepub fn starts_with(&self, base: &Name<'_>, execution: &Memory) -> Result<bool>
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.