Trait Recorder

Source
pub trait Recorder<B: Backend>:
    Send
    + Sync
    + Default
    + Debug
    + Clone {
    type Settings: PrecisionSettings;
    type RecordArgs: Clone;
    type RecordOutput;
    type LoadArgs;

    // Required methods
    fn save_item<I: Serialize>(
        &self,
        item: I,
        args: Self::RecordArgs,
    ) -> Result<Self::RecordOutput, RecorderError>;
    fn load_item<I>(
        &self,
        args: &mut 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::Device,
    ) -> Result<R, RecorderError>
       where R: Record<B> { ... }
}
Expand description

Record any item implementing Serialize and DeserializeOwned.

Required Associated Types§

Source

type Settings: PrecisionSettings

Type of the settings used by the recorder.

Source

type RecordArgs: Clone

Arguments used to record objects.

Source

type RecordOutput

Record output type.

Source

type LoadArgs

Arguments used to load recorded objects.

Required Methods§

Source

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

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.

Source

fn load_item<I>(&self, args: &mut 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§

Source

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.

Source

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

Load an item from the given arguments.

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.

Implementors§

Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for BinFileRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for BinGzFileRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for JsonGzFileRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for NamedMpkBytesRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for NamedMpkFileRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for NamedMpkGzFileRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend> Recorder<B> for PrettyJsonFileRecorder<S>

Available on crate feature std only.
Source§

impl<S: PrecisionSettings, B: Backend, L: AsRef<[u8]> + Send + Sync + Debug + Clone + Default> Recorder<B> for BinBytesRecorder<S, L>