pub struct SyncV4Handler<T: TransactedSyncV4Queries, S> {
transaction: T,
stage: S,
}Expand description
This is the state machine handling sync v4 requests.
It contains a database transaction to be used throughout the whole request handling, as well as the per-stage data.
Fields§
§transaction: TThe database transaction to be used throughout the whole request handling.
stage: SThe data associated to the stage the handler is currently in.
Implementations§
Source§impl<'a> SyncV4Handler<TransactedDb<'a>, ResolvedConnection>
impl<'a> SyncV4Handler<TransactedDb<'a>, ResolvedConnection>
Sourcepub async fn connect(
database: &'a mut DefaultDb,
key: ConnectionKey,
pos: Option<String>,
) -> Result<SyncV4Handler<TransactedDb<'a>, ResolvedConnection>, SyncV4Error>
pub async fn connect( database: &'a mut DefaultDb, key: ConnectionKey, pos: Option<String>, ) -> Result<SyncV4Handler<TransactedDb<'a>, ResolvedConnection>, SyncV4Error>
Connects a SyncV4Handler to the database (by starting a transaction) and to the user’s connection.
This is the start of handling a sync v4 request.
Source§impl<T: TransactedSyncV4Queries> SyncV4Handler<T, ResolvedConnection>
impl<T: TransactedSyncV4Queries> SyncV4Handler<T, ResolvedConnection>
Sourcepub async fn gather(self) -> Result<SyncV4Handler<T, SyncV4Inputs>, SyncV4Error>
pub async fn gather(self) -> Result<SyncV4Handler<T, SyncV4Inputs>, SyncV4Error>
Gather everything we’ll need to handle the current request.
This is the second step of handling a sync v4 request.
Source§impl<T: TransactedSyncV4Queries> SyncV4Handler<T, SyncV4Inputs>
impl<T: TransactedSyncV4Queries> SyncV4Handler<T, SyncV4Inputs>
Sourcepub fn plan(
self,
request: &Request,
) -> Result<SyncV4Handler<T, SyncV4Plan>, SyncV4Error>
pub fn plan( self, request: &Request, ) -> Result<SyncV4Handler<T, SyncV4Plan>, SyncV4Error>
Plan the current sync v4 request handling.
This is the core of sync v4 where we compute which data will be part of the current sync (if any) by applying the request to the user’s rooms, as well as the per-connection state.
This is the third step of handling a sync v4 request, in which all the core logic occurs.
Source§impl<T: TransactedSyncV4Queries> SyncV4Handler<T, SyncV4Plan>
impl<T: TransactedSyncV4Queries> SyncV4Handler<T, SyncV4Plan>
Sourcepub fn has_data_to_sync(&self) -> bool
pub fn has_data_to_sync(&self) -> bool
Tells whether the computed plan actually contains data to sync or not.
Source§impl SyncV4Handler<TransactedDb<'_>, SyncV4Plan>
impl SyncV4Handler<TransactedDb<'_>, SyncV4Plan>
Sourcepub(crate) async fn execute(self) -> Result<Persisted, SyncV4Error>
pub(crate) async fn execute(self) -> Result<Persisted, SyncV4Error>
Execute the computed plan::SyncV4Plan.
This will compute the actual content of the sync response, as well as create a new position in the per-connection state which will store what the current request produced.
NOTE: This is to be ran when plan::SyncV4Plan::has_data_to_sync returns true.
This is the final step of handling a sync v4 request.
Sourcepub(crate) async fn persist_without_position(
self,
) -> Result<Persisted, SyncV4Error>
pub(crate) async fn persist_without_position( self, ) -> Result<Persisted, SyncV4Error>
Execute the computed plan::SyncV4Plan to produce an empty response.
This will simply update the previous position’s state if needs be.
NOTE: This is to be ran when plan::SyncV4Plan::has_data_to_sync returns false.
This is the final step of handling a sync v4 request.
Trait Implementations§
Auto Trait Implementations§
impl<T, S> Freeze for SyncV4Handler<T, S>
impl<T, S> RefUnwindSafe for SyncV4Handler<T, S>where
T: RefUnwindSafe,
S: RefUnwindSafe,
impl<T, S> Send for SyncV4Handler<T, S>
impl<T, S> Sync for SyncV4Handler<T, S>
impl<T, S> Unpin for SyncV4Handler<T, S>
impl<T, S> UnsafeUnpin for SyncV4Handler<T, S>where
T: UnsafeUnpin,
S: UnsafeUnpin,
impl<T, S> UnwindSafe for SyncV4Handler<T, S>where
T: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more