Skip to main content

AccountDataQueries

Trait AccountDataQueries 

Source
pub trait AccountDataQueries: Database {
    // Provided methods
    async fn upsert_room_account_data(
        &mut self,
        user_id: &UserId,
        room_id: &RoomId,
        event_type: &RoomAccountDataEventType,
        data: Value,
    ) -> Result<PgQueryResult, DatabaseError> { ... }
    async fn upsert_global_account_data(
        &mut self,
        user_id: &UserId,
        event_type: &GlobalAccountDataEventType,
        data: Value,
    ) -> Result<PgQueryResult, DatabaseError> { ... }
    async fn fetch_room_account_data<C: RoomAccountDataEventContent + DeserializeOwned>(
        &mut self,
        user_id: &UserId,
        room_id: &RoomId,
        event_type: &RoomAccountDataEventType,
    ) -> Result<Option<RoomAccountDataEvent<C>>, DatabaseError> { ... }
    async fn fetch_room_account_data_untyped(
        &mut self,
        user_id: &UserId,
        room_id: &RoomId,
        event_type: &RoomAccountDataEventType,
    ) -> Result<Option<Value>, DatabaseError> { ... }
    async fn import_global_account_data(
        &mut self,
        user_id: &UserId,
        data_type: &str,
        data: Value,
        stream_id: i64,
    ) -> Result<bool, DatabaseError> { ... }
    async fn import_room_account_data(
        &mut self,
        user_id: &UserId,
        room_id: &RoomId,
        data_type: &str,
        data: Value,
        stream_id: i64,
    ) -> Result<bool, DatabaseError> { ... }
    async fn fetch_global_account_data_untyped(
        &mut self,
        user_id: &UserId,
        event_type: &GlobalAccountDataEventType,
    ) -> Result<Option<Value>, DatabaseError> { ... }
    async fn fetch_sync_global_account_data_events(
        &mut self,
        user_id: &UserId,
        from_stream_id: StreamId,
        filter: Option<&Filter>,
    ) -> Result<Vec<SyncGlobalAccountDataEvent>, DatabaseError> { ... }
    async fn fetch_sync_room_account_data_events(
        &mut self,
        user_id: &OwnedUserId,
        from_stream_id: StreamId,
        filter: Option<&RoomEventFilter>,
    ) -> Result<Vec<SyncRoomAccountDataEvent>, DatabaseError> { ... }
}
Expand description

Queries relating to account data

Provided Methods§

Source

async fn upsert_room_account_data( &mut self, user_id: &UserId, room_id: &RoomId, event_type: &RoomAccountDataEventType, data: Value, ) -> Result<PgQueryResult, DatabaseError>

Inserts or updates room account data for a user in a specific room.

Source

async fn upsert_global_account_data( &mut self, user_id: &UserId, event_type: &GlobalAccountDataEventType, data: Value, ) -> Result<PgQueryResult, DatabaseError>

Inserts or updates global account data for a user.

Source

async fn fetch_room_account_data<C: RoomAccountDataEventContent + DeserializeOwned>( &mut self, user_id: &UserId, room_id: &RoomId, event_type: &RoomAccountDataEventType, ) -> Result<Option<RoomAccountDataEvent<C>>, DatabaseError>

Retrieve room account data for a user in a specific room.

Source

async fn fetch_room_account_data_untyped( &mut self, user_id: &UserId, room_id: &RoomId, event_type: &RoomAccountDataEventType, ) -> Result<Option<Value>, DatabaseError>

Retrieve room account data for a user in a specific room.

This function, as opposed to Self::fetch_room_account_data, is to be used when you do not need to know which variant of [RoomAccountDataEvent] you have in the caller.

Source

async fn import_global_account_data( &mut self, user_id: &UserId, data_type: &str, data: Value, stream_id: i64, ) -> Result<bool, DatabaseError>

Imports a global account-data row, preserving the source stream_id. Idempotent: an existing (user, data_type) row is left untouched.

Preserving the stream_id bypasses account_data_streamids, so the sequence is advanced past the imported value in the same transaction. This keeps the “next auto-assigned stream_id never collides with an existing row” invariant: the import leaves the database healthy on its own, with no external sequence reset to remember.

Source

async fn import_room_account_data( &mut self, user_id: &UserId, room_id: &RoomId, data_type: &str, data: Value, stream_id: i64, ) -> Result<bool, DatabaseError>

Imports a room account-data row, preserving the source stream_id. Idempotent: an existing (user, room, data_type) row is left untouched.

Shares account_data_streamids with Self::import_global_account_data and, like it, advances the sequence past the preserved stream_id in the same transaction so the import leaves the database healthy on its own.

Source

async fn fetch_global_account_data_untyped( &mut self, user_id: &UserId, event_type: &GlobalAccountDataEventType, ) -> Result<Option<Value>, DatabaseError>

Fetch global account data for a user based on the event type.

Source

async fn fetch_sync_global_account_data_events( &mut self, user_id: &UserId, from_stream_id: StreamId, filter: Option<&Filter>, ) -> Result<Vec<SyncGlobalAccountDataEvent>, DatabaseError>

Fetches any entry in the global_account_data table which stream_id strictly higher than from_stream_id.

Source

async fn fetch_sync_room_account_data_events( &mut self, user_id: &OwnedUserId, from_stream_id: StreamId, filter: Option<&RoomEventFilter>, ) -> Result<Vec<SyncRoomAccountDataEvent>, DatabaseError>

Fetches any entry in the room_account_data table which stream_id strictly higher than from_stream_id.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> AccountDataQueries for T
where T: Database,