pub fn capability(&mut self, capability_type: u8, data: &[u8]) -> Result<()> {
        match self.num_caps_mark {
            Some(mark) => self.writer.buf[mark] += 1,
            None => return Err(UsbError::InvalidState),
        }

        let mut start = self.writer.position;
        let blen = data.len();

        if (start + blen + 3) > self.writer.buf.len() || (blen + 3) > 255 {
            return Err(UsbError::BufferOverflow);
        }

        self.writer.buf[start] = (blen + 3) as u8;
        self.writer.buf[start + 1] = descriptor_type::CAPABILITY;
        self.writer.buf[start + 2] = capability_type;

        start += 3;
        self.writer.buf[start..start + blen].copy_from_slice(data);
        self.writer.position = start + blen;

        Ok(())
    }
/// Writes capability descriptor to a BOS
///
/// # Arguments
///
/// * `capability_type` - Type of a capability
/// * `data` - Binary data of the descriptor
Writes capability descriptor to a BOS
Writes capability descriptor to a BOS
pub fn capability(&mut self, capability_type: u8, data: &[u8]) -> Result<()> {
        match self.num_caps_mark {
            Some(mark) => self.writer.buf[mark] += 1,
            None => return Err(UsbError::InvalidState),
        }
        let mut start = self.writer.position;
        let blen = data.len();
        if (start + blen + 3) > self.writer.buf.len() || (blen + 3) > 255 {
            return Err(UsbError::BufferOverflow);
        }
        self.writer.buf[start] = (blen + 3) as u8;
        self.writer.buf[start + 1] = descriptor_type::CAPABILITY;
        self.writer.buf[start + 2] = capability_type;
        start += 3;
        self.writer.buf[start..start + blen].copy_from_slice(data);
        self.writer.position = start + blen;
        Ok(())
    }
pub fn capability ( & mut self , capability_type : u8 , data : & [ u8 ] ) -> Result < ( ) > { match self . num_caps_mark { Some ( mark ) => self . writer . buf [ mark ] += 1 , None => return Err ( UsbError :: InvalidState ) , } let mut start = self . writer . position ; let blen = data . len ( ) ; if ( start + blen + 3 ) > self . writer . buf . len ( ) || ( blen + 3 ) > 255 { return Err ( UsbError :: BufferOverflow ) ; } self . writer . buf [ start ] = ( blen + 3 ) as u8 ; self . writer . buf [ start + 1 ] = descriptor_type :: CAPABILITY ; self . writer . buf [ start + 2 ] = capability_type ; start += 3 ; self . writer . buf [ start .. start + blen ] . copy_from_slice ( data ) ; self . writer . position = start + blen ; Ok ( ( ) ) }
Writes capability descriptor to a BOS
Writes capability descriptor to a BOS
&mut self
capability_type
u8
data
&[u8]
&mut self
capability_type
u8
data
&[u8]