More struct

This commit is contained in:
2024-03-16 13:34:13 +05:00
parent 73b0fb8762
commit 9473ebe7a0
4 changed files with 35 additions and 19 deletions

40
src/types/sites.rs Normal file
View File

@ -0,0 +1,40 @@
use skytable::{
query::SQParam,
response::{FromResponse, Response},
ClientResult,
};
pub struct Sites {
pub uuid: String,
pub uid: String,
pub domain: String,
pub pkey: Vec<u8>,
pub skey: Vec<u8>,
}
impl Sites {
pub fn new(uuid: String, uid: String, domain: String, pkey: Vec<u8>, skey: Vec<u8>) -> Self {
Self {
uuid,
uid,
domain,
pkey,
skey,
}
}
}
impl SQParam for Sites {
fn append_param(&self, q: &mut Vec<u8>) -> usize {
self.uuid.append_param(q)
+ self.domain.append_param(q)
}
}
impl FromResponse for Sites {
fn from_response(resp: Response) -> ClientResult<Self> {
let (uuid, uid, domain, pkey, skey) = FromResponse::from_response(resp)?;
Ok(Self::new(uuid, uid, domain, pkey, skey))
}
}