Struct Config

Source
pub struct Config { /* private fields */ }
Expand description

Builder for thrift compiler wrapper.

Implementations§

Source§

impl Config

Source

pub fn new( gen_context: GenContext, thrift_bin: Option<OsString>, out_dir: PathBuf, ) -> Result<Self>

Return a new configuration with the required parameters set

Source

pub fn from_env(gen_context: GenContext) -> Result<Self>

Return a new configuration with parameters computed based on environment variables set by Cargo’s build scrip (OUT_DIR mostly). If THRIFT is in the environment, that will be used as the Thrift binary. Otherwise, it will be detected in run_compiler.

Source

pub fn base_path(&mut self, value: impl Into<PathBuf>) -> &mut Self

Set the base path which is used by the compiler to find thrift files included by input thrift files. This is also used to find the compiler.

Source

pub fn crate_map(&mut self, value: impl Into<PathBuf>) -> &mut Self

Set the path to file with crate map definition which is used by the compiler to infer crate names that will be used in the generated code. Please refer to code in fbthrift/thrift/compiler/generate/t_mstch_rust_generator.cc for the scheme of crate map.

Source

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

Set the name of the types sub-crate needed by by the thrift-compiler (to be able to generate things like use ::foo__types).

Source

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

Set the options to be passed to mstch_rust code generation. Example options are serde.

Source

pub fn lib_include_srcs(&mut self, value: Vec<String>) -> &mut Self

Set extra srcs to be available in the generated primary crate.

Source

pub fn types_include_srcs(&mut self, value: Vec<String>) -> &mut Self

Set extra srcs to be available in the generated types sub-crate.

Source

pub fn run( &self, input_files: impl IntoIterator<Item = impl AsRef<Path>>, ) -> Result<()>

Run the compiler on the input files. As a result a lib.rs file will be generated inside the output dir. The contents of the lib.rs can vary according to the generation context (e.g. for a given thrift library, ‘foo’ say, we invoke the generator for the crate ‘foo’ and for the crate ‘foo-types’).

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.