1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Implementation of [ZeroFormatter](https://github.com/neuecc/ZeroFormatter) in Rust.
//!
//! ## Usage
//!
//! Put this in your `Cargo.toml`:
//!
//! ```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
//!     }
//! }
//!
//! # fn example() -> Result<()> {
//! let mut writer = Buffer::new(Cursor::new(Vec::new()));
//! try!(writer.serialize(0, ObjectSample { a: 1, b: 2 }));
//! # Ok(())
//! # }
//! #
//! # fn main() {
//! # example();
//! # }
//! ```
//!
//! ## Supported Type
//!
//! Currently, this library support only [Stage1](https://github.com/neuecc/ZeroFormatter/tree/1.6.0#cross-platform).
//! See also [WireFormat Specification](https://github.com/neuecc/ZeroFormatter/tree/1.6.0#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<enum> | | if byte_size = 1, indicates `None` |


extern crate byteorder;
extern crate chrono;

mod error;
mod formatter;
#[macro_use]
mod buffer;
mod primitive;
pub mod util;
#[macro_use]
mod has_value;
#[macro_use]
mod option;
#[macro_use]
mod object;
mod time;
mod sequence;
mod union;

pub use error::ZeroFormatterResult;
pub use error::ZeroFormatterError;
pub use formatter::Formatter;