Struct derp::Der

source ·
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>

source

pub fn new(writer: &'a mut W) -> Self

Create a new Der structure that writes values to the given writer.

source

pub fn null(&mut self) -> Result<()>

Write a NULL tag.

source

pub fn element(&mut self, tag: Tag, input: &[u8]) -> Result<()>

Write an arbitrary element.

source

pub fn integer(&mut self, input: &[u8]) -> Result<()>

Write the given input as an integer.

source

pub fn positive_integer(&mut self, input: &[u8]) -> Result<()>

Write the given input as a positive integer.

source

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.

source

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.

source

pub fn oid(&mut self, input: &[u8]) -> Result<()>

Write an OBJECT IDENTIFIER.

source

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.

source

pub fn bit_string(&mut self, unused_bits: u8, bit_string: &[u8]) -> Result<()>

Write a BIT STRING.

source

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.