pub struct ObFileOnDisk<T = HashMap<String, Value>>where
T: DeserializeOwned + Clone,{ /* private fields */ }Expand description
On-disk representation of an Obsidian note file
Optimized for vault operations where:
- Memory efficiency is critical (large vaults)
- Storage is fast (SSD/NVMe)
- Content is accessed infrequently
§Tradeoffs vs ObFileInMemory
| Characteristic | ObFileOnDisk | ObFileInMemory |
|---|---|---|
| Memory usage | Minimal (~24 bytes) | High (content + properties) |
| File access | On-demand | Preloaded |
| Best for | SSD-based vaults | RAM-heavy workflows |
| Content access cost | Disk read | Zero cost |
§Recommendation
Prefer ObFileOnDisk for vault operations on modern hardware. The combination of
SSD speeds and Rust’s efficient I/O makes this implementation ideal for:
- Large vaults (1000+ files)
- Graph processing
§Warning
Requires persistent file access throughout the object’s lifetime
Trait Implementations§
Source§impl<T> Clone for ObFileOnDisk<T>
impl<T> Clone for ObFileOnDisk<T>
Source§fn clone(&self) -> ObFileOnDisk<T>
fn clone(&self) -> ObFileOnDisk<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for ObFileOnDisk<T>
impl<T> Debug for ObFileOnDisk<T>
Source§impl<T> Default for ObFileOnDisk<T>
impl<T> Default for ObFileOnDisk<T>
Source§fn default() -> ObFileOnDisk<T>
fn default() -> ObFileOnDisk<T>
Returns the “default value” for a type. Read more
Source§impl<T: DeserializeOwned + Clone> ObFile<T> for ObFileOnDisk<T>
impl<T: DeserializeOwned + Clone> ObFile<T> for ObFileOnDisk<T>
Source§fn content(&self) -> Result<Cow<'_, str>, Error>
fn content(&self) -> Result<Cow<'_, str>, Error>
Returns the note’s content body (without frontmatter)
§Errors
- If file doesn’t exist
- On filesystem errors
§Performance
Performs disk read on every call. Suitable for:
- Single-pass processing (link extraction, analysis)
- Large files where in-memory storage is prohibitive
For repeated access, consider caching or ObFileInMemory.
Source§fn properties(&self) -> Result<Option<Cow<'_, T>>, Error>
fn properties(&self) -> Result<Option<Cow<'_, T>>, Error>
Parses YAML frontmatter directly from disk
§Errors
- If properties can’t be deserialized
- If file doesn’t exist
- On filesystem errors
Source§impl<T: DeserializeOwned + Serialize + Clone> ObFileFlush<T> for ObFileOnDisk<T>
impl<T: DeserializeOwned + Serialize + Clone> ObFileFlush<T> for ObFileOnDisk<T>
Source§fn flush_content(&self, open_option: &OpenOptions) -> Result<(), Error>
fn flush_content(&self, open_option: &OpenOptions) -> Result<(), Error>
Flush only
content Read moreSource§fn flush_properties(&self, open_option: &OpenOptions) -> Result<(), Error>
fn flush_properties(&self, open_option: &OpenOptions) -> Result<(), Error>
Flush only
content Read moreSource§impl<T> PartialEq for ObFileOnDisk<T>
impl<T> PartialEq for ObFileOnDisk<T>
impl<T> Eq for ObFileOnDisk<T>
impl<T> StructuralPartialEq for ObFileOnDisk<T>where
T: DeserializeOwned + Clone,
Auto Trait Implementations§
impl<T> Freeze for ObFileOnDisk<T>
impl<T> RefUnwindSafe for ObFileOnDisk<T>where
T: RefUnwindSafe,
impl<T> Send for ObFileOnDisk<T>where
T: Send,
impl<T> Sync for ObFileOnDisk<T>where
T: Sync,
impl<T> Unpin for ObFileOnDisk<T>where
T: Unpin,
impl<T> UnwindSafe for ObFileOnDisk<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> ObFileDefault for Twhere
T: ObFile,
impl<T> ObFileDefault for Twhere
T: ObFile,
Source§fn from_string_default<P>(text: &str, path: Option<P>) -> Result<T, Error>
fn from_string_default<P>(text: &str, path: Option<P>) -> Result<T, Error>
Same as
ObFile::from_string with default properties type Read moreSource§fn from_file_default<P>(path: P) -> Result<T, Error>
fn from_file_default<P>(path: P) -> Result<T, Error>
Same as
ObFile::from_file with default properties type Read more