Struct der_parser::der::Header
source · pub struct Header<'a> { /* private fields */ }
Expand description
BER/DER object header (identifier and length)
Implementations§
source§impl<'a> Header<'a>
impl<'a> Header<'a>
sourcepub const fn new(
class: Class,
constructed: bool,
tag: Tag,
length: Length
) -> Header<'a>
pub const fn new( class: Class, constructed: bool, tag: Tag, length: Length ) -> Header<'a>
Build a new BER/DER header from the provided values
sourcepub const fn new_simple(tag: Tag) -> Header<'a>
pub const fn new_simple(tag: Tag) -> Header<'a>
Build a new BER/DER header from the provided tag, with default values for other fields
sourcepub fn with_class(self, class: Class) -> Header<'a>
pub fn with_class(self, class: Class) -> Header<'a>
Set the class of this Header
sourcepub fn with_constructed(self, constructed: bool) -> Header<'a>
pub fn with_constructed(self, constructed: bool) -> Header<'a>
Set the constructed flags of this Header
sourcepub fn with_length(self, length: Length) -> Header<'a>
pub fn with_length(self, length: Length) -> Header<'a>
Set the length of this Header
sourcepub fn with_raw_tag(self, raw_tag: Option<Cow<'a, [u8]>>) -> Header<'a>
pub fn with_raw_tag(self, raw_tag: Option<Cow<'a, [u8]>>) -> Header<'a>
Update header to add reference to raw tag
sourcepub const fn constructed(&self) -> bool
pub const fn constructed(&self) -> bool
Return true if this header has the ‘constructed’ flag.
sourcepub fn raw_tag(&self) -> Option<&[u8]>
pub fn raw_tag(&self) -> Option<&[u8]>
Return the raw tag encoding, if it was stored in this object
sourcepub const fn is_primitive(&self) -> bool
pub const fn is_primitive(&self) -> bool
Test if object is primitive
sourcepub const fn is_constructed(&self) -> bool
pub const fn is_constructed(&self) -> bool
Test if object is constructed
sourcepub const fn assert_class(&self, class: Class) -> Result<(), Error>
pub const fn assert_class(&self, class: Class) -> Result<(), Error>
Return error if class is not the expected class
sourcepub const fn assert_tag(&self, tag: Tag) -> Result<(), Error>
pub const fn assert_tag(&self, tag: Tag) -> Result<(), Error>
Return error if tag is not the expected tag
sourcepub const fn assert_primitive(&self) -> Result<(), Error>
pub const fn assert_primitive(&self) -> Result<(), Error>
Return error if object is not primitive
sourcepub const fn assert_constructed(&self) -> Result<(), Error>
pub const fn assert_constructed(&self) -> Result<(), Error>
Return error if object is primitive
sourcepub const fn is_universal(&self) -> bool
pub const fn is_universal(&self) -> bool
Test if object class is Universal
sourcepub const fn is_application(&self) -> bool
pub const fn is_application(&self) -> bool
Test if object class is Application
sourcepub const fn is_contextspecific(&self) -> bool
pub const fn is_contextspecific(&self) -> bool
Test if object class is Context-specific
sourcepub const fn is_private(&self) -> bool
pub const fn is_private(&self) -> bool
Test if object class is Private
sourcepub const fn assert_definite(&self) -> Result<(), Error>
pub const fn assert_definite(&self) -> Result<(), Error>
Return error if object length is definite
Trait Implementations§
source§impl<'a> PartialEq<Header<'a>> for Header<'a>
impl<'a> PartialEq<Header<'a>> for Header<'a>
Compare two BER headers. len
fields are compared only if both objects have it set (same for raw_tag
)
source§impl ToDer for Header<'_>
impl ToDer for Header<'_>
source§fn to_der_len(&self) -> Result<usize, Error>
fn to_der_len(&self) -> Result<usize, Error>
source§fn write_der_header(
&self,
writer: &mut dyn Write
) -> Result<usize, SerializeError>
fn write_der_header( &self, writer: &mut dyn Write ) -> Result<usize, SerializeError>
source§fn write_der_content(
&self,
_writer: &mut dyn Write
) -> Result<usize, SerializeError>
fn write_der_content( &self, _writer: &mut dyn Write ) -> Result<usize, SerializeError>
source§fn write_der_raw(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>
fn write_der_raw(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>
to_der
, but uses provided values without changes.
This can generate an invalid encoding for a DER object.source§fn to_der_vec(&self) -> Result<Vec<u8, Global>, SerializeError>
fn to_der_vec(&self) -> Result<Vec<u8, Global>, SerializeError>
Vec<u8>
.source§fn to_der_vec_raw(&self) -> Result<Vec<u8, Global>, SerializeError>
fn to_der_vec_raw(&self) -> Result<Vec<u8, Global>, SerializeError>
to_vec
, but uses provided values without changes.
This can generate an invalid encoding for a DER object.