[][src]Struct serde_at::Bytes

pub struct Bytes<'a>(pub &'a [u8]);

Wrapper type to allow serializing a byte slice as bytes, rather than as a sequence (array)

Example:

use heapless::{consts, String};
use serde_at::{to_string, Bytes, SerializeOptions};
use serde_derive::Serialize;

#[derive(Clone, PartialEq, Serialize)]
pub struct WithBytes<'a> {
    s: Bytes<'a>,
};

let slice = b"Some bytes";
let b = WithBytes {
    s: Bytes(&slice[..]),
};
let s: String<consts::U32> = to_string(
    &b,
    String::<consts::U32>::from("+CMD"),
    SerializeOptions::default(),
)
.unwrap();

assert_eq!(s, String::<consts::U32>::from("AT+CMD=Some bytes\r\n"));

Trait Implementations

impl<'a> Clone for Bytes<'a>[src]

impl<'a> PartialEq<Bytes<'a>> for Bytes<'a>[src]

impl<'a> Serialize for Bytes<'a>[src]

impl<'a> StructuralPartialEq for Bytes<'a>[src]

Auto Trait Implementations

impl<'a> Send for Bytes<'a>

impl<'a> Sync for Bytes<'a>

impl<'a> Unpin for Bytes<'a>

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> Same<T> for T

type Output = T

Should always be Self

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.