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

import "go:io"

/// NewReader creates a new ReadCloser.
/// Reads from the returned ReadCloser read and decompress data from r.
/// If r does not 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 done.
/// 
/// The [io.ReadCloser] returned by NewReader also implements [Resetter].
pub fn NewReader(r: io.Reader) -> Result<io.ReadCloser, error>

/// NewReaderDict is like [NewReader] but uses a preset dictionary.
/// NewReaderDict ignores the dictionary if the compressed data does not refer to it.
/// If the compressed data refers to a different dictionary, NewReaderDict returns [ErrDictionary].
/// 
/// The ReadCloser returned by NewReaderDict also implements [Resetter].
pub fn NewReaderDict(r: io.Reader, dict: Slice<uint8>) -> Result<io.ReadCloser, error>

pub fn NewWriter(w: io.Writer) -> Ref<Writer>

pub fn NewWriterLevel(w: io.Writer, level: int) -> Result<Ref<Writer>, error>

pub fn NewWriterLevelDict(w: io.Writer, level: int, dict: Slice<uint8>) -> Result<Ref<Writer>, error>

/// Resetter resets a ReadCloser returned by [NewReader] or [NewReaderDict]
/// to switch to a new underlying Reader. This permits reusing a ReadCloser
/// instead of allocating a new one.
pub interface Resetter {
  fn Reset(r: io.Reader, dict: Slice<uint8>) -> Result<(), error>
}

/// A Writer takes data written to it and writes the compressed
/// form of that data to an underlying writer (see [NewWriter]).
pub type Writer

/// These constants are copied from the [flate] package, so that code that imports
/// [compress/zlib] does not also have to import [compress/flate].
pub const BestCompression = 9

/// These constants are copied from the [flate] package, so that code that imports
/// [compress/zlib] does not also have to import [compress/flate].
pub const BestSpeed = 1

/// These constants are copied from the [flate] package, so that code that imports
/// [compress/zlib] does not also have to import [compress/flate].
pub const DefaultCompression = -1

/// These constants are copied from the [flate] package, so that code that imports
/// [compress/zlib] does not also have to import [compress/flate].
pub const HuffmanOnly = -2

/// These constants are copied from the [flate] package, so that code that imports
/// [compress/zlib] does not also have to import [compress/flate].
pub const NoCompression = 0

pub var ErrChecksum: error

pub var ErrDictionary: error

pub var ErrHeader: error

impl Writer {
  /// Close closes the Writer, flushing any unwritten data to the underlying
  /// [io.Writer], but does not close the underlying io.Writer.
  #[allow(unused_result)]
  fn Close(self: Ref<Writer>) -> Result<(), error>

  /// Flush flushes the Writer to its underlying [io.Writer].
  #[allow(unused_result)]
  fn Flush(self: Ref<Writer>) -> Result<(), error>

  /// Reset clears the state of the [Writer] z such that it is equivalent to its
  /// initial state from [NewWriterLevel] or [NewWriterLevelDict], but instead writing
  /// to w.
  fn Reset(self: Ref<Writer>, w: io.Writer)

  /// Write writes a compressed form of p to the underlying [io.Writer]. The
  /// compressed bytes are not necessarily flushed until the [Writer] is closed or
  /// explicitly flushed.
  fn Write(self: Ref<Writer>, p: Slice<uint8>) -> Partial<int, error>
}
