Skip to main content

ruda_model/record/
base.rs

1pub use ruda_model_macros::Record;
2use ruda_tensor::api::backend::Backend;
3
4use super::PrecisionSettings;
5use serde::{Serialize, de::DeserializeOwned};
6
7/// Trait to define a family of types which can be recorded using any [settings](PrecisionSettings).
8pub trait Record<B: Backend>: Send {
9    /// Type of the item that can be serialized and deserialized.
10    type Item<S: PrecisionSettings>: Serialize + DeserializeOwned + Clone;
11
12    /// Convert the current record into the corresponding item that follows the given [settings](PrecisionSettings).
13    fn into_item<S: PrecisionSettings>(self) -> Self::Item<S>;
14
15    /// Convert the given item into a record.
16    fn from_item<S: PrecisionSettings>(item: Self::Item<S>, device: &B::Device) -> Self;
17}