Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derive Debug for all structs #17

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cdc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::*;

/// A handler of a CDC ACM(Abstract Control Model)
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct UsbCdcAcmHandler {
pub tx_buffer: Vec<u8>,
}
Expand Down
8 changes: 5 additions & 3 deletions src/device.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::fmt::Debug;

use super::*;
use rusb::Version as rusbVersion;

#[derive(Clone, Default)]
#[derive(Clone, Debug, Default)]
pub struct Version {
pub major: u8,
pub minor: u8,
Expand All @@ -25,7 +27,7 @@ impl Into<rusbVersion> for Version {
}

/// Represent a USB device
#[derive(Clone, Default)]
#[derive(Clone, Debug, Default)]
pub struct UsbDevice {
pub path: String,
pub bus_id: String,
Expand Down Expand Up @@ -437,7 +439,7 @@ impl UsbDevice {
}

/// A handler for URB targeting the device
pub trait UsbDeviceHandler {
pub trait UsbDeviceHandler: Debug {
/// Handle a URB(USB Request Block) targeting at this device
///
/// When the lower 4 bits of bmRequestType is zero and the URB is not handled by the library, this function is called
Expand Down
6 changes: 3 additions & 3 deletions src/hid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use super::*;
// HID 1.11: https://www.usb.org/sites/default/files/documents/hid1_11.pdf
// HID Usage Tables 1.12: https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf

#[derive(Clone)]
#[derive(Clone, Debug)]
enum UsbHidKeyboardHandlerState {
Idle,
KeyDown,
}

/// A handler of a HID keyboard
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct UsbHidKeyboardHandler {
pub report_descriptor: Vec<u8>,
pub pending_key_events: VecDeque<UsbHidKeyboardReport>,
Expand All @@ -22,7 +22,7 @@ pub struct UsbHidKeyboardHandler {
/// A report of a HID keyboard
///
/// For definition of key codes, see [HID Usage Tables](https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf)
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct UsbHidKeyboardReport {
/// Key modifier
pub modifier: u8,
Expand Down
4 changes: 2 additions & 2 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use super::*;

/// A handler to pass requests to a USB device of the host
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct UsbHostInterfaceHandler {
handle: Arc<Mutex<DeviceHandle<GlobalContext>>>,
}
Expand Down Expand Up @@ -92,7 +92,7 @@ impl UsbInterfaceHandler for UsbHostInterfaceHandler {
}

/// A handler to pass requests to a USB device of the host
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct UsbHostDeviceHandler {
handle: Arc<Mutex<DeviceHandle<GlobalContext>>>,
}
Expand Down
6 changes: 4 additions & 2 deletions src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::fmt::Debug;

use super::*;

/// Represent a USB interface
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct UsbInterface {
pub interface_class: u8,
pub interface_subclass: u8,
Expand All @@ -13,7 +15,7 @@ pub struct UsbInterface {
}

/// A handler of a custom usb interface
pub trait UsbInterfaceHandler {
pub trait UsbInterfaceHandler: Debug {
/// Return the class specific descriptor which is inserted between interface descriptor and endpoint descriptor
fn get_class_specific_descriptor(&self) -> Vec<u8>;

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub use setup::*;
pub use util::*;

/// Main struct of a USB/IP server
#[derive(Debug, Default)]
pub struct UsbIpServer {
devices: Vec<UsbDevice>,
}
Expand Down