pub enum Error {
ValueTooLarge {
value: u128,
bits: u32,
},
}Expand description
Errors from checked construction.
Currently the only fallible operation is UInt::try_new (and the TryFrom
impls built on it). Decoding never fails: the codec is dual-use, so unknown
values are preserved as Custom/catch-all rather than rejected, and field
access masks rather than validates.
§Examples
use bnb::{u4, Error};
let err = u4::try_new(20).unwrap_err(); // 20 doesn't fit in 4 bits
assert_eq!(err, Error::ValueTooLarge { value: 20, bits: 4 });
assert_eq!(err.to_string(), "value 20 does not fit in 4 bits");Variants§
ValueTooLarge
A value did not fit in the target integer’s bit width.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<Error> for BitError
impl From<Error> for BitError
Source§fn from(e: Error) -> Self
fn from(e: Error) -> Self
Bridges a construction error (e.g. UInt::try_new) into a codec error, so it
?-propagates inside a custom parse_with/write_with fn or a converter
that returns BitError. The offset is unknown (0) — the codec’s own
reads/writes carry the real bit offset; this is only for borrowed construction
failures with no cursor context.
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more