Struct extism_pdk::memory::Memory

source ·
pub struct Memory(pub MemoryHandle);

Tuple Fields§

§0: MemoryHandle

Implementations§

source§

impl Memory

source

pub fn offset(&self) -> u64

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn null() -> Self

source

pub fn new<'a, T: ToBytes<'a>>(x: &T) -> Result<Self, Error>

Allocate a new block with an encoded value

source

pub fn from_bytes(data: impl AsRef<[u8]>) -> Result<Self, Error>

Create a memory block and copy bytes from u8 slice

source

pub fn to_vec(&self) -> Vec<u8>

Copy data out of memory and into a vec

source

pub fn to_string(&self) -> Result<String, Error>

Copy data out of memory and convert to string

source

pub fn set_output(self)

Store memory as function output

source

pub fn log(&self, level: LogLevel)

Log memory

source

pub fn to<T: FromBytesOwned>(&self) -> Result<T, Error>

Convert to a Rust value

source

pub fn find(offs: u64) -> Option<Memory>

Locate a memory block by offset

source

pub fn free(self)

Free a memory block, allowing for it to be re-used

Trait Implementations§

source§

impl From<()> for Memory

source§

fn from(_: ()) -> Memory

Converts to this type from the input type.
source§

impl From<Memory> for ()

source§

fn from(_: Memory)

Converts to this type from the input type.
source§

impl From<Memory> for i64

source§

fn from(m: Memory) -> Self

Converts to this type from the input type.
source§

impl From<Memory> for u64

source§

fn from(m: Memory) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Memory

source§

fn from(offset: i64) -> Memory

Converts to this type from the input type.
source§

impl From<u64> for Memory

source§

fn from(offset: u64) -> Memory

Converts to this type from the input type.
source§

impl<'a> ToMemory for &'a Memory

source§

impl ToMemory for Memory

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.