Skip to main content

lamco_data_control/
error.rs

1//! Errors returned by the clipboard client.
2
3/// Errors returned by [`DataControl`](crate::DataControl).
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7    /// The connection to the Wayland compositor could not be made.
8    #[error("cannot connect to the Wayland compositor: {0}")]
9    Connect(String),
10
11    /// The compositor offers neither data-control protocol.
12    #[error("the compositor offers neither ext-data-control-v1 nor wlr-data-control-unstable-v1")]
13    Unsupported,
14
15    /// The requested protocol is not offered and fallback is disabled.
16    #[error("the requested data-control protocol is not offered by the compositor")]
17    ProtocolUnavailable,
18
19    /// The compositor advertises no seat to attach the clipboard to.
20    #[error("the compositor advertises no seat")]
21    NoSeat,
22
23    /// The compositor reported a protocol error or the connection failed.
24    #[error("Wayland error: {0}")]
25    Wayland(String),
26
27    /// The worker thread has stopped, so the request could not be delivered.
28    #[error("the clipboard worker has stopped")]
29    Stopped,
30
31    /// Clipboard data exceeded the size limit.
32    #[error("clipboard data of {size} bytes exceeds the {limit} byte limit")]
33    TooLarge {
34        /// Bytes received when the limit was hit.
35        size: usize,
36        /// The limit.
37        limit: usize,
38    },
39
40    /// The source did not deliver its data in time.
41    #[error("the clipboard source did not deliver its data in time")]
42    Timeout,
43
44    /// An I/O error while creating or reading a pipe.
45    #[error("I/O error: {0}")]
46    Io(#[from] std::io::Error),
47}
48
49/// Result alias for this crate.
50pub type Result<T> = std::result::Result<T, Error>;