Conn
struct ConnImplements Movable
- Fields
stream: Streamclosed: Bool: The peer hung up, or the connection failed.connecting: Bool: Started withStream.start_connectand not yet connected: output queues until it is.deadline: UInt64: While connecting: when to give up, inwall_ns; 0 for never.why: String: Why the connection failed, if it's known.
__init__
def __init__(out self, var stream: Stream) fd
def fd(self) -> c_int read_available
def read_available(mut self, limit: Int = Int(0)) Reads what's waiting on the socket into the input buffer, or a large frame's own: all of it, or with limit, about that many bytes, leaving the rest in the socket, where poll still reports it.
next_frame
def next_frame(mut self) -> Optional[Frame] The next complete frame, if there is one.
send
def send(mut self, kind: UInt8, object_id: UInt64, task_id: UInt64, payload: Span[UInt8]) Queues a frame and sends as much as the socket takes now.
finish_connect
def finish_connect(mut self) The socket polled writable while connecting: connected, or raises why not.
send_parts
def send_parts(mut self, object_id: UInt64, data: Span[UInt8], part: Int) Queues object object_id as part frames of at most part bytes, and sends as much as the socket takes now.
queue
def queue(mut self, data: Span[UInt8]) Adds bytes to the output buffer without sending them: part of a frame whose header went before; flush sends them.
flush
def flush(mut self) Sends queued output until the socket would block.
release_buffers
def release_buffers(mut self) Frees both buffers, of a connection that's closed.
wants_write
def wants_write(self) -> Bool unsent
def unsent(self) -> Int Bytes queued to send that the peer hasn't taken yet.