pub struct Config { /* private fields */ }
Expand description
Builder for thrift compiler wrapper.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(
gen_context: GenContext,
thrift_bin: Option<OsString>,
out_dir: PathBuf,
) -> Result<Self>
pub fn new( gen_context: GenContext, thrift_bin: Option<OsString>, out_dir: PathBuf, ) -> Result<Self>
Return a new configuration with the required parameters set
Sourcepub fn from_env(gen_context: GenContext) -> Result<Self>
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.
Sourcepub fn base_path(&mut self, value: impl Into<PathBuf>) -> &mut Self
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.
Sourcepub fn crate_map(&mut self, value: impl Into<PathBuf>) -> &mut Self
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.
Sourcepub fn types_crate(&mut self, value: impl Into<String>) -> &mut Self
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
).
Sourcepub fn options(&mut self, value: impl Into<String>) -> &mut Self
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
.
Sourcepub fn lib_include_srcs(&mut self, value: Vec<String>) -> &mut Self
pub fn lib_include_srcs(&mut self, value: Vec<String>) -> &mut Self
Set extra srcs to be available in the generated primary crate.
Sourcepub fn types_include_srcs(&mut self, value: Vec<String>) -> &mut Self
pub fn types_include_srcs(&mut self, value: Vec<String>) -> &mut Self
Set extra srcs to be available in the generated types sub-crate.
Sourcepub fn run(
&self,
input_files: impl IntoIterator<Item = impl AsRef<Path>>,
) -> Result<()>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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