Skip to main content

Crate jiminy_layouts

Crate jiminy_layouts 

Source
Expand description

§jiminy-layouts

Standard zero-copy account layouts for well-known Solana programs.

This crate provides #[repr(C)] structs with Pod and FixedLayout implementations for SPL Token accounts, Mint accounts, and other widely-used on-chain data structures. These layouts are compatible with jiminy-core’s pod_from_bytes() for direct zero-copy access.

§Why a separate crate?

jiminy-solana provides function-based field readers (e.g., token_account_owner(account)). This crate provides struct-based overlays that map the entire account into a typed struct - useful when you need to read multiple fields efficiently.

§Layouts

StructProgramSize
SplTokenAccountSPL Token165 bytes
SplMintSPL Token82 bytes
SplMultisigSPL Token355 bytes
NonceAccountSystem program80 bytes
StakeStateStake program200 bytes

§Coverage philosophy

This crate targets account types that programs commonly read cross-program. SPL Token accounts dominate that set. Nonce and Stake accounts are included because staking programs and durable-transaction workflows frequently inspect them. Additional layouts (e.g., Metaplex Token Metadata) can be added as the ecosystem matures.

§Example

use jiminy_layouts::SplTokenAccount;
use jiminy_core::account::{pod_from_bytes, FixedLayout};

let data: &[u8] = &account.data;
let token = pod_from_bytes::<SplTokenAccount>(data)?;
let owner = token.owner;
let amount = u64::from_le_bytes(token.amount);

§Important

These are external (non-Jiminy) account layouts - they do NOT have the Jiminy 16-byte header. They are meant for reading accounts owned by other programs (SPL Token, System, Stake, etc.).

Structs§

NonceAccount
Zero-copy overlay for a system program durable nonce account (80 bytes).
SplMint
Zero-copy overlay for an SPL Token mint account (82 bytes).
SplMultisig
Zero-copy overlay for an SPL Token multisig account (355 bytes).
SplTokenAccount
Zero-copy overlay for an SPL Token account (165 bytes).
StakeState
Zero-copy overlay for the fixed prefix of a stake account (200 bytes).