pub struct WorkerConn {
stream: TcpStream,
decoder: FrameDecoder,
scratch: Vec<u8>,
poisoned: bool,
}Fields§
§stream: TcpStream§decoder: FrameDecoder§scratch: Vec<u8>§poisoned: boolSet when the stream is known-corrupt (an id mismatch, a framing/EOF error, or an externally signalled cancellation). A poisoned conn must NOT be reused; the holder kill+respawns (§4.4).
Implementations§
Source§impl WorkerConn
impl WorkerConn
pub fn new(stream: TcpStream) -> Self
Sourcepub async fn request(&mut self, req: &RpcRequest) -> Result<RpcResponse>
pub async fn request(&mut self, req: &RpcRequest) -> Result<RpcResponse>
Send a request and read the matching response frame. On any stream/framing error, or a
response whose id does not equal the request’s, the connection is POISONED (never reused).
async fn request_inner(&mut self, req: &RpcRequest) -> Result<RpcResponse>
Sourcepub async fn request_raw(&mut self, req: &RpcRequest) -> Result<RpcResponse>
pub async fn request_raw(&mut self, req: &RpcRequest) -> Result<RpcResponse>
Like request but does NOT early-return on the poison flag and does NOT set it on error — the
caller drives poisoning explicitly (poison-before-await, unpoison-on-success) so a DROPPED
future (cancellation) leaves the conn poisoned (spec §4.4 poison-on-drop). Still validates the
response id and still errors on a broken/desynced stream.
Sourcepub fn unpoison(&mut self)
pub fn unpoison(&mut self)
Clear the poison flag (used only after a request_raw completes successfully).
Sourcepub fn is_poisoned(&self) -> bool
pub fn is_poisoned(&self) -> bool
True once the connection has been poisoned and must be torn down.
Sourcepub fn poison(&mut self)
pub fn poison(&mut self)
Mark the connection poisoned (e.g. the in-flight request future was dropped/cancelled — §4.4 poison-on-drop: the caller marks it before the next call so the orphaned response frame is never mis-read).
Sourcepub async fn read_frame(&mut self) -> Result<Vec<u8>>
pub async fn read_frame(&mut self) -> Result<Vec<u8>>
Read exactly one complete frame body, pulling from the socket until the decoder yields one.