Skip to main content

MultiGenerator

Struct MultiGenerator 

Source
pub struct MultiGenerator { /* private fields */ }
Expand description

Helper for chaining multiple generators

Allows generating code in multiple languages from the same IR. This is useful for projects that need to generate code in multiple target languages from a single schema.

§Examples

use unistructgen_core::{MultiGenerator, IRModule};

let multi = MultiGenerator::new()
    .add("rust", rust_generator)
    .add("typescript", ts_generator);

let results = multi.generate_all(&module)?;
for (name, code) in results {
    println!("Generated {} code", name);
}

Implementations§

Source§

impl MultiGenerator

Source

pub fn new() -> Self

Create a new multi-generator

Source

pub fn add<G>(self, name: impl Into<String>, generator: G) -> Self
where G: CodeGenerator + 'static,

Add a generator

Source

pub fn generate_all( &self, module: &IRModule, ) -> Result<Vec<(String, String)>, MultiGeneratorError>

Generate code with all registered generators

Source

pub fn generator_names(&self) -> Vec<&str>

Get list of registered generator names

Trait Implementations§

Source§

impl Default for MultiGenerator

Source§

fn default() -> Self

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

Auto Trait Implementations§

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.