diff --git a/crates/sl-std/src/bitreader.rs b/crates/sl-std/src/bitreader.rs index ca46c164..e0935fc6 100644 --- a/crates/sl-std/src/bitreader.rs +++ b/crates/sl-std/src/bitreader.rs @@ -1,3 +1,5 @@ +use std::fmt; + /// Wraps a byte buffer to allow reading individual bits #[derive(Debug)] pub struct BitReader<'a> { @@ -114,6 +116,16 @@ impl<'a> BitReader<'a> { } } +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::TooLargeRead => "attempting to read too many bits at once".fmt(f), + Self::UnalignedRead => "attempting to read bytes from an unaligned position".fmt(f), + Self::UnexpectedEOF => "unexpected end of file".fmt(f), + } + } +} + #[cfg(test)] mod tests { use super::BitReader;