Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

DirectoryString

Enum DirectoryString 

Source
pub enum DirectoryString {
    PrintableString(PrintableString),
    TeletexString(TeletexString),
    Utf8String(String),
    BmpString(BmpString),
}
Expand description

DirectoryString as defined in RFC 5280 Section 4.2.1.4.

ASN.1 structure for DirectoryString is below.

DirectoryString ::= CHOICE {
    teletexString           TeletexString (SIZE (1..MAX)),
    printableString         PrintableString (SIZE (1..MAX)),
    universalString         UniversalString (SIZE (1..MAX)),
    utf8String              UTF8String (SIZE (1..MAX)),
    bmpString               BMPString (SIZE (1..MAX))
}

Further, RFC 5280 Section 4.2.1.4 states:

The DirectoryString type is defined as a choice of PrintableString,
TeletexString, BMPString, UTF8String, and UniversalString.  CAs
conforming to this profile MUST use either the PrintableString or
UTF8String encoding of DirectoryString, with two exceptions.  When
CAs have previously issued certificates with issuer fields with
attributes encoded using TeletexString, BMPString, or
UniversalString, then the CA MAY continue to use these encodings of
the DirectoryString to preserve backward compatibility.  Also, new
CAs that are added to a domain where existing CAs issue certificates
with issuer fields with attributes encoded using TeletexString,
BMPString, or UniversalString MAY encode attributes that they share
with the existing CAs using the same encodings as the existing CAs
use.

The implication of the above paragraph is that PrintableString and UTF8String are the new types and the other types are legacy. Until the need arises, we only support PrintableString and UTF8String.

Variants§

§

PrintableString(PrintableString)

§

TeletexString(TeletexString)

§

Utf8String(String)

§

BmpString(BmpString)

Implementations§

Source§

impl DirectoryString

Source

pub fn value(&self) -> Cow<'_, str>

Returns Borrowed variant for UTF-8 compatible strings and Owned variant otherwise.

Source

pub fn as_ref(&self) -> &str

👎Deprecated since 0.3.0-pre.0:

use DirectoryString::value instead

Returns &str for PrintableString, TeletexString and Utf8String

Warning: Returns "" empty string for DirectoryString::BmpString variant

Trait Implementations§

Source§

impl<'__der_lifetime> Choice<'__der_lifetime> for DirectoryString

Source§

fn can_decode(tag: Tag) -> bool

Is the provided Tag decodable as a variant of this CHOICE?
Source§

impl Clone for DirectoryString

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectoryString

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'__der_lifetime> Decode<'__der_lifetime> for DirectoryString

Source§

type Error = Error

Type returned in the event of a decoding error.
Source§

fn decode<R: Reader<'__der_lifetime>>(reader: &mut R) -> Result<Self, Error>

Attempt to decode this TLV message using the provided decoder. Read more
Source§

fn from_der(bytes: &'a [u8]) -> Result<Self, Self::Error>

Parse Self from the provided DER-encoded byte slice. Read more
Source§

fn from_der_partial(bytes: &'a [u8]) -> Result<(Self, &'a [u8]), Self::Error>

Parse Self from the provided DER-encoded byte slice. Read more
Source§

impl<'__der_lifetime> DecodeValue<'__der_lifetime> for DirectoryString

Source§

type Error = Error

Type returned in the event of a decoding error.
Source§

fn decode_value<R: Reader<'__der_lifetime>>( reader: &mut R, header: Header, ) -> Result<Self, Error>

Attempt to decode this value using the provided Reader. Read more
Source§

impl<'__der_lifetime> EncodeValue for DirectoryString

Source§

fn encode_value(&self, encoder: &mut impl Writer) -> Result<()>

Encode value (sans [Tag]+Length header) as ASN.1 DER using the provided Writer. Read more
Source§

fn value_len(&self) -> Result<Length>

Compute the length of this value (sans [Tag]+Length header) when encoded as ASN.1 DER. Read more
Source§

fn header(&self) -> Result<Header, Error>
where Self: Tagged,

Get the Header used to encode this value. Read more
Source§

impl Eq for DirectoryString

Source§

impl From<DirectoryString> for String

Source§

fn from(value: DirectoryString) -> Self

Converts to this type from the input type.
Source§

impl<'__der_lifetime> IsConstructed for DirectoryString

Source§

const CONSTRUCTED: bool = true

ASN.1 constructed bit
Source§

impl PartialEq for DirectoryString

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DirectoryString

Source§

impl<'__der_lifetime> Tagged for DirectoryString

Source§

fn tag(&self) -> Tag

Get the ASN.1 tag that this type is encoded with.
Source§

impl<'a> TryFrom<&'a Any> for DirectoryString

Source§

type Error = Error

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

fn try_from(any: &'a Any) -> Result<Self>

Performs the conversion.
Source§

impl ValueOrd for DirectoryString

Source§

fn value_cmp(&self, other: &Self) -> Result<Ordering>

Return an Ordering between value portion of TLV-encoded self and other when serialized as ASN.1 DER. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DecodeOwned for T
where T: for<'a> Decode<'a>,

Source§

impl<T> DerOrd for T

Source§

fn der_cmp(&self, other: &T) -> Result<Ordering, Error>

Return an Ordering between self and other when serialized as ASN.1 DER. Read more
Source§

impl<T> Encode for T
where T: EncodeValue + Tagged + ?Sized,

Source§

fn encoded_len(&self) -> Result<Length, Error>

Compute the length of this TLV object in bytes when encoded as ASN.1 DER. Read more
Source§

fn encode(&self, writer: &mut impl Writer) -> Result<(), Error>

Encode this TLV object as ASN.1 DER using the provided Writer. Read more
Source§

fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>

Encode this TLV object to the provided byte slice, returning a sub-slice containing the encoded message. Read more
Source§

fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length, Error>

Encode this TLV object as ASN.1 DER, appending it to the provided byte vector. Read more
Source§

fn to_der(&self) -> Result<Vec<u8>, Error>

Encode this TLV object as ASN.1 DER, returning a byte vector. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.