47 lines
865 B
Rust
47 lines
865 B
Rust
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))
|
|
}
|
|
}
|