rasn_compiler

Struct Compiler

Source
pub struct Compiler<B: Backend, S: CompilerState> { /* private fields */ }
Expand description

The rasn compiler

Implementations§

Source§

impl<B: Backend, S: CompilerState> Compiler<B, S>

Source

pub fn with_backend<B2: Backend>(self, backend: B2) -> Compiler<B2, S>

Source§

impl<B: Backend> Compiler<B, CompilerMissingParams>

Source

pub fn new() -> Compiler<B, CompilerMissingParams>

Provides a Builder for building rasn compiler commands

Source

pub fn new_with_config(config: B::Config) -> Compiler<B, CompilerMissingParams>

Provides a Builder for building rasn compiler commands

Source§

impl<B: Backend> Compiler<B, CompilerMissingParams>

Source

pub fn add_asn_by_path( self, path_to_source: impl Into<PathBuf>, ) -> Compiler<B, CompilerSourcesSet>

Add an ASN1 source to the compile command by path

  • path_to_source - path to ASN1 file to include
Source

pub fn add_asn_sources_by_path( self, paths_to_sources: impl Iterator<Item = impl Into<PathBuf>>, ) -> Compiler<B, CompilerSourcesSet>

Add several ASN1 sources by path to the compile command

  • path_to_source - iterator of paths to the ASN1 files to be included
Source

pub fn add_asn_literal( self, literal: impl Into<String>, ) -> Compiler<B, CompilerSourcesSet>

Add a literal ASN1 source to the compile command

  • literal - literal ASN1 statement to include
Compiler::<RasnBackend, _>::new().add_asn_literal(format!(
    "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
    "My-test-integer ::= INTEGER (1..128)"
)).compile_to_string();
Source

pub fn set_output_path( self, output_path: impl Into<PathBuf>, ) -> Compiler<B, CompilerOutputSet>

Set the output path for the generated rust representation.

  • output_path - path to an output file or directory, if path indicates a directory, the output file is named rasn_generated.rs
Source§

impl<B: Backend> Compiler<B, CompilerOutputSet>

Source

pub fn add_asn_by_path( self, path_to_source: impl Into<PathBuf>, ) -> Compiler<B, CompilerReady>

Add an ASN1 source to the compile command by path

  • path_to_source - path to ASN1 file to include
Source

pub fn add_asn_sources_by_path( self, paths_to_sources: impl Iterator<Item = impl Into<PathBuf>>, ) -> Compiler<B, CompilerReady>

Add several ASN1 sources by path to the compile command

  • path_to_source - iterator of paths to the ASN1 files to be included
Source

pub fn add_asn_literal( self, literal: impl Into<String>, ) -> Compiler<B, CompilerReady>

Add a literal ASN1 source to the compile command

  • literal - literal ASN1 statement to include
Compiler::<RasnBackend, _>::new().add_asn_literal(format!(
    "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
    "My-test-integer ::= INTEGER (1..128)"
)).compile_to_string();
Source§

impl<B: Backend> Compiler<B, CompilerSourcesSet>

Source

pub fn add_asn_by_path( self, path_to_source: impl Into<PathBuf>, ) -> Compiler<B, CompilerSourcesSet>

Add an ASN1 source to the compile command by path

  • path_to_source - path to ASN1 file to include
Source

pub fn add_asn_sources_by_path( self, paths_to_sources: impl Iterator<Item = impl Into<PathBuf>>, ) -> Compiler<B, CompilerSourcesSet>

Add several ASN1 sources by path to the compile command

  • path_to_source - iterator of paths to the ASN1 files to be included
Source

pub fn add_asn_literal( self, literal: impl Into<String>, ) -> Compiler<B, CompilerSourcesSet>

Add a literal ASN1 source to the compile command

  • literal - literal ASN1 statement to include
Compiler::<RasnBackend, _>::new().add_asn_literal(format!(
    "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
    "My-test-integer ::= INTEGER (1..128)"
)).compile_to_string();
Source

pub fn set_output_path( self, output_path: impl Into<PathBuf>, ) -> Compiler<B, CompilerReady>

Set the output path for the generated rust representation.

  • output_path - path to an output file or directory, if path points to a directory, the compiler will generate a file for every ASN.1 module. If the path points to a file, all modules will be written to that file.
Source

pub fn compile_to_string(self) -> Result<CompileResult, CompilerError>

Runs the rasn compiler command and returns stringified Rust. Returns a Result wrapping a compilation result:

  • Ok - tuple containing the stringified bindings for the ASN1 spec as well as a vector of warnings raised during the compilation
  • Err - Unrecoverable error, no rust representations were generated
Source§

impl<B: Backend> Compiler<B, CompilerReady>

Source

pub fn add_asn_by_path( self, path_to_source: impl Into<PathBuf>, ) -> Compiler<B, CompilerReady>

Add an ASN1 source to the compile command by path

  • path_to_source - path to ASN1 file to include
Source

pub fn add_asn_sources_by_path( self, paths_to_sources: impl Iterator<Item = impl Into<PathBuf>>, ) -> Compiler<B, CompilerReady>

Add several ASN1 sources by path to the compile command

  • path_to_source - iterator of paths to the ASN1 files to be included
Source

pub fn add_asn_literal( self, literal: impl Into<String>, ) -> Compiler<B, CompilerReady>

Add a literal ASN1 source to the compile command

  • literal - literal ASN1 statement to include
Compiler::<RasnBackend, _>::new().add_asn_literal(format!(
    "TestModule DEFINITIONS AUTOMATIC TAGS::= BEGIN {} END",
    "My-test-integer ::= INTEGER (1..128)"
)).compile_to_string();
Source

pub fn compile_to_string(self) -> Result<CompileResult, CompilerError>

Runs the rasn compiler command and returns stringified Rust. Returns a Result wrapping a compilation result:

  • Ok - tuple containing the stringified bindings for the ASN1 spec as well as a vector of warnings raised during the compilation
  • Err - Unrecoverable error, no rust representations were generated
Source

pub fn compile(self) -> Result<Vec<CompilerError>, CompilerError>

Runs the rasn compiler command. Returns a Result wrapping a compilation result:

  • Ok - Vector of warnings raised during the compilation
  • Err - Unrecoverable error, no rust representations were generated

Trait Implementations§

Source§

impl<B: Backend> Default for Compiler<B, CompilerMissingParams>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<B, S> Freeze for Compiler<B, S>
where S: Freeze, B: Freeze,

§

impl<B, S> RefUnwindSafe for Compiler<B, S>

§

impl<B, S> Send for Compiler<B, S>
where S: Send, B: Send,

§

impl<B, S> Sync for Compiler<B, S>
where S: Sync, B: Sync,

§

impl<B, S> Unpin for Compiler<B, S>
where S: Unpin, B: Unpin,

§

impl<B, S> UnwindSafe for Compiler<B, S>
where S: UnwindSafe, B: UnwindSafe,

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.