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