pub struct VaultApi { /* private fields */ }Expand description
Cloneable, curated facade supplied to every plugin.
The host builds one of these PER PLUGIN, bound to that plugin’s identity, so a capability granted to one plugin is not reachable from another.
Implementations§
Source§impl VaultApi
impl VaultApi
Sourcepub fn new(host: Arc<dyn VaultHost>, identity: PluginIdentity) -> Self
pub fn new(host: Arc<dyn VaultHost>, identity: PluginIdentity) -> Self
Wrap a host implementation for one specific plugin.
Sourcepub fn identity(&self) -> &PluginIdentity
pub fn identity(&self) -> &PluginIdentity
The calling plugin’s identity, as the host validated it.
Sourcepub async fn active_vault(&self) -> PluginResult<VaultDescriptor>
pub async fn active_vault(&self) -> PluginResult<VaultDescriptor>
Return the currently selected vault’s identity.
The selection can change between calls. Capture the name once and pass it to subsequent operations rather than re-resolving per call.
Sourcepub async fn list_notes(&self, vault: &str) -> PluginResult<Vec<String>>
pub async fn list_notes(&self, vault: &str) -> PluginResult<Vec<String>>
List markdown note paths in vault.
Sourcepub async fn list_notes_detailed(
&self,
vault: &str,
) -> PluginResult<Vec<NoteListing>>
pub async fn list_notes_detailed( &self, vault: &str, ) -> PluginResult<Vec<NoteListing>>
List notes in vault with change-detection metadata.
The reconciliation half of the change contract: crate::HookBus is
the fast path for changes while a plugin is running, and this is how a
plugin catches up on everything the feed could not tell it about —
changes made while the process was down, and changes lost to
crate::HookRecvError::Lagged. Compare each entry against what you
stored and re-read only what moved.
Sourcepub async fn read_note(
&self,
vault: &str,
path: &str,
) -> PluginResult<NoteSnapshot>
pub async fn read_note( &self, vault: &str, path: &str, ) -> PluginResult<NoteSnapshot>
Read a complete note and its opaque version from vault.
Sourcepub async fn read_notes(
&self,
vault: &str,
paths: &[String],
) -> PluginResult<Vec<NoteSnapshot>>
pub async fn read_notes( &self, vault: &str, paths: &[String], ) -> PluginResult<Vec<NoteSnapshot>>
Read several notes in one call.
Prefer this to a loop over Self::read_note when reconciling: the
host resolves the vault once for the whole batch instead of once per
note. Paths that cannot be read are omitted, so a note deleted between
listing and reading does not fail the pass.
Sourcepub async fn write_note(
&self,
request: WriteNoteRequest,
) -> PluginResult<WriteReceipt>
pub async fn write_note( &self, request: WriteNoteRequest, ) -> PluginResult<WriteReceipt>
Create or compare-and-swap a complete note.
Sourcepub async fn read_config(
&self,
vault: &str,
path: &str,
) -> PluginResult<Option<Vec<u8>>>
pub async fn read_config( &self, vault: &str, path: &str, ) -> PluginResult<Option<Vec<u8>>>
Read one application-config file this plugin declared it needs.
The note APIs cannot reach .obsidian/ — that space holds code the
application executes, so it is not part of the note surface. A plugin
that genuinely needs to self-tune to app settings declares the exact
files it reads via PluginCapabilities::config_reads, and this method
serves only those. Anything else is
PluginErrorCode::PermissionDenied.
Returns Ok(None) when a permitted file does not exist.