diff options
author | 2025-06-02 19:50:45 +0100 | |
---|---|---|
committer | 2025-06-02 19:50:45 +0100 | |
commit | ab654372e4d3766c8df17623a6de8922fc2a1960 (patch) | |
tree | 59ff88ab5da68af23ad84bc2310730e29eb89410 /src/contact.rs | |
parent | 6ee4190a26f32bfa953302ee363ad3bb6c384ebb (diff) | |
download | macaw-web-ab654372e4d3766c8df17623a6de8922fc2a1960.tar.gz macaw-web-ab654372e4d3766c8df17623a6de8922fc2a1960.tar.bz2 macaw-web-ab654372e4d3766c8df17623a6de8922fc2a1960.zip |
feat: make `MacawUser`, `MacawChat` and `MacawMessage` arena-allocated
Diffstat (limited to 'src/contact.rs')
-rw-r--r-- | src/contact.rs | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/contact.rs b/src/contact.rs index e9ab21f..9adec16 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -3,23 +3,52 @@ use std::ops::{Deref, DerefMut}; use filamento::{roster::Contact, user::User}; use reactive_stores::Store; -use crate::user::MacawUser; +use crate::user::{ArcMacawUser, MacawUser}; -#[derive(Clone)] +#[derive(Clone, Copy)] pub struct MacawContact { pub contact: Store<Contact>, pub user: MacawUser, } -impl MacawContact { +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 = MacawUser::got_user(user); + let user = ArcMacawUser::got_user(user); Self { contact, user } } } -impl Deref for MacawContact { +impl Deref for ArcMacawContact { type Target = Store<Contact>; fn deref(&self) -> &Self::Target { @@ -27,7 +56,7 @@ impl Deref for MacawContact { } } -impl DerefMut for MacawContact { +impl DerefMut for ArcMacawContact { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.contact } |