Skip to main content

ChatRoomStateV1

Struct ChatRoomStateV1 

Source
pub struct ChatRoomStateV1 {
    pub configuration: AuthorizedConfigurationV1,
    pub bans: BansV1,
    pub members: MembersV1,
    pub member_info: MemberInfoV1,
    pub secrets: RoomSecretsV1,
    pub recent_messages: MessagesV1,
    pub direct_messages: DirectMessagesV1,
    pub upgrade: OptionalUpgradeV1,
    pub version: StateVersion,
}

Fields§

§configuration: AuthorizedConfigurationV1

Configures things like maximum message length, can be updated by the owner.

§bans: BansV1

A list of recently banned members, a banned member can’t be present in the members list and will be removed from it ifc necessary.

§members: MembersV1

The members in the chat room along with who invited them

§member_info: MemberInfoV1

Metadata about members like their nickname, can be updated by members themselves.

§secrets: RoomSecretsV1

Secret distribution for private rooms. Must come before recent_messages so message validation can check secret version consistency.

§recent_messages: MessagesV1

The most recent messages in the chat room, the number is limited by the room configuration.

§direct_messages: DirectMessagesV1

In-room encrypted direct messages between members (#230 Phase 1). #[serde(default)] keeps states written before this field was added backwards-compatible.

§upgrade: OptionalUpgradeV1

If this contract has been replaced by a new contract this will contain the new contract address. This can only be set by the owner.

§version: StateVersion

State format version for migration compatibility. Defaults to 0 for backward compatibility with states created before versioning.

Implementations§

Source§

impl ChatRoomStateV1

Source

pub fn post_apply_cleanup( &mut self, parameters: &ChatRoomParametersV1, ) -> Result<(), String>

Post-apply cleanup: prune members who have no recent messages, clean up member_info for pruned members, remove orphaned bans, and sweep direct messages whose participants are no longer in the room.

Members are kept if they have at least one message in recent_messages, are a sender/recipient of a currently-held direct message (see crate::room_state::direct_messages::DirectMessagesV1::active_participants), or are in the invite chain of someone who qualifies. The owner is never in the members list (they’re implicit via parameters).

Bans are only removed if the banner was themselves BANNED (orphaned ban). If the banner was merely pruned for inactivity, their bans persist.

Direct-message sweep: after pruning, any DM whose sender or recipient is now non-member or banned is dropped. Without this, adding a ban for a DM participant would silently make every peer’s verify fail, and members referenced only by a DM would be pruned (orphaning their DMs). See direct_messages.rs module docs, “Interaction with bans”.

Trait Implementations§

Source§

impl Clone for ChatRoomStateV1

Source§

fn clone(&self) -> ChatRoomStateV1

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl ComposableState for ChatRoomStateV1

Source§

type ParentState = ChatRoomStateV1

Source§

type Summary = ChatRoomStateV1Summary

Source§

type Delta = ChatRoomStateV1Delta

Source§

type Parameters = <AuthorizedConfigurationV1 as ComposableState>::Parameters

Source§

fn verify( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Result<(), String>

Source§

fn summarize( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Self::Summary

Source§

fn delta( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, old_state_summary: &Self::Summary, ) -> Option<Self::Delta>

Source§

fn apply_delta( &mut self, _parent_state: &Self::ParentState, parameters: &Self::Parameters, delta: &Option<Self::Delta>, ) -> Result<(), String>

Applies the specified delta to the current state. Read more
Source§

fn merge( &mut self, parent_state: &Self::ParentState, parameters: &Self::Parameters, other_state: &Self, ) -> Result<(), String>

Merges the current state with another state.
Source§

impl Debug for ChatRoomStateV1

Source§

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

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

impl Default for ChatRoomStateV1

Source§

fn default() -> ChatRoomStateV1

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ChatRoomStateV1

Source§

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

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

impl PartialEq for ChatRoomStateV1

Source§

fn eq(&self, other: &ChatRoomStateV1) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ChatRoomStateV1

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ChatRoomStateV1

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
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
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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.
Source§

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