Struct sn_bindgen::Bindgen [−][src]
pub struct Bindgen { /* fields omitted */ }
Expand description
Stores configuration for the bindgen.
Examples
Since construction can only fail if there is an error while reading the cargo manifest it is
usually safe to call .unwrap()
on the result (though .expect()
is considered better
practice).
Bindgen::new().expect("unable to read cargo manifest");
If your project is a valid cargo project or follows the same structure, you can simply place the following in your build script.
Bindgen::new().expect("unable to read cargo manifest") .run_build("path/to/output/file");
If you use a different structure you should use .source_file("...")
to set the path to the
root crate file.
Bindgen::new().expect("unable to read cargo manifest") .source_file("src/root.rs") .run_build("include/my_header.h");
Implementations
impl Bindgen
[src]
impl Bindgen
[src]pub fn new() -> Result<Self, Error>
[src]
pub fn new() -> Result<Self, Error>
[src]Create a new bindgen instance.
This can only fail if there are issues reading the cargo manifest. If there is no cargo
manifest available then the source file defaults to src/lib.rs
.
pub fn source_file<T>(&mut self, path: T) -> &mut Self where
PathBuf: From<T>,
[src]
pub fn source_file<T>(&mut self, path: T) -> &mut Self where
PathBuf: From<T>,
[src]Set the path to the root source file of the crate.
This should only be used when not using a cargo
build system.
pub fn source_code<S>(&mut self, file_name: S, code: S) -> &mut Self where
S: Into<String>,
[src]
pub fn source_code<S>(&mut self, file_name: S, code: S) -> &mut Self where
S: Into<String>,
[src]Use custom code as input.
pub fn compile<L: Lang>(
&mut self,
lang: &mut L,
outputs: &mut HashMap<String, String>,
finalise: bool
) -> Result<(), Vec<Error>>
[src]
pub fn compile<L: Lang>(
&mut self,
lang: &mut L,
outputs: &mut HashMap<String, String>,
finalise: bool
) -> Result<(), Vec<Error>>
[src]Compile just the code into header declarations.
This does not add any include-guards, includes, or extern declarations. It is mainly intended for internal use, but may be of interest to people who wish to embed moz-cheddar’s generated code in another file.
pub fn compile_or_panic<L: Lang>(
&mut self,
lang: &mut L,
outputs: &mut HashMap<String, String>,
finalise: bool
)
[src]
&mut self,
lang: &mut L,
outputs: &mut HashMap<String, String>,
finalise: bool
)
pub fn write_outputs<P: AsRef<Path>>(
&self,
root: P,
outputs: &HashMap<String, String>
) -> Result<(), IoError>
[src]
pub fn write_outputs<P: AsRef<Path>>(
&self,
root: P,
outputs: &HashMap<String, String>
) -> Result<(), IoError>
[src]Writes virtual files to the file system
pub fn write_outputs_or_panic<P: AsRef<Path>>(
&self,
root: P,
outputs: &HashMap<String, String>
)
[src]
&self,
root: P,
outputs: &HashMap<String, String>
)
pub fn run_build<P: AsRef<Path>, L: Lang>(
&mut self,
lang: &mut L,
output_dir: P
)
[src]
pub fn run_build<P: AsRef<Path>, L: Lang>(
&mut self,
lang: &mut L,
output_dir: P
)
[src]Write the header to a file, panicking on error.
This is a convenience method for use in build scripts. If errors occur during compilation they will be printed then the function will panic.
Panics
Panics on any compilation error so that the build script exits and prints output.
pub fn print_error(&self, error: &Error)
[src]
pub fn print_error(&self, error: &Error)
[src]Print an error
Auto Trait Implementations
impl RefUnwindSafe for Bindgen
impl Send for Bindgen
impl Sync for Bindgen
impl Unpin for Bindgen
impl UnwindSafe for Bindgen
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more