#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct EntryType {
byte: u8,
}
impl EntryType {
pub fn new(byte: u8) -> EntryType {
EntryType { byte: byte }
}
pub fn file() -> EntryType {
EntryType::new(b'0')
}
pub fn hard_link() -> EntryType {
EntryType::new(b'1')
}
pub fn symlink() -> EntryType {
EntryType::new(b'2')
}
pub fn character_special() -> EntryType {
EntryType::new(b'3')
}
pub fn block_special() -> EntryType {
EntryType::new(b'4')
}
pub fn dir() -> EntryType {
EntryType::new(b'5')
}
pub fn fifo() -> EntryType {
EntryType::new(b'6')
}
pub fn contiguous() -> EntryType {
EntryType::new(b'7')
}
pub fn is_file(&self) -> bool {
self.byte == 0 || self.byte == b'0'
}
pub fn is_hard_link(&self) -> bool {
self.byte == b'1'
}
pub fn is_symlink(&self) -> bool {
self.byte == b'2'
}
pub fn is_character_special(&self) -> bool {
self.byte == b'3'
}
pub fn is_block_special(&self) -> bool {
self.byte == b'4'
}
pub fn is_dir(&self) -> bool {
self.byte == b'5'
}
pub fn is_fifo(&self) -> bool {
self.byte == b'6'
}
pub fn is_contiguous(&self) -> bool {
self.byte == b'7'
}
pub fn as_byte(&self) -> u8 {
self.byte
}
}