Expand description
RNS 1.4.2 Resource bz2, the half the pure engine leaves to its host. prns-core
carries a resource as an opaque stream and flags it compressed or not; the codec is
the host’s, because bz2 is unavailable on the embedded targets the core also serves.
The tokio host has no such limit, so it compresses every outgoing resource and inflates
every compressed one, and a std node speaks the reference’s wire compression byte-for-byte.
Pure-Rust bz2 (bzip2’s default libbz2-rs-sys backend): no C toolchain, and nothing
for the crate’s forbid(unsafe_code) to trip on.
Enums§
Constants§
- SAMPLE_
GATE_ LEN - Sampling pays ~5 ms to sidestep an ~80 ms attempt at 1 MiB; below this the full attempt is cheap enough to just run, and every input stays on the reference’s exact path.
Functions§
- compress_
if_ smaller - RNS 1.4.2
Resource.__init__:bz2.compressat level 9 (its default), kept only when it comes out strictly smaller than the input.Noneis the reference’s else-branch: send the payload as-is with thecflag clear. For already-dense bytes bz2 only adds overhead, so the reference, and we, decline it. - compress_
resource_ candidate - decompress_
bounded - RNS 1.4.2’s bounded bz2 inflate,
BZ2Decompressor(...).decompress(data, max_length=…)with theeofcheck: inflate to at mostmax_len, refusing a stream that would run past it. Both callers capmax_lenat host policy (a resource’s advertised length, already gated by the link’sResourceStrategy; a stream chunk’s channel MDU), so a bz2 bomb can force neither an unbounded allocation nor an unbounded inflate. A resource caller passes its exact advertised length and re-checks it on assembly, so a stream that inflates short is caught there.