conduwuit/src/service/rooms/state_accessor/data.rs

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

49 lines
1.8 KiB
Rust
Raw Normal View History

2022-12-18 06:37:03 +01:00
use std::{collections::HashMap, sync::Arc};
2022-09-07 13:25:51 +02:00
use async_trait::async_trait;
2022-10-05 20:34:31 +02:00
use ruma::{events::StateEventType, EventId, RoomId};
2022-10-05 20:34:31 +02:00
use crate::{PduEvent, Result};
2022-09-07 13:25:51 +02:00
#[async_trait]
pub(crate) trait Data: Send + Sync {
/// Builds a StateMap by iterating over all keys that start
/// with state_hash, this gives the full state for the given state_hash.
#[allow(unused_qualifications)] // async traits
2022-12-18 06:37:03 +01:00
async fn state_full_ids(&self, shortstatehash: u64) -> Result<HashMap<u64, Arc<EventId>>>;
#[allow(unused_qualifications)] // async traits
async fn state_full(&self, shortstatehash: u64) -> Result<HashMap<(StateEventType, String), Arc<PduEvent>>>;
/// Returns a single PDU from `room_id` with key (`event_type`,
/// `state_key`).
fn state_get_id(
2022-04-06 21:31:29 +02:00
&self, shortstatehash: u64, event_type: &StateEventType, state_key: &str,
) -> Result<Option<Arc<EventId>>>;
2021-04-11 21:01:27 +02:00
/// Returns a single PDU from `room_id` with key (`event_type`,
/// `state_key`).
fn state_get(
2022-04-06 21:31:29 +02:00
&self, shortstatehash: u64, event_type: &StateEventType, state_key: &str,
) -> Result<Option<Arc<PduEvent>>>;
/// Returns the state hash for this pdu.
fn pdu_shortstatehash(&self, event_id: &EventId) -> Result<Option<u64>>;
/// Returns the full room state.
#[allow(unused_qualifications)] // async traits
async fn room_state_full(&self, room_id: &RoomId) -> Result<HashMap<(StateEventType, String), Arc<PduEvent>>>;
2021-04-11 21:01:27 +02:00
/// Returns a single PDU from `room_id` with key (`event_type`,
/// `state_key`).
fn room_state_get_id(
2022-04-06 21:31:29 +02:00
&self, room_id: &RoomId, event_type: &StateEventType, state_key: &str,
) -> Result<Option<Arc<EventId>>>;
/// Returns a single PDU from `room_id` with key (`event_type`,
/// `state_key`).
fn room_state_get(
2022-04-06 21:31:29 +02:00
&self, room_id: &RoomId, event_type: &StateEventType, state_key: &str,
) -> Result<Option<Arc<PduEvent>>>;
}