2022-04-06 15:18:06 +00:00
|
|
|
use crate::data::entity_manager::EntityManager;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
|
|
|
|
pub struct ClientID(pub String);
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
|
|
pub struct Client {
|
|
|
|
pub id: ClientID,
|
|
|
|
pub name: String,
|
|
|
|
pub description: String,
|
2022-04-09 09:30:23 +00:00
|
|
|
pub secret: String,
|
|
|
|
pub redirect_uri: String,
|
2022-04-06 15:18:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl PartialEq for Client {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
self.id.eq(&other.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Eq for Client {}
|
|
|
|
|
|
|
|
pub type ClientManager = EntityManager<Client>;
|
|
|
|
|
|
|
|
impl EntityManager<Client> {
|
|
|
|
pub fn find_by_id(&self, u: &ClientID) -> Option<Client> {
|
|
|
|
for entry in self.iter() {
|
|
|
|
if entry.id.eq(u) {
|
|
|
|
return Some(entry.clone());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|