pub struct Der<'a, W: Write + 'a> { /* private fields */ }
Expand description
Helper for writing DER that automattically encoes tags and content lengths.
Implementations§
source§impl<'a, W: Write> Der<'a, W>
impl<'a, W: Write> Der<'a, W>
sourcepub fn new(writer: &'a mut W) -> Self
pub fn new(writer: &'a mut W) -> Self
Create a new Der
structure that writes values to the given writer.
sourcepub fn positive_integer(&mut self, input: &[u8]) -> Result<()>
pub fn positive_integer(&mut self, input: &[u8]) -> Result<()>
Write the given input as a positive integer.
sourcepub fn nested<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>(
&mut self,
tag: Tag,
func: F
) -> Result<()>
pub fn nested<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>( &mut self, tag: Tag, func: F ) -> Result<()>
Write a nested structure by passing in a handling function that writes to an intermediate
Vec
before writing the whole sequence to self
.
sourcepub fn sequence<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>(
&mut self,
func: F
) -> Result<()>
pub fn sequence<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>( &mut self, func: F ) -> Result<()>
Write a SEQUENCE
by passing in a handling function that writes to an intermediate Vec
before writing the whole sequence to self
.
sourcepub fn raw(&mut self, input: &[u8]) -> Result<()>
pub fn raw(&mut self, input: &[u8]) -> Result<()>
Write raw bytes to self
. This does not calculate length or apply. This should only be used
when you know you are dealing with bytes that are already DER encoded.
sourcepub fn bit_string(&mut self, unused_bits: u8, bit_string: &[u8]) -> Result<()>
pub fn bit_string(&mut self, unused_bits: u8, bit_string: &[u8]) -> Result<()>
Write a BIT STRING
.
sourcepub fn octet_string(&mut self, octet_string: &[u8]) -> Result<()>
pub fn octet_string(&mut self, octet_string: &[u8]) -> Result<()>
Write an OCTET STRING
.
Auto Trait Implementations§
impl<'a, W> Freeze for Der<'a, W>
impl<'a, W> RefUnwindSafe for Der<'a, W>where
W: RefUnwindSafe,
impl<'a, W> Send for Der<'a, W>where
W: Send,
impl<'a, W> Sync for Der<'a, W>where
W: Sync,
impl<'a, W> Unpin for Der<'a, W>
impl<'a, W> !UnwindSafe for Der<'a, W>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more