Struct membuffer::MemBufferReader[][src]

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

The reader which is used for reading the memory area produced by the writer, Important notice: The reader uses the native endian of the system used therefore sending between big endian and little endian systems wont work

use membuffer::{MemBufferWriter,MemBufferReader};

let mut data = MemBufferWriter::new();
data.add_entry("Add some data to save to file or send over the network");
let data_vec = data.finalize();
let reader = MemBufferReader::new(&data_vec).unwrap();
assert_eq!(reader.load_entry::<&str>(0).unwrap(),"Add some data to save to file or send over the network");

Implementations

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

pub fn deserialize_i32_from(mut buffer: &[u8]) -> i32[src]

Deserialize data from a buffer to an i32 integer

pub fn len(&self) -> usize[src]

pub fn payload_len(&self) -> usize[src]

pub fn load_entry<X: MemBufferDeserialize<'a, X> + MemBufferSerialize>(
    &self,
    key: usize
) -> Result<X, MemBufferError>
[src]

Load one entry with the given type, expecting the serializable trait as well to determine the integer type, when doing polymorphismus of structures use the same integer for multiple types

pub fn load_serde_entry<T: Deserialize<'a>>(
    &self,
    key: usize
) -> Result<T, MemBufferError>
[src]

Loads an entry stored with serde_json and returns it.

pub fn load_recursive_reader(
    &self,
    key: usize
) -> Result<MemBufferReader<'a>, MemBufferError>
[src]

Loads a nested MembufferWriter as reader

pub fn new(val: &'a [u8]) -> Result<MemBufferReader<'a>, MemBufferError>[src]

Creates a new memory format reader from the given memory slice, as the readed values are borrowed from the memory slice the reader cannot outlive the memory it borrows from

Trait Implementations

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

impl<'a> MemBufferDeserialize<'a, MemBufferReader<'a>> for MemBufferReader<'a>[src]

Auto Trait Implementations

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, 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.