Skip to main content

ToBytes

Trait ToBytes 

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

ToBytes can be used to convert a type into a Bytes

§Examples

use ngyn_shared::{ToBytes, Bytes};

let string_body: Bytes = "Hello, world!".to_string().to_bytes();

Required Methods§

Source

fn to_bytes(&self) -> Bytes

Parses the body into a Bytes object.

§Examples
use ngyn_shared::{ToBytes, Bytes};

let bytes: Bytes = Bytes::from("Hello, world!");
let parsed_bytes: Bytes = bytes.to_bytes();

Trait Implementations§

Source§

impl ToBytes for Box<dyn ToBytes>

Source§

fn to_bytes(&self) -> Bytes

Parses the body into a Bytes object. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ToBytes for &'static str

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for ()

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for Box<dyn ToBytes>

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for String

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for Value

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for bool

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for f32

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for f64

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for i8

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for i16

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for i32

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for i64

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for i128

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for u8

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for u16

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for u32

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for u64

Source§

fn to_bytes(&self) -> Bytes

Source§

impl ToBytes for u128

Source§

fn to_bytes(&self) -> Bytes

Source§

impl<T, E> ToBytes for Result<T, E>
where T: ToBytes + Serialize + Any, E: ToBytes + Serialize + Any,

Converts a Result into a Bytes

In Ngyn, a Result can be converted into a Bytes object.

Source§

fn to_bytes(&self) -> Bytes

Source§

impl<T> ToBytes for Vec<T>
where T: Serialize + 'static,

Source§

fn to_bytes(&self) -> Bytes

Implementors§

Source§

impl ToBytes for Bytes

Source§

impl<D, E> ToBytes for JsonResponse<D, E>
where D: Serialize + 'static, E: Serialize + 'static,