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
#![warn(missing_docs, missing_debug_implementations)]
use wayland_backend::{
client::{InvalidId, ObjectId, WaylandError},
protocol::{Interface, Message},
};
mod conn;
mod event_queue;
pub mod globals;
pub mod backend {
pub use wayland_backend::client::{
Backend, Handle, InvalidId, NoWaylandLib, ObjectData, ObjectId, ReadEventsGuard,
WaylandError,
};
pub use wayland_backend::protocol;
pub use wayland_backend::smallvec;
}
pub use wayland_backend::protocol::WEnum;
pub use conn::{ConnectError, Connection, ConnectionHandle};
pub use event_queue::{
DelegateDispatch, DelegateDispatchBase, Dispatch, EventQueue, QueueHandle, QueueProxyData,
};
#[allow(missing_docs)]
pub mod protocol {
use self::__interfaces::*;
use crate as wayland_client;
pub mod __interfaces {
wayland_scanner::generate_interfaces!("wayland.xml");
}
wayland_scanner::generate_client_code!("wayland.xml");
}
pub trait Proxy: Sized {
type Event;
type Request;
fn interface() -> &'static Interface;
fn id(&self) -> ObjectId;
fn version(&self) -> u32;
fn data<U: Send + Sync + 'static>(&self) -> Option<&U>;
fn from_id(conn: &mut ConnectionHandle, id: ObjectId) -> Result<Self, InvalidId>;
fn parse_event(
conn: &mut ConnectionHandle,
msg: Message<ObjectId>,
) -> Result<(Self, Self::Event), DispatchError>;
fn write_request(
&self,
conn: &mut ConnectionHandle,
req: Self::Request,
) -> Result<Message<ObjectId>, InvalidId>;
}
#[derive(thiserror::Error, Debug)]
pub enum DispatchError {
#[error("Bad message for interface {interface} : {msg:?}")]
BadMessage {
msg: Message<ObjectId>,
interface: &'static str,
},
#[error("Backend error: {0}")]
Backend(#[from] WaylandError),
}