pub struct WriteBlockHandle {
pub request_tx: Option<Sender<WriteRequest>>,
/* private fields */
}Expand description
Handle for an in-progress WriteBlock bidirectional streaming RPC.
The gRPC call runs in a background tokio task. The caller sends data through
request_tx and receives responses via recv_response(). When done, call
close() to drop the request channel and wait for the server to finalize.
Fields§
§request_tx: Option<Sender<WriteRequest>>Sender for client → server WriteRequest messages (data chunks, flush commands).
Wrapped in Option so that close() can take() the sender (closing
the client→server half of the stream) without violating the move
semantics imposed by this type’s Drop impl. None after close()
has run; senders attempting to use it should treat that as
“stream already closed”.
Implementations§
Source§impl WriteBlockHandle
impl WriteBlockHandle
Sourcepub async fn recv_response(&mut self) -> Result<Option<WriteResponse>>
pub async fn recv_response(&mut self) -> Result<Option<WriteResponse>>
Receive the next WriteResponse from the server (e.g., flush ack).
Returns None if the server has closed the response stream.
Sourcepub async fn close(self) -> Result<()>
pub async fn close(self) -> Result<()>
Close the write stream by dropping the request sender and wait for any final response from the server.
Sourcepub async fn cancel(self)
pub async fn cancel(self)
Cancel the write stream without waiting for server finalization.
Drops the request sender and response receiver immediately and
aborts the background gRPC task so its resources are released
promptly (rather than relying on the implicit “task exits because
channels were dropped” behaviour, which leaves the JoinHandle
detached on drop).
Matches Java’s GrpcBlockingStream.cancel().
Trait Implementations§
Source§impl Drop for WriteBlockHandle
Safety net: aborts the background gRPC task if the handle is dropped
without going through close() / cancel().
impl Drop for WriteBlockHandle
Safety net: aborts the background gRPC task if the handle is dropped
without going through close() / cancel().
Without this, an early ? return on the error path leaves a detached
tokio task that can hang indefinitely on stream.message().await
(e.g. on a half-open server connection that never sends a final response),
keeping the underlying tonic Channel alive and leaking resources.
cancel() and close() already take() the task_handle, so on the
happy path task_handle is None here and abort() is a no-op —
matching the doc-comment on task_handle above.
Auto Trait Implementations§
impl Freeze for WriteBlockHandle
impl RefUnwindSafe for WriteBlockHandle
impl Send for WriteBlockHandle
impl Sync for WriteBlockHandle
impl Unpin for WriteBlockHandle
impl UnsafeUnpin for WriteBlockHandle
impl UnwindSafe for WriteBlockHandle
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request