Next Generation WASM Microkernel Operating System
1// Copyright 2025. Jonas Kruckenberg
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7
8use core::alloc::AllocError;
9use core::fmt;
10
11#[derive(Debug)]
12pub enum SpawnError {
13 Closed,
14 Alloc,
15}
16
17impl From<AllocError> for SpawnError {
18 fn from(_: AllocError) -> Self {
19 Self::Alloc
20 }
21}
22
23impl From<Closed> for SpawnError {
24 fn from(_: Closed) -> Self {
25 Self::Closed
26 }
27}
28
29impl fmt::Display for SpawnError {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 match self {
32 SpawnError::Closed => f.write_str("executor was closed"),
33 SpawnError::Alloc => f.write_str("memory allocation failed"),
34 }
35 }
36}
37
38impl core::error::Error for SpawnError {}
39
40#[derive(Copy, Clone, Debug, Eq, PartialEq)]
41pub struct Closed(pub(crate) ());
42
43impl fmt::Display for Closed {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 f.pad("closed")
46 }
47}
48
49impl core::error::Error for Closed {}