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>
impl<'a> Build<'a>
Sourcepub fn cargo_output(&self) -> &Output
pub fn cargo_output(&self) -> &Output
The output of the cargo process.
Sourcepub fn timestamp(&self) -> SystemTime
pub fn timestamp(&self) -> SystemTime
The moment at which the build was completed.
Sourcepub fn dylib_path(&self) -> PathBuf
pub fn dylib_path(&self) -> PathBuf
The path to the generated dylib target.
Sourcepub fn tmp_dylib_path(&self) -> PathBuf
pub fn tmp_dylib_path(&self) -> PathBuf
The path to the temporary dynamic library clone that will be created upon load
.
Sourcepub fn load(self) -> Result<TempLibrary, LoadError>
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}
Sourcepub fn load_in_place(self) -> Result<Library, Error>
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> 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
Mutably borrows from an owned value. Read more