Skip to content

Commit 7204f13

Browse files
committed
Auto-fixed clippy::pedantic lints
Notes: - Exact command done: `cargo clippy --fix --features calloop,tokio -- -W clippy::pedantic` - Undid fixes for auto-generated files, for now - Ran `cargo fmt`
1 parent 3d0049b commit 7204f13

File tree

16 files changed

+95
-55
lines changed

16 files changed

+95
-55
lines changed

examples/list-devices.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,12 @@ impl State {
104104
_ => {}
105105
}
106106
}
107-
ei::Event::Callback(callback, request) => match request {
108-
ei::callback::Event::Done { callback_data: _ } => {
107+
ei::Event::Callback(callback, request) => {
108+
if let ei::callback::Event::Done { callback_data: _ } = request {
109109
// TODO: Callback being called after first device, but not later ones?
110110
// self.print_and_exit_if_done();
111111
}
112-
_ => {}
113-
},
112+
}
114113
_ => {}
115114
}
116115

examples/receive-synchronous.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ fn main() {
7878
println!(" seat: {:?}", evt.device.seat().name());
7979
println!(" type: {:?}", evt.device.device_type());
8080
if let Some(dimensions) = evt.device.dimensions() {
81-
println!(" dimensions: {:?}", dimensions);
81+
println!(" dimensions: {dimensions:?}");
8282
}
8383
println!(" regions: {:?}", evt.device.regions());
8484
if let Some(keymap) = evt.device.keymap() {
85-
println!(" keymap: {:?}", keymap);
85+
println!(" keymap: {keymap:?}");
8686
}
8787
// Interfaces?
8888
}

examples/receive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ async fn main() {
7979
println!(" seat: {:?}", evt.device.seat().name());
8080
println!(" type: {:?}", evt.device.device_type());
8181
if let Some(dimensions) = evt.device.dimensions() {
82-
println!(" dimensions: {:?}", dimensions);
82+
println!(" dimensions: {dimensions:?}");
8383
}
8484
println!(" regions: {:?}", evt.device.regions());
8585
if let Some(keymap) = evt.device.keymap() {
86-
println!(" keymap: {:?}", keymap);
86+
println!(" keymap: {keymap:?}");
8787
}
8888
// Interfaces?
8989
}

examples/reis-demo-server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct State {
112112

113113
impl State {
114114
fn handle_new_connection(&mut self, context: eis::Context) -> io::Result<calloop::PostAction> {
115-
println!("New connection: {:?}", context);
115+
println!("New connection: {context:?}");
116116

117117
let source = EisRequestSource::new(context, 1);
118118
let mut context_state = ContextState { seat: None };

examples/type-text.rs

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl State {
5454
&mut self,
5555
context: &mut ei::Context,
5656
) -> io::Result<calloop::PostAction> {
57-
if let Err(_) = context.read() {
57+
if context.read().is_err() {
5858
return Ok(calloop::PostAction::Remove);
5959
}
6060

@@ -193,31 +193,29 @@ impl State {
193193
}
194194
}
195195
ei::Event::Keyboard(keyboard, request) => {
196-
match request {
197-
ei::keyboard::Event::Keymap {
198-
keymap_type,
199-
size,
200-
keymap,
201-
} => {
202-
// XXX format
203-
// flags?
204-
// handle multiple keyboard?
205-
let context = xkb::Context::new(0);
206-
self.keymap = Some(
207-
unsafe {
208-
xkb::Keymap::new_from_fd(
209-
&context,
210-
keymap,
211-
size as _,
212-
xkb::KEYMAP_FORMAT_TEXT_V1,
213-
0,
214-
)
215-
}
216-
.unwrap()
217-
.unwrap(),
218-
);
219-
}
220-
_ => {}
196+
if let ei::keyboard::Event::Keymap {
197+
keymap_type,
198+
size,
199+
keymap,
200+
} = request
201+
{
202+
// XXX format
203+
// flags?
204+
// handle multiple keyboard?
205+
let context = xkb::Context::new(0);
206+
self.keymap = Some(
207+
unsafe {
208+
xkb::Keymap::new_from_fd(
209+
&context,
210+
keymap,
211+
size as _,
212+
xkb::KEYMAP_FORMAT_TEXT_V1,
213+
0,
214+
)
215+
}
216+
.unwrap()
217+
.unwrap(),
218+
);
221219
}
222220
}
223221
_ => {}

src/calloop.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct EisListenerSource {
1717
}
1818

1919
impl EisListenerSource {
20+
#[must_use]
2021
pub fn new(listener: eis::Listener) -> Self {
2122
Self {
2223
source: Generic::new(listener, Interest::READ, Mode::Level),
@@ -166,6 +167,7 @@ pub struct EisRequestSource {
166167
}
167168

168169
impl EisRequestSource {
170+
#[must_use]
169171
pub fn new(context: eis::Context, initial_serial: u32) -> Self {
170172
let handshaker = crate::handshake::EisHandshaker::new(&context, initial_serial);
171173
Self {

src/ei.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl Context {
9898
}
9999

100100
/// Returns the interface proxy for the `ei_handshake` object.
101+
#[must_use]
101102
pub fn handshake(&self) -> handshake::Handshake {
102103
self.0.object_for_id(0).unwrap().downcast_unchecked()
103104
}

src/eis.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl Context {
134134
}
135135

136136
/// Returns the interface proxy for the `ei_handshake` object.
137+
#[must_use]
137138
pub fn handshake(&self) -> handshake::Handshake {
138139
self.0.object_for_id(0).unwrap().downcast_unchecked()
139140
}

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl fmt::Display for Error {
2222
write!(f, "invalid version {version} for interface '{interface}'")
2323
}
2424
Self::Event(err) => write!(f, "event error: {err}"),
25-
Self::Request(err) => write!(f, "request error: {}", err),
25+
Self::Request(err) => write!(f, "request error: {err}"),
2626
Self::Io(err) => write!(f, "IO error: {err}"),
2727
Self::Handshake(err) => write!(f, "handshake error: {err}"),
2828
Self::Parse(err) => write!(f, "parse error: {err}"),

src/event.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub struct Connection(Arc<ConnectionInner>);
7272

7373
impl Connection {
7474
/// Returns the interface proxy for the underlying `ei_connection` object.
75+
#[must_use]
7576
pub fn connection(&self) -> &ei::Connection {
7677
&self.0.handshake_resp.connection
7778
}
@@ -88,6 +89,7 @@ impl Connection {
8889
// TODO(axka, 2025-07-08): specify in the function name that this is the last serial from
8990
// the server, and not the client, and create a function for the other way around.
9091
/// Returns the last serial number used in an event by the server.
92+
#[must_use]
9193
pub fn serial(&self) -> u32 {
9294
self.0.serial.load(Ordering::Relaxed)
9395
}
@@ -108,6 +110,7 @@ pub struct EiEventConverter {
108110
}
109111

110112
impl EiEventConverter {
113+
#[must_use]
111114
pub fn new(context: &ei::Context, handshake_resp: HandshakeResp) -> Self {
112115
Self {
113116
pending_seats: HashMap::new(),
@@ -126,6 +129,7 @@ impl EiEventConverter {
126129
}
127130
}
128131

132+
#[must_use]
129133
pub fn connection(&self) -> &Connection {
130134
&self.connection
131135
}
@@ -755,6 +759,7 @@ impl std::hash::Hash for Seat {
755759

756760
impl Seat {
757761
/// Returns the name of the seat, as provided by the server.
762+
#[must_use]
758763
pub fn name(&self) -> Option<&str> {
759764
self.0.name.as_deref()
760765
}
@@ -804,48 +809,57 @@ impl fmt::Debug for Device {
804809

805810
impl Device {
806811
/// Returns the high-level [`Seat`] wrapper for the device.
812+
#[must_use]
807813
pub fn seat(&self) -> &Seat {
808814
&self.0.seat
809815
}
810816

811817
/// Returns the interface proxy for the underlying `ei_device` object.
818+
#[must_use]
812819
pub fn device(&self) -> &ei::Device {
813820
&self.0.device
814821
}
815822

816823
/// Returns the name of the device, as provided by the server.
824+
#[must_use]
817825
pub fn name(&self) -> Option<&str> {
818826
self.0.name.as_deref()
819827
}
820828

821829
/// Returns the device's type.
830+
#[must_use]
822831
pub fn device_type(&self) -> ei::device::DeviceType {
823832
self.0.device_type.unwrap()
824833
}
825834

826835
/// Returns the device's dimensions, if applicable.
836+
#[must_use]
827837
pub fn dimensions(&self) -> Option<(u32, u32)> {
828838
self.0.dimensions
829839
}
830840

831841
/// Returns the device's regions.
842+
#[must_use]
832843
pub fn regions(&self) -> &[Region] {
833844
&self.0.regions
834845
}
835846

836847
/// Returns the device's keymap, if applicable.
848+
#[must_use]
837849
pub fn keymap(&self) -> Option<&Keymap> {
838850
self.0.keymap.as_ref()
839851
}
840852

841853
/// Returns an interface proxy if it is implemented for this device.
842854
///
843855
/// Interfaces of devices are implemented, such that there is one `ei_device` object and other objects (for example `ei_keyboard`) denoting capabilities.
856+
#[must_use]
844857
pub fn interface<T: ei::Interface>(&self) -> Option<T> {
845858
self.0.interfaces.get(T::NAME)?.clone().downcast()
846859
}
847860

848861
/// Returns `true` if this device has an interface matching the provided capability.
862+
#[must_use]
849863
pub fn has_capability(&self, capability: DeviceCapability) -> bool {
850864
self.0.interfaces.contains_key(capability.interface_name())
851865
}
@@ -1270,7 +1284,7 @@ impl Iterator for EiConvertEventIterator {
12701284
Err(err) if err.kind() == io::ErrorKind::UnexpectedEof => return None,
12711285
Err(err) => return Some(Err(err.into())),
12721286
Ok(_) => {}
1273-
};
1287+
}
12741288
while let Some(result) = self.context.pending_event() {
12751289
let request = match result {
12761290
PendingRequestResult::Request(request) => request,

0 commit comments

Comments
 (0)