bytey_byte_buffer/
error.rs1pub type Result<T> = std::result::Result<T, ByteBufferError>;
2
3#[derive(thiserror::Error, Debug, Eq, PartialEq)]
4pub enum ByteBufferError {
5 #[error("Capacity cannot be greater than {} bytes", isize::MAX)]
6 MaxCapacity,
7
8 #[error("Failed to allocate {size} bytes")]
9 AllocationFailure { size: usize },
10
11 #[error("Failed to Generate Layout for Capacity {size}")]
12 LayoutFailure { size: usize },
13
14 #[error("Capacity cannot be less than 1 byte")]
15 MinCapacity,
16
17 #[error("Cursor out of bounds: {cursor} >= {length}")]
18 CursorOutOfBounds { length: usize, cursor: usize },
19
20 #[error("Read out of bounds: {start}..{end} >= {length}")]
21 ReadOutOfBounds {
22 length: usize,
23 start: usize,
24 end: usize,
25 },
26
27 #[error("Length out of bounds: {new} >= {current}")]
28 LengthOutOfBounds { current: usize, new: usize },
29
30 #[error("Other Error: {error}")]
31 OtherError { error: String },
32
33 #[error(transparent)]
34 UnicodeError(#[from] std::str::Utf8Error),
35
36 #[error("RefCellAlreadyBorrowed: {error} for type: {type_name}")]
37 RefCellAlreadyBorrowed {
38 error: String,
40 type_name: &'static str,
42 },
43 #[error("The NonZero Type is a 0. Maybe you have it set to the wrong position in the struct?")]
44 NonZeroIsZero,
45 #[error(
46 "the value can not be a char. Maybe you have it set to the wrong position in the struct?"
47 )]
48 NotAChar,
49}