From 5b488f558ccaca6ac35edda0366d74b9126285e3 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sat, 14 Nov 2026 03:17:45 -0700 Subject: use futures-lite and async-io these are from smol, but we don't need all of smol it's a kinda upsetting quantity of transitive dependencies :( but oh well Force-Push: yes Change-Id: I84d638b4866adf7f68401f6065c7ab358d3e7892 --- src/error.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/error.rs (limited to 'src/error.rs') diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..81c69e5 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,35 @@ +use std::fmt::{ self, Display }; + +#[derive(Debug)] +pub struct Error(String); +pub type Result = std::result::Result; + + +impl Display for Error { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(formatter, "Error: {}", self.0) + } +} + +impl From for Error { + fn from(error: xcb::Error) -> Error { + match error { + xcb::Error::Connection(error) => error.into(), + xcb::Error::Protocol(error) => error.into(), + } + } +} + +impl From for Error { + fn from(error: xcb::ConnError) -> Error { + Error(format!("X connection: {}", error)) + } +} + +impl From for Error { + fn from(error: xcb::ProtocolError) -> Error { + Error(format!("X protocol: {}", error)) + } +} + + -- cgit 1.4.1