sftp_protocol/common/
metadata.rs

1use camino::Utf8Path;
2use camino::Utf8PathBuf;
3use time::OffsetDateTime;
4
5#[derive(Clone, Debug)]
6pub struct Metadata {
7	pub path: Utf8PathBuf,
8	pub size: u64,
9	pub is_dir: bool,
10	pub is_file: bool,
11	pub link_target: Option<Utf8PathBuf>,
12	pub uid: u32,
13	pub gid: u32,
14	pub permissions: u32,
15	pub atime: OffsetDateTime,
16	pub mtime: OffsetDateTime
17}
18
19impl Metadata {
20	#[allow(clippy::too_many_arguments)]
21	pub fn new(path: &Utf8Path, size: u64, is_dir: bool, is_file: bool, link_target: Option<&Utf8Path>, uid: u32, gid: u32, permissions: u32, atime: impl Into<OffsetDateTime>, mtime: impl Into<OffsetDateTime>) -> Self {
22		Self{
23			path: path.to_path_buf(),
24			size,
25			is_dir,
26			is_file,
27			link_target: link_target.map(Utf8PathBuf::from),
28			uid,
29			gid,
30			permissions,
31			atime: atime.into(),
32			mtime: mtime.into()
33		}
34	}
35}
36