Trait ConvertTo

Source
pub trait ConvertTo {
    // Required methods
    fn convert_to_3(&self) -> [u8; 3];
    fn convert_to_4(&self) -> [u8; 4];
    fn convert_to_32(&self) -> [u8; 32];
    fn convert_to_64(&self) -> [u8; 64];
}
Expand description

Helper trait to convert ATCA_CMD_SIZE_MAX (151-byte) array to

  • a 3-byte (ATCA_RSP_SIZE_MIN-1) array
  • or a 64-byte array

This is just to optimize runtime space requirements. We use a ATCA_CMD_SIZE_MAX (151-byte) array to store all responses from the ATECC device as Rust does not yet support code that is generic over the size of an array type i.e. [Foo; 3] and [Bar; 3] are instances of same generic type [T; 3], but [Foo; 3] and [Foo; 5] are entirely different types.

Required Methods§

Source

fn convert_to_3(&self) -> [u8; 3]

Trait to convert any array (of u8s) of size > 3 to a 3 byte array.

Source

fn convert_to_4(&self) -> [u8; 4]

Trait to convert any array (of u8s) of size > 4 to a 4 byte array.

Source

fn convert_to_32(&self) -> [u8; 32]

Trait to convert any array (of u8s) of size > 32 to a 32 byte array.

Source

fn convert_to_64(&self) -> [u8; 64]

Trait to convert any array (of u8s) of size > 64 to a 64 byte array.

Implementations on Foreign Types§

Source§

impl ConvertTo for [u8; 151]

Source§

fn convert_to_3(&self) -> [u8; 3]

This method takes a reference to self (an array) and returns the first 3-bytes. Responses that do not contain data are 4 bytes in length. The method send_packet returns a [u8;151] which does not include the count (or first) byte. So, we only need to pick the first 3 bytes.

Source§

fn convert_to_4(&self) -> [u8; 4]

This method takes a reference to self (an array) and returns the first 4-bytes.

Source§

fn convert_to_64(&self) -> [u8; 64]

This method takes a reference to self (an array) and returns the first 64-bytes.

Source§

fn convert_to_32(&self) -> [u8; 32]

This method takes a reference to self (an array) and returns the first 32-bytes.

Implementors§