Resource
Module @netwiv/api/core · Kind Class
import { Resource } from '@netwiv/api/core';A rust-backed resource stored through tauri::Manager::resources_table API.
The resource lives in the main process and does not exist in the Javascript world, and thus will not be cleaned up automatically except on application exit. If you want to clean it up early, call {@linkcode Resource.close}
Constructor
Section titled “Constructor”new Resource(rid: number)Instance members
Section titled “Instance members”close(): Promise<void>Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.
rid: numberExample
Section titled “Example”import { Resource, invoke } from '@netwiv/api/core';export class DatabaseHandle extends Resource { static async open(path: string): Promise<DatabaseHandle> { const rid: number = await invoke('open_db', { path }); return new DatabaseHandle(rid); }
async execute(sql: string): Promise<void> { await invoke('execute_sql', { rid: this.rid, sql }); }}Descriptions come from the pinned @tauri-apps/api@2.11.1 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.