XU XUv0.16.0

#io

import: #io

counts: 25 functions, 39 methods, 17 types, 1 constants, 6 method sets

Buffer / Cursor, stream copying, EOF/error results with data, and write-progress contracts; also multi/tee/section/pipe.

const EOF

XuAPI
pub const EOF = "EOF"

Purpose

Constant EOF, defining protocol or algorithm parameters.

struct@ Writer

XuAPI
struct@ Writer {
    fn write(&string) int
}

Purpose

Writer data I/O method-set constraint.

Required methods

write fn write(&string) int
Operation on Writer: write data and return the byte count.

(Writer) write

XuAPI
fn write(&string) int

Purpose

Operation on Writer: write data and return the byte count.

Parameters

self Self
The Self instance used by this call (value receiver).
string &string
string (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

struct@ Reader

XuAPI
struct@ Reader {
    fn read_n(int) string
}

Purpose

Reader data I/O method-set constraint.

Required methods

read_n fn read_n(int) string
Operation on Reader: read at most n bytes; may return shorter or empty at end.

(Reader) read_n

XuAPI
fn read_n(int) string

Purpose

Operation on Reader: read at most n bytes; may return shorter or empty at end.

Parameters

self Self
The Self instance used by this call (value receiver).
int int
int (int)

Returns

string — result string

struct Buffer

XuAPI
pub struct Buffer {
    pub data string
    pub off int
}

Purpose

Structure encapsulating data, off.

Public fields

data string
data
off int
offset

struct Cursor

XuAPI
pub struct Cursor {
    pub data string
    pub off int
}

Purpose

Structure encapsulating data, off.

Public fields

data string
data
off int
offset

buffer

XuAPI
pub fn buffer() Buffer

Purpose

Execute buffer.

Parameters

No arguments are required.

Returns

Buffer — a value of this type

buffer_from

XuAPI
pub fn buffer_from(s string) Buffer

Purpose

Buffer from.

Parameters

s string
source string (string)

Returns

Buffer — a value of this type

cursor

XuAPI
pub fn cursor(s string) Cursor

Purpose

Execute cursor.

Parameters

s string
source string (string)

Returns

Cursor — a value of this type

($&Cursor) reset

XuAPI
pub fn (c $&Cursor) reset(s string)

Purpose

Operation on $&Cursor: clear internal state so the value can be reused.

Parameters

c $&Cursor
The Cursor instance used by this call (exclusive borrow).
s string
source string (string)

Returns

This call does not return a value.

($&Buffer) reset

XuAPI
pub fn (b $&Buffer) reset()

Purpose

Operation on $&Buffer: clear internal state so the value can be reused.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).

Returns

This call does not return a value.

(&Buffer) len

XuAPI
pub fn (b &Buffer) len() int

Purpose

Operation on &Buffer: return the length.

Parameters

b &Buffer
The Buffer instance used by this call (borrow).

Returns

int — a value of this type

(&Buffer) cap

XuAPI
pub fn (b &Buffer) cap() int

Purpose

Operation on &Buffer: return the capacity.

Parameters

b &Buffer
The Buffer instance used by this call (borrow).

Returns

int — a value of this type

(&Cursor) size

XuAPI
pub fn (c &Cursor) size() int

Purpose

Operation on &Cursor: return the size.

Parameters

c &Cursor
The Cursor instance used by this call (borrow).

Returns

int — a value of this type

($&Buffer) write

XuAPI
pub fn (b $&Buffer) write(data &string) int

Purpose

Operation on $&Buffer: write data and return the byte count.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

($&Buffer) write_str

XuAPI
pub fn (b $&Buffer) write_str(s string) int

Purpose

write_str appends an owned string without requiring a borrow of a local.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
s string
source string (string)

Returns

int — a value of this type

($&Buffer) write_byte

XuAPI
pub fn (b $&Buffer) write_byte(c int) int

Purpose

Operation on $&Buffer: write one byte.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
c int
byte or character code (int)

Returns

int — bytes written

($&Buffer) read_n

XuAPI
pub fn (b $&Buffer) read_n(n int) string

Purpose

Operation on $&Buffer: read at most n bytes; may return shorter or empty at end.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

(&Buffer) bytes

XuAPI
pub fn (b &Buffer) bytes() string

Purpose

Operation on &Buffer: return the buffered bytes.

Parameters

b &Buffer
The Buffer instance used by this call (borrow).

Returns

string — result string

($&Cursor) read_n

XuAPI
pub fn (c $&Cursor) read_n(n int) string

Purpose

Operation on $&Cursor: read at most n bytes; may return shorter or empty at end.

Parameters

c $&Cursor
The Cursor instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

copy

XuAPI
pub fn copy(dst Buffer, src Cursor) string

Purpose

Drain src cursor into dst buffer until EOF, returning remaining bytes.

Parameters

dst Buffer
destination buffer
src Cursor
source cursor

Returns

written string content

copy_to

XuAPI
pub fn copy_to(dst Buffer, src Cursor) Buffer

Purpose

copy_to is the Buffer-returning form.

Parameters

dst Buffer
destination (Buffer)
src Cursor
source (Cursor)

Returns

Buffer — a value of this type

read_all

XuAPI
pub fn read_all(src Cursor) string

Purpose

Read all.

Parameters

src Cursor
source (Cursor)

Returns

string — result string

(&Cursor) remaining

XuAPI
pub fn (c &Cursor) remaining() int

Purpose

Execute remaining on &Cursor.

Parameters

c &Cursor
The Cursor instance used by this call (borrow).

Returns

int — a value of this type

($&Cursor) seek

XuAPI
pub fn (c $&Cursor) seek(offset int, whence int) int

Purpose

Operation on $&Cursor: move the read position. whence 0/1/2 = absolute / relative / from end. Throws on failure; handle the error or propagate it to the caller.

Parameters

c $&Cursor
The Cursor instance used by this call (exclusive borrow).
offset int
offset (int)
whence int
seek base: 0 start / 1 current / 2 end (int)

Returns

int — a value of this type

(&Cursor) read_at

XuAPI
pub fn (c &Cursor) read_at(n int, off int) string

Purpose

Operation on &Cursor: read at most n bytes starting at offset off. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Cursor
The Cursor instance used by this call (borrow).
n int
count, length, or limit (int)
off int
offset (int)

Returns

string — result string

read_full

XuAPI
pub fn read_full(src Cursor, n int) string

Purpose

Read full.

Parameters

src Cursor
source (Cursor)
n int
count, length, or limit (int)

Returns

string — result string

read_at_least

XuAPI
pub fn read_at_least(src Cursor, min int, max int) string

Purpose

Read at least. Throws on failure; handle the error or propagate it to the caller.

Parameters

src Cursor
source (Cursor)
min int
minimum (int)
max int
maximum (int)

Returns

string — result string

copy_n

XuAPI
pub fn copy_n(dst Buffer, src Cursor, n int) string

Purpose

Copy n. Throws on failure; handle the error or propagate it to the caller.

Parameters

dst Buffer
destination (Buffer)
src Cursor
source (Cursor)
n int
count, length, or limit (int)

Returns

string — result string

struct LimitCursor

XuAPI
pub struct LimitCursor {
    pub src Cursor
    pub n int
}

Purpose

Structure encapsulating src, n.

Public fields

src Cursor
source
n int
count, length, or limit

limit_cursor

XuAPI
pub fn limit_cursor(src Cursor, n int) LimitCursor

Purpose

Limit cursor.

Parameters

src Cursor
source (Cursor)
n int
count, length, or limit (int)

Returns

LimitCursor — a value of this type

(LimitCursor) remaining

XuAPI
pub fn (l LimitCursor) remaining() int

Purpose

Execute remaining on LimitCursor.

Parameters

l LimitCursor
The LimitCursor instance used by this call (value receiver).

Returns

int — a value of this type

($&LimitCursor) read_n

XuAPI
pub fn (l $&LimitCursor) read_n(n int) string

Purpose

Operation on $&LimitCursor: read at most n bytes; may return shorter or empty at end.

Parameters

l $&LimitCursor
The LimitCursor instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

struct Discard

XuAPI
pub struct Discard {
    pub n int
}

Purpose

Structure encapsulating n.

Public fields

n int
count, length, or limit

discard

XuAPI
pub fn discard() Discard

Purpose

Execute discard.

Parameters

No arguments are required.

Returns

Discard — a value of this type

($&Discard) write

XuAPI
pub fn (d $&Discard) write(data &string) int

Purpose

Operation on $&Discard: write data and return the byte count.

Parameters

d $&Discard
The Discard instance used by this call (exclusive borrow).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

(Discard) written

XuAPI
pub fn (d Discard) written() int

Purpose

Execute written on Discard.

Parameters

d Discard
The Discard instance used by this call (value receiver).

Returns

int — a value of this type

struct MultiCursor

XuAPI
pub struct MultiCursor {
    pub chunks []string
    pub i int
    pub off int
}

Purpose

Concatenate string snapshots ( MultiReader, bound to Cursor-shaped chunks — no generic Reader). One read_n drains the current chunk only empty/exhausted chunks are skipped in the same call.

Public fields

chunks []string
field ([]string)
i int
index or integer
off int
offset

multi_cursor

XuAPI
pub fn multi_cursor(parts <-> string) MultiCursor

Purpose

Multi cursor.

Parameters

parts <-> string
variadic string (seen inside the function as []string)

Returns

MultiCursor — a value of this type

($&MultiCursor) read_n

XuAPI
pub fn (m $&MultiCursor) read_n(n int) string

Purpose

Operation on $&MultiCursor: read at most n bytes; may return shorter or empty at end.

Parameters

m $&MultiCursor
The MultiCursor instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

struct MultiBuffer

XuAPI
pub struct MultiBuffer {
    pub parts []string
}

Purpose

Write the same bytes to n owning destinations ( MultiWriter).

Public fields

parts []string
parts

multi_buffer

XuAPI
pub fn multi_buffer(n int) MultiBuffer

Purpose

Multi buffer.

Parameters

n int
count, length, or limit (int)

Returns

MultiBuffer — a value of this type

($&MultiBuffer) write

XuAPI
pub fn (m $&MultiBuffer) write(data &string) int

Purpose

Operation on $&MultiBuffer: write data and return the byte count.

Parameters

m $&MultiBuffer
The MultiBuffer instance used by this call (exclusive borrow).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

(&MultiBuffer) text

XuAPI
pub fn (m &MultiBuffer) text(i int) string

Purpose

Operation on &MultiBuffer: return the current text.

Parameters

m &MultiBuffer
The MultiBuffer instance used by this call (borrow).
i int
index or integer (int)

Returns

string — result string

struct Tee

XuAPI
pub struct Tee {
    pub src Cursor
    pub dst Buffer
}

Purpose

Read from src, copy each chunk into dst ( TeeReader).

Public fields

src Cursor
source
dst Buffer
destination

tee

XuAPI
pub fn tee(src Cursor, dst Buffer) Tee

Purpose

Construct a Tee reader that mirrors every read chunk into dst.

Parameters

src Cursor
source (Cursor)
dst Buffer
destination (Buffer)

Returns

Tee — a value of this type

($&Tee) read_n

XuAPI
pub fn (t $&Tee) read_n(n int) string

Purpose

Operation on $&Tee: read at most n bytes; may return shorter or empty at end.

Parameters

t $&Tee
The Tee instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

(&Tee) copied

XuAPI
pub fn (t &Tee) copied() string

Purpose

Execute copied on &Tee.

Parameters

t &Tee
The Tee instance used by this call (borrow).

Returns

string — result string

struct SectionCursor

XuAPI
pub struct SectionCursor {
    pub data string
    pub base int
    pub limit int
    pub off int
}

Purpose

Window into a string snapshot ( SectionReader + ReadAt/Seek).

Public fields

data string
data
base int
numeric base
limit int
field (int)
off int
offset

section_cursor

XuAPI
pub fn section_cursor(s string, off int, n int) SectionCursor

Purpose

Section cursor.

Parameters

s string
source string (string)
off int
offset (int)
n int
count, length, or limit (int)

Returns

SectionCursor — a value of this type

($&SectionCursor) read_n

XuAPI
pub fn (s $&SectionCursor) read_n(n int) string

Purpose

Operation on $&SectionCursor: read at most n bytes; may return shorter or empty at end.

Parameters

s $&SectionCursor
The SectionCursor instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

(&SectionCursor) size

XuAPI
pub fn (s &SectionCursor) size() int

Purpose

Operation on &SectionCursor: return the size.

Parameters

s &SectionCursor
The SectionCursor instance used by this call (borrow).

Returns

int — a value of this type

($&SectionCursor) seek

XuAPI
pub fn (s $&SectionCursor) seek(offset int, whence int) int

Purpose

Operation on $&SectionCursor: move the read position. whence 0/1/2 = absolute / relative / from end. Throws on failure; handle the error or propagate it to the caller.

Parameters

s $&SectionCursor
The SectionCursor instance used by this call (exclusive borrow).
offset int
offset (int)
whence int
seek base: 0 start / 1 current / 2 end (int)

Returns

int — a value of this type

(&SectionCursor) read_at

XuAPI
pub fn (s &SectionCursor) read_at(n int, off int) string

Purpose

Operation on &SectionCursor: read at most n bytes starting at offset off. Throws on failure; handle the error or propagate it to the caller.

Parameters

s &SectionCursor
The SectionCursor instance used by this call (borrow).
n int
count, length, or limit (int)
off int
offset (int)

Returns

string — result string

struct PipeReader

XuAPI
pub struct PipeReader {
    pub r chan string
    pub buf string
    pub off int
}

Purpose

In-memory one-way pipe ( io.Pipe shape; queue is a bounded chan like net.pipe, not a synchronous unbuffered handshake).

Public fields

r chan string
rune (Unicode code point)
buf string
buffer
off int
offset

struct PipeWriter

XuAPI
pub struct PipeWriter {
    pub w chan string
    pub closed int
}

Purpose

Writing end of an in-memory synchronous pipe.

Public fields

w chan string
writer or width
closed int
field (int)

struct Pipe

XuAPI
pub struct Pipe {
    pub r PipeReader
    pub w PipeWriter
}

Purpose

Structure encapsulating r, w.

Public fields

r PipeReader
rune (Unicode code point)
w PipeWriter
writer or width

pipe

XuAPI
pub fn pipe() Pipe

Purpose

Create a pair of connected synchronous in-memory pipe endpoints.

Parameters

No arguments are required.

Returns

Pipe — a value of this type

($&PipeReader) read_n

XuAPI
pub fn (p $&PipeReader) read_n(n int) string

Purpose

Operation on $&PipeReader: read at most n bytes; may return shorter or empty at end.

Parameters

p $&PipeReader
The PipeReader instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

string — result string

(PipeWriter) write

XuAPI
pub fn (w PipeWriter) write(data &string) int

Purpose

Operation on PipeWriter: write data and return the byte count. Throws on failure; handle the error or propagate it to the caller.

Parameters

w PipeWriter
The PipeWriter instance used by this call (value receiver).
data &string
data (read-only borrow; caller keeps the original; type &string)

Returns

int — bytes written

($&PipeWriter) close

XuAPI
pub fn (w $&PipeWriter) close() int

Purpose

Operation on $&PipeWriter: close the resource.

Parameters

w $&PipeWriter
The PipeWriter instance used by this call (exclusive borrow).

Returns

int — a value of this type

enum ReadResult

XuAPI
pub enum ReadResult {
    Data(string)
    End(string)
    Failed(string, errors.Error)
}

Purpose

Owned chunks; terminal conditions may accompany the last bytes.

enum WriteResult

XuAPI
pub enum WriteResult {
    Written(int)
    Failed(int, errors.Error)
    Unknown(errors.Error)
}

Purpose

Counts acknowledge a prefix of this call's input. Unknown is required when a legacy operation throws after effects it cannot quantify.

enum CopyResult

XuAPI
pub enum CopyResult {
    Copied(int)
    Failed(int, errors.Error)
    Uncertain(int, errors.Error)
}

Purpose

Failed has an exact accepted count; Uncertain has a confirmed lower bound.

struct@ ProgressReader

XuAPI
pub struct@ ProgressReader {
    fn read_result(int) ReadResult
}

Purpose

ProgressReader data I/O method-set constraint.

Required methods

read_result fn read_result(int) ReadResult
Operation on ProgressReader: read result.

(ProgressReader) read_result

XuAPI
fn read_result(int) ReadResult

Purpose

Operation on ProgressReader: read result.

Parameters

self Self
The Self instance used by this call (value receiver).
int int
int (int)

Returns

ReadResult — a value of this type

struct@ ProgressWriter

XuAPI
pub struct@ ProgressWriter {
    fn write_result(string) WriteResult
}

Purpose

ProgressWriter data I/O method-set constraint.

Required methods

write_result fn write_result(string) WriteResult
Operation on ProgressWriter: write result.

(ProgressWriter) write_result

XuAPI
fn write_result(string) WriteResult

Purpose

Operation on ProgressWriter: write result.

Parameters

self Self
The Self instance used by this call (value receiver).
string string
string (string)

Returns

WriteResult — a value of this type

struct LegacyReader#R:StreamReader

XuAPI
pub struct LegacyReader#R:StreamReader {
    pub src R
}

Purpose

Legacy readers cannot recover bytes that were lost when throwing.

Public fields

src R
source

struct LegacyWriter#W:StreamWriter

XuAPI
pub struct LegacyWriter#W:StreamWriter {
    pub dst W
}

Purpose

Io Streaming writer and encoder.

Public fields

dst W
destination

progress_reader

XuAPI
pub fn progress_reader#R:StreamReader(src R) LegacyReader#R

Purpose

Progress reader.

Parameters

src R
source (R)

Returns

LegacyReader#R — a value of this type

progress_writer

XuAPI
pub fn progress_writer#W:StreamWriter(dst W) LegacyWriter#W

Purpose

Progress writer.

Parameters

dst W
destination (W)

Returns

LegacyWriter#W — a value of this type

($&LegacyReader#R) read_result

XuAPI
pub fn (r $&LegacyReader#R) read_result(n int) ReadResult

Purpose

Operation on $&LegacyReader#R: read result.

Parameters

r $&LegacyReader#R
The LegacyReader#R instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

ReadResult — a value of this type

($&LegacyWriter#W) write_result

XuAPI
pub fn (w $&LegacyWriter#W) write_result(data string) WriteResult

Purpose

Operation on $&LegacyWriter#W: write result.

Parameters

w $&LegacyWriter#W
The LegacyWriter#W instance used by this call (exclusive borrow).
data string
data (string)

Returns

WriteResult — a value of this type

copy_result

XuAPI
pub fn copy_result#W:ProgressWriter,R:ProgressReader(dst $&W, src $&R) CopyResult

Purpose

Copy result.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)

Returns

CopyResult — a value of this type

copy_result_buffer

XuAPI
pub fn copy_result_buffer#W:ProgressWriter,R:ProgressReader(dst $&W, src $&R, size int) CopyResult

Purpose

Copy result buffer.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)
size int
size (int)

Returns

CopyResult — a value of this type

copy_result_n

XuAPI
pub fn copy_result_n#W:ProgressWriter,R:ProgressReader(dst $&W, src $&R, n int) CopyResult

Purpose

Copy result n.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)
n int
count, length, or limit (int)

Returns

CopyResult — a value of this type

($&Cursor) read_result

XuAPI
pub fn (c $&Cursor) read_result(n int) ReadResult

Purpose

Operation on $&Cursor: read result.

Parameters

c $&Cursor
The Cursor instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

ReadResult — a value of this type

($&Buffer) read_result

XuAPI
pub fn (b $&Buffer) read_result(n int) ReadResult

Purpose

Operation on $&Buffer: read result.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
n int
count, length, or limit (int)

Returns

ReadResult — a value of this type

($&Buffer) write_result

XuAPI
pub fn (b $&Buffer) write_result(data string) WriteResult

Purpose

Operation on $&Buffer: write result.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
data string
data (string)

Returns

WriteResult — a value of this type

($&Discard) write_result

XuAPI
pub fn (d $&Discard) write_result(data string) WriteResult

Purpose

Operation on $&Discard: write result.

Parameters

d $&Discard
The Discard instance used by this call (exclusive borrow).
data string
data (string)

Returns

WriteResult — a value of this type

enum ReadInto

XuAPI
pub enum ReadInto {
    Filled(int)
    End(int)
    Failed(int, errors.Error)
}

Purpose

ReadInto reports how many bytes were stored in the caller's buffer. The destination is exclusively borrowed for the call and is never grown. The result owns only the count and error; it does not borrow the buffer. Bytes outside the written prefix stay unchanged. A zero count performs no I/O.

($&Cursor) read_into

XuAPI
pub fn (c $&Cursor) read_into(dst $&[]int, off int, n int) ReadInto

Purpose

Operation on $&Cursor: read into.

Parameters

c $&Cursor
The Cursor instance used by this call (exclusive borrow).
dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
n int
count, length, or limit (int)

Returns

ReadInto — a value of this type

($&Buffer) read_into

XuAPI
pub fn (b $&Buffer) read_into(dst $&[]int, off int, n int) ReadInto

Purpose

Operation on $&Buffer: read into.

Parameters

b $&Buffer
The Buffer instance used by this call (exclusive borrow).
dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
n int
count, length, or limit (int)

Returns

ReadInto — a value of this type

read_into

XuAPI
pub fn read_into#R:ProgressReader(src $&R, dst $&[]int, off int, n int) ReadInto

Purpose

One synchronous read_result, then a copy into the exclusive window. The temporary owned chunk dies before return. Invalid counts are not stored. This does not retry and does not replace Cursor/Buffer.read_into.

Parameters

src $&R
source (exclusive borrow; may modify the original; type $&R)
dst $&[]int
destination (exclusive borrow; may modify the original; type $&[]int)
off int
offset (int)
n int
count, length, or limit (int)

Returns

ReadInto — a value of this type

struct@ StreamReader

XuAPI
pub struct@ StreamReader {
    fn read_n(int) string
}

Purpose

read_n(n>0) returns at most n bytes. Empty string or an error with message eof ends the stream; other errors propagate. Unlike Reader, this API cannot return bytes and an error in the same operation.

Required methods

read_n fn read_n(int) string
Operation on StreamReader: read at most n bytes; may return shorter or empty at end.

(StreamReader) read_n

XuAPI
fn read_n(int) string

Purpose

Operation on StreamReader: read at most n bytes; may return shorter or empty at end.

Parameters

self Self
The Self instance used by this call (value receiver).
int int
int (int)

Returns

string — result string

struct@ StreamWriter

XuAPI
pub struct@ StreamWriter {
    fn write_str(string) int
}

Purpose

write_str consumes one owning chunk. It must accept the whole chunk or throw; returning a shorter count is a short write, never an invitation to replay a partially accepted chunk. The destination may retain data itself.

Required methods

write_str fn write_str(string) int
Operation on StreamWriter: write a string.

(StreamWriter) write_str

XuAPI
fn write_str(string) int

Purpose

Operation on StreamWriter: write a string.

Parameters

self Self
The Self instance used by this call (value receiver).
string string
string (string)

Returns

int — a value of this type

copy_stream

XuAPI
pub fn copy_stream#W:StreamWriter,R:StreamReader(dst $&W, src $&R) int

Purpose

The three public forms retain their independently tested copy contracts. Generic forwarding is supported; no additional whole-stream staging is used. Both endpoints are borrowed; their partial effects remain visible on errors. Throws on failure; handle the error or propagate it to the caller.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)

Returns

int — a value of this type

copy_stream_buffer

XuAPI
pub fn copy_stream_buffer#W:StreamWriter,R:StreamReader(dst $&W, src $&R, size int) int

Purpose

Maximum owning chunk size, with no whole-stream staging. Throws on failure; handle the error or propagate it to the caller.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)
size int
size (int)

Returns

int — a value of this type

copy_stream_n

XuAPI
pub fn copy_stream_n#W:StreamWriter,R:StreamReader(dst $&W, src $&R, n int) int

Purpose

Exactly n bytes, with no over-read. n=0 touches neither endpoint. Throws on failure; handle the error or propagate it to the caller.

Parameters

dst $&W
destination (exclusive borrow; may modify the original; type $&W)
src $&R
source (exclusive borrow; may modify the original; type $&R)
n int
count, length, or limit (int)

Returns

int — a value of this type

($&Discard) write_str

XuAPI
pub fn (d $&Discard) write_str(data string) int

Purpose

Operation on $&Discard: write a string.

Parameters

d $&Discard
The Discard instance used by this call (exclusive borrow).
data string
data (string)

Returns

int — a value of this type