use super::types::*; impl ClientHello { fn new(name: String, exp_ver: f32) -> Self { ClientHello { name: name, expected_version: exp_ver, } } } impl FcpRequest for ClientHello { fn convert(&self) -> String { return format!( "ClientHello\n\ Name={}\n\ ExpectedVersion={}\n\ EndMessage\n\n", self.name, self.expected_version ); } } pub struct ClientHello { name: String, expected_version: f32, } #[test] fn client_hello_converts() { let hello = ClientHello::new("user name".to_string(), 2.0); assert_eq!( hello.convert(), "ClientHello\nName=user name\nExpectedVersion=2\nEndMessage\n\n" ); } // TODO not implemented ListPeer pub struct ListPeer { message_name: String, node_identifier: NodeIdentifier, with_volatile: Option, with_metadata: Option, } pub struct ListPeers { message_name: String, with_volatile: Option, with_metadata: Option, } pub struct ListPeerNotes { message_name: String, node_identifier: NodeIdentifier, } pub struct AddPeer { message_name: String, trust: TrustLevel, visibility: VisibilityLevel, file: Option, url: Option, raw: Option, } pub struct ModifyPeer { message_name: String, node_identifier: NodeIdentifier, allow_local_addresses: Option, is_disabled: Option, is_listen_only: Option, is_burst_only: Option, ignore_source_port: Option, } pub struct ModifyPeerNote { message_name: String, node_text: String, peer_note_type: i32, } pub struct RemovePeer { message_name: String, node_identifier: NodeIdentifier, } pub struct GetNode { message_name: String, identifier: Option, give_opennet_ref: Option, with_private: Option, with_volatile: Option, } pub struct GenerateSSK { message_name: String, identifier: Option, } pub struct ClientPut { uri: String, //TODO create key type data_length: u64, filename: String, content_type: Option<&'static String>, identifier: Option, verbosity: Option, max_retries: Option, priority_class: Option, get_chk_only: Option, global: Option, dont_compress: Option, codecs: Option>, client_token: Option, persistence: Option, target_filename: Option, // TODO create filename type (not PATH, ONLY SLASHES) early_encode: Option, upload_ffrom: Option, target_uri: Option, // cloning uri if does not exists file_hash: Option, //TODO SHAA256 type binary_blob: Option, fork_on_cacheable: Option, extra_inserts_single_block: Option, extra_inserts_splitfile_header_block: Option, compatibility_mode: Option, //TODO create enum??? local_request_only: Option, override_splitfile_crypto_key: Option, //key in hex real_time_flag: Option, metadata_threshold: Option, data: Option, // Data fromdirect } impl FcpRequest for ClientPut { fn convert(&self) -> String { format!( "ClientPut\n\ {}\ {}\ {}\ {}\ "/* {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ {}\ EndMessage\n\ {}\ ",*/, format!("URI={}\n", self.uri), format!("DataLength={}\n", self.data_length), format!("Filename={}\n", self.filename), to_fcp_unwrap("ContentType", self.content_type, "\n") ) } } pub struct ClientGet { message_name: String, ignore_ds: Option, ds_only: Option, uri: String, //FIXME freenet uri type identifier: String, verbosity: Option, max_size: Option, max_retries: Option, priority_class: Option, persistence: Option, client_token: Option, global: Option, return_type: Option, binary_blob: Option, filter_data: Option, allowed_mime_types: Option>, filename: Option>, temp_filename: Option>, real_time_flag: Option, initial_metadata_data_length: u64, } pub struct Disconnect { message_name: String, } pub struct Shutdown { message_name: String, }