// Generated by Lisette bindgen
// Source: compress/lzw (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.20

import "go:io"

pub enum Order: int {
  LSB = 0,
  MSB = 1,
}

pub const LSB: Order = 0

pub const MSB: Order = 1

/// NewReader creates a new [io.ReadCloser].
/// Reads from the returned [io.ReadCloser] read and decompress data from r.
/// If r does not also implement [io.ByteReader],
/// the decompressor may read more data than necessary from r.
/// It is the caller's responsibility to call Close on the ReadCloser when
/// finished reading.
/// The number of bits to use for literal codes, litWidth, must be in the
/// range [2,8] and is typically 8. It must equal the litWidth
/// used during compression.
/// 
/// It is guaranteed that the underlying type of the returned [io.ReadCloser]
/// is a *[Reader].
pub fn NewReader(r: io.Reader, order: Order, litWidth: int) -> io.ReadCloser

/// NewWriter creates a new [io.WriteCloser].
/// Writes to the returned [io.WriteCloser] are compressed and written to w.
/// It is the caller's responsibility to call Close on the WriteCloser when
/// finished writing.
/// The number of bits to use for literal codes, litWidth, must be in the
/// range [2,8] and is typically 8. Input bytes must be less than 1<<litWidth.
/// 
/// It is guaranteed that the underlying type of the returned [io.WriteCloser]
/// is a *[Writer].
pub fn NewWriter(w: io.Writer, order: Order, litWidth: int) -> io.WriteCloser

/// Reader is an [io.Reader] which can be used to read compressed data in the
/// LZW format.
pub type Reader

/// Writer is an LZW compressor. It writes the compressed form of the data
/// to an underlying writer (see [NewWriter]).
pub type Writer

impl Reader {
  /// Close closes the [Reader] and returns an error for any future read operation.
  /// It does not close the underlying [io.Reader].
  #[allow(unused_result)]
  fn Close(self: Ref<Reader>) -> Result<(), error>

  /// Read implements io.Reader, reading uncompressed bytes from its underlying reader.
  fn Read(self: Ref<Reader>, mut b: Slice<uint8>) -> Partial<int, error>

  /// Reset clears the [Reader]'s state and allows it to be reused again
  /// as a new [Reader].
  fn Reset(self: Ref<Reader>, src: io.Reader, order: Order, litWidth: int)
}

impl Writer {
  /// Close closes the [Writer], flushing any pending output. It does not close
  /// w's underlying writer.
  #[allow(unused_result)]
  fn Close(self: Ref<Writer>) -> Result<(), error>

  /// Reset clears the [Writer]'s state and allows it to be reused again
  /// as a new [Writer].
  fn Reset(self: Ref<Writer>, dst: io.Writer, order: Order, litWidth: int)

  /// Write writes a compressed representation of p to w's underlying writer.
  fn Write(self: Ref<Writer>, p: Slice<uint8>) -> Partial<int, error>
}
