-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Description
For example: impl<T> From<T> for FileAttr where T: std::fs::MetadataExt.
Currently, this is a pretty trivial mapping:
fn metadata_convert(m: Metadata) -> FileAttr {
FileAttr {
ino: m.ino(),
size: m.size(),
blocks: m.blocks(),
atime: from_unix_secs_signed(m.atime()),
mtime: from_unix_secs_signed(m.mtime()),
ctime: from_unix_secs_signed(m.ctime()),
kind: match m.file_type() {
ft if ft.is_file() => FileType::RegularFile,
ft if ft.is_dir() => FileType::Directory,
ft if ft.is_symlink() => FileType::Symlink,
ft if ft.is_block_device() => FileType::BlockDevice,
ft if ft.is_char_device() => FileType::CharDevice,
ft if ft.is_fifo() => FileType::NamedPipe,
ft if ft.is_socket() => FileType::Socket,
_ => return Err("Unknown file type".into()),
},
perm: (m.mode() & 0o7777) as u16,
nlink: m.nlink().try_into()?,
uid: m.uid(),
gid: m.gid(),
rdev: m.rdev().try_into()?,
blksize: m.blksize().try_into()?,
// MacOS only, which we don't yet support
crtime: UNIX_EPOCH,
flags: 0,
}
}However, we can't implement is using From/Into since we don't own the trait. Moving it upstream would be ideal. I'm happy to provide my implementation.
Metadata
Metadata
Assignees
Labels
No labels