#bufio/file
Xu 0.16.0 API
import: #bufio/file
counts: 4 functions, 4 methods, 2 types, 0 constants, 0 method sets
File-backed buffered I/O ( bufio.NewReader(os.File) shape). Kept out of #bufio so importing strings-only bufio does not pull #os.
struct FileReader
pub struct FileReader {
pub src os.File
pub buf string
pub r int
pub err string
pub size int
pub last_byte int
}
Purpose
File Streaming reader and decoder.
Public fields
src os.File- source
buf string- buffer
r int- rune (Unicode code point)
err string- error
size int- field (int)
last_byte int- field (int)
struct FileWriter
pub struct FileWriter {
pub dst os.File
pub buf string
pub size int
pub err string
}
Purpose
File Streaming writer and encoder.
Public fields
dst os.File- destination
buf string- buffer
size int- field (int)
err string- error
new_reader
pub fn new_reader(src os.File) FileReader
Purpose
Construct reader.
Parameters
src os.File- source (os.File)
Returns
FileReader — a value of this type
new_reader_size
pub fn new_reader_size(src os.File, size int) FileReader
Purpose
Construct reader size.
Parameters
src os.File- source (os.File)
size int- size (int)
Returns
FileReader — a value of this type
new_writer
pub fn new_writer(dst os.File) FileWriter
Purpose
Construct writer.
Parameters
dst os.File- destination (os.File)
Returns
FileWriter — a value of this type
new_writer_size
pub fn new_writer_size(dst os.File, size int) FileWriter
Purpose
Construct writer size.
Parameters
dst os.File- destination (os.File)
size int- size (int)
Returns
FileWriter — a value of this type
($&FileReader) read_byte
pub fn (r $&FileReader) read_byte() int
Purpose
Operation on $&FileReader: read one byte; throws on failure. Throws on failure; handle the error or propagate it to the caller.
Parameters
r $&FileReader- The
FileReader instance used by this call (exclusive borrow).
Returns
int — a value of this type
($&FileReader) read_string
pub fn (r $&FileReader) read_string(delim int) string
Purpose
Operation on $&FileReader: read string. Throws on failure; handle the error or propagate it to the caller.
Parameters
r $&FileReader- The
FileReader instance used by this call (exclusive borrow).
delim int- delim (int)
Returns
string — result string
($&FileWriter) write
pub fn (w $&FileWriter) write(data string) int
Purpose
Bounded staging; return bytes accepted from this call, not the flush count. A failed flush remains sticky and retains bytes not confirmed as written. Throws on failure; handle the error or propagate it to the caller.
Parameters
w $&FileWriter- The
FileWriter instance used by this call (exclusive borrow).
data string- data (string)
Returns
int — bytes written
($&FileWriter) flush
pub fn (w $&FileWriter) flush() int
Purpose
Operation on $&FileWriter: flush buffered data. Throws on failure; handle the error or propagate it to the caller.
Parameters
w $&FileWriter- The
FileWriter instance used by this call (exclusive borrow).
Returns
int — a value of this type