DocumentLoader

Trait DocumentLoader 

Source
pub trait DocumentLoader<T: Send>:
    Clone
    + Send
    + Sync {
    // Required methods
    fn parse_content(&self, content: &str, path: Option<&Path>) -> Result<T>;
    fn doc_type_name(&self) -> &'static str;
    fn file_filter(&self) -> fn(&Path) -> bool;

    // Provided methods
    fn load_file<'life0, 'life1, 'async_trait>(
        &'life0 self,
        path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn load_directory<'life0, 'life1, 'async_trait>(
        &'life0 self,
        dir: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
       where T: 'static,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn load_inline(&self, content: &str) -> Result<T> { ... }
}
Expand description

Trait for loading items from files.

Implementors only need to implement parse_content(), doc_type_name(), and file_filter(). The load_file() and load_directory() methods have default implementations.

Required Methods§

Source

fn parse_content(&self, content: &str, path: Option<&Path>) -> Result<T>

Parse content into the target type.

Source

fn doc_type_name(&self) -> &'static str

Document type name for error messages (e.g., “skill”, “subagent”, “output style”).

Source

fn file_filter(&self) -> fn(&Path) -> bool

File filter function for directory loading.

Provided Methods§

Source

fn load_file<'life0, 'life1, 'async_trait>( &'life0 self, path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load an item from a file path.

Source

fn load_directory<'life0, 'life1, 'async_trait>( &'life0 self, dir: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where T: 'static, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load all items from a directory.

Source

fn load_inline(&self, content: &str) -> Result<T>

Load from inline content.

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§

Source§

impl DocumentLoader<OutputStyle> for OutputStyleLoader

Available on crate feature cli-integration only.