a1ien / rusb

A safe Rust wrapper for libusb.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to create a language

Animeshz opened this issue · comments

Is there no public API to make an instance of Language? I couldn't find a way to make Language either from a raw hex or from using PrimaryLanguage and SecondaryLanguage.

rusb/src/language.rs

Lines 11 to 39 in f611e84

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Language {
raw: u16,
}
impl Language {
/// Returns the language's 16-bit `LANGID`.
///
/// Each language's `LANGID` is defined by the USB forum
/// (http://www.usb.org/developers/docs/USB_LANGIDs.pdf).
pub fn lang_id(self) -> u16 {
self.raw
}
/// Returns the primary language.
pub fn primary_language(self) -> PrimaryLanguage {
PrimaryLanguage::from_raw(self.raw)
}
/// Returns the sub language.
pub fn sub_language(self) -> SubLanguage {
SubLanguage::from_raw(self.primary_language(), self.raw)
}
}
#[doc(hidden)]
pub(crate) fn from_lang_id(raw: u16) -> Language {
Language { raw }
}

For what purpose you need make an instance of Language?

@a1ien Reading a string descriptor from particular usb device, DeviceHandle::read_string_descriptor particularly.

You can get Language from DeviceHandle::read_languages.

Oh thanks 👀