// Generated by Lisette bindgen
// Source: compress/flate (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1

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<byte>) -> io.ReadCloser

/// NewWriter returns a new [Writer] compressing data at the given level.
/// Following zlib, levels range from 1 ([BestSpeed]) to 9 ([BestCompression]);
/// higher levels typically run slower but compress more. Level 0
/// ([NoCompression]) does not attempt any compression; it only adds the
/// necessary DEFLATE framing.
/// Level -1 ([DefaultCompression]) uses the default compression level.
/// Level -2 ([HuffmanOnly]) will use Huffman compression only, giving
/// a very fast compression for all types of input, but sacrificing considerable
/// compression efficiency.
/// 
/// If level is in the range [-2, 9] then the error returned will be nil.
/// Otherwise the error returned will be non-nil.
pub fn NewWriter(w: io.Writer, level: int) -> Result<Ref<Writer>, error>

/// NewWriterDict is like [NewWriter] but initializes the new
/// [Writer] with a preset dictionary. The returned [Writer] behaves
/// as if the dictionary had been written to it without producing
/// any compressed output. The compressed data written to w
/// can only be decompressed by a reader initialized with the
/// same dictionary (see [NewReaderDict]).
pub fn NewWriterDict(w: io.Writer, level: int, dict: Slice<byte>) -> 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<byte>) -> Partial<int, error>
  fn ReadByte() -> Result<byte, 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<byte>) -> 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

pub const BestCompression = 9

pub const BestSpeed = 1

pub const DefaultCompression = -1

pub const HuffmanOnly = -2

pub 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<byte>) -> Partial<int, error>
}
