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: AuthorizedConfigurationV1Configures things like maximum message length, can be updated by the owner.
bans: BansV1A 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: MembersV1The members in the chat room along with who invited them
member_info: MemberInfoV1Metadata about members like their nickname, can be updated by members themselves.
secrets: RoomSecretsV1Secret distribution for private rooms. Must come before recent_messages so message validation can check secret version consistency.
recent_messages: MessagesV1The most recent messages in the chat room, the number is limited by the room configuration.
direct_messages: DirectMessagesV1In-room encrypted direct messages between members (#230 Phase 1).
#[serde(default)] keeps states written before this field was added
backwards-compatible.
upgrade: OptionalUpgradeV1If 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: StateVersionState format version for migration compatibility. Defaults to 0 for backward compatibility with states created before versioning.
Implementations§
Source§impl ChatRoomStateV1
impl ChatRoomStateV1
Sourcepub fn post_apply_cleanup(
&mut self,
parameters: &ChatRoomParametersV1,
) -> Result<(), String>
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
impl Clone for ChatRoomStateV1
Source§fn clone(&self) -> ChatRoomStateV1
fn clone(&self) -> ChatRoomStateV1
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ComposableState for ChatRoomStateV1
impl ComposableState for ChatRoomStateV1
type ParentState = ChatRoomStateV1
type Summary = ChatRoomStateV1Summary
type Delta = ChatRoomStateV1Delta
type Parameters = <AuthorizedConfigurationV1 as ComposableState>::Parameters
fn verify( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Result<(), String>
fn summarize( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Self::Summary
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>
fn apply_delta( &mut self, _parent_state: &Self::ParentState, parameters: &Self::Parameters, delta: &Option<Self::Delta>, ) -> Result<(), String>
delta to the current state. Read moreSource§fn merge(
&mut self,
parent_state: &Self::ParentState,
parameters: &Self::Parameters,
other_state: &Self,
) -> Result<(), String>
fn merge( &mut self, parent_state: &Self::ParentState, parameters: &Self::Parameters, other_state: &Self, ) -> Result<(), String>
Source§impl Debug for ChatRoomStateV1
impl Debug for ChatRoomStateV1
Source§impl Default for ChatRoomStateV1
impl Default for ChatRoomStateV1
Source§fn default() -> ChatRoomStateV1
fn default() -> ChatRoomStateV1
Source§impl<'de> Deserialize<'de> for ChatRoomStateV1
impl<'de> Deserialize<'de> for ChatRoomStateV1
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>,
Source§impl PartialEq for ChatRoomStateV1
impl PartialEq for ChatRoomStateV1
Source§fn eq(&self, other: &ChatRoomStateV1) -> bool
fn eq(&self, other: &ChatRoomStateV1) -> bool
self and other values to be equal, and is used by ==.