gossamer/readable_stream/byob_reader
Types
A reader over a byte ReadableStream that reads into caller-provided
buffers.
See ReadableStreamBYOBReader on MDN.
pub type ByobReader(a)
pub type ByobReaderReadOption {
Min(Int)
}
Constructors
-
Min(Int)
Values
pub fn cancel(
reader: ByobReader(a),
reason reason: r,
) -> promise.Promise(Result(Nil, js_error.JsError))
Cancels the stream and releases the reader’s lock. Returns an error if the underlying cancel fails.
pub fn closed(
of reader: ByobReader(a),
) -> promise.Promise(Result(Nil, js_error.JsError))
Resolves when the stream closes. Returns an error if the stream errored.
pub fn read(
reader: ByobReader(a),
into view: typed_array.TypedArray,
with options: List(ByobReaderReadOption),
) -> promise.Promise(
Result(
read_result.ReadResult(typed_array.TypedArray),
js_error.JsError,
),
)
Reads bytes from the stream into view. The returned chunk is a new
TypedArray over the same underlying buffer, since the original
view is detached during the read. Returns an error if the stream
errored or the reader was released.
pub fn read_data_view(
reader: ByobReader(a),
into view: data_view.DataView,
with options: List(ByobReaderReadOption),
) -> promise.Promise(
Result(
read_result.ReadResult(data_view.DataView),
js_error.JsError,
),
)
Reads bytes from the stream into view. The returned chunk is a new
DataView over the same underlying buffer, since the original view
is detached during the read. Returns an error if the stream errored
or the reader was released.
pub fn release_lock(
reader: ByobReader(a),
) -> Result(ByobReader(a), js_error.JsError)
Releases the reader’s lock on the stream. Returns an error if the reader has outstanding read requests.