add impl of ClientPut (no tests)
This commit is contained in:
parent
94f7b83c5a
commit
8a5d004ac7
|
@ -97,41 +97,69 @@ pub struct ClientPut {
|
||||||
data_length: u64,
|
data_length: u64,
|
||||||
filename: String,
|
filename: String,
|
||||||
content_type: Option<&'static String>,
|
content_type: Option<&'static String>,
|
||||||
identifier: Option<String>,
|
identifier: Option<&'static String>,
|
||||||
verbosity: Option<VerbosityPut>,
|
verbosity: Option<&'static VerbosityPut>,
|
||||||
max_retries: Option<Retry>,
|
max_retries: Option<&'static Retry>,
|
||||||
priority_class: Option<Priority>,
|
priority_class: Option<&'static Priority>,
|
||||||
get_chk_only: Option<bool>,
|
get_chk_only: Option<&'static bool>,
|
||||||
global: Option<bool>,
|
global: Option<&'static bool>,
|
||||||
dont_compress: Option<bool>,
|
dont_compress: Option<&'static bool>,
|
||||||
codecs: Option<Vec<String>>,
|
codecs: Option<&'static String>, // TODO turn into vec and add implementation
|
||||||
client_token: Option<String>,
|
client_token: Option<&'static String>,
|
||||||
persistence: Option<Persistence>,
|
persistence: Option<&'static Persistence>,
|
||||||
target_filename: Option<String>, // TODO create filename type (not PATH, ONLY SLASHES)
|
target_filename: Option<&'static String>, // TODO create filename type (&'static not PATH, ONLY SLASHES)
|
||||||
early_encode: Option<bool>,
|
early_encode: Option<&'static bool>,
|
||||||
upload_ffrom: Option<UploadForm>,
|
upload_ffrom: Option<&'static UploadForm>,
|
||||||
target_uri: Option<String>, // cloning uri if does not exists
|
target_uri: Option<&'static String>, // cloning uri if does not exists
|
||||||
file_hash: Option<String>, //TODO SHAA256 type
|
file_hash: Option<&'static String>, //TODO SHAA256 type
|
||||||
binary_blob: Option<bool>,
|
binary_blob: Option<&'static bool>,
|
||||||
fork_on_cacheable: Option<bool>,
|
fork_on_cacheable: Option<&'static bool>,
|
||||||
extra_inserts_single_block: Option<u32>,
|
extra_inserts_single_block: Option<&'static u32>,
|
||||||
extra_inserts_splitfile_header_block: Option<u32>,
|
extra_inserts_splitfile_header_block: Option<&'static u32>,
|
||||||
compatibility_mode: Option<String>, //TODO create enum???
|
compatibility_mode: Option<&'static String>, //TODO create enum???
|
||||||
local_request_only: Option<bool>,
|
local_request_only: Option<&'static bool>,
|
||||||
override_splitfile_crypto_key: Option<String>, //key in hex
|
override_splitfile_crypto_key: Option<&'static String>, //key in hex
|
||||||
real_time_flag: Option<String>,
|
real_time_flag: Option<&'static String>,
|
||||||
metadata_threshold: Option<i64>,
|
metadata_threshold: Option<&'static i64>,
|
||||||
data: Option<String>, // Data fromdirect
|
data: Option<&'static String>, // Data fromdirect
|
||||||
}
|
}
|
||||||
impl FcpRequest for ClientPut {
|
impl FcpRequest for ClientPut {
|
||||||
fn convert(&self) -> String {
|
fn convert(&self) -> String {
|
||||||
|
let content_type = to_fcp_unwrap("ContentType=", self.content_type, "\n");
|
||||||
|
let identifier = to_fcp_unwrap("Identifier=", self.identifier, "\n");
|
||||||
|
let verbosity = to_fcp_unwrap("=", self.verbosity, "\n");
|
||||||
|
let max_retries = to_fcp_unwrap("=", self.max_retries, "\n");
|
||||||
|
let priority_class = to_fcp_unwrap("=", self.priority_class, "\n");
|
||||||
|
let get_chk_only = to_fcp_unwrap("=", self.get_chk_only, "\n");
|
||||||
|
let global = to_fcp_unwrap("=", self.global, "\n");
|
||||||
|
let dont_compress = to_fcp_unwrap("=", self.dont_compress, "\n");
|
||||||
|
let codecs = to_fcp_unwrap("=", self.codecs, "\n");
|
||||||
|
let client_token = to_fcp_unwrap("=", self.client_token, "\n");
|
||||||
|
let persistence = to_fcp_unwrap("=", self.persistence, "\n");
|
||||||
|
let target_filename = to_fcp_unwrap("=", self.target_filename, "\n");
|
||||||
|
let early_encode = to_fcp_unwrap("=", self.early_encode, "\n");
|
||||||
|
let upload_ffrom = to_fcp_unwrap("=", self.upload_ffrom, "\n");
|
||||||
|
let target_uri = to_fcp_unwrap("=", self.target_uri, "\n");
|
||||||
|
let file_hash = to_fcp_unwrap("=", self.file_hash, "\n");
|
||||||
|
let binary_blob = to_fcp_unwrap("=", self.binary_blob, "\n");
|
||||||
|
let fork_on_cacheable = to_fcp_unwrap("=", self.fork_on_cacheable, "\n");
|
||||||
|
let extra_inserts_single_block = to_fcp_unwrap("=", self.extra_inserts_single_block, "\n");
|
||||||
|
let extra_inserts_splitfile_header_block =
|
||||||
|
to_fcp_unwrap("=", self.extra_inserts_splitfile_header_block, "\n");
|
||||||
|
let compatibility_mode = to_fcp_unwrap("=", self.compatibility_mode, "\n");
|
||||||
|
let local_request_only = to_fcp_unwrap("=", self.local_request_only, "\n");
|
||||||
|
let override_splitfile_crypto_key =
|
||||||
|
to_fcp_unwrap("=", self.override_splitfile_crypto_key, "\n");
|
||||||
|
let real_time_flag = to_fcp_unwrap("=", self.real_time_flag, "\n");
|
||||||
|
let metadata_threshold = to_fcp_unwrap("=", self.metadata_threshold, "\n");
|
||||||
|
let data = to_fcp_unwrap("=", self.data, "\n");
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"ClientPut\n\
|
"ClientPut\n\
|
||||||
{}\
|
{}\
|
||||||
{}\
|
{}\
|
||||||
{}\
|
{}\
|
||||||
{}\
|
{}\
|
||||||
"/*
|
|
||||||
{}\
|
{}\
|
||||||
{}\
|
{}\
|
||||||
{}\
|
{}\
|
||||||
|
@ -158,11 +186,37 @@ impl FcpRequest for ClientPut {
|
||||||
{}\
|
{}\
|
||||||
EndMessage\n\
|
EndMessage\n\
|
||||||
{}\
|
{}\
|
||||||
",*/,
|
",
|
||||||
format!("URI={}\n", self.uri),
|
format!("URI={}\n", self.uri),
|
||||||
format!("DataLength={}\n", self.data_length),
|
format!("DataLength={}\n", self.data_length),
|
||||||
format!("Filename={}\n", self.filename),
|
format!("Filename={}\n", self.filename),
|
||||||
to_fcp_unwrap("ContentType", self.content_type, "\n")
|
content_type,
|
||||||
|
identifier,
|
||||||
|
verbosity,
|
||||||
|
max_retries,
|
||||||
|
priority_class,
|
||||||
|
get_chk_only,
|
||||||
|
global,
|
||||||
|
dont_compress,
|
||||||
|
codecs,
|
||||||
|
client_token,
|
||||||
|
persistence,
|
||||||
|
target_filename,
|
||||||
|
early_encode,
|
||||||
|
upload_ffrom,
|
||||||
|
target_uri,
|
||||||
|
file_hash,
|
||||||
|
binary_blob,
|
||||||
|
fork_on_cacheable,
|
||||||
|
extra_inserts_single_block,
|
||||||
|
extra_inserts_splitfile_header_block,
|
||||||
|
compatibility_mode,
|
||||||
|
local_request_only,
|
||||||
|
override_splitfile_crypto_key,
|
||||||
|
real_time_flag,
|
||||||
|
metadata_threshold,
|
||||||
|
data,
|
||||||
|
// to_fcp_unwrap("Verbosity", self.verbosity, "\n"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,15 @@ pub enum Retry {
|
||||||
Forever,
|
Forever,
|
||||||
Num(i32),
|
Num(i32),
|
||||||
}
|
}
|
||||||
|
impl FcpRequest for Retry {
|
||||||
|
fn convert(&self) -> String {
|
||||||
|
match *self {
|
||||||
|
Retry::None => "0".to_string(),
|
||||||
|
Retry::Forever => "-1".to_string(),
|
||||||
|
Retry::Num(num) => num.to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Persistence {
|
pub enum Persistence {
|
||||||
Connection,
|
Connection,
|
||||||
|
@ -190,6 +199,11 @@ impl FcpRequest for u32 {
|
||||||
self.to_string()
|
self.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl FcpRequest for i64 {
|
||||||
|
fn convert(&self) -> String {
|
||||||
|
self.to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FcpRequest for String {
|
impl FcpRequest for String {
|
||||||
fn convert(&self) -> String {
|
fn convert(&self) -> String {
|
||||||
|
@ -220,11 +234,7 @@ pub fn fcp_types_unwrap<T: FcpRequest>(fcp_type: Option<&T>) -> String {
|
||||||
None => String::from(""),
|
None => String::from(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn to_fcp_unwrap<T: FcpRequest>(
|
pub fn to_fcp_unwrap<T: FcpRequest>(prefix: &str, fcp_type: Option<&T>, postfix: &str) -> String {
|
||||||
prefix: &'static str,
|
|
||||||
fcp_type: Option<&T>,
|
|
||||||
postfix: &'static str,
|
|
||||||
) -> String {
|
|
||||||
match fcp_type {
|
match fcp_type {
|
||||||
Some(val) => val.fcp_wrap(&prefix, &postfix),
|
Some(val) => val.fcp_wrap(&prefix, &postfix),
|
||||||
None => String::from(""),
|
None => String::from(""),
|
||||||
|
|
Loading…
Reference in a new issue