-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
This is slightly related to #4 but goes further so I wanted to ticket it.
I would like to open a PR to change the return of decompress to error | {ok, Uncompressed}. The reason for that is that it will allow clearer matching and guarding against wrong returns.
Right now using a code like:
Uncompressed = zstd:decompress(In),
<<Acc/binary, Uncompressed/binary>>can lead to odd errors in places where the error doesn't occur when the In value isn't a valid compressed binary.
It would require additional matching to guard against handing on invalid data For example:
Uncompressed = case zstd:decompress(In) of
X when is_binary(X) -> X
end,
<<Acc/binary, Uncompressed/binary>>returning a tuple would allow to guard against handing on bad data right during decoding time and failing fast:
{ok, Uncompressed} = zstd:decompress(In),
<<Acc/binary, Uncompressed/binary>>Metadata
Metadata
Assignees
Labels
No labels