openlegends_api/user/login/request/
data.rs1pub mod error;
2pub use error::Error;
3
4use serde::{Deserialize, Serialize};
5
6#[derive(Serialize, Deserialize, Debug)]
7pub struct Data {
8 password: String,
9 username: String,
10}
11
12impl Data {
13 pub fn build(username: String, password: String) -> Self {
14 Self { password, username }
15 }
16
17 pub fn to_json(&self) -> Result<String, Error> {
18 match serde_json::to_string(&self) {
19 Ok(json) => Ok(json),
20 Err(e) => Err(Error::Json(e)),
21 }
22 }
23
24 pub fn password(&self) -> &str {
25 &self.password
26 }
27
28 pub fn username(&self) -> &str {
29 &self.username
30 }
31}