Struct membuffer::MemBufferWriter[][src]

pub struct MemBufferWriter { /* fields omitted */ }

The Writer class which sets up the schema and writes it into the memory when finished building

Implementations

impl MemBufferWriter[src]

pub fn new() -> MemBufferWriter[src]

Creates a new empty memory format writer

pub fn from<'a>(raw_memory: &'a [u8]) -> Result<MemBufferWriter, MemBufferError>[src]

Create a new Membuffer writer from the given memory, this will enable the writer to add more data to the previous version, to do so the writer does a full reload of the memory therefore it is an expensive operation if the structure adding fields to is huge.

use membuffer::{MemBufferWriter,MemBufferReader};

let mut value = MemBufferWriter::new();
value.add_entry("Hello");
value.add_entry("World");

let data = value.finalize();


let mut writer_adder = MemBufferWriter::from(&data).unwrap();
writer_adder.add_entry("Damn I forgot");

let new_data = writer_adder.finalize();

pub fn serialize_i32_to(val: i32, to: &mut Vec<u8>)[src]

Serializes the integer to the memory slice

pub fn add_entry<T: MemBufferSerialize>(&mut self, val: T)[src]

Adds an entry to the writer the only requirement is the serializable trait

pub fn add_serde_entry<T: Serialize>(&mut self, val: &T)[src]

Adds a serde serializable entry into the structure as serializer serde_json is used. Internally it is saved as a string.

pub fn finalize(&self) -> Vec<u8>[src]

Finalize the schema and return the memory slice holding the whole vector

Trait Implementations

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.