Struct ot_certs::asn1::codegen::Codegen

source ·
pub struct Codegen<'a> { /* private fields */ }
Expand description

ASN1 code generator.

Implementations§

source§

impl Codegen<'_>

source

pub fn generate( buf_name: &str, buf_size_name: &str, indent: &str, indent_lvl: usize, constants: &mut ConstantPool, variable_info: &dyn Fn(&str) -> Result<VariableInfo>, gen: impl FnOnce(&mut Codegen<'_>) -> Result<()> ) -> Result<(String, usize)>

Generate code that corresponds to an ASN1 document described by a closure acting on a Builder. Returns the generated code and the maximum possible size of the output.

Arguments
  • buf_name - Name of the variable holding the pointer to the output buffer.
  • buf_size_name - Name of the variable holding the size of the output buffer. This variable is updated by the code to hold the actual size of the data after production.
  • indent - Identation string (one level).
  • indent_lvl - Initial identation level.
  • constants - Constant pool used to create necessary constants for the code.
  • variables - Description of the variable types used when producing the output.
  • gen - Closure generating the ASN1 document.

Trait Implementations§

source§

impl Builder for Codegen<'_>

source§

fn push_byte(&mut self, val: u8) -> Result<()>

Push a byte into the ASN1 output, the value can be any C expression.

source§

fn push_boolean(&mut self, tag: &Tag, val: &Value<bool>) -> Result<()>

Push a tagged boolean into the ASN1 output.

source§

fn push_integer( &mut self, name_hint: Option<String>, tag: &Tag, val: &Value<BigUint> ) -> Result<()>

Push a tagged integer into the ASN1 output, the buffer (a big-endian integer) and its size are arbitrary C expressions.

source§

fn push_integer_pad( &mut self, name_hint: Option<String>, val: &Value<BigUint>, size: usize ) -> Result<()>

Push a byte array into the ASN1 output, represeting an integer. If the provided buffer is too small, it will be padded with zeroes. Note that this function does not add a tag to the ASN1 output.

source§

fn push_byte_array( &mut self, name_hint: Option<String>, val: &Value<Vec<u8>> ) -> Result<()>

Push a byte array of fixed length into the ASN1 output. Note that this function does not add a tag to the ASN1 output.

source§

fn push_string( &mut self, _name_hint: Option<String>, str_type: &Tag, val: &Value<String> ) -> Result<()>

Push an optionally tagged string into the ASN1 output.

source§

fn push_bitstring<'a>( &mut self, name_hint: Option<String>, tag: &Tag, bits: &[Value<bool>] ) -> Result<()>

source§

fn push_oid(&mut self, oid: &Oid) -> Result<()>

Push a tagged object identifier into the ASN1 output.
source§

fn push_tag( &mut self, name_hint: Option<String>, tag: &Tag, gen: impl FnOnce(&mut Self) -> Result<()> ) -> Result<()>

Push tagged content into the ASN1 output. The closure can use any available function of the builder and produces the content of the tagged data.
source§

fn push_octet_string( &mut self, name_hint: Option<String>, gen: impl FnOnce(&mut Self) -> Result<()> ) -> Result<()>

Push a tagged octet string into the ASN1 output. The closure can use any available function of the builder and produces the content of the octet string.
source§

fn push_seq( &mut self, name_hint: Option<String>, gen: impl FnOnce(&mut Self) -> Result<()> ) -> Result<()>

Push a sequence into the ASN1 output. The closure can use any available function of the builder and produces the content of the sequence.
source§

fn push_set( &mut self, name_hint: Option<String>, gen: impl FnOnce(&mut Self) -> Result<()> ) -> Result<()>

Push a sequence into the ASN1 output. The closure can use any available function of the builder and produces the content of the set.
source§

fn push_as_bit_string( &mut self, name_hint: Option<String>, tag: &Tag, unused_bits: usize, gen: impl FnOnce(&mut Self) -> Result<()> ) -> Result<()>

Push tagged content into the ASN1 output as a bitstring. The closure can use any available function of the builder and the resulting content will be stored as a BITSTRING using the provided tag and unused number of bits.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Codegen<'a>

§

impl<'a> !Send for Codegen<'a>

§

impl<'a> !Sync for Codegen<'a>

§

impl<'a> Unpin for Codegen<'a>

§

impl<'a> !UnwindSafe for Codegen<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

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

§

fn vzip(self) -> V