[][src]Struct gbl::AppImage

pub struct AppImage<'a> { /* fields omitted */ }

A flash image containing application data.

It is expected that every application embeds an "application properties" data structure, which will be located by AppImage::parse and contains an AppInfo structure which can be accessed using AppImage::app_info.

Can be turned into a Gbl by calling Gbl::from_app_image or into a ProgramData section using From/Into conversion. The resulting section will be flashed at offset 0. It is the user's responsibility to ensure that the whole image fits in the target device's flash memory (this library is completely device-agnostic and thus cannot check that device-specific constraints are satisfied).

Methods

impl<'a> AppImage<'a>[src]

pub fn parse<T: AsRef<[u8]> + ?Sized>(image: &'a T) -> Result<Self, Error>[src]

Parses a raw application image by extracting the application properties.

Errors

Returns an error if image does not contain a valid application properties structure.

pub fn into_raw(self) -> Cow<'a, [u8]>[src]

Consumes self and returns the raw bytes making up the application image.

pub fn app_info(&self) -> &AppInfo[src]

Returns the AppInfo structure extracted from the application image.

pub fn is_signed(&self) -> bool[src]

Returns whether a cryptographic signature is embedded into the application image.

pub fn ecdsa_signature(&self) -> Option<[u8; 64]>[src]

If present, returns the embedded ECDSA P-256 signature blob.

pub fn sign(self, pem_private_key: &str) -> Result<Self, Error>[src]

Signs this application image.

The signature will be embedded into the flashed data, and the application properties structure will be updated to point at the signature. If the signature pointer is non-zero and the signature type indicates an ECDSA P-256 signature, an existing signature is assumed to be present at that offset and will be overwritten with a new signature.

If no signature is present, this will append the new signature to the raw image, enlarging it.

If secure boot is enabled in the bootloader, a valid signature must be present for boot to continue.

Errors

Returns an error if:

  • pem_private_key is malformed or does not contain an ECDSA P-256 private key.
  • there is a problem accessing the system's random number generator.

Trait Implementations

impl<'a> From<AppImage<'a>> for ProgramData<'a>[src]

impl<'a> Debug for AppImage<'a>[src]

Auto Trait Implementations

impl<'a> Send for AppImage<'a>

impl<'a> Sync for AppImage<'a>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]