[][src]Struct serde_bytes::Bytes

pub struct Bytes<'a> { /* fields omitted */ }

Wrapper around &[u8] to serialize and deserialize efficiently.

This code runs with edition 2018
use std::collections::HashMap;
use std::io;

use serde_bytes::Bytes;

fn print_encoded_cache() -> bincode::Result<()> {
    let mut cache = HashMap::new();
    cache.insert(3, Bytes::new(b"three"));
    cache.insert(2, Bytes::new(b"two"));
    cache.insert(1, Bytes::new(b"one"));

    bincode::serialize_into(&mut io::stdout(), &cache)
}

Methods

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

pub fn new(bytes: &'a [u8]) -> Self[src]

Wrap an existing &[u8].

Trait Implementations

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

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

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

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

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

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

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

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

impl<'a> From<&'a [u8]> for Bytes<'a>[src]

impl<'a> From<Bytes<'a>> for &'a [u8][src]

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

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

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

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

type Target = [u8]

The resulting type after dereferencing.

impl<'de, 'a, E> IntoDeserializer<'de, E> for Bytes<'a> where
    E: Error
[src]

type Deserializer = BytesDeserializer<'a, E>

The type of the deserializer being converted into.

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

impl<'a, 'de: 'a> Deserialize<'de> for Bytes<'a>[src]

Auto Trait Implementations

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

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

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]