JuteGenerator

Struct JuteGenerator 

Source
pub struct JuteGenerator {
    pub out_dir: Option<PathBuf>,
    pub src_files: Vec<PathBuf>,
}
Expand description

High-level Jute code generation driver.

JuteGenerator follows a builder-style API and is responsible for:

  1. Collecting source .jute files
  2. Parsing them into ASTs
  3. Resolving type and module dependencies
  4. Invoking the language-specific code generator (Rust)

§Example

use jute::JuteGenerator;
let schema_path1 = "./schema/1.jute";
let schema_path2 = "./schema/2.jute";
let out_dir_path= "generated";

JuteGenerator::new()
    .add_src_file(schema_path1)
    .add_src_file(schema_path2)
    .add_out_dir(out_dir_path)
    .generate()
    .unwrap();

Fields§

§out_dir: Option<PathBuf>

Output directory where generated code will be written.

If not provided, code generation defaults to the current(src) directory.

§src_files: Vec<PathBuf>

List of input Jute schema files.

Implementations§

Source§

impl JuteGenerator

Source

pub fn new() -> Self

Creates a new empty JuteGenerator.

Source

pub fn add_src_file<P: AsRef<Path>>(self, file_path: P) -> Self

Adds a Jute source file to the generator.

§Panics

Panics if the same file is added more than once.

Source

pub fn add_out_dir<P: AsRef<Path>>(self, out_dir: P) -> Self

Sets the output directory for generated code.

§Panics

Panics if the output directory is already set.

Source

pub fn generate(self) -> Result<(), JuteError>

Executes the full code generation pipeline.

This method:

  1. Parses all provided .jute files into AST documents
  2. Resolves cross-module and cross-file dependencies
  3. Merges all modules into a single collection
  4. Generates Rust code into the configured output directory
§Errors

Returns an error if:

  • Parsing fails
  • Dependency resolution fails
  • Code generation fails

Trait Implementations§

Source§

impl Default for JuteGenerator

Source§

fn default() -> JuteGenerator

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

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.