stringio

In-Memory String I/O

Functions

FunctionDescription
_sio_byte_at
_sio_copy
sio_newCreate empty StringIO with given capacity.
sio_fromCreate StringIO from existing string.
sio_writeWrite data at current position. Returns bytes written.
sio_readRead n bytes from current position. Returns bytes read.
sio_getlineRead until newline or max bytes. Returns bytes read (including newline).
sio_seekSet read/write position.
sio_rewindReset position to beginning.
sio_eof1 if at end of data.
sio_lenCurrent data length.
sio_posCurrent read/write position.
sio_stringCopy all contents to out buffer. Returns length.
sio_putcWrite a single byte at current position.
sio_getcRead a single byte at current position. Returns -1 at EOF.

Details

_sio_byte_at

fn _sio_byte_at(buf: &i8, idx: i64) -> i64

_sio_copy

fn _sio_copy(dst: &i8, doff: i64, src: &i8, soff: i64, n: i64)

sio_new

fn sio_new(cap: i64) -> &i64

Create empty StringIO with given capacity.

sio_from

fn sio_from(src: &i8, len: i64) -> &i64

Create StringIO from existing string.

sio_write

fn sio_write(sio: &i64, data: &i8, dlen: i64) -> i64

Write data at current position. Returns bytes written.

sio_read

fn sio_read(sio: &i64, out: &i8, n: i64) -> i64

Read n bytes from current position. Returns bytes read.

sio_getline

fn sio_getline(sio: &i64, out: &i8, max: i64) -> i64

Read until newline or max bytes. Returns bytes read (including newline).

sio_seek

fn sio_seek(sio: &i64, pos: i64)

Set read/write position.

sio_rewind

fn sio_rewind(sio: &i64)

Reset position to beginning.

sio_eof

fn sio_eof(sio: &i64) -> i64

1 if at end of data.

sio_len

fn sio_len(sio: &i64) -> i64

Current data length.

sio_pos

fn sio_pos(sio: &i64) -> i64

Current read/write position.

sio_string

fn sio_string(sio: &i64, out: &i8) -> i64

Copy all contents to out buffer. Returns length.

sio_putc

fn sio_putc(sio: &i64, ch: i64) -> i64

Write a single byte at current position.

sio_getc

fn sio_getc(sio: &i64) -> i64

Read a single byte at current position. Returns -1 at EOF.