pub trait Storable: StorableType + Sized {
// Required methods
fn load<S: StorageOps>(
storage: &S,
slot: U256,
ctx: LayoutCtx,
) -> Result<Self>;
fn store<S: StorageOps>(
&self,
storage: &mut S,
slot: U256,
ctx: LayoutCtx,
) -> Result<()>;
// Provided method
fn delete<S: StorageOps>(
storage: &mut S,
slot: U256,
ctx: LayoutCtx,
) -> Result<()> { ... }
}Expand description
High-level storage operations for storable types.
This trait provides storage I/O operations: load, store, delete. Types implement their own logic for handling packed vs full-slot contexts.
Required Methods§
Provided Methods§
Sourcefn delete<S: StorageOps>(
storage: &mut S,
slot: U256,
ctx: LayoutCtx,
) -> Result<()>
fn delete<S: StorageOps>( storage: &mut S, slot: U256, ctx: LayoutCtx, ) -> Result<()>
Delete this type from storage (set to zero).
Default implementation handles both full-slot and packed contexts:
LayoutCtx::FULL: Writes zero to allSelf::SLOTSconsecutive slotsLayoutCtx::packed(offset): Clears only the bytes at the offset (read-modify-write)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Storable for String
impl Storable for String
Source§fn delete<S: StorageOps>(
storage: &mut S,
slot: U256,
ctx: LayoutCtx,
) -> Result<()>
fn delete<S: StorageOps>( storage: &mut S, slot: U256, ctx: LayoutCtx, ) -> Result<()>
Custom delete for bytes-like types: clears keccak256-addressed data slots for long values.
fn load<S: StorageOps>(storage: &S, slot: U256, ctx: LayoutCtx) -> Result<Self>
fn store<S: StorageOps>( &self, storage: &mut S, slot: U256, ctx: LayoutCtx, ) -> Result<()>
Source§impl Storable for Bytes
impl Storable for Bytes
Source§fn delete<S: StorageOps>(
storage: &mut S,
slot: U256,
ctx: LayoutCtx,
) -> Result<()>
fn delete<S: StorageOps>( storage: &mut S, slot: U256, ctx: LayoutCtx, ) -> Result<()>
Custom delete for bytes-like types: clears keccak256-addressed data slots for long values.
fn load<S: StorageOps>(storage: &S, slot: U256, ctx: LayoutCtx) -> Result<Self>
fn store<S: StorageOps>( &self, storage: &mut S, slot: U256, ctx: LayoutCtx, ) -> Result<()>
Source§impl<T> Storable for Vec<T>where
T: Storable,
impl<T> Storable for Vec<T>where
T: Storable,
Source§fn delete<S: StorageOps>(
storage: &mut S,
len_slot: U256,
ctx: LayoutCtx,
) -> Result<()>
fn delete<S: StorageOps>( storage: &mut S, len_slot: U256, ctx: LayoutCtx, ) -> Result<()>
Custom delete for Vec: clears both length slot and all data slots.
fn load<S: StorageOps>( storage: &S, len_slot: U256, ctx: LayoutCtx, ) -> Result<Self>
fn store<S: StorageOps>( &self, storage: &mut S, len_slot: U256, ctx: LayoutCtx, ) -> Result<()>
Implementors§
impl Storable for AuthorizedKey
impl Storable for Order
impl Storable for Orderbook
impl Storable for TickLevel
impl Storable for RewardStream
impl Storable for UserRewardInfo
impl Storable for PolicyData
impl Storable for Pool
impl Storable for PoolKey
impl Storable for TokenPair
impl Storable for Validator
impl<T: Packable> Storable for T
Blanket implementation of Storable for all Packable types.
This provides a unified load/store implementation for all primitive types, handling both full-slot and packed contexts automatically.