Crate zero_formatter [] [src]

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

Rust C# Note
i16 Int16
i32 Int32
i64 Int64
u16 UInt16
u32 UInt32
u64 UInt64
f32 Single
f64 Double
bool Boolean
u8 Byte
i8 SByte
time::Duration TimeSpan
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

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

List Format

Rust C# Note
FixedSizeList
VariableSizeList

Object Format

Rust C# Note
struct Object use object_formatter macro
Option<struct> Object if byteSize = -1, indicates None
struct Struct
Option<struct> Struct?

Union Format

Rust C# Note
enum Union use union_formatter macro
Option if byte_size = 1, indicates None

Modules

util

Macros

declare_buffer
has_value_formatter
has_value_formatter_methods
object_formatter

object_formatter define struct type and provide formatter. object_formatter support versioning.

option_formatter
struct_formatter

struct_formatter define sturct type and provide sequential fields formatter. But, struct_formatter does not support versioning.

union_formatter

union_formatter define struct type and provide formatter.

Enums

ZeroFormatterError

Traits

Formatter

Formatter provide serializer and deserializer for ZeroFormatter.

Type Definitions

ZeroFormatterResult