atagen

macltok

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