@@ -175,7 +175,7 @@ impl DescriptorWriter<'_> {
175175 pub fn interface ( & mut self , number : InterfaceNumber ,
176176 interface_class : u8 , interface_sub_class : u8 , interface_protocol : u8 ) -> Result < ( ) >
177177 {
178- self . interface_alternate_setting (
178+ self . interface_alt (
179179 number,
180180 device:: DEFAULT_ALTERNATE_SETTING ,
181181 interface_class,
@@ -192,14 +192,14 @@ impl DescriptorWriter<'_> {
192192 ///
193193 /// * `number` - Interface number previously allocated with
194194 /// [`UsbBusAllocator::interface`](crate::bus::UsbBusAllocator::interface).
195- /// * `alternate_setting` - number of the alternate setting
195+ /// * `alternate_setting` - Number of the alternate setting
196196 /// * `interface_class` - Class code assigned by USB.org. Use `0xff` for vendor-specific devices
197197 /// that do not conform to any class.
198198 /// * `interface_sub_class` - Sub-class code. Depends on class.
199199 /// * `interface_protocol` - Protocol code. Depends on class and sub-class.
200200 /// * `interface_string` - Index of string descriptor describing this interface
201201
202- pub fn interface_alternate_setting (
202+ pub fn interface_alt (
203203 & mut self ,
204204 number : InterfaceNumber ,
205205 alternate_setting : u8 ,
@@ -208,29 +208,27 @@ impl DescriptorWriter<'_> {
208208 interface_protocol : u8 ,
209209 interface_string : Option < StringIndex > ,
210210 ) -> Result < ( ) > {
211- let ifndx = match interface_string {
212- Some ( si) => si. into ( ) ,
213- None => 0 ,
214- } ;
215211 if alternate_setting == device:: DEFAULT_ALTERNATE_SETTING {
216212 match self . num_interfaces_mark {
217213 Some ( mark) => self . buf [ mark] += 1 ,
218214 None => return Err ( UsbError :: InvalidState ) ,
219215 } ;
220216 }
221217
218+ let str_index = interface_string. map_or ( 0 , Into :: into) ;
219+
222220 self . num_endpoints_mark = Some ( self . position + 4 ) ;
223221
224222 self . write (
225223 descriptor_type:: INTERFACE ,
226224 & [
227225 number. into ( ) , // bInterfaceNumber
228- alternate_setting, // bAlternateSetting (how to even handle these...)
226+ alternate_setting, // bAlternateSetting
229227 0 , // bNumEndpoints
230228 interface_class, // bInterfaceClass
231229 interface_sub_class, // bInterfaceSubClass
232230 interface_protocol, // bInterfaceProtocol
233- ifndx , // iInterface
231+ str_index , // iInterface
234232 ] ,
235233 ) ?;
236234
0 commit comments