[][src]Function zstd_safe::get_decompressed_size

pub fn get_decompressed_size(src: &[u8]) -> u64

ZSTD_getDecompressedSize()

NOTE: This function is planned to be obsolete, in favour of ZSTD_getFrameContentSize.

ZSTD_getFrameContentSize functions the same way, returning the decompressed size of a single frame, but distinguishes empty frames from frames with an unknown size, or errors.

Additionally, ZSTD_findDecompressedSize can be used instead. It can handle multiple concatenated frames in one buffer, and so is more general.

As a result however, it requires more computation and entire frames to be passed to it, as opposed to ZSTD_getFrameContentSize which requires only a single frame's header.

src is the start of a zstd compressed frame.

Returns content size to be decompressed, as a 64-bits value if known, 0 otherwise.

note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode. When return==0, data to decompress could be any size. In which case, it's necessary to use streaming mode to decompress data. Optionally, application can still use ZSTD_decompress() while relying on implied limits. (For example, data may be necessarily cut into blocks <= 16 KB).

note 2 : decompressed size is always present when compression is done with ZSTD_compress()

note 3 : decompressed size can be very large (64-bits value), potentially larger than what local system can handle as a single memory segment. In which case, it's necessary to use streaming mode to decompress data.

note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified. Always ensure result fits within application's authorized limits. Each application can set its own limits.

note 5 : when return==0, if precise failure cause is needed, use ZSTD_getFrameParams() to know more.