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,
) -> Self
pub const fn new( class: Class, constructed: bool, tag: Tag, length: Length, ) -> Self
Build a new BER/DER header from the provided values
Sourcepub const fn new_simple(tag: Tag) -> Self
pub const fn new_simple(tag: Tag) -> Self
Build a new BER/DER header from the provided tag, with default values for other fields
Sourcepub fn with_class(self, class: Class) -> Self
pub fn with_class(self, class: Class) -> Self
Set the class of this Header
Sourcepub fn with_constructed(self, constructed: bool) -> Self
pub fn with_constructed(self, constructed: bool) -> Self
Set the constructed flags of this Header
Sourcepub fn with_length(self, length: Length) -> Self
pub fn with_length(self, length: Length) -> Self
Set the length of this Header
Sourcepub fn with_raw_tag(self, raw_tag: Option<Cow<'a, [u8]>>) -> Self
pub fn with_raw_tag(self, raw_tag: Option<Cow<'a, [u8]>>) -> Self
Update header to add reference to raw tag
Sourcepub fn with_raw_header(self, raw_header: Option<Input<'a>>) -> Self
pub fn with_raw_header(self, raw_header: Option<Input<'a>>) -> Self
Update header to add reference to raw header
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 fn raw_header(&self) -> Option<&Input<'a>>
pub fn raw_header(&self) -> Option<&Input<'a>>
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<()>
pub const fn assert_class(&self, class: Class) -> Result<()>
Return error if class is not the expected class
Sourcepub const fn assert_tag(&self, tag: Tag) -> Result<()>
pub const fn assert_tag(&self, tag: Tag) -> Result<()>
Return error if tag is not the expected tag
Sourcepub const fn assert_primitive(&self) -> Result<()>
pub const fn assert_primitive(&self) -> Result<()>
Return error if object is not primitive (returning an Error)
Sourcepub const fn assert_primitive_inner(&self) -> Result<(), InnerError>
pub const fn assert_primitive_inner(&self) -> Result<(), InnerError>
Return error if object is not primitive (returning an InnerError)
Sourcepub const fn assert_primitive_input<'i>(
&self,
input: &Input<'i>,
) -> Result<(), BerError<Input<'i>>>
pub const fn assert_primitive_input<'i>( &self, input: &Input<'i>, ) -> Result<(), BerError<Input<'i>>>
Return error if object is not primitive (returning a BerError)
Sourcepub const fn assert_constructed(&self) -> Result<()>
pub const fn assert_constructed(&self) -> Result<()>
Return error if object is primitive
Sourcepub const fn assert_constructed_inner(&self) -> Result<(), InnerError>
pub const fn assert_constructed_inner(&self) -> Result<(), InnerError>
Return error if object is primitive
Sourcepub const fn assert_constructed_input<'i>(
&self,
input: &Input<'i>,
) -> Result<(), BerError<Input<'i>>>
pub const fn assert_constructed_input<'i>( &self, input: &Input<'i>, ) -> Result<(), BerError<Input<'i>>>
Return error if object is primitive (returning a BerError)
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<()>
pub const fn assert_definite(&self) -> Result<()>
Return error if object length is definite
Sourcepub const fn assert_definite_inner(&self) -> Result<(), InnerError>
pub const fn assert_definite_inner(&self) -> Result<(), InnerError>
Return error if object length is definite
Trait Implementations§
Source§impl<'i> BerParser<'i> for Header<'i>
impl<'i> BerParser<'i> for Header<'i>
Source§fn from_ber_content(
header: &Header<'i>,
input: Input<'i>,
) -> IResult<Input<'i>, Self, Self::Error>
fn from_ber_content( header: &Header<'i>, input: Input<'i>, ) -> IResult<Input<'i>, Self, Self::Error>
Source§fn parse_ber(input: Input<'i>) -> IResult<Input<'i>, Self, Self::Error>
fn parse_ber(input: Input<'i>) -> IResult<Input<'i>, Self, Self::Error>
fn parse_ber_optional( input: Input<'i>, ) -> IResult<Input<'i>, Option<Self>, Self::Error>
Source§impl<'i> DerParser<'i> for Header<'i>
impl<'i> DerParser<'i> for Header<'i>
Source§fn from_der_content(
header: &Header<'i>,
input: Input<'i>,
) -> IResult<Input<'i>, Self, Self::Error>
fn from_der_content( header: &Header<'i>, input: Input<'i>, ) -> IResult<Input<'i>, Self, Self::Error>
Source§fn parse_der(input: Input<'i>) -> IResult<Input<'i>, Self, Self::Error>
fn parse_der(input: Input<'i>) -> IResult<Input<'i>, Self, Self::Error>
fn parse_der_optional( input: Input<'i>, ) -> IResult<Input<'i>, Option<Self>, Self::Error>
Source§impl DynTagged for Header<'_>
impl DynTagged for Header<'_>
Source§fn constructed(&self) -> bool
fn constructed(&self) -> bool
true if the object is constructedSource§impl<'a> FromBer<'a> for Header<'a>
impl<'a> FromBer<'a> for Header<'a>
Source§fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self>
fn from_ber(bytes: &'a [u8]) -> ParseResult<'a, Self>
Source§impl<'a> FromDer<'a> for Header<'a>
impl<'a> FromDer<'a> for Header<'a>
Source§fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self>
fn from_der(bytes: &'a [u8]) -> ParseResult<'a, Self>
Source§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)
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)
Source§impl ToBer for Header<'_>
impl ToBer for Header<'_>
type Encoder = BerGenericEncoder
Source§fn ber_content_len(&self) -> Length
fn ber_content_len(&self) -> Length
Source§fn ber_write_content<W: Write>(&self, _: &mut W) -> SerializeResult<usize>
fn ber_write_content<W: Write>(&self, _: &mut W) -> SerializeResult<usize>
target Read moreSource§fn ber_tag_info(&self) -> (Class, bool, Tag)
fn ber_tag_info(&self) -> (Class, bool, Tag)
Source§fn ber_total_len(&self) -> Length
fn ber_total_len(&self) -> Length
Source§fn ber_write_header<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
fn ber_write_header<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
target Read moreSource§fn ber_encode<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
fn ber_encode<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
target Read moreSource§fn ber_encode_tagged_explicit<W: Write>(
&self,
class: Class,
tag_number: u32,
target: &mut W,
) -> SerializeResult<usize>
fn ber_encode_tagged_explicit<W: Write>( &self, class: Class, tag_number: u32, target: &mut W, ) -> SerializeResult<usize>
target Read moreSource§fn ber_encode_tagged_implicit<W: Write>(
&self,
class: Class,
tag_number: u32,
target: &mut W,
) -> SerializeResult<usize>
fn ber_encode_tagged_implicit<W: Write>( &self, class: Class, tag_number: u32, target: &mut W, ) -> SerializeResult<usize>
target Read moreSource§fn to_ber_vec(&self) -> SerializeResult<Vec<u8>>
fn to_ber_vec(&self) -> SerializeResult<Vec<u8>>
Vec<u8>Source§impl ToDer for Header<'_>
impl ToDer for Header<'_>
type Encoder = BerGenericEncoder
Source§fn der_content_len(&self) -> Length
fn der_content_len(&self) -> Length
Source§fn der_write_content<W: Write>(&self, _: &mut W) -> SerializeResult<usize>
fn der_write_content<W: Write>(&self, _: &mut W) -> SerializeResult<usize>
target Read moreSource§fn der_tag_info(&self) -> (Class, bool, Tag)
fn der_tag_info(&self) -> (Class, bool, Tag)
Source§fn der_total_len(&self) -> Length
fn der_total_len(&self) -> Length
Source§fn der_write_header<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
fn der_write_header<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
target Read moreSource§fn der_encode<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
fn der_encode<W: Write>(&self, target: &mut W) -> SerializeResult<usize>
target Read moreSource§fn der_encode_tagged_explicit<W: Write>(
&self,
class: Class,
tag_number: u32,
target: &mut W,
) -> SerializeResult<usize>
fn der_encode_tagged_explicit<W: Write>( &self, class: Class, tag_number: u32, target: &mut W, ) -> SerializeResult<usize>
target Read moreSource§fn der_encode_tagged_implicit<W: Write>(
&self,
class: Class,
tag_number: u32,
target: &mut W,
) -> SerializeResult<usize>
fn der_encode_tagged_implicit<W: Write>( &self, class: Class, tag_number: u32, target: &mut W, ) -> SerializeResult<usize>
target Read moreSource§fn to_der_vec(&self) -> SerializeResult<Vec<u8>>
fn to_der_vec(&self) -> SerializeResult<Vec<u8>>
Vec<u8>Source§fn write_der<W: Write>(&self, writer: &mut W) -> SerializeResult<usize>
fn write_der<W: Write>(&self, writer: &mut W) -> SerializeResult<usize>
target Read moreSource§fn to_der_len(&self) -> Result<usize>
fn to_der_len(&self) -> Result<usize>
der_total_len() instead.Source§fn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>
fn to_der_vec_raw(&self) -> SerializeResult<Vec<u8>>
to_der_vec() instead.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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: BerParser<'a, Error = E>,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: BerParser<'a, Error = E>,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: BerParser<'a, Error = E>,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: BerParser<'a, Error = E>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.