Regc.Oci.Transport.Reader (regc v0.0.2)

View Source

An incremental transport response body.

Readers are single-consumer resources. They can be consumed with read/2, enumerated directly, or converted to a stream with stream/2. Enumeration always closes the reader when it finishes or halts early.

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the reader. Closing an already closed or empty reader is harmless.

Reads up to max_bytes from the response.

Returns a lazy stream of response chunks.

Types

deadline()

@type deadline() :: integer() | :infinity

read_result()

@type read_result() :: {:ok, binary()} | :eof | {:error, term()}

t()

@type t() :: %Regc.Oci.Transport.Reader{deadline: deadline(), pid: pid() | nil}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(reader)

@spec close(t()) :: :ok

Closes the reader. Closing an already closed or empty reader is harmless.

read(reader, max_bytes \\ 65536)

@spec read(t(), pos_integer()) :: read_result()

Reads up to max_bytes from the response.

stream(reader, chunk_bytes \\ 65536)

@spec stream(t(), pos_integer()) :: Enumerable.t()

Returns a lazy stream of response chunks.