Skip to content

Commit e092c0a

Browse files
committed
add doc and changelog, reverse change for StringIndex
1 parent 8d132e1 commit e092c0a

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313
* Added support for alternate settings on interfaces ([#114](https://github.com/rust-embedded-community/usb-device/pull/114)).
1414
* Added support for architectures without atomics ([#115](https://github.com/rust-embedded-community/usb-device/pull/115)).
1515

16+
### Breaking
17+
* `DescriptorWriter::iad()` now requires a `Option<StringIndex>` to optionally specify a string for describing the function (#[121](https://github.com/rust-embedded-community/usb-device/pull/121/files))
18+
1619
### Changed
1720
* `EndpointType` enum now has fields for isochronous synchronization and usage ([#60](https://github.com/rust-embedded-community/usb-device/pull/60)).
1821

src/bus.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ impl From<InterfaceNumber> for u8 {
334334
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
335335
pub struct StringIndex(u8);
336336

337-
impl From<u8> for StringIndex {
338-
fn from(i: u8) -> StringIndex {
339-
StringIndex(i)
337+
impl StringIndex {
338+
pub(crate) fn new(index: u8) -> StringIndex {
339+
StringIndex(index)
340340
}
341341
}
342342

src/descriptor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ impl DescriptorWriter<'_> {
178178
/// that do not conform to any class.
179179
/// * `function_sub_class` - Sub-class code. Depends on class.
180180
/// * `function_protocol` - Protocol code. Depends on class and sub-class.
181+
/// * `function_string` - Index of string descriptor describing this function
181182
pub fn iad(
182183
&mut self,
183184
first_interface: InterfaceNumber,

src/device.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::bus::{InterfaceNumber, PollResult, UsbBus, UsbBusAllocator};
1+
use crate::bus::{InterfaceNumber, PollResult, StringIndex, UsbBus, UsbBusAllocator};
22
use crate::class::{ControlIn, ControlOut, UsbClass};
33
use crate::control;
44
use crate::control_pipe::ControlPipe;
@@ -558,12 +558,12 @@ impl<B: UsbBus> UsbDevice<'_, B> {
558558
2 => config.product,
559559
3 => config.serial_number,
560560
_ => {
561-
let str_index = index.into();
561+
let index = StringIndex::new(index);
562562
let lang_id = req.index;
563563

564564
classes
565565
.iter()
566-
.filter_map(|cls| cls.get_string(str_index, lang_id))
566+
.filter_map(|cls| cls.get_string(index, lang_id))
567567
.next()
568568
}
569569
};

0 commit comments

Comments
 (0)