// Generated by Lisette bindgen
// Source: compress/flate (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.14

import "go:io"

/// NewReader returns a new ReadCloser that can be used
/// to read the uncompressed version of r.
/// If r does not also implement [io.ByteReader],
/// the decompressor may read more data than necessary from r.
/// The reader returns [io.EOF] after the final block in the DEFLATE stream has
/// been encountered. Any trailing data after the final block is ignored.
/// 
/// The [io.ReadCloser] returned by NewReader also implements [Resetter].
pub fn NewReader(r: io.Reader) -> io.ReadCloser

/// NewReaderDict is like [NewReader] but initializes the reader
/// with a preset dictionary. The returned reader behaves as if
/// the uncompressed data stream started with the given dictionary,
/// which has already been read. NewReaderDict is typically used
/// to read data compressed by [NewWriterDict].
/// 
/// The ReadCloser returned by NewReaderDict also implements [Resetter].
pub fn NewReaderDict(r: io.Reader, dict: Slice<uint8>) -> io.ReadCloser

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

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

/// A CorruptInputError reports the presence of corrupt input at a given offset.
pub struct CorruptInputError(int64)

/// An InternalError reports an error in the flate code itself.
pub struct InternalError(string)

/// A ReadError reports an error encountered while reading input.
/// 
/// Deprecated: No longer returned.
pub struct ReadError {
  pub Offset: int64,
  pub Err: error,
}

/// The actual read interface needed by [NewReader].
/// If the passed in [io.Reader] does not also have ReadByte,
/// the [NewReader] will introduce its own buffering.
pub interface Reader {
  fn Read(mut p: Slice<uint8>) -> Partial<int, error>
  fn ReadByte() -> Result<uint8, 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 WriteError reports an error encountered while writing output.
/// 
/// Deprecated: No longer returned.
pub struct WriteError {
  pub Offset: int64,
  pub Err: 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

const BestCompression = 9

const BestSpeed = 1

const DefaultCompression = -1

const HuffmanOnly = -2

const NoCompression = 0

impl CorruptInputError {
  fn Error(self) -> string
}

impl InternalError {
  fn Error(self) -> string
}

impl ReadError {
  fn Error(self: Ref<ReadError>) -> string
}

impl WriteError {
  fn Error(self: Ref<WriteError>) -> string
}

impl Writer {
  /// Close flushes and closes the writer.
  #[allow(unused_result)]
  fn Close(self: Ref<Writer>) -> Result<(), error>

  /// Flush flushes any pending data to the underlying writer.
  /// It is useful mainly in compressed network protocols, to ensure that
  /// a remote reader has enough data to reconstruct a packet.
  /// Flush does not return until the data has been written.
  /// Calling Flush when there is no pending data still causes the [Writer]
  /// to emit a sync marker of at least 4 bytes.
  /// If the underlying writer returns an error, Flush returns that error.
  /// 
  /// In the terminology of the zlib library, Flush is equivalent to Z_SYNC_FLUSH.
  #[allow(unused_result)]
  fn Flush(self: Ref<Writer>) -> Result<(), error>

  /// Reset discards the writer's state and makes it equivalent to
  /// the result of [NewWriter] or [NewWriterDict] called with dst
  /// and w's level and dictionary.
  fn Reset(self: Ref<Writer>, dst: io.Writer)

  /// Write writes data to w, which will eventually write the
  /// compressed form of data to its underlying writer.
  fn Write(self: Ref<Writer>, data: Slice<uint8>) -> Partial<int, error>
}
