pub struct ChatStateHandle;Expand description
The account’s chats and profiles in memory.
Locking resolves the session THIS work belongs to, so a task bound by
crate::db::spawn_bound reaches the state of the account it started
under — for its whole life, whoever logs in meanwhile. A swap installs a
fresh session, and with it a fresh state; the previous account’s is dropped
with the session rather than cleared field by field.
Deliberately a handle rather than the Mutex itself: STATE.lock().await
reads the same at every call site, and cannot be hoisted into a static or
a long-lived struct where it would freeze one account’s state in place.
Implementations§
Source§impl ChatStateHandle
impl ChatStateHandle
pub async fn lock(&self) -> OwnedMutexGuard<ChatState>
Sourcepub fn try_lock(&self) -> Result<OwnedMutexGuard<ChatState>, TryLockError>
pub fn try_lock(&self) -> Result<OwnedMutexGuard<ChatState>, TryLockError>
For callers that must not block — notably Android’s WebView threads, which have no tokio runtime.
Auto Trait Implementations§
impl Freeze for ChatStateHandle
impl RefUnwindSafe for ChatStateHandle
impl Send for ChatStateHandle
impl Sync for ChatStateHandle
impl Unpin for ChatStateHandle
impl UnsafeUnpin for ChatStateHandle
impl UnwindSafe for ChatStateHandle
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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