pub struct GroupMetadata {
pub name: Option<String>,
pub created_at_ms: u64,
pub last_activity_ms: u64,
pub custom: HashMap<String, String>,
pub created_by: Option<String>,
pub roles: HashMap<String, GroupRole>,
}Expand description
Metadata about an MLS group (stored separately from MLS state).
Fields§
§name: Option<String>Human-readable group name.
created_at_ms: u64Timestamp when the group was created (milliseconds since epoch).
last_activity_ms: u64Timestamp of the last activity (milliseconds since epoch).
custom: HashMap<String, String>Custom application-specific metadata.
created_by: Option<String>User ID of the group creator.
roles: HashMap<String, GroupRole>Per-member role assignments.
Deserialization falls back to migrating legacy "role:*" keys from custom.
Implementations§
Source§impl GroupMetadata
impl GroupMetadata
Sourcepub const LEGACY_ROLE_KEY_PREFIX: &'static str = "role:"
pub const LEGACY_ROLE_KEY_PREFIX: &'static str = "role:"
Prefix previously used for role entries in the custom map (legacy).
Sourcepub fn new(name: Option<String>) -> Self
pub fn new(name: Option<String>) -> Self
Creates new group metadata with the given name and creator.
Sourcepub fn new_with_creator(name: Option<String>, creator_id: &str) -> Self
pub fn new_with_creator(name: Option<String>, creator_id: &str) -> Self
Creates new group metadata with a creator.
Sourcepub fn migrate_legacy_roles(&mut self)
pub fn migrate_legacy_roles(&mut self)
Migrates any legacy "role:*" keys from the custom map into the
dedicated roles field. Call after deserialization for
backwards-compatibility with older group metadata.
Sourcepub fn get_role(&self, user_id: &str) -> GroupRole
pub fn get_role(&self, user_id: &str) -> GroupRole
Gets the role for a user, defaulting to GroupRole::Member if not set.
Sourcepub fn remove_role(&mut self, user_id: &str)
pub fn remove_role(&mut self, user_id: &str)
Removes role metadata for a user (on removal from group).
Sourcepub fn has_any_admin(&self) -> bool
pub fn has_any_admin(&self) -> bool
Returns true if any admin role is stored in this metadata.
Sourcepub fn get_all_roles(&self) -> HashMap<String, GroupRole>
pub fn get_all_roles(&self) -> HashMap<String, GroupRole>
Returns all user_id -> role mappings.
Trait Implementations§
Source§impl Clone for GroupMetadata
impl Clone for GroupMetadata
Source§impl Debug for GroupMetadata
impl Debug for GroupMetadata
Source§impl<'de> Deserialize<'de> for GroupMetadata
impl<'de> Deserialize<'de> for GroupMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for GroupMetadata
impl RefUnwindSafe for GroupMetadata
impl Send for GroupMetadata
impl Sync for GroupMetadata
impl Unpin for GroupMetadata
impl UnsafeUnpin for GroupMetadata
impl UnwindSafe for GroupMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more