Skip to main content

tuwunel_service/rooms/state_res/
fetch_event.rs

1use ruma::EventId;
2use serde::Deserialize;
3use tuwunel_core::{Result, matrix::pdu::AuthEvents};
4
5#[derive(Deserialize)]
6pub(super) struct AuthRefs {
7	pub(super) auth_events: AuthEvents,
8}
9
10/// Reads events through a copyable handle to their storage.
11///
12/// Callers borrow identifiers and choose the fields they need to decode.
13/// Implementations apply the caller's missing-event policy.
14pub trait FetchEvent: Copy + Send + Sync {
15	/// Decodes an event into the requested representation.
16	///
17	/// Missing-event handling follows the caller's completeness policy.
18	fn get<T>(self, event_id: &EventId) -> impl Future<Output = Result<T>> + Send
19	where
20		T: for<'de> Deserialize<'de> + Send;
21
22	/// Checks whether an event exists without requiring a full decode.
23	///
24	/// Missing events yield false unless the caller requires completeness.
25	fn exists(self, event_id: &EventId) -> impl Future<Output = Result<bool>> + Send;
26}