Skip to main content

tuwunel_matrix/room/state/resolution/
fetch_event.rs

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