pub trait Backend: Sized + Default {
type Config: Sized + Default + Debug;
const FILE_EXTENSION: &'static str;
// Required methods
fn generate_module(
&mut self,
top_level_declarations: Vec<ToplevelDefinition>,
) -> Result<GeneratedModule, GeneratorError>;
fn generate(
&self,
tld: ToplevelDefinition,
) -> Result<String, GeneratorError>;
fn config(&self) -> &Self::Config;
fn from_config(config: Self::Config) -> Self;
fn new(
config: Self::Config,
tagging_environment: TaggingEnvironment,
extensibility_environment: ExtensibilityEnvironment,
) -> Self;
// Provided method
fn format_bindings(bindings: &str) -> Result<String, CompilerError> { ... }
}
Expand description
Implementors of the Backend
trait can be used
as a backend to the compiler in order to create bindings
for other frameworks and languages than the default backend.
Required Associated Constants§
Sourceconst FILE_EXTENSION: &'static str
const FILE_EXTENSION: &'static str
File extension that should be used for output file containing the generated bindings.
For example: .ts
for Typescript, .rs
for Rasn bindings.
Required Associated Types§
Required Methods§
Sourcefn generate_module(
&mut self,
top_level_declarations: Vec<ToplevelDefinition>,
) -> Result<GeneratedModule, GeneratorError>
fn generate_module( &mut self, top_level_declarations: Vec<ToplevelDefinition>, ) -> Result<GeneratedModule, GeneratorError>
generates bindings for an ASN.1 module
§Params
top_level_declarations
vector of [TopLevelDeclaration]s that are defined in the ASN.1 module
Sourcefn generate(&self, tld: ToplevelDefinition) -> Result<String, GeneratorError>
fn generate(&self, tld: ToplevelDefinition) -> Result<String, GeneratorError>
generates bindings for a single ASN.1 item
§Params
tld
[TopLevelDeclaration] for which the bindings should be generated
Sourcefn from_config(config: Self::Config) -> Self
fn from_config(config: Self::Config) -> Self
Creates a backend from its config
Sourcefn new(
config: Self::Config,
tagging_environment: TaggingEnvironment,
extensibility_environment: ExtensibilityEnvironment,
) -> Self
fn new( config: Self::Config, tagging_environment: TaggingEnvironment, extensibility_environment: ExtensibilityEnvironment, ) -> Self
Creates a backend from its fields. Usually, the tagging and extensibility environments do not have to be set manually, but will follow the respective module header.
Provided Methods§
Sourcefn format_bindings(bindings: &str) -> Result<String, CompilerError>
fn format_bindings(bindings: &str) -> Result<String, CompilerError>
Formats the bindings using the language- or framework-specific linters. For example, the Rust backend uses rustfmt for formatting bindings.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.