Lonami / lzxd

https://crates.io/crates/lzxd
Apache License 2.0
14 stars 3 forks source link

Allow empty length trees #13

Closed DrChat closed 10 months ago

DrChat commented 10 months ago

Length trees are allowed to be empty (zero maximum path length).

Reference (in addition to BUILD_TABLE_MAYBE_EMPTY): https://github.com/kyz/libmspack/blob/305907723a4e7ab2018e58 40059ffb5e77db837/libmspack/mspack/lzxd.c#L555-L558

DrChat commented 10 months ago

As an aside, for the errors I'd urge you to consider making them opaque to our callers using something like the following:

enum ErrorRepr {
  OddLength,
  OverreadBlock,
  // ....
}

/// Implements std::error::Error, Display, etc...
pub struct Error(Box<ErrorRepr>);

Generally, most callers don't really care why decoding failed apart from knowing that it did fail. So this allows us much more flexibility in capturing relevant context information in errors as well as changing the representation without breaking SemVer.