pub struct StableLog<T: Storable, M: Memory = DefaultMemoryImpl> { /* private fields */ }Expand description
Governed upstream Log; initialization and failures follow upstream contracts.
Implementations§
Source§impl<T: Storable, M: Memory> StableLog<T, M>
impl<T: Storable, M: Memory> StableLog<T, M>
Sourcepub fn new(
index_memory: RuntimeMemory<M>,
data_memory: RuntimeMemory<M>,
) -> Self
pub fn new( index_memory: RuntimeMemory<M>, data_memory: RuntimeMemory<M>, ) -> Self
Create a new collection, replacing any prior collection in the selected memory. This is destructive even when a valid collection already exists.
§Panics
Panics on insufficient memory or codec/backing failure.
Sourcepub fn init(
index_memory: RuntimeMemory<M>,
data_memory: RuntimeMemory<M>,
) -> Self
pub fn init( index_memory: RuntimeMemory<M>, data_memory: RuntimeMemory<M>, ) -> Self
Open a retained log, or initialize both memories when data memory is empty or has foreign magic. The latter overwrites previous contents.
§Panics
With recognized data magic, panics for an invalid index or unsupported layout. Growth and codec/backing failures also retain upstream panics.
Sourcepub fn first(&self) -> Option<T>
pub fn first(&self) -> Option<T>
Delegates to upstream Log::first with the governed allocation.
Sourcepub fn get(&self, idx: u64) -> Option<T>
pub fn get(&self, idx: u64) -> Option<T>
Delegates to upstream Log::get with the governed allocation.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Delegates to upstream Log::is_empty with the governed allocation.
Trait Implementations§
Auto Trait Implementations§
impl<T, M = Rc<RefCell<Vec<u8>>>> !Freeze for StableLog<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !RefUnwindSafe for StableLog<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !Send for StableLog<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !Sync for StableLog<T, M>
impl<T, M = Rc<RefCell<Vec<u8>>>> !UnwindSafe for StableLog<T, M>
impl<T, M> Unpin for StableLog<T, M>
impl<T, M> UnsafeUnpin for StableLog<T, M>
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