Skip to main content

VaultApi

Struct VaultApi 

Source
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

Source

pub fn new(host: Arc<dyn VaultHost>, identity: PluginIdentity) -> Self

Wrap a host implementation for one specific plugin.

Source

pub fn identity(&self) -> &PluginIdentity

The calling plugin’s identity, as the host validated it.

Source

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.

Source

pub async fn list_notes(&self, vault: &str) -> PluginResult<Vec<String>>

List markdown note paths in vault.

Source

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.

Source

pub async fn read_note( &self, vault: &str, path: &str, ) -> PluginResult<NoteSnapshot>

Read a complete note and its opaque version from vault.

Source

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.

Source

pub async fn write_note( &self, request: WriteNoteRequest, ) -> PluginResult<WriteReceipt>

Create or compare-and-swap a complete note.

Source

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.

Trait Implementations§

Source§

impl Clone for VaultApi

Source§

fn clone(&self) -> VaultApi

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VaultApi

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.