Trait Record
pub trait Record<B>: Sendwhere
B: Backend,{
type Item<S: PrecisionSettings>: Serialize + DeserializeOwned + Clone;
// Required methods
fn into_item<S>(self) -> Self::Item<S>
where S: PrecisionSettings;
fn from_item<S>(
item: Self::Item<S>,
device: &<B as BackendTypes>::Device,
) -> Self
where S: PrecisionSettings;
}Expand description
Trait to define a family of types which can be recorded using any settings.
Required Associated Types§
type Item<S: PrecisionSettings>: Serialize + DeserializeOwned + Clone
type Item<S: PrecisionSettings>: Serialize + DeserializeOwned + Clone
Type of the item that can be serialized and deserialized.
Required Methods§
fn into_item<S>(self) -> Self::Item<S>where
S: PrecisionSettings,
fn into_item<S>(self) -> Self::Item<S>where
S: PrecisionSettings,
Convert the current record into the corresponding item that follows the given settings.
fn from_item<S>(
item: Self::Item<S>,
device: &<B as BackendTypes>::Device,
) -> Selfwhere
S: PrecisionSettings,
fn from_item<S>(
item: Self::Item<S>,
device: &<B as BackendTypes>::Device,
) -> Selfwhere
S: PrecisionSettings,
Convert the given item into a record.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
§impl<B> Record<B> for boolwhere
B: Backend,
impl<B> Record<B> for boolwhere
B: Backend,
type Item<S: PrecisionSettings> = bool
fn into_item<S>(self) -> <bool as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <bool as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> boolwhere
S: PrecisionSettings,
§impl<B> Record<B> for f32where
B: Backend,
impl<B> Record<B> for f32where
B: Backend,
type Item<S: PrecisionSettings> = f32
fn into_item<S>(self) -> <f32 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <f32 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> f32where
S: PrecisionSettings,
§impl<B> Record<B> for f64where
B: Backend,
impl<B> Record<B> for f64where
B: Backend,
type Item<S: PrecisionSettings> = f64
fn into_item<S>(self) -> <f64 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <f64 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> f64where
S: PrecisionSettings,
§impl<B> Record<B> for i8where
B: Backend,
impl<B> Record<B> for i8where
B: Backend,
type Item<S: PrecisionSettings> = i8
fn into_item<S>(self) -> <i8 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <i8 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> i8where
S: PrecisionSettings,
§impl<B> Record<B> for i16where
B: Backend,
impl<B> Record<B> for i16where
B: Backend,
type Item<S: PrecisionSettings> = i16
fn into_item<S>(self) -> <i16 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <i16 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> i16where
S: PrecisionSettings,
§impl<B> Record<B> for i32where
B: Backend,
impl<B> Record<B> for i32where
B: Backend,
type Item<S: PrecisionSettings> = i32
fn into_item<S>(self) -> <i32 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <i32 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> i32where
S: PrecisionSettings,
§impl<B> Record<B> for i64where
B: Backend,
impl<B> Record<B> for i64where
B: Backend,
type Item<S: PrecisionSettings> = i64
fn into_item<S>(self) -> <i64 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <i64 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> i64where
S: PrecisionSettings,
§impl<B> Record<B> for isizewhere
B: Backend,
impl<B> Record<B> for isizewhere
B: Backend,
type Item<S: PrecisionSettings> = isize
fn into_item<S>(self) -> <isize as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <isize as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> isizewhere
S: PrecisionSettings,
§impl<B> Record<B> for u8where
B: Backend,
impl<B> Record<B> for u8where
B: Backend,
type Item<S: PrecisionSettings> = u8
fn into_item<S>(self) -> <u8 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <u8 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> u8where
S: PrecisionSettings,
§impl<B> Record<B> for u16where
B: Backend,
impl<B> Record<B> for u16where
B: Backend,
type Item<S: PrecisionSettings> = u16
fn into_item<S>(self) -> <u16 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <u16 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> u16where
S: PrecisionSettings,
§impl<B> Record<B> for u32where
B: Backend,
impl<B> Record<B> for u32where
B: Backend,
type Item<S: PrecisionSettings> = u32
fn into_item<S>(self) -> <u32 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <u32 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> u32where
S: PrecisionSettings,
§impl<B> Record<B> for u64where
B: Backend,
impl<B> Record<B> for u64where
B: Backend,
type Item<S: PrecisionSettings> = u64
fn into_item<S>(self) -> <u64 as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <u64 as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> u64where
S: PrecisionSettings,
§impl<B> Record<B> for ()where
B: Backend,
impl<B> Record<B> for ()where
B: Backend,
type Item<S: PrecisionSettings> = ()
fn into_item<S>(self) -> <() as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
_item: <() as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
)where
S: PrecisionSettings,
§impl<B> Record<B> for usizewhere
B: Backend,
impl<B> Record<B> for usizewhere
B: Backend,
type Item<S: PrecisionSettings> = usize
fn into_item<S>(self) -> <usize as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <usize as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> usizewhere
S: PrecisionSettings,
§impl<B> Record<B> for Stringwhere
B: Backend,
impl<B> Record<B> for Stringwhere
B: Backend,
type Item<S: PrecisionSettings> = String
fn into_item<S>(self) -> <String as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <String as Record<B>>::Item<S>,
_device: &<B as BackendTypes>::Device,
) -> Stringwhere
S: PrecisionSettings,
§impl<B, R0> Record<B> for (R0,)
impl<B, R0> Record<B> for (R0,)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>,)
fn into_item<S>(self) -> <(R0,) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0,) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0,)where
S: PrecisionSettings,
§impl<B, R0, R1> Record<B> for (R0, R1)
impl<B, R0, R1> Record<B> for (R0, R1)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>)
fn into_item<S>(self) -> <(R0, R1) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1)where
S: PrecisionSettings,
§impl<B, R0, R1, R2> Record<B> for (R0, R1, R2)
impl<B, R0, R1, R2> Record<B> for (R0, R1, R2)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>)
fn into_item<S>(self) -> <(R0, R1, R2) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3> Record<B> for (R0, R1, R2, R3)
impl<B, R0, R1, R2, R3> Record<B> for (R0, R1, R2, R3)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>)
fn into_item<S>(self) -> <(R0, R1, R2, R3) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3, R4> Record<B> for (R0, R1, R2, R3, R4)
impl<B, R0, R1, R2, R3, R4> Record<B> for (R0, R1, R2, R3, R4)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>, <R4 as Record<B>>::Item<S>)
fn into_item<S>(self) -> <(R0, R1, R2, R3, R4) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3, R4) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3, R4)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3, R4, R5> Record<B> for (R0, R1, R2, R3, R4, R5)
impl<B, R0, R1, R2, R3, R4, R5> Record<B> for (R0, R1, R2, R3, R4, R5)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>, <R4 as Record<B>>::Item<S>, <R5 as Record<B>>::Item<S>)
fn into_item<S>(self) -> <(R0, R1, R2, R3, R4, R5) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3, R4, R5) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3, R4, R5)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3, R4, R5, R6> Record<B> for (R0, R1, R2, R3, R4, R5, R6)
impl<B, R0, R1, R2, R3, R4, R5, R6> Record<B> for (R0, R1, R2, R3, R4, R5, R6)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>, <R4 as Record<B>>::Item<S>, <R5 as Record<B>>::Item<S>, <R6 as Record<B>>::Item<S>)
fn into_item<S>(self) -> <(R0, R1, R2, R3, R4, R5, R6) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3, R4, R5, R6) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3, R4, R5, R6)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3, R4, R5, R6, R7> Record<B> for (R0, R1, R2, R3, R4, R5, R6, R7)
impl<B, R0, R1, R2, R3, R4, R5, R6, R7> Record<B> for (R0, R1, R2, R3, R4, R5, R6, R7)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>, <R4 as Record<B>>::Item<S>, <R5 as Record<B>>::Item<S>, <R6 as Record<B>>::Item<S>, <R7 as Record<B>>::Item<S>)
fn into_item<S>(
self,
) -> <(R0, R1, R2, R3, R4, R5, R6, R7) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3, R4, R5, R6, R7) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3, R4, R5, R6, R7)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3, R4, R5, R6, R7, R8> Record<B> for (R0, R1, R2, R3, R4, R5, R6, R7, R8)
impl<B, R0, R1, R2, R3, R4, R5, R6, R7, R8> Record<B> for (R0, R1, R2, R3, R4, R5, R6, R7, R8)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>, <R4 as Record<B>>::Item<S>, <R5 as Record<B>>::Item<S>, <R6 as Record<B>>::Item<S>, <R7 as Record<B>>::Item<S>, <R8 as Record<B>>::Item<S>)
fn into_item<S>(
self,
) -> <(R0, R1, R2, R3, R4, R5, R6, R7, R8) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3, R4, R5, R6, R7, R8) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3, R4, R5, R6, R7, R8)where
S: PrecisionSettings,
§impl<B, R0, R1, R2, R3, R4, R5, R6, R7, R8, R9> Record<B> for (R0, R1, R2, R3, R4, R5, R6, R7, R8, R9)
impl<B, R0, R1, R2, R3, R4, R5, R6, R7, R8, R9> Record<B> for (R0, R1, R2, R3, R4, R5, R6, R7, R8, R9)
type Item<S: PrecisionSettings> = (<R0 as Record<B>>::Item<S>, <R1 as Record<B>>::Item<S>, <R2 as Record<B>>::Item<S>, <R3 as Record<B>>::Item<S>, <R4 as Record<B>>::Item<S>, <R5 as Record<B>>::Item<S>, <R6 as Record<B>>::Item<S>, <R7 as Record<B>>::Item<S>, <R8 as Record<B>>::Item<S>, <R9 as Record<B>>::Item<S>)
fn into_item<S>(
self,
) -> <(R0, R1, R2, R3, R4, R5, R6, R7, R8, R9) as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <(R0, R1, R2, R3, R4, R5, R6, R7, R8, R9) as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> (R0, R1, R2, R3, R4, R5, R6, R7, R8, R9)where
S: PrecisionSettings,
§impl<T, B> Record<B> for HashMap<ParamId, T>
impl<T, B> Record<B> for HashMap<ParamId, T>
type Item<S: PrecisionSettings> = HashMap<String, <T as Record<B>>::Item<S>>
fn into_item<S>(self) -> <HashMap<ParamId, T> as Record<B>>::Item<S>where
S: PrecisionSettings,
fn from_item<S>(
item: <HashMap<ParamId, T> as Record<B>>::Item<S>,
device: &<B as BackendTypes>::Device,
) -> HashMap<ParamId, T>where
S: PrecisionSettings,
§impl<const N: usize, T, B> Record<B> for [T; N]
impl<const N: usize, T, B> Record<B> for [T; N]
§type Item<S: PrecisionSettings> = Array<N, <T as Record<B>>::Item<S>>
type Item<S: PrecisionSettings> = Array<N, <T as Record<B>>::Item<S>>
The record item is an array of the record item of the elements. The reason why we wrap the array in a struct is because serde does not support deserializing arrays of variable size, see serde/issues/1937. for backward compatibility reasons. Serde APIs were created before const generics.