Struct Header

pub struct Header<'a> { /* private fields */ }
Expand description

BER/DER object header (identifier and length)

Implementations§

§

impl<'a> 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

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

pub fn with_class(self, class: Class) -> Header<'a>

Set the class of this Header

pub fn with_constructed(self, constructed: bool) -> Header<'a>

Set the constructed flags of this Header

pub fn with_tag(self, tag: Tag) -> Header<'a>

Set the tag of this Header

pub fn with_length(self, length: Length) -> Header<'a>

Set the length of this Header

pub fn with_raw_tag(self, raw_tag: Option<Cow<'a, [u8]>>) -> Header<'a>

Update header to add reference to raw tag

pub const fn class(&self) -> Class

Return the class of this header.

pub const fn constructed(&self) -> bool

Return true if this header has the ‘constructed’ flag.

pub const fn tag(&self) -> Tag

Return the tag of this header.

pub const fn length(&self) -> Length

Return the length of this header.

pub fn raw_tag(&self) -> Option<&[u8]>

Return the raw tag encoding, if it was stored in this object

pub const fn is_primitive(&self) -> bool

Test if object is primitive

pub const fn is_constructed(&self) -> bool

Test if object is constructed

pub const fn assert_class(&self, class: Class) -> Result<(), Error>

Return error if class is not the expected class

pub const fn assert_tag(&self, tag: Tag) -> Result<(), Error>

Return error if tag is not the expected tag

pub const fn assert_primitive(&self) -> Result<(), Error>

Return error if object is not primitive

pub const fn assert_constructed(&self) -> Result<(), Error>

Return error if object is primitive

pub const fn is_universal(&self) -> bool

Test if object class is Universal

pub const fn is_application(&self) -> bool

Test if object class is Application

pub const fn is_contextspecific(&self) -> bool

Test if object class is Context-specific

pub const fn is_private(&self) -> bool

Test if object class is Private

pub const fn assert_definite(&self) -> Result<(), Error>

Return error if object length is definite

pub fn parse_ber_content<'i>( &self, i: &'i [u8], ) -> Result<(&'i [u8], &'i [u8]), Err<Error>>

Get the content following a BER header

pub fn parse_der_content<'i>( &self, i: &'i [u8], ) -> Result<(&'i [u8], &'i [u8]), Err<Error>>

Get the content following a DER header

Trait Implementations§

§

impl<'a> Clone for Header<'a>

§

fn clone(&self) -> Header<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl<'a> Debug for Header<'a>

§

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

Formats the value using the given formatter. Read more
§

impl DynTagged for Header<'_>

§

fn tag(&self) -> Tag

§

impl From<Tag> for Header<'_>

§

fn from(tag: Tag) -> Header<'_>

Converts to this type from the input type.
§

impl<'a> FromBer<'a> for Header<'a>

§

fn from_ber(bytes: &'a [u8]) -> Result<(&'a [u8], Header<'a>), Err<Error>>

Attempt to parse input bytes into a BER object
§

impl<'a> FromDer<'a> for Header<'a>

§

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

Attempt to parse input bytes into a DER object (enforcing constraints)
§

impl<'a> PartialEq for Header<'a>

Compare two BER headers. len fields are compared only if both objects have it set (same for raw_tag)

§

fn eq(&self, other: &Header<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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.
§

impl ToDer for Header<'_>

§

fn to_der_len(&self) -> Result<usize, Error>

Get the length of the object (including the header), when encoded
§

fn write_der_header( &self, writer: &mut dyn Write, ) -> Result<usize, SerializeError>

Attempt to write the DER header to this writer.
§

fn write_der_content( &self, _writer: &mut dyn Write, ) -> Result<usize, SerializeError>

Attempt to write the DER content (all except header) to this writer.
§

fn write_der_raw(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>

Similar to using to_der, but uses provided values without changes. This can generate an invalid encoding for a DER object.
§

fn to_der_vec(&self) -> Result<Vec<u8>, SerializeError>

Write the DER encoded representation to a newly allocated Vec<u8>.
§

fn to_der_vec_raw(&self) -> Result<Vec<u8>, SerializeError>

Similar to using to_vec, but uses provided values without changes. This can generate an invalid encoding for a DER object.
§

fn write_der(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>

Attempt to write the DER encoded representation (header and content) into this writer. Read more
§

impl ToStatic for Header<'_>

§

type Owned = Header<'static>

§

fn to_static(&self) -> <Header<'_> as ToStatic>::Owned

§

impl Eq for Header<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Header<'a>

§

impl<'a> RefUnwindSafe for Header<'a>

§

impl<'a> Send for Header<'a>

§

impl<'a> Sync for Header<'a>

§

impl<'a> Unpin for Header<'a>

§

impl<'a> UnwindSafe for Header<'a>

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
§

impl<T, U> RamaInto<U> for T
where U: RamaFrom<T>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaInto<U> for T
where U: RamaFrom<T>,

§

fn rama_into(self) -> U

§

impl<T, U> RamaTryInto<U> for T
where U: RamaTryFrom<T>,

§

type Error = <U as RamaTryFrom<T>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>

§

impl<T, U> RamaTryInto<U> for T
where U: RamaTryFrom<T>,

§

type Error = <U as RamaTryFrom<T>>::Error

§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T>>::Error>

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 = 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,