Skip to main content

ferrin_spec/dynamic/
mod.rs

1//! Object-safe adapters (`Dyn*` traits) and reference types.
2//!
3//! Every model trait uses `impl Future` return types and is therefore not
4//! object safe. For each trait this module provides a `Dyn*` counterpart that
5//! boxes the futures, a blanket implementation so that every concrete model
6//! is also a `Dyn*`, and a cloneable reference type (`*Ref`) wrapping
7//! `Arc<dyn Dyn*>`.
8//!
9//! Only import a `Dyn*` trait where you hold a trait object; importing both
10//! `LanguageModel` and `DynLanguageModel` makes method calls on a concrete
11//! model ambiguous.
12
13use std::future::Future;
14use std::pin::Pin;
15
16use futures_core::Stream;
17
18mod batch;
19mod embedding_model;
20mod files;
21mod image_model;
22mod language_model;
23mod model_ref;
24mod realtime_model;
25mod reranking_model;
26mod skills;
27mod speech_model;
28mod speech_translation_model;
29mod transcription_model;
30mod video_model;
31
32pub use batch::BatchRef;
33pub use batch::DynBatch;
34pub use embedding_model::DynEmbeddingModel;
35pub use embedding_model::EmbeddingModelRef;
36pub use files::DynFiles;
37pub use files::FilesRef;
38pub use image_model::DynImageModel;
39pub use image_model::ImageModelRef;
40pub use language_model::DynLanguageModel;
41pub use language_model::LanguageModelRef;
42pub use model_ref::ModelRef;
43pub use model_ref::ServiceRef;
44pub use realtime_model::DynRealtimeFactory;
45pub use realtime_model::DynRealtimeModel;
46pub use realtime_model::RealtimeFactoryRef;
47pub use realtime_model::RealtimeModelRef;
48pub use reranking_model::DynRerankingModel;
49pub use reranking_model::RerankingModelRef;
50pub use skills::DynSkills;
51pub use skills::SkillsRef;
52pub use speech_model::DynSpeechModel;
53pub use speech_model::SpeechModelRef;
54pub use speech_translation_model::DynSpeechTranslationModel;
55pub use speech_translation_model::SpeechTranslationModelRef;
56pub use transcription_model::DynTranscriptionModel;
57pub use transcription_model::TranscriptionModelRef;
58pub use video_model::DynVideoModel;
59pub use video_model::VideoModelRef;
60
61/// A boxed, `Send` future.
62pub type BoxFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
63
64/// A boxed, `Send` stream.
65pub type BoxStream<'a, T> = Pin<Box<dyn Stream<Item = T> + Send + 'a>>;