felixwrt / sml-rs

Smart Message Language parser written in Rust
Other
11 stars 3 forks source link

Decoder Improvements #43

Closed felixwrt closed 3 days ago

felixwrt commented 3 days ago

Up until now, the Decoder was writing some data (escape sequence bytes, padding bytes) into the Buffer even though that data isn't always part of the user data. This lead to situations where a decoded message that would barely fit into the buffer couldn't be decoded because writing these additional (unneeded) bytes into the buffer failed.

With this PR, the decoder's state handling is adapted such that it only writes data into the buffer when that data belongs to the decoded message. The decoder doesn't use truncate anymore to remove written bytes from the buffer.

Breaking Changes

This PR adds a new member invalid_padding_bytes to the enum variant DecodeErr::InvalidMessage which indicates if any of the padding bytes were invalid (!=0).