use crate::completion::{CompletionHandle, ContractResponse};
use crate::runtime::RuntimeResourceRef;
pub trait Codec: Send + Sync {
type In: ?Sized + bb_ir::types::Storage;
type Out: ?Sized + bb_ir::types::Storage;
type Error: std::error::Error + std::fmt::Display + Send + Sync + 'static;
fn train(
&mut self,
_ctx: &mut RuntimeResourceRef<'_>,
_samples: &[&Self::In],
_completion: CompletionHandle<(), Self::Error>,
) -> ContractResponse<(), Self::Error> {
ContractResponse::Now(Ok(()))
}
fn encode(
&self,
ctx: &mut RuntimeResourceRef<'_>,
input: &Self::In,
completion: CompletionHandle<Box<Self::Out>, Self::Error>,
) -> ContractResponse<Box<Self::Out>, Self::Error>;
fn decode(
&self,
ctx: &mut RuntimeResourceRef<'_>,
encoded: &Self::Out,
completion: CompletionHandle<Box<Self::In>, Self::Error>,
) -> ContractResponse<Box<Self::In>, Self::Error>;
}