Skip to content

Commit 98ccb7f

Browse files
authored
Merge pull request #121 from eZioPan/StringIndex-and-IAD
let `.iad()` accept a `Option<StringIndex>`
2 parents f72934f + 40d4460 commit 98ccb7f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
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))
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/descriptor.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,22 @@ 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,
184185
interface_count: u8,
185186
function_class: u8,
186187
function_sub_class: u8,
187188
function_protocol: u8,
189+
function_string: Option<StringIndex>,
188190
) -> Result<()> {
189191
if !self.write_iads {
190192
return Ok(());
191193
}
192194

195+
let str_index = function_string.map_or(0, Into::into);
196+
193197
self.write(
194198
descriptor_type::IAD,
195199
&[
@@ -198,7 +202,7 @@ impl DescriptorWriter<'_> {
198202
function_class,
199203
function_sub_class,
200204
function_protocol,
201-
0,
205+
str_index,
202206
],
203207
)?;
204208

0 commit comments

Comments
 (0)