2021-03-12 04:49:51 +00:00
pub mod traits ;
2021-03-24 04:18:53 +00:00
mod key ;
2021-03-12 04:49:51 +00:00
use regex ::Regex ;
2021-03-12 05:03:35 +00:00
use traits ::* ;
2021-03-24 04:18:53 +00:00
pub use key ::* ;
2021-03-13 08:23:40 +00:00
2021-03-12 04:49:51 +00:00
#[ derive(Debug, PartialEq) ]
pub struct SSKKeypair {
pub insert_uri : SSK ,
pub request_uri : SSK ,
pub identifier : String ,
}
impl FcpParser < SSKKeypair > for SSKKeypair {
fn parse ( plain : & str ) -> Option < SSKKeypair > {
let reg = Regex ::new (
r "^SSKKeypair\nIdentifier=(.*)\nInsertURI=(.*)\nRequestURI=(.*)\nEndMessage" ,
)
2021-03-12 05:03:35 +00:00
. unwrap ( ) ;
2021-03-12 04:49:51 +00:00
println! ( " {:?} " , reg ) ;
let res = reg . captures ( plain ) . unwrap ( ) ;
let identifier = res [ 1 ] . to_string ( ) ;
let insert_uri = SSK ::parse ( & res [ 2 ] ) . unwrap ( ) ;
let request_uri = SSK ::parse ( & res [ 3 ] ) . unwrap ( ) ;
return Some ( SSKKeypair {
insert_uri : insert_uri ,
request_uri : request_uri ,
identifier : identifier ,
} ) ;
}
}
pub enum ReturnType {
2021-03-12 05:03:35 +00:00
/// return the data directly to the client via an AllData message, once we have all of it. (For persistent requests, the client will get a DataFound message but must send a GetRequestStatus to ask for the AllData).
2021-03-12 04:49:51 +00:00
Direct ,
2021-03-12 05:03:35 +00:00
/// write the data to disk. If you download to disk, you have to do a TestDDARequest.
2021-03-12 04:49:51 +00:00
None ,
2021-03-12 05:03:35 +00:00
/// don't return the data at all, just fetch it to the node and tell the client when we have finished.
2021-03-12 04:49:51 +00:00
Disk ,
}
impl FcpRequest for ReturnType {
fn convert ( & self ) -> String {
2021-03-21 11:03:32 +00:00
match self {
ReturnType ::Direct = > " direct " . to_string ( ) ,
ReturnType ::Disk = > " disk " . to_string ( ) ,
ReturnType ::None = > " none " . to_string ( ) ,
}
2021-03-12 04:49:51 +00:00
}
}