use thiserror::Error;
#[derive(Debug, Error)]
pub(crate) enum MutterError {
#[error("dbus-launch failed: {0}")]
DbusLaunchFailed(String),
#[error("could not parse {field} from dbus-launch output")]
DbusOutputMissingField { field: &'static str },
#[error("invalid dbus PID in dbus-launch output")]
DbusPidParse(#[source] std::num::ParseIntError),
#[error("invalid mutter D-Bus address {addr:?}")]
DbusAddressInvalid {
addr: String,
#[source]
source: zbus::Error,
},
#[error("mutter D-Bus: {stage}")]
DbusConnect {
stage: &'static str,
#[source]
source: zbus::Error,
},
#[error("RemoteDesktop.CreateSession")]
RemoteDesktopCreate(#[source] zbus::Error),
#[error("parse RemoteDesktop session path")]
RdSessionPathParse(#[source] zbus::Error),
#[error("Get SessionId property")]
SessionIdGet(#[source] zbus::Error),
#[error("parse SessionId variant")]
SessionIdVariantParse(#[source] zbus::Error),
#[error("SessionId is not a string")]
SessionIdNotString(#[source] zbus::zvariant::Error),
#[error("invalid resolution {value:?}: expected WIDTHxHEIGHT")]
ResolutionInvalid { value: String },
#[error("spawning {process}")]
Spawn {
process: &'static str,
#[source]
source: std::io::Error,
},
#[error("io")]
Io(#[from] std::io::Error),
#[error("wayland socket {socket} did not appear within 5s")]
WaylandSocketTimeout { socket: String },
#[error("pipewire socket {socket} did not appear within 5s")]
PipewireSocketTimeout { socket: String },
}
impl From<MutterError> for waydriver::Error {
fn from(e: MutterError) -> Self {
match e {
MutterError::WaylandSocketTimeout { ref socket } => waydriver::Error::Timeout(format!(
"wayland socket {socket} did not appear within 5s"
)),
MutterError::PipewireSocketTimeout { ref socket } => waydriver::Error::Timeout(
format!("pipewire socket {socket} did not appear within 5s"),
),
MutterError::Io(io) => waydriver::Error::Io(io),
other => waydriver::Error::process_with("mutter compositor", other),
}
}
}