use std::fmt::Debug;
use crate::{
error::CompilerError,
intermediate::{ExtensibilityEnvironment, TaggingEnvironment, ToplevelDefinition},
};
use self::error::GeneratorError;
pub mod error;
pub mod rasn;
pub mod typescript;
pub trait Backend: Default {
type Config: Default + Debug;
const FILE_EXTENSION: &'static str;
fn generate_module(
&mut self,
top_level_declarations: Vec<ToplevelDefinition>,
) -> Result<GeneratedModule, GeneratorError>;
fn generate(&self, tld: ToplevelDefinition) -> Result<String, GeneratorError>;
fn format_bindings(bindings: &str) -> Result<String, CompilerError> {
Ok(bindings.to_owned())
}
fn config(&self) -> &Self::Config;
fn from_config(config: Self::Config) -> Self;
fn new(
config: Self::Config,
tagging_environment: TaggingEnvironment,
extensibility_environment: ExtensibilityEnvironment,
) -> Self;
}
pub struct GeneratedModule {
pub generated: Option<String>,
pub warnings: Vec<CompilerError>,
}
impl GeneratedModule {
pub fn empty() -> Self {
Self {
generated: None,
warnings: vec![],
}
}
}