pub struct SessionLoopState {
pub client_to_backend: ClientToBackendBytes,
pub backend_to_client: BackendToClientBytes,
pub last_reported_c2b: ClientToBackendBytes,
pub last_reported_b2c: BackendToClientBytes,
pub auth_username: Option<String>,
pub skip_auth_check: bool,
/* private fields */
}Expand description
Fields§
§client_to_backend: ClientToBackendBytesBytes sent from client to backend
backend_to_client: BackendToClientBytesBytes sent from backend to client
last_reported_c2b: ClientToBackendBytesLast reported client-to-backend bytes (for incremental metrics)
last_reported_b2c: BackendToClientBytesLast reported backend-to-client bytes (for incremental metrics)
auth_username: Option<String>Username from AUTHINFO USER command (if any)
skip_auth_check: boolWhether to skip auth checking (optimization after first auth)
Implementations§
Source§impl SessionLoopState
impl SessionLoopState
Sourcepub fn new(auth_enabled: bool) -> Self
pub fn new(auth_enabled: bool) -> Self
Create new session loop state
§Arguments
auth_enabled- If true, auth checking starts enabled; if false, it’s skipped
Sourcepub fn from_initial_bytes(
client_to_backend: u64,
backend_to_client: u64,
auth_enabled: bool,
) -> Self
pub fn from_initial_bytes( client_to_backend: u64, backend_to_client: u64, auth_enabled: bool, ) -> Self
Create session loop state with initial byte counts
Used by hybrid mode when switching from per-command to stateful, to carry forward the bytes already transferred.
Sourcepub const fn with_initial_bytes(self, c2b: u64, b2c: u64) -> Self
pub const fn with_initial_bytes(self, c2b: u64, b2c: u64) -> Self
Builder method: set initial byte counts
Sourcepub const fn check_and_maybe_flush_metrics(&mut self) -> bool
pub const fn check_and_maybe_flush_metrics(&mut self) -> bool
Check if metrics should be flushed and reset counter if so
Returns true every METRICS_FLUSH_INTERVAL iterations.
Sourcepub const fn add_client_to_backend(&mut self, bytes: usize)
pub const fn add_client_to_backend(&mut self, bytes: usize)
Add bytes to client-to-backend counter
Sourcepub const fn add_backend_to_client(&mut self, bytes: u64)
pub const fn add_backend_to_client(&mut self, bytes: u64)
Add bytes to backend-to-client counter
Sourcepub fn flush_byte_deltas(
&mut self,
metrics: &MetricsCollector,
backend_id: BackendId,
username: Option<&str>,
)
pub fn flush_byte_deltas( &mut self, metrics: &MetricsCollector, backend_id: BackendId, username: Option<&str>, )
Flush accumulated byte deltas to the metrics collector.
Reports the difference since the last flush and updates the last-reported watermarks. Used by both the periodic in-loop flush and the final flush on disconnect.
Sourcepub fn into_metrics(self) -> TransferMetrics
pub fn into_metrics(self) -> TransferMetrics
Convert to final transfer metrics
Sourcepub fn mark_authenticated(&mut self)
pub fn mark_authenticated(&mut self)
Mark authentication as complete (skip future checks)
Sourcepub fn apply_auth_result(&mut self, result: &AuthHandlerResult) -> u64
pub fn apply_auth_result(&mut self, result: &AuthHandlerResult) -> u64
Update state based on auth handler result
Returns the bytes written for convenience in chaining.
Sourcepub fn mark_backend_request_sent(&mut self, kind: RequestKind)
pub fn mark_backend_request_sent(&mut self, kind: RequestKind)
Mark that a backend request was forwarded and its reply must be ordered first.
Sourcepub fn has_pending_backend_replies(&self) -> bool
pub fn has_pending_backend_replies(&self) -> bool
Whether earlier forwarded backend replies are still ahead of any deferred local replies.
Sourcepub fn push_deferred_reply(&mut self, reply: &'static [u8])
pub fn push_deferred_reply(&mut self, reply: &'static [u8])
Queue a local reply until earlier backend output has been sent.
Sourcepub fn has_deferred_replies(&self) -> bool
pub fn has_deferred_replies(&self) -> bool
Whether deferred local replies remain queued.
Sourcepub fn read_mode(&self) -> StatefulReadMode
pub fn read_mode(&self) -> StatefulReadMode
Reading mode for the stateful loop.
Sourcepub fn take_ready_deferred_replies(&mut self) -> SmallVec<[&'static [u8]; 2]>
pub fn take_ready_deferred_replies(&mut self) -> SmallVec<[&'static [u8]; 2]>
Drain deferred local replies that are ready at the front of the ordered queue.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionLoopState
impl RefUnwindSafe for SessionLoopState
impl Send for SessionLoopState
impl Sync for SessionLoopState
impl Unpin for SessionLoopState
impl UnsafeUnpin for SessionLoopState
impl UnwindSafe for SessionLoopState
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 more