ToBytes

Trait ToBytes 

Source
pub trait ToBytes {
    // Required method
    fn to_bytes(self) -> Bytes;
}
Expand description

A trait for types that can be converted to the Bytes type.

This trait is implemented for various types such as Vec<u8>, String, &str, and primitive types like u8, i32, etc.

Additionally it supports an JSON serializable type via the serde and serde_json crates.

Required Methods§

Source

fn to_bytes(self) -> Bytes

Converts the implementing type to a Bytes instance.

§Examples
use seda_sdk_rs::bytes::{Bytes, ToBytes};
let bytes: Bytes = "Hello, world!".to_bytes();
assert_eq!(bytes.eject(), b"Hello, world!");

Implementations on Foreign Types§

Source§

impl ToBytes for &str

Source§

impl ToBytes for bool

Source§

impl ToBytes for f32

Source§

impl ToBytes for f64

Source§

impl ToBytes for i8

Source§

impl ToBytes for i32

Source§

impl ToBytes for i64

Source§

impl ToBytes for i128

Source§

impl ToBytes for u8

Source§

impl ToBytes for u32

Source§

impl ToBytes for u64

Source§

impl ToBytes for u128

Source§

impl ToBytes for ()

Source§

impl ToBytes for String

Source§

impl ToBytes for Vec<u8>

Implementors§