use crate::protocol::session::prelude::*;
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone)]
pub struct GetArgs {
pub filename: String,
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Default, Clone)]
pub struct Get2Args {
pub filename: String,
pub options: Vec<TaggedData<CommandParam>>,
}
impl From<GetArgs> for Get2Args {
fn from(v1: GetArgs) -> Self {
Self {
filename: v1.filename,
options: vec![],
}
}
}
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone)]
pub struct PutArgs {
pub filename: String,
}
#[derive(Serialize, Deserialize, PartialEq, Debug, Default, Clone)]
pub struct Put2Args {
pub filename: String,
pub options: Vec<TaggedData<CommandParam>>,
}
impl From<PutArgs> for Put2Args {
fn from(v1: PutArgs) -> Self {
Self {
filename: v1.filename,
options: vec![],
}
}
}
#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod test {
use crate::protocol::session::Command;
use crate::protocol::session::prelude::*;
use pretty_assertions::assert_eq;
#[test]
fn wire_marshalling_command_get() {
let cmd = Command::Get(super::GetArgs {
filename: "myfile".to_string(),
});
let wire = cmd.to_vec().unwrap();
let expected = b"\x00\x06myfile".to_vec();
assert_eq!(wire, expected);
}
#[test]
fn wire_marshalling_command_put() {
let cmd = Command::Put(super::PutArgs {
filename: "myfile2".to_string(),
});
let wire = cmd.to_vec().unwrap();
let expected = b"\x01\x07myfile2".to_vec();
assert_eq!(wire, expected);
}
}