pub struct MarkdownFile<T: DeserializeOwned> {
pub frontmatter: Option<T>,
pub content: String,
}Expand description
Represents a parsed markdown file with optional frontmatter
Fields§
§frontmatter: Option<T>Parsed frontmatter (if present)
content: StringThe content after frontmatter
Implementations§
Source§impl<T: DeserializeOwned + Send + 'static> MarkdownFile<T>
impl<T: DeserializeOwned + Send + 'static> MarkdownFile<T>
pub fn parse(path: impl AsRef<Path>) -> Result<Self, ParseError>
Sourcepub fn list(dir: impl AsRef<Path>) -> Result<Vec<PathBuf>, Error>
pub fn list(dir: impl AsRef<Path>) -> Result<Vec<PathBuf>, Error>
List all markdown files in a directory
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self, ParseError>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self, ParseError>
Load a single markdown file from a path
Sourcepub async fn from_dir(dir: &PathBuf) -> Result<Vec<(PathBuf, Self)>, Error>
pub async fn from_dir(dir: &PathBuf) -> Result<Vec<(PathBuf, Self)>, Error>
Load all markdown files from a directory
Sourcepub async fn from_nested_dirs(
parent_dir: impl AsRef<Path>,
filename: &str,
) -> Result<Vec<(PathBuf, Self)>, Error>
pub async fn from_nested_dirs( parent_dir: impl AsRef<Path>, filename: &str, ) -> Result<Vec<(PathBuf, Self)>, Error>
Load all markdown files from nested subdirectories, where each subdirectory contains a file with the specified filename.
Flat files in the parent directory are ignored. Only subdirectories containing the specified filename are processed.
§Example
ⓘ
// Load from:
// skills/skill-1/SKILL.md
// skills/skill-2/SKILL.md
// skills/flat-file.md -> ignored (not in a subdirectory)
let skills = MarkdownFile::from_nested_dirs(Path::new("skills"), "SKILL.md").await?;Trait Implementations§
Source§impl<T: Clone + DeserializeOwned> Clone for MarkdownFile<T>
impl<T: Clone + DeserializeOwned> Clone for MarkdownFile<T>
Source§fn clone(&self) -> MarkdownFile<T>
fn clone(&self) -> MarkdownFile<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 moreAuto Trait Implementations§
impl<T> Freeze for MarkdownFile<T>where
T: Freeze,
impl<T> RefUnwindSafe for MarkdownFile<T>where
T: RefUnwindSafe,
impl<T> Send for MarkdownFile<T>where
T: Send,
impl<T> Sync for MarkdownFile<T>where
T: Sync,
impl<T> Unpin for MarkdownFile<T>where
T: Unpin,
impl<T> UnsafeUnpin for MarkdownFile<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for MarkdownFile<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