More struct
This commit is contained in:
40
src/types/sites.rs
Normal file
40
src/types/sites.rs
Normal 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))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user