pub trait ToBytes<'a> {
    type Bytes: AsRef<[u8]>;

    // Required method
    fn to_bytes(&self) -> Result<Self::Bytes, Error>;
}
Expand description

ToBytes is used to define how a type should be encoded when working with Extism memory. It is used for plugin input and host function output.

Required Associated Types§

source

type Bytes: AsRef<[u8]>

A configurable byte slice representation, allows any type that implements AsRef<[u8]>

Required Methods§

source

fn to_bytes(&self) -> Result<Self::Bytes, Error>

to_bytes converts a value into Self::Bytes

Implementations on Foreign Types§

source§

impl<'a> ToBytes<'a> for &'a str

§

type Bytes = &'a str

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for &'a [u8]

§

type Bytes = &'a [u8]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for Value

§

type Bytes = Vec<u8>

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for f32

§

type Bytes = [u8; 4]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for f64

§

type Bytes = [u8; 8]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for i32

§

type Bytes = [u8; 4]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for i64

§

type Bytes = [u8; 8]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for u32

§

type Bytes = [u8; 4]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for u64

§

type Bytes = [u8; 8]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for ()

§

type Bytes = [u8; 0]

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for String

§

type Bytes = String

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a> ToBytes<'a> for Vec<u8>

§

type Bytes = Vec<u8>

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a, T: ToBytes<'a>> ToBytes<'a> for Option<T>

§

type Bytes = Vec<u8>

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

source§

impl<'a, T: ToBytes<'a>> ToBytes<'a> for &'a T

§

type Bytes = <T as ToBytes<'a>>::Bytes

source§

fn to_bytes(&self) -> Result<Self::Bytes, Error>

Implementors§

source§

impl<'a, T: AsRef<[u8]>> ToBytes<'a> for Base64<T>

source§

impl<'a, T: Pod> ToBytes<'a> for Raw<'a, T>

§

type Bytes = &'a [u8]

source§

impl<'a, T: Message> ToBytes<'a> for Prost<T>

§

type Bytes = Vec<u8>

source§

impl<'a, T: Serialize> ToBytes<'a> for Json<T>

§

type Bytes = Vec<u8>

source§

impl<'a, T: Serialize> ToBytes<'a> for Msgpack<T>

§

type Bytes = Vec<u8>