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.