[][src]Struct serde_bytes::ByteBuf

pub struct ByteBuf { /* fields omitted */ }

Wrapper around Vec<u8> to serialize and deserialize efficiently.

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

use serde_bytes::ByteBuf;

fn deserialize_bytebufs() -> bincode::Result<()> {
    let example_data = [
        2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 116,
        119, 111, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 111, 110, 101];

    let map: HashMap<u32, ByteBuf> = bincode::deserialize(&example_data[..])?;

    println!("{:?}", map);

    Ok(())
}

Methods

impl ByteBuf[src]

pub fn new() -> Self[src]

Construct a new, empty ByteBuf.

pub fn with_capacity(cap: usize) -> Self[src]

Construct a new, empty ByteBuf with the specified capacity.

pub fn from<T: Into<Vec<u8>>>(bytes: T) -> Self[src]

Wrap existing bytes in a ByteBuf.

Trait Implementations

impl AsRef<Vec<u8>> for ByteBuf[src]

impl AsRef<[u8]> for ByteBuf[src]

impl PartialEq<ByteBuf> for ByteBuf[src]

impl Clone for ByteBuf[src]

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

Performs copy-assignment from source. Read more

impl PartialOrd<ByteBuf> for ByteBuf[src]

impl Eq for ByteBuf[src]

impl Ord for ByteBuf[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 AsMut<Vec<u8>> for ByteBuf[src]

impl AsMut<[u8]> for ByteBuf[src]

impl From<ByteBuf> for Vec<u8>[src]

impl From<Vec<u8>> for ByteBuf[src]

impl Default for ByteBuf[src]

impl Debug for ByteBuf[src]

impl Hash for ByteBuf[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 Deref for ByteBuf[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for ByteBuf[src]

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

type Deserializer = ByteBufDeserializer<E>

The type of the deserializer being converted into.

impl Serialize for ByteBuf[src]

impl<'de> Deserialize<'de> for ByteBuf[src]

Auto Trait Implementations

impl Send for ByteBuf

impl Sync for ByteBuf

Blanket Implementations

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

type Owned = T

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

impl<T> From for T[src]

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]