pub struct MarkdownIngester { /* private fields */ }Expand description
Markdown file ingester that parses and chunks markdown documents.
The ingester handles:
- YAML front-matter extraction
- Content chunking by headings
- Code block preservation with language tags
- Recursive directory traversal
Implementations§
Source§impl MarkdownIngester
impl MarkdownIngester
Sourcepub fn with_config(config: IngesterConfig) -> Self
pub fn with_config(config: IngesterConfig) -> Self
Create a new markdown ingester with custom configuration.
Sourcepub async fn ingest_file(&self, path: &Path) -> Result<MarkdownDocument>
pub async fn ingest_file(&self, path: &Path) -> Result<MarkdownDocument>
Ingest a single markdown file.
This method reads the file, extracts front-matter, parses the markdown, and returns a structured document with chunks.
§Arguments
path- Path to the markdown file
§Returns
A MarkdownDocument containing the parsed content and metadata
§Errors
Returns an error if the file cannot be read or is not valid UTF-8
Sourcepub async fn ingest_directory(
&self,
dir: &Path,
recursive: bool,
) -> Result<Vec<MarkdownDocument>>
pub async fn ingest_directory( &self, dir: &Path, recursive: bool, ) -> Result<Vec<MarkdownDocument>>
Sourcepub fn extract_frontmatter(
content: &str,
) -> (Option<HashMap<String, String>>, &str)
pub fn extract_frontmatter( content: &str, ) -> (Option<HashMap<String, String>>, &str)
Extract YAML front-matter from markdown content.
Front-matter is expected to be at the very beginning of the file,
delimited by --- lines. For example:
---
title: My Document
author: John Doe
date: 2024-01-15
---
# Document content starts here§Arguments
content- The full markdown file content
§Returns
A tuple of (optional metadata HashMap, remaining content after front-matter)
Trait Implementations§
Source§impl Clone for MarkdownIngester
impl Clone for MarkdownIngester
Source§fn clone(&self) -> MarkdownIngester
fn clone(&self) -> MarkdownIngester
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 Debug for MarkdownIngester
impl Debug for MarkdownIngester
Auto Trait Implementations§
impl Freeze for MarkdownIngester
impl RefUnwindSafe for MarkdownIngester
impl Send for MarkdownIngester
impl Sync for MarkdownIngester
impl Unpin for MarkdownIngester
impl UnsafeUnpin for MarkdownIngester
impl UnwindSafe for MarkdownIngester
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request