FromMemoryBackend

Trait FromMemoryBackend 

Source
pub trait FromMemoryBackend: Sized {
    // Required methods
    fn from_memory_backend(
        memory: MemoryBackend,
    ) -> impl Future<Output = Result<Self>> + Send;
    fn initialize_memory_backend(
        memory: MemoryBackend,
    ) -> impl Future<Output = Result<Self>> + Send;
    fn close_memory(self) -> MemoryBackend;
}
Expand description

A trait for types that can be constructed from a memory device.

This trait provides an asynchronous interface for creating instances of types from a MemoryDevice. Implementors should define how to read and parse data from the memory device to construct their specific type.

§Errors

Implementations should return an error if:

  • The memory device cannot be accessed
  • The data format is invalid or corrupted
  • Required data is missing from the memory device

Required Methods§

Source

fn from_memory_backend( memory: MemoryBackend, ) -> impl Future<Output = Result<Self>> + Send

Create a memory-specific type from a MemoryBackend. When created the memory is automatically read to populate the fields of the type.

§Arguments
  • memory - The MemoryBackend to read from
§Returns

A Result containing the constructed type or an Error if the operation fails

Source

fn initialize_memory_backend( memory: MemoryBackend, ) -> impl Future<Output = Result<Self>> + Send

Get a specific memory by its ID and initialize it according to the defaults. Note that the values will not be written to the memory by default, the user needs to handle this.

§Arguments
  • memory - The MemoryDevice struct representing the memory to get
§Returns

An Option containing a reference to the MemoryDevice struct if found, or None if not found

Source

fn close_memory(self) -> MemoryBackend

Close the memory and return the backend to the subsystem

§Arguments
  • memory_device - The MemoryDevice struct representing the memory to close
  • backend - The MemoryBackend to return to the subsystem

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§