llvm_bitcursor/error.rs
1//! Error management for `llvm-bitcursor`.
2
3use thiserror::Error as ThisError;
4
5/// All errors potentially produced by `llvm-bitcursor` APIs.
6/// Consumers should *not* attempt to match specific variants of this error type.
7#[non_exhaustive]
8#[derive(Debug, ThisError)]
9pub enum Error {
10 /// A read or other I/O operation encountered the end of the inner buffer.
11 #[error("EOF while reading")]
12 Eof,
13 /// A user attempted to call [`BitCursor::new_with_len`](crate::BitCursor::new_with_len) with
14 /// an impossible length (larger that the supplied buffer).
15 #[error("invalid length for buffer supplied to cursor")]
16 InvalidLength,
17 /// A generic API (e.g. [`BitCursor::read_as`](crate::BitCursor::read_as)) was asked to
18 /// read a value larger than the requested type could represent.
19 #[error("loss of data with cast")]
20 BadCast,
21 /// A read API was called with an invalid bitsize (too small or large).
22 #[error("invalid read size (zero or too large)")]
23 InvalidReadSize,
24 /// A VBR read API was called with an invalid VBR width.
25 #[cfg(any(feature = "vbr", doc))]
26 #[error("invalid VBR width (must be > 1 but <= system word width)")]
27 InvalidVbrWidth,
28 /// An I/O operation completed partially, but the inner buffer ended before it full completion.
29 #[error("too little data to service request")]
30 Short,
31}