[][src]Trait transporter::CodeGenerator

pub trait CodeGenerator {
    fn build<C>(&self, fc: &mut C) -> Result<()>
    where
        C: FileCreator
; }

Represents a structure from which one or more source-code files can be built

A CodeGenerator can build some code that is written to one or multiple source-code files using a FileCreator.

use transporter::{
    CodeGenerator,
    Result,
    FileCreator,
};
use std::{
    io::Write,
    path::Path,
};

struct UnionStruct {
    name: String,
}

impl CodeGenerator for UnionStruct {
    fn build<C>(&self, fc: &mut C) -> Result<()> where
        C: FileCreator,
    {
        let mut file = fc.create(Path::new(&format!("{}.rs", self.name)).into())?;

        file.write_all(&(format!("struct {};", self.name).into_bytes()));

        Ok(())
    }
}

let null = UnionStruct { name: "Null".to_string() };

Required methods

fn build<C>(&self, fc: &mut C) -> Result<()> where
    C: FileCreator

Loading content...

Implementors

impl CodeGenerator for transporter::Cli[src]

impl CodeGenerator for transporter::php::Cli[src]

impl CodeGenerator for transporter::rust::Cli[src]

Loading content...