Refactor naming
This commit is contained in:
parent
a9fd240bd3
commit
ad58ab9bdd
10 changed files with 66 additions and 62 deletions
src/models
40
src/models/client.rs
Normal file
40
src/models/client.rs
Normal file
|
@ -0,0 +1,40 @@
|
|||
use std::fmt::{Display, Formatter};
|
||||
|
||||
use crate::parameter::{parameter_find, ParameterList};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Client {
|
||||
pub cid: i32,
|
||||
pub clid: i32,
|
||||
pub client_database_id: i32,
|
||||
pub client_nickname: String,
|
||||
pub client_type: i32,
|
||||
}
|
||||
|
||||
impl Display for Client {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{} ({})", self.client_nickname, self.clid)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ParameterList> for Client {
|
||||
fn from(value: ParameterList) -> Self {
|
||||
Client {
|
||||
cid: parameter_find(&value, "cid")
|
||||
.unwrap_or_default()
|
||||
.to_i32(-1),
|
||||
clid: parameter_find(&value, "clid")
|
||||
.unwrap_or_default()
|
||||
.to_i32(-1),
|
||||
client_database_id: parameter_find(&value, "client_database_id")
|
||||
.unwrap_or_default()
|
||||
.to_i32(-1),
|
||||
client_nickname: parameter_find(&value, "client_nickname")
|
||||
.unwrap_or_default()
|
||||
.value,
|
||||
client_type: parameter_find(&value, "channel_topic")
|
||||
.unwrap_or_default()
|
||||
.to_i32(0),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue