Module codec

Source
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.
CodecFlags
Encodes and decodes a sequence of flags as a single byte.
CodecIf
Encodes and decodes conditionally.
CodecJoin
Encodes and decodes an iterator as a sequence with an optional separator.
CodecLe
Encodes and decodes a number in little-endian order.
CodecLen
A dummy writer that counts bytes instead of actually writing them.
CodecLenValue
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 in Base16, Base32, and Base64.
Rfc4648Hex
The RFC 4648 hexadecimal-variant encoding, used in Base32.

Enums§

CompressionMode
The type of compression applied to data.
EncodingMode
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.
EncodableLen
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.
Base32Crockford
Base32 Crockford encoding. Case-insensitive, remaps O → 0, I/L → 1.
Base32Hex
Base32Hex uses RFC 4648 hex-encoding (0-9 A-V instead of A-Z 2-7).
Base32Padded
Base32 encoding with padding (=) enabled, using LUT decoding.
Base64Padded
Base64 encoding with padding (=) enabled, using LUT decoding.