GroupMember

Struct GroupMember 

Source
pub struct GroupMember {
    pub key: IdentityRef,
    pub role: GroupRole,
    pub joined_at: u64,
    pub last_active: u64,
    pub metadata: Vec<Metadata>,
}
Expand description

Runtime information about an active group member.

GroupMember tracks the runtime state of a participant in a group. This includes their role, activity timestamps, and member-specific metadata. It’s distinct from the cryptographic identity and display identity managed by GroupMembership.

§📊 Member State vs Identity State

  • GroupMember: Runtime participation state (roles, activity, metadata)
  • GroupMembership: Identity management (aliases, display names, authorization)
  • VerifyingKey: Cryptographic identity (authentication, message signing)

These three layers work together to provide comprehensive member management:

VerifyingKey → GroupMember (runtime state) + GroupMembership (identity state)

§🔄 Lifecycle and State Transitions

  1. Initial Creation: When a key first participates, a GroupMember is created
  2. Activity Updates: GroupMember::last_active updated with each message
  3. Role Changes: GroupMember::role updated via role assignment events
  4. Metadata Updates: GroupMember::metadata can store custom key-value data
  5. Departure: GroupMember removed when user leaves (but could rejoin later)

§💡 Usage Examples

§Tracking Member Activity

use zoe_app_primitives::{GroupMember, IdentityRef, events::roles::GroupRole};
use zoe_wire_protocol::KeyPair;
use std::collections::BTreeMap;

let member_key = KeyPair::generate(&mut rand::rngs::OsRng).public_key();
let join_time = 1234567890;

let mut member = GroupMember {
    key: IdentityRef::Key(member_key),
    role: GroupRole::Member,
    joined_at: join_time,
    last_active: join_time,
    metadata: vec![],
};

// Update activity when they send a message
member.last_active = join_time + 3600; // 1 hour later

// Check how long they've been inactive
let current_time = join_time + 7200; // 2 hours later  
let inactive_duration = current_time - member.last_active;
assert_eq!(inactive_duration, 3600); // 1 hour inactive

§Role-Based Member Management


// Promote member to moderator
member.role = GroupRole::Moderator;

// Check permissions
use zoe_app_primitives::Permission;
assert!(member.role.has_permission(&Permission::AllMembers));
assert!(member.role.has_permission(&Permission::ModeratorOrAbove));

§Custom Member Metadata


// Store custom metadata about the member using structured types
member.metadata.push(Metadata::Generic { key: "department".to_string(), value: "engineering".to_string() });
member.metadata.push(Metadata::Generic { key: "team".to_string(), value: "backend".to_string() });
member.metadata.push(Metadata::Generic { key: "timezone".to_string(), value: "UTC-8".to_string() });
member.metadata.push(Metadata::Email("member@company.com".to_string()));

// Query metadata
for meta in &member.metadata {
    match meta {
        Metadata::Generic { key, value } if key == "department" => {
            println!("Member is in {} department", value);
        }
        Metadata::Email(email) => {
            println!("Member email: {}", email);
        }
        _ => {}
    }
}

Fields§

§key: IdentityRef

Member’s public key encoded as bytes for serialization compatibility

§role: GroupRole

Member’s role in the group

§joined_at: u64

When they joined the group

§last_active: u64

When they were last active

§metadata: Vec<Metadata>

Member-specific metadata using structured types

Trait Implementations§

Source§

impl Clone for GroupMember

Source§

fn clone(&self) -> GroupMember

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GroupMember

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for GroupMember

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<GroupMember, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for GroupMember

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Classify for T

§

type Classified = T

§

fn classify(self) -> T

§

impl<T> Classify for T

§

type Classified = T

§

fn classify(self) -> T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Declassify for T

§

type Declassified = T

§

fn declassify(self) -> T

§

impl<T> Declassify for T

§

type Declassified = T

§

fn declassify(self) -> T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> DartSafe for T

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> TaskRetFutTrait for T
where T: Send,