use crate::{error::Error, ser};
pub const LIMITS: &str = "limits@openssh.com";
pub const HARDLINK: &str = "hardlink@openssh.com";
pub const FSYNC: &str = "fsync@openssh.com";
pub const STATVFS: &str = "statvfs@openssh.com";
macro_rules! impl_try_into_bytes {
($struct:ty) => {
impl TryInto<Vec<u8>> for $struct {
type Error = Error;
fn try_into(self) -> Result<Vec<u8>, Self::Error> {
ser::to_bytes(&self).map(|b| b.to_vec())
}
}
};
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LimitsExtension {
pub max_packet_len: u64,
pub max_read_len: u64,
pub max_write_len: u64,
pub max_open_handles: u64,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct HardlinkExtension {
pub oldpath: String,
pub newpath: String,
}
impl_try_into_bytes!(HardlinkExtension);
#[derive(Debug, Serialize, Deserialize)]
pub struct FsyncExtension {
pub handle: String,
}
impl_try_into_bytes!(FsyncExtension);
#[derive(Debug, Serialize, Deserialize)]
pub struct StatvfsExtension {
pub path: String,
}
impl_try_into_bytes!(StatvfsExtension);
#[derive(Debug, Serialize, Deserialize)]
pub struct Statvfs {
pub block_size: u64,
pub fragment_size: u64,
pub blocks: u64,
pub blocks_free: u64,
pub blocks_avail: u64,
pub inodes: u64,
pub inodes_free: u64,
pub inodes_avail: u64,
pub fs_id: u64,
pub flags: u64,
pub name_max: u64,
}