Expand description
Abstractions for encoding and decoding data.
codec::{hash}
Extends: std::{hash}
§Determinism & Side Effects
Encoding and decoding should be deterministic. Implementations should avoid introducing side effects where possible.
Potential sources of non-determinism:
- Writing to or reading from external files or devices.
- Using randomness during encoding or decoding.
- Modifying or depending on global state.
§Example
use devela::{Encodable, CodecLenValue, IoWrite};
let mut buf = Vec::new();
CodecLenValue::<_, u8>::new("hello").encode(&mut buf).unwrap();
assert_eq!(&buf, b"\x05hello");
Modules§
- hash
- Generic hashing support.
Macros§
- bitfield
_bit··
- Creates a custom bit field struct.
Structs§
- Base
- A compile-time configurable radix-based encoding scheme.
- Bitwise
_bit··
- 🌐
Provides constant bitwise operations on
T
. - CodecBe
- Encodes and decodes a number in big-endian order.
- Codec
Flags - Encodes and decodes a sequence of flags as a single byte.
- CodecIf
- Encodes and decodes conditionally.
- Codec
Join - Encodes and decodes an iterator as a sequence with an optional
separator
. - CodecLe
- Encodes and decodes a number in little-endian order.
- Codec
Len - A dummy writer that counts bytes instead of actually writing them.
- Codec
LenValue - Encodes and decodes a length prefixed value (TLV).
- Crockford
- The
Crockford
Base32
encoding, case-insensitive, remaps certain characters. - Rfc4648
- The
RFC 4648
standard encoding, used inBase16
,Base32
, andBase64
. - Rfc4648
Hex - The
RFC 4648
hexadecimal-variant encoding, used inBase32
.
Enums§
- Compression
Mode - The type of compression applied to data.
- Encoding
Mode - The primary mode for data encoding.
Traits§
- BitOps
- Provides bitwise operations on
T
. - Decodable
- A type that can be decoded from an I/O reader.
- Encodable
- A type that can be encoded into an I/O writer.
- Encodable
Len - A type that can compute the size of its encoded form without actual encoding.
Type Aliases§
- Base16
Base16
standard encoding (hex), with linear search. Case-insensitive.- Base32
Base32
standard encoding, using LUT decoding. Case-sensitive.- Base64
Base64
standard encoding, using LUT decoding. Case-sensitive.- Base32
Crockford Base32
Crockford
encoding. Case-insensitive, remapsO → 0
,I/L → 1
.- Base32
Hex Base32Hex
uses RFC 4648 hex-encoding (0-9 A-V
instead ofA-Z 2-7
).- Base32
Padded Base32
encoding with padding (=
) enabled, using LUT decoding.- Base64
Padded Base64
encoding with padding (=
) enabled, using LUT decoding.