You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was hoping the rustdocs for zstd::stream::read::Decoder::new might explain why it is fallible, so I could determine whether specific user facing error handling was required for this failure mode, or whether it was unlikely to occur in practice.
From inspection, it seems the only two fallible calls during the creation of the decoder are here:
Migrating from
flate2
to thezstd
crate, it was surprising to me to find thatzstd::stream::read::Decoder::new
returns anio::Result
:zstd-rs/src/stream/read/mod.rs
Lines 24 to 31 in e470f00
Compare this to
flate2::read::GzDecoder::new
, which returns the decoder directly:https://docs.rs/flate2/latest/flate2/read/struct.GzDecoder.html#method.new
I was hoping the rustdocs for
zstd::stream::read::Decoder::new
might explain why it is fallible, so I could determine whether specific user facing error handling was required for this failure mode, or whether it was unlikely to occur in practice.From inspection, it seems the only two fallible calls during the creation of the decoder are here:
zstd-rs/src/stream/raw.rs
Lines 147 to 150 in e470f00
...which are:
zstd_sys::ZSTD_initDStream
zstd_sys::ZSTD_DCtx_loadDictionary
Checking the zstd source for
ZSTD_initDStream
I see:https://github.com/facebook/zstd/blob/ff7a151f2e6c009b657d9f798c2d9962b0e3feb5/lib/decompress/zstd_decompress.c#L1747-L1754
...where the code comment suggests it can't fail?
Similarly, checking
ZSTD_DCtx_loadDictionary
I see the fallible paths appear to only be encountered if trying to set the dictionary when the context is in the wrong state (which can't happen unlesszstd-safe
has a bug), or when a non-empty dictionary is provided (andDecoder::new
sets an empty dictionary):https://github.com/facebook/zstd/blob/ff7a151f2e6c009b657d9f798c2d9962b0e3feb5/lib/decompress/zstd_decompress.c#L1697-L1711
...so unless I'm missing something it appears
Decoder::new()
can never fail in practice?The text was updated successfully, but these errors were encountered: