Skip to content

Commit

Permalink
Add new error types, remove implementation of From<T: Into<AtspiError…
Browse files Browse the repository at this point in the history
…>> due to conflicting trait implementations
  • Loading branch information
TTWNO committed Jan 21, 2023
1 parent b7dd3b3 commit 990370a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ smartstring = "1.0.1"
thiserror = "1.0.37"
tini = "^1.3.0"
zbus.workspace = true
serde_plain.workspace = true
32 changes: 29 additions & 3 deletions common/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use serde_plain::Error as SerdePlainError;
use std::{error::Error, fmt, str::FromStr};
use atspi::error::AtspiError;
use smartstring::alias::String as SmartString;
Expand All @@ -6,11 +7,36 @@ use smartstring::alias::String as SmartString;
pub enum OdiliaError {
AtspiError(AtspiError),
PrimitiveConversionError(AccessiblePrimitiveConversionError),
NoAttributeError(String),
SerdeError(SerdePlainError),
Zbus(zbus::Error),
ZbusFdo(zbus::fdo::Error),
Zvariant(zbus::zvariant::Error),
}
impl Error for OdiliaError {}
impl<T: Into<AtspiError>> From<T> for OdiliaError {
fn from(err: T) -> OdiliaError {
Self::AtspiError(err.into())
impl From<zbus::fdo::Error> for OdiliaError {
fn from(spe: zbus::fdo::Error) -> Self {
Self::ZbusFdo(spe)
}
}
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 {
Expand Down
15 changes: 15 additions & 0 deletions common/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use serde::{self, Serialize, Deserialize};
use atspi::text::Granularity;
use zbus::zvariant::OwnedObjectPath;

Expand All @@ -16,3 +17,17 @@ pub enum TextSelectionArea {
Index(IndexesSelection),
Granular(GranularSelection),
}

#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Hash)]
#[serde(rename_all="lowercase", untagged)]
pub enum AriaLive {
Off,
Assertive,
Polite,
Other(String),
}

#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Hash)]
#[serde(transparent)]
pub struct AriaAtomic(bool);

0 comments on commit 990370a

Please sign in to comment.