pub fn dictionary_describes_frame(
dict_content: usize,
src_size: Option<u64>,
) -> boolExpand description
Whether a dictionary of dict_content bytes still describes a frame over
src_size bytes (None = not yet known), so that the shape it was prepared
with is the frame’s too.
A source under 128 KiB, or under six times the dictionary, is about the
dictionary: the tables it was prepared with are the right ones and can be
searched in place. Past that the frame is about its own content, and a shape
chosen for a dictionary undersizes it. A frame of unknown size keeps the
dictionary’s shape, having nothing better to go on. Upstream weighs the same
three things at ZSTD_compressBegin_internal (zstd_compress.c:5254).
A size of u64::MAX is the encoder’s “unknown” sentinel, not a source of
that many bytes, and counts as unknown here too.
This is the codec’s rule, exported so that every surface in front of it (the C ABI included) asks rather than re-deciding.
§Examples
use structured_zstd::encoding::dictionary_describes_frame;
// A few kilobytes against a 4 KiB dictionary: about the dictionary.
assert!(dictionary_describes_frame(4096, Some(8192)));
// A megabyte against the same: about itself.
assert!(!dictionary_describes_frame(4096, Some(1 << 20)));
// Unknown, so there is nothing better than the dictionary's own shape.
assert!(dictionary_describes_frame(4096, None));
assert!(dictionary_describes_frame(4096, Some(u64::MAX)));