pub struct OnDisconnectGuard { /* private fields */ }server only.Expand description
Reports a connection’s disconnect to AccessControl when dropped.
A guard is created the moment AccessControl::on_connect admits a
connection, and is then held for the connection’s entire lifetime. Dropping
it - whether the connection closed cleanly, hit an error, or setup returned
early - calls AccessControl::on_disconnect exactly once.
Threading the guard through connection setup and into the connection actor makes it impossible to admit a connection without eventually reporting its disconnect, even as the surrounding code changes.
Embedders that register connections through Clients::register construct
the guard themselves; see that method for the expected lifecycle.
Implementations§
Source§impl OnDisconnectGuard
impl OnDisconnectGuard
Sourcepub fn for_access_control(
access: Arc<dyn DynAccessControl>,
request: &ClientRequest,
) -> Self
pub fn for_access_control( access: Arc<dyn DynAccessControl>, request: &ClientRequest, ) -> Self
Creates a guard for the connection described by request.
Dropping the guard calls AccessControl::on_disconnect on access
with the request’s EndpointId and ConnectionId. Create it only
once AccessControl::on_connect has admitted the connection.
Sourcepub fn empty(endpoint_id: EndpointId) -> Self
pub fn empty(endpoint_id: EndpointId) -> Self
Creates a no-op guard for endpoint_id.
The guard carries endpoint_id and a fresh ConnectionId but has no
access control attached, so dropping it does nothing.
Sourcepub fn endpoint_id(&self) -> EndpointId
pub fn endpoint_id(&self) -> EndpointId
Returns the EndpointId of the guarded connection.
Sourcepub fn connection_id(&self) -> ConnectionId
pub fn connection_id(&self) -> ConnectionId
Returns the ConnectionId of the guarded connection.
Trait Implementations§
Source§impl Debug for OnDisconnectGuard
impl Debug for OnDisconnectGuard
Auto Trait Implementations§
impl Freeze for OnDisconnectGuard
impl !RefUnwindSafe for OnDisconnectGuard
impl Send for OnDisconnectGuard
impl Sync for OnDisconnectGuard
impl Unpin for OnDisconnectGuard
impl !UnwindSafe for OnDisconnectGuard
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<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 more