1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use atspi::error::AtspiError;
use serde_plain::Error as SerdePlainError;
use smartstring::alias::String as SmartString;
use std::{error::Error, fmt, str::FromStr};
#[derive(Debug)]
pub enum OdiliaError {
AtspiError(AtspiError),
PrimitiveConversionError(AccessiblePrimitiveConversionError),
NoAttributeError(String),
SerdeError(SerdePlainError),
Zbus(zbus::Error),
ZbusFdo(zbus::fdo::Error),
Zvariant(zbus::zvariant::Error),
Cache(CacheError),
InfallibleConversion(std::convert::Infallible),
Generic(String),
}
#[derive(Debug)]
pub enum CacheError {
NotAvailable,
NoItem,
NoLock,
}
impl std::fmt::Display for CacheError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::NotAvailable => f.write_str("The cache has been dropped from memory. This never happens under normal circumstances, and should never happen. Please send a detailed bug report if this ever happens."),
Self::NoItem => f.write_str("No item in cache found."),
Self::NoLock => f.write_str("It was not possible to get a lock on this item from the cache."),
}
}
}
impl std::error::Error for CacheError {}
impl Error for OdiliaError {}
impl From<zbus::fdo::Error> for OdiliaError {
fn from(spe: zbus::fdo::Error) -> Self {
Self::ZbusFdo(spe)
}
}
impl From<std::convert::Infallible> for OdiliaError {
fn from(infallible: std::convert::Infallible) -> Self {
Self::InfallibleConversion(infallible)
}
}
impl From<CacheError> for OdiliaError {
fn from(cache_error: CacheError) -> Self {
Self::Cache(cache_error)
}
}
impl From<zbus::Error> for OdiliaError {
fn from(spe: zbus::Error) -> Self {
Self::Zbus(spe)
}
}
impl From<zbus::zvariant::Error> for OdiliaError {
fn from(spe: zbus::zvariant::Error) -> Self {
Self::Zvariant(spe)
}
}
impl From<SerdePlainError> for OdiliaError {
fn from(spe: SerdePlainError) -> Self {
Self::SerdeError(spe)
}
}
impl From<AtspiError> for OdiliaError {
fn from(err: AtspiError) -> OdiliaError {
Self::AtspiError(err)
}
}
impl fmt::Display for OdiliaError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{self:?}")
}
}
#[derive(Clone, Debug)]
pub enum AccessiblePrimitiveConversionError {
ParseError(<i32 as FromStr>::Err),
ObjectConversionError(atspi::error::ObjectPathConversionError),
NoPathId,
NoFirstSectionOfSender,
NoSecondSectionOfSender,
NoSender,
ErrSender,
}
impl From<AccessiblePrimitiveConversionError> for OdiliaError {
fn from(apc_error: AccessiblePrimitiveConversionError) -> Self {
Self::PrimitiveConversionError(apc_error)
}
}
impl fmt::Display for AccessiblePrimitiveConversionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for AccessiblePrimitiveConversionError {}
impl From<atspi::error::ObjectPathConversionError> for AccessiblePrimitiveConversionError {
fn from(object_conversion_error: atspi::error::ObjectPathConversionError) -> Self {
Self::ObjectConversionError(object_conversion_error)
}
}
#[derive(Debug, Clone, thiserror::Error)]
pub enum KeyFromStrError {
#[error("Empty key binding")]
EmptyString,
#[error("No key was provided")]
NoKey,
#[error("Empty key")]
EmptyKey,
#[error("Invalid key: {0:?}")]
InvalidKey(SmartString),
#[error("Invalid repeat: {0:?}")]
InvalidRepeat(SmartString),
#[error("Invalid modifier: {0:?}")]
InvalidModifier(SmartString),
#[error("Invalid mode: {0:?}")]
InvalidMode(SmartString),
}
#[derive(Debug, Clone, Copy, thiserror::Error)]
pub enum ModeFromStrError {
#[error("Mode not found")]
ModeNameNotFound,
}