Expand description
This module provides specialized implementations of standard library collection types that
provide control over the length encoding (see SeqLen), as well
as special case opt-in raw-copy overrides (see pod_wrapper!).
§Examples
Raw byte vec with UseIntLen<u16> length encoding:
#[derive(SchemaWrite, SchemaRead, PartialEq, Debug)]
struct MyStruct {
#[wincode(with = "containers::Vec<_, UseIntLen<u16>>")]
vec: Vec<u8>,
}
let my_struct = MyStruct { vec: vec![1, 2, 3] };
let bytes = wincode::serialize(&my_struct).unwrap();
assert_eq!(bytes.len(), size_of::<u16>() + my_struct.vec.len() * size_of::<u8>());
assert_eq!(my_struct, wincode::deserialize(&bytes).unwrap());Vector with struct elements and UseIntLen<u16> length encoding:
#[derive(SchemaWrite, SchemaRead, PartialEq, Debug)]
struct Point {
x: u64,
y: u64,
}
#[derive(SchemaWrite, SchemaRead, PartialEq, Debug)]
struct MyStruct {
#[wincode(with = "containers::Vec<Point, UseIntLen<u16>>")]
vec: Vec<Point>,
}
let my_struct = MyStruct {
vec: vec![Point { x: 1, y: 2 }, Point { x: 3, y: 4 }],
};
let bytes = wincode::serialize(&my_struct).unwrap();
assert_eq!(bytes.len(), size_of::<u16>() + my_struct.vec.len() * size_of::<Point>());
assert_eq!(my_struct, wincode::deserialize(&bytes).unwrap());Macros§
- pod_
wrapper - Creates a wrapper type for a type that is represented by raw bytes and does not have any invalid bit patterns.
Structs§
- Arc
- Like
Box, forArc. - Binary
Heap - A
BinaryHeapwith a customizable length encoding. - Box
- A
Box<[T]>with a customizable length encoding. - From
Into Iterator - A generic sequence schema for custom collections that implement
FromIterator(for reading) and whose references implementIntoIteratorwith anExactSizeIterator(for writing). - Rc
- Like
Box, forRc. - Vec
- A
Vecwith a customizable length encoding. - VecDeque
- A
VecDequewith a customizable length encoding.
Functions§
- decode_
into_ slice_ t - Decode
slice.len()items ofTinto contiguous, uninitialized memory. - encode_
from_ iter - Like
encode_from_iter_prealloc_check, but skips the preallocation size check. - encode_
from_ iter_ prealloc_ check - Encode a sequence of
Tfrom an iterator into theWriter.