Encode trailer to a fixed-size stack array.
(&self)
| 106 | |
| 107 | /// Encode trailer to a fixed-size stack array. |
| 108 | pub fn to_bytes(&self) -> [u8; BLOCK_TRAILER_LENGTH] { |
| 109 | let crc_bytes = (self.crc32c as i32).to_le_bytes(); |
| 110 | [ |
| 111 | self.compression_type as u8, |
| 112 | crc_bytes[0], |
| 113 | crc_bytes[1], |
| 114 | crc_bytes[2], |
| 115 | crc_bytes[3], |
| 116 | ] |
| 117 | } |
| 118 | |
| 119 | pub fn read_from(data: &[u8]) -> io::Result<Self> { |
| 120 | if data.len() < BLOCK_TRAILER_LENGTH { |
no outgoing calls
no test coverage detected