ChunkPoll
struct ChunkPollThe result of one AsyncChunkSource.poll -- a total tri-state.
Exactly one state holds:
- ready: a chunk is available now (
is_ready(); take it withtake_chunk()). - pending: nothing yet; the caller should wait until
wait_fd()is readable and poll again (is_pending()). No busy-poll. - eof: the stream is complete; no more chunks (
is_eof()).
Built only through ready / pending / eof so a chunk can
never coexist with a wait fd.
Implements Movable
__init__
def __init__(out self, _state: Int, var chunk: List[UInt8], fd: Int32) Internal: prefer the ready / pending / eof factories.
ready
def ready(var chunk: List[UInt8]) -> Self A chunk is available now.
pending
def pending(fd: Int32) -> Self Nothing yet; wake and re-poll when fd is readable.
eof
def eof() -> Self The stream is complete.
is_ready
def is_ready(self) -> Bool True if a chunk is available now.
is_pending
def is_pending(self) -> Bool True if the source is waiting on wait_fd().
is_eof
def is_eof(self) -> Bool True if the stream is complete.
wait_fd
def wait_fd(self) -> c_int The fd to wait on (valid only when is_pending(); -1 otherwise).
take_chunk
def take_chunk(mut self) -> List[UInt8] Move the ready chunk out (valid only when is_ready(); leaves the poll holding an empty chunk).
consume
def consume(mut self) -> Optional[List[UInt8]] Collapse the ready/eof split into one move-out.
Returns Some(chunk) when a chunk is ready (moved out, as
take_chunk) and None on EOF. Raises on pending: a
pending poll must be parked on wait_fd() and re-polled, never
consumed. This is the one-call form for callers that drain to EOF
and have already handled the pending branch (the reactor only
delivers an upstream edge when the fd is readable, so a relay loop
sees only ready / eof).