pub struct GenServerHandle<S: GenServer> { /* private fields */ }Expand description
Handle to a running GenServer.
Provides typed call() and cast() methods. The handle owns a sender to
the server’s mailbox and a oneshot receiver for join.
Implementations§
Source§impl<S: GenServer> GenServerHandle<S>
impl<S: GenServer> GenServerHandle<S>
Sourcepub async fn call(
&self,
cx: &Cx,
request: S::Call,
) -> Result<S::Reply, CallError>
pub async fn call( &self, cx: &Cx, request: S::Call, ) -> Result<S::Reply, CallError>
Send a call (request-response) to the server.
Blocks until the server replies or the server stops. The reply channel
uses obligation-tracked oneshot from channel::session, ensuring that
if the server drops the reply without sending, the obligation token
panics rather than silently losing the reply.
Sourcepub async fn cast(&self, cx: &Cx, msg: S::Cast) -> Result<(), CastError>
pub async fn cast(&self, cx: &Cx, msg: S::Cast) -> Result<(), CastError>
Send a cast (fire-and-forget) to the server.
Sourcepub fn try_cast(&self, msg: S::Cast) -> Result<(), CastError>
pub fn try_cast(&self, msg: S::Cast) -> Result<(), CastError>
Try to send a cast without blocking.
Applies the server’s CastOverflowPolicy when the mailbox is full:
Reject: returnsCastError::FullDropOldest: evicts the oldest message and enqueues the new one
Sourcepub async fn info(&self, cx: &Cx, msg: S::Info) -> Result<(), InfoError>
pub async fn info(&self, cx: &Cx, msg: S::Info) -> Result<(), InfoError>
Send an info message (system/out-of-band) to the server.
Sourcepub fn try_info(&self, msg: S::Info) -> Result<(), InfoError>
pub fn try_info(&self, msg: S::Info) -> Result<(), InfoError>
Try to send an info message without blocking.
Sourcepub fn cast_overflow_policy(&self) -> CastOverflowPolicy
pub fn cast_overflow_policy(&self) -> CastOverflowPolicy
Returns the server’s overflow policy for cast messages.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the server has finished.
Source§impl<S: GenServer> GenServerHandle<S>
impl<S: GenServer> GenServerHandle<S>
Sourcepub fn server_ref(&self) -> GenServerRef<S>
pub fn server_ref(&self) -> GenServerRef<S>
Returns a lightweight, clonable reference for casting.