use futures::stream::BoxStream; use crate::common::{ entities::{DecodedValue, Dict, DictEntry, EncodedValue}, errors::{CodecError, RepositoryError}, }; pub trait SystemDecoder: Send + Sync { fn decode(&self, word: &str) -> Result; } pub trait SystemEncoder: Send + Sync { fn initialize(&self) -> Result<(), CodecError>; fn encode(&self, word: &str) -> Result; } #[async_trait::async_trait] pub trait DictRepository: Send + Sync { fn use_dict(&mut self, name: &str); async fn create_dict(&self) -> Result<(), RepositoryError>; /// "Upsert" logic: /// - If entry exists (by text), update metadata. /// - If not, insert new. /// - IDs are handled by the Database. async fn save_entries(&self, entries: &[DictEntry]) -> Result<(), RepositoryError>; /// Fetch a page of entries. async fn fetch_many(&self, limit: usize, offset: usize) -> Result; /// Returns a cold stream that fetches strings in chunks. /// The stream yields `Result, RepositoryError>`. async fn stream_batches( &self, batch_size: usize, ) -> Result, RepositoryError>>, RepositoryError>; } pub trait DictSource { fn next_entry(&mut self) -> Option>; }