update some implementations

This commit is contained in:
Horhik 2021-04-21 23:55:16 +03:00
parent d65a0bb4cf
commit 734c733e50
2 changed files with 26 additions and 4 deletions

View File

@ -1,6 +1,7 @@
use std::ops;
use super::types::*;
use crate::types::traits::*;
use crate::types::{ReturnType, SSKKeypair, SSK, USK};
use crate::types::{ReturnType, SSKKeypair, SSK, USK, KEY};
use regex::Regex;
impl ClientHello {
@ -91,7 +92,7 @@ pub struct GetNode {
}
pub struct GenerateSSK {
identifier: Option<String>,
pub identifier: Option<String>,
}
impl FcpRequest for GenerateSSK {
@ -187,6 +188,16 @@ fn is_ssk_parsing() {
}
);
}
impl FcpRequest for KEY {
fn convert(&self) -> String{
match self {
KEY::SSK(key) => key.convert(),
KEY::USK(key) => key.convert()
}
}
}
// TODO Create just Key type which contains from sign_key, decrtypt_key, settings and path.
// And use it for all keys, like SSK, USK e.t.c.
/// converting SSK key to string
@ -201,6 +212,8 @@ impl FcpRequest for SSK {
}
}
#[test]
fn is_ssk_converting() {
assert_eq!(SSK {
@ -496,8 +509,9 @@ BinaryBlob=false
FilterData=true
EndMessage
*/
impl ClientGet {
pub fn new_default(uri: SSK, identifier: &str, return_type: ReturnType) -> ClientGet {
pub fn new_default(uri: KEY, identifier: &str, return_type: ReturnType) -> ClientGet {
ClientGet {
ignore_ds: None,
ds_only: None,

View File

@ -11,12 +11,20 @@ use std::fmt;
use serde::de::{self, Deserialize, Deserializer, MapAccess, SeqAccess, Visitor, Error};
use serde::ser::{SerializeStruct, Serializer};
use serde::Serialize;
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Clone)]
pub struct SSK {
pub sign_key: String,
pub decrypt_key: String,
pub settings: Option<String>,
}
pub enum KEY {
SSK(SSK),
USK(USK),
}
/// converting SSK to rusqlite type
impl ToSql for SSK {
fn to_sql(&self) -> Result<ToSqlOutput<'_>> {