1use crate::{error::Error, ser};
2
3pub const LIMITS: &str = "limits@openssh.com";
4pub const HARDLINK: &str = "hardlink@openssh.com";
5pub const FSYNC: &str = "fsync@openssh.com";
6pub const STATVFS: &str = "statvfs@openssh.com";
7
8macro_rules! impl_try_into_bytes {
9 ($struct:ty) => {
10 impl TryInto<Vec<u8>> for $struct {
11 type Error = Error;
12
13 fn try_into(self) -> Result<Vec<u8>, Self::Error> {
14 ser::to_bytes(&self).map(|b| b.to_vec())
15 }
16 }
17 };
18}
19
20#[derive(Debug, Serialize, Deserialize)]
21pub struct LimitsExtension {
22 pub max_packet_len: u64,
23 pub max_read_len: u64,
24 pub max_write_len: u64,
25 pub max_open_handles: u64,
26}
27
28#[derive(Debug, Serialize, Deserialize)]
29pub struct HardlinkExtension {
30 pub oldpath: String,
31 pub newpath: String,
32}
33
34impl_try_into_bytes!(HardlinkExtension);
35
36#[derive(Debug, Serialize, Deserialize)]
37pub struct FsyncExtension {
38 pub handle: String,
39}
40
41impl_try_into_bytes!(FsyncExtension);
42
43#[derive(Debug, Serialize, Deserialize)]
44pub struct StatvfsExtension {
45 pub path: String,
46}
47
48impl_try_into_bytes!(StatvfsExtension);
49
50#[derive(Debug, Serialize, Deserialize)]
51pub struct Statvfs {
52 pub block_size: u64,
54 pub fragment_size: u64,
56 pub blocks: u64,
60 pub blocks_free: u64,
62 pub blocks_avail: u64,
64 pub inodes: u64,
66 pub inodes_free: u64,
68 pub inodes_avail: u64,
70 pub fs_id: u64,
72 pub flags: u64,
74 pub name_max: u64,
76}