[][src]Struct holochain_wasmer_guest::AllocationPtr

pub struct AllocationPtr(_);

AllocationPtr wraps a ptr that is used to pass the location of an Allocation between the host and guest (in either direction). The AllocationPtr intentionally does not implement Clone The From and Into round trip handles manually allocating and deallocating an internal vector that is shared across host/guest If the AllocationPtr was to be cloned the shared vector could be allocated and deallocated in an undefined way

Methods

impl AllocationPtr[src]

pub fn as_remote_ptr(&self) -> u64[src]

normally we don't want to expose the inner Ptr because cloning or reusing it can lead to bad allocation and deallocation in the case that we pass the inner Ptr over to the host we do need to access it this function is just like From for Ptr but renamed to make it clear that it has only one valid use-case

pub fn from_remote_ptr(host_ptr: u64) -> AllocationPtr[src]

pub fn peek_allocation(&self) -> [u64; 2][src]

get the Allocation for this Allocation without deallocating the Allocation in the process usually you do not want to do this because From for Allocation consumes the original AllocationPtr and returns a new identical Allocation

Trait Implementations

impl From<[u64; 2]> for AllocationPtr[src]

given an Allocation returns a u64 pointer to it the Allocation (slice) is internally converted to a Vec that requires a manual drop i.e. the allocation vec is not dropped when it goes out of scope the pointer returned is to this new vector and the originally passed allocation is handled by the rust allocater as per normal ownership rules this allows us to pass the AllocationPtr across the host/guest boundary in either direction and have the Allocation bytes remain in memory until the AllocationPtr recipient is ready to have them copied in. the from_allocation_ptr function does the inverse and internally deallocates the allocation vector that is created here. to avoid memory leaks, every Allocation must fully round-trip through these two functions.

impl From<AllocationPtr> for SerializedBytes[src]

impl From<SerializedBytes> for AllocationPtr[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.