macro_rules! jiminy_interface {
(
$(#[$meta:meta])*
$vis:vis struct $name:ident for $owner:path {
$( $(#[$fmeta:meta])* $field:ident : $fty:ident = $fsize:expr ),+ $(,)?
}
) => { ... };
(
$(#[$meta:meta])*
$vis:vis struct $name:ident for $owner:path, version = $ver:literal {
$( $(#[$fmeta:meta])* $field:ident : $fty:ident = $fsize:expr ),+ $(,)?
}
) => { ... };
(
@impl version = $ver:literal,
$(#[$meta:meta])*
$vis:vis struct $name:ident for $owner:path {
$( $(#[$fmeta:meta])* $field:ident : $fty:ident = $fsize:expr ),+ $(,)?
}
) => { ... };
}Expand description
Declare a read-only interface for a foreign program’s account layout.
Generates a #[repr(C)] struct with the same LAYOUT_ID as the
foreign program’s zero_copy_layout! definition, plus a
load_foreign method that validates owner + layout_id.
The struct name must match the original account name for the
LAYOUT_ID hash to agree. If you want a local alias, use
type VaultView = Vault; after the macro invocation.
§Version
By default, the interface assumes the foreign program uses
version = 1. If the foreign layout uses a different version,
specify it explicitly so the LAYOUT_ID hash matches:
ⓘ
jiminy_interface! {
pub struct PoolV2 for PROGRAM_A, version = 2 {
header: AccountHeader = 16,
authority: Address = 32,
reserve: LeU64 = 8,
fee_bps: LeU16 = 2,
}
}