pub struct LayoutFingerprint { /* private fields */ }Expand description
An 8-byte deterministic layout fingerprint.
Generated from SHA-256("hopper:v1:" + name + ":" + version + ":" + fields)[..8].
Two layouts with identical fields, types, sizes, and ordering produce
the same fingerprint. Any structural change produces a different one.
Use this to assert compatibility between layout versions at compile time, verify on-chain accounts match expected schemas, and detect schema drift in migration paths.
Implementations§
Source§impl LayoutFingerprint
impl LayoutFingerprint
Sourcepub const fn from_bytes(bytes: [u8; 8]) -> Self
pub const fn from_bytes(bytes: [u8; 8]) -> Self
Create a fingerprint from raw bytes.
Sourcepub const fn matches(&self, other: &LayoutFingerprint) -> bool
pub const fn matches(&self, other: &LayoutFingerprint) -> bool
Check if two fingerprints match.
Sourcepub const fn differs_from(&self, other: &LayoutFingerprint) -> bool
pub const fn differs_from(&self, other: &LayoutFingerprint) -> bool
Check if two fingerprints differ (schema changed between versions).
Sourcepub fn verify_header(&self, data: &[u8]) -> Result<(), ProgramError>
pub fn verify_header(&self, data: &[u8]) -> Result<(), ProgramError>
Verify this fingerprint matches data read from an account header.
Reads the layout_id from bytes 4..12 of the header and compares.
Trait Implementations§
Source§impl Clone for LayoutFingerprint
impl Clone for LayoutFingerprint
Source§fn clone(&self) -> LayoutFingerprint
fn clone(&self) -> LayoutFingerprint
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl PartialEq for LayoutFingerprint
impl PartialEq for LayoutFingerprint
Source§fn eq(&self, other: &LayoutFingerprint) -> bool
fn eq(&self, other: &LayoutFingerprint) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for LayoutFingerprint
impl Eq for LayoutFingerprint
impl StructuralPartialEq for LayoutFingerprint
Auto Trait Implementations§
impl Freeze for LayoutFingerprint
impl RefUnwindSafe for LayoutFingerprint
impl Send for LayoutFingerprint
impl Sync for LayoutFingerprint
impl Unpin for LayoutFingerprint
impl UnsafeUnpin for LayoutFingerprint
impl UnwindSafe for LayoutFingerprint
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