// Generated by Lisette bindgen
// Source: bytes (Go stdlib)
// Go: 1.25.10
// Lisette: 0.3.0

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<byte>) -> Slice<byte>

/// 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<byte>, b: Slice<byte>) -> int

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

/// ContainsAny reports whether any of the UTF-8-encoded code points in chars are within b.
pub fn ContainsAny(b: Slice<byte>, 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<byte>, f: fn(rune) -> bool) -> bool

/// ContainsRune reports whether the rune is contained in the UTF-8-encoded byte slice b.
pub fn ContainsRune(b: Slice<byte>, r: rune) -> 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<byte>, sep: Slice<byte>) -> 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<byte>, sep: Slice<byte>) -> (Slice<byte>, Slice<byte>, bool)

/// 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<byte>, prefix: Slice<byte>) -> Option<Slice<byte>>

/// 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<byte>, suffix: Slice<byte>) -> Option<Slice<byte>>

/// 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<byte>, b: Slice<byte>) -> 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<byte>, t: Slice<byte>) -> 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<byte>) -> Slice<Slice<byte>>

/// 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<byte>, f: fn(rune) -> bool) -> Slice<Slice<byte>>

/// 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<byte>, f: fn(rune) -> bool) -> iter.Seq<Slice<byte>>

/// 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<byte>) -> iter.Seq<Slice<byte>>

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

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

/// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
#[go(sentinel_minus_one)]
pub fn Index(s: Slice<byte>, sep: Slice<byte>) -> Option<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.
#[go(sentinel_minus_one)]
pub fn IndexAny(s: Slice<byte>, chars: string) -> Option<int>

/// IndexByte returns the index of the first instance of c in b, or -1 if c is not present in b.
#[go(sentinel_minus_one)]
pub fn IndexByte(b: Slice<byte>, c: byte) -> Option<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<byte>, f: fn(rune) -> 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.
#[go(sentinel_minus_one)]
pub fn IndexRune(s: Slice<byte>, r: rune) -> Option<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<byte>>, sep: Slice<byte>) -> Slice<byte>

/// LastIndex returns the index of the last instance of sep in s, or -1 if sep is not present in s.
#[go(sentinel_minus_one)]
pub fn LastIndex(s: Slice<byte>, sep: Slice<byte>) -> Option<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.
#[go(sentinel_minus_one)]
pub fn LastIndexAny(s: Slice<byte>, chars: string) -> Option<int>

/// LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
#[go(sentinel_minus_one)]
pub fn LastIndexByte(s: Slice<byte>, c: byte) -> Option<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<byte>, f: fn(rune) -> 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<byte>) -> iter.Seq<Slice<byte>>

/// 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(rune) -> rune, s: Slice<byte>) -> Slice<byte>

/// NewBuffer creates and initializes a new [Buffer] using buf as its
/// initial contents. The new [Buffer] takes ownership of buf, and the
/// caller should not use buf after this call. NewBuffer is intended to
/// prepare a [Buffer] to read existing data. It can also be used to set
/// the initial size of the internal buffer for writing. To do that,
/// buf should have the desired capacity but a length of zero.
/// 
/// In most cases, new([Buffer]) (or just declaring a [Buffer] variable) is
/// sufficient to initialize a [Buffer].
pub fn NewBuffer(mut buf: Slice<byte>) -> Ref<Buffer>

/// NewBufferString creates and initializes a new [Buffer] using string s as its
/// initial contents. It is intended to prepare a buffer to read an existing
/// string.
/// 
/// In most cases, new([Buffer]) (or just declaring a [Buffer] variable) is
/// sufficient to initialize a [Buffer].
pub fn NewBufferString(s: string) -> Ref<Buffer>

/// NewReader returns a new [Reader] reading from b.
pub fn NewReader(b: Slice<byte>) -> 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<byte>, count: int) -> Slice<byte>

/// 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<byte>, old: Slice<byte>, new: Slice<byte>, n: int) -> Slice<byte>

/// 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<byte>, old: Slice<byte>, new: Slice<byte>) -> Slice<byte>

/// 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<byte>) -> Slice<rune>

/// 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<byte>, sep: Slice<byte>) -> Slice<Slice<byte>>

/// 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<byte>, sep: Slice<byte>) -> Slice<Slice<byte>>

/// 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<byte>, sep: Slice<byte>, n: int) -> Slice<Slice<byte>>

/// 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<byte>, sep: Slice<byte>) -> iter.Seq<Slice<byte>>

/// 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<byte>, sep: Slice<byte>, n: int) -> Slice<Slice<byte>>

/// 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<byte>, sep: Slice<byte>) -> iter.Seq<Slice<byte>>

/// 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<byte>) -> Slice<byte>

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

/// 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<byte>) -> Slice<byte>

/// 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<byte>) -> Slice<byte>

/// 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<byte>) -> Slice<byte>

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

/// 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<byte>) -> Slice<byte>

/// 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<byte>, replacement: Slice<byte>) -> Slice<byte>

/// 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<byte>, cutset: string) -> Slice<byte>

/// 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<byte>, f: fn(rune) -> bool) -> Slice<byte>

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

/// 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<byte>, f: fn(rune) -> bool) -> Slice<byte>

/// 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<byte>, prefix: Slice<byte>) -> Slice<byte>

/// 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<byte>, cutset: string) -> Slice<byte>

/// 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<byte>, f: fn(rune) -> bool) -> Slice<byte>

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

/// 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<byte>, suffix: Slice<byte>) -> Slice<byte>

/// 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.
pub 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<byte>

  /// 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<byte>

  /// 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<byte>

  /// 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<byte>) -> 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<byte, 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: byte) -> Partial<Slice<byte>, 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) -> Partial<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<(rune, 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: byte) -> Partial<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<byte>) -> 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: byte) -> 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: rune) -> 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_partial)]
  fn WriteString(self: Ref<Buffer>, s: string) -> Partial<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) -> Partial<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<byte>) -> Partial<int, error>

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

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

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

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

  /// 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) -> Partial<int64, error>
}
