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