Struct Build

Source
pub struct Build<'a> { /* private fields */ }
Expand description

The result of building a package’s dynamic library.

This can be used to load the dynamic library either in place or via a temporary file as to allow for re-building the package while using the library.

Implementations§

Source§

impl<'a> Build<'a>

Source

pub fn cargo_output(&self) -> &Output

The output of the cargo process.

Source

pub fn timestamp(&self) -> SystemTime

The moment at which the build was completed.

Source

pub fn dylib_path(&self) -> PathBuf

The path to the generated dylib target.

Source

pub fn tmp_dylib_path(&self) -> PathBuf

The path to the temporary dynamic library clone that will be created upon load.

Source

pub fn load(self) -> Result<TempLibrary, LoadError>

Copy the library to the platform’s temporary directory and load it from there.

Note that the copied dynamic library will be removed on Drop.

Examples found in repository?
examples/demo.rs (line 7)
1fn main() {
2    let test_crate_path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
3        .join("test_crate")
4        .join("Cargo.toml");
5    println!("Begin watching for changes to {:?}", test_crate_path);
6    let watch = hotlib::watch(&test_crate_path).unwrap();
7    let mut lib = watch.package().build().unwrap().load().unwrap();
8    loop {
9        unsafe {
10            let foo: libloading::Symbol<fn(i32, i32) -> i32> = lib.get(b"foo").unwrap();
11            let res = foo(6, 7);
12            println!("{}", res);
13        }
14        println!("Awaiting next change...");
15        let pkg = watch.next().unwrap();
16        lib = pkg.build().unwrap().load().unwrap();
17    }
18}
Source

pub fn load_in_place(self) -> Result<Library, Error>

Load the library from it’s existing location.

Note that if you do this, you will have to ensure the returned Library is dropped before attempting to re-build the library.

Auto Trait Implementations§

§

impl<'a> Freeze for Build<'a>

§

impl<'a> RefUnwindSafe for Build<'a>

§

impl<'a> Send for Build<'a>

§

impl<'a> Sync for Build<'a>

§

impl<'a> Unpin for Build<'a>

§

impl<'a> UnwindSafe for Build<'a>

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, 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.
Source§

impl<T> Any for T
where T: Any,

Source§

impl<T> Erased for T