Struct Reloadable

Source
pub struct Reloadable<Host> { /* private fields */ }
Expand description

A Reloadable represents a handle to library that can be live reloaded.

Implementations§

Source§

impl<Host> Reloadable<Host>

Source

pub fn new<P: AsRef<Path>>(path: P, host: Host) -> Result<Self, Error>

Create a new Reloadable library.

This takes the path to a dynamic library containing a RELOAD_API symbol that exports the functions needed for live reloading. In order to define this symbol in your own reloadable libraries, see the live_reload! macro. This will load the library and initialize a filesystem watcher pointing to the file in order to know when the library has changed.

Source

pub fn reload(&mut self) -> Result<(), Error>

Reload the library if it has changed, otherwise do nothing.

This will consult with the filesystem watcher, and if the library has been recreated or updated, it will reload the library. See reload_now for details on what happens when a library is reloaded.

Source

pub fn reload_now(&mut self) -> Result<(), Error>

Immediately reload the library without checking whether it has changed.

This first calls unload on the currently loaded library, then unloads the dynamic library. Next, it loads the new dynamic library, and calls reload on that. If the new library fails to load, this method will return an Err and the Reloadable will be left with no library loaded.

Source

pub fn update(&mut self) -> ShouldQuit

Call the update method on the library.

If no library is currently loaded, this does nothing and returns ShouldQuit::No.

Source

pub fn host(&self) -> &Host

Get a reference to the Host struct>

Source

pub fn host_mut(&mut self) -> &mut Host

Get a mutable reference to the Host struct.

Trait Implementations§

Source§

impl<Host> Drop for Reloadable<Host>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Host> !Freeze for Reloadable<Host>

§

impl<Host> RefUnwindSafe for Reloadable<Host>
where Host: RefUnwindSafe,

§

impl<Host> !Send for Reloadable<Host>

§

impl<Host> !Sync for Reloadable<Host>

§

impl<Host> Unpin for Reloadable<Host>
where Host: Unpin,

§

impl<Host> UnwindSafe for Reloadable<Host>
where Host: UnwindSafe,

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.