Writer

Struct Writer 

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

ASN.1 DER Writer to a mutable buffer

Implementations§

Source§

impl<'a> Writer<'a>

Source

pub fn new(buf: &'a mut [u8]) -> Self

create a new DER writer, with the buffer as the user allocated write buffer

Source

pub fn bool(&mut self, b: bool) -> Result<(), Error>

Write a boolean to the DER writer

Source

pub fn integer<'b>(&mut self, integer: &'b Integer) -> Result<(), Error>

Write an Integer to the DER writer

Source

pub fn enumerated<'b>( &mut self, enumerated: &'b Enumerated, ) -> Result<(), Error>

Write an Enumerated to the DER writer

Source

pub fn bitstring<'b>(&mut self, obj: &'b BitString) -> Result<(), Error>

Write a bitstring to the DER writer

Source

pub fn octetstring<'b>(&mut self, obj: &'b [u8]) -> Result<(), Error>

Write a octetstring to the DER writer

Source

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

Write a null to the DER writer

Source

pub fn utf8_string<'b>(&mut self, str: &'b str) -> Result<(), Error>

Write a utf8 string to the DER writer

Source

pub fn sequence<F>(&mut self, f: F) -> Result<(), Error>
where F: Fn(&mut Self) -> Result<(), Error>,

Write a sequence to the DER writer

Source

pub fn current_position(&self) -> usize

Get the current position in the Writer, which is also the number of byte written

Source

pub fn finish<'b: 'a>(&'b self) -> &'a [u8]

Return the inner sub-slice with a valid DER stream of data

Auto Trait Implementations§

§

impl<'a> Freeze for Writer<'a>

§

impl<'a> RefUnwindSafe for Writer<'a>

§

impl<'a> Send for Writer<'a>

§

impl<'a> Sync for Writer<'a>

§

impl<'a> Unpin for Writer<'a>

§

impl<'a> !UnwindSafe for Writer<'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
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>,

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.