impl Debug for Device, Interface, and Endpoint
This commit is contained in:
parent
6895347f4b
commit
535fc7d458
1 changed files with 28 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ use crate::{
|
|||
};
|
||||
use log::{error, warn};
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
future::{poll_fn, Future},
|
||||
marker::PhantomData,
|
||||
num::NonZeroU8,
|
||||
|
|
@ -346,6 +347,12 @@ impl Device {
|
|||
}
|
||||
}
|
||||
|
||||
impl Debug for Device {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Device").finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// An opened interface of a USB device.
|
||||
///
|
||||
/// Obtain an `Interface` with the [`Device::claim_interface`] method.
|
||||
|
|
@ -521,6 +528,14 @@ impl Interface {
|
|||
}
|
||||
}
|
||||
|
||||
impl Debug for Interface {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Interface")
|
||||
.field("number", &self.backend.interface_number)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
/// Exclusive access to an endpoint of a USB device.
|
||||
///
|
||||
/// Obtain an `Endpoint` with the [`Interface::endpoint`] method.
|
||||
|
|
@ -693,6 +708,19 @@ impl<EpType: BulkOrInterrupt, Dir: EndpointDirection> Endpoint<EpType, Dir> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<EpType: BulkOrInterrupt, Dir: EndpointDirection> Debug for Endpoint<EpType, Dir> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("Endpoint")
|
||||
.field(
|
||||
"address",
|
||||
&format_args!("0x{:02x}", self.endpoint_address()),
|
||||
)
|
||||
.field("type", &EpType::TYPE)
|
||||
.field("direction", &Dir::DIR)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assert_send_sync() {
|
||||
use crate::transfer::{Bulk, In, Interrupt, Out};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue