pub trait FromId<T> {
// Required method
fn from_id(id: T) -> Option<&'static Self>;
}
Expand description
A convenience trait for retrieving a top-level entity (like a Vendor
) from the USB
database by its unique ID.
use usb_ids::{FromId, Vendor};
let vendor = Vendor::from_id(0x1d6b).unwrap();
assert_eq!(vendor.name(), "Linux Foundation");
Required Methods§
sourcefn from_id(id: T) -> Option<&'static Self>
fn from_id(id: T) -> Option<&'static Self>
Returns the entity corresponding to id
, or None
if none exists.
Object Safety§
This trait is not object safe.