Skip to main content

X690Element

Struct X690Element 

Source
pub struct X690Element {
    pub tag: Tag,
    pub value: X690Value,
}
Expand description

Represents a complete X.690 encoded element with tag and value

An X690Element contains a tag that identifies the type and class of the element, and a value that contains the actual data. The value can be primitive (raw bytes), constructed (containing child elements), or serialized (encoded bytes).

Fields§

§tag: Tag

The tag identifying the type and class of this element

§value: X690Value

The value content of this element

Implementations§

Source§

impl X690Element

Source

pub const fn new(tag: Tag, value: X690Value) -> X690Element

Creates a new X690Element with the specified tag and value

Source

pub const fn null() -> X690Element

Make a new NULL encoding.

Source

pub const fn boolean_true() -> X690Element

Make a new TRUE encoding.

Source

pub const fn boolean_false() -> X690Element

Make a new FALSE encoding.

Source

pub fn len(&self) -> usize

Returns the total length of this element in bytes when encoded

This includes the tag bytes, length bytes, and value bytes.

Source

pub fn is_constructed(&self) -> bool

Returns true if this element is constructed (contains child elements)

For serialized values, this checks the constructed bit in the tag. For constructed values, this always returns true. For primitive values, this always returns false.

Source

pub fn components(&self) -> ASN1Result<Arc<Vec<X690Element>>>

Returns the components of this element if it is constructed

This is a convenience method that delegates to the value’s X690Value::components method.

Source

pub fn inner(&self) -> ASN1Result<X690Element>

Returns the inner element if this is an explicit wrapper

For explicit tagged values, this returns the single child element. For other values, this returns an error.

Source

pub fn content_octets<'a>(&'a self) -> ASN1Result<Cow<'a, [u8]>>

Returns the content octets of this element

For primitive values, returns the raw bytes. For constructed values, serializes the child elements and returns the bytes. For serialized values, decodes and returns the content octets.

Source

pub fn to_asn1_error(&self, errcode: ASN1ErrorCode) -> ASN1Error

Creates an ASN1Error with information from this element

This is useful for creating detailed error messages that include information about the element that caused the error.

Source

pub fn to_asn1_err_named(&self, errcode: ASN1ErrorCode, name: &str) -> ASN1Error

Creates an ASN1Error with information from this element and a component name

This is useful for creating detailed error messages that include information about the element and the specific component that caused the error.

Source

pub fn is_empty(&self) -> bool

Returns true if this element is empty

For primitive values, checks if the byte length is zero. For constructed values, checks if there are no child elements. For serialized values, checks if the serialized data is minimal (just tag and length).

Source

pub fn iter_deconstruction<'a>(&'a self) -> DeconstructionIterator<'a>

Returns an iterator that iterates over the primitive content octets of the constituent elements of this element, recursively.

In other words a UTF8String encoding that is structed like so:

[UNIV 12]
    [UNIV 4] "hello"
    [UNIV 4]
        [UNIV 4] " "
    [UNIV 4] "world"

Will result in the content octets for “hello”, “ “, and “world” being returned from the iterator, in that order.

Trait Implementations§

Source§

impl Clone for X690Element

Source§

fn clone(&self) -> X690Element

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 X690Element

Source§

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

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

impl Eq for X690Element

Source§

impl From<&OBJECT_IDENTIFIER> for X690Element

Source§

fn from(value: &OBJECT_IDENTIFIER) -> Self

Converts a reference to an OBJECT_IDENTIFIER to an X690Element by encoding it

Source§

impl From<DATE> for X690Element

Source§

fn from(value: DATE) -> Self

Converts a DATE to an X690Element by encoding it

Source§

impl From<DATE_TIME> for X690Element

Source§

fn from(value: DATE_TIME) -> Self

Converts a DATE_TIME to an X690Element by encoding it

Source§

impl From<DURATION_EQUIVALENT> for X690Element

Source§

fn from(value: DURATION) -> Self

Converts a DURATION to an X690Element by encoding it

Source§

impl From<OBJECT_IDENTIFIER> for X690Element

Source§

fn from(value: OBJECT_IDENTIFIER) -> Self

Converts an OBJECT_IDENTIFIER to an X690Element by encoding it

Source§

impl From<String> for X690Element

Source§

fn from(value: TIME) -> Self

Converts a TIME to an X690Element by encoding it

Source§

impl From<TIME_OF_DAY> for X690Element

Source§

fn from(value: TIME_OF_DAY) -> Self

Converts a TIME_OF_DAY to an X690Element by encoding it

Source§

impl From<bool> for X690Element

Source§

fn from(value: bool) -> Self

Converts a bool to an X690Element by encoding it as a BOOLEAN

Source§

impl From<i8> for X690Element

Source§

fn from(value: i8) -> Self

Converts an i8 to an X690Element by encoding it as an INTEGER

Source§

impl From<i16> for X690Element

Source§

fn from(value: i16) -> Self

Converts an i16 to an X690Element by encoding it as an INTEGER

Source§

impl From<i32> for X690Element

Source§

fn from(value: i32) -> Self

Converts an i32 to an X690Element by encoding it as an INTEGER

Source§

impl From<i64> for X690Element

Source§

fn from(value: i64) -> Self

Converts an i64 to an X690Element by encoding it as an INTEGER

Source§

impl From<u8> for X690Element

Source§

fn from(value: u8) -> Self

Converts a u8 to an X690Element by encoding it as an INTEGER

Source§

impl From<u16> for X690Element

Source§

fn from(value: u16) -> Self

Converts a u16 to an X690Element by encoding it as an INTEGER

Source§

impl From<u32> for X690Element

Source§

fn from(value: u32) -> Self

Converts a u32 to an X690Element by encoding it as an INTEGER

Source§

impl From<u64> for X690Element

Source§

fn from(value: u64) -> Self

Converts a u64 to an X690Element by encoding it as an INTEGER

Source§

impl Hash for X690Element

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for X690Element

Source§

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

Compares two X690Elements for equality

For serialized values, this decodes them first before comparison. Primitive values are compared by their raw bytes. Constructed values are compared by their child elements.

1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryInto<bool> for X690Element

Source§

fn try_into(self) -> ASN1Result<BOOLEAN>

Attempts to decode an X690Element as a BOOLEAN

Source§

type Error = ASN1Error

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

impl TryInto<i8> for X690Element

Source§

fn try_into(self) -> ASN1Result<i8>

Attempts to decode an X690Element as an i8 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<i16> for X690Element

Source§

fn try_into(self) -> ASN1Result<i16>

Attempts to decode an X690Element as an i16 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<i32> for X690Element

Source§

fn try_into(self) -> ASN1Result<i32>

Attempts to decode an X690Element as an i32 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<i64> for X690Element

Source§

fn try_into(self) -> ASN1Result<i64>

Attempts to decode an X690Element as an i64 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<i128> for X690Element

Source§

fn try_into(self) -> ASN1Result<i128>

Attempts to decode an X690Element as an i128 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<u8> for X690Element

Source§

fn try_into(self) -> ASN1Result<u8>

Attempts to decode an X690Element as a u8 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<u16> for X690Element

Source§

fn try_into(self) -> ASN1Result<u16>

Attempts to decode an X690Element as a u16 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<u32> for X690Element

Source§

fn try_into(self) -> ASN1Result<u32>

Attempts to decode an X690Element as a u32 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<u64> for X690Element

Source§

fn try_into(self) -> ASN1Result<u64>

Attempts to decode an X690Element as a u64 INTEGER

Source§

type Error = ASN1Error

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

impl TryInto<u128> for X690Element

Source§

fn try_into(self) -> ASN1Result<u128>

Attempts to decode an X690Element as a u128 INTEGER

Source§

type Error = ASN1Error

The type returned in the event of a conversion error.

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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.