Skip to main content

base_scheduler/
spawn_error.rs

1// Released under the MIT License.
2// Copyright, 2026, by Samuel Williams.
3
4use std::fmt;
5
6/// A task could not be registered with its scheduler.
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum SpawnError {
9    /// The scheduler has begun shutting down.
10    SchedulerClosed,
11    /// All task identifiers have been used.
12    IdentifiersExhausted,
13}
14
15impl fmt::Display for SpawnError {
16    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
17        formatter.write_str(match self {
18            Self::SchedulerClosed => "the scheduler is closed",
19            Self::IdentifiersExhausted => "task identifiers are exhausted",
20        })
21    }
22}
23
24impl std::error::Error for SpawnError {}
25
26#[cfg(test)]
27mod tests;