Trait Platform

Source
pub trait Platform {
    type Interface: Read + ReadReady + Write;
    type Error: Debug;
    type Settings: Settings;

    // Required methods
    fn fetch<'a>(
        &mut self,
        buf: &'a mut [u8],
        key: &[u8],
    ) -> Result<Option<&'a [u8]>, Self::Error>;
    fn store(
        &mut self,
        buf: &mut [u8],
        key: &[u8],
        value: &[u8],
    ) -> Result<(), Self::Error>;
    fn clear(&mut self, buf: &mut [u8], key: &[u8]) -> Result<(), Self::Error>;
    fn cmd(&mut self, cmd: &str);
    fn interface_mut(&mut self) -> &mut Self::Interface;
}
Expand description

Platform support for serial settings.

Covers platform-specific commands, persistent key-value storage and the Read/Write interface for interaction.

Assuming there are no unit fields in the Settings, the empty value can be used to mark the “cleared” state.

Required Associated Types§

Source

type Interface: Read + ReadReady + Write

This type specifies the interface to the user, for example, a USB CDC-ACM serial port.

Source

type Error: Debug

Source

type Settings: Settings

Required Methods§

Source

fn fetch<'a>( &mut self, buf: &'a mut [u8], key: &[u8], ) -> Result<Option<&'a [u8]>, Self::Error>

Fetch a value from persisten storage

Source

fn store( &mut self, buf: &mut [u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>

Store a value to persistent storage

Source

fn clear(&mut self, buf: &mut [u8], key: &[u8]) -> Result<(), Self::Error>

Remove a key from storage.

Source

fn cmd(&mut self, cmd: &str)

Execute a platform specific command.

Source

fn interface_mut(&mut self) -> &mut Self::Interface

Return a mutable reference to the Interface.

Implementors§