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
pub use self::numerics::Integer;
pub use self::array::Array;
pub use self::string::String;
pub mod numerics;
#[macro_use]
pub mod composite;
pub mod array;
pub mod string;
pub mod char;
pub mod tuple;
pub mod option;
pub mod collections;
pub mod smart_ptr;
#[cfg(feature = "uuid")]
pub mod uuid;
use std::io::prelude::*;
use std::{fmt, io};
pub type ByteOrder = ::byteorder::BigEndian;
pub trait Type : Clone + fmt::Debug
{
fn read(read: &mut Read) -> Result<Self, ::Error>;
fn write(&self, write: &mut Write) -> Result<(), ::Error>;
fn from_raw_bytes(bytes: &[u8]) -> Result<Self, ::Error> {
let mut buffer = ::std::io::Cursor::new(bytes);
Self::read(&mut buffer)
}
fn raw_bytes(&self) -> Result<Vec<u8>, ::Error> {
let mut buffer = io::Cursor::new(Vec::new());
self.write(&mut buffer)?;
Ok(buffer.into_inner())
}
}