Skip to main content

assert_legacy_layout

Macro assert_legacy_layout 

Source
macro_rules! assert_legacy_layout {
    ($ty:ty, $size:expr $(,)?) => { ... };
    ($ty:ty, size = $size:expr $(,)?) => { ... };
    ($ty:ty, size = $size:expr, max_align = $max_align:expr $(,)?) => { ... };
    (@inner $ty:ty, $size:expr, $max_align:expr) => { ... };
}
Expand description

Assert that an existing non-Jiminy account layout is safe to overlay.

Use this for live programs that already have account bytes in production and cannot adopt Jiminy’s 16-byte header or layout_id convention yet. The macro does not generate a struct, header, discriminator, or ABI hash. It only proves that the type has opted into Jiminy’s Pod + FixedLayout contract and that the Rust layout still matches the declared legacy size.

#[repr(C)]
#[derive(Clone, Copy)]
pub struct ArgusVaultV1 {
    pub authority: Address,
    pub balance: LeU64,
}

unsafe impl jiminy_core::account::Pod for ArgusVaultV1 {}
impl jiminy_core::account::FixedLayout for ArgusVaultV1 {
    const SIZE: usize = 40;
}

jiminy_core::assert_legacy_layout!(ArgusVaultV1, 40);