pub struct NamedGenServerHandle<S: GenServer> { /* private fields */ }Expand description
Handle to a running named GenServer.
Wraps a GenServerHandle together with a [NameLease] from the
registry. The lease is an obligation (drop bomb): callers must resolve it
by calling release_name or
abort_lease before dropping.
All call, cast, info methods delegate to the inner handle.
Implementations§
Source§impl<S: GenServer> NamedGenServerHandle<S>
impl<S: GenServer> NamedGenServerHandle<S>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the server has finished execution.
Sourcepub fn server_ref(&self) -> GenServerRef<S>
pub fn server_ref(&self) -> GenServerRef<S>
Create a lightweight server reference for sending messages.
Sourcepub fn inner(&self) -> &GenServerHandle<S>
pub fn inner(&self) -> &GenServerHandle<S>
Access the inner (unnamed) handle.
Sourcepub fn release_name(
&mut self,
registry: &mut NameRegistry,
now: Time,
) -> Result<(), ReleaseNameError>
pub fn release_name( &mut self, registry: &mut NameRegistry, now: Time, ) -> Result<(), ReleaseNameError>
Release the name lease (commit) after the server has already stopped.
Callers should first request graceful shutdown via stop
and then drive or join the server to completion. This method only
removes the registry entry and resolves the lease once the underlying
server task is no longer live, preserving the invariant that a running
server keeps its name.
§Errors
Returns ReleaseNameError::StillRunning if the underlying server
task has not finished yet. Returns ReleaseNameError::Lease if
the lease was already resolved or moved out via
take_lease, or if lease resolution fails.
Sourcepub fn abort_lease(
&mut self,
registry: &mut NameRegistry,
now: Time,
) -> Result<(), NameLeaseError>
pub fn abort_lease( &mut self, registry: &mut NameRegistry, now: Time, ) -> Result<(), NameLeaseError>
Abort the name lease without stopping the server.
Use this for cancellation / error paths where the name registration itself should be rolled back.
§Errors
Returns crate::cx::NameLeaseError::AlreadyResolved if the lease was
already resolved or moved out via take_lease.
Sourcepub fn take_lease(&mut self) -> Option<NameLease>
pub fn take_lease(&mut self) -> Option<NameLease>
Take ownership of the lease (for manual lifecycle management).
After this call, the handle no longer owns the lease; the caller is
responsible for removing the matching registry entry (for example via
crate::cx::NameRegistry::unregister_owned_and_grant) and then
resolving the lease obligation.