atagen

macltok

public
Star0
Watch0
fa51490b6ae98fdf5eeddb0799f4e3a160bf53cb
3
ssh://brewery@pls.lobotomise.me:33/atagen/macltok.git

Blame: src/model.rs

96fdf90aacd6atagen2026-09-08 08:24 UTC1
use std::{fmt, sync::Arc};
96fdf90aacd6atagen2026-09-08 08:24 UTC2
d5d8097c3afdatagen2026-09-26 09:33 UTC3
use imbl::Vector;
96fdf90aacd6atagen2026-09-08 08:24 UTC4
use ruma::{
5d2974de5826atagen2026-10-08 11:29 UTC5
    MxcUri, OwnedDeviceId, OwnedEventId, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId,
17e042fbc331atagen2026-10-08 12:39 UTC6
    OwnedRoomOrAliasId, OwnedServerName, OwnedTransactionId, OwnedUserId, RoomId,
31ce2453c82fatagen2026-09-24 13:07 UTC7
    events::{
31ce2453c82fatagen2026-09-24 13:07 UTC8
        AnyGlobalAccountDataEventContent, AnyRoomAccountDataEventContent, AnySyncTimelineEvent,
31ce2453c82fatagen2026-09-24 13:07 UTC9
        GlobalAccountDataEventType, RoomAccountDataEventType,
31ce2453c82fatagen2026-09-24 13:07 UTC10
        room::member::StrippedRoomMemberEvent,
31ce2453c82fatagen2026-09-24 13:07 UTC11
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC12
    serde::Raw,
96fdf90aacd6atagen2026-09-08 08:24 UTC13
};
96fdf90aacd6atagen2026-09-08 08:24 UTC14
#[cfg(feature = "serde")]
96fdf90aacd6atagen2026-09-08 08:24 UTC15
use serde::{Deserialize, Serialize};
96fdf90aacd6atagen2026-09-08 08:24 UTC16
31ce2453c82fatagen2026-09-24 13:07 UTC17
/// every command answers exactly once through `ClientHandle::send` or `execute`.
31ce2453c82fatagen2026-09-24 13:07 UTC18
/// the event stream only ever carries state
31ce2453c82fatagen2026-09-24 13:07 UTC19
#[derive(Debug)]
96fdf90aacd6atagen2026-09-08 08:24 UTC20
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC21
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC22
pub enum Command {
96fdf90aacd6atagen2026-09-08 08:24 UTC23
    Account(AccountCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC24
    Room(RoomCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC25
    Timeline(TimelineCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC26
    Media(MediaCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC27
    Encryption(EncryptionCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC28
    Notification(NotificationCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC29
    Lifecycle(LifecycleCommand),
fa51490b6ae9atagen2026-10-24 08:41 UTC30
    Pack(PackCommand),
96fdf90aacd6atagen2026-09-08 08:24 UTC31
}
96fdf90aacd6atagen2026-09-08 08:24 UTC32
31ce2453c82fatagen2026-09-24 13:07 UTC33
#[derive(Debug)]
96fdf90aacd6atagen2026-09-08 08:24 UTC34
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC35
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC36
pub enum AccountCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC37
    Logout,
31ce2453c82fatagen2026-09-24 13:07 UTC38
    SetAccountData {
31ce2453c82fatagen2026-09-24 13:07 UTC39
        event_type: GlobalAccountDataEventType,
31ce2453c82fatagen2026-09-24 13:07 UTC40
        content: Raw<AnyGlobalAccountDataEventContent>,
31ce2453c82fatagen2026-09-24 13:07 UTC41
    },
31ce2453c82fatagen2026-09-24 13:07 UTC42
    SetDisplayName(Option<String>),
31ce2453c82fatagen2026-09-24 13:07 UTC43
    SetAvatar(Option<OwnedMxcUri>),
31ce2453c82fatagen2026-09-24 13:07 UTC44
    /// uploads the image and points the profile at it, same byte cap as any upload
31ce2453c82fatagen2026-09-24 13:07 UTC45
    UploadAvatar {
31ce2453c82fatagen2026-09-24 13:07 UTC46
        mimetype: String,
31ce2453c82fatagen2026-09-24 13:07 UTC47
        bytes: Vec<u8>,
31ce2453c82fatagen2026-09-24 13:07 UTC48
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC49
    /// unencrypted, answers with `CommandOutput::Mxc`. same byte cap as any upload
9bd34e25bb86atagen2026-10-24 07:23 UTC50
    UploadMedia {
9bd34e25bb86atagen2026-10-24 07:23 UTC51
        mimetype: String,
9bd34e25bb86atagen2026-10-24 07:23 UTC52
        bytes: Vec<u8>,
9bd34e25bb86atagen2026-10-24 07:23 UTC53
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC54
    IgnoreUser(OwnedUserId),
9bd34e25bb86atagen2026-10-24 07:23 UTC55
    UnignoreUser(OwnedUserId),
9bd34e25bb86atagen2026-10-24 07:23 UTC56
    /// writes msc3230 orders so these spaces sort in exactly this sequence, touching as few as it can
9bd34e25bb86atagen2026-10-24 07:23 UTC57
    ReorderSpaces(Vec<OwnedRoomId>),
96fdf90aacd6atagen2026-09-08 08:24 UTC58
    RenameDevice {
96fdf90aacd6atagen2026-09-08 08:24 UTC59
        device_id: OwnedDeviceId,
96fdf90aacd6atagen2026-09-08 08:24 UTC60
        display_name: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC61
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC62
    DeleteDevices {
96fdf90aacd6atagen2026-09-08 08:24 UTC63
        device_ids: Vec<OwnedDeviceId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC64
        auth: Option<crate::InteractiveAuth>,
96fdf90aacd6atagen2026-09-08 08:24 UTC65
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC66
}
96fdf90aacd6atagen2026-09-08 08:24 UTC67
31ce2453c82fatagen2026-09-24 13:07 UTC68
#[derive(Clone, Debug)]
96fdf90aacd6atagen2026-09-08 08:24 UTC69
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC70
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC71
pub enum RoomCommand {
31ce2453c82fatagen2026-09-24 13:07 UTC72
    /// the snapshot turns up as `Event::TimelineReset`. opening an open room sends a fresh one
96fdf90aacd6atagen2026-09-08 08:24 UTC73
    Open(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC74
    Close(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC75
    Join {
96fdf90aacd6atagen2026-09-08 08:24 UTC76
        room: OwnedRoomOrAliasId,
96fdf90aacd6atagen2026-09-08 08:24 UTC77
        via: Vec<OwnedServerName>,
96fdf90aacd6atagen2026-09-08 08:24 UTC78
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC79
    Leave(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC80
    Forget(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC81
    AcceptInvite(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC82
    RejectInvite(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC83
    InviteUser {
96fdf90aacd6atagen2026-09-08 08:24 UTC84
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC85
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC86
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC87
    KickUser {
96fdf90aacd6atagen2026-09-08 08:24 UTC88
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC89
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC90
        reason: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC91
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC92
    BanUser {
96fdf90aacd6atagen2026-09-08 08:24 UTC93
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC94
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC95
        reason: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC96
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC97
    UnbanUser {
96fdf90aacd6atagen2026-09-08 08:24 UTC98
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC99
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC100
        reason: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC101
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC102
    SetPowerLevels {
96fdf90aacd6atagen2026-09-08 08:24 UTC103
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC104
        changes: PowerLevelChanges,
96fdf90aacd6atagen2026-09-08 08:24 UTC105
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC106
    SetUserPowerLevel {
96fdf90aacd6atagen2026-09-08 08:24 UTC107
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC108
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC109
        level: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC110
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC111
    /// muting drops them below what sending a message takes, unmuting puts a muted user back
9bd34e25bb86atagen2026-10-24 07:23 UTC112
    /// at users_default and leaves anyone else alone
9bd34e25bb86atagen2026-10-24 07:23 UTC113
    MuteUser {
9bd34e25bb86atagen2026-10-24 07:23 UTC114
        room_id: OwnedRoomId,
9bd34e25bb86atagen2026-10-24 07:23 UTC115
        user_id: OwnedUserId,
9bd34e25bb86atagen2026-10-24 07:23 UTC116
        muted: bool,
9bd34e25bb86atagen2026-10-24 07:23 UTC117
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC118
    /// adding m.favourite drops m.lowpriority, the way Element does
9bd34e25bb86atagen2026-10-24 07:23 UTC119
    SetFavourite {
9bd34e25bb86atagen2026-10-24 07:23 UTC120
        room_id: OwnedRoomId,
9bd34e25bb86atagen2026-10-24 07:23 UTC121
        favourite: bool,
9bd34e25bb86atagen2026-10-24 07:23 UTC122
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC123
    /// your name in one room. None goes back to your global name
9bd34e25bb86atagen2026-10-24 07:23 UTC124
    SetOwnDisplayName {
9bd34e25bb86atagen2026-10-24 07:23 UTC125
        room_id: OwnedRoomId,
9bd34e25bb86atagen2026-10-24 07:23 UTC126
        name: Option<String>,
9bd34e25bb86atagen2026-10-24 07:23 UTC127
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC128
    /// your avatar in one room. None goes back to your global avatar
9bd34e25bb86atagen2026-10-24 07:23 UTC129
    SetOwnAvatar {
9bd34e25bb86atagen2026-10-24 07:23 UTC130
        room_id: OwnedRoomId,
9bd34e25bb86atagen2026-10-24 07:23 UTC131
        avatar: Option<OwnedMxcUri>,
9bd34e25bb86atagen2026-10-24 07:23 UTC132
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC133
    Create(CreateRoomOptions),
fa9114fcf75fatagen2026-09-24 12:51 UTC134
    /// hands back the existing dm if there is one
96fdf90aacd6atagen2026-09-08 08:24 UTC135
    CreateDirect(OwnedUserId),
96fdf90aacd6atagen2026-09-08 08:24 UTC136
    CancelSend {
96fdf90aacd6atagen2026-09-08 08:24 UTC137
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC138
        transaction_id: OwnedTransactionId,
96fdf90aacd6atagen2026-09-08 08:24 UTC139
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC140
    RetrySend {
96fdf90aacd6atagen2026-09-08 08:24 UTC141
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC142
        transaction_id: OwnedTransactionId,
96fdf90aacd6atagen2026-09-08 08:24 UTC143
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC144
    SetTyping {
96fdf90aacd6atagen2026-09-08 08:24 UTC145
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC146
        typing: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC147
    },
38c4caecdb3datagen2026-09-26 13:35 UTC148
    /// the key work a send into an encrypted room would otherwise start with, done now.
38c4caecdb3datagen2026-09-26 13:35 UTC149
    /// nothing in a plain room, and a second ask joins the first
38c4caecdb3datagen2026-09-26 13:35 UTC150
    PrepareToSend(OwnedRoomId),
31ce2453c82fatagen2026-09-24 13:07 UTC151
    SetAccountData {
31ce2453c82fatagen2026-09-24 13:07 UTC152
        room_id: OwnedRoomId,
31ce2453c82fatagen2026-09-24 13:07 UTC153
        event_type: RoomAccountDataEventType,
31ce2453c82fatagen2026-09-24 13:07 UTC154
        content: Raw<AnyRoomAccountDataEventContent>,
31ce2453c82fatagen2026-09-24 13:07 UTC155
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC156
}
96fdf90aacd6atagen2026-09-08 08:24 UTC157
96fdf90aacd6atagen2026-09-08 08:24 UTC158
#[derive(Clone, Debug, Default, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC159
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC160
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC161
pub struct CreateRoomOptions {
96fdf90aacd6atagen2026-09-08 08:24 UTC162
    pub name: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC163
    pub topic: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC164
    pub alias_localpart: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC165
    pub invite: Vec<OwnedUserId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC166
    pub direct: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC167
    pub visibility: RoomVisibility,
96fdf90aacd6atagen2026-09-08 08:24 UTC168
    pub preset: Option<RoomPreset>,
96fdf90aacd6atagen2026-09-08 08:24 UTC169
}
96fdf90aacd6atagen2026-09-08 08:24 UTC170
31ce2453c82fatagen2026-09-24 13:07 UTC171
impl CreateRoomOptions {
31ce2453c82fatagen2026-09-24 13:07 UTC172
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC173
    pub fn with_name(mut self, name: impl Into<String>) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC174
        self.name = Some(name.into());
31ce2453c82fatagen2026-09-24 13:07 UTC175
        self
31ce2453c82fatagen2026-09-24 13:07 UTC176
    }
31ce2453c82fatagen2026-09-24 13:07 UTC177
31ce2453c82fatagen2026-09-24 13:07 UTC178
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC179
    pub fn with_topic(mut self, topic: impl Into<String>) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC180
        self.topic = Some(topic.into());
31ce2453c82fatagen2026-09-24 13:07 UTC181
        self
31ce2453c82fatagen2026-09-24 13:07 UTC182
    }
31ce2453c82fatagen2026-09-24 13:07 UTC183
31ce2453c82fatagen2026-09-24 13:07 UTC184
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC185
    pub fn with_alias_localpart(mut self, localpart: impl Into<String>) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC186
        self.alias_localpart = Some(localpart.into());
31ce2453c82fatagen2026-09-24 13:07 UTC187
        self
31ce2453c82fatagen2026-09-24 13:07 UTC188
    }
31ce2453c82fatagen2026-09-24 13:07 UTC189
31ce2453c82fatagen2026-09-24 13:07 UTC190
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC191
    pub fn with_invite(mut self, invite: impl IntoIterator<Item = OwnedUserId>) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC192
        self.invite = invite.into_iter().collect();
31ce2453c82fatagen2026-09-24 13:07 UTC193
        self
31ce2453c82fatagen2026-09-24 13:07 UTC194
    }
31ce2453c82fatagen2026-09-24 13:07 UTC195
31ce2453c82fatagen2026-09-24 13:07 UTC196
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC197
    pub const fn with_direct(mut self, direct: bool) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC198
        self.direct = direct;
31ce2453c82fatagen2026-09-24 13:07 UTC199
        self
31ce2453c82fatagen2026-09-24 13:07 UTC200
    }
31ce2453c82fatagen2026-09-24 13:07 UTC201
31ce2453c82fatagen2026-09-24 13:07 UTC202
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC203
    pub const fn with_visibility(mut self, visibility: RoomVisibility) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC204
        self.visibility = visibility;
31ce2453c82fatagen2026-09-24 13:07 UTC205
        self
31ce2453c82fatagen2026-09-24 13:07 UTC206
    }
31ce2453c82fatagen2026-09-24 13:07 UTC207
31ce2453c82fatagen2026-09-24 13:07 UTC208
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC209
    pub const fn with_preset(mut self, preset: RoomPreset) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC210
        self.preset = Some(preset);
31ce2453c82fatagen2026-09-24 13:07 UTC211
        self
31ce2453c82fatagen2026-09-24 13:07 UTC212
    }
31ce2453c82fatagen2026-09-24 13:07 UTC213
}
31ce2453c82fatagen2026-09-24 13:07 UTC214
96fdf90aacd6atagen2026-09-08 08:24 UTC215
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC216
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC217
pub enum RoomVisibility {
96fdf90aacd6atagen2026-09-08 08:24 UTC218
    #[default]
96fdf90aacd6atagen2026-09-08 08:24 UTC219
    Private,
96fdf90aacd6atagen2026-09-08 08:24 UTC220
    Public,
96fdf90aacd6atagen2026-09-08 08:24 UTC221
}
96fdf90aacd6atagen2026-09-08 08:24 UTC222
96fdf90aacd6atagen2026-09-08 08:24 UTC223
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC224
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC225
pub enum RoomPreset {
96fdf90aacd6atagen2026-09-08 08:24 UTC226
    PrivateChat,
96fdf90aacd6atagen2026-09-08 08:24 UTC227
    TrustedPrivateChat,
96fdf90aacd6atagen2026-09-08 08:24 UTC228
    PublicChat,
96fdf90aacd6atagen2026-09-08 08:24 UTC229
}
96fdf90aacd6atagen2026-09-08 08:24 UTC230
96fdf90aacd6atagen2026-09-08 08:24 UTC231
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC232
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC233
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC234
pub enum TimelineCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC235
    OpenThread {
96fdf90aacd6atagen2026-09-08 08:24 UTC236
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC237
        root_event_id: OwnedEventId,
96fdf90aacd6atagen2026-09-08 08:24 UTC238
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC239
    CloseThread {
96fdf90aacd6atagen2026-09-08 08:24 UTC240
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC241
        root_event_id: OwnedEventId,
96fdf90aacd6atagen2026-09-08 08:24 UTC242
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC243
    /// Re-emit an authoritative reset for an open room or thread without
96fdf90aacd6atagen2026-09-08 08:24 UTC244
    /// closing it. The reset arrives before this command's terminal result.
96fdf90aacd6atagen2026-09-08 08:24 UTC245
    Resync {
96fdf90aacd6atagen2026-09-08 08:24 UTC246
        timeline_id: TimelineId,
96fdf90aacd6atagen2026-09-08 08:24 UTC247
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC248
    Paginate {
96fdf90aacd6atagen2026-09-08 08:24 UTC249
        timeline_id: TimelineId,
96fdf90aacd6atagen2026-09-08 08:24 UTC250
        limit: u16,
96fdf90aacd6atagen2026-09-08 08:24 UTC251
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC252
    Send {
96fdf90aacd6atagen2026-09-08 08:24 UTC253
        timeline_id: TimelineId,
96fdf90aacd6atagen2026-09-08 08:24 UTC254
        content: MessageContent,
96fdf90aacd6atagen2026-09-08 08:24 UTC255
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC256
    Edit {
96fdf90aacd6atagen2026-09-08 08:24 UTC257
        timeline_id: TimelineId,
960ac0721079atagen2026-09-25 00:24 UTC258
        target: EventRef,
96fdf90aacd6atagen2026-09-08 08:24 UTC259
        content: MessageEditContent,
96fdf90aacd6atagen2026-09-08 08:24 UTC260
    },
960ac0721079atagen2026-09-25 00:24 UTC261
    /// redacting your own unsent message just cancels it
96fdf90aacd6atagen2026-09-08 08:24 UTC262
    Redact {
96fdf90aacd6atagen2026-09-08 08:24 UTC263
        timeline_id: TimelineId,
960ac0721079atagen2026-09-25 00:24 UTC264
        target: EventRef,
96fdf90aacd6atagen2026-09-08 08:24 UTC265
        reason: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC266
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC267
    ToggleReaction {
96fdf90aacd6atagen2026-09-08 08:24 UTC268
        timeline_id: TimelineId,
960ac0721079atagen2026-09-25 00:24 UTC269
        target: EventRef,
96fdf90aacd6atagen2026-09-08 08:24 UTC270
        key: String,
8fa8a7cde89catagen2026-10-08 12:39 UTC271
        /// a custom emote's shortcode, sent along so clients without the pack can label it
8fa8a7cde89catagen2026-10-08 12:39 UTC272
        shortcode: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC273
    },
fa9114fcf75fatagen2026-09-24 12:51 UTC274
    /// works on a closed room too, it just can't refuse to move the marker backwards
fa9114fcf75fatagen2026-09-24 12:51 UTC275
    MarkRead {
fa9114fcf75fatagen2026-09-24 12:51 UTC276
        timeline_id: TimelineId,
fa9114fcf75fatagen2026-09-24 12:51 UTC277
        event_id: OwnedEventId,
fa9114fcf75fatagen2026-09-24 12:51 UTC278
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC279
}
96fdf90aacd6atagen2026-09-08 08:24 UTC280
96fdf90aacd6atagen2026-09-08 08:24 UTC281
impl TimelineCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC282
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC283
    pub const fn room_id(&self) -> &OwnedRoomId {
96fdf90aacd6atagen2026-09-08 08:24 UTC284
        match self {
96fdf90aacd6atagen2026-09-08 08:24 UTC285
            Self::OpenThread { room_id, .. } | Self::CloseThread { room_id, .. } => room_id,
96fdf90aacd6atagen2026-09-08 08:24 UTC286
            Self::Resync { timeline_id }
96fdf90aacd6atagen2026-09-08 08:24 UTC287
            | Self::Paginate { timeline_id, .. }
96fdf90aacd6atagen2026-09-08 08:24 UTC288
            | Self::Send { timeline_id, .. }
96fdf90aacd6atagen2026-09-08 08:24 UTC289
            | Self::Edit { timeline_id, .. }
96fdf90aacd6atagen2026-09-08 08:24 UTC290
            | Self::Redact { timeline_id, .. }
fa9114fcf75fatagen2026-09-24 12:51 UTC291
            | Self::ToggleReaction { timeline_id, .. }
fa9114fcf75fatagen2026-09-24 12:51 UTC292
            | Self::MarkRead { timeline_id, .. } => timeline_id.room_id(),
96fdf90aacd6atagen2026-09-08 08:24 UTC293
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC294
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC295
96fdf90aacd6atagen2026-09-08 08:24 UTC296
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC297
    pub const fn timeline_id(&self) -> Option<&TimelineId> {
96fdf90aacd6atagen2026-09-08 08:24 UTC298
        match self {
96fdf90aacd6atagen2026-09-08 08:24 UTC299
            Self::OpenThread { .. } | Self::CloseThread { .. } => None,
96fdf90aacd6atagen2026-09-08 08:24 UTC300
            Self::Resync { timeline_id }
96fdf90aacd6atagen2026-09-08 08:24 UTC301
            | Self::Paginate { timeline_id, .. }
96fdf90aacd6atagen2026-09-08 08:24 UTC302
            | Self::Send { timeline_id, .. }
96fdf90aacd6atagen2026-09-08 08:24 UTC303
            | Self::Edit { timeline_id, .. }
96fdf90aacd6atagen2026-09-08 08:24 UTC304
            | Self::Redact { timeline_id, .. }
fa9114fcf75fatagen2026-09-24 12:51 UTC305
            | Self::ToggleReaction { timeline_id, .. }
fa9114fcf75fatagen2026-09-24 12:51 UTC306
            | Self::MarkRead { timeline_id, .. } => Some(timeline_id),
96fdf90aacd6atagen2026-09-08 08:24 UTC307
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC308
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC309
}
96fdf90aacd6atagen2026-09-08 08:24 UTC310
96fdf90aacd6atagen2026-09-08 08:24 UTC311
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC312
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC313
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC314
pub enum TimelineId {
96fdf90aacd6atagen2026-09-08 08:24 UTC315
    Room(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC316
    Thread {
96fdf90aacd6atagen2026-09-08 08:24 UTC317
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC318
        root_event_id: OwnedEventId,
96fdf90aacd6atagen2026-09-08 08:24 UTC319
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC320
}
96fdf90aacd6atagen2026-09-08 08:24 UTC321
96fdf90aacd6atagen2026-09-08 08:24 UTC322
impl TimelineId {
96fdf90aacd6atagen2026-09-08 08:24 UTC323
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC324
    pub const fn room_id(&self) -> &OwnedRoomId {
96fdf90aacd6atagen2026-09-08 08:24 UTC325
        match self {
96fdf90aacd6atagen2026-09-08 08:24 UTC326
            Self::Room(room_id) | Self::Thread { room_id, .. } => room_id,
96fdf90aacd6atagen2026-09-08 08:24 UTC327
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC328
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC329
96fdf90aacd6atagen2026-09-08 08:24 UTC330
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC331
    pub fn thread(room_id: OwnedRoomId, root_event_id: OwnedEventId) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC332
        Self::Thread {
96fdf90aacd6atagen2026-09-08 08:24 UTC333
            room_id,
96fdf90aacd6atagen2026-09-08 08:24 UTC334
            root_event_id,
96fdf90aacd6atagen2026-09-08 08:24 UTC335
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC336
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC337
96fdf90aacd6atagen2026-09-08 08:24 UTC338
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC339
    pub fn thread_root(&self) -> Option<&OwnedEventId> {
96fdf90aacd6atagen2026-09-08 08:24 UTC340
        match self {
96fdf90aacd6atagen2026-09-08 08:24 UTC341
            Self::Room(_) => None,
96fdf90aacd6atagen2026-09-08 08:24 UTC342
            Self::Thread { root_event_id, .. } => Some(root_event_id),
96fdf90aacd6atagen2026-09-08 08:24 UTC343
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC344
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC345
}
96fdf90aacd6atagen2026-09-08 08:24 UTC346
96fdf90aacd6atagen2026-09-08 08:24 UTC347
impl From<OwnedRoomId> for TimelineId {
96fdf90aacd6atagen2026-09-08 08:24 UTC348
    fn from(room_id: OwnedRoomId) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC349
        Self::Room(room_id)
96fdf90aacd6atagen2026-09-08 08:24 UTC350
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC351
}
96fdf90aacd6atagen2026-09-08 08:24 UTC352
96fdf90aacd6atagen2026-09-08 08:24 UTC353
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC354
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC355
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC356
pub enum MediaCommand {
31ce2453c82fatagen2026-09-24 13:07 UTC357
    /// succeeds once the send queue has it. progress and failure arrive as events
31ce2453c82fatagen2026-09-24 13:07 UTC358
    Upload(AttachmentUpload),
96fdf90aacd6atagen2026-09-08 08:24 UTC359
}
96fdf90aacd6atagen2026-09-08 08:24 UTC360
fa51490b6ae9atagen2026-10-24 08:41 UTC361
/// msc2545 pack editing. edits read the server's copy and keep keys macltok doesn't model
fa51490b6ae9atagen2026-10-24 08:41 UTC362
#[derive(Clone, Debug, Eq, PartialEq)]
fa51490b6ae9atagen2026-10-24 08:41 UTC363
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
fa51490b6ae9atagen2026-10-24 08:41 UTC364
#[non_exhaustive]
fa51490b6ae9atagen2026-10-24 08:41 UTC365
pub enum PackCommand {
fa51490b6ae9atagen2026-10-24 08:41 UTC366
    /// body defaults to the shortcode
fa51490b6ae9atagen2026-10-24 08:41 UTC367
    SendSticker {
fa51490b6ae9atagen2026-10-24 08:41 UTC368
        room_id: OwnedRoomId,
fa51490b6ae9atagen2026-10-24 08:41 UTC369
        pack_id: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC370
        shortcode: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC371
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC372
    /// fails if the state key already holds a pack
fa51490b6ae9atagen2026-10-24 08:41 UTC373
    CreateRoomPack {
fa51490b6ae9atagen2026-10-24 08:41 UTC374
        room_id: OwnedRoomId,
fa51490b6ae9atagen2026-10-24 08:41 UTC375
        state_key: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC376
        display_name: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC377
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC378
    /// empties the content, which is all deleting a pack can mean
fa51490b6ae9atagen2026-10-24 08:41 UTC379
    Delete(ImagePackSource),
fa51490b6ae9atagen2026-10-24 08:41 UTC380
    SetMeta {
fa51490b6ae9atagen2026-10-24 08:41 UTC381
        pack: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC382
        display_name: Patch<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC383
        avatar: Patch<OwnedMxcUri>,
fa51490b6ae9atagen2026-10-24 08:41 UTC384
        usage: Patch<Vec<PackUsage>>,
fa51490b6ae9atagen2026-10-24 08:41 UTC385
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC386
    /// adds or replaces by shortcode. a replaced image keeps its info unless the url changed
fa51490b6ae9atagen2026-10-24 08:41 UTC387
    PutImage {
fa51490b6ae9atagen2026-10-24 08:41 UTC388
        pack: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC389
        shortcode: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC390
        mxc: OwnedMxcUri,
fa51490b6ae9atagen2026-10-24 08:41 UTC391
        body: Option<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC392
        usage: Option<Vec<PackUsage>>,
fa51490b6ae9atagen2026-10-24 08:41 UTC393
        info: Option<PackImageInfo>,
fa51490b6ae9atagen2026-10-24 08:41 UTC394
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC395
    /// fails if `to` is taken
fa51490b6ae9atagen2026-10-24 08:41 UTC396
    RenameImage {
fa51490b6ae9atagen2026-10-24 08:41 UTC397
        pack: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC398
        from: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC399
        to: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC400
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC401
    RemoveImage {
fa51490b6ae9atagen2026-10-24 08:41 UTC402
        pack: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC403
        shortcode: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC404
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC405
    SetEnabledEverywhere {
fa51490b6ae9atagen2026-10-24 08:41 UTC406
        room_id: OwnedRoomId,
fa51490b6ae9atagen2026-10-24 08:41 UTC407
        state_key: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC408
        enabled: bool,
fa51490b6ae9atagen2026-10-24 08:41 UTC409
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC410
    /// answers with `CommandOutput::Mxc`, the same uri when it already lives on your homeserver
fa51490b6ae9atagen2026-10-24 08:41 UTC411
    Rehost(OwnedMxcUri),
fa51490b6ae9atagen2026-10-24 08:41 UTC412
    /// the rest answer with `CommandOutput::Cloned`. clashes get `-2`, `-3` and so on
fa51490b6ae9atagen2026-10-24 08:41 UTC413
    CloneImage {
fa51490b6ae9atagen2026-10-24 08:41 UTC414
        from_pack: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC415
        shortcode: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC416
        to: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC417
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC418
    CloneSticker {
fa51490b6ae9atagen2026-10-24 08:41 UTC419
        room_id: OwnedRoomId,
fa51490b6ae9atagen2026-10-24 08:41 UTC420
        event_id: OwnedEventId,
fa51490b6ae9atagen2026-10-24 08:41 UTC421
        to: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC422
        shortcode: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC423
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC424
    /// makes the room pack if its state key is free, else merges. images that can't be
fa51490b6ae9atagen2026-10-24 08:41 UTC425
    /// fetched are skipped and listed, the rest are written
fa51490b6ae9atagen2026-10-24 08:41 UTC426
    ClonePack {
fa51490b6ae9atagen2026-10-24 08:41 UTC427
        from_pack: String,
fa51490b6ae9atagen2026-10-24 08:41 UTC428
        to: ImagePackSource,
fa51490b6ae9atagen2026-10-24 08:41 UTC429
        display_name: Option<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC430
    },
fa51490b6ae9atagen2026-10-24 08:41 UTC431
}
fa51490b6ae9atagen2026-10-24 08:41 UTC432
fa51490b6ae9atagen2026-10-24 08:41 UTC433
#[derive(Clone, Debug, Default, Eq, PartialEq)]
fa51490b6ae9atagen2026-10-24 08:41 UTC434
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
fa51490b6ae9atagen2026-10-24 08:41 UTC435
pub enum Patch<T> {
fa51490b6ae9atagen2026-10-24 08:41 UTC436
    #[default]
fa51490b6ae9atagen2026-10-24 08:41 UTC437
    Keep,
fa51490b6ae9atagen2026-10-24 08:41 UTC438
    Clear,
fa51490b6ae9atagen2026-10-24 08:41 UTC439
    Set(T),
fa51490b6ae9atagen2026-10-24 08:41 UTC440
}
fa51490b6ae9atagen2026-10-24 08:41 UTC441
fa51490b6ae9atagen2026-10-24 08:41 UTC442
#[derive(Clone, Debug, Default, Eq, PartialEq)]
fa51490b6ae9atagen2026-10-24 08:41 UTC443
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
fa51490b6ae9atagen2026-10-24 08:41 UTC444
#[non_exhaustive]
fa51490b6ae9atagen2026-10-24 08:41 UTC445
pub struct PackImageInfo {
fa51490b6ae9atagen2026-10-24 08:41 UTC446
    pub mimetype: Option<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC447
    pub size_bytes: Option<u64>,
fa51490b6ae9atagen2026-10-24 08:41 UTC448
    pub width: Option<u64>,
fa51490b6ae9atagen2026-10-24 08:41 UTC449
    pub height: Option<u64>,
fa51490b6ae9atagen2026-10-24 08:41 UTC450
}
fa51490b6ae9atagen2026-10-24 08:41 UTC451
fa51490b6ae9atagen2026-10-24 08:41 UTC452
impl PackImageInfo {
fa51490b6ae9atagen2026-10-24 08:41 UTC453
    #[must_use]
fa51490b6ae9atagen2026-10-24 08:41 UTC454
    pub fn new(
fa51490b6ae9atagen2026-10-24 08:41 UTC455
        mimetype: Option<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC456
        size_bytes: Option<u64>,
fa51490b6ae9atagen2026-10-24 08:41 UTC457
        width: Option<u64>,
fa51490b6ae9atagen2026-10-24 08:41 UTC458
        height: Option<u64>,
fa51490b6ae9atagen2026-10-24 08:41 UTC459
    ) -> Self {
fa51490b6ae9atagen2026-10-24 08:41 UTC460
        Self {
fa51490b6ae9atagen2026-10-24 08:41 UTC461
            mimetype,
fa51490b6ae9atagen2026-10-24 08:41 UTC462
            size_bytes,
fa51490b6ae9atagen2026-10-24 08:41 UTC463
            width,
fa51490b6ae9atagen2026-10-24 08:41 UTC464
            height,
fa51490b6ae9atagen2026-10-24 08:41 UTC465
        }
fa51490b6ae9atagen2026-10-24 08:41 UTC466
    }
fa51490b6ae9atagen2026-10-24 08:41 UTC467
}
fa51490b6ae9atagen2026-10-24 08:41 UTC468
96fdf90aacd6atagen2026-09-08 08:24 UTC469
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC470
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5a52012c9b1datagen2026-09-24 23:45 UTC471
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC472
pub struct AttachmentUpload {
96fdf90aacd6atagen2026-09-08 08:24 UTC473
    pub timeline_id: TimelineId,
96fdf90aacd6atagen2026-09-08 08:24 UTC474
    pub filename: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC475
    pub mimetype: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC476
    pub bytes: Vec<u8>,
0827ad2d24e9atagen2026-10-23 06:49 UTC477
    pub caption: Option<RichText>,
0827ad2d24e9atagen2026-10-23 06:49 UTC478
    pub mentions: MessageMentions,
0827ad2d24e9atagen2026-10-23 06:49 UTC479
    pub reply_to: Option<OwnedEventId>,
0827ad2d24e9atagen2026-10-23 06:49 UTC480
    pub notify_replied_to: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC481
    pub details: Option<UploadDetails>,
96fdf90aacd6atagen2026-09-08 08:24 UTC482
    pub thumbnail: Option<UploadThumbnail>,
96fdf90aacd6atagen2026-09-08 08:24 UTC483
}
96fdf90aacd6atagen2026-09-08 08:24 UTC484
96fdf90aacd6atagen2026-09-08 08:24 UTC485
impl AttachmentUpload {
96fdf90aacd6atagen2026-09-08 08:24 UTC486
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC487
    pub fn new(
96fdf90aacd6atagen2026-09-08 08:24 UTC488
        timeline_id: impl Into<TimelineId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC489
        filename: impl Into<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC490
        mimetype: impl Into<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC491
        bytes: Vec<u8>,
96fdf90aacd6atagen2026-09-08 08:24 UTC492
    ) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC493
        Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC494
            timeline_id: timeline_id.into(),
96fdf90aacd6atagen2026-09-08 08:24 UTC495
            filename: filename.into(),
96fdf90aacd6atagen2026-09-08 08:24 UTC496
            mimetype: mimetype.into(),
96fdf90aacd6atagen2026-09-08 08:24 UTC497
            bytes,
96fdf90aacd6atagen2026-09-08 08:24 UTC498
            caption: None,
0827ad2d24e9atagen2026-10-23 06:49 UTC499
            mentions: MessageMentions::default(),
0827ad2d24e9atagen2026-10-23 06:49 UTC500
            reply_to: None,
0827ad2d24e9atagen2026-10-23 06:49 UTC501
            notify_replied_to: true,
96fdf90aacd6atagen2026-09-08 08:24 UTC502
            details: None,
96fdf90aacd6atagen2026-09-08 08:24 UTC503
            thumbnail: None,
96fdf90aacd6atagen2026-09-08 08:24 UTC504
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC505
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC506
}
96fdf90aacd6atagen2026-09-08 08:24 UTC507
96fdf90aacd6atagen2026-09-08 08:24 UTC508
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC509
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC510
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC511
pub enum UploadDetails {
96fdf90aacd6atagen2026-09-08 08:24 UTC512
    Image {
96fdf90aacd6atagen2026-09-08 08:24 UTC513
        width: Option<u32>,
96fdf90aacd6atagen2026-09-08 08:24 UTC514
        height: Option<u32>,
96fdf90aacd6atagen2026-09-08 08:24 UTC515
        blurhash: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC516
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC517
    Video {
96fdf90aacd6atagen2026-09-08 08:24 UTC518
        width: Option<u32>,
96fdf90aacd6atagen2026-09-08 08:24 UTC519
        height: Option<u32>,
96fdf90aacd6atagen2026-09-08 08:24 UTC520
        duration_ms: Option<u64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC521
        blurhash: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC522
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC523
    Audio {
96fdf90aacd6atagen2026-09-08 08:24 UTC524
        duration_ms: Option<u64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC525
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC526
    Voice {
96fdf90aacd6atagen2026-09-08 08:24 UTC527
        duration_ms: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC528
        waveform: Vec<u16>,
96fdf90aacd6atagen2026-09-08 08:24 UTC529
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC530
    File,
96fdf90aacd6atagen2026-09-08 08:24 UTC531
}
96fdf90aacd6atagen2026-09-08 08:24 UTC532
96fdf90aacd6atagen2026-09-08 08:24 UTC533
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC534
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC535
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC536
pub struct UploadThumbnail {
96fdf90aacd6atagen2026-09-08 08:24 UTC537
    pub bytes: Vec<u8>,
96fdf90aacd6atagen2026-09-08 08:24 UTC538
    pub mimetype: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC539
    pub width: u32,
96fdf90aacd6atagen2026-09-08 08:24 UTC540
    pub height: u32,
96fdf90aacd6atagen2026-09-08 08:24 UTC541
}
96fdf90aacd6atagen2026-09-08 08:24 UTC542
31ce2453c82fatagen2026-09-24 13:07 UTC543
impl UploadThumbnail {
31ce2453c82fatagen2026-09-24 13:07 UTC544
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC545
    pub fn new(bytes: Vec<u8>, mimetype: impl Into<String>, width: u32, height: u32) -> Self {
31ce2453c82fatagen2026-09-24 13:07 UTC546
        Self {
31ce2453c82fatagen2026-09-24 13:07 UTC547
            bytes,
31ce2453c82fatagen2026-09-24 13:07 UTC548
            mimetype: mimetype.into(),
31ce2453c82fatagen2026-09-24 13:07 UTC549
            width,
31ce2453c82fatagen2026-09-24 13:07 UTC550
            height,
31ce2453c82fatagen2026-09-24 13:07 UTC551
        }
31ce2453c82fatagen2026-09-24 13:07 UTC552
    }
31ce2453c82fatagen2026-09-24 13:07 UTC553
}
31ce2453c82fatagen2026-09-24 13:07 UTC554
96fdf90aacd6atagen2026-09-08 08:24 UTC555
#[derive(Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC556
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC557
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC558
pub enum EncryptionCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC559
    Recover(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC560
    CreateKeyBackup,
96fdf90aacd6atagen2026-09-08 08:24 UTC561
    EnableKeyBackup,
96fdf90aacd6atagen2026-09-08 08:24 UTC562
    DisableKeyBackup { delete_from_server: bool },
96fdf90aacd6atagen2026-09-08 08:24 UTC563
    RecoverKeyBackup(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC564
    StartVerification(VerificationTarget),
96fdf90aacd6atagen2026-09-08 08:24 UTC565
    Verify(VerificationAction),
96fdf90aacd6atagen2026-09-08 08:24 UTC566
}
96fdf90aacd6atagen2026-09-08 08:24 UTC567
96fdf90aacd6atagen2026-09-08 08:24 UTC568
impl fmt::Debug for EncryptionCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC569
    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
96fdf90aacd6atagen2026-09-08 08:24 UTC570
        match self {
96fdf90aacd6atagen2026-09-08 08:24 UTC571
            Self::Recover(_) => formatter.debug_tuple("Recover").field(&"...").finish(),
96fdf90aacd6atagen2026-09-08 08:24 UTC572
            Self::CreateKeyBackup => formatter.write_str("CreateKeyBackup"),
96fdf90aacd6atagen2026-09-08 08:24 UTC573
            Self::EnableKeyBackup => formatter.write_str("EnableKeyBackup"),
96fdf90aacd6atagen2026-09-08 08:24 UTC574
            Self::DisableKeyBackup { delete_from_server } => formatter
96fdf90aacd6atagen2026-09-08 08:24 UTC575
                .debug_struct("DisableKeyBackup")
96fdf90aacd6atagen2026-09-08 08:24 UTC576
                .field("delete_from_server", delete_from_server)
96fdf90aacd6atagen2026-09-08 08:24 UTC577
                .finish(),
96fdf90aacd6atagen2026-09-08 08:24 UTC578
            Self::RecoverKeyBackup(_) => formatter
96fdf90aacd6atagen2026-09-08 08:24 UTC579
                .debug_tuple("RecoverKeyBackup")
96fdf90aacd6atagen2026-09-08 08:24 UTC580
                .field(&"...")
96fdf90aacd6atagen2026-09-08 08:24 UTC581
                .finish(),
96fdf90aacd6atagen2026-09-08 08:24 UTC582
            Self::StartVerification(target) => formatter
96fdf90aacd6atagen2026-09-08 08:24 UTC583
                .debug_tuple("StartVerification")
96fdf90aacd6atagen2026-09-08 08:24 UTC584
                .field(target)
96fdf90aacd6atagen2026-09-08 08:24 UTC585
                .finish(),
96fdf90aacd6atagen2026-09-08 08:24 UTC586
            Self::Verify(action) => formatter.debug_tuple("Verify").field(action).finish(),
96fdf90aacd6atagen2026-09-08 08:24 UTC587
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC588
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC589
}
96fdf90aacd6atagen2026-09-08 08:24 UTC590
96fdf90aacd6atagen2026-09-08 08:24 UTC591
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC592
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC593
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC594
pub enum NotificationCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC595
    SetRoomMode {
96fdf90aacd6atagen2026-09-08 08:24 UTC596
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC597
        mode: RoomNotificationMode,
96fdf90aacd6atagen2026-09-08 08:24 UTC598
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC599
    ResetRoomMode(OwnedRoomId),
96fdf90aacd6atagen2026-09-08 08:24 UTC600
    SetDefaultMode {
96fdf90aacd6atagen2026-09-08 08:24 UTC601
        encrypted: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC602
        one_to_one: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC603
        mode: RoomNotificationMode,
96fdf90aacd6atagen2026-09-08 08:24 UTC604
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC605
    AddKeyword(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC606
    RemoveKeyword(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC607
}
96fdf90aacd6atagen2026-09-08 08:24 UTC608
96fdf90aacd6atagen2026-09-08 08:24 UTC609
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC610
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC611
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC612
pub enum LifecycleCommand {
96fdf90aacd6atagen2026-09-08 08:24 UTC613
    Shutdown,
96fdf90aacd6atagen2026-09-08 08:24 UTC614
}
96fdf90aacd6atagen2026-09-08 08:24 UTC615
31ce2453c82fatagen2026-09-24 13:07 UTC616
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC617
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC618
#[non_exhaustive]
31ce2453c82fatagen2026-09-24 13:07 UTC619
pub enum CommandOutput {
31ce2453c82fatagen2026-09-24 13:07 UTC620
    Done,
31ce2453c82fatagen2026-09-24 13:07 UTC621
    Room(OwnedRoomId),
9bd34e25bb86atagen2026-10-24 07:23 UTC622
    Mxc(OwnedMxcUri),
fa51490b6ae9atagen2026-10-24 08:41 UTC623
    /// the shortcodes the copies ended up under, and the ones that couldn't be fetched
fa51490b6ae9atagen2026-10-24 08:41 UTC624
    Cloned {
fa51490b6ae9atagen2026-10-24 08:41 UTC625
        shortcodes: Vec<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC626
        skipped: Vec<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC627
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC628
}
96fdf90aacd6atagen2026-09-08 08:24 UTC629
96fdf90aacd6atagen2026-09-08 08:24 UTC630
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC631
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC632
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC633
pub enum MessageContent {
96fdf90aacd6atagen2026-09-08 08:24 UTC634
    Text {
96fdf90aacd6atagen2026-09-08 08:24 UTC635
        content: RichText,
96fdf90aacd6atagen2026-09-08 08:24 UTC636
        mentions: MessageMentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC637
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC638
    Emote {
96fdf90aacd6atagen2026-09-08 08:24 UTC639
        content: RichText,
96fdf90aacd6atagen2026-09-08 08:24 UTC640
        mentions: MessageMentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC641
    },
9bd34e25bb86atagen2026-10-24 07:23 UTC642
    /// m.notice, for bots. clients render it muted and never answer it automatically
9bd34e25bb86atagen2026-10-24 07:23 UTC643
    Notice {
9bd34e25bb86atagen2026-10-24 07:23 UTC644
        content: RichText,
9bd34e25bb86atagen2026-10-24 07:23 UTC645
        mentions: MessageMentions,
9bd34e25bb86atagen2026-10-24 07:23 UTC646
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC647
    Reply {
96fdf90aacd6atagen2026-09-08 08:24 UTC648
        event_id: OwnedEventId,
96fdf90aacd6atagen2026-09-08 08:24 UTC649
        content: RichText,
96fdf90aacd6atagen2026-09-08 08:24 UTC650
        mentions: MessageMentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC651
        notify_replied_to: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC652
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC653
}
96fdf90aacd6atagen2026-09-08 08:24 UTC654
96fdf90aacd6atagen2026-09-08 08:24 UTC655
impl MessageContent {
96fdf90aacd6atagen2026-09-08 08:24 UTC656
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC657
    pub fn text(body: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC658
        Self::Text {
96fdf90aacd6atagen2026-09-08 08:24 UTC659
            content: RichText::plain(body),
96fdf90aacd6atagen2026-09-08 08:24 UTC660
            mentions: MessageMentions::default(),
96fdf90aacd6atagen2026-09-08 08:24 UTC661
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC662
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC663
96fdf90aacd6atagen2026-09-08 08:24 UTC664
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC665
    pub fn html(body: impl Into<String>, formatted_body: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC666
        Self::Text {
96fdf90aacd6atagen2026-09-08 08:24 UTC667
            content: RichText::html(body, formatted_body),
96fdf90aacd6atagen2026-09-08 08:24 UTC668
            mentions: MessageMentions::default(),
96fdf90aacd6atagen2026-09-08 08:24 UTC669
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC670
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC671
96fdf90aacd6atagen2026-09-08 08:24 UTC672
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC673
    pub fn emote(content: RichText, mentions: MessageMentions) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC674
        Self::Emote { content, mentions }
96fdf90aacd6atagen2026-09-08 08:24 UTC675
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC676
96fdf90aacd6atagen2026-09-08 08:24 UTC677
    #[must_use]
9bd34e25bb86atagen2026-10-24 07:23 UTC678
    pub fn notice(content: RichText, mentions: MessageMentions) -> Self {
9bd34e25bb86atagen2026-10-24 07:23 UTC679
        Self::Notice { content, mentions }
9bd34e25bb86atagen2026-10-24 07:23 UTC680
    }
9bd34e25bb86atagen2026-10-24 07:23 UTC681
9bd34e25bb86atagen2026-10-24 07:23 UTC682
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC683
    pub fn reply(event_id: OwnedEventId, content: RichText, mentions: MessageMentions) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC684
        Self::Reply {
96fdf90aacd6atagen2026-09-08 08:24 UTC685
            event_id,
96fdf90aacd6atagen2026-09-08 08:24 UTC686
            content,
96fdf90aacd6atagen2026-09-08 08:24 UTC687
            mentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC688
            notify_replied_to: true,
96fdf90aacd6atagen2026-09-08 08:24 UTC689
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC690
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC691
96fdf90aacd6atagen2026-09-08 08:24 UTC692
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC693
    pub fn reply_without_notification(
96fdf90aacd6atagen2026-09-08 08:24 UTC694
        event_id: OwnedEventId,
96fdf90aacd6atagen2026-09-08 08:24 UTC695
        content: RichText,
96fdf90aacd6atagen2026-09-08 08:24 UTC696
        mentions: MessageMentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC697
    ) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC698
        Self::Reply {
96fdf90aacd6atagen2026-09-08 08:24 UTC699
            event_id,
96fdf90aacd6atagen2026-09-08 08:24 UTC700
            content,
96fdf90aacd6atagen2026-09-08 08:24 UTC701
            mentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC702
            notify_replied_to: false,
96fdf90aacd6atagen2026-09-08 08:24 UTC703
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC704
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC705
}
96fdf90aacd6atagen2026-09-08 08:24 UTC706
96fdf90aacd6atagen2026-09-08 08:24 UTC707
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC708
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC709
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC710
pub enum MessageEditContent {
96fdf90aacd6atagen2026-09-08 08:24 UTC711
    Text {
96fdf90aacd6atagen2026-09-08 08:24 UTC712
        content: RichText,
96fdf90aacd6atagen2026-09-08 08:24 UTC713
        mentions: MessageMentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC714
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC715
    Emote {
96fdf90aacd6atagen2026-09-08 08:24 UTC716
        content: RichText,
96fdf90aacd6atagen2026-09-08 08:24 UTC717
        mentions: MessageMentions,
96fdf90aacd6atagen2026-09-08 08:24 UTC718
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC719
}
96fdf90aacd6atagen2026-09-08 08:24 UTC720
96fdf90aacd6atagen2026-09-08 08:24 UTC721
impl MessageEditContent {
96fdf90aacd6atagen2026-09-08 08:24 UTC722
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC723
    pub fn text(body: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC724
        Self::Text {
96fdf90aacd6atagen2026-09-08 08:24 UTC725
            content: RichText::plain(body),
96fdf90aacd6atagen2026-09-08 08:24 UTC726
            mentions: MessageMentions::default(),
96fdf90aacd6atagen2026-09-08 08:24 UTC727
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC728
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC729
96fdf90aacd6atagen2026-09-08 08:24 UTC730
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC731
    pub fn html(body: impl Into<String>, formatted_body: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC732
        Self::Text {
96fdf90aacd6atagen2026-09-08 08:24 UTC733
            content: RichText::html(body, formatted_body),
96fdf90aacd6atagen2026-09-08 08:24 UTC734
            mentions: MessageMentions::default(),
96fdf90aacd6atagen2026-09-08 08:24 UTC735
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC736
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC737
96fdf90aacd6atagen2026-09-08 08:24 UTC738
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC739
    pub fn emote(content: RichText, mentions: MessageMentions) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC740
        Self::Emote { content, mentions }
96fdf90aacd6atagen2026-09-08 08:24 UTC741
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC742
}
96fdf90aacd6atagen2026-09-08 08:24 UTC743
96fdf90aacd6atagen2026-09-08 08:24 UTC744
#[derive(Clone, Debug, Default, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC745
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC746
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC747
pub struct RichText {
96fdf90aacd6atagen2026-09-08 08:24 UTC748
    pub body: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC749
    pub formatted_body: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC750
}
96fdf90aacd6atagen2026-09-08 08:24 UTC751
96fdf90aacd6atagen2026-09-08 08:24 UTC752
impl RichText {
96fdf90aacd6atagen2026-09-08 08:24 UTC753
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC754
    pub fn plain(body: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC755
        Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC756
            body: body.into(),
96fdf90aacd6atagen2026-09-08 08:24 UTC757
            formatted_body: None,
96fdf90aacd6atagen2026-09-08 08:24 UTC758
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC759
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC760
96fdf90aacd6atagen2026-09-08 08:24 UTC761
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC762
    pub fn html(body: impl Into<String>, formatted_body: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC763
        Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC764
            body: body.into(),
96fdf90aacd6atagen2026-09-08 08:24 UTC765
            formatted_body: Some(formatted_body.into()),
96fdf90aacd6atagen2026-09-08 08:24 UTC766
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC767
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC768
}
96fdf90aacd6atagen2026-09-08 08:24 UTC769
96fdf90aacd6atagen2026-09-08 08:24 UTC770
#[derive(Clone, Debug, Default, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC771
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC772
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC773
pub struct MessageMentions {
96fdf90aacd6atagen2026-09-08 08:24 UTC774
    pub user_ids: Vec<OwnedUserId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC775
    pub room: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC776
}
96fdf90aacd6atagen2026-09-08 08:24 UTC777
96fdf90aacd6atagen2026-09-08 08:24 UTC778
impl MessageMentions {
96fdf90aacd6atagen2026-09-08 08:24 UTC779
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC780
    pub fn with_user_ids(user_ids: impl IntoIterator<Item = OwnedUserId>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC781
        Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC782
            user_ids: user_ids.into_iter().collect(),
96fdf90aacd6atagen2026-09-08 08:24 UTC783
            room: false,
96fdf90aacd6atagen2026-09-08 08:24 UTC784
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC785
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC786
96fdf90aacd6atagen2026-09-08 08:24 UTC787
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC788
    pub fn room() -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC789
        Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC790
            user_ids: Vec::new(),
96fdf90aacd6atagen2026-09-08 08:24 UTC791
            room: true,
96fdf90aacd6atagen2026-09-08 08:24 UTC792
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC793
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC794
}
96fdf90aacd6atagen2026-09-08 08:24 UTC795
96fdf90aacd6atagen2026-09-08 08:24 UTC796
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC797
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC798
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC799
pub enum Event {
96fdf90aacd6atagen2026-09-08 08:24 UTC800
    ConnectionChanged(ConnectionState),
96fdf90aacd6atagen2026-09-08 08:24 UTC801
    Authenticated {
96fdf90aacd6atagen2026-09-08 08:24 UTC802
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC803
    },
f12377bce9b9atagen2026-09-26 12:32 UTC804
    /// the tokens rotated. with a `SessionStore` the record is already saved by now,
f12377bce9b9atagen2026-09-26 12:32 UTC805
    /// without one persist a fresh `ClientHandle::session_record()` atomically
96fdf90aacd6atagen2026-09-08 08:24 UTC806
    SessionTokensChanged,
f12377bce9b9atagen2026-09-26 12:32 UTC807
    /// the rotated tokens didn't reach the `SessionStore`, so the saved record may not
f12377bce9b9atagen2026-09-26 12:32 UTC808
    /// restore. the engine tries again on the next rotation
f12377bce9b9atagen2026-09-26 12:32 UTC809
    SessionSaveFailed {
f12377bce9b9atagen2026-09-26 12:32 UTC810
        message: String,
f12377bce9b9atagen2026-09-26 12:32 UTC811
    },
7c26fad34822atagen2026-09-26 09:41 UTC812
    /// the server stopped honouring our token and the engine stops. a soft logout
7c26fad34822atagen2026-09-26 09:41 UTC813
    /// names the device to log in again as, keeping the store. otherwise the record
7c26fad34822atagen2026-09-26 09:41 UTC814
    /// and the store are both dead
fa9114fcf75fatagen2026-09-24 12:51 UTC815
    SessionAccessRejected {
7c26fad34822atagen2026-09-26 09:41 UTC816
        soft_logout: Option<OwnedDeviceId>,
fa9114fcf75fatagen2026-09-24 12:51 UTC817
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC818
    NotificationSettingsChanged,
96fdf90aacd6atagen2026-09-08 08:24 UTC819
    VerificationTargetChanged(VerificationTarget),
96fdf90aacd6atagen2026-09-08 08:24 UTC820
    RoomsChanged,
17e042fbc331atagen2026-10-08 12:39 UTC821
    /// an image pack came, went or changed somewhere. ask `image_packs` again
17e042fbc331atagen2026-10-08 12:39 UTC822
    ImagePacksChanged,
31ce2453c82fatagen2026-09-24 13:07 UTC823
    /// replaces whatever you had for this timeline. every diff after it applies to it
96fdf90aacd6atagen2026-09-08 08:24 UTC824
    TimelineReset {
96fdf90aacd6atagen2026-09-08 08:24 UTC825
        timeline_id: TimelineId,
d5d8097c3afdatagen2026-09-26 09:33 UTC826
        items: Vector<TimelineItem>,
96fdf90aacd6atagen2026-09-08 08:24 UTC827
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC828
    TimelineChanged {
96fdf90aacd6atagen2026-09-08 08:24 UTC829
        timeline_id: TimelineId,
96fdf90aacd6atagen2026-09-08 08:24 UTC830
        diffs: Vec<TimelineDiff>,
96fdf90aacd6atagen2026-09-08 08:24 UTC831
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC832
    HistoryChanged {
96fdf90aacd6atagen2026-09-08 08:24 UTC833
        timeline_id: TimelineId,
96fdf90aacd6atagen2026-09-08 08:24 UTC834
        state: HistoryState,
96fdf90aacd6atagen2026-09-08 08:24 UTC835
    },
0bfa3f46f0beatagen2026-09-26 09:12 UTC836
    /// the timeline was closed, or its room was left, and nothing more comes for it
0bfa3f46f0beatagen2026-09-26 09:12 UTC837
    /// until another `TimelineReset`
0bfa3f46f0beatagen2026-09-26 09:12 UTC838
    TimelineClosed {
0bfa3f46f0beatagen2026-09-26 09:12 UTC839
        timeline_id: TimelineId,
0bfa3f46f0beatagen2026-09-26 09:12 UTC840
    },
0bfa3f46f0beatagen2026-09-26 09:12 UTC841
    /// a room that stops being watched says so with an empty `users`
96fdf90aacd6atagen2026-09-08 08:24 UTC842
    TypingChanged(TypingState),
96fdf90aacd6atagen2026-09-08 08:24 UTC843
    MediaUploadProgress {
96fdf90aacd6atagen2026-09-08 08:24 UTC844
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC845
        transaction_id: OwnedTransactionId,
96fdf90aacd6atagen2026-09-08 08:24 UTC846
        uploaded_bytes: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC847
        total_bytes: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC848
        complete: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC849
    },
0bfa3f46f0beatagen2026-09-26 09:12 UTC850
    /// not the end of it. `will_retry` means the send queue has another go by itself,
0bfa3f46f0beatagen2026-09-26 09:12 UTC851
    /// otherwise it waits for `retry_send` or `cancel_send`
96fdf90aacd6atagen2026-09-08 08:24 UTC852
    MediaUploadFailed {
96fdf90aacd6atagen2026-09-08 08:24 UTC853
        room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC854
        transaction_id: OwnedTransactionId,
31ce2453c82fatagen2026-09-24 13:07 UTC855
        kind: crate::ErrorKind,
0bfa3f46f0beatagen2026-09-26 09:12 UTC856
        will_retry: bool,
0bfa3f46f0beatagen2026-09-26 09:12 UTC857
    },
7cf348521204atagen2026-09-26 12:28 UTC858
    /// an upload that turned up in a progress or failure event gets exactly one of
7cf348521204atagen2026-09-26 12:28 UTC859
    /// these while the engine runs, and nothing about it after. stopping ends
7cf348521204atagen2026-09-26 12:28 UTC860
    /// nothing, `Stopped` covers whatever is still going and the sdk resumes it next run
0bfa3f46f0beatagen2026-09-26 09:12 UTC861
    MediaUploadFinished {
0bfa3f46f0beatagen2026-09-26 09:12 UTC862
        room_id: OwnedRoomId,
0bfa3f46f0beatagen2026-09-26 09:12 UTC863
        transaction_id: OwnedTransactionId,
0bfa3f46f0beatagen2026-09-26 09:12 UTC864
        outcome: UploadOutcome,
96fdf90aacd6atagen2026-09-08 08:24 UTC865
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC866
    EncryptionChanged(EncryptionState),
96fdf90aacd6atagen2026-09-08 08:24 UTC867
    VerificationChanged(VerificationState),
fa9114fcf75fatagen2026-09-24 12:51 UTC868
    /// logout went through and the engine stops. delete the record and the store
96fdf90aacd6atagen2026-09-08 08:24 UTC869
    LoggedOut,
96fdf90aacd6atagen2026-09-08 08:24 UTC870
    Failed(EngineFailure),
fa9114fcf75fatagen2026-09-24 12:51 UTC871
    /// always the last event. keep the saved record unless `LoggedOut` or a
5a52012c9b1datagen2026-09-24 23:45 UTC872
    /// hard `SessionAccessRejected` came first. commands still in flight answer `Interrupted`
96fdf90aacd6atagen2026-09-08 08:24 UTC873
    Stopped,
96fdf90aacd6atagen2026-09-08 08:24 UTC874
}
96fdf90aacd6atagen2026-09-08 08:24 UTC875
0bfa3f46f0beatagen2026-09-26 09:12 UTC876
#[derive(Clone, Debug, Eq, PartialEq)]
0bfa3f46f0beatagen2026-09-26 09:12 UTC877
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
0bfa3f46f0beatagen2026-09-26 09:12 UTC878
#[non_exhaustive]
0bfa3f46f0beatagen2026-09-26 09:12 UTC879
pub enum UploadOutcome {
0bfa3f46f0beatagen2026-09-26 09:12 UTC880
    Sent {
0bfa3f46f0beatagen2026-09-26 09:12 UTC881
        event_id: OwnedEventId,
0bfa3f46f0beatagen2026-09-26 09:12 UTC882
    },
0bfa3f46f0beatagen2026-09-26 09:12 UTC883
    Cancelled,
0bfa3f46f0beatagen2026-09-26 09:12 UTC884
    /// its room was forgotten, and the queue with it
0bfa3f46f0beatagen2026-09-26 09:12 UTC885
    RoomForgotten,
0bfa3f46f0beatagen2026-09-26 09:12 UTC886
    /// the sdk's update channel overflowed while it ended, so whether it was sent is unknown
0bfa3f46f0beatagen2026-09-26 09:12 UTC887
    Missed,
0bfa3f46f0beatagen2026-09-26 09:12 UTC888
}
0bfa3f46f0beatagen2026-09-26 09:12 UTC889
fe4133dbcd47atagen2026-09-26 09:05 UTC890
/// why `Engine::run` came back, when nothing went wrong
fe4133dbcd47atagen2026-09-26 09:05 UTC891
#[derive(Clone, Debug, Eq, PartialEq)]
fe4133dbcd47atagen2026-09-26 09:05 UTC892
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
fe4133dbcd47atagen2026-09-26 09:05 UTC893
#[non_exhaustive]
fe4133dbcd47atagen2026-09-26 09:05 UTC894
pub enum Termination {
fe4133dbcd47atagen2026-09-26 09:05 UTC895
    ShutDown,
fe4133dbcd47atagen2026-09-26 09:05 UTC896
    /// every `ClientHandle` was dropped, so nobody could have asked for anything else
fe4133dbcd47atagen2026-09-26 09:05 UTC897
    HandlesDropped,
fe4133dbcd47atagen2026-09-26 09:05 UTC898
    LoggedOut,
fe4133dbcd47atagen2026-09-26 09:05 UTC899
    /// the server rejected our token for good
fe4133dbcd47atagen2026-09-26 09:05 UTC900
    AccessRevoked,
fe4133dbcd47atagen2026-09-26 09:05 UTC901
    /// the server wants this device to log in again, and its e2ee keys live in the store
fe4133dbcd47atagen2026-09-26 09:05 UTC902
    SoftLoggedOut {
fe4133dbcd47atagen2026-09-26 09:05 UTC903
        device_id: OwnedDeviceId,
fe4133dbcd47atagen2026-09-26 09:05 UTC904
    },
fe4133dbcd47atagen2026-09-26 09:05 UTC905
}
fe4133dbcd47atagen2026-09-26 09:05 UTC906
fe4133dbcd47atagen2026-09-26 09:05 UTC907
impl Termination {
fe4133dbcd47atagen2026-09-26 09:05 UTC908
    #[must_use]
fe4133dbcd47atagen2026-09-26 09:05 UTC909
    pub const fn retain(&self) -> Retain {
fe4133dbcd47atagen2026-09-26 09:05 UTC910
        match self {
fe4133dbcd47atagen2026-09-26 09:05 UTC911
            Self::ShutDown | Self::HandlesDropped => Retain::RecordAndStore,
fe4133dbcd47atagen2026-09-26 09:05 UTC912
            Self::SoftLoggedOut { .. } => Retain::Store,
fe4133dbcd47atagen2026-09-26 09:05 UTC913
            Self::LoggedOut | Self::AccessRevoked => Retain::Nothing,
fe4133dbcd47atagen2026-09-26 09:05 UTC914
        }
fe4133dbcd47atagen2026-09-26 09:05 UTC915
    }
fe4133dbcd47atagen2026-09-26 09:05 UTC916
}
fe4133dbcd47atagen2026-09-26 09:05 UTC917
fe4133dbcd47atagen2026-09-26 09:05 UTC918
/// what's still worth keeping of the saved record and the store
fe4133dbcd47atagen2026-09-26 09:05 UTC919
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
fe4133dbcd47atagen2026-09-26 09:05 UTC920
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
fe4133dbcd47atagen2026-09-26 09:05 UTC921
pub enum Retain {
fe4133dbcd47atagen2026-09-26 09:05 UTC922
    RecordAndStore,
6f1d6591c10datagen2026-09-26 09:52 UTC923
    /// keep the store and a record naming the device to log in again as
fe4133dbcd47atagen2026-09-26 09:05 UTC924
    Store,
fe4133dbcd47atagen2026-09-26 09:05 UTC925
    Nothing,
fe4133dbcd47atagen2026-09-26 09:05 UTC926
}
fe4133dbcd47atagen2026-09-26 09:05 UTC927
96fdf90aacd6atagen2026-09-08 08:24 UTC928
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC929
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC930
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC931
pub enum ConnectionState {
96fdf90aacd6atagen2026-09-08 08:24 UTC932
    Idle,
96fdf90aacd6atagen2026-09-08 08:24 UTC933
    Connecting,
96fdf90aacd6atagen2026-09-08 08:24 UTC934
    Online,
96fdf90aacd6atagen2026-09-08 08:24 UTC935
    Offline,
96fdf90aacd6atagen2026-09-08 08:24 UTC936
    Stopped,
96fdf90aacd6atagen2026-09-08 08:24 UTC937
}
96fdf90aacd6atagen2026-09-08 08:24 UTC938
96fdf90aacd6atagen2026-09-08 08:24 UTC939
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC940
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC941
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC942
pub struct RoomSummary {
96fdf90aacd6atagen2026-09-08 08:24 UTC943
    pub room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC944
    pub name: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC945
    pub membership: RoomMembership,
96fdf90aacd6atagen2026-09-08 08:24 UTC946
    pub unread_messages: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC947
    pub unread_mentions: u64,
5a52012c9b1datagen2026-09-24 23:45 UTC948
    /// unread events the push rules said to notify about, which is neither of the above
5a52012c9b1datagen2026-09-24 23:45 UTC949
    pub unread_notifications: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC950
    pub encrypted: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC951
    pub space: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC952
    pub direct: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC953
    pub favourite: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC954
    pub low_priority: bool,
5d2974de5826atagen2026-10-08 11:29 UTC955
    pub avatar: Option<MediaId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC956
    pub latest_event_timestamp_ms: Option<u64>,
31ce2453c82fatagen2026-09-24 13:07 UTC957
    pub latest_event: Option<LatestEvent>,
96fdf90aacd6atagen2026-09-08 08:24 UTC958
    pub notification_mode: Option<RoomNotificationMode>,
96fdf90aacd6atagen2026-09-08 08:24 UTC959
    pub notification_mode_custom: bool,
31ce2453c82fatagen2026-09-24 13:07 UTC960
    pub topic: Option<String>,
31ce2453c82fatagen2026-09-24 13:07 UTC961
    pub canonical_alias: Option<OwnedRoomAliasId>,
31ce2453c82fatagen2026-09-24 13:07 UTC962
    pub joined_members: u64,
31ce2453c82fatagen2026-09-24 13:07 UTC963
    pub invited_members: u64,
31ce2453c82fatagen2026-09-24 13:07 UTC964
    /// who a nameless room gets named after
31ce2453c82fatagen2026-09-24 13:07 UTC965
    pub heroes: Vec<RoomHero>,
31ce2453c82fatagen2026-09-24 13:07 UTC966
    /// set once the room has been upgraded, this is where everyone went
31ce2453c82fatagen2026-09-24 13:07 UTC967
    pub successor: Option<OwnedRoomId>,
31ce2453c82fatagen2026-09-24 13:07 UTC968
    pub inviter: Option<OwnedUserId>,
31ce2453c82fatagen2026-09-24 13:07 UTC969
    /// joined spaces that list this room as a child
31ce2453c82fatagen2026-09-24 13:07 UTC970
    pub parent_spaces: Vec<OwnedRoomId>,
31ce2453c82fatagen2026-09-24 13:07 UTC971
    /// for a space, the children it lists, joined or not
31ce2453c82fatagen2026-09-24 13:07 UTC972
    pub children: Vec<OwnedRoomId>,
9bd34e25bb86atagen2026-10-24 07:23 UTC973
    /// a space's msc3230 order. ordered spaces sort first by (order, room id), the rest by room id
9bd34e25bb86atagen2026-10-24 07:23 UTC974
    pub space_order: Option<String>,
fa51490b6ae9atagen2026-10-24 08:41 UTC975
    /// you can send im.ponies.room_emotes here, so you can make and edit its packs
fa51490b6ae9atagen2026-10-24 08:41 UTC976
    pub can_edit_packs: bool,
31ce2453c82fatagen2026-09-24 13:07 UTC977
}
31ce2453c82fatagen2026-09-24 13:07 UTC978
31ce2453c82fatagen2026-09-24 13:07 UTC979
#[derive(Clone, Debug, Eq, PartialEq)]
31ce2453c82fatagen2026-09-24 13:07 UTC980
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC981
#[non_exhaustive]
31ce2453c82fatagen2026-09-24 13:07 UTC982
pub struct RoomHero {
31ce2453c82fatagen2026-09-24 13:07 UTC983
    pub user_id: OwnedUserId,
31ce2453c82fatagen2026-09-24 13:07 UTC984
    pub display_name: Option<String>,
5d2974de5826atagen2026-10-08 11:29 UTC985
    pub avatar: Option<MediaId>,
31ce2453c82fatagen2026-09-24 13:07 UTC986
}
31ce2453c82fatagen2026-09-24 13:07 UTC987
5a52012c9b1datagen2026-09-24 23:45 UTC988
/// enough for a room list preview line. `kind` and `body` are only set for messages,
5a52012c9b1datagen2026-09-24 23:45 UTC989
/// and an edit shows its new text
31ce2453c82fatagen2026-09-24 13:07 UTC990
#[derive(Clone, Debug, Eq, PartialEq)]
31ce2453c82fatagen2026-09-24 13:07 UTC991
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC992
#[non_exhaustive]
31ce2453c82fatagen2026-09-24 13:07 UTC993
pub struct LatestEvent {
31ce2453c82fatagen2026-09-24 13:07 UTC994
    pub sender: Option<OwnedUserId>,
5a52012c9b1datagen2026-09-24 23:45 UTC995
    pub kind: Option<MessageKind>,
31ce2453c82fatagen2026-09-24 13:07 UTC996
    pub body: Option<String>,
31ce2453c82fatagen2026-09-24 13:07 UTC997
    pub timestamp_ms: Option<u64>,
31ce2453c82fatagen2026-09-24 13:07 UTC998
    pub send_state: SendState,
31ce2453c82fatagen2026-09-24 13:07 UTC999
}
31ce2453c82fatagen2026-09-24 13:07 UTC1000
31ce2453c82fatagen2026-09-24 13:07 UTC1001
#[derive(Clone, Debug, Eq, PartialEq)]
31ce2453c82fatagen2026-09-24 13:07 UTC1002
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC1003
#[non_exhaustive]
31ce2453c82fatagen2026-09-24 13:07 UTC1004
pub struct Profile {
31ce2453c82fatagen2026-09-24 13:07 UTC1005
    pub user_id: OwnedUserId,
31ce2453c82fatagen2026-09-24 13:07 UTC1006
    pub display_name: Option<String>,
5d2974de5826atagen2026-10-08 11:29 UTC1007
    pub avatar: Option<MediaId>,
31ce2453c82fatagen2026-09-24 13:07 UTC1008
}
31ce2453c82fatagen2026-09-24 13:07 UTC1009
31ce2453c82fatagen2026-09-24 13:07 UTC1010
/// one room in a space's hierarchy, as the server describes it, which may be a room you're not in
31ce2453c82fatagen2026-09-24 13:07 UTC1011
#[derive(Clone, Debug, Eq, PartialEq)]
31ce2453c82fatagen2026-09-24 13:07 UTC1012
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC1013
#[non_exhaustive]
31ce2453c82fatagen2026-09-24 13:07 UTC1014
pub struct SpaceChild {
31ce2453c82fatagen2026-09-24 13:07 UTC1015
    pub room_id: OwnedRoomId,
31ce2453c82fatagen2026-09-24 13:07 UTC1016
    pub name: String,
31ce2453c82fatagen2026-09-24 13:07 UTC1017
    pub topic: Option<String>,
5d2974de5826atagen2026-10-08 11:29 UTC1018
    pub avatar: Option<MediaId>,
31ce2453c82fatagen2026-09-24 13:07 UTC1019
    pub canonical_alias: Option<OwnedRoomAliasId>,
31ce2453c82fatagen2026-09-24 13:07 UTC1020
    pub joined_members: u64,
31ce2453c82fatagen2026-09-24 13:07 UTC1021
    pub space: bool,
31ce2453c82fatagen2026-09-24 13:07 UTC1022
    pub children_count: u64,
31ce2453c82fatagen2026-09-24 13:07 UTC1023
    pub membership: Option<RoomMembership>,
31ce2453c82fatagen2026-09-24 13:07 UTC1024
    pub via: Vec<OwnedServerName>,
31ce2453c82fatagen2026-09-24 13:07 UTC1025
    pub suggested: bool,
31ce2453c82fatagen2026-09-24 13:07 UTC1026
    pub world_readable: Option<bool>,
31ce2453c82fatagen2026-09-24 13:07 UTC1027
    pub guest_can_join: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1028
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1029
96fdf90aacd6atagen2026-09-08 08:24 UTC1030
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1031
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC1032
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1033
pub enum RoomNotificationMode {
96fdf90aacd6atagen2026-09-08 08:24 UTC1034
    AllMessages,
96fdf90aacd6atagen2026-09-08 08:24 UTC1035
    MentionsAndKeywordsOnly,
96fdf90aacd6atagen2026-09-08 08:24 UTC1036
    Mute,
96fdf90aacd6atagen2026-09-08 08:24 UTC1037
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1038
96fdf90aacd6atagen2026-09-08 08:24 UTC1039
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1040
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1041
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1042
pub struct RoomNotificationSettings {
96fdf90aacd6atagen2026-09-08 08:24 UTC1043
    pub mode: RoomNotificationMode,
96fdf90aacd6atagen2026-09-08 08:24 UTC1044
    pub custom: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1045
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1046
96fdf90aacd6atagen2026-09-08 08:24 UTC1047
#[derive(Clone, Debug)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1048
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1049
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1050
pub enum PushNotificationStatus {
96fdf90aacd6atagen2026-09-08 08:24 UTC1051
    Event(Box<PushNotification>),
96fdf90aacd6atagen2026-09-08 08:24 UTC1052
    NotFound,
96fdf90aacd6atagen2026-09-08 08:24 UTC1053
    FilteredOut,
96fdf90aacd6atagen2026-09-08 08:24 UTC1054
    Redacted,
96fdf90aacd6atagen2026-09-08 08:24 UTC1055
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1056
96fdf90aacd6atagen2026-09-08 08:24 UTC1057
#[derive(Clone, Debug)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1058
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1059
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1060
pub struct PushNotification {
96fdf90aacd6atagen2026-09-08 08:24 UTC1061
    pub event_id: OwnedEventId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1062
    pub event: PushNotificationEvent,
96fdf90aacd6atagen2026-09-08 08:24 UTC1063
    pub sender: PushNotificationSender,
96fdf90aacd6atagen2026-09-08 08:24 UTC1064
    pub room: PushNotificationRoom,
96fdf90aacd6atagen2026-09-08 08:24 UTC1065
    pub noisy: Option<bool>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1066
    pub has_mention: Option<bool>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1067
    pub thread_id: Option<OwnedEventId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1068
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1069
96fdf90aacd6atagen2026-09-08 08:24 UTC1070
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1071
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1072
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1073
pub struct PushNotificationSender {
96fdf90aacd6atagen2026-09-08 08:24 UTC1074
    pub user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1075
    pub display_name: Option<String>,
5d2974de5826atagen2026-10-08 11:29 UTC1076
    pub avatar_url: Option<MediaId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1077
    pub name_ambiguous: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1078
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1079
96fdf90aacd6atagen2026-09-08 08:24 UTC1080
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1081
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1082
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1083
pub struct PushNotificationRoom {
96fdf90aacd6atagen2026-09-08 08:24 UTC1084
    pub room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1085
    pub name: String,
5d2974de5826atagen2026-10-08 11:29 UTC1086
    pub avatar_url: Option<MediaId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1087
    pub canonical_alias: Option<OwnedRoomAliasId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1088
    pub topic: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1089
    pub encrypted: Option<bool>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1090
    pub direct: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1091
    pub joined_members_count: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1092
    pub service_members: Vec<OwnedUserId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1093
    pub active_service_members_count: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1094
    pub space: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1095
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1096
96fdf90aacd6atagen2026-09-08 08:24 UTC1097
#[derive(Clone, Debug)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1098
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1099
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1100
pub enum PushNotificationEvent {
96fdf90aacd6atagen2026-09-08 08:24 UTC1101
    Timeline(Raw<AnySyncTimelineEvent>),
96fdf90aacd6atagen2026-09-08 08:24 UTC1102
    Invite(Raw<StrippedRoomMemberEvent>),
96fdf90aacd6atagen2026-09-08 08:24 UTC1103
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1104
96fdf90aacd6atagen2026-09-08 08:24 UTC1105
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1106
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1107
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1108
pub struct RoomPowerLevels {
96fdf90aacd6atagen2026-09-08 08:24 UTC1109
    pub ban: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1110
    pub invite: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1111
    pub kick: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1112
    pub redact: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1113
    pub events_default: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1114
    pub state_default: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1115
    pub users_default: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1116
    pub room_notification: i64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1117
    pub users: Vec<(OwnedUserId, i64)>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1118
    pub events: Vec<(String, i64)>,
5a52012c9b1datagen2026-09-24 23:45 UTC1119
    /// in rooms from version 12 the creators outrank everyone and aren't listed in `users`
5a52012c9b1datagen2026-09-24 23:45 UTC1120
    pub creators: Vec<OwnedUserId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1121
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1122
96fdf90aacd6atagen2026-09-08 08:24 UTC1123
#[derive(Clone, Debug, Default, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1124
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1125
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1126
pub struct PowerLevelChanges {
96fdf90aacd6atagen2026-09-08 08:24 UTC1127
    pub ban: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1128
    pub invite: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1129
    pub kick: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1130
    pub redact: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1131
    pub events_default: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1132
    pub state_default: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1133
    pub users_default: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1134
    pub room_notification: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1135
    pub room_name: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1136
    pub room_avatar: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1137
    pub room_topic: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1138
    pub space_child: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1139
    pub beacon: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1140
    pub beacon_info: Option<i64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1141
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1142
96fdf90aacd6atagen2026-09-08 08:24 UTC1143
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1144
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC1145
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1146
pub enum RoomMembership {
96fdf90aacd6atagen2026-09-08 08:24 UTC1147
    Joined,
96fdf90aacd6atagen2026-09-08 08:24 UTC1148
    Invited,
96fdf90aacd6atagen2026-09-08 08:24 UTC1149
    Left,
96fdf90aacd6atagen2026-09-08 08:24 UTC1150
    Knocked,
96fdf90aacd6atagen2026-09-08 08:24 UTC1151
    Banned,
96fdf90aacd6atagen2026-09-08 08:24 UTC1152
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1153
96fdf90aacd6atagen2026-09-08 08:24 UTC1154
#[derive(Clone, Debug, Default, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1155
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1156
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1157
pub struct RoomListFilter {
96fdf90aacd6atagen2026-09-08 08:24 UTC1158
    pub membership: Option<RoomMembership>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1159
    pub category: Option<RoomCategory>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1160
    pub favourite: Option<bool>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1161
    pub unread_only: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1162
    pub search: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1163
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1164
96fdf90aacd6atagen2026-09-08 08:24 UTC1165
impl RoomListFilter {
96fdf90aacd6atagen2026-09-08 08:24 UTC1166
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1167
    pub fn with_membership(mut self, membership: RoomMembership) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1168
        self.membership = Some(membership);
96fdf90aacd6atagen2026-09-08 08:24 UTC1169
        self
96fdf90aacd6atagen2026-09-08 08:24 UTC1170
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1171
96fdf90aacd6atagen2026-09-08 08:24 UTC1172
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1173
    pub fn with_category(mut self, category: RoomCategory) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1174
        self.category = Some(category);
96fdf90aacd6atagen2026-09-08 08:24 UTC1175
        self
96fdf90aacd6atagen2026-09-08 08:24 UTC1176
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1177
96fdf90aacd6atagen2026-09-08 08:24 UTC1178
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1179
    pub fn with_favourite(mut self, favourite: bool) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1180
        self.favourite = Some(favourite);
96fdf90aacd6atagen2026-09-08 08:24 UTC1181
        self
96fdf90aacd6atagen2026-09-08 08:24 UTC1182
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1183
96fdf90aacd6atagen2026-09-08 08:24 UTC1184
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1185
    pub const fn with_unread_only(mut self, unread_only: bool) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1186
        self.unread_only = unread_only;
96fdf90aacd6atagen2026-09-08 08:24 UTC1187
        self
96fdf90aacd6atagen2026-09-08 08:24 UTC1188
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1189
96fdf90aacd6atagen2026-09-08 08:24 UTC1190
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1191
    pub fn with_search(mut self, search: impl Into<String>) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1192
        self.search = Some(search.into());
96fdf90aacd6atagen2026-09-08 08:24 UTC1193
        self
96fdf90aacd6atagen2026-09-08 08:24 UTC1194
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1195
96fdf90aacd6atagen2026-09-08 08:24 UTC1196
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1197
    pub fn matches(&self, room: &RoomSummary) -> bool {
31ce2453c82fatagen2026-09-24 13:07 UTC1198
        self.matcher().matches(room)
31ce2453c82fatagen2026-09-24 13:07 UTC1199
    }
31ce2453c82fatagen2026-09-24 13:07 UTC1200
31ce2453c82fatagen2026-09-24 13:07 UTC1201
    /// lowercases the search once, for filtering a whole list
31ce2453c82fatagen2026-09-24 13:07 UTC1202
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC1203
    pub fn matcher(&self) -> RoomMatcher<'_> {
31ce2453c82fatagen2026-09-24 13:07 UTC1204
        RoomMatcher {
31ce2453c82fatagen2026-09-24 13:07 UTC1205
            filter: self,
31ce2453c82fatagen2026-09-24 13:07 UTC1206
            search: self.search.as_deref().map(str::to_lowercase),
31ce2453c82fatagen2026-09-24 13:07 UTC1207
        }
31ce2453c82fatagen2026-09-24 13:07 UTC1208
    }
31ce2453c82fatagen2026-09-24 13:07 UTC1209
}
31ce2453c82fatagen2026-09-24 13:07 UTC1210
31ce2453c82fatagen2026-09-24 13:07 UTC1211
#[derive(Debug)]
31ce2453c82fatagen2026-09-24 13:07 UTC1212
pub struct RoomMatcher<'a> {
31ce2453c82fatagen2026-09-24 13:07 UTC1213
    filter: &'a RoomListFilter,
31ce2453c82fatagen2026-09-24 13:07 UTC1214
    search: Option<String>,
31ce2453c82fatagen2026-09-24 13:07 UTC1215
}
31ce2453c82fatagen2026-09-24 13:07 UTC1216
31ce2453c82fatagen2026-09-24 13:07 UTC1217
impl RoomMatcher<'_> {
31ce2453c82fatagen2026-09-24 13:07 UTC1218
    #[must_use]
31ce2453c82fatagen2026-09-24 13:07 UTC1219
    pub fn matches(&self, room: &RoomSummary) -> bool {
31ce2453c82fatagen2026-09-24 13:07 UTC1220
        let filter = self.filter;
31ce2453c82fatagen2026-09-24 13:07 UTC1221
        filter
31ce2453c82fatagen2026-09-24 13:07 UTC1222
            .membership
96fdf90aacd6atagen2026-09-08 08:24 UTC1223
            .is_none_or(|membership| room.membership == membership)
31ce2453c82fatagen2026-09-24 13:07 UTC1224
            && filter.category.is_none_or(|category| match category {
96fdf90aacd6atagen2026-09-08 08:24 UTC1225
                RoomCategory::People => room.direct && !room.space,
96fdf90aacd6atagen2026-09-08 08:24 UTC1226
                RoomCategory::Rooms => !room.direct && !room.space,
96fdf90aacd6atagen2026-09-08 08:24 UTC1227
                RoomCategory::Spaces => room.space,
96fdf90aacd6atagen2026-09-08 08:24 UTC1228
            })
31ce2453c82fatagen2026-09-24 13:07 UTC1229
            && filter
96fdf90aacd6atagen2026-09-08 08:24 UTC1230
                .favourite
96fdf90aacd6atagen2026-09-08 08:24 UTC1231
                .is_none_or(|favourite| room.favourite == favourite)
31ce2453c82fatagen2026-09-24 13:07 UTC1232
            && (!filter.unread_only || room.unread_messages > 0 || room.unread_mentions > 0)
96fdf90aacd6atagen2026-09-08 08:24 UTC1233
            && self.search.as_ref().is_none_or(|search| {
31ce2453c82fatagen2026-09-24 13:07 UTC1234
                room.name.to_lowercase().contains(search)
31ce2453c82fatagen2026-09-24 13:07 UTC1235
                    || room.room_id.as_str().to_lowercase().contains(search)
96fdf90aacd6atagen2026-09-08 08:24 UTC1236
            })
96fdf90aacd6atagen2026-09-08 08:24 UTC1237
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1238
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1239
96fdf90aacd6atagen2026-09-08 08:24 UTC1240
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1241
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5a52012c9b1datagen2026-09-24 23:45 UTC1242
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1243
pub enum RoomCategory {
96fdf90aacd6atagen2026-09-08 08:24 UTC1244
    People,
96fdf90aacd6atagen2026-09-08 08:24 UTC1245
    Rooms,
96fdf90aacd6atagen2026-09-08 08:24 UTC1246
    Spaces,
96fdf90aacd6atagen2026-09-08 08:24 UTC1247
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1248
96fdf90aacd6atagen2026-09-08 08:24 UTC1249
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1250
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5a52012c9b1datagen2026-09-24 23:45 UTC1251
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1252
pub enum MemberFilter {
96fdf90aacd6atagen2026-09-08 08:24 UTC1253
    Active,
96fdf90aacd6atagen2026-09-08 08:24 UTC1254
    Joined,
96fdf90aacd6atagen2026-09-08 08:24 UTC1255
    Invited,
5a52012c9b1datagen2026-09-24 23:45 UTC1256
    Banned,
5a52012c9b1datagen2026-09-24 23:45 UTC1257
    Left,
96fdf90aacd6atagen2026-09-08 08:24 UTC1258
    All,
96fdf90aacd6atagen2026-09-08 08:24 UTC1259
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1260
96fdf90aacd6atagen2026-09-08 08:24 UTC1261
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1262
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1263
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1264
pub enum MemberMembership {
96fdf90aacd6atagen2026-09-08 08:24 UTC1265
    Joined,
96fdf90aacd6atagen2026-09-08 08:24 UTC1266
    Invited,
96fdf90aacd6atagen2026-09-08 08:24 UTC1267
    Left,
96fdf90aacd6atagen2026-09-08 08:24 UTC1268
    Knocked,
96fdf90aacd6atagen2026-09-08 08:24 UTC1269
    Banned,
96fdf90aacd6atagen2026-09-08 08:24 UTC1270
    Custom(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC1271
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1272
96fdf90aacd6atagen2026-09-08 08:24 UTC1273
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1274
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1275
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1276
pub struct MemberSummary {
96fdf90aacd6atagen2026-09-08 08:24 UTC1277
    pub user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1278
    pub name: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC1279
    pub display_name: Option<String>,
5d2974de5826atagen2026-10-08 11:29 UTC1280
    pub avatar: Option<MediaId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1281
    pub membership: MemberMembership,
96fdf90aacd6atagen2026-09-08 08:24 UTC1282
    pub own: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1283
    pub name_ambiguous: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1284
    pub ignored: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1285
    pub service: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1286
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1287
96fdf90aacd6atagen2026-09-08 08:24 UTC1288
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1289
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1290
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1291
pub struct OwnDevice {
96fdf90aacd6atagen2026-09-08 08:24 UTC1292
    pub device_id: OwnedDeviceId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1293
    pub display_name: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1294
    pub last_seen_ip: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1295
    pub last_seen_timestamp_ms: Option<u64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1296
    pub current: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1297
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1298
96fdf90aacd6atagen2026-09-08 08:24 UTC1299
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1300
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC1301
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1302
pub enum TimelineItem {
960ac0721079atagen2026-09-25 00:24 UTC1303
    Event(Box<TimelineEvent>),
96fdf90aacd6atagen2026-09-08 08:24 UTC1304
    DayDivider { timestamp_ms: u64 },
96fdf90aacd6atagen2026-09-08 08:24 UTC1305
    ReadMarker,
96fdf90aacd6atagen2026-09-08 08:24 UTC1306
    TimelineStart,
96fdf90aacd6atagen2026-09-08 08:24 UTC1307
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1308
96fdf90aacd6atagen2026-09-08 08:24 UTC1309
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1310
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1311
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1312
pub enum TimelineDiff {
96fdf90aacd6atagen2026-09-08 08:24 UTC1313
    Append { values: Vec<TimelineItem> },
96fdf90aacd6atagen2026-09-08 08:24 UTC1314
    Clear,
96fdf90aacd6atagen2026-09-08 08:24 UTC1315
    PushFront { value: TimelineItem },
96fdf90aacd6atagen2026-09-08 08:24 UTC1316
    PushBack { value: TimelineItem },
96fdf90aacd6atagen2026-09-08 08:24 UTC1317
    PopFront,
96fdf90aacd6atagen2026-09-08 08:24 UTC1318
    PopBack,
96fdf90aacd6atagen2026-09-08 08:24 UTC1319
    Insert { index: usize, value: TimelineItem },
96fdf90aacd6atagen2026-09-08 08:24 UTC1320
    Set { index: usize, value: TimelineItem },
96fdf90aacd6atagen2026-09-08 08:24 UTC1321
    Remove { index: usize },
96fdf90aacd6atagen2026-09-08 08:24 UTC1322
    Truncate { length: usize },
96fdf90aacd6atagen2026-09-08 08:24 UTC1323
    Reset { values: Vec<TimelineItem> },
96fdf90aacd6atagen2026-09-08 08:24 UTC1324
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1325
96fdf90aacd6atagen2026-09-08 08:24 UTC1326
#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1327
#[error("timeline diff is incompatible with the current {length}-item snapshot")]
96fdf90aacd6atagen2026-09-08 08:24 UTC1328
pub struct TimelineDiffError {
96fdf90aacd6atagen2026-09-08 08:24 UTC1329
    pub length: usize,
96fdf90aacd6atagen2026-09-08 08:24 UTC1330
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1331
96fdf90aacd6atagen2026-09-08 08:24 UTC1332
impl TimelineDiff {
96fdf90aacd6atagen2026-09-08 08:24 UTC1333
    /// Apply a diff only when its indices match the current snapshot.
96fdf90aacd6atagen2026-09-08 08:24 UTC1334
    /// On error the snapshot is unchanged; request `TimelineCommand::Resync`
96fdf90aacd6atagen2026-09-08 08:24 UTC1335
    /// and ignore further diffs until the corresponding `TimelineReset`.
d5d8097c3afdatagen2026-09-26 09:33 UTC1336
    pub fn try_apply(self, items: &mut Vector<TimelineItem>) -> Result<(), TimelineDiffError> {
96fdf90aacd6atagen2026-09-08 08:24 UTC1337
        let length = items.len();
d5d8097c3afdatagen2026-09-26 09:33 UTC1338
        if self.length_after(length).is_none() {
d5d8097c3afdatagen2026-09-26 09:33 UTC1339
            return Err(TimelineDiffError { length });
d5d8097c3afdatagen2026-09-26 09:33 UTC1340
        }
d5d8097c3afdatagen2026-09-26 09:33 UTC1341
        self.apply(items);
d5d8097c3afdatagen2026-09-26 09:33 UTC1342
        Ok(())
d5d8097c3afdatagen2026-09-26 09:33 UTC1343
    }
d5d8097c3afdatagen2026-09-26 09:33 UTC1344
d5d8097c3afdatagen2026-09-26 09:33 UTC1345
    /// a whole `TimelineChanged` or none of it. whether a diff fits depends only on the
d5d8097c3afdatagen2026-09-26 09:33 UTC1346
    /// length before it, so the batch is checked against lengths alone before anything
d5d8097c3afdatagen2026-09-26 09:33 UTC1347
    /// moves. the error carries the length the snapshot would have had at the misfit
d5d8097c3afdatagen2026-09-26 09:33 UTC1348
    pub fn try_apply_all(
d5d8097c3afdatagen2026-09-26 09:33 UTC1349
        diffs: Vec<Self>,
d5d8097c3afdatagen2026-09-26 09:33 UTC1350
        items: &mut Vector<TimelineItem>,
d5d8097c3afdatagen2026-09-26 09:33 UTC1351
    ) -> Result<(), TimelineDiffError> {
d5d8097c3afdatagen2026-09-26 09:33 UTC1352
        diffs.iter().try_fold(items.len(), |length, diff| {
d5d8097c3afdatagen2026-09-26 09:33 UTC1353
            diff.length_after(length)
d5d8097c3afdatagen2026-09-26 09:33 UTC1354
                .ok_or(TimelineDiffError { length })
d5d8097c3afdatagen2026-09-26 09:33 UTC1355
        })?;
d5d8097c3afdatagen2026-09-26 09:33 UTC1356
        for diff in diffs {
d5d8097c3afdatagen2026-09-26 09:33 UTC1357
            diff.apply(items);
d5d8097c3afdatagen2026-09-26 09:33 UTC1358
        }
d5d8097c3afdatagen2026-09-26 09:33 UTC1359
        Ok(())
d5d8097c3afdatagen2026-09-26 09:33 UTC1360
    }
d5d8097c3afdatagen2026-09-26 09:33 UTC1361
d5d8097c3afdatagen2026-09-26 09:33 UTC1362
    fn length_after(&self, length: usize) -> Option<usize> {
d5d8097c3afdatagen2026-09-26 09:33 UTC1363
        match self {
d5d8097c3afdatagen2026-09-26 09:33 UTC1364
            Self::Append { values } => Some(length + values.len()),
d5d8097c3afdatagen2026-09-26 09:33 UTC1365
            Self::Clear => Some(0),
d5d8097c3afdatagen2026-09-26 09:33 UTC1366
            Self::PushFront { .. } | Self::PushBack { .. } => Some(length + 1),
d5d8097c3afdatagen2026-09-26 09:33 UTC1367
            Self::PopFront | Self::PopBack => length.checked_sub(1),
d5d8097c3afdatagen2026-09-26 09:33 UTC1368
            Self::Insert { index, .. } => (*index <= length).then_some(length + 1),
d5d8097c3afdatagen2026-09-26 09:33 UTC1369
            Self::Set { index, .. } => (*index < length).then_some(length),
d5d8097c3afdatagen2026-09-26 09:33 UTC1370
            Self::Remove { index } => (*index < length).then(|| length - 1),
d5d8097c3afdatagen2026-09-26 09:33 UTC1371
            Self::Truncate { length: target } => (*target <= length).then_some(*target),
d5d8097c3afdatagen2026-09-26 09:33 UTC1372
            Self::Reset { values } => Some(values.len()),
d5d8097c3afdatagen2026-09-26 09:33 UTC1373
        }
d5d8097c3afdatagen2026-09-26 09:33 UTC1374
    }
d5d8097c3afdatagen2026-09-26 09:33 UTC1375
d5d8097c3afdatagen2026-09-26 09:33 UTC1376
    fn apply(self, items: &mut Vector<TimelineItem>) {
96fdf90aacd6atagen2026-09-08 08:24 UTC1377
        match self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1378
            Self::Append { values } => items.extend(values),
96fdf90aacd6atagen2026-09-08 08:24 UTC1379
            Self::Clear => items.clear(),
d5d8097c3afdatagen2026-09-26 09:33 UTC1380
            Self::PushFront { value } => items.push_front(value),
d5d8097c3afdatagen2026-09-26 09:33 UTC1381
            Self::PushBack { value } => items.push_back(value),
96fdf90aacd6atagen2026-09-08 08:24 UTC1382
            Self::PopFront => {
d5d8097c3afdatagen2026-09-26 09:33 UTC1383
                items.pop_front();
96fdf90aacd6atagen2026-09-08 08:24 UTC1384
            }
96fdf90aacd6atagen2026-09-08 08:24 UTC1385
            Self::PopBack => {
d5d8097c3afdatagen2026-09-26 09:33 UTC1386
                items.pop_back();
96fdf90aacd6atagen2026-09-08 08:24 UTC1387
            }
96fdf90aacd6atagen2026-09-08 08:24 UTC1388
            Self::Insert { index, value } => items.insert(index, value),
d5d8097c3afdatagen2026-09-26 09:33 UTC1389
            Self::Set { index, value } => {
d5d8097c3afdatagen2026-09-26 09:33 UTC1390
                items.set(index, value);
d5d8097c3afdatagen2026-09-26 09:33 UTC1391
            }
96fdf90aacd6atagen2026-09-08 08:24 UTC1392
            Self::Remove { index } => {
96fdf90aacd6atagen2026-09-08 08:24 UTC1393
                items.remove(index);
96fdf90aacd6atagen2026-09-08 08:24 UTC1394
            }
96fdf90aacd6atagen2026-09-08 08:24 UTC1395
            Self::Truncate { length } => items.truncate(length),
d5d8097c3afdatagen2026-09-26 09:33 UTC1396
            Self::Reset { values } => *items = values.into_iter().collect(),
96fdf90aacd6atagen2026-09-08 08:24 UTC1397
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1398
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1399
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1400
96fdf90aacd6atagen2026-09-08 08:24 UTC1401
#[cfg(test)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1402
mod tests {
d5d8097c3afdatagen2026-09-26 09:33 UTC1403
    use imbl::{Vector, vector};
d5d8097c3afdatagen2026-09-26 09:33 UTC1404
96fdf90aacd6atagen2026-09-08 08:24 UTC1405
    use super::{TimelineDiff, TimelineItem};
96fdf90aacd6atagen2026-09-08 08:24 UTC1406
96fdf90aacd6atagen2026-09-08 08:24 UTC1407
    fn item(timestamp_ms: u64) -> TimelineItem {
96fdf90aacd6atagen2026-09-08 08:24 UTC1408
        TimelineItem::DayDivider { timestamp_ms }
96fdf90aacd6atagen2026-09-08 08:24 UTC1409
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1410
96fdf90aacd6atagen2026-09-08 08:24 UTC1411
    #[test]
96fdf90aacd6atagen2026-09-08 08:24 UTC1412
    fn timeline_diff_try_apply_handles_every_variant() {
d5d8097c3afdatagen2026-09-26 09:33 UTC1413
        let mut items = vector![item(1), item(2)];
96fdf90aacd6atagen2026-09-08 08:24 UTC1414
96fdf90aacd6atagen2026-09-08 08:24 UTC1415
        TimelineDiff::Append {
96fdf90aacd6atagen2026-09-08 08:24 UTC1416
            values: vec![item(3)],
96fdf90aacd6atagen2026-09-08 08:24 UTC1417
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1418
        .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1419
        .unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1420
        assert_eq!(items, vector![item(1), item(2), item(3)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1421
96fdf90aacd6atagen2026-09-08 08:24 UTC1422
        TimelineDiff::Clear.try_apply(&mut items).unwrap();
96fdf90aacd6atagen2026-09-08 08:24 UTC1423
        assert!(items.is_empty());
96fdf90aacd6atagen2026-09-08 08:24 UTC1424
96fdf90aacd6atagen2026-09-08 08:24 UTC1425
        TimelineDiff::PushFront { value: item(2) }
96fdf90aacd6atagen2026-09-08 08:24 UTC1426
            .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1427
            .unwrap();
96fdf90aacd6atagen2026-09-08 08:24 UTC1428
        TimelineDiff::PushBack { value: item(3) }
96fdf90aacd6atagen2026-09-08 08:24 UTC1429
            .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1430
            .unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1431
        assert_eq!(items, vector![item(2), item(3)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1432
96fdf90aacd6atagen2026-09-08 08:24 UTC1433
        TimelineDiff::PopFront.try_apply(&mut items).unwrap();
96fdf90aacd6atagen2026-09-08 08:24 UTC1434
        TimelineDiff::PopBack.try_apply(&mut items).unwrap();
96fdf90aacd6atagen2026-09-08 08:24 UTC1435
        assert!(items.is_empty());
96fdf90aacd6atagen2026-09-08 08:24 UTC1436
96fdf90aacd6atagen2026-09-08 08:24 UTC1437
        TimelineDiff::Reset {
96fdf90aacd6atagen2026-09-08 08:24 UTC1438
            values: vec![item(1), item(3)],
96fdf90aacd6atagen2026-09-08 08:24 UTC1439
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1440
        .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1441
        .unwrap();
96fdf90aacd6atagen2026-09-08 08:24 UTC1442
        TimelineDiff::Insert {
96fdf90aacd6atagen2026-09-08 08:24 UTC1443
            index: 1,
96fdf90aacd6atagen2026-09-08 08:24 UTC1444
            value: item(2),
96fdf90aacd6atagen2026-09-08 08:24 UTC1445
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1446
        .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1447
        .unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1448
        assert_eq!(items, vector![item(1), item(2), item(3)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1449
96fdf90aacd6atagen2026-09-08 08:24 UTC1450
        TimelineDiff::Set {
96fdf90aacd6atagen2026-09-08 08:24 UTC1451
            index: 1,
96fdf90aacd6atagen2026-09-08 08:24 UTC1452
            value: item(4),
96fdf90aacd6atagen2026-09-08 08:24 UTC1453
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1454
        .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1455
        .unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1456
        assert_eq!(items, vector![item(1), item(4), item(3)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1457
96fdf90aacd6atagen2026-09-08 08:24 UTC1458
        TimelineDiff::Remove { index: 1 }
96fdf90aacd6atagen2026-09-08 08:24 UTC1459
            .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1460
            .unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1461
        assert_eq!(items, vector![item(1), item(3)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1462
96fdf90aacd6atagen2026-09-08 08:24 UTC1463
        TimelineDiff::Truncate { length: 1 }
96fdf90aacd6atagen2026-09-08 08:24 UTC1464
            .try_apply(&mut items)
96fdf90aacd6atagen2026-09-08 08:24 UTC1465
            .unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1466
        assert_eq!(items, vector![item(1)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1467
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1468
96fdf90aacd6atagen2026-09-08 08:24 UTC1469
    #[test]
96fdf90aacd6atagen2026-09-08 08:24 UTC1470
    fn invalid_timeline_diff_leaves_snapshot_unchanged() {
96fdf90aacd6atagen2026-09-08 08:24 UTC1471
        let invalid = [
96fdf90aacd6atagen2026-09-08 08:24 UTC1472
            TimelineDiff::Insert {
96fdf90aacd6atagen2026-09-08 08:24 UTC1473
                index: 3,
96fdf90aacd6atagen2026-09-08 08:24 UTC1474
                value: item(3),
96fdf90aacd6atagen2026-09-08 08:24 UTC1475
            },
96fdf90aacd6atagen2026-09-08 08:24 UTC1476
            TimelineDiff::Set {
96fdf90aacd6atagen2026-09-08 08:24 UTC1477
                index: 2,
96fdf90aacd6atagen2026-09-08 08:24 UTC1478
                value: item(3),
96fdf90aacd6atagen2026-09-08 08:24 UTC1479
            },
96fdf90aacd6atagen2026-09-08 08:24 UTC1480
            TimelineDiff::Remove { index: 2 },
96fdf90aacd6atagen2026-09-08 08:24 UTC1481
            TimelineDiff::Truncate { length: 3 },
96fdf90aacd6atagen2026-09-08 08:24 UTC1482
        ];
96fdf90aacd6atagen2026-09-08 08:24 UTC1483
        for diff in invalid {
d5d8097c3afdatagen2026-09-26 09:33 UTC1484
            let mut items = vector![item(1), item(2)];
96fdf90aacd6atagen2026-09-08 08:24 UTC1485
            assert_eq!(diff.try_apply(&mut items).unwrap_err().length, 2);
d5d8097c3afdatagen2026-09-26 09:33 UTC1486
            assert_eq!(items, vector![item(1), item(2)]);
96fdf90aacd6atagen2026-09-08 08:24 UTC1487
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1488
        for diff in [TimelineDiff::PopFront, TimelineDiff::PopBack] {
d5d8097c3afdatagen2026-09-26 09:33 UTC1489
            let mut items = Vector::new();
96fdf90aacd6atagen2026-09-08 08:24 UTC1490
            assert_eq!(diff.try_apply(&mut items).unwrap_err().length, 0);
96fdf90aacd6atagen2026-09-08 08:24 UTC1491
            assert!(items.is_empty());
96fdf90aacd6atagen2026-09-08 08:24 UTC1492
        }
96fdf90aacd6atagen2026-09-08 08:24 UTC1493
    }
d5d8097c3afdatagen2026-09-26 09:33 UTC1494
d5d8097c3afdatagen2026-09-26 09:33 UTC1495
    #[test]
d5d8097c3afdatagen2026-09-26 09:33 UTC1496
    fn a_batch_that_goes_wrong_halfway_changes_nothing() {
d5d8097c3afdatagen2026-09-26 09:33 UTC1497
        let mut items = vector![item(1), item(2)];
d5d8097c3afdatagen2026-09-26 09:33 UTC1498
        let batch = vec![
d5d8097c3afdatagen2026-09-26 09:33 UTC1499
            TimelineDiff::PushBack { value: item(3) },
0b8ce8dc9a1catagen2026-09-26 12:30 UTC1500
            TimelineDiff::PushBack { value: item(4) },
d5d8097c3afdatagen2026-09-26 09:33 UTC1501
            TimelineDiff::Remove { index: 0 },
d5d8097c3afdatagen2026-09-26 09:33 UTC1502
            TimelineDiff::Set {
0b8ce8dc9a1catagen2026-09-26 12:30 UTC1503
                index: 3,
0b8ce8dc9a1catagen2026-09-26 12:30 UTC1504
                value: item(5),
d5d8097c3afdatagen2026-09-26 09:33 UTC1505
            },
d5d8097c3afdatagen2026-09-26 09:33 UTC1506
        ];
d5d8097c3afdatagen2026-09-26 09:33 UTC1507
        assert_eq!(
d5d8097c3afdatagen2026-09-26 09:33 UTC1508
            TimelineDiff::try_apply_all(batch, &mut items)
d5d8097c3afdatagen2026-09-26 09:33 UTC1509
                .unwrap_err()
d5d8097c3afdatagen2026-09-26 09:33 UTC1510
                .length,
0b8ce8dc9a1catagen2026-09-26 12:30 UTC1511
            3
d5d8097c3afdatagen2026-09-26 09:33 UTC1512
        );
d5d8097c3afdatagen2026-09-26 09:33 UTC1513
        assert_eq!(items, vector![item(1), item(2)]);
d5d8097c3afdatagen2026-09-26 09:33 UTC1514
d5d8097c3afdatagen2026-09-26 09:33 UTC1515
        let batch = vec![
d5d8097c3afdatagen2026-09-26 09:33 UTC1516
            TimelineDiff::PushBack { value: item(3) },
d5d8097c3afdatagen2026-09-26 09:33 UTC1517
            TimelineDiff::Remove { index: 0 },
d5d8097c3afdatagen2026-09-26 09:33 UTC1518
            TimelineDiff::Set {
d5d8097c3afdatagen2026-09-26 09:33 UTC1519
                index: 1,
d5d8097c3afdatagen2026-09-26 09:33 UTC1520
                value: item(4),
d5d8097c3afdatagen2026-09-26 09:33 UTC1521
            },
d5d8097c3afdatagen2026-09-26 09:33 UTC1522
        ];
d5d8097c3afdatagen2026-09-26 09:33 UTC1523
        TimelineDiff::try_apply_all(batch, &mut items).unwrap();
d5d8097c3afdatagen2026-09-26 09:33 UTC1524
        assert_eq!(items, vector![item(2), item(4)]);
d5d8097c3afdatagen2026-09-26 09:33 UTC1525
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1526
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1527
96fdf90aacd6atagen2026-09-08 08:24 UTC1528
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1529
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1530
pub struct TimelineItemId(String);
96fdf90aacd6atagen2026-09-08 08:24 UTC1531
96fdf90aacd6atagen2026-09-08 08:24 UTC1532
impl TimelineItemId {
96fdf90aacd6atagen2026-09-08 08:24 UTC1533
    pub(crate) fn new(value: String) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1534
        Self(value)
96fdf90aacd6atagen2026-09-08 08:24 UTC1535
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1536
96fdf90aacd6atagen2026-09-08 08:24 UTC1537
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1538
    pub fn as_str(&self) -> &str {
96fdf90aacd6atagen2026-09-08 08:24 UTC1539
        &self.0
96fdf90aacd6atagen2026-09-08 08:24 UTC1540
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1541
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1542
96fdf90aacd6atagen2026-09-08 08:24 UTC1543
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1544
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1545
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1546
pub struct TimelineEvent {
96fdf90aacd6atagen2026-09-08 08:24 UTC1547
    pub item_id: TimelineItemId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1548
    pub event_id: Option<OwnedEventId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1549
    pub transaction_id: Option<OwnedTransactionId>,
960ac0721079atagen2026-09-25 00:24 UTC1550
    pub sender: Sender,
96fdf90aacd6atagen2026-09-08 08:24 UTC1551
    pub timestamp_ms: u64,
96fdf90aacd6atagen2026-09-08 08:24 UTC1552
    pub own: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1553
    pub send_state: SendState,
960ac0721079atagen2026-09-25 00:24 UTC1554
    pub content: TimelineContent,
96fdf90aacd6atagen2026-09-08 08:24 UTC1555
    pub reply_to: Option<ReplyReference>,
960ac0721079atagen2026-09-25 00:24 UTC1556
    pub thread_root: Option<OwnedEventId>,
960ac0721079atagen2026-09-25 00:24 UTC1557
    pub thread_summary: Option<ThreadSummary>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1558
    pub reactions: Vec<Reaction>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1559
    pub read_by: Vec<OwnedUserId>,
960ac0721079atagen2026-09-25 00:24 UTC1560
    pub editable: bool,
960ac0721079atagen2026-09-25 00:24 UTC1561
}
960ac0721079atagen2026-09-25 00:24 UTC1562
960ac0721079atagen2026-09-25 00:24 UTC1563
impl TimelineEvent {
960ac0721079atagen2026-09-25 00:24 UTC1564
    /// what to hand edit, redact and react. works before the server has echoed it back
960ac0721079atagen2026-09-25 00:24 UTC1565
    #[must_use]
960ac0721079atagen2026-09-25 00:24 UTC1566
    pub fn target(&self) -> Option<EventRef> {
960ac0721079atagen2026-09-25 00:24 UTC1567
        self.event_id
960ac0721079atagen2026-09-25 00:24 UTC1568
            .clone()
960ac0721079atagen2026-09-25 00:24 UTC1569
            .map(EventRef::Remote)
960ac0721079atagen2026-09-25 00:24 UTC1570
            .or_else(|| self.transaction_id.clone().map(EventRef::Local))
960ac0721079atagen2026-09-25 00:24 UTC1571
    }
960ac0721079atagen2026-09-25 00:24 UTC1572
}
960ac0721079atagen2026-09-25 00:24 UTC1573
960ac0721079atagen2026-09-25 00:24 UTC1574
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1575
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1576
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1577
pub enum EventRef {
960ac0721079atagen2026-09-25 00:24 UTC1578
    Remote(OwnedEventId),
960ac0721079atagen2026-09-25 00:24 UTC1579
    /// a local echo, by the transaction id it was queued under
960ac0721079atagen2026-09-25 00:24 UTC1580
    Local(OwnedTransactionId),
960ac0721079atagen2026-09-25 00:24 UTC1581
}
960ac0721079atagen2026-09-25 00:24 UTC1582
960ac0721079atagen2026-09-25 00:24 UTC1583
impl From<OwnedEventId> for EventRef {
960ac0721079atagen2026-09-25 00:24 UTC1584
    fn from(event_id: OwnedEventId) -> Self {
960ac0721079atagen2026-09-25 00:24 UTC1585
        Self::Remote(event_id)
960ac0721079atagen2026-09-25 00:24 UTC1586
    }
960ac0721079atagen2026-09-25 00:24 UTC1587
}
960ac0721079atagen2026-09-25 00:24 UTC1588
960ac0721079atagen2026-09-25 00:24 UTC1589
#[derive(Clone, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1590
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1591
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1592
pub struct Sender {
960ac0721079atagen2026-09-25 00:24 UTC1593
    pub user_id: OwnedUserId,
960ac0721079atagen2026-09-25 00:24 UTC1594
    pub display_name: Option<String>,
5d2974de5826atagen2026-10-08 11:29 UTC1595
    pub avatar: Option<MediaId>,
960ac0721079atagen2026-09-25 00:24 UTC1596
    /// someone else in the room goes by the same name, so show the user id too
960ac0721079atagen2026-09-25 00:24 UTC1597
    pub name_ambiguous: bool,
960ac0721079atagen2026-09-25 00:24 UTC1598
}
960ac0721079atagen2026-09-25 00:24 UTC1599
960ac0721079atagen2026-09-25 00:24 UTC1600
impl Sender {
960ac0721079atagen2026-09-25 00:24 UTC1601
    #[must_use]
960ac0721079atagen2026-09-25 00:24 UTC1602
    pub fn name(&self) -> &str {
960ac0721079atagen2026-09-25 00:24 UTC1603
        self.display_name
960ac0721079atagen2026-09-25 00:24 UTC1604
            .as_deref()
960ac0721079atagen2026-09-25 00:24 UTC1605
            .unwrap_or_else(|| self.user_id.as_str())
960ac0721079atagen2026-09-25 00:24 UTC1606
    }
960ac0721079atagen2026-09-25 00:24 UTC1607
}
960ac0721079atagen2026-09-25 00:24 UTC1608
960ac0721079atagen2026-09-25 00:24 UTC1609
#[derive(Clone, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1610
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1611
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1612
pub enum TimelineContent {
960ac0721079atagen2026-09-25 00:24 UTC1613
    Message(Message),
960ac0721079atagen2026-09-25 00:24 UTC1614
    Sticker {
960ac0721079atagen2026-09-25 00:24 UTC1615
        body: String,
960ac0721079atagen2026-09-25 00:24 UTC1616
        media: MediaDescriptor,
960ac0721079atagen2026-09-25 00:24 UTC1617
    },
960ac0721079atagen2026-09-25 00:24 UTC1618
    Poll {
960ac0721079atagen2026-09-25 00:24 UTC1619
        question: String,
960ac0721079atagen2026-09-25 00:24 UTC1620
    },
960ac0721079atagen2026-09-25 00:24 UTC1621
    Redacted,
960ac0721079atagen2026-09-25 00:24 UTC1622
    UnableToDecrypt(UtdCause),
960ac0721079atagen2026-09-25 00:24 UTC1623
    Membership {
960ac0721079atagen2026-09-25 00:24 UTC1624
        user_id: OwnedUserId,
960ac0721079atagen2026-09-25 00:24 UTC1625
        display_name: Option<String>,
960ac0721079atagen2026-09-25 00:24 UTC1626
        change: MembershipChange,
960ac0721079atagen2026-09-25 00:24 UTC1627
    },
960ac0721079atagen2026-09-25 00:24 UTC1628
    Profile {
960ac0721079atagen2026-09-25 00:24 UTC1629
        user_id: OwnedUserId,
960ac0721079atagen2026-09-25 00:24 UTC1630
        display_name: Option<Change<Option<String>>>,
5d2974de5826atagen2026-10-08 11:29 UTC1631
        avatar: Option<Change<Option<MediaId>>>,
960ac0721079atagen2026-09-25 00:24 UTC1632
    },
5a52012c9b1datagen2026-09-24 23:45 UTC1633
    /// `None` means it was cleared, or the event was redacted
960ac0721079atagen2026-09-25 00:24 UTC1634
    RoomName(Option<String>),
960ac0721079atagen2026-09-25 00:24 UTC1635
    RoomTopic(Option<String>),
5d2974de5826atagen2026-10-08 11:29 UTC1636
    RoomAvatar(Option<MediaId>),
960ac0721079atagen2026-09-25 00:24 UTC1637
    EncryptionEnabled,
960ac0721079atagen2026-09-25 00:24 UTC1638
    RoomCreated,
960ac0721079atagen2026-09-25 00:24 UTC1639
    RoomUpgraded {
960ac0721079atagen2026-09-25 00:24 UTC1640
        successor: OwnedRoomId,
960ac0721079atagen2026-09-25 00:24 UTC1641
    },
960ac0721079atagen2026-09-25 00:24 UTC1642
    OtherState {
960ac0721079atagen2026-09-25 00:24 UTC1643
        event_type: String,
960ac0721079atagen2026-09-25 00:24 UTC1644
        state_key: String,
960ac0721079atagen2026-09-25 00:24 UTC1645
    },
960ac0721079atagen2026-09-25 00:24 UTC1646
    Other {
960ac0721079atagen2026-09-25 00:24 UTC1647
        event_type: String,
960ac0721079atagen2026-09-25 00:24 UTC1648
    },
960ac0721079atagen2026-09-25 00:24 UTC1649
}
960ac0721079atagen2026-09-25 00:24 UTC1650
960ac0721079atagen2026-09-25 00:24 UTC1651
#[derive(Clone, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1652
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1653
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1654
pub struct Message {
960ac0721079atagen2026-09-25 00:24 UTC1655
    pub kind: MessageKind,
960ac0721079atagen2026-09-25 00:24 UTC1656
    pub body: String,
5a52012c9b1datagen2026-09-24 23:45 UTC1657
    /// only for `MessageKind::Location`
5a52012c9b1datagen2026-09-24 23:45 UTC1658
    pub geo_uri: Option<String>,
960ac0721079atagen2026-09-25 00:24 UTC1659
    pub formatted_body: Option<String>,
960ac0721079atagen2026-09-25 00:24 UTC1660
    pub mentions: Option<MessageMentions>,
960ac0721079atagen2026-09-25 00:24 UTC1661
    pub edited: bool,
960ac0721079atagen2026-09-25 00:24 UTC1662
    pub media: Option<MediaDescriptor>,
0291516d40b5atagen2026-10-22 08:31 UTC1663
    /// previews the sender attached (msc4095), so showing them asks no one about the url.
0291516d40b5atagen2026-10-22 08:31 UTC1664
    /// one for a url the body doesn't contain is dropped
0291516d40b5atagen2026-10-22 08:31 UTC1665
    pub link_previews: Vec<LinkPreview>,
0291516d40b5atagen2026-10-22 08:31 UTC1666
}
0291516d40b5atagen2026-10-22 08:31 UTC1667
0291516d40b5atagen2026-10-22 08:31 UTC1668
/// a link card, from the sender's own message or from `ClientHandle::url_preview`. page
0291516d40b5atagen2026-10-22 08:31 UTC1669
/// text passes through whoever made it unfiltered, so it arrives trimmed to a sane length
0291516d40b5atagen2026-10-22 08:31 UTC1670
#[derive(Clone, Debug, Eq, PartialEq)]
0291516d40b5atagen2026-10-22 08:31 UTC1671
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
0291516d40b5atagen2026-10-22 08:31 UTC1672
#[non_exhaustive]
0291516d40b5atagen2026-10-22 08:31 UTC1673
pub struct LinkPreview {
0291516d40b5atagen2026-10-22 08:31 UTC1674
    /// the url as it appears in the message, or as it was asked about
0291516d40b5atagen2026-10-22 08:31 UTC1675
    pub url: String,
0291516d40b5atagen2026-10-22 08:31 UTC1676
    /// where the page says it lives, when that's somewhere else
0291516d40b5atagen2026-10-22 08:31 UTC1677
    pub canonical_url: Option<String>,
0291516d40b5atagen2026-10-22 08:31 UTC1678
    pub title: Option<String>,
0291516d40b5atagen2026-10-22 08:31 UTC1679
    pub description: Option<String>,
0291516d40b5atagen2026-10-22 08:31 UTC1680
    pub site_name: Option<String>,
0291516d40b5atagen2026-10-22 08:31 UTC1681
    pub image: Option<LinkPreviewImage>,
0291516d40b5atagen2026-10-22 08:31 UTC1682
}
0291516d40b5atagen2026-10-22 08:31 UTC1683
0291516d40b5atagen2026-10-22 08:31 UTC1684
#[derive(Clone, Debug, Eq, PartialEq)]
0291516d40b5atagen2026-10-22 08:31 UTC1685
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
0291516d40b5atagen2026-10-22 08:31 UTC1686
#[non_exhaustive]
0291516d40b5atagen2026-10-22 08:31 UTC1687
pub struct LinkPreviewImage {
0291516d40b5atagen2026-10-22 08:31 UTC1688
    pub media_id: MediaId,
0291516d40b5atagen2026-10-22 08:31 UTC1689
    pub mimetype: Option<String>,
0291516d40b5atagen2026-10-22 08:31 UTC1690
    pub size_bytes: Option<u64>,
0291516d40b5atagen2026-10-22 08:31 UTC1691
    pub width: Option<u64>,
0291516d40b5atagen2026-10-22 08:31 UTC1692
    pub height: Option<u64>,
960ac0721079atagen2026-09-25 00:24 UTC1693
}
960ac0721079atagen2026-09-25 00:24 UTC1694
960ac0721079atagen2026-09-25 00:24 UTC1695
#[derive(Clone, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1696
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1697
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1698
pub enum MessageKind {
960ac0721079atagen2026-09-25 00:24 UTC1699
    Text,
960ac0721079atagen2026-09-25 00:24 UTC1700
    Emote,
960ac0721079atagen2026-09-25 00:24 UTC1701
    Notice,
960ac0721079atagen2026-09-25 00:24 UTC1702
    ServerNotice,
960ac0721079atagen2026-09-25 00:24 UTC1703
    Image,
960ac0721079atagen2026-09-25 00:24 UTC1704
    Video,
960ac0721079atagen2026-09-25 00:24 UTC1705
    Audio,
960ac0721079atagen2026-09-25 00:24 UTC1706
    File,
960ac0721079atagen2026-09-25 00:24 UTC1707
    Location,
960ac0721079atagen2026-09-25 00:24 UTC1708
    VerificationRequest,
960ac0721079atagen2026-09-25 00:24 UTC1709
    Other(String),
960ac0721079atagen2026-09-25 00:24 UTC1710
}
960ac0721079atagen2026-09-25 00:24 UTC1711
960ac0721079atagen2026-09-25 00:24 UTC1712
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1713
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1714
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1715
pub enum MembershipChange {
960ac0721079atagen2026-09-25 00:24 UTC1716
    Joined,
960ac0721079atagen2026-09-25 00:24 UTC1717
    Left,
960ac0721079atagen2026-09-25 00:24 UTC1718
    Banned,
960ac0721079atagen2026-09-25 00:24 UTC1719
    Unbanned,
960ac0721079atagen2026-09-25 00:24 UTC1720
    Kicked,
960ac0721079atagen2026-09-25 00:24 UTC1721
    KickedAndBanned,
960ac0721079atagen2026-09-25 00:24 UTC1722
    Invited,
960ac0721079atagen2026-09-25 00:24 UTC1723
    InvitationAccepted,
960ac0721079atagen2026-09-25 00:24 UTC1724
    InvitationRejected,
960ac0721079atagen2026-09-25 00:24 UTC1725
    InvitationRevoked,
960ac0721079atagen2026-09-25 00:24 UTC1726
    Knocked,
960ac0721079atagen2026-09-25 00:24 UTC1727
    KnockAccepted,
960ac0721079atagen2026-09-25 00:24 UTC1728
    KnockRetracted,
960ac0721079atagen2026-09-25 00:24 UTC1729
    KnockDenied,
960ac0721079atagen2026-09-25 00:24 UTC1730
    /// nothing a person would call a change, or something the sdk couldn't make sense of
960ac0721079atagen2026-09-25 00:24 UTC1731
    Other,
960ac0721079atagen2026-09-25 00:24 UTC1732
}
960ac0721079atagen2026-09-25 00:24 UTC1733
960ac0721079atagen2026-09-25 00:24 UTC1734
#[derive(Clone, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1735
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1736
pub struct Change<T> {
960ac0721079atagen2026-09-25 00:24 UTC1737
    pub old: T,
960ac0721079atagen2026-09-25 00:24 UTC1738
    pub new: T,
960ac0721079atagen2026-09-25 00:24 UTC1739
}
960ac0721079atagen2026-09-25 00:24 UTC1740
960ac0721079atagen2026-09-25 00:24 UTC1741
/// why a message couldn't be read, worth telling the user since some of these they can fix
960ac0721079atagen2026-09-25 00:24 UTC1742
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1743
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1744
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1745
pub enum UtdCause {
960ac0721079atagen2026-09-25 00:24 UTC1746
    Unknown,
960ac0721079atagen2026-09-25 00:24 UTC1747
    SentBeforeWeJoined,
960ac0721079atagen2026-09-25 00:24 UTC1748
    VerificationViolation,
960ac0721079atagen2026-09-25 00:24 UTC1749
    UnsignedDevice,
960ac0721079atagen2026-09-25 00:24 UTC1750
    UnknownDevice,
960ac0721079atagen2026-09-25 00:24 UTC1751
    HistoricalMessageAndBackupIsDisabled,
960ac0721079atagen2026-09-25 00:24 UTC1752
    WithheldForUnverifiedOrInsecureDevice,
960ac0721079atagen2026-09-25 00:24 UTC1753
    WithheldBySender,
960ac0721079atagen2026-09-25 00:24 UTC1754
    HistoricalMessageAndDeviceIsUnverified,
96fdf90aacd6atagen2026-09-08 08:24 UTC1755
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1756
96fdf90aacd6atagen2026-09-08 08:24 UTC1757
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1758
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1759
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1760
pub struct ThreadSummary {
96fdf90aacd6atagen2026-09-08 08:24 UTC1761
    pub reply_count: u32,
96fdf90aacd6atagen2026-09-08 08:24 UTC1762
    pub latest_event_id: Option<OwnedEventId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1763
    pub latest_event_timestamp_ms: Option<u64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1764
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1765
96fdf90aacd6atagen2026-09-08 08:24 UTC1766
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1767
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1768
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1769
pub enum SendState {
96fdf90aacd6atagen2026-09-08 08:24 UTC1770
    Sent,
96fdf90aacd6atagen2026-09-08 08:24 UTC1771
    Sending,
5a52012c9b1datagen2026-09-24 23:45 UTC1772
    /// `will_retry` means macltok has it in hand. otherwise it's wedged until you
5a52012c9b1datagen2026-09-24 23:45 UTC1773
    /// `retry_send` or `cancel_send`, so that's when to show a retry button
5a52012c9b1datagen2026-09-24 23:45 UTC1774
    Failed {
5a52012c9b1datagen2026-09-24 23:45 UTC1775
        will_retry: bool,
5a52012c9b1datagen2026-09-24 23:45 UTC1776
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC1777
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1778
96fdf90aacd6atagen2026-09-08 08:24 UTC1779
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1780
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC1781
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1782
pub struct ReplyReference {
96fdf90aacd6atagen2026-09-08 08:24 UTC1783
    pub event_id: OwnedEventId,
960ac0721079atagen2026-09-25 00:24 UTC1784
    pub details: ReplyDetails,
960ac0721079atagen2026-09-25 00:24 UTC1785
}
960ac0721079atagen2026-09-25 00:24 UTC1786
960ac0721079atagen2026-09-25 00:24 UTC1787
/// the replied-to event. macltok asks for it when it isn't loaded, `Pending` then turns into one of the others
960ac0721079atagen2026-09-25 00:24 UTC1788
#[derive(Clone, Debug, Eq, PartialEq)]
960ac0721079atagen2026-09-25 00:24 UTC1789
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
960ac0721079atagen2026-09-25 00:24 UTC1790
#[non_exhaustive]
960ac0721079atagen2026-09-25 00:24 UTC1791
pub enum ReplyDetails {
960ac0721079atagen2026-09-25 00:24 UTC1792
    Pending,
960ac0721079atagen2026-09-25 00:24 UTC1793
    Ready {
960ac0721079atagen2026-09-25 00:24 UTC1794
        sender: Sender,
960ac0721079atagen2026-09-25 00:24 UTC1795
        content: Box<TimelineContent>,
960ac0721079atagen2026-09-25 00:24 UTC1796
        timestamp_ms: u64,
960ac0721079atagen2026-09-25 00:24 UTC1797
    },
960ac0721079atagen2026-09-25 00:24 UTC1798
    Unavailable,
96fdf90aacd6atagen2026-09-08 08:24 UTC1799
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1800
96fdf90aacd6atagen2026-09-08 08:24 UTC1801
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1802
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1803
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1804
pub struct Reaction {
96fdf90aacd6atagen2026-09-08 08:24 UTC1805
    pub key: String,
8fa8a7cde89catagen2026-10-08 12:39 UTC1806
    /// a custom emote's shortcode, from whichever sender gave one
8fa8a7cde89catagen2026-10-08 12:39 UTC1807
    pub shortcode: Option<String>,
8fa8a7cde89catagen2026-10-08 12:39 UTC1808
    /// the custom emote itself, when the key is an image
8fa8a7cde89catagen2026-10-08 12:39 UTC1809
    pub image: Option<MediaId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1810
    pub count: usize,
96fdf90aacd6atagen2026-09-08 08:24 UTC1811
    pub own: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1812
    pub senders: Vec<OwnedUserId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1813
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1814
17e042fbc331atagen2026-10-08 12:39 UTC1815
/// every custom emote and sticker pack the account can reach, from the user's own
17e042fbc331atagen2026-10-08 12:39 UTC1816
/// pack, each joined room's packs, and the rooms the user enabled everywhere
17e042fbc331atagen2026-10-08 12:39 UTC1817
#[derive(Clone, Debug, Default, Eq, PartialEq)]
17e042fbc331atagen2026-10-08 12:39 UTC1818
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17e042fbc331atagen2026-10-08 12:39 UTC1819
#[non_exhaustive]
17e042fbc331atagen2026-10-08 12:39 UTC1820
pub struct ImagePacks {
17e042fbc331atagen2026-10-08 12:39 UTC1821
    /// the user's own pack, then the packs of rooms enabled everywhere
17e042fbc331atagen2026-10-08 12:39 UTC1822
    pub global: Vec<ImagePack>,
17e042fbc331atagen2026-10-08 12:39 UTC1823
    /// each joined room's own packs, rooms without any left out
17e042fbc331atagen2026-10-08 12:39 UTC1824
    pub rooms: imbl::HashMap<OwnedRoomId, Vec<ImagePack>>,
17e042fbc331atagen2026-10-08 12:39 UTC1825
}
17e042fbc331atagen2026-10-08 12:39 UTC1826
17e042fbc331atagen2026-10-08 12:39 UTC1827
impl ImagePacks {
17e042fbc331atagen2026-10-08 12:39 UTC1828
    /// what a picker in this room offers. the user's pack, the room's own, then the
17e042fbc331atagen2026-10-08 12:39 UTC1829
    /// rest of the enabled ones, each pack once
17e042fbc331atagen2026-10-08 12:39 UTC1830
    #[must_use]
17e042fbc331atagen2026-10-08 12:39 UTC1831
    pub fn for_room(&self, room_id: Option<&RoomId>) -> Vec<&ImagePack> {
17e042fbc331atagen2026-10-08 12:39 UTC1832
        let is_user = |pack: &&ImagePack| pack.source == ImagePackSource::User;
17e042fbc331atagen2026-10-08 12:39 UTC1833
        let own = room_id.and_then(|room_id| self.rooms.get(room_id));
17e042fbc331atagen2026-10-08 12:39 UTC1834
        let mut packs: Vec<&ImagePack> = self.global.iter().filter(is_user).collect();
17e042fbc331atagen2026-10-08 12:39 UTC1835
        packs.extend(own.into_iter().flatten());
17e042fbc331atagen2026-10-08 12:39 UTC1836
        for pack in self.global.iter().filter(|pack| !is_user(pack)) {
17e042fbc331atagen2026-10-08 12:39 UTC1837
            if !packs.iter().any(|seen| seen.id == pack.id) {
17e042fbc331atagen2026-10-08 12:39 UTC1838
                packs.push(pack);
17e042fbc331atagen2026-10-08 12:39 UTC1839
            }
17e042fbc331atagen2026-10-08 12:39 UTC1840
        }
17e042fbc331atagen2026-10-08 12:39 UTC1841
        packs
17e042fbc331atagen2026-10-08 12:39 UTC1842
    }
17e042fbc331atagen2026-10-08 12:39 UTC1843
}
17e042fbc331atagen2026-10-08 12:39 UTC1844
17e042fbc331atagen2026-10-08 12:39 UTC1845
#[derive(Clone, Debug, Eq, PartialEq)]
17e042fbc331atagen2026-10-08 12:39 UTC1846
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17e042fbc331atagen2026-10-08 12:39 UTC1847
#[non_exhaustive]
17e042fbc331atagen2026-10-08 12:39 UTC1848
pub struct ImagePack {
17e042fbc331atagen2026-10-08 12:39 UTC1849
    /// `user`, or `room:<room id>:<state key>`, the same across calls
17e042fbc331atagen2026-10-08 12:39 UTC1850
    pub id: String,
17e042fbc331atagen2026-10-08 12:39 UTC1851
    pub display_name: Option<String>,
17e042fbc331atagen2026-10-08 12:39 UTC1852
    pub avatar: Option<MediaId>,
17e042fbc331atagen2026-10-08 12:39 UTC1853
    pub attribution: Option<String>,
17e042fbc331atagen2026-10-08 12:39 UTC1854
    pub source: ImagePackSource,
17e042fbc331atagen2026-10-08 12:39 UTC1855
    pub images: Vec<PackImage>,
fa51490b6ae9atagen2026-10-24 08:41 UTC1856
    /// your own pack, or a room pack whose state you're allowed to send
fa51490b6ae9atagen2026-10-24 08:41 UTC1857
    pub editable: bool,
fa51490b6ae9atagen2026-10-24 08:41 UTC1858
    /// listed in im.ponies.emote_rooms. always true for your own pack
fa51490b6ae9atagen2026-10-24 08:41 UTC1859
    pub enabled_everywhere: bool,
17e042fbc331atagen2026-10-08 12:39 UTC1860
}
17e042fbc331atagen2026-10-08 12:39 UTC1861
17e042fbc331atagen2026-10-08 12:39 UTC1862
#[derive(Clone, Debug, Eq, PartialEq)]
17e042fbc331atagen2026-10-08 12:39 UTC1863
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17e042fbc331atagen2026-10-08 12:39 UTC1864
#[non_exhaustive]
17e042fbc331atagen2026-10-08 12:39 UTC1865
pub enum ImagePackSource {
17e042fbc331atagen2026-10-08 12:39 UTC1866
    User,
17e042fbc331atagen2026-10-08 12:39 UTC1867
    Room {
17e042fbc331atagen2026-10-08 12:39 UTC1868
        room_id: OwnedRoomId,
17e042fbc331atagen2026-10-08 12:39 UTC1869
        state_key: String,
17e042fbc331atagen2026-10-08 12:39 UTC1870
    },
17e042fbc331atagen2026-10-08 12:39 UTC1871
}
17e042fbc331atagen2026-10-08 12:39 UTC1872
17e042fbc331atagen2026-10-08 12:39 UTC1873
#[derive(Clone, Debug, Eq, PartialEq)]
17e042fbc331atagen2026-10-08 12:39 UTC1874
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17e042fbc331atagen2026-10-08 12:39 UTC1875
#[non_exhaustive]
17e042fbc331atagen2026-10-08 12:39 UTC1876
pub struct PackImage {
17e042fbc331atagen2026-10-08 12:39 UTC1877
    pub shortcode: String,
17e042fbc331atagen2026-10-08 12:39 UTC1878
    pub media_id: MediaId,
17e042fbc331atagen2026-10-08 12:39 UTC1879
    /// what `toggle_reaction` takes to react with this image
17e042fbc331atagen2026-10-08 12:39 UTC1880
    pub reaction_key: String,
17e042fbc331atagen2026-10-08 12:39 UTC1881
    pub body: Option<String>,
17e042fbc331atagen2026-10-08 12:39 UTC1882
    pub mimetype: Option<String>,
17e042fbc331atagen2026-10-08 12:39 UTC1883
    pub width: Option<u64>,
17e042fbc331atagen2026-10-08 12:39 UTC1884
    pub height: Option<u64>,
17e042fbc331atagen2026-10-08 12:39 UTC1885
    /// the image's own, else its pack's, else both
17e042fbc331atagen2026-10-08 12:39 UTC1886
    pub usage: Vec<PackUsage>,
17e042fbc331atagen2026-10-08 12:39 UTC1887
}
17e042fbc331atagen2026-10-08 12:39 UTC1888
17e042fbc331atagen2026-10-08 12:39 UTC1889
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17e042fbc331atagen2026-10-08 12:39 UTC1890
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17e042fbc331atagen2026-10-08 12:39 UTC1891
#[non_exhaustive]
17e042fbc331atagen2026-10-08 12:39 UTC1892
pub enum PackUsage {
17e042fbc331atagen2026-10-08 12:39 UTC1893
    Emoticon,
17e042fbc331atagen2026-10-08 12:39 UTC1894
    Sticker,
17e042fbc331atagen2026-10-08 12:39 UTC1895
}
17e042fbc331atagen2026-10-08 12:39 UTC1896
96fdf90aacd6atagen2026-09-08 08:24 UTC1897
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1898
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1899
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1900
pub struct MediaDescriptor {
96fdf90aacd6atagen2026-09-08 08:24 UTC1901
    pub id: MediaId,
96fdf90aacd6atagen2026-09-08 08:24 UTC1902
    pub kind: MediaKind,
9bd34e25bb86atagen2026-10-24 07:23 UTC1903
    /// only for unencrypted media, an encrypted file's mxc is ciphertext without the keys
9bd34e25bb86atagen2026-10-24 07:23 UTC1904
    pub mxc: Option<OwnedMxcUri>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1905
    pub filename: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC1906
    pub caption: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1907
    pub mimetype: Option<String>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1908
    pub size_bytes: Option<u64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1909
    pub width: Option<u64>,
96fdf90aacd6atagen2026-09-08 08:24 UTC1910
    pub height: Option<u64>,
5a52012c9b1datagen2026-09-24 23:45 UTC1911
    pub duration_ms: Option<u64>,
5a52012c9b1datagen2026-09-24 23:45 UTC1912
    pub blurhash: Option<String>,
5a52012c9b1datagen2026-09-24 23:45 UTC1913
    /// the uploader sent a thumbnail, so `MediaSize::Thumbnail` won't need the server to resize
5a52012c9b1datagen2026-09-24 23:45 UTC1914
    pub has_thumbnail: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC1915
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1916
96fdf90aacd6atagen2026-09-08 08:24 UTC1917
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1918
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC1919
pub struct MediaId(String);
96fdf90aacd6atagen2026-09-08 08:24 UTC1920
96fdf90aacd6atagen2026-09-08 08:24 UTC1921
impl MediaId {
96fdf90aacd6atagen2026-09-08 08:24 UTC1922
    pub(crate) fn new(value: String) -> Self {
96fdf90aacd6atagen2026-09-08 08:24 UTC1923
        Self(value)
96fdf90aacd6atagen2026-09-08 08:24 UTC1924
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1925
5d2974de5826atagen2026-10-08 11:29 UTC1926
    /// plain media carries no keys, so it needs no registering and never expires
5d2974de5826atagen2026-10-08 11:29 UTC1927
    pub(crate) fn plain<U: AsRef<str> + ?Sized>(uri: &U) -> Self {
5d2974de5826atagen2026-10-08 11:29 UTC1928
        Self(uri.as_ref().to_owned())
5d2974de5826atagen2026-10-08 11:29 UTC1929
    }
5d2974de5826atagen2026-10-08 11:29 UTC1930
5d2974de5826atagen2026-10-08 11:29 UTC1931
    pub(crate) fn as_plain(&self) -> Option<&MxcUri> {
5d2974de5826atagen2026-10-08 11:29 UTC1932
        self.0.starts_with("mxc://").then(|| self.0.as_str().into())
5d2974de5826atagen2026-10-08 11:29 UTC1933
    }
5d2974de5826atagen2026-10-08 11:29 UTC1934
96fdf90aacd6atagen2026-09-08 08:24 UTC1935
    #[must_use]
96fdf90aacd6atagen2026-09-08 08:24 UTC1936
    pub fn as_str(&self) -> &str {
96fdf90aacd6atagen2026-09-08 08:24 UTC1937
        &self.0
96fdf90aacd6atagen2026-09-08 08:24 UTC1938
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1939
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1940
5a52012c9b1datagen2026-09-24 23:45 UTC1941
/// media ids are opaque but they do have to survive a trip through a browser. a made up one just fails `MediaUnknown`
5a52012c9b1datagen2026-09-24 23:45 UTC1942
impl std::str::FromStr for MediaId {
5a52012c9b1datagen2026-09-24 23:45 UTC1943
    type Err = std::convert::Infallible;
5a52012c9b1datagen2026-09-24 23:45 UTC1944
5a52012c9b1datagen2026-09-24 23:45 UTC1945
    fn from_str(value: &str) -> Result<Self, Self::Err> {
5a52012c9b1datagen2026-09-24 23:45 UTC1946
        Ok(Self(value.to_owned()))
5a52012c9b1datagen2026-09-24 23:45 UTC1947
    }
5a52012c9b1datagen2026-09-24 23:45 UTC1948
}
5a52012c9b1datagen2026-09-24 23:45 UTC1949
5a52012c9b1datagen2026-09-24 23:45 UTC1950
impl From<String> for MediaId {
5a52012c9b1datagen2026-09-24 23:45 UTC1951
    fn from(value: String) -> Self {
5a52012c9b1datagen2026-09-24 23:45 UTC1952
        Self(value)
5a52012c9b1datagen2026-09-24 23:45 UTC1953
    }
5a52012c9b1datagen2026-09-24 23:45 UTC1954
}
5a52012c9b1datagen2026-09-24 23:45 UTC1955
96fdf90aacd6atagen2026-09-08 08:24 UTC1956
impl std::fmt::Display for MediaId {
96fdf90aacd6atagen2026-09-08 08:24 UTC1957
    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
96fdf90aacd6atagen2026-09-08 08:24 UTC1958
        self.0.fmt(formatter)
96fdf90aacd6atagen2026-09-08 08:24 UTC1959
    }
96fdf90aacd6atagen2026-09-08 08:24 UTC1960
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1961
96fdf90aacd6atagen2026-09-08 08:24 UTC1962
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC1963
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5a52012c9b1datagen2026-09-24 23:45 UTC1964
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC1965
pub enum MediaSize {
96fdf90aacd6atagen2026-09-08 08:24 UTC1966
    Full,
31ce2453c82fatagen2026-09-24 13:07 UTC1967
    /// a hint. an uploader's own thumbnail wins over the server resizing anything
31ce2453c82fatagen2026-09-24 13:07 UTC1968
    Thumbnail {
31ce2453c82fatagen2026-09-24 13:07 UTC1969
        width: u32,
31ce2453c82fatagen2026-09-24 13:07 UTC1970
        height: u32,
31ce2453c82fatagen2026-09-24 13:07 UTC1971
    },
31ce2453c82fatagen2026-09-24 13:07 UTC1972
}
31ce2453c82fatagen2026-09-24 13:07 UTC1973
31ce2453c82fatagen2026-09-24 13:07 UTC1974
#[derive(Clone, Debug, Eq, PartialEq)]
31ce2453c82fatagen2026-09-24 13:07 UTC1975
#[non_exhaustive]
31ce2453c82fatagen2026-09-24 13:07 UTC1976
pub struct Media {
31ce2453c82fatagen2026-09-24 13:07 UTC1977
    pub bytes: Arc<[u8]>,
31ce2453c82fatagen2026-09-24 13:07 UTC1978
    pub mimetype: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC1979
}
96fdf90aacd6atagen2026-09-08 08:24 UTC1980
5b21b919d1e6atagen2026-09-27 11:47 UTC1981
/// where media lives, for a host that fetches and decrypts it itself
5b21b919d1e6atagen2026-09-27 11:47 UTC1982
#[derive(Clone, Debug, Eq, PartialEq)]
5b21b919d1e6atagen2026-09-27 11:47 UTC1983
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5b21b919d1e6atagen2026-09-27 11:47 UTC1984
#[non_exhaustive]
5b21b919d1e6atagen2026-09-27 11:47 UTC1985
pub enum MediaLocation {
5b21b919d1e6atagen2026-09-27 11:47 UTC1986
    File(MediaFile),
5b21b919d1e6atagen2026-09-27 11:47 UTC1987
    /// a resize of plaintext, so never encrypted. plenty of servers refuse some, and `media`
5b21b919d1e6atagen2026-09-27 11:47 UTC1988
    /// then fetches `fallback` instead, so should you
5b21b919d1e6atagen2026-09-27 11:47 UTC1989
    ServerThumbnail {
5b21b919d1e6atagen2026-09-27 11:47 UTC1990
        url: String,
5b21b919d1e6atagen2026-09-27 11:47 UTC1991
        fallback: MediaFile,
5b21b919d1e6atagen2026-09-27 11:47 UTC1992
    },
5b21b919d1e6atagen2026-09-27 11:47 UTC1993
    /// still in the send queue with no url yet. `media` has the bytes
5b21b919d1e6atagen2026-09-27 11:47 UTC1994
    Local,
5b21b919d1e6atagen2026-09-27 11:47 UTC1995
}
5b21b919d1e6atagen2026-09-27 11:47 UTC1996
5b21b919d1e6atagen2026-09-27 11:47 UTC1997
#[derive(Clone, Debug, Eq, PartialEq)]
5b21b919d1e6atagen2026-09-27 11:47 UTC1998
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5b21b919d1e6atagen2026-09-27 11:47 UTC1999
#[non_exhaustive]
5b21b919d1e6atagen2026-09-27 11:47 UTC2000
pub struct MediaFile {
5b21b919d1e6atagen2026-09-27 11:47 UTC2001
    pub url: String,
5b21b919d1e6atagen2026-09-27 11:47 UTC2002
    pub mimetype: Option<String>,
5b21b919d1e6atagen2026-09-27 11:47 UTC2003
    pub declared_size: Option<u64>,
5b21b919d1e6atagen2026-09-27 11:47 UTC2004
    pub encryption: Option<AttachmentEncryption>,
5b21b919d1e6atagen2026-09-27 11:47 UTC2005
}
5b21b919d1e6atagen2026-09-27 11:47 UTC2006
5b21b919d1e6atagen2026-09-27 11:47 UTC2007
/// AES-256-CTR, the only attachment cipher matrix has
5b21b919d1e6atagen2026-09-27 11:47 UTC2008
#[derive(Clone, Debug, Eq, PartialEq)]
5b21b919d1e6atagen2026-09-27 11:47 UTC2009
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5b21b919d1e6atagen2026-09-27 11:47 UTC2010
#[non_exhaustive]
5b21b919d1e6atagen2026-09-27 11:47 UTC2011
pub struct AttachmentEncryption {
5b21b919d1e6atagen2026-09-27 11:47 UTC2012
    /// the JWK `k`, unpadded url-safe base64
5b21b919d1e6atagen2026-09-27 11:47 UTC2013
    pub key: String,
5b21b919d1e6atagen2026-09-27 11:47 UTC2014
    /// unpadded base64, the initial counter block
5b21b919d1e6atagen2026-09-27 11:47 UTC2015
    pub iv: String,
5b21b919d1e6atagen2026-09-27 11:47 UTC2016
    /// unpadded base64 SHA-256 of the whole ciphertext, so a partial read goes unchecked
5b21b919d1e6atagen2026-09-27 11:47 UTC2017
    pub sha256: String,
5b21b919d1e6atagen2026-09-27 11:47 UTC2018
}
5b21b919d1e6atagen2026-09-27 11:47 UTC2019
96fdf90aacd6atagen2026-09-08 08:24 UTC2020
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2021
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC2022
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2023
pub enum MediaKind {
96fdf90aacd6atagen2026-09-08 08:24 UTC2024
    Image,
96fdf90aacd6atagen2026-09-08 08:24 UTC2025
    Video,
96fdf90aacd6atagen2026-09-08 08:24 UTC2026
    Audio,
96fdf90aacd6atagen2026-09-08 08:24 UTC2027
    File,
96fdf90aacd6atagen2026-09-08 08:24 UTC2028
    Sticker,
96fdf90aacd6atagen2026-09-08 08:24 UTC2029
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2030
96fdf90aacd6atagen2026-09-08 08:24 UTC2031
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2032
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC2033
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2034
pub struct TypingState {
96fdf90aacd6atagen2026-09-08 08:24 UTC2035
    pub room_id: OwnedRoomId,
96fdf90aacd6atagen2026-09-08 08:24 UTC2036
    pub users: Vec<OwnedUserId>,
96fdf90aacd6atagen2026-09-08 08:24 UTC2037
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2038
96fdf90aacd6atagen2026-09-08 08:24 UTC2039
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2040
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC2041
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2042
pub enum HistoryState {
96fdf90aacd6atagen2026-09-08 08:24 UTC2043
    Idle,
96fdf90aacd6atagen2026-09-08 08:24 UTC2044
    Loading,
96fdf90aacd6atagen2026-09-08 08:24 UTC2045
    StartReached,
96fdf90aacd6atagen2026-09-08 08:24 UTC2046
    Failed(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC2047
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2048
96fdf90aacd6atagen2026-09-08 08:24 UTC2049
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2050
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC2051
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2052
pub struct EncryptionState {
96fdf90aacd6atagen2026-09-08 08:24 UTC2053
    pub device_id: OwnedDeviceId,
96fdf90aacd6atagen2026-09-08 08:24 UTC2054
    pub device_verified: bool,
96fdf90aacd6atagen2026-09-08 08:24 UTC2055
    pub recovery: RecoveryState,
96fdf90aacd6atagen2026-09-08 08:24 UTC2056
    pub key_backup: KeyBackupState,
96fdf90aacd6atagen2026-09-08 08:24 UTC2057
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2058
96fdf90aacd6atagen2026-09-08 08:24 UTC2059
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2060
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC2061
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2062
pub enum KeyBackupState {
96fdf90aacd6atagen2026-09-08 08:24 UTC2063
    Unknown,
96fdf90aacd6atagen2026-09-08 08:24 UTC2064
    Creating,
96fdf90aacd6atagen2026-09-08 08:24 UTC2065
    Enabling,
96fdf90aacd6atagen2026-09-08 08:24 UTC2066
    Resuming,
96fdf90aacd6atagen2026-09-08 08:24 UTC2067
    Downloading,
96fdf90aacd6atagen2026-09-08 08:24 UTC2068
    Enabled,
96fdf90aacd6atagen2026-09-08 08:24 UTC2069
    Disabling,
96fdf90aacd6atagen2026-09-08 08:24 UTC2070
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2071
96fdf90aacd6atagen2026-09-08 08:24 UTC2072
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2073
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC2074
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2075
pub enum RecoveryState {
96fdf90aacd6atagen2026-09-08 08:24 UTC2076
    Unknown,
96fdf90aacd6atagen2026-09-08 08:24 UTC2077
    Disabled,
96fdf90aacd6atagen2026-09-08 08:24 UTC2078
    Incomplete,
96fdf90aacd6atagen2026-09-08 08:24 UTC2079
    Enabled,
96fdf90aacd6atagen2026-09-08 08:24 UTC2080
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2081
96fdf90aacd6atagen2026-09-08 08:24 UTC2082
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2083
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5a52012c9b1datagen2026-09-24 23:45 UTC2084
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2085
pub enum VerificationAction {
5a52012c9b1datagen2026-09-24 23:45 UTC2086
    /// take up a request another device sent, which arrives as `VerificationState::Incoming`
5a52012c9b1datagen2026-09-24 23:45 UTC2087
    Accept,
96fdf90aacd6atagen2026-09-08 08:24 UTC2088
    Confirm,
96fdf90aacd6atagen2026-09-08 08:24 UTC2089
    Reject,
96fdf90aacd6atagen2026-09-08 08:24 UTC2090
    Cancel,
96fdf90aacd6atagen2026-09-08 08:24 UTC2091
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2092
96fdf90aacd6atagen2026-09-08 08:24 UTC2093
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2094
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC2095
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2096
pub enum VerificationTarget {
96fdf90aacd6atagen2026-09-08 08:24 UTC2097
    OwnIdentity,
96fdf90aacd6atagen2026-09-08 08:24 UTC2098
    User(OwnedUserId),
96fdf90aacd6atagen2026-09-08 08:24 UTC2099
    Device {
96fdf90aacd6atagen2026-09-08 08:24 UTC2100
        user_id: OwnedUserId,
96fdf90aacd6atagen2026-09-08 08:24 UTC2101
        device_id: OwnedDeviceId,
96fdf90aacd6atagen2026-09-08 08:24 UTC2102
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC2103
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2104
96fdf90aacd6atagen2026-09-08 08:24 UTC2105
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2106
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31ce2453c82fatagen2026-09-24 13:07 UTC2107
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2108
pub enum VerificationState {
96fdf90aacd6atagen2026-09-08 08:24 UTC2109
    Waiting,
5a52012c9b1datagen2026-09-24 23:45 UTC2110
    /// someone else asked. `Accept` to go ahead, `Cancel` to turn them down
5a52012c9b1datagen2026-09-24 23:45 UTC2111
    Incoming {
5a52012c9b1datagen2026-09-24 23:45 UTC2112
        user_id: OwnedUserId,
5a52012c9b1datagen2026-09-24 23:45 UTC2113
        device_id: Option<OwnedDeviceId>,
5a52012c9b1datagen2026-09-24 23:45 UTC2114
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC2115
    Comparison {
96fdf90aacd6atagen2026-09-08 08:24 UTC2116
        emojis: Vec<(String, String)>,
96fdf90aacd6atagen2026-09-08 08:24 UTC2117
        decimals: (u16, u16, u16),
96fdf90aacd6atagen2026-09-08 08:24 UTC2118
    },
96fdf90aacd6atagen2026-09-08 08:24 UTC2119
    Confirmed,
96fdf90aacd6atagen2026-09-08 08:24 UTC2120
    Done,
96fdf90aacd6atagen2026-09-08 08:24 UTC2121
    Cancelled(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC2122
    Failed(VerificationFailure),
96fdf90aacd6atagen2026-09-08 08:24 UTC2123
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2124
96fdf90aacd6atagen2026-09-08 08:24 UTC2125
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2126
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC2127
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2128
pub enum VerificationFailure {
96fdf90aacd6atagen2026-09-08 08:24 UTC2129
    RequestAcceptance(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC2130
    SasStartup(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC2131
    SasAcceptance(String),
96fdf90aacd6atagen2026-09-08 08:24 UTC2132
    RequestStreamEnded,
96fdf90aacd6atagen2026-09-08 08:24 UTC2133
    SasStreamEnded,
96fdf90aacd6atagen2026-09-08 08:24 UTC2134
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2135
96fdf90aacd6atagen2026-09-08 08:24 UTC2136
#[derive(Clone, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2137
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC2138
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2139
pub struct EngineFailure {
96fdf90aacd6atagen2026-09-08 08:24 UTC2140
    pub kind: EngineErrorKind,
96fdf90aacd6atagen2026-09-08 08:24 UTC2141
    pub message: String,
96fdf90aacd6atagen2026-09-08 08:24 UTC2142
}
96fdf90aacd6atagen2026-09-08 08:24 UTC2143
96fdf90aacd6atagen2026-09-08 08:24 UTC2144
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
96fdf90aacd6atagen2026-09-08 08:24 UTC2145
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96fdf90aacd6atagen2026-09-08 08:24 UTC2146
#[non_exhaustive]
96fdf90aacd6atagen2026-09-08 08:24 UTC2147
pub enum EngineErrorKind {
96fdf90aacd6atagen2026-09-08 08:24 UTC2148
    EventReceiverClosed,
96fdf90aacd6atagen2026-09-08 08:24 UTC2149
    Watcher,
96fdf90aacd6atagen2026-09-08 08:24 UTC2150
    Other,
96fdf90aacd6atagen2026-09-08 08:24 UTC2151
}