fn from_buf_fixed(buf: &[u8]) -> Option <Sense> {
    if buf.len() < 8 {
      return None;
    }

    let response_code = buf[0] & 0x7F;
    if !(0x70..=0x71_u8).contains(&response_code) {
      return None;
    }

    let mut rv: Sense = Sense {
      deferred: response_code == 0x71,
      filemark: buf[2] & 0x80 == 0x80,
      eom: buf[2] & 0x40 == 0x40,
      ili: buf[2] & 0x20 == 0x20,
      sense_key: SenseKey::from_u8(buf[2] & 0x0F),
      ..Default::default()
    };

    if buf[0] & 0x80 == 0x80 {
      rv.information[4..].copy_from_slice(&buf[3..7]);
    }

    let additional_sense_length = buf[7] as usize;

    if additional_sense_length < 4 {
      return Some(rv);
    }
    if let Some(slice) = buf.get(8..12) {
      rv.command_specific_information[4..].copy_from_slice(&slice);
    }

    if additional_sense_length < 5 {
      return Some(rv);
    }
    if let Some(val) = buf.get(12) {
      rv.additional_sense_code = *val; 
    }

    if additional_sense_length < 6 {
      return Some(rv);
    }
    if let Some(val) = buf.get(13) {
      rv.additional_sense_code_qualifier = *val; 
    }

    if additional_sense_length < 7 {
      return Some(rv);
    }
    if let Some(val) = buf.get(14) {
      rv.field_replaceable_unit_code = *val; 
    }

    if additional_sense_length < 10 {
      return Some(rv);
    }
    if let Some(slice) = buf.get(15..18) {
      if slice[0] & 0x80 == 0x80 {
        rv.sense_key_specific = SenseKeySpecific::from_buf(&rv.sense_key, &slice);
      }
    }

    let end = additional_sense_length + 8;
    if let Some(slice) = buf.get(18..end) {
      rv.additional_sense_bytes = slice.to_vec();
    }

    Some(rv)
  }
/// Fixed format described in SPC-3 Section 4.5.3
Fixed format described in SPC-3 Section 4.5.3
Fixed format described in SPC - 3 Section 4 . 5 . 3
fn from_buf_fixed(buf: &[u8]) -> Option <Sense> {
    if buf.len() < 8 {
      return None;
    }
    let response_code = buf[0] & 0x7F;
    if !(0x70..=0x71_u8).contains(&response_code) {
      return None;
    }
    let mut rv: Sense = Sense {
      deferred: response_code == 0x71,
      filemark: buf[2] & 0x80 == 0x80,
      eom: buf[2] & 0x40 == 0x40,
      ili: buf[2] & 0x20 == 0x20,
      sense_key: SenseKey::from_u8(buf[2] & 0x0F),
      ..Default::default()
    };
    if buf[0] & 0x80 == 0x80 {
      rv.information[4..].copy_from_slice(&buf[3..7]);
    }
    let additional_sense_length = buf[7] as usize;
    if additional_sense_length < 4 {
      return Some(rv);
    }
    if let Some(slice) = buf.get(8..12) {
      rv.command_specific_information[4..].copy_from_slice(&slice);
    }
    if additional_sense_length < 5 {
      return Some(rv);
    }
    if let Some(val) = buf.get(12) {
      rv.additional_sense_code = *val; 
    }
    if additional_sense_length < 6 {
      return Some(rv);
    }
    if let Some(val) = buf.get(13) {
      rv.additional_sense_code_qualifier = *val; 
    }
    if additional_sense_length < 7 {
      return Some(rv);
    }
    if let Some(val) = buf.get(14) {
      rv.field_replaceable_unit_code = *val; 
    }
    if additional_sense_length < 10 {
      return Some(rv);
    }
    if let Some(slice) = buf.get(15..18) {
      if slice[0] & 0x80 == 0x80 {
        rv.sense_key_specific = SenseKeySpecific::from_buf(&rv.sense_key, &slice);
      }
    }
    let end = additional_sense_length + 8;
    if let Some(slice) = buf.get(18..end) {
      rv.additional_sense_bytes = slice.to_vec();
    }
    Some(rv)
  }
fn from_buf_fixed ( buf : & [ u8 ] ) -> Option < Sense > { if buf . len ( ) < 8 { return None ; } let response_code = buf [ 0 ] & 0x7F ; if ! ( 0x70 ..= 0x71_u8 ) . contains ( & response_code ) { return None ; } let mut rv : Sense = Sense { deferred : response_code == 0x71 , filemark : buf [ 2 ] & 0x80 == 0x80 , eom : buf [ 2 ] & 0x40 == 0x40 , ili : buf [ 2 ] & 0x20 == 0x20 , sense_key : SenseKey :: from_u8 ( buf [ 2 ] & 0x0F ) , .. Default :: default ( ) } ; if buf [ 0 ] & 0x80 == 0x80 { rv . information [ 4 .. ] . copy_from_slice ( & buf [ 3 .. 7 ] ) ; } let additional_sense_length = buf [ 7 ] as usize ; if additional_sense_length < 4 { return Some ( rv ) ; } if let Some ( slice ) = buf . get ( 8 .. 12 ) { rv . command_specific_information [ 4 .. ] . copy_from_slice ( & slice ) ; } if additional_sense_length < 5 { return Some ( rv ) ; } if let Some ( val ) = buf . get ( 12 ) { rv . additional_sense_code = * val ; } if additional_sense_length < 6 { return Some ( rv ) ; } if let Some ( val ) = buf . get ( 13 ) { rv . additional_sense_code_qualifier = * val ; } if additional_sense_length < 7 { return Some ( rv ) ; } if let Some ( val ) = buf . get ( 14 ) { rv . field_replaceable_unit_code = * val ; } if additional_sense_length < 10 { return Some ( rv ) ; } if let Some ( slice ) = buf . get ( 15 .. 18 ) { if slice [ 0 ] & 0x80 == 0x80 { rv . sense_key_specific = SenseKeySpecific :: from_buf ( & rv . sense_key , & slice ) ; } } let end = additional_sense_length + 8 ; if let Some ( slice ) = buf . get ( 18 .. end ) { rv . additional_sense_bytes = slice . to_vec ( ) ; } Some ( rv ) }
Fixed format described in SPC-3 Section 4.5.3
Fixed format described in SPC - 3 Section 4 . 5 . 3
buf
&[u8]