Expand description
Zero-unsafe, zero-runtime-dependency Tier-2 little-endian binary codec primitives
(ByteReader, ByteWriter, SliceWriter, ByteSink, ByteBuf, CodecError, NvEncode,
NvDecode) and #[derive(NvCodec)].
Sits strictly below nativeview-abi in the workspace dependency DAG (depends only on zero-dep
nativeview-abi-macros) so every core, framework, backend, and module crate shares one canonical,
bounds-checked, DoS-hardened Tier-2 codec.
Re-exports§
pub use transport::call_sync_decode;pub use transport::decode_opt_raw_str;pub use transport::encode_f32_stack;pub use transport::encode_f64_stack;pub use transport::encode_opt_raw_str;pub use transport::try_with_stack_writer;pub use transport::with_stack_writer;pub use transport::ByteTransport;pub use transport::StackWriter;pub use transport::TransportDoneFn;pub use transport::TransportError;
Modules§
- transport
- Framework- and runtime-agnostic binary byte transport (
ByteTransport), error model (TransportError), and zero-waste stack-first request encoding helpers (StackWriter,with_stack_writer,try_with_stack_writer, and canonical float stack encoders).
Structs§
- ByteBuf
- Owned binary byte buffer (
u32length prefix + raw bytes, capped atDEFAULT_MAX_BYTES= 16 MiB and encoded/decoded in one bulk slice copy). - Byte
Reader - Strictly bounds-checked little-endian binary reader.
- Byte
Writer - Reusable little-endian binary writer.
- Flat
OpDesc - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums. - Flat
OpField Desc - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums. - Flat
OpScope Desc - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums. - Flat
OpStream Desc - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums. - Slice
Writer - Zero-allocation little-endian binary writer over a caller-owned
&mut [u8]slice.
Enums§
- Codec
Error - Typed, allocation-free error produced by
ByteReader,ByteWriter,SliceWriter, and#[derive(NvCodec)]. - Flat
OpField Type - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums. - Flat
OpStr Error - Error returned when validating or decoding a word-padded UTF-8
crate::FlatOpFieldType::StrSlice. - Float
Constraint - Derives
NvEncodeandNvDecodefor Tier-2 little-endian structs and enums.
Constants§
- CANONICAL_
F32_ NAN_ BITS - Canonical quiet NaN bit pattern for
f32(IEEE-754 little-endian deterministic encoding). - CANONICAL_
F64_ NAN_ BITS - Canonical quiet NaN bit pattern for
f64(IEEE-754 little-endian deterministic encoding). - DEFAULT_
MAX_ BYTES - Default upper bound on byte/string lengths encoded/decoded by
NvEncode/NvDecode(16 MiB). - DEFAULT_
MAX_ DEPTH - Default maximum container nesting depth (
read_vec/read_opt) guarding against stack-overflow DoS on recursive#[derive(NvCodec)]types. - DEFAULT_
MAX_ ITEMS - Default upper bound on element counts encoded/decoded by
NvEncode/NvDecodeforVec<T>.
Traits§
- Byte
Sink - Shared little-endian primitive writing sink implemented by
ByteWriter,SliceWriter, and [StackWriter], enabling wire types to share one zero-alloc serialization path. - NvDecode
- Trait for Tier-2 little-endian binary deserialization from a
ByteReader. - NvEncode
- Trait for Tier-2 little-endian binary serialization into any
ByteSink.
Functions§
- canonical_
f32_ bits - Canonicalizes an
f32(-0.0->+0.0, anyNaN-> canonical quietNaN). - canonical_
f64_ bits - Canonicalizes an
f64(-0.0->+0.0, anyNaN-> canonical quietNaN). - check_
flat_ op_ bytes_ words - Validates the framing, length bound, bounds, and zero trailing padding of a word-padded byte
block starting at
words[pos], returning(payload_start, block_end, byte_len)on success. - flat_
op_ str_ pad_ mask - Bitmask of the trailing padding bytes in the final
u32word forbyte_lenbytes (0whenbyte_lenis already 4-byte aligned). - flat_
op_ str_ padded_ bytes - Padded byte length (multiple of 4) required for
byte_lenbytes, orNoneon overflow. - flat_
op_ str_ word_ len - Number of
u32payload words required forbyte_lenbytes (ceil(byte_len / 4)). - for_
each_ padded_ le_ word - Visits
bytesas little-endianu32words, zero-padding the final partial word (flat_op_str_word_len(bytes.len())calls; the payload half of aStrSliceblock, e.g. for hashing it without materializing the words). Zero-allocation. - hex_
nibble - Decodes one ASCII hexadecimal digit (
0-9,a-f,A-F) into its 4-bit value0..=15. - read_
flat_ op_ padded_ bytes - Validates and borrows the raw payload of a
[byte_len: u32 LE, bytes..., zero_pad...]block (the byte form ofwrite_flat_op_bytes_words) atbytes[*pos], advancing*pospast the 4-byte-padded block on success. - read_
flat_ op_ str_ bytes - Validates and borrows a zero-copy
&strfrom a little-endian byte buffer atbytes[*pos], advancing*pospast the 4-byte-padded block on success. - read_
flat_ op_ str_ words - Validates and decodes a word-padded UTF-8 string block at
words[*pos]into an ownedString, advancing*pospast the block on success. - read_
flat_ op_ str_ words_ into - Validates and decodes a word-padded UTF-8 string block at
words[*pos]intooutin a single pass, clearingoutfirst and advancing*pospast the block on success. - try_
write_ fixed - Fallible zero-allocation helper for fixed-size wire layouts (
Nbytes exact). - validate_
flat_ op_ str_ bytes - Validates a word-padded UTF-8 string block in a little-endian byte buffer at
bytes[*pos], advancing*pospast the 4-byte-padded block on success. - validate_
flat_ op_ str_ words - Validates a word-padded UTF-8 string block at
words[*pos](enforcinglen <= max_bytes, sufficient words, zeroed trailing padding bytes, and strict UTF-8) and advances*pospast it. - write_
fixed - Zero-allocation helper for infallible fixed-size wire layouts (
Nbytes exact). - write_
fixed_ into - Zero-allocation helper filling a caller-owned
[u8; N]fixed-size wire buffer. - write_
flat_ op_ bytes_ words - Appends
[byte_len: u32, zero_padded_le_words...]for rawbytestoout. - write_
flat_ op_ str_ bytes - Appends
[byte_len: u32 LE, utf8_bytes..., zero_pad...]toout. - write_
flat_ op_ str_ words - Appends
[byte_len: u32, zero_padded_utf8_le_words...]toout.