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: TagThe tag identifying the type and class of this element
value: X690ValueThe value content of this element
Implementations§
Source§impl X690Element
impl X690Element
Sourcepub const fn new(tag: Tag, value: X690Value) -> X690Element
pub const fn new(tag: Tag, value: X690Value) -> X690Element
Creates a new X690Element with the specified tag and value
Sourcepub const fn null() -> X690Element
pub const fn null() -> X690Element
Make a new NULL encoding.
Sourcepub const fn boolean_true() -> X690Element
pub const fn boolean_true() -> X690Element
Make a new TRUE encoding.
Sourcepub const fn boolean_false() -> X690Element
pub const fn boolean_false() -> X690Element
Make a new FALSE encoding.
Sourcepub fn len(&self) -> usize
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.
Sourcepub fn is_constructed(&self) -> bool
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.
Sourcepub fn components(&self) -> ASN1Result<Arc<Vec<X690Element>>>
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.
Sourcepub fn inner(&self) -> ASN1Result<X690Element>
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.
Sourcepub fn content_octets<'a>(&'a self) -> ASN1Result<Cow<'a, [u8]>>
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.
Sourcepub fn to_asn1_error(&self, errcode: ASN1ErrorCode) -> ASN1Error
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.
Sourcepub fn to_asn1_err_named(&self, errcode: ASN1ErrorCode, name: &str) -> ASN1Error
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.
Sourcepub fn is_empty(&self) -> bool
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).
Sourcepub fn iter_deconstruction<'a>(&'a self) -> DeconstructionIterator<'a> ⓘ
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
impl Clone for X690Element
Source§fn clone(&self) -> X690Element
fn clone(&self) -> X690Element
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for X690Element
impl Debug for X690Element
impl Eq for X690Element
Source§impl From<&OBJECT_IDENTIFIER> for X690Element
impl From<&OBJECT_IDENTIFIER> for X690Element
Source§fn from(value: &OBJECT_IDENTIFIER) -> Self
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
impl From<DATE> for X690Element
Source§impl From<DATE_TIME> for X690Element
impl From<DATE_TIME> for X690Element
Source§impl From<DURATION_EQUIVALENT> for X690Element
impl From<DURATION_EQUIVALENT> for X690Element
Source§impl From<OBJECT_IDENTIFIER> for X690Element
impl From<OBJECT_IDENTIFIER> for X690Element
Source§fn from(value: OBJECT_IDENTIFIER) -> Self
fn from(value: OBJECT_IDENTIFIER) -> Self
Converts an OBJECT_IDENTIFIER to an X690Element by encoding it
Source§impl From<String> for X690Element
impl From<String> for X690Element
Source§impl From<TIME_OF_DAY> for X690Element
impl From<TIME_OF_DAY> for X690Element
Source§fn from(value: TIME_OF_DAY) -> Self
fn from(value: TIME_OF_DAY) -> Self
Converts a TIME_OF_DAY to an X690Element by encoding it