pub struct SysvarContext { /* private fields */ }Expand description
Combined sysvar context for a single instruction.
Parse all needed sysvars once at the top of your instruction handler, then pass this context to all validation functions.
ⓘ
let ctx = SysvarContext::new()
.with_clock(&clock_account)?
.with_rent(&rent_account)?;
ctx.clock()?.check_not_expired(deadline)?;
ctx.clock()?.check_slot_staleness(oracle_slot, 50)?;Implementations§
Source§impl SysvarContext
impl SysvarContext
Sourcepub fn with_clock(self, clock_data: &[u8]) -> Result<Self, ProgramError>
pub fn with_clock(self, clock_data: &[u8]) -> Result<Self, ProgramError>
Parse and cache the Clock sysvar.
Sourcepub fn with_rent(self, rent_data: &[u8]) -> Result<Self, ProgramError>
pub fn with_rent(self, rent_data: &[u8]) -> Result<Self, ProgramError>
Parse and cache the Rent sysvar.
Sourcepub fn clock(&self) -> Result<&CachedClock, ProgramError>
pub fn clock(&self) -> Result<&CachedClock, ProgramError>
Get the cached Clock. Returns error if not initialized.
Sourcepub fn rent(&self) -> Result<&CachedRent, ProgramError>
pub fn rent(&self) -> Result<&CachedRent, ProgramError>
Get the cached Rent. Returns error if not initialized.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SysvarContext
impl RefUnwindSafe for SysvarContext
impl Send for SysvarContext
impl Sync for SysvarContext
impl Unpin for SysvarContext
impl UnsafeUnpin for SysvarContext
impl UnwindSafe for SysvarContext
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