|
|
@@ -1,3 +1,7 @@
|
|
|
+//! Orio is a fairly small library that works on top of little-endian byteorder.
|
|
|
+//! It's intended to automate the boilerplate of serializing types like packets
|
|
|
+//! and still give the user control of the data's representation.
|
|
|
+//!
|
|
|
//! # Io trait
|
|
|
//! The [Io] trait allows types to be written and read generically to byte vecs.
|
|
|
//! See its documentation for usage and manual implementation.
|
|
|
@@ -8,13 +12,19 @@
|
|
|
//! Fields can have the `#[io(ignore)]` attribute added which will:
|
|
|
//! 1. Ignore the field when writing the full struct/enum.
|
|
|
//! 2. Use `Default` for reading as there is nothing to read from.
|
|
|
+//! Some types like `String` or `Vec` have a length field which can be changed.
|
|
|
+//! To use these, add the `#[io(len(TYPE))]` attribute, where TYPE is an int like u8, u16, etc.
|
|
|
+//! This lets you customize how much data you want a field to support, e.g. for a filename 255 bytes
|
|
|
+//! might be fine but you'd want u64 for the file contents.
|
|
|
//!
|
|
|
//! # Std types
|
|
|
//! Currently a few types from std are supported:
|
|
|
//! - All numbers
|
|
|
//! - `String`
|
|
|
//! - `Box` `HashMap` `Option` and `Vec` of types that implement `Io`
|
|
|
-//! - `Duration` and `SystemTime`.
|
|
|
+//! - `Duration` and `SystemTime`. These are both stored as milliseconds.
|
|
|
+//! Duration uses `#[io(len)]` to change the lengths of times you want to support.
|
|
|
+//! Since u16 is a little over a minute, you'l usually want u32 or u64.
|
|
|
|
|
|
use std::io::{Error, ErrorKind};
|
|
|
|