pub struct ObFileInMemory<T = HashMap<String, Value>>where
T: DeserializeOwned + 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 ObFileOnDisk.
Trait Implementations§
Source§impl<T> Clone for ObFileInMemory<T>
impl<T> Clone for ObFileInMemory<T>
Source§fn clone(&self) -> ObFileInMemory<T>
fn clone(&self) -> ObFileInMemory<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 ObFileInMemory<T>
impl<T> Debug for ObFileInMemory<T>
Source§impl<T> Default for ObFileInMemory<T>
impl<T> Default for ObFileInMemory<T>
Source§fn default() -> ObFileInMemory<T>
fn default() -> ObFileInMemory<T>
Returns the “default value” for a type. Read more
Source§impl<T: DeserializeOwned + Clone> ObFile<T> for ObFileInMemory<T>
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>
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 frontmatterpath- Optional source path for reference
§Process
- Splits text into frontmatter/content sections
- Parses YAML frontmatter if present
- Stores content without frontmatter delimiters
§Errors
Error::InvalidFormatfor malformed frontmatterError::Yamlfor invalid YAML syntax
§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>
fn content(&self) -> Result<Cow<'_, str>, Error>
Returns the main content body of the note (excluding frontmatter) Read more
Source§impl<T> PartialEq for ObFileInMemory<T>
impl<T> PartialEq for ObFileInMemory<T>
impl<T> Eq for ObFileInMemory<T>
impl<T> StructuralPartialEq for ObFileInMemory<T>where
T: DeserializeOwned + Clone,
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> 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