class

RNS::RawChannelReader(TPacket)

Inherits Reference < Object

Provides an IO-like read interface over a Channel.

Listens for StreamDataMessage packets matching a given stream_id, buffers incoming data, and exposes #read / #readinto for consumption. Supports ready-callbacks so callers can be notified when new data arrives. Generic over TPacket to match the channel's packet type.

Constructors

new(stream_id : Int32, channel : Channel(TPacket))
Source

Instance methods

add_ready_callback(cb : Int32 -> Nil)

Add a callback invoked when new data arrives. Signature: (ready_bytes : Int32) -> Nil

Source
available

Number of bytes available to read without blocking.

Source
close
Source
closed?
Source
eof?

Whether the stream has received EOF.

Source
read(size : Int32) : Bytes | Nil

Read up to size bytes from the internal buffer. Returns Bytes if data available (possibly empty at EOF), nil if no data and not EOF.

Source
readable?
Source
readinto(buffer : Bytes) : Int32 | Nil

Read into a provided buffer (matching Python readinto). Returns number of bytes read, or nil if no data available and not EOF.

Source
remove_ready_callback(cb : Int32 -> Nil)

Remove a previously added callback.

Source
seekable?
Source
writable?
Source