← Back to the index

Module std/io/bytes.vv

The io/bytes module provides a buffered byte reader.

Example:

import bytes from "std/io/bytes.vv"
import file from "std/fs/file.vv"

let f = try file.reader("test.bin")
let r = try bytes.reader(f, 4096)
let content = try bytes.read(r, 10)

Table of Contents

Exports

fun close(r)

Closes the reader.

  • r: The reader record.

fun read(r, n)

Reads n bytes from the reader.

  • r: The reader record.
  • n: The number of bytes to read.

Returns a result containing a list of bytes.

fun peek(r, n)

Peeks n bytes from the reader without advancing the position.

  • r: The reader record.
  • n: The number of bytes to peek.

Returns a result containing a list of bytes.

fun read_all(r)

Reads all remaining content from the reader.

  • r: The reader record.

Returns a result containing a list of all remaining bytes.

fun reader(source_reader, size)

Creates a buffered reader with the specified buffer size.

  • source_reader: An object with a read(length) method.
  • size: The size of the internal buffer.

Returns a result containing a reader record.