Struct includer_codegen::Codegen [−][src]
pub struct Codegen { /* fields omitted */ }
A code generation builder.
By default the path written to is $OUT_DIR/assets.rs
where $OUT_DIR
is
from your environmental variables. This is usually set by cargo. If
$OUT_DIR
is not set, then no path is set.
An unlimited amount of Pipelines
can be added and they will be written
to the file in the same order as they were added.
Methods
impl Codegen
[src]
impl Codegen
pub fn new() -> Codegen
[src]
pub fn new() -> Codegen
Creates a Codegen instance.
If the cargo env var OUT_DIR
is set, the path is automatically set
to $OUT_DIR/assets.rs
, otherwise a path is not set. In that case
you are able to explicitly able to specify the path with set_path
.
use includer_codegen::prelude::*; let c = Codegen::new();
pub fn path(&self) -> Option<&Path>
[src]
pub fn path(&self) -> Option<&Path>
Returns the currently set path.
use std::path::Path; use includer_codegen::prelude::*; let c = Codegen::new().set_path("./out/gen.rs"); assert_eq!(c.path(), Some(Path::new("./out/gen.rs")));
pub fn set_path<P: Into<PathBuf>>(self, path: P) -> Codegen
[src]
pub fn set_path<P: Into<PathBuf>>(self, path: P) -> Codegen
Sets the output path for the generated file.
use includer_codegen::prelude::*; Codegen::new().set_path("./out/gen.rs");
pub fn pipelines(&self) -> &[Box<Pipeline>]
[src]
pub fn pipelines(&self) -> &[Box<Pipeline>]
Returns a list of all currently set Pipelines
pub fn pipe(self, generator: Box<Pipeline>) -> Codegen
[src]
pub fn pipe(self, generator: Box<Pipeline>) -> Codegen
Add a Pipeline
to the Codegen
instance.
use includer_codegen::prelude::*; Codegen::new().pipe(Assets::new("ASSETS", "../web/dist").build());
pub fn write(&self) -> usize
[src]
pub fn write(&self) -> usize
Writes everything to file and returns the written amount.
use includer_codegen::prelude::*; Codegen::new() .pipe(Assets::new("ASSETS", "../web/dist").build()) .write();
Panics
If path
is not set then this function will panic.
A panic will also happen when any file operation fails - such as opening, writing, or closing.