shared_resources/
errors.rs

1/// Represents an error that occurred when accessing the [`Resources`](crate::Resources) store.
2#[derive(Debug, Copy, Clone, Eq, PartialEq)]
3pub enum AccessError {
4    /// There is no [`Resource`](crate::Resource) of the requested type in the store.
5    NoSuchResource,
6
7    /// The requested [`Resource`](crate::Resource) has already been borrowed.
8    AlreadyBorrowed,
9}
10
11impl std::fmt::Display for AccessError {
12    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
13        match self {
14            AccessError::NoSuchResource => write!(f, "There is no resource of the requested type."),
15            AccessError::AlreadyBorrowed => {
16                write!(f, "The requested resource is already borrowed.")
17            }
18        }
19    }
20}
21
22impl std::error::Error for AccessError {}