Skip to main content

arc_impl

Macro arc_impl 

Source
macro_rules! arc_impl {
    ($trait_name:ident {
        $(
            fn $method:ident(&self $(, $arg:ident: $arg_ty:ty)*) -> $ret:ty;
        )*
    }) => { ... };
}
Expand description

Macro to implement traits for Arc where T implements the trait. This eliminates boilerplate Arc delegation code across trait modules.

ยงUsage

For sync traits (methods returning concrete types):

โ“˜
arc_impl!(Embedder {
    fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>>;
    fn dimension(&self) -> usize;
    fn name(&self) -> &str;
});

For async traits (methods returning impl Future):

โ“˜
arc_impl!(VectorStore {
    fn insert_chunks(&self, chunks: Vec<HierarchicalChunk>) -> impl Future<Output = Result<()>> + Send;
    fn search(&self, query_embedding: &[f32], limit: usize, level_filter: Option<ChunkLevel>) -> impl Future<Output = Result<Vec<SearchResult>>> + Send;
});