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, Box<dyn Error>>

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, Box<dyn Error>>

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<Box<dyn Error>>, Box<dyn Error>>

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.