NoteInMemory

Struct NoteInMemory 

Source
pub struct NoteInMemory<T = HashMap<String, Value>>
where T: Clone,
{ /* 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 NoteOnDisk.

Implementations§

Source§

impl<T> NoteInMemory<T>
where T: Clone,

Source

pub fn set_path(&mut self, path: Option<PathBuf>)

Set path to note

Trait Implementations§

Source§

impl<T> Clone for NoteInMemory<T>
where T: Clone + Clone,

Source§

fn clone(&self) -> NoteInMemory<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 NoteInMemory<T>
where T: Clone + Debug,

Source§

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

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

impl<T> Default for NoteInMemory<T>
where T: Clone + Default,

Source§

fn default() -> NoteInMemory<T>

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

impl<T> Note for NoteInMemory<T>
where T: Clone,

Source§

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

Source§

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

Get contents

Source§

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

Get path to file

Source§

type Properties = T

Frontmatter properties type
Source§

type Error = Error

Error type
Source§

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

Get note name
Source§

fn count_words_from_content(&self) -> Result<usize, Self::Error>

Get count words from content Read more
Source§

fn count_symbols_from_content(&self) -> Result<usize, Self::Error>

Get count symbols from content Read more
Source§

impl<T> NoteFromFile for NoteInMemory<T>

Available on non-target_family=wasm only.
Source§

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

Parses an Obsidian note from a file Read more
Source§

impl<T> NoteFromString for NoteInMemory<T>

Source§

fn from_string(raw_text: impl AsRef<str>) -> Result<Self, 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 text = r#"---
title: Example
---
Content"#;

let note: NoteInMemory<NoteProperties> = NoteInMemory::from_string(text).unwrap();
let properties = note.properties().unwrap().unwrap();

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

impl<T> PartialEq for NoteInMemory<T>
where T: Clone + PartialEq,

Source§

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

Source§

impl<T> StructuralPartialEq for NoteInMemory<T>
where T: Clone,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for NoteInMemory<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

Checks if this value is equivalent to the given key. 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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

Checks if this value is equivalent to the given key. 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> NoteDefault for T
where T: Note<Properties = HashMap<String, Value>>,

Source§

fn from_string_default( raw_text: impl AsRef<str>, ) -> Result<T, <T as Note>::Error>

Same as NoteFromString::from_string with default properties type
Source§

fn from_file_default(path: impl AsRef<Path>) -> Result<T, <T as Note>::Error>

Available on non-target_family=wasm only.
Same as crate::note::NoteFromFile::from_file with default properties type
Source§

fn from_reader_default(reader: &mut impl Read) -> Result<T, <T as Note>::Error>

Same as NoteFromReader::from_reader with default properties type
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.