Skip to main content

BaseClass

Enum BaseClass 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum BaseClass {
Show 25 variants UseInterfaceDescriptor = 0, Audio = 1, CdcCommunications = 2, Hid = 3, Physical = 5, Image = 6, Printer = 7, MassStorage = 8, Hub = 9, CdcData = 10, SmartCard = 11, ContentSecurity = 13, Video = 14, PersonalHealthcare = 15, AudioVideo = 16, Billboard = 17, UsbTypeCBridge = 18, Bdp = 19, Mctp = 20, I3cDevice = 60, Diagnostic = 220, WirelessController = 224, Miscellaneous = 239, ApplicationSpecificInterface = 254, VendorSpecificClass = 255,
}
Expand description

USB class code defines ref

Technically this is the ‘Base Class’ - the ‘Class Code’ is the full triplet of (Base Class, Sub Class, Protocol).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

UseInterfaceDescriptor = 0

Device class is unspecified, interface descriptors are used to determine needed drivers

§

Audio = 1

Speaker, microphone, sound card, MIDI

§

CdcCommunications = 2

The modern serial interface; appears as a UART/RS232 port on most systems

§

Hid = 3

Human Interface Device; game controllers, keyboards, mice etc. Also commonly used as a device data interface rather then creating something from scratch

§

Physical = 5

Force feedback joystick

§

Image = 6

Still imaging device; scanners, cameras

§

Printer = 7

Laser printer, inkjet printer, CNC machine

§

MassStorage = 8

Mass storage devices (MSD): USB flash drive, memory card reader, digital audio player, digital camera, external drive

§

Hub = 9

High speed USB hub

§

CdcData = 10

Used together with class 02h (Communications and CDC Control) above

§

SmartCard = 11

USB smart card reader

§

ContentSecurity = 13

Fingerprint reader

§

Video = 14

Webcam

§

PersonalHealthcare = 15

Pulse monitor (watch)

§

AudioVideo = 16

Webcam, TV

§

Billboard = 17

Describes USB-C alternate modes supported by device

§

UsbTypeCBridge = 18

An interface to expose and configure the USB Type-C capabilities of Connectors on USB Hubs or Alternate Mode Adapters

§

Bdp = 19

This base class is defined for devices that conform to the “VESA USB BDP Device Specification” found at the VESA website. This specification defines the usable set of SubClass and Protocol values. Values outside of this defined spec are reserved. These class codes can only be used in Interface Descriptors.

§

Mctp = 20

This base class is defined for devices that conform to the “MCTP over USB” found at the DMTF website as DSP0283. This specification defines the usable set of SubClass and Protocol values. Values outside of this defined spec are reserved. These class codes can only be used in Interface Descriptors.

§

I3cDevice = 60

An interface to expose and configure I3C function within a USB device to allow interaction between host software and the I3C device, to drive transaction on the I3C bus to/from target devices

§

Diagnostic = 220

Trace and debugging equipment

§

WirelessController = 224

Wireless controllers: Bluetooth adaptors, Microsoft RNDIS

§

Miscellaneous = 239

This base class is defined for miscellaneous device definitions. Some matching SubClass and Protocols are defined on the USB-IF website

§

ApplicationSpecificInterface = 254

This base class is defined for devices that conform to several class specifications found on the USB-IF website

§

VendorSpecificClass = 255

This base class is defined for vendors to use as they please

Implementations§

Source§

impl BaseClass

Source

pub fn usage(&self) -> DescriptorUsage

How the BaseClass is used DescriptorUsage

Source

pub fn to_lsusb_string(&self) -> String

lsusb is explicit for some in styling of tree


assert_eq!(BaseClass::Hid.to_lsusb_string(), "Human Interface Device");
Source

pub fn to_title_case(&self) -> String

Converts Pascal case enum to space separated on capitals


assert_eq!(BaseClass::UseInterfaceDescriptor.to_title_case(), "Use Interface Descriptor");
assert_eq!(BaseClass::CdcData.to_title_case(), "CDC Data");

Trait Implementations§

Source§

impl Clone for BaseClass

Source§

fn clone(&self) -> BaseClass

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BaseClass

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BaseClass

Source§

fn default() -> BaseClass

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BaseClass

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for BaseClass

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<BaseClass> for ClassCode

Source§

fn from(class: BaseClass) -> Self

Converts to this type from the input type.
Source§

impl From<BaseClass> for DescriptorUsage

Source§

fn from(c: BaseClass) -> DescriptorUsage

Converts to this type from the input type.
Source§

impl From<BaseClass> for u8

Source§

fn from(val: BaseClass) -> Self

Converts to this type from the input type.
Source§

impl From<ClassCode> for BaseClass

Source§

fn from(c: ClassCode) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for BaseClass

Source§

fn from(b: u8) -> BaseClass

Converts to this type from the input type.
Source§

impl Hash for BaseClass

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BaseClass

Source§

fn eq(&self, other: &BaseClass) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for BaseClass

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ValueEnum for BaseClass

Source§

fn value_variants<'a>() -> &'a [Self]

All possible argument values, in display order.
Source§

fn to_possible_value<'a>(&self) -> Option<PossibleValue>

The canonical argument value. Read more
Source§

fn from_str(input: &str, ignore_case: bool) -> Result<Self, String>

Parse an argument into Self.
Source§

impl Copy for BaseClass

Source§

impl Eq for BaseClass

Source§

impl StructuralPartialEq for BaseClass

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,