Skip to content

Commit 54e10b7

Browse files
00xcroypat
authored andcommitted
derive Debug for multiple types
Add free derives of Debug for multiple types, and add the deny(missing_debug_implementations) attribute to prevent similar issues in the future. Signed-off-by: Carlos López <[email protected]>
1 parent 8250039 commit 54e10b7

File tree

8 files changed

+12
-0
lines changed

8 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Changed
44

55
- Added `remote_endpoint` feature to generated docs.rs documentation.
6+
- Derived the `Debug` trait for multiple types
67

78
# v0.3.0
89

src/endpoint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub(crate) struct FnMsg<S> {
4848
}
4949

5050
// Used by the `EventManager` to keep state associated with the channel.
51+
#[derive(Debug)]
5152
pub(crate) struct EventManagerChannel<S> {
5253
// A clone of this is given to every `RemoteEndpoint` and used to signal the presence of
5354
// an new message on the channel.
@@ -84,6 +85,7 @@ impl<S> EventManagerChannel<S> {
8485
}
8586

8687
/// Enables interactions with an `EventManager` that runs on a different thread of execution.
88+
#[derive(Debug)]
8789
pub struct RemoteEndpoint<S> {
8890
// A sender associated with `EventManager` channel requests are sent over.
8991
msg_sender: Sender<FnMsg<S>>,

src/epoll.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use vmm_sys_util::epoll::{ControlOperation, Epoll, EpollEvent};
99
use super::{Errno, Error, EventOps, Result, SubscriberId};
1010

1111
// Internal use structure that keeps the epoll related state of an EventManager.
12+
#[derive(Debug)]
1213
pub(crate) struct EpollWrapper {
1314
// The epoll wrapper.
1415
pub(crate) epoll: Epoll,

src/events.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ impl Events {
202202
/// removal of events in the watchlist.
203203
// Right now this is a concrete object, but going further it can be turned into a trait and
204204
// passed around as a trait object.
205+
#[derive(Debug)]
205206
pub struct EventOps<'a> {
206207
// Mutable reference to the EpollContext of an EventManager.
207208
epoll_wrapper: &'a mut EpollWrapper,

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
33

44
//! Event Manager traits and implementation.
5+
#![deny(missing_debug_implementations)]
56
#![deny(missing_docs)]
67
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
78

src/manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use super::Errno;
1616
use super::{Error, EventOps, Events, MutEventSubscriber, Result, SubscriberId, SubscriberOps};
1717

1818
/// Allows event subscribers to be registered, connected to the event loop, and later removed.
19+
#[derive(Debug)]
1920
pub struct EventManager<T> {
2021
subscribers: Subscribers<T>,
2122
epoll_context: EpollWrapper,

src/subscribers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::collections::HashMap;
77
// Internal structure used to keep the set of subscribers registered with an EventManger.
88
// This structure is a thin wrapper over a `HashMap` in which the keys are uniquely
99
// generated when calling `add`.
10+
#[derive(Debug)]
1011
pub(crate) struct Subscribers<T> {
1112
// The key is the unique id of the subscriber and the entry is the `Subscriber`.
1213
subscribers: HashMap<SubscriberId, T>,

src/utilities/subscribers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use crate::{EventOps, EventSubscriber, Events, MutEventSubscriber};
3636
/// A `Counter` is a helper structure for creating subscribers that increment a value
3737
/// each time an event is triggered.
3838
/// The `Counter` allows users to assert and de-assert an event, and to query the counter value.
39+
#[derive(Debug)]
3940
pub struct Counter {
4041
event_fd: EventFd,
4142
counter: u64,
@@ -81,6 +82,7 @@ impl Default for Counter {
8182

8283
// A dummy subscriber that increments a counter whenever it processes
8384
// a new request.
85+
#[derive(Debug)]
8486
pub struct CounterSubscriber(Counter);
8587

8688
impl std::ops::Deref for CounterSubscriber {
@@ -137,6 +139,7 @@ impl MutEventSubscriber for CounterSubscriber {
137139
// registering & processing events.
138140
// Using 3 counters each having associated event data to showcase the implementation of
139141
// EventSubscriber trait with this scenario.
142+
#[derive(Debug)]
140143
pub struct CounterSubscriberWithData {
141144
counter_1: Counter,
142145
counter_2: Counter,
@@ -275,6 +278,7 @@ impl MutEventSubscriber for CounterSubscriberWithData {
275278
}
276279
}
277280

281+
#[derive(Debug)]
278282
pub struct CounterInnerMutSubscriber {
279283
event_fd: EventFd,
280284
counter: AtomicU64,

0 commit comments

Comments
 (0)