Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn capabilities(&self) -> BackendCapabilities;
    fn supports(&self, model: &ModelSpec) -> bool;
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelSpec,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<ModelHandle>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn infer<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelHandle,
        request: &'life2 InferenceRequest,
        cancellation: Option<CancellationToken>,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<InferenceResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn infer_stream<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelHandle,
        request: &'life2 InferenceRequest,
        cancellation: Option<CancellationToken>,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<BoxStream<RuntimeResult<InferenceChunk>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn infer_batch<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        model: &'life1 ModelHandle,
        requests: &'life2 [InferenceRequest],
        cancellation: Option<CancellationToken>,
    ) -> Pin<Box<dyn Future<Output = RuntimeResult<Vec<InferenceResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}

Required Methods§

Source

fn name(&self) -> &str

Source

fn capabilities(&self) -> BackendCapabilities

Source

fn supports(&self, model: &ModelSpec) -> bool

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, model: &'life1 ModelSpec, ) -> Pin<Box<dyn Future<Output = RuntimeResult<ModelHandle>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn infer<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, model: &'life1 ModelHandle, request: &'life2 InferenceRequest, cancellation: Option<CancellationToken>, ) -> Pin<Box<dyn Future<Output = RuntimeResult<InferenceResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn infer_stream<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, model: &'life1 ModelHandle, request: &'life2 InferenceRequest, cancellation: Option<CancellationToken>, ) -> Pin<Box<dyn Future<Output = RuntimeResult<BoxStream<RuntimeResult<InferenceChunk>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Provided Methods§

Source

fn infer_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, model: &'life1 ModelHandle, requests: &'life2 [InferenceRequest], cancellation: Option<CancellationToken>, ) -> Pin<Box<dyn Future<Output = RuntimeResult<Vec<InferenceResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§