Skip to main content

FetchState

Trait FetchState 

Source
pub trait FetchState:
    Copy
    + Send
    + Sync {
    type Pdu: Event;

    // Required method
    fn get(
        self,
        ty: StateEventType,
        key: StateKey,
    ) -> impl Future<Output = Result<Self::Pdu>> + Send;

    // Provided methods
    fn room_create_event(
        self,
    ) -> impl Future<Output = Result<RoomCreateEvent<Self::Pdu>>> + Send { ... }
    fn user_membership(
        self,
        user_id: &UserId,
    ) -> impl Future<Output = Result<MembershipState>> + Send { ... }
    fn room_power_levels_event(
        self,
    ) -> impl Future<Output = Result<Option<RoomPowerLevelsEvent<Self::Pdu>>>> + Send { ... }
    fn join_rule(self) -> impl Future<Output = Result<JoinRule>> + Send { ... }
    fn room_third_party_invite_event(
        self,
        token: &str,
    ) -> impl Future<Output = Result<Option<RoomThirdPartyInviteEvent<Self::Pdu>>>> + Send { ... }
}
Expand description

Reads authorization state through a copyable handle.

Implementations may return owned events or borrow events held by the state snapshot.

Required Associated Types§

Source

type Pdu: Event

Event representation returned by this state snapshot.

Borrowed representations avoid cloning events during authorization.

Required Methods§

Source

fn get( self, ty: StateEventType, key: StateKey, ) -> impl Future<Output = Result<Self::Pdu>> + Send

Reads the event for an exact state tuple.

Missing tuples return a not-found error under the snapshot’s completeness policy.

Provided Methods§

Source

fn room_create_event( self, ) -> impl Future<Output = Result<RoomCreateEvent<Self::Pdu>>> + Send

Reads the room creation event.

Missing creation state is an authorization input error.

Source

fn user_membership( self, user_id: &UserId, ) -> impl Future<Output = Result<MembershipState>> + Send

Reads a user membership from the state snapshot.

Missing membership follows the member-event defaulting rules.

Source

fn room_power_levels_event( self, ) -> impl Future<Output = Result<Option<RoomPowerLevelsEvent<Self::Pdu>>>> + Send

Reads the optional room power levels event.

Missing power levels return no event.

Source

fn join_rule(self) -> impl Future<Output = Result<JoinRule>> + Send

Reads the current room join rule.

Missing join-rule state is an authorization input error.

Source

fn room_third_party_invite_event( self, token: &str, ) -> impl Future<Output = Result<Option<RoomThirdPartyInviteEvent<Self::Pdu>>>> + Send

Reads the invitation matching a third-party token.

Missing invitation state returns no event.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<'a> FetchState for &'a [(TypeStateKey, PduEvent)]

Source§

type Pdu = &'a Pdu

Source§

fn get( self, ty: StateEventType, key: StateKey, ) -> impl Future<Output = Result<Self::Pdu>> + Send

Source§

impl<F, Fut> FetchState for &F
where F: Fn(StateEventType, StateKey) -> Fut + Sync, Fut: Future<Output = Result<PduEvent>> + Send,

Source§

type Pdu = Pdu

Source§

fn get( self, event_type: StateEventType, state_key: StateKey, ) -> impl Future<Output = Result<Self::Pdu>> + Send

Implementors§