[][src]Struct cs_serde_bytes::Bytes

#[repr(C)]pub struct Bytes { /* fields omitted */ }

Wrapper around [u8] to serialize and deserialize efficiently.

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)
}

Implementations

impl Bytes[src]

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

Wrap an existing &[u8].

Trait Implementations

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

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

impl Borrow<Bytes> for ByteBuf[src]

impl BorrowMut<Bytes> for ByteBuf[src]

impl Debug for Bytes[src]

impl<'a> Default for &'a Bytes[src]

impl Deref for Bytes[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for Bytes[src]

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

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

impl Eq for Bytes[src]

impl Hash for Bytes[src]

impl<'a> IntoIterator for &'a Bytes[src]

type Item = &'a u8

The type of the elements being iterated over.

type IntoIter = <&'a [u8] as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut Bytes[src]

type Item = &'a mut u8

The type of the elements being iterated over.

type IntoIter = <&'a mut [u8] as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

impl Ord for Bytes[src]

impl<Rhs: ?Sized> PartialEq<Rhs> for Bytes where
    Rhs: AsRef<[u8]>, 
[src]

impl<Rhs: ?Sized> PartialOrd<Rhs> for Bytes where
    Rhs: AsRef<[u8]>, 
[src]

impl Serialize for Bytes[src]

impl Serialize for Bytes[src]

impl StructuralEq for Bytes[src]

impl ToOwned for Bytes[src]

type Owned = ByteBuf

The resulting type after obtaining ownership.

Auto Trait Implementations

impl RefUnwindSafe for Bytes

impl Send for Bytes

impl Sync for Bytes

impl Unpin for Bytes

impl UnwindSafe for Bytes

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]