pub struct SessionSlot { /* private fields */ }Expand description
Shared between all clones of one server; the live instance is replaced only on a project change.
Implementations§
Source§impl SessionSlot
impl SessionSlot
pub fn new(session: SharedSession) -> Self
Sourcepub fn remember_own(&self, project_root: &str, session_id: &str)
pub fn remember_own(&self, project_root: &str, session_id: &str)
Record that this server’s session for project_root is session_id.
Sourcepub fn own_session_id(&self, project_root: &str) -> Option<String>
pub fn own_session_id(&self, project_root: &str) -> Option<String>
The session this server left project_root with, if any.
Sourcepub fn live(&self) -> SharedSession
pub fn live(&self) -> SharedSession
The instance new requests bind to, ignoring any request binding.
Sourcepub fn instance(&self) -> SharedSession
pub fn instance(&self) -> SharedSession
The instance this request is bound to, or the live one outside a bound request.
pub async fn read(&self) -> OwnedRwLockReadGuard<SessionState>
pub async fn write(&self) -> OwnedRwLockWriteGuard<SessionState>
Sourcepub fn replace_if_live(
&self,
current: &SharedSession,
next: SharedSession,
) -> bool
pub fn replace_if_live( &self, current: &SharedSession, next: SharedSession, ) -> bool
Install next as the live instance if current still is it. Requests
already bound keep the previous one. false: another switch won.
Sourcepub fn rebind(&self, next: SharedSession)
pub fn rebind(&self, next: SharedSession)
Move the current request’s binding to next: a request that switched
the session itself continues in the new one. No-op outside a bound
request.
Sourcepub async fn scope<F: Future>(&self, request: F) -> F::Output
pub async fn scope<F: Future>(&self, request: F) -> F::Output
Run one request with an empty binding; Self::pin fills it.
A request that ends bound to an instance no longer live saves its late changes there, under that session’s own project: the batch cadence that would otherwise pick them up only runs on the live instance.
Sourcepub fn pin(&self)
pub fn pin(&self)
Bind the current request to the live instance once its roots are
resolved. A request keeps its first binding; outside Self::scope
this is a no-op.
Trait Implementations§
Auto Trait Implementations§
impl Forget for SessionSlot
impl Freeze for SessionSlot
impl Move for SessionSlot
impl RefUnwindSafe for SessionSlot
impl Send for SessionSlot
impl Sync for SessionSlot
impl Unpin for SessionSlot
impl UnsafeUnpin for SessionSlot
impl UnwindSafe for SessionSlot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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