Files
continuwuity/src/service/account_data/data.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
869 B
Rust
Raw Normal View History

2022-09-07 13:25:51 +02:00
use std::collections::HashMap;
2021-06-08 18:10:00 +02:00
2022-10-05 20:34:31 +02:00
use ruma::{
2024-03-05 19:48:54 -05:00
events::{AnyEphemeralRoomEvent, RoomAccountDataEventType},
serde::Raw,
RoomId, UserId,
2022-10-05 20:34:31 +02:00
};
2022-09-07 13:25:51 +02:00
2024-03-05 19:48:54 -05:00
use crate::Result;
2022-10-05 15:33:57 +02:00
pub trait Data: Send + Sync {
2024-03-05 19:48:54 -05:00
/// Places one event in the account data of the user and removes the
/// previous entry.
fn update(
&self, room_id: Option<&RoomId>, user_id: &UserId, event_type: RoomAccountDataEventType,
data: &serde_json::Value,
) -> Result<()>;
2024-03-05 19:48:54 -05:00
/// Searches the account data for a specific kind.
fn get(
&self, room_id: Option<&RoomId>, user_id: &UserId, kind: RoomAccountDataEventType,
) -> Result<Option<Box<serde_json::value::RawValue>>>;
2024-03-05 19:48:54 -05:00
/// Returns all changes to the account data that happened after `since`.
fn changes_since(
&self, room_id: Option<&RoomId>, user_id: &UserId, since: u64,
) -> Result<HashMap<RoomAccountDataEventType, Raw<AnyEphemeralRoomEvent>>>;
}