pub fn write(&mut self, descriptor_type: u8, descriptor: &[u8]) -> Result<()> {
        let length = descriptor.len();

        if (self.position + 2 + length) > self.buf.len() || (length + 2) > 255 {
            return Err(UsbError::BufferOverflow);
        }

        self.buf[self.position] = (length + 2) as u8;
        self.buf[self.position + 1] = descriptor_type;

        let start = self.position + 2;

        self.buf[start..start + length].copy_from_slice(descriptor);

        self.position = start + length;

        Ok(())
    }
/// Writes an arbitrary (usually class-specific) descriptor.
Writes an arbitrary (usually class-specific) descriptor.
Writes an arbitrary ( usually class - specific ) descriptor .
pub fn write(&mut self, descriptor_type: u8, descriptor: &[u8]) -> Result<()> {
        let length = descriptor.len();
        if (self.position + 2 + length) > self.buf.len() || (length + 2) > 255 {
            return Err(UsbError::BufferOverflow);
        }
        self.buf[self.position] = (length + 2) as u8;
        self.buf[self.position + 1] = descriptor_type;
        let start = self.position + 2;
        self.buf[start..start + length].copy_from_slice(descriptor);
        self.position = start + length;
        Ok(())
    }
pub fn write ( & mut self , descriptor_type : u8 , descriptor : & [ u8 ] ) -> Result < ( ) > { let length = descriptor . len ( ) ; if ( self . position + 2 + length ) > self . buf . len ( ) || ( length + 2 ) > 255 { return Err ( UsbError :: BufferOverflow ) ; } self . buf [ self . position ] = ( length + 2 ) as u8 ; self . buf [ self . position + 1 ] = descriptor_type ; let start = self . position + 2 ; self . buf [ start .. start + length ] . copy_from_slice ( descriptor ) ; self . position = start + length ; Ok ( ( ) ) }
Writes an arbitrary (usually class-specific) descriptor.
Writes an arbitrary ( usually class - specific ) descriptor .
&mut self
descriptor_type
u8
descriptor
&[u8]
&mut self
descriptor_type
u8
descriptor
&[u8]