Decode metadata from bytes.
(bytes: &[u8])
| 167 | |
| 168 | /// Decode metadata from bytes. |
| 169 | pub fn from_bytes(bytes: &[u8]) -> Option<Self> { |
| 170 | if bytes.len() < 3 { |
| 171 | return None; |
| 172 | } |
| 173 | let permissions = u16::from(bytes[0]) | (u16::from(bytes[1]) << 8); |
| 174 | let (is_dir, is_symlink) = match bytes[2] { |
| 175 | 0x01 => (true, false), |
| 176 | 0x02 => (false, true), |
| 177 | _ => (false, false), |
| 178 | }; |
| 179 | Some(Self { |
| 180 | permissions, |
| 181 | is_dir, |
| 182 | is_symlink, |
| 183 | }) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | // WORKING COPY READ TRAIT |