pub struct TypedSegment<T: Pod, const OFFSET: u32> { /* private fields */ }Expand description
Compile-time typed segment descriptor: T is the overlay type,
OFFSET is the absolute byte offset from the start of account
data. Zero-sized.
ⓘ
// Matches Vault.balance at body offset 0, past the 16-byte header:
const VAULT_BALANCE: TypedSegment<WireU64, { HopperHeader::SIZE as u32 }>
= TypedSegment::new();
let bal = account.segment_ref_typed(&mut borrows, VAULT_BALANCE)?;Implementations§
Source§impl<T: Pod, const OFFSET: u32> TypedSegment<T, OFFSET>
impl<T: Pod, const OFFSET: u32> TypedSegment<T, OFFSET>
Sourcepub const fn size() -> u32
pub const fn size() -> u32
The byte size of this segment (size_of::<T>(), folded at compile time).
Sourcepub const fn end() -> u64
pub const fn end() -> u64
One-past-the-end byte offset, widened like Segment::end.
Sourcepub const fn as_segment() -> Segment
pub const fn as_segment() -> Segment
Lower to a runtime Segment when a heterogeneous collection
of segments is needed (e.g. a validation pass that iterates).
Trait Implementations§
impl<T: Copy + Pod, const OFFSET: u32> Copy for TypedSegment<T, OFFSET>
Auto Trait Implementations§
impl<T, const OFFSET: u32> Freeze for TypedSegment<T, OFFSET>
impl<T, const OFFSET: u32> RefUnwindSafe for TypedSegment<T, OFFSET>
impl<T, const OFFSET: u32> Send for TypedSegment<T, OFFSET>
impl<T, const OFFSET: u32> Sync for TypedSegment<T, OFFSET>
impl<T, const OFFSET: u32> Unpin for TypedSegment<T, OFFSET>
impl<T, const OFFSET: u32> UnsafeUnpin for TypedSegment<T, OFFSET>
impl<T, const OFFSET: u32> UnwindSafe for TypedSegment<T, OFFSET>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more