Trait tauri::Resource

source ·
pub trait Resource: Any + 'static + Send + Sync {
    // Provided methods
    fn name(&self) -> Cow<'_, str> { ... }
    fn close(self: Arc<Self>) { ... }
}
Expand description

Resources are Rust objects that are stored in ResourceTable and managed by tauri. They are identified in JS by a numeric ID (the resource ID, or rid). Resources can be created in commands. Resources can also be retrieved in commands by their rid. Resources are thread-safe.

Resources are reference counted in Rust. This means that they can be cloned and passed around. When the last reference is dropped, the resource is automatically closed. As long as the resource exists in the resource table, the reference count is at least 1.

Provided Methods§

source

fn name(&self) -> Cow<'_, str>

Returns a string representation of the resource. The default implementation returns the Rust type name, but specific resource types may override this trait method.

source

fn close(self: Arc<Self>)

Resources may implement the close() trait method if they need to do resource specific clean-ups, such as cancelling pending futures, after a resource has been removed from the resource table.

Implementors§

source§

impl Resource for Image<'static>