Skip to content

Commit

Permalink
derive Debug for multiple types
Browse files Browse the repository at this point in the history
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 <carlos.lopez@suse.com>
  • Loading branch information
00xc authored and roypat committed Nov 15, 2023
1 parent 8250039 commit 54e10b7
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Changed

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

# v0.3.0

Expand Down
2 changes: 2 additions & 0 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub(crate) struct FnMsg<S> {
}

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

/// Enables interactions with an `EventManager` that runs on a different thread of execution.
#[derive(Debug)]
pub struct RemoteEndpoint<S> {
// A sender associated with `EventManager` channel requests are sent over.
msg_sender: Sender<FnMsg<S>>,
Expand Down
1 change: 1 addition & 0 deletions src/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use vmm_sys_util::epoll::{ControlOperation, Epoll, EpollEvent};
use super::{Errno, Error, EventOps, Result, SubscriberId};

// Internal use structure that keeps the epoll related state of an EventManager.
#[derive(Debug)]
pub(crate) struct EpollWrapper {
// The epoll wrapper.
pub(crate) epoll: Epoll,
Expand Down
1 change: 1 addition & 0 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ impl Events {
/// removal of events in the watchlist.
// Right now this is a concrete object, but going further it can be turned into a trait and
// passed around as a trait object.
#[derive(Debug)]
pub struct EventOps<'a> {
// Mutable reference to the EpollContext of an EventManager.
epoll_wrapper: &'a mut EpollWrapper,
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

//! Event Manager traits and implementation.
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

Expand Down
1 change: 1 addition & 0 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use super::Errno;
use super::{Error, EventOps, Events, MutEventSubscriber, Result, SubscriberId, SubscriberOps};

/// Allows event subscribers to be registered, connected to the event loop, and later removed.
#[derive(Debug)]
pub struct EventManager<T> {
subscribers: Subscribers<T>,
epoll_context: EpollWrapper,
Expand Down
1 change: 1 addition & 0 deletions src/subscribers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::collections::HashMap;
// Internal structure used to keep the set of subscribers registered with an EventManger.
// This structure is a thin wrapper over a `HashMap` in which the keys are uniquely
// generated when calling `add`.
#[derive(Debug)]
pub(crate) struct Subscribers<T> {
// The key is the unique id of the subscriber and the entry is the `Subscriber`.
subscribers: HashMap<SubscriberId, T>,
Expand Down
4 changes: 4 additions & 0 deletions src/utilities/subscribers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use crate::{EventOps, EventSubscriber, Events, MutEventSubscriber};
/// A `Counter` is a helper structure for creating subscribers that increment a value
/// each time an event is triggered.
/// The `Counter` allows users to assert and de-assert an event, and to query the counter value.
#[derive(Debug)]
pub struct Counter {
event_fd: EventFd,
counter: u64,
Expand Down Expand Up @@ -81,6 +82,7 @@ impl Default for Counter {

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

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

#[derive(Debug)]
pub struct CounterInnerMutSubscriber {
event_fd: EventFd,
counter: AtomicU64,
Expand Down

0 comments on commit 54e10b7

Please sign in to comment.