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))
}
}

46
src/types/users.rs Normal file
View File

@ -0,0 +1,46 @@
use skytable::{
query::SQParam,
response::{
FromResponse,
Response,
Value,
},
ClientResult,
};
pub struct Users {
pub login: String,
pub uuid: String,
pub password: String,
pub email: String,
pub tokens: Vec<Value>,
}
impl Users {
pub fn new(login: String, uuid: String, password: String, email: String, tokens: Vec<Value>) -> Self {
Self {
login,
uuid,
password,
email,
tokens,
}
}
}
impl SQParam for Users {
fn append_param(&self, q: &mut Vec<u8>) -> usize {
self.login.append_param(q)
+ self.uuid.append_param(q)
+ self.password.append_param(q)
+ self.email.append_param(q)
}
}
impl FromResponse for Users {
fn from_response(resp: Response) -> ClientResult<Self> {
let (login, uuid, password, email, tokens) = FromResponse::from_response(resp)?;
Ok(Self::new(login, uuid, password, email, tokens))
}
}