Struct Emitter

Source
pub struct Emitter {
    pub out: Box<dyn Write>,
    pub config_data: Figment,
    pub workdir: Utf8PathBuf,
}

Fields§

§out: Box<dyn Write>§config_data: Figment§workdir: Utf8PathBuf

Implementations§

Source§

impl Emitter

Source

pub fn config_val(&self, key: &str) -> Result<String, EmitError>

Fetch a configuration value, or panic if it’s missing.

Source

pub fn config_or(&self, key: &str, default: &str) -> String

Fetch a configuration value, using a default if it’s missing.

Source

pub fn config_var(&mut self, name: &str, key: &str) -> EmitResult

Emit a Ninja variable declaration for name based on the configured value for key.

Source

pub fn config_var_or( &mut self, name: &str, key: &str, default: &str, ) -> Result<()>

Emit a Ninja variable declaration for name based on the configured value for key, or a default value if it’s missing.

Source

pub fn var(&mut self, name: &str, value: &str) -> Result<()>

Emit a Ninja variable declaration.

Source

pub fn rule(&mut self, name: &str, command: &str) -> Result<()>

Emit a Ninja rule definition.

Source

pub fn build(&mut self, rule: &str, input: &str, output: &str) -> Result<()>

Emit a simple Ninja build command with one dependency.

Source

pub fn build_cmd( &mut self, targets: &[&str], rule: &str, deps: &[&str], implicit_deps: &[&str], ) -> Result<()>

Emit a Ninja build command.

Source

pub fn comment(&mut self, text: &str) -> Result<()>

Emit a Ninja comment.

Source

pub fn add_file(&self, name: &str, contents: &[u8]) -> Result<()>

Add a file to the build directory.

Source

pub fn external_path(&self, path: &Utf8Path) -> Utf8PathBuf

Get a path to an external file. The input path may be relative to our original invocation; we make it relative to the build directory so it can safely be used in the Ninja file.

Source

pub fn arg(&mut self, name: &str, value: &str) -> Result<()>

Add a variable parameter to a rule or build command.

Auto Trait Implementations§

§

impl Freeze for Emitter

§

impl !RefUnwindSafe for Emitter

§

impl !Send for Emitter

§

impl !Sync for Emitter

§

impl Unpin for Emitter

§

impl !UnwindSafe for Emitter

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.