[−][src]Struct holochain_core::nucleus::ribosome::memory::SinglePageManager
Struct for managing a WASM Memory Instance as a single page memory stack
Methods
impl SinglePageManager
[src]
impl SinglePageManager
A Memory Manager limited to one wasm memory page that works like a stack. With this Memory Manager, the WASM host (i.e. the Ribosome) and WASM module (i.e. the Zome) only need to pass around an i32 to communicate any data. That i32 is the last memory allocation on the stack: it is split in an i16 'offset' in the upper bits and an i16 'length' in the lower bits. This fits with the 64KiB sized of a memory Page. Complex input arguments should be stored on the latest allocation on the stack. Complex output arguments can be stored anywhere on stack. Since zero sized allocations are not allowed, it is possible to pass around a return and/or error code with the following convention: using the i16 'offset' as return code and i16 'length' set to zero to indicate its a return code. Return code of 0 means success, while any other value means a failure and gives the error code. In the future, to handle bigger memory needs, we could do same with an i64 instead and handle multiple memory Pages.
pub fn new(wasm_instance: &ModuleRef) -> Self
[src]
pub fn new(wasm_instance: &ModuleRef) -> Self
pub fn allocate(
&mut self,
length: u16
) -> Result<SinglePageAllocation, RibosomeErrorCode>
[src]
pub fn allocate(
&mut self,
length: u16
) -> Result<SinglePageAllocation, RibosomeErrorCode>
Allocate on stack without writing in it
pub fn write(
&mut self,
data: &[u8]
) -> Result<SinglePageAllocation, RibosomeErrorCode>
[src]
pub fn write(
&mut self,
data: &[u8]
) -> Result<SinglePageAllocation, RibosomeErrorCode>
Write data on top of stack
pub fn read(&self, allocation: SinglePageAllocation) -> Vec<u8>
[src]
pub fn read(&self, allocation: SinglePageAllocation) -> Vec<u8>
Read data somewhere in stack
Trait Implementations
impl Clone for SinglePageManager
[src]
impl Clone for SinglePageManager
fn clone(&self) -> SinglePageManager
[src]
fn clone(&self) -> SinglePageManager
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for SinglePageManager
[src]
impl Debug for SinglePageManager
Auto Trait Implementations
impl !Send for SinglePageManager
impl !Send for SinglePageManager
impl !Sync for SinglePageManager
impl !Sync for SinglePageManager
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Same for T
[src]
impl<T> Same for T
type Output = T
Should always be Self