Commit 998aa8d2 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

sim: Move `Images` to before code

Rust convention is to have types before implementation.  Move `Images`
up to the top to make it more prominent.  This is also a good
opportunity to add a bit of a comment to this struct.

Signed-off-by: default avatarDavid Brown <david.brown@linaro.org>
parent 01617af2
Loading
Loading
Loading
Loading
+12 −9
Changes for sim/src/image.rs: 12 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -21,6 +21,18 @@ use mcuboot_sys::{c, AreaDesc};
use crate::caps::Caps;
use crate::tlv::{ManifestGen, TlvGen, TlvFlags, AES_SEC_KEY};

/// Images represents the state of a simulation for a given set of images.
/// The flashmap holds the state of the simulated flash, whereas primaries
/// and upgrades hold the expected contents of these images.
pub struct Images {
    pub flashmap: SimFlashMap,
    pub areadesc: AreaDesc,
    pub slots: [SlotInfo; 2],
    pub primaries: [Option<Vec<u8>>; 2],
    pub upgrades: [Option<Vec<u8>>; 2],
    pub total_count: Option<i32>,
}

impl Images {
    /// A simple upgrade without forced failures.
    ///
@@ -957,15 +969,6 @@ pub struct SlotInfo {
    pub dev_id: u8,
}

pub struct Images {
    pub flashmap: SimFlashMap,
    pub areadesc: AreaDesc,
    pub slots: [SlotInfo; 2],
    pub primaries: [Option<Vec<u8>>; 2],
    pub upgrades: [Option<Vec<u8>>; 2],
    pub total_count: Option<i32>,
}

const MAGIC: Option<&[u8]> = Some(&[0x77, 0xc2, 0x95, 0xf3,
                                    0x60, 0xd2, 0xef, 0x7f,
                                    0x35, 0x52, 0x50, 0x0f,