diff --git a/src/types/client/fcp_types.rs b/src/types/client/fcp_types.rs index 7523cce..0013519 100644 --- a/src/types/client/fcp_types.rs +++ b/src/types/client/fcp_types.rs @@ -106,7 +106,8 @@ pub struct ClientPut { dont_compress: Option, codecs: Option>, client_token: Option, - persistence: Option>, + persistence: Option, + target_filename: Option>, early_encode: Option, upload_ffrom: Option, target_uri: Option, // cloning uri if does not exists @@ -192,12 +193,6 @@ impl FcpRequest for ClientPut { } }*/ -pub fn default_unwrap(fcp_type: Option<&T>) -> String { - match fcp_type { - Some(val) => val.parse(), - None => String::from(""), - } -} impl FcpRequest for String { fn parse(&self) -> String { self.to_string() @@ -214,40 +209,6 @@ impl FcpRequest for bool { } } -impl FcpRequest for VerbosityPut { - fn parse(&self) -> String { - match self { - VerbosityPut::SimpleProgress => 0.to_string(), - VerbosityPut::ExpectedHashes => 3.to_string(), - VerbosityPut::PutFetchable => 8.to_string(), - VerbosityPut::StartedCompressionANDFinishedCompression => 9.to_string(), - } - } -} - -#[test] -fn is_berbosity_put_parsing() { - assert_eq!(default_unwrap::(None), "".to_string()); - assert_eq!( - default_unwrap::(Some(&VerbosityPut::SimpleProgress)), - "0".to_string() - ); - assert_eq!( - default_unwrap::(Some(&VerbosityPut::ExpectedHashes)), - "3".to_string() - ); - assert_eq!( - default_unwrap::(Some(&VerbosityPut::PutFetchable)), - "8".to_string() - ); - assert_eq!( - default_unwrap::(Some( - &VerbosityPut::StartedCompressionANDFinishedCompression - )), - "9".to_string() - ); -} - pub struct ClientGet { message_name: String, ignore_ds: Option, diff --git a/src/types/client/types.rs b/src/types/client/types.rs index cf95016..f904f92 100644 --- a/src/types/client/types.rs +++ b/src/types/client/types.rs @@ -24,6 +24,41 @@ pub enum VerbosityPut { PutFetchable, StartedCompressionANDFinishedCompression, } + +impl FcpRequest for VerbosityPut { + fn parse(&self) -> String { + match self { + VerbosityPut::SimpleProgress => 0.to_string(), + VerbosityPut::ExpectedHashes => 3.to_string(), + VerbosityPut::PutFetchable => 8.to_string(), + VerbosityPut::StartedCompressionANDFinishedCompression => 9.to_string(), + } + } +} + +#[test] +fn is_berbosity_put_parsing() { + assert_eq!(default_unwrap::(None), "".to_string()); + assert_eq!( + default_unwrap::(Some(&VerbosityPut::SimpleProgress)), + "0".to_string() + ); + assert_eq!( + default_unwrap::(Some(&VerbosityPut::ExpectedHashes)), + "3".to_string() + ); + assert_eq!( + default_unwrap::(Some(&VerbosityPut::PutFetchable)), + "8".to_string() + ); + assert_eq!( + default_unwrap::(Some( + &VerbosityPut::StartedCompressionANDFinishedCompression + )), + "9".to_string() + ); +} + pub enum VerbosityGet { SimpleProgress, SendingToNetwork, @@ -45,6 +80,33 @@ pub enum Persistence { Forever, } +impl FcpRequest for Persistence { + fn parse(&self) -> String { + match *self { + Persistence::Connection => "connection".to_string(), + Persistence::Reboot => "reboot".to_string(), + Persistence::Forever => "forever".to_string(), + } + } +} + +#[test] +fn is_persistence_parsing() { + assert_eq!( + default_unwrap(Some(&Persistence::Connection)), + "connection".to_string() + ); + assert_eq!( + default_unwrap(Some(&Persistence::Reboot)), + "reboot".to_string() + ); + assert_eq!( + default_unwrap(Some(&Persistence::Forever)), + "forever".to_string() + ); + assert_eq!(default_unwrap::(None), "".to_string()); +} + pub enum UploadForm { Direct, Disk, @@ -75,3 +137,9 @@ pub enum Priority { pub trait FcpRequest { fn parse(&self) -> String; } +pub fn default_unwrap(fcp_type: Option<&T>) -> String { + match fcp_type { + Some(val) => val.parse(), + None => String::from(""), + } +}