[][src]Struct 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)
}

Methods

impl Bytes[src]

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

Wrap an existing &[u8].

Trait Implementations

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

impl Serialize for Bytes[src]

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

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

impl ToOwned for Bytes[src]

type Owned = ByteBuf

The resulting type after obtaining ownership.

fn clone_into(&self, target: &mut Self::Owned)[src]

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl Ord for Bytes[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

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

Restrict a value to a certain interval. Read more

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

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

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

impl Eq 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<Rhs: ?Sized> PartialOrd<Rhs> for Bytes where
    Rhs: AsRef<[u8]>, 
[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Deref for Bytes[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for Bytes[src]

impl Debug for Bytes[src]

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

impl BorrowMut<Bytes> for ByteBuf[src]

impl Serialize for Bytes[src]

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

Auto Trait Implementations

impl Sync for Bytes

impl Unpin for Bytes

impl Send for Bytes

impl UnwindSafe for Bytes

impl RefUnwindSafe for Bytes

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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