/// Metadata about an inode, including unix-style permissions and
/// whether this inode is a directory.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, Deserialize)]#[doc(hidden)]pubstructInodeMetadata(pub u16);constDIR_BIT:u16=0x200;implInodeMetadata{pubconstDIR:Self= InodeMetadata(DIR_BIT);/// Create a new file metadata with the given Unix permissions,
/// and "is directory" bit.
pubfnnew(perm:usize, is_dir:bool)->Self{letmut m = InodeMetadata(0);
m.set_permissions((perm &0x1ff)asu16);if is_dir {
m.set_dir()}else{
m.unset_dir()}
m
}pubfnfrom_basename(b:&[u8])->Self{usebyteorder::ByteOrder;
InodeMetadata(byteorder::BigEndian::read_u16(b))}/// Permissions of this inode (as in Unix).
pubfnpermissions(&self)->u16{self.0&0x1ff}/// Set the permissions to the supplied parameters.
pubfnset_permissions(&mutself, perm:u16){self.0|= perm &0x1ff}/// Tell whether this `InodeMetadata` is a directory.
pubfnis_dir(&self)->bool{self.0&DIR_BIT!=0}/// Tell whether this `InodeMetadata` is a file.
pubfnis_file(&self)->bool{self.0&DIR_BIT==0}/// Set the metadata to be a directory.
pubfnset_dir(&mutself){self.0|=DIR_BIT}/// Set the metadata to be a file.
pubfnunset_dir(&mutself){self.0&=0o777}}