Skip to content

Commit 741dea6

Browse files
committed
Restore changed public error structs for semver compat
1 parent 85d47ef commit 741dea6

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

src/common.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ pub enum Error {
3232
WaylandCommunication(#[source] WaylandError),
3333

3434
#[error(
35-
"A required Wayland protocol (ext-data-control, or wlr-data-control version {version}) \
36-
is not supported by the compositor"
35+
"A required Wayland protocol ({name} version {version}) is not supported by the compositor"
3736
)]
38-
MissingProtocol { version: u32 },
37+
MissingProtocol { name: &'static str, version: u32 },
3938
}
4039

4140
impl<S> Dispatch<WlSeat, (), S> for State
@@ -107,7 +106,12 @@ where
107106

108107
let clipboard_manager = match ext_manager.or_else(wlr_manager) {
109108
Some(manager) => manager,
110-
None => return Err(Error::MissingProtocol { version: wlr_v }),
109+
None => {
110+
return Err(Error::MissingProtocol {
111+
name: "ext-data-control, or wlr-data-control",
112+
version: wlr_v,
113+
})
114+
}
111115
};
112116

113117
let registry = globals.registry();

src/copy.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,11 @@ pub enum Error {
188188
WaylandCommunication(#[source] DispatchError),
189189

190190
#[error(
191-
"A required Wayland protocol (ext-data-control, or wlr-data-control version {version}) \
192-
is not supported by the compositor"
191+
"A required Wayland protocol ({} version {}) is not supported by the compositor",
192+
name,
193+
version
193194
)]
194-
MissingProtocol { version: u32 },
195+
MissingProtocol { name: &'static str, version: u32 },
195196

196197
#[error("The compositor does not support primary selection")]
197198
PrimarySelectionUnsupported,
@@ -220,7 +221,7 @@ impl From<common::Error> for Error {
220221
SocketOpenError(err) => Error::SocketOpenError(err),
221222
WaylandConnection(err) => Error::WaylandConnection(err),
222223
WaylandCommunication(err) => Error::WaylandCommunication(err.into()),
223-
MissingProtocol { version } => Error::MissingProtocol { version },
224+
MissingProtocol { name, version } => Error::MissingProtocol { name, version },
224225
}
225226
}
226227
}

src/paste.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ pub enum Error {
108108
WaylandCommunication(#[source] DispatchError),
109109

110110
#[error(
111-
"A required Wayland protocol (ext-data-control, or wlr-data-control version {version}) \
112-
is not supported by the compositor"
111+
"A required Wayland protocol ({} version {}) is not supported by the compositor",
112+
name,
113+
version
113114
)]
114-
MissingProtocol { version: u32 },
115+
MissingProtocol { name: &'static str, version: u32 },
115116

116117
#[error("The compositor does not support primary selection")]
117118
PrimarySelectionUnsupported,
@@ -131,7 +132,7 @@ impl From<common::Error> for Error {
131132
SocketOpenError(err) => Error::SocketOpenError(err),
132133
WaylandConnection(err) => Error::WaylandConnection(err),
133134
WaylandCommunication(err) => Error::WaylandCommunication(err.into()),
134-
MissingProtocol { version } => Error::MissingProtocol { version },
135+
MissingProtocol { name, version } => Error::MissingProtocol { name, version },
135136
}
136137
}
137138
}

src/tests/paste.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ fn get_mime_types_no_data_control() {
6565

6666
let result =
6767
get_mime_types_internal(ClipboardType::Regular, Seat::Unspecified, Some(socket_name));
68-
assert!(matches!(result, Err(Error::MissingProtocol { version: 1 })));
68+
assert!(matches!(
69+
result,
70+
Err(Error::MissingProtocol {
71+
name: "ext-data-control, or wlr-data-control",
72+
version: 1
73+
})
74+
));
6975
}
7076

7177
#[test]
@@ -88,7 +94,13 @@ fn get_mime_types_no_data_control_2() {
8894

8995
let result =
9096
get_mime_types_internal(ClipboardType::Primary, Seat::Unspecified, Some(socket_name));
91-
assert!(matches!(result, Err(Error::MissingProtocol { version: 2 })));
97+
assert!(matches!(
98+
result,
99+
Err(Error::MissingProtocol {
100+
name: "ext-data-control, or wlr-data-control",
101+
version: 2
102+
})
103+
));
92104
}
93105

94106
#[test]

0 commit comments

Comments
 (0)