pub struct WriteRange {
pub account_index: u8,
pub offset: u32,
pub size: u32,
}Expand description
One allowed write range on one instruction account.
account_index is the position in the instruction’s account list
(the same index handed to Context::account).
Offsets are absolute within the account data, including any layout
header bytes, the same convention the segment access primitives use.
Fields§
§account_index: u8Instruction account-list index this range applies to.
offset: u32Absolute byte offset of the allowed range.
size: u32Byte size of the allowed range. WriteRange::whole_account
uses u32::MAX, which contains any request on the account
(account data is capped far below 4 GiB).
Implementations§
Source§impl WriteRange
impl WriteRange
Sourcepub const fn new(account_index: u8, offset: u32, size: u32) -> Self
pub const fn new(account_index: u8, offset: u32, size: u32) -> Self
Allow writes to [offset, offset + size) on account_index.
Sourcepub const fn whole_account(account_index: u8) -> Self
pub const fn whole_account(account_index: u8) -> Self
Allow whole-account writes on account_index (what a plain
mut declaration grants).
Sourcepub const fn tail_from(account_index: u8, offset: u32) -> Self
pub const fn tail_from(account_index: u8, offset: u32) -> Self
Allow writes to the open-ended tail [offset, +inf) on
account_index, the grant a growable Seq<T> tail needs.
size is u32::MAX, so contains admits any
sub-range starting at or after offset regardless of how large the
account grows (the account data cap is far below 4 GiB, and
contains widens to u64 so offset + u32::MAX cannot wrap).
Crucially this is not a whole-account grant when offset != 0:
allows_whole_account_write
requires a range containing [0, u32::MAX), and a tail range that
starts past the fixed head fails that test. So the fixed head stays
byte-protected and CPI writable-meta delegation stays refused, while
the tail region past offset remains freely writable and growable.