pub struct CodegenOptions { /* private fields */ }
Expand description

Options for the code generator.

This struct is a builder for the code generator options.

Examples

CodegenOptions::new()
    .spec("tighterror.yaml".to_owned())
    .dst("src/errors.rs".to_owned())
    .codegen()?;

Implementations§

source§

impl CodegenOptions

source

pub fn new() -> Self

Creates a new options object with default values.

source

pub fn spec(&mut self, spec: impl Into<Option<String>>) -> &mut Self

Sets the specification file path.

If not specified the path DEFAULT_SPEC_PATH is used.

Examples
CodegenOptions::new().spec(None);
CodegenOptions::new().spec("tighterror.yaml".to_owned());
CodegenOptions::new().spec(Some("myerrors.toml".into()));
source

pub fn dst(&mut self, dst: impl Into<Option<String>>) -> &mut Self

Sets the destination file path.

If the value is "-", or destination file path is not set at all, the output is written to stdout.

A value specified here overrides the one present in the specification file.

Examples
CodegenOptions::new().dst(None);
CodegenOptions::new().dst("src/errors.rs".to_owned());
CodegenOptions::new().dst(Some("myerrors.rs".into()));
source

pub fn codegen(&self) -> Result<(), TebError>

Invokes the code generator main function using these options.

See the struct documentation for a full example.

Trait Implementations§

source§

impl Clone for CodegenOptions

source§

fn clone(&self) -> CodegenOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CodegenOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CodegenOptions

source§

fn default() -> CodegenOptions

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.