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§
Sourcetype Interface: Read + ReadReady + Write
type Interface: Read + ReadReady + Write
This type specifies the interface to the user, for example, a USB CDC-ACM serial port.
type Error: Debug
type Settings: Settings
Required Methods§
Sourcefn fetch<'a>(
&mut self,
buf: &'a mut [u8],
key: &[u8],
) -> Result<Option<&'a [u8]>, Self::Error>
fn fetch<'a>( &mut self, buf: &'a mut [u8], key: &[u8], ) -> Result<Option<&'a [u8]>, Self::Error>
Fetch a value from persisten storage
Sourcefn store(
&mut self,
buf: &mut [u8],
key: &[u8],
value: &[u8],
) -> Result<(), Self::Error>
fn store( &mut self, buf: &mut [u8], key: &[u8], value: &[u8], ) -> Result<(), Self::Error>
Store a value to persistent storage
Sourcefn clear(&mut self, buf: &mut [u8], key: &[u8]) -> Result<(), Self::Error>
fn clear(&mut self, buf: &mut [u8], key: &[u8]) -> Result<(), Self::Error>
Remove a key from storage.
Sourcefn interface_mut(&mut self) -> &mut Self::Interface
fn interface_mut(&mut self) -> &mut Self::Interface
Return a mutable reference to the Interface
.