blob: 9adec16587fa95cd1a5c11c47181df478ccb5b63 (
plain) (
tree)
|
|
use std::ops::{Deref, DerefMut};
use filamento::{roster::Contact, user::User};
use reactive_stores::Store;
use crate::user::{ArcMacawUser, MacawUser};
#[derive(Clone, Copy)]
pub struct MacawContact {
pub contact: Store<Contact>,
pub user: MacawUser,
}
impl Deref for MacawContact {
type Target = Store<Contact>;
fn deref(&self) -> &Self::Target {
&self.contact
}
}
impl DerefMut for MacawContact {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.contact
}
}
impl From<ArcMacawContact> for MacawContact {
fn from(value: ArcMacawContact) -> Self {
Self {
contact: value.contact,
user: value.user.into(),
}
}
}
#[derive(Clone)]
pub struct ArcMacawContact {
pub contact: Store<Contact>,
pub user: ArcMacawUser,
}
impl ArcMacawContact {
pub fn got_contact_and_user(contact: Contact, user: User) -> Self {
let contact = Store::new(contact);
let user = ArcMacawUser::got_user(user);
Self { contact, user }
}
}
impl Deref for ArcMacawContact {
type Target = Store<Contact>;
fn deref(&self) -> &Self::Target {
&self.contact
}
}
impl DerefMut for ArcMacawContact {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.contact
}
}
|