[−][src]Struct safe_bindgen::Bindgen
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");
Methods
impl Bindgen
[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]
PathBuf: From<T>,
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]
S: Into<String>,
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]
&mut self,
lang: &mut L,
outputs: &mut HashMap<String, String>,
finalise: bool
) -> Result<(), Vec<Error>>
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]
&self,
root: P,
outputs: &HashMap<String, String>
) -> Result<(), IoError>
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]
&mut self,
lang: &mut L,
output_dir: P
)
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]
Print an error
Auto Trait Implementations
impl Send for Bindgen
impl Sync for Bindgen
impl Unpin for Bindgen
impl UnwindSafe for Bindgen
impl RefUnwindSafe for Bindgen
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,