pub struct Name<'a> { /* private fields */ }Expand description
A distinguished name, as the sequence of parts the certificate holds.
Implementations§
Source§impl Name<'_>
impl Name<'_>
Sourcepub fn rfc4514(&self, execution: &Memory) -> Result<OwnedString>
pub fn rfc4514(&self, execution: &Memory) -> Result<OwnedString>
Formats a reversible RFC 4514 name, preserving every original value
as #BER. Types use registered descriptors or exact numeric OIDs; RDN order
is reversed as required by RFC 4514 §2.1. No value is truncated.
The returned string independently retains its storage charge.
Sourcepub fn rfc4514_readable(&self, execution: &Memory) -> Result<OwnedString>
pub fn rfc4514_readable(&self, execution: &Memory) -> Result<OwnedString>
Formats a complete readable RFC 4514 name. Known, fully decoded
attribute syntax uses escaped text; unknown/nontext values use
original #BER. Text follows the declared attribute syntax; matching
remains a separate fallible operation. This form does not preserve
the original ASN.1 string tag or promise a canonical identity string.
This convenience form is for metadata; use rfc4514 for reversibility.
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, W: Work>(
&'n self,
kind: Oid<'q>,
execution: &'q W,
) -> impl Iterator<Item = Result<&'n Attribute<'a>>> + 'qwhere
'n: 'q,
pub fn attributes_of<'n, 'q, W: Work>(
&'n self,
kind: Oid<'q>,
execution: &'q W,
) -> 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<W: Work>(
&self,
kind: Oid<'_>,
execution: &W,
) -> Result<Option<&Attribute<'a>>>
pub fn attribute<W: Work>( &self, kind: Oid<'_>, execution: &W, ) -> Result<Option<&Attribute<'a>>>
The first attribute of one kind.
Sourcepub fn common_name<W: Work>(
&self,
execution: &W,
) -> Result<Option<&Attribute<'a>>>
pub fn common_name<W: Work>( &self, execution: &W, ) -> Result<Option<&Attribute<'a>>>
The common name, which describes the subject and does not identify it.
Sourcepub fn organization_identifier<W: Work>(
&self,
execution: &W,
) -> Result<Option<&Attribute<'a>>>
pub fn organization_identifier<W: Work>( &self, execution: &W, ) -> 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<W: Work>(&self, other: &Name<'_>, execution: &W) -> Result<bool>
pub fn matches<W: Work>(&self, other: &Name<'_>, execution: &W) -> 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 under their declared equality rule.
Directory 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. Unsupported types and nonconforming stored values retain their encoded identity; that preservation does not validate an LDAP assertion. Valid supported values use the schema’s size bounds and the current work/storage budget, independently of display truncation. IA5 emailAddress and domainComponent values instead use their exact ASCII case-insensitive rules without whitespace compression; the DN emailAddress rule covers the whole value, unlike rfc822Name mailboxes. Pseudonym uses caseExactMatch (RFC2985 §5.2.9): the same preparation and insignificant-space handling, with case preserved.
§Errors
Returns a located resource error before unfunded comparison work.
Sourcepub fn matches_in(
&self,
other: &Name<'_>,
parent: &Reader<'_, '_>,
) -> Result<bool>
pub fn matches_in( &self, other: &Name<'_>, parent: &Reader<'_, '_>, ) -> Result<bool>
Compares retained names under the current query reader’s execution.
Names may come from independently parsed certificates. Their storage stays on its original account; normalization/comparison scratch and deferred string decoding use the query’s local and aggregate ceilings. This is a comparison, not permission to reparse a foreign certificate.
Sourcepub fn order<W: Work>(
&self,
other: &Name<'_>,
execution: &W,
) -> Result<Ordering>
pub fn order<W: Work>( &self, other: &Name<'_>, execution: &W, ) -> 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<W: Work>(&self, execution: &W) -> Result<Ordered<'a, W>>
pub fn ordered<W: Work>(&self, execution: &W) -> Result<Ordered<'a, W>>
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 ordered_in<'p>(
&self,
parent: &'p Reader<'_, '_>,
) -> Result<Ordered<'a, Execution<'p>>>
pub fn ordered_in<'p>( &self, parent: &'p Reader<'_, '_>, ) -> Result<Ordered<'a, Execution<'p>>>
Prepares a cache inside the current producing operation’s work ceilings.
Original document values and their retained nesting depths remain intact.
Deferred BER strings use the supplied reader’s session/account instead
of a new Parser. Cache storage retains its current account; its work
owner borrows the operation independently of the document’s lifetime.
This is the same semantic order as Name::ordered, with scoped funding.
Sourcepub fn starts_with<W: Work>(
&self,
base: &Name<'_>,
execution: &W,
) -> Result<bool>
pub fn starts_with<W: Work>( &self, base: &Name<'_>, execution: &W, ) -> 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.