Struct membuffer::Position[][src]

pub struct Position {
    pub offset: i32,
    pub length: i32,
}

!This crate will provide a extremely fast deserialization of dynamic data structures with big fields. This is very MMAP friendly since it only parses the header and does not parse the fields until requested. Easy example:

use membuffer::{MemBufferWriter,MemBufferReader};

fn main() {
  //Creates a new empty MemBufferWriter
  let mut writer = MemBufferWriter::new();
  
  //Adds this as immutable field, no more changing after adding it
  //The first entry is the key and must be a type that implements Into<i32>
  writer.add_entry("Very long value");

  //Creates a Vec<u8> out of all the collected data
  let result = writer.finalize();

  //Try to read the created vector. Will return an error if the CRC32 does not fit
  //or if the header is not terminated. Will panic if the memory is corrupted beyond recognition
  let reader = MemBufferReader::new(&result).unwrap();

  //Will return an error if the selected key could not be found or if the value types dont match
  assert_eq!(reader.load_entry::<&str>(0).unwrap(), "Very long value");
}

Refers to a position given to every deserialize and serialize operation, can be used to store data if one does not need to store data in the payload e. g. Field smaller than 8 Bytes

Fields

offset: i32length: i32

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.