Trait burn::record::Recorder

pub trait Recorder<B>: Send + Sync + Default + Debug + Clone
where B: Backend,
{ type Settings: PrecisionSettings; type RecordArgs: Clone; type RecordOutput; type LoadArgs: Clone; // Required methods fn save_item<I>( &self, item: I, args: Self::RecordArgs, ) -> Result<Self::RecordOutput, RecorderError> where I: Serialize; fn load_item<I>(&self, args: Self::LoadArgs) -> Result<I, RecorderError> where I: DeserializeOwned; // Provided methods fn record<R>( &self, record: R, args: Self::RecordArgs, ) -> Result<Self::RecordOutput, RecorderError> where R: Record<B> { ... } fn load<R>( &self, args: Self::LoadArgs, device: &<B as Backend>::Device, ) -> Result<R, RecorderError> where R: Record<B> { ... } }
Expand description

Record any item implementing Serialize and DeserializeOwned.

Required Associated Types§

type Settings: PrecisionSettings

Type of the settings used by the recorder.

type RecordArgs: Clone

Arguments used to record objects.

type RecordOutput

Record output type.

type LoadArgs: Clone

Arguments used to load recorded objects.

Required Methods§

fn save_item<I>( &self, item: I, args: Self::RecordArgs, ) -> Result<Self::RecordOutput, RecorderError>
where I: Serialize,

Saves an item.

This method is used by record to save the item.

§Arguments
  • item - Item to save.
  • args - Arguments to use to save the item.
§Returns

The output of the save operation.

fn load_item<I>(&self, args: Self::LoadArgs) -> Result<I, RecorderError>

Loads an item.

This method is used by load to load the item.

§Arguments
  • args - Arguments to use to load the item.
§Returns

The loaded item.

Provided Methods§

fn record<R>( &self, record: R, args: Self::RecordArgs, ) -> Result<Self::RecordOutput, RecorderError>
where R: Record<B>,

Records an item.

§Arguments
  • record - The item to record.
  • args - Arguments used to record the item.
§Returns

The output of the recording.

fn load<R>( &self, args: Self::LoadArgs, device: &<B as Backend>::Device, ) -> Result<R, RecorderError>
where R: Record<B>,

Load an item from the given arguments.

Object Safety§

This trait is not object safe.

Implementors§