Struct ObFileInMemory

Source
pub struct ObFileInMemory<T = HashMap<String, Value>>{ /* private fields */ }
Expand description

In-memory representation of an Obsidian note file

This struct provides full access to parsed note content, properties, and path. It stores the entire file contents in memory, making it suitable for:

  • Frequent access to note content
  • Transformation or analysis workflows
  • Environments with fast storage (SSD/RAM disks)

§Performance Considerations

  • Uses ~2x memory of original file size (UTF-8 + deserialized properties)
  • Preferred for small-to-medium vaults (<10k notes)

For large vaults or read-heavy workflows, consider ObFileOnDisk.

Trait Implementations§

Source§

impl<T> Clone for ObFileInMemory<T>

Source§

fn clone(&self) -> ObFileInMemory<T>

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> Debug for ObFileInMemory<T>

Source§

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

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

impl<T> Default for ObFileInMemory<T>

Source§

fn default() -> ObFileInMemory<T>

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

impl<T: DeserializeOwned + Clone> ObFile<T> for ObFileInMemory<T>

Source§

fn from_string<P: AsRef<Path>>( raw_text: &str, path: Option<P>, ) -> Result<Self, Error>

Parses a string into an in-memory Obsidian note representation

§Arguments
  • raw_text - Full note text including optional frontmatter
  • path - Optional source path for reference
§Process
  1. Splits text into frontmatter/content sections
  2. Parses YAML frontmatter if present
  3. Stores content without frontmatter delimiters
§Errors
§Example
use obsidian_parser::prelude::*;
use serde::Deserialize;

#[derive(Deserialize, Clone, Default)]
struct NoteProperties {
    title: String
}

let note = r#"---
title: Example
---
Content"#;

let file: ObFileInMemory<NoteProperties> = ObFileInMemory::from_string(note, None::<&str>).unwrap();
let properties = file.properties().unwrap().unwrap();

assert_eq!(properties.title, "Example");
assert_eq!(file.content().unwrap(), "Content");
Source§

fn content(&self) -> Result<Cow<'_, str>, Error>

Returns the main content body of the note (excluding frontmatter) Read more
Source§

fn path(&self) -> Option<Cow<'_, Path>>

Returns the source file path if available Read more
Source§

fn properties(&self) -> Result<Option<Cow<'_, T>>, Error>

Returns the parsed properties of frontmatter Read more
Source§

fn note_name(&self) -> Option<String>

Get note name
Source§

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

Parses an Obsidian note from a file Read more
Source§

impl<T> PartialEq for ObFileInMemory<T>

Source§

fn eq(&self, other: &ObFileInMemory<T>) -> 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> Eq for ObFileInMemory<T>
where T: DeserializeOwned + Clone + Eq,

Source§

impl<T> StructuralPartialEq for ObFileInMemory<T>

Auto Trait Implementations§

§

impl<T> Freeze for ObFileInMemory<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for ObFileInMemory<T>
where T: RefUnwindSafe,

§

impl<T> Send for ObFileInMemory<T>
where T: Send,

§

impl<T> Sync for ObFileInMemory<T>
where T: Sync,

§

impl<T> Unpin for ObFileInMemory<T>
where T: Unpin,

§

impl<T> UnwindSafe for ObFileInMemory<T>
where T: 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ObFileDefault for T
where T: ObFile,

Source§

fn from_string_default<P>(text: &str, path: Option<P>) -> Result<T, Error>
where P: AsRef<Path>,

Same as ObFile::from_string with default properties type Read more
Source§

fn from_file_default<P>(path: P) -> Result<T, Error>
where P: AsRef<Path>,

Same as ObFile::from_file with default properties type Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.