[−][src]Crate binn_ir
An implementation of Binn - https://github.com/liteserver/binn
Project
- Repository: https://bitbucket.org/haibison/binn-ir
- License: Nice License 1.0.0 (see LICENSE file at root directory of
master
branch) - This project follows Semantic Versioning 2.0.0
Features
- All official types are supported.
- User defined types are not yet supported.
Notes
IR
stands for implementation in Rust.- The crate uses
#![no_std]
by default. Documentation is built with all features, which includestd
. If you see some components fromstd
crate, you have to use that feature.
Security notes
To prevent attacks when decoding from Read
, consider limiting your source via Read::take()
.
Quick examples
This example demonstrates a simple file container:
use core::convert::TryFrom; use binn_ir::{Blob, Decoder, Encoder, Map, Value}; const MAGIC_NUMBER: u64 = 0xABCD; // Buffer let mut buf: Vec<u8> = vec![]; // Magic number buf.encode_u64(MAGIC_NUMBER)?; // A single file header contains: name and hash let mut file_header = binn_ir::map(); file_header.map_insert(0, "the-sun")?; // name file_header.map_insert(1, 0_u64)?; // hash let file_content = Value::Blob(b"is hot".to_vec()); // Encode data file_header.encode(&mut buf)?; file_content.encode(&mut buf)?; // Now decode data back let mut cursor = std::io::Cursor::new(buf); assert_eq!(cursor.decode_u64()?, Some(MAGIC_NUMBER)); assert_eq!(cursor.decode_map()?, Some(Map::try_from(file_header)?)); assert_eq!(cursor.decode_blob()?, Some(Blob::try_from(file_content)?)); assert_eq!(cursor.decode()?, None);
Thanks
Special thanks to Binn's authors for their hard work.
Thank you,
Modules
specification | Specification |
storage | Storages |
value | Values |
version_info |
|
Structs
Error | Error |
Enums
Value | Values |
Constants
CODE_NAME | Crate code name |
ID | ID of this crate |
NAME | Crate name |
RELEASE_DATE | Crate release date (year/month/day) |
TAG | Tag, which can be used for logging... |
VERSION | Crate version |
Traits
Decoder | Decoder |
Encoder | Encoder |
Functions
blob | Makes new blob |
blob_with_capacity | Makes new blob with capacity |
decode | Decodes a value from source |
decode_blob | Decodes a |
decode_bool | Decodes a boolean value |
decode_date | Decodes a |
decode_date_time | Decodes a |
decode_decimal_str | Decodes a |
decode_double | Decodes a |
decode_float | Decodes a |
decode_i8 | Decodes an |
decode_i16 | Decodes an |
decode_i32 | Decodes an |
decode_i64 | Decodes an |
decode_list | Decodes a |
decode_map | Decodes a |
decode_null | Decodes a |
decode_object | Decodes an |
decode_text | Decodes a |
decode_time | Decodes a |
decode_u8 | Decodes a |
decode_u16 | Decodes a |
decode_u32 | Decodes a |
decode_u64 | Decodes a |
encode | Encodes a value |
encode_blob | Encodes a |
encode_bool | |
encode_date | Encodes a |
encode_date_time | Encodes a |
encode_decimal_str | Encodes a |
encode_double | Encodes a |
encode_float | Encodes a |
encode_i8 | Encodes an |
encode_i16 | Encodes an |
encode_i32 | Encodes an |
encode_i64 | Encodes an |
encode_list | Encodes a |
encode_map | Encodes a |
encode_null | Encodes a |
encode_object | Encodes an |
encode_text | Encodes a |
encode_time | Encodes a |
encode_u8 | Encodes a |
encode_u16 | Encodes a |
encode_u32 | Encodes a |
encode_u64 | Encodes a |
list | Makes new list |
list_with_capacity | Makes new list with capacity |
map | Makes new map |
map_from | Makes new map from one pair of key/value |
map_insert | Inserts new item into a map |
object | Makes new object |
object_from | Makes new object from one pair of key/value |
object_insert | Inserts new item into an object |
push | Pushes new value into a list |
Type Definitions
Blob | Blob |
IoResult | Result for I/O functions |
List | List |
Map | Map |
MapKey | Map key |
Object | Object |
ObjectKey | Object key |
Result | Result type used in this crate |
Size | Size |