pub struct Locked<'invoker, 'buffer, B: Buffer> { /* private fields */ }
Expand description
An EEPROM component on which methods can be invoked.
This type combines an EEPROM address, an Invoker
that can be used to make method calls, and
a scratch buffer used to perform CBOR encoding and decoding. A value of this type can be
created by calling Eeprom::lock
, and it can be dropped to return the borrow of the invoker
and buffer to the caller so they can be reused for other purposes.
The 'invoker
lifetime is the lifetime of the invoker. The 'buffer
lifetime is the lifetime
of the buffer. The B
type is the type of scratch buffer to use.
Implementations§
Source§impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>
impl<'invoker, 'buffer, B: Buffer> Locked<'invoker, 'buffer, B>
Sourcepub async fn get(self) -> Result<&'buffer [u8], Error>
pub async fn get(self) -> Result<&'buffer [u8], Error>
Returns the contents of the main storage area.
In an EEPROM used for booting, the main storage area contains the BIOS code.
The returned byte slice points into, and therefore retains ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.
§Errors
Sourcepub async fn set(&mut self, data: &[u8]) -> Result<(), Error>
pub async fn set(&mut self, data: &[u8]) -> Result<(), Error>
Writes to the main storage area.
In an EEPROM used for booting, the main storage area contains the BIOS code.
§Errors
Sourcepub async fn get_label(self) -> Result<&'buffer str, Error>
pub async fn get_label(self) -> Result<&'buffer str, Error>
Returns the label, if it has one.
The label is displayed in the item’s tooltip.
The returned string slice points into, and therefore retains ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.
§Errors
Sourcepub async fn set_label(self, label: &str) -> Result<&'buffer str, Error>
pub async fn set_label(self, label: &str) -> Result<&'buffer str, Error>
Sets the label and returns the new label, which may be truncated.
The label is displayed in the item’s tooltip.
The returned string slice points into, and therefore retains ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.
§Errors
Sourcepub async fn get_checksum(&mut self) -> Result<u32, Error>
pub async fn get_checksum(&mut self) -> Result<u32, Error>
Sourcepub async fn make_read_only(&mut self, checksum: u32) -> Result<(), Error>
pub async fn make_read_only(&mut self, checksum: u32) -> Result<(), Error>
Makes the EEPROM read-only.
A read-only EEPROM’s main storage area and label cannot be modified. Its volatile data area can still be modified. A read-only EEPROM cannot be made read-write again later.
For safety, the checksum value must be passed as a parameter.
If the EEPROM is already read-only, this method successfully does nothing (assuming the checksum is correct).
§Errors
Sourcepub async fn get_data_size(&mut self) -> Result<usize, Error>
pub async fn get_data_size(&mut self) -> Result<usize, Error>
Sourcepub async fn get_data(self) -> Result<&'buffer [u8], Error>
pub async fn get_data(self) -> Result<&'buffer [u8], Error>
Returns the contents of the volatile data area.
In an EEPROM used for booting, the volatile data area contains the UUID of the filesystem to prefer booting from.
The returned byte slice points into, and therefore retains ownership of, the scratch
buffer. Consequently, the Locked
is consumed and cannot be reused.