kernel/alloc/kvec/
errors.rs1use crate::{
6 fmt,
7 prelude::*, };
9
10pub struct PushError<T>(pub T);
12
13impl<T> fmt::Debug for PushError<T> {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 write!(f, "Not enough capacity")
16 }
17}
18
19impl<T> From<PushError<T>> for Error {
20 #[inline]
21 fn from(_: PushError<T>) -> Error {
22 EINVAL
25 }
26}
27
28pub struct RemoveError;
30
31impl fmt::Debug for RemoveError {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 write!(f, "Index out of bounds")
34 }
35}
36
37impl From<RemoveError> for Error {
38 #[inline]
39 fn from(_: RemoveError) -> Error {
40 EINVAL
41 }
42}
43
44pub enum InsertError<T> {
46 IndexOutOfBounds(T),
48 OutOfCapacity(T),
50}
51
52impl<T> fmt::Debug for InsertError<T> {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 match self {
55 InsertError::IndexOutOfBounds(_) => write!(f, "Index out of bounds"),
56 InsertError::OutOfCapacity(_) => write!(f, "Not enough capacity"),
57 }
58 }
59}
60
61impl<T> From<InsertError<T>> for Error {
62 #[inline]
63 fn from(_: InsertError<T>) -> Error {
64 EINVAL
65 }
66}