Crate zero_formatter

Source
Expand description

Implementation of ZeroFormatter in Rust.

§Usage

Put this in your Cargo.toml:

[dependencies]
zero-formatter = "0.1"

§Examples

#[macro_use] extern crate zero_formatter;
extern crate byteorder;
use zero_formatter::*;
use std::io::{Seek, SeekFrom, Read, Write, Cursor, Result};
use byteorder::{ReadBytesExt, WriteBytesExt};

declare_buffer! { Buffer }

object_formatter! {
    #[target(Buffer<Cursor<Vec<u8>>>)]
    ObjectSample {
        0; a: i32,
        1; b: i64
    }
}

let mut writer = Buffer::new(Cursor::new(Vec::new()));
try!(writer.serialize(0, ObjectSample { a: 1, b: 2 }));

§Supported Type

Currently, this library support only Stage1. See also WireFormat Specification.

§Primitive Format

RustC#Note
i16Int16
i32Int32
i64Int64
u16UInt16
u32UInt32
u64UInt64
f32Single
f64Double
boolBoolean
u8Byte
i8SByte
time::DurationTimeSpan
chrono::DateTime<chrono::UTC>DateTime
DateTimeOffset
Cow<'a, str>String
Option<i16>Int16?
Option<i32>Int32?
Option<i64>Int64?
Option<u16>UInt16?
Option<u32>UInt32?
Option<u64>UInt64?
Option<f32>Single?
Option<f64>Double?
Option<bool>Boolean?
Option<u8>Byte?
Option<i8>SByte?
Option<time::Duration>TimeSpan?
Option<chrono::DateTime<chrono::UTC>>DateTime?
DateTimeOffset?

§Sequence Format

RustC#Note
Cow<'a, [T]>Sequence<T>

§List Format

RustC#Note
FixedSizeList
VariableSizeList

§Object Format

RustC#Note
structObjectuse object_formatter macro
Option<struct>Objectif byteSize = -1, indicates None
structStruct
Option<struct>Struct?

§Union Format

RustC#Note
enumUnionuse union_formatter macro
Optionif byte_size = 1, indicates None

Modules§

Macros§

Enums§

Traits§

  • Formatter provide serializer and deserializer for ZeroFormatter.

Type Aliases§