pub struct DeviceString(/* private fields */);Expand description
String limited to 30 UTF-16 code units.
The strings stored in the MCP2221 flash memory (used during USB enumeration) are limited to at most 60 bytes of UTF-16-encoded text.
Create a DeviceString by calling str::parse on a string slice, or
DeviceString::try_from with an owned String.
let manufacturer: DeviceString = "Acme Widgets Company (UK) Ltd".parse()?;
let product = String::from("Internet of Widgets Hub v3.0");
let product: DeviceString = product.try_into()?;Note that some characters require two UTF-16 code units to express (4 bytes).
let serial = "4 bytes each: ๐ซ๐ซ๐ซ๐ซ๐ซ๐ซ๐ซ๐ซ๐ซ๐ซ";
let result: Result<DeviceString, _> = serial.parse();
assert!(result.is_err(), "More than 60 bytes when UTF-16 encoded.");ยงDatasheet
See table 3-7 and table 3-14 for details of how the device strings are read from and written to the MCP2221, including the length limitation. (Those tables are for the manufacturer string, but the following tables are identical except for the subcommand code.)
Trait Implementationsยง
Sourceยงimpl Clone for DeviceString
impl Clone for DeviceString
Sourceยงfn clone(&self) -> DeviceString
fn clone(&self) -> DeviceString
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSourceยงimpl Debug for DeviceString
impl Debug for DeviceString
Sourceยงimpl Display for DeviceString
impl Display for DeviceString
Sourceยงimpl FromStr for DeviceString
impl FromStr for DeviceString
Auto Trait Implementationsยง
impl Freeze for DeviceString
impl RefUnwindSafe for DeviceString
impl Send for DeviceString
impl Sync for DeviceString
impl Unpin for DeviceString
impl UnsafeUnpin for DeviceString
impl UnwindSafe for DeviceString
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more