pub struct TrustProfile<'a> {
pub owner: &'a Address,
pub layout_id: &'a [u8; 8],
pub size: usize,
pub level: TrustLevel,
pub flags: TrustFlags,
}Expand description
A foreign-account trust profile.
Encapsulates the expected owner, layout_id, size, and trust level so that foreign account loading is explicit and auditable.
Fields§
§owner: &'a AddressExpected owner program.
layout_id: &'a [u8; 8]Expected layout_id (first 8 bytes of SHA-256 hash).
size: usizeExpected size (exact for Strict, minimum for Compatible, ignored for Observational).
level: TrustLevelTrust level.
flags: TrustFlagsAdditional flags.
Implementations§
Source§impl<'a> TrustProfile<'a>
impl<'a> TrustProfile<'a>
Sourcepub const fn strict(
owner: &'a Address,
layout_id: &'a [u8; 8],
size: usize,
) -> Self
pub const fn strict( owner: &'a Address, layout_id: &'a [u8; 8], size: usize, ) -> Self
Strict profile: full validation.
Sourcepub const fn compatible(
owner: &'a Address,
layout_id: &'a [u8; 8],
min_size: usize,
) -> Self
pub const fn compatible( owner: &'a Address, layout_id: &'a [u8; 8], min_size: usize, ) -> Self
Compatible profile: accepts newer versions with larger accounts.
Sourcepub const fn observational(layout_id: &'a [u8; 8]) -> Self
pub const fn observational(layout_id: &'a [u8; 8]) -> Self
Observational profile: layout_id only, for tooling.
Sourcepub const fn read_only(
owner: &'a Address,
layout_id: &'a [u8; 8],
min_size: usize,
) -> Self
pub const fn read_only( owner: &'a Address, layout_id: &'a [u8; 8], min_size: usize, ) -> Self
Read-only profile: owner + layout_id + minimum size + require immutable.
Like compatible() but additionally requires the account to not be
writable. Use this when reading cross-program state that must not
be mutated within the same transaction.
Sourcepub const fn with_min_version(self, v: u8) -> Self
pub const fn with_min_version(self, v: u8) -> Self
Set the minimum version floor.
Sourcepub const fn require_immutable(self) -> Self
pub const fn require_immutable(self) -> Self
Require the account to be immutable (not writable).
Sourcepub fn load(
&self,
account: &'a AccountView,
) -> Result<Ref<'a, [u8]>, ProgramError>
pub fn load( &self, account: &'a AccountView, ) -> Result<Ref<'a, [u8]>, ProgramError>
Validate an account against this profile and return its data.
On success, returns a borrow-carrying byte view suitable for overlay.