lisette-stdlib 0.1.15

Little language inspired by Rust that compiles to Go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
// Generated by Lisette bindgen
// Source: bytes (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.14

import "go:io"
import "go:iter"
import "go:unicode"

/// Clone returns a copy of b[:len(b)].
/// The result may have additional unused capacity.
/// Clone(nil) returns nil.
pub fn Clone(b: Slice<uint8>) -> Slice<uint8>

/// Compare returns an integer comparing two byte slices lexicographically.
/// The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
/// A nil argument is equivalent to an empty slice.
pub fn Compare(a: Slice<uint8>, b: Slice<uint8>) -> int

/// Contains reports whether subslice is within b.
pub fn Contains(b: Slice<uint8>, subslice: Slice<uint8>) -> bool

/// ContainsAny reports whether any of the UTF-8-encoded code points in chars are within b.
pub fn ContainsAny(b: Slice<uint8>, chars: string) -> bool

/// ContainsFunc reports whether any of the UTF-8-encoded code points r within b satisfy f(r).
pub fn ContainsFunc(b: Slice<uint8>, f: fn(int32) -> bool) -> bool

/// ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.
pub fn ContainsRune(b: Slice<uint8>, r: int32) -> bool

/// Count counts the number of non-overlapping instances of sep in s.
/// If sep is an empty slice, Count returns 1 + the number of UTF-8-encoded code points in s.
pub fn Count(s: Slice<uint8>, sep: Slice<uint8>) -> int

/// Cut slices s around the first instance of sep,
/// returning the text before and after sep.
/// The found result reports whether sep appears in s.
/// If sep does not appear in s, cut returns s, nil, false.
/// 
/// Cut returns slices of the original slice s, not copies.
pub fn Cut(s: Slice<uint8>, sep: Slice<uint8>) -> Option<(Slice<uint8>, Slice<uint8>)>

/// CutPrefix returns s without the provided leading prefix byte slice
/// and reports whether it found the prefix.
/// If s doesn't start with prefix, CutPrefix returns s, false.
/// If prefix is the empty byte slice, CutPrefix returns s, true.
/// 
/// CutPrefix returns slices of the original slice s, not copies.
pub fn CutPrefix(s: Slice<uint8>, prefix: Slice<uint8>) -> Option<Slice<uint8>>

/// CutSuffix returns s without the provided ending suffix byte slice
/// and reports whether it found the suffix.
/// If s doesn't end with suffix, CutSuffix returns s, false.
/// If suffix is the empty byte slice, CutSuffix returns s, true.
/// 
/// CutSuffix returns slices of the original slice s, not copies.
pub fn CutSuffix(s: Slice<uint8>, suffix: Slice<uint8>) -> Option<Slice<uint8>>

/// Equal reports whether a and b
/// are the same length and contain the same bytes.
/// A nil argument is equivalent to an empty slice.
pub fn Equal(a: Slice<uint8>, b: Slice<uint8>) -> bool

/// EqualFold reports whether s and t, interpreted as UTF-8 strings,
/// are equal under simple Unicode case-folding, which is a more general
/// form of case-insensitivity.
pub fn EqualFold(s: Slice<uint8>, t: Slice<uint8>) -> bool

/// Fields interprets s as a sequence of UTF-8-encoded code points.
/// It splits the slice s around each instance of one or more consecutive white space
/// characters, as defined by [unicode.IsSpace], returning a slice of subslices of s or an
/// empty slice if s contains only white space. Every element of the returned slice is
/// non-empty. Unlike [Split], leading and trailing runs of white space characters
/// are discarded.
pub fn Fields(s: Slice<uint8>) -> Slice<Slice<uint8>>

/// FieldsFunc interprets s as a sequence of UTF-8-encoded code points.
/// It splits the slice s at each run of code points c satisfying f(c) and
/// returns a slice of subslices of s. If all code points in s satisfy f(c), or
/// len(s) == 0, an empty slice is returned. Every element of the returned slice is
/// non-empty. Unlike [SplitFunc], leading and trailing runs of code points
/// satisfying f(c) are discarded.
/// 
/// FieldsFunc makes no guarantees about the order in which it calls f(c)
/// and assumes that f always returns the same value for a given c.
pub fn FieldsFunc(s: Slice<uint8>, f: fn(int32) -> bool) -> Slice<Slice<uint8>>

/// FieldsFuncSeq returns an iterator over subslices of s split around runs of
/// Unicode code points satisfying f(c).
/// The iterator yields the same subslices that would be returned by [FieldsFunc](s),
/// but without constructing a new slice containing the subslices.
pub fn FieldsFuncSeq(s: Slice<uint8>, f: fn(int32) -> bool) -> iter.Seq<Slice<uint8>>

/// FieldsSeq returns an iterator over subslices of s split around runs of
/// whitespace characters, as defined by [unicode.IsSpace].
/// The iterator yields the same subslices that would be returned by [Fields](s),
/// but without constructing a new slice containing the subslices.
pub fn FieldsSeq(s: Slice<uint8>) -> iter.Seq<Slice<uint8>>

/// HasPrefix reports whether the byte slice s begins with prefix.
pub fn HasPrefix(s: Slice<uint8>, prefix: Slice<uint8>) -> bool

/// HasSuffix reports whether the byte slice s ends with suffix.
pub fn HasSuffix(s: Slice<uint8>, suffix: Slice<uint8>) -> bool

/// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
pub fn Index(s: Slice<uint8>, sep: Slice<uint8>) -> int

/// IndexAny interprets s as a sequence of UTF-8-encoded Unicode code points.
/// It returns the byte index of the first occurrence in s of any of the Unicode
/// code points in chars. It returns -1 if chars is empty or if there is no code
/// point in common.
pub fn IndexAny(s: Slice<uint8>, chars: string) -> int

/// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
pub fn IndexByte(b: Slice<uint8>, c: uint8) -> int

/// IndexFunc interprets s as a sequence of UTF-8-encoded code points.
/// It returns the byte index in s of the first Unicode
/// code point satisfying f(c), or -1 if none do.
pub fn IndexFunc(s: Slice<uint8>, f: fn(int32) -> bool) -> int

/// IndexRune interprets s as a sequence of UTF-8-encoded code points.
/// It returns the byte index of the first occurrence in s of the given rune.
/// It returns -1 if rune is not present in s.
/// If r is [utf8.RuneError], it returns the first instance of any
/// invalid UTF-8 byte sequence.
pub fn IndexRune(s: Slice<uint8>, r: int32) -> int

/// Join concatenates the elements of s to create a new byte slice. The separator
/// sep is placed between elements in the resulting slice.
pub fn Join(s: Slice<Slice<uint8>>, sep: Slice<uint8>) -> Slice<uint8>

/// LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
pub fn LastIndex(s: Slice<uint8>, sep: Slice<uint8>) -> int

/// LastIndexAny interprets s as a sequence of UTF-8-encoded Unicode code
/// points. It returns the byte index of the last occurrence in s of any of
/// the Unicode code points in chars. It returns -1 if chars is empty or if
/// there is no code point in common.
pub fn LastIndexAny(s: Slice<uint8>, chars: string) -> int

/// LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
pub fn LastIndexByte(s: Slice<uint8>, c: uint8) -> int

/// LastIndexFunc interprets s as a sequence of UTF-8-encoded code points.
/// It returns the byte index in s of the last Unicode
/// code point satisfying f(c), or -1 if none do.
pub fn LastIndexFunc(s: Slice<uint8>, f: fn(int32) -> bool) -> int

/// Lines returns an iterator over the newline-terminated lines in the byte slice s.
/// The lines yielded by the iterator include their terminating newlines.
/// If s is empty, the iterator yields no lines at all.
/// If s does not end in a newline, the final yielded line will not end in a newline.
/// It returns a single-use iterator.
pub fn Lines(s: Slice<uint8>) -> iter.Seq<Slice<uint8>>

/// Map returns a copy of the byte slice s with all its characters modified
/// according to the mapping function. If mapping returns a negative value, the character is
/// dropped from the byte slice with no replacement. The characters in s and the
/// output are interpreted as UTF-8-encoded code points.
pub fn Map(mapping: fn(int32) -> int32, s: Slice<uint8>) -> Slice<uint8>

pub fn NewBuffer(mut buf: Slice<uint8>) -> Ref<Buffer>

pub fn NewBufferString(s: string) -> Ref<Buffer>

pub fn NewReader(b: Slice<uint8>) -> Ref<Reader>

/// Repeat returns a new byte slice consisting of count copies of b.
/// 
/// It panics if count is negative or if the result of (len(b) * count)
/// overflows.
pub fn Repeat(b: Slice<uint8>, count: int) -> Slice<uint8>

/// Replace returns a copy of the slice s with the first n
/// non-overlapping instances of old replaced by new.
/// If old is empty, it matches at the beginning of the slice
/// and after each UTF-8 sequence, yielding up to k+1 replacements
/// for a k-rune slice.
/// If n < 0, there is no limit on the number of replacements.
pub fn Replace(s: Slice<uint8>, old: Slice<uint8>, new: Slice<uint8>, n: int) -> Slice<uint8>

/// ReplaceAll returns a copy of the slice s with all
/// non-overlapping instances of old replaced by new.
/// If old is empty, it matches at the beginning of the slice
/// and after each UTF-8 sequence, yielding up to k+1 replacements
/// for a k-rune slice.
pub fn ReplaceAll(s: Slice<uint8>, old: Slice<uint8>, new: Slice<uint8>) -> Slice<uint8>

/// Runes interprets s as a sequence of UTF-8-encoded code points.
/// It returns a slice of runes (Unicode code points) equivalent to s.
pub fn Runes(s: Slice<uint8>) -> Slice<int32>

/// Split slices s into all subslices separated by sep and returns a slice of
/// the subslices between those separators.
/// If sep is empty, Split splits after each UTF-8 sequence.
/// It is equivalent to SplitN with a count of -1.
/// 
/// To split around the first instance of a separator, see [Cut].
pub fn Split(s: Slice<uint8>, sep: Slice<uint8>) -> Slice<Slice<uint8>>

/// SplitAfter slices s into all subslices after each instance of sep and
/// returns a slice of those subslices.
/// If sep is empty, SplitAfter splits after each UTF-8 sequence.
/// It is equivalent to SplitAfterN with a count of -1.
pub fn SplitAfter(s: Slice<uint8>, sep: Slice<uint8>) -> Slice<Slice<uint8>>

/// SplitAfterN slices s into subslices after each instance of sep and
/// returns a slice of those subslices.
/// If sep is empty, SplitAfterN splits after each UTF-8 sequence.
/// The count determines the number of subslices to return:
///   - n > 0: at most n subslices; the last subslice will be the unsplit remainder;
///   - n == 0: the result is nil (zero subslices);
///   - n < 0: all subslices.
pub fn SplitAfterN(s: Slice<uint8>, sep: Slice<uint8>, n: int) -> Slice<Slice<uint8>>

/// SplitAfterSeq returns an iterator over subslices of s split after each instance of sep.
/// The iterator yields the same subslices that would be returned by [SplitAfter](s, sep),
/// but without constructing a new slice containing the subslices.
/// It returns a single-use iterator.
pub fn SplitAfterSeq(s: Slice<uint8>, sep: Slice<uint8>) -> iter.Seq<Slice<uint8>>

/// SplitN slices s into subslices separated by sep and returns a slice of
/// the subslices between those separators.
/// If sep is empty, SplitN splits after each UTF-8 sequence.
/// The count determines the number of subslices to return:
///   - n > 0: at most n subslices; the last subslice will be the unsplit remainder;
///   - n == 0: the result is nil (zero subslices);
///   - n < 0: all subslices.
/// 
/// To split around the first instance of a separator, see [Cut].
pub fn SplitN(s: Slice<uint8>, sep: Slice<uint8>, n: int) -> Slice<Slice<uint8>>

/// SplitSeq returns an iterator over all subslices of s separated by sep.
/// The iterator yields the same subslices that would be returned by [Split](s, sep),
/// but without constructing a new slice containing the subslices.
/// It returns a single-use iterator.
pub fn SplitSeq(s: Slice<uint8>, sep: Slice<uint8>) -> iter.Seq<Slice<uint8>>

/// Title treats s as UTF-8-encoded bytes and returns a copy with all Unicode letters that begin
/// words mapped to their title case.
/// 
/// Deprecated: The rule Title uses for word boundaries does not handle Unicode
/// punctuation properly. Use golang.org/x/text/cases instead.
pub fn Title(s: Slice<uint8>) -> Slice<uint8>

/// ToLower returns a copy of the byte slice s with all Unicode letters mapped to
/// their lower case.
pub fn ToLower(s: Slice<uint8>) -> Slice<uint8>

/// ToLowerSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
/// lower case, giving priority to the special casing rules.
pub fn ToLowerSpecial(c: unicode.SpecialCase, s: Slice<uint8>) -> Slice<uint8>

/// ToTitle treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their title case.
pub fn ToTitle(s: Slice<uint8>) -> Slice<uint8>

/// ToTitleSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
/// title case, giving priority to the special casing rules.
pub fn ToTitleSpecial(c: unicode.SpecialCase, s: Slice<uint8>) -> Slice<uint8>

/// ToUpper returns a copy of the byte slice s with all Unicode letters mapped to
/// their upper case.
pub fn ToUpper(s: Slice<uint8>) -> Slice<uint8>

/// ToUpperSpecial treats s as UTF-8-encoded bytes and returns a copy with all the Unicode letters mapped to their
/// upper case, giving priority to the special casing rules.
pub fn ToUpperSpecial(c: unicode.SpecialCase, s: Slice<uint8>) -> Slice<uint8>

/// ToValidUTF8 treats s as UTF-8-encoded bytes and returns a copy with each run of bytes
/// representing invalid UTF-8 replaced with the bytes in replacement, which may be empty.
pub fn ToValidUTF8(s: Slice<uint8>, replacement: Slice<uint8>) -> Slice<uint8>

/// Trim returns a subslice of s by slicing off all leading and
/// trailing UTF-8-encoded code points contained in cutset.
pub fn Trim(s: Slice<uint8>, cutset: string) -> Slice<uint8>

/// TrimFunc returns a subslice of s by slicing off all leading and trailing
/// UTF-8-encoded code points c that satisfy f(c).
pub fn TrimFunc(s: Slice<uint8>, f: fn(int32) -> bool) -> Slice<uint8>

/// TrimLeft returns a subslice of s by slicing off all leading
/// UTF-8-encoded code points contained in cutset.
pub fn TrimLeft(s: Slice<uint8>, cutset: string) -> Slice<uint8>

/// TrimLeftFunc treats s as UTF-8-encoded bytes and returns a subslice of s by slicing off
/// all leading UTF-8-encoded code points c that satisfy f(c).
pub fn TrimLeftFunc(s: Slice<uint8>, f: fn(int32) -> bool) -> Slice<uint8>

/// TrimPrefix returns s without the provided leading prefix string.
/// If s doesn't start with prefix, s is returned unchanged.
pub fn TrimPrefix(s: Slice<uint8>, prefix: Slice<uint8>) -> Slice<uint8>

/// TrimRight returns a subslice of s by slicing off all trailing
/// UTF-8-encoded code points that are contained in cutset.
pub fn TrimRight(s: Slice<uint8>, cutset: string) -> Slice<uint8>

/// TrimRightFunc returns a subslice of s by slicing off all trailing
/// UTF-8-encoded code points c that satisfy f(c).
pub fn TrimRightFunc(s: Slice<uint8>, f: fn(int32) -> bool) -> Slice<uint8>

/// TrimSpace returns a subslice of s by slicing off all leading and
/// trailing white space, as defined by Unicode.
pub fn TrimSpace(s: Slice<uint8>) -> Slice<uint8>

/// TrimSuffix returns s without the provided trailing suffix string.
/// If s doesn't end with suffix, s is returned unchanged.
pub fn TrimSuffix(s: Slice<uint8>, suffix: Slice<uint8>) -> Slice<uint8>

/// A Buffer is a variable-sized buffer of bytes with [Buffer.Read] and [Buffer.Write] methods.
/// The zero value for Buffer is an empty buffer ready to use.
pub type Buffer

/// A Reader implements the [io.Reader], [io.ReaderAt], [io.WriterTo], [io.Seeker],
/// [io.ByteScanner], and [io.RuneScanner] interfaces by reading from
/// a byte slice.
/// Unlike a [Buffer], a Reader is read-only and supports seeking.
/// The zero value for Reader operates like a Reader of an empty slice.
pub type Reader

/// MinRead is the minimum slice size passed to a [Buffer.Read] call by
/// [Buffer.ReadFrom]. As long as the [Buffer] has at least MinRead bytes beyond
/// what is required to hold the contents of r, [Buffer.ReadFrom] will not grow the
/// underlying buffer.
const MinRead = 512

/// ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer.
pub var ErrTooLarge: error

impl Buffer {
  /// Available returns how many bytes are unused in the buffer.
  fn Available(self: Ref<Buffer>) -> int

  /// AvailableBuffer returns an empty buffer with b.Available() capacity.
  /// This buffer is intended to be appended to and
  /// passed to an immediately succeeding [Buffer.Write] call.
  /// The buffer is only valid until the next write operation on b.
  fn AvailableBuffer(self: Ref<Buffer>) -> Slice<uint8>

  /// Bytes returns a slice of length b.Len() holding the unread portion of the buffer.
  /// The slice is valid for use only until the next buffer modification (that is,
  /// only until the next call to a method like [Buffer.Read], [Buffer.Write], [Buffer.Reset], or [Buffer.Truncate]).
  /// The slice aliases the buffer content at least until the next buffer modification,
  /// so immediate changes to the slice will affect the result of future reads.
  fn Bytes(self: Ref<Buffer>) -> Slice<uint8>

  /// Cap returns the capacity of the buffer's underlying byte slice, that is, the
  /// total space allocated for the buffer's data.
  fn Cap(self: Ref<Buffer>) -> int

  /// Grow grows the buffer's capacity, if necessary, to guarantee space for
  /// another n bytes. After Grow(n), at least n bytes can be written to the
  /// buffer without another allocation.
  /// If n is negative, Grow will panic.
  /// If the buffer can't grow it will panic with [ErrTooLarge].
  fn Grow(self: Ref<Buffer>, n: int)

  /// Len returns the number of bytes of the unread portion of the buffer;
  /// b.Len() == len(b.Bytes()).
  fn Len(self: Ref<Buffer>) -> int

  /// Next returns a slice containing the next n bytes from the buffer,
  /// advancing the buffer as if the bytes had been returned by [Buffer.Read].
  /// If there are fewer than n bytes in the buffer, Next returns the entire buffer.
  /// The slice is only valid until the next call to a read or write method.
  fn Next(self: Ref<Buffer>, n: int) -> Slice<uint8>

  /// Read reads the next len(p) bytes from the buffer or until the buffer
  /// is drained. The return value n is the number of bytes read. If the
  /// buffer has no data to return, err is [io.EOF] (unless len(p) is zero);
  /// otherwise it is nil.
  fn Read(self: Ref<Buffer>, mut p: Slice<uint8>) -> Partial<int, error>

  /// ReadByte reads and returns the next byte from the buffer.
  /// If no byte is available, it returns error [io.EOF].
  fn ReadByte(self: Ref<Buffer>) -> Result<uint8, error>

  /// ReadBytes reads until the first occurrence of delim in the input,
  /// returning a slice containing the data up to and including the delimiter.
  /// If ReadBytes encounters an error before finding a delimiter,
  /// it returns the data read before the error and the error itself (often [io.EOF]).
  /// ReadBytes returns err != nil if and only if the returned data does not end in
  /// delim.
  fn ReadBytes(self: Ref<Buffer>, delim: uint8) -> Result<Slice<uint8>, error>

  /// ReadFrom reads data from r until EOF and appends it to the buffer, growing
  /// the buffer as needed. The return value n is the number of bytes read. Any
  /// error except io.EOF encountered during the read is also returned. If the
  /// buffer becomes too large, ReadFrom will panic with [ErrTooLarge].
  fn ReadFrom(self: Ref<Buffer>, r: io.Reader) -> Result<int64, error>

  /// ReadRune reads and returns the next UTF-8-encoded
  /// Unicode code point from the buffer.
  /// If no bytes are available, the error returned is io.EOF.
  /// If the bytes are an erroneous UTF-8 encoding, it
  /// consumes one byte and returns U+FFFD, 1.
  fn ReadRune(self: Ref<Buffer>) -> Result<(int32, int), error>

  /// ReadString reads until the first occurrence of delim in the input,
  /// returning a string containing the data up to and including the delimiter.
  /// If ReadString encounters an error before finding a delimiter,
  /// it returns the data read before the error and the error itself (often [io.EOF]).
  /// ReadString returns err != nil if and only if the returned data does not end
  /// in delim.
  fn ReadString(self: Ref<Buffer>, delim: uint8) -> Result<string, error>

  /// Reset resets the buffer to be empty,
  /// but it retains the underlying storage for use by future writes.
  /// Reset is the same as [Buffer.Truncate](0).
  fn Reset(self: Ref<Buffer>)

  /// String returns the contents of the unread portion of the buffer
  /// as a string. If the [Buffer] is a nil pointer, it returns "<nil>".
  /// 
  /// To build strings more efficiently, see the [strings.Builder] type.
  fn String(self: Ref<Buffer>) -> string

  /// Truncate discards all but the first n unread bytes from the buffer
  /// but continues to use the same allocated storage.
  /// It panics if n is negative or greater than the length of the buffer.
  fn Truncate(self: Ref<Buffer>, n: int)

  /// UnreadByte unreads the last byte returned by the most recent successful
  /// read operation that read at least one byte. If a write has happened since
  /// the last read, if the last read returned an error, or if the read read zero
  /// bytes, UnreadByte returns an error.
  fn UnreadByte(self: Ref<Buffer>) -> Result<(), error>

  /// UnreadRune unreads the last rune returned by [Buffer.ReadRune].
  /// If the most recent read or write operation on the buffer was
  /// not a successful [Buffer.ReadRune], UnreadRune returns an error.  (In this regard
  /// it is stricter than [Buffer.UnreadByte], which will unread the last byte
  /// from any read operation.)
  fn UnreadRune(self: Ref<Buffer>) -> Result<(), error>

  /// Write appends the contents of p to the buffer, growing the buffer as
  /// needed. The return value n is the length of p; err is always nil. If the
  /// buffer becomes too large, Write will panic with [ErrTooLarge].
  fn Write(self: Ref<Buffer>, p: Slice<uint8>) -> Partial<int, error>

  /// WriteByte appends the byte c to the buffer, growing the buffer as needed.
  /// The returned error is always nil, but is included to match [bufio.Writer]'s
  /// WriteByte. If the buffer becomes too large, WriteByte will panic with
  /// [ErrTooLarge].
  #[allow(unused_result)]
  fn WriteByte(self: Ref<Buffer>, c: uint8) -> Result<(), error>

  /// WriteRune appends the UTF-8 encoding of Unicode code point r to the
  /// buffer, returning its length and an error, which is always nil but is
  /// included to match [bufio.Writer]'s WriteRune. The buffer is grown as needed;
  /// if it becomes too large, WriteRune will panic with [ErrTooLarge].
  #[allow(unused_result)]
  fn WriteRune(self: Ref<Buffer>, r: int32) -> Result<int, error>

  /// WriteString appends the contents of s to the buffer, growing the buffer as
  /// needed. The return value n is the length of s; err is always nil. If the
  /// buffer becomes too large, WriteString will panic with [ErrTooLarge].
  #[allow(unused_result)]
  fn WriteString(self: Ref<Buffer>, s: string) -> Result<int, error>

  /// WriteTo writes data to w until the buffer is drained or an error occurs.
  /// The return value n is the number of bytes written; it always fits into an
  /// int, but it is int64 to match the [io.WriterTo] interface. Any error
  /// encountered during the write is also returned.
  fn WriteTo(self: Ref<Buffer>, w: io.Writer) -> Result<int64, error>
}

impl Reader {
  /// Len returns the number of bytes of the unread portion of the
  /// slice.
  fn Len(self: Ref<Reader>) -> int

  /// Read implements the [io.Reader] interface.
  fn Read(self: Ref<Reader>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadAt implements the [io.ReaderAt] interface.
  fn ReadAt(self: Ref<Reader>, mut b: Slice<uint8>, off: int64) -> Partial<int, error>

  /// ReadByte implements the [io.ByteReader] interface.
  fn ReadByte(self: Ref<Reader>) -> Result<uint8, error>

  /// ReadRune implements the [io.RuneReader] interface.
  fn ReadRune(self: Ref<Reader>) -> Result<(int32, int), error>

  /// Reset resets the [Reader] to be reading from b.
  fn Reset(self: Ref<Reader>, b: Slice<uint8>)

  /// Seek implements the [io.Seeker] interface.
  fn Seek(self: Ref<Reader>, offset: int64, whence: int) -> Result<int64, error>

  /// Size returns the original length of the underlying byte slice.
  /// Size is the number of bytes available for reading via [Reader.ReadAt].
  /// The result is unaffected by any method calls except [Reader.Reset].
  fn Size(self: Ref<Reader>) -> int64

  /// UnreadByte complements [Reader.ReadByte] in implementing the [io.ByteScanner] interface.
  fn UnreadByte(self: Ref<Reader>) -> Result<(), error>

  /// UnreadRune complements [Reader.ReadRune] in implementing the [io.RuneScanner] interface.
  fn UnreadRune(self: Ref<Reader>) -> Result<(), error>

  /// WriteTo implements the [io.WriterTo] interface.
  fn WriteTo(self: Ref<Reader>, w: io.Writer) -> Result<int64, error>
}