Struct Locked

Source
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>

Source

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
Source

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
Source

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
Source

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
Source

pub async fn get_size(&mut self) -> Result<usize, Error>

Returns the capacity, in bytes, of the main storage area.

§Errors
Source

pub async fn get_checksum(&mut self) -> Result<u32, Error>

Returns the CRC32 of the contents of the main storage area.

§Errors
Source

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
Source

pub async fn get_data_size(&mut self) -> Result<usize, Error>

Returns the capacity, in bytes, of the volatile data area.

§Errors
Source

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.

§Errors
Source

pub async fn set_data(&mut self, data: &[u8]) -> Result<(), Error>

Writes to the volatile data area.

In an EEPROM used for booting, the volatile data area contains the UUID of the filesystem to prefer booting from.

§Errors

Auto Trait Implementations§

§

impl<'invoker, 'buffer, B> Freeze for Locked<'invoker, 'buffer, B>

§

impl<'invoker, 'buffer, B> RefUnwindSafe for Locked<'invoker, 'buffer, B>
where B: RefUnwindSafe,

§

impl<'invoker, 'buffer, B> Send for Locked<'invoker, 'buffer, B>
where B: Send,

§

impl<'invoker, 'buffer, B> Sync for Locked<'invoker, 'buffer, B>
where B: Sync,

§

impl<'invoker, 'buffer, B> Unpin for Locked<'invoker, 'buffer, B>

§

impl<'invoker, 'buffer, B> !UnwindSafe for Locked<'invoker, 'buffer, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.