Note

Trait Note 

Source
pub trait Note: Sized {
    type Properties: Clone;
    type Error: Error;

    // Required methods
    fn properties(
        &self,
    ) -> Result<Option<Cow<'_, Self::Properties>>, Self::Error>;
    fn content(&self) -> Result<Cow<'_, str>, Self::Error>;
    fn path(&self) -> Option<Cow<'_, Path>>;

    // Provided method
    fn note_name(&self) -> Option<String> { ... }
}
Expand description

Represents an Obsidian note file with frontmatter properties and content

This trait provides a standardized interface for working with Obsidian markdown files, handling frontmatter parsing, content extraction, and file operations.

§Example

use obsidian_parser::prelude::*;
use serde::Deserialize;

#[derive(Deserialize, Clone)]
struct NoteProperties {
    topic: String,
    created: String,
}

let note: NoteInMemory<NoteProperties> = NoteFromFile::from_file("note.md").unwrap();
let properties = note.properties().unwrap().unwrap();
println!("Note topic: {}", properties.topic);

§Other

Required Associated Types§

Source

type Properties: Clone

Frontmatter properties type

Source

type Error: Error

Error type

Required Methods§

Source

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

Returns the parsed properties of frontmatter

Returns None if the note has no properties

Source

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

Returns the main content body of the note (excluding frontmatter)

§Implementation Notes
  • Strips YAML frontmatter if present
  • Preserves original formatting and whitespace
Source

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

Returns the source file path if available

Returns None for in-memory notes without physical storage

Provided Methods§

Source

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

Get note name

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§