Skip to main content

TrustProfile

Struct TrustProfile 

Source
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 Address

Expected owner program.

§layout_id: &'a [u8; 8]

Expected layout_id (first 8 bytes of SHA-256 hash).

§size: usize

Expected size (exact for Strict, minimum for Compatible, ignored for Observational).

§level: TrustLevel

Trust level.

§flags: TrustFlags

Additional flags.

Implementations§

Source§

impl<'a> TrustProfile<'a>

Source

pub const fn strict( owner: &'a Address, layout_id: &'a [u8; 8], size: usize, ) -> Self

Strict profile: full validation.

Source

pub const fn compatible( owner: &'a Address, layout_id: &'a [u8; 8], min_size: usize, ) -> Self

Compatible profile: accepts newer versions with larger accounts.

Source

pub const fn observational(layout_id: &'a [u8; 8]) -> Self

Observational profile: layout_id only, for tooling.

Source

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.

Source

pub const fn with_min_version(self, v: u8) -> Self

Set the minimum version floor.

Source

pub const fn require_immutable(self) -> Self

Require the account to be immutable (not writable).

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for TrustProfile<'a>

§

impl<'a> RefUnwindSafe for TrustProfile<'a>

§

impl<'a> Send for TrustProfile<'a>

§

impl<'a> Sync for TrustProfile<'a>

§

impl<'a> Unpin for TrustProfile<'a>

§

impl<'a> UnsafeUnpin for TrustProfile<'a>

§

impl<'a> UnwindSafe for TrustProfile<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.