Struct Vault

Source
pub struct Vault<T, F = ObFileOnDisk<T>>
where T: DeserializeOwned + Default + Send + Clone, F: ObFile<T> + Send + Clone,
{ pub files: Vec<F>, pub path: PathBuf, pub phantom: PhantomData<T>, }
Expand description

Represents an entire Obsidian vault

Contains all parsed notes and metadata about the vault. Uses ObFileOnDisk by default which is optimized for memory efficiency in large vaults.

§Type Parameters

  • T: Type for frontmatter properties (must implement DeserializeOwned + Default)
  • F: File representation type (ObFileOnDisk recommended for production use)

Fields§

§files: Vec<F>

All files in the vault

§path: PathBuf

Path to vault root directory

§phantom: PhantomData<T>

Implementations§

Source§

impl<T, F> Vault<T, F>
where T: DeserializeOwned + Default + Clone + Send, F: ObFile<T> + Send + Clone,

Source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Opens and parses an Obsidian vault

Recursively scans the directory for Markdown files (.md) and parses them. Uses ObFileOnDisk by default which is more memory efficient than ObFileInMemory.

§Arguments
  • path - Path to the vault directory
§Errors

Returns Error if:

  • Path doesn’t exist or isn’t a directory

Files that fail parsing are skipped

§Memory Considerations

For vaults with 1000+ notes, prefer ObFileOnDisk (default) over ObFileInMemory as it:

  1. Uses 90%+ less memory upfront
  2. Only loads file content when accessed
  3. Scales better for large knowledge bases
Source

pub fn has_unique_filenames(&self) -> bool

Checks if all note filenames in the vault are unique

Critical for graph operations where notes are identified by name. Always run this before calling get_digraph() or get_ungraph().

§Returns

true if all filenames are unique, false otherwise

§Performance

Operates in O(n log n) time - safe for large vaults

Source§

impl Vault<HashMap<String, Value>, ObFileOnDisk>

Source

pub fn open_default<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Opens vault using default properties (HashMap) and ObFileOnDisk storage

Recommended for most use cases due to its memory efficiency

§Errors

Returns Error if:

  • Path doesn’t exist or isn’t a directory

Trait Implementations§

Source§

impl<T, F> Clone for Vault<T, F>
where T: DeserializeOwned + Default + Send + Clone + Clone, F: ObFile<T> + Send + Clone + Clone,

Source§

fn clone(&self) -> Vault<T, F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, F> Debug for Vault<T, F>
where T: DeserializeOwned + Default + Send + Clone + Debug, F: ObFile<T> + Send + Clone + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T, F> Default for Vault<T, F>

Source§

fn default() -> Vault<T, F>

Returns the “default value” for a type. Read more
Source§

impl<T, F> PartialEq for Vault<T, F>

Source§

fn eq(&self, other: &Vault<T, F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, F> StructuralPartialEq for Vault<T, F>
where T: DeserializeOwned + Default + Send + Clone, F: ObFile<T> + Send + Clone,

Auto Trait Implementations§

§

impl<T, F> Freeze for Vault<T, F>

§

impl<T, F> RefUnwindSafe for Vault<T, F>

§

impl<T, F> Send for Vault<T, F>

§

impl<T, F> Sync for Vault<T, F>
where T: Sync, F: Sync,

§

impl<T, F> Unpin for Vault<T, F>
where T: Unpin, F: Unpin,

§

impl<T, F> UnwindSafe for Vault<T, F>
where T: UnwindSafe, F: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.