Regc.Blob.Reader (regc v0.0.2)

View Source

Incrementally verified blob content.

Digest and size verification completes when read/2 returns :eof. Enumeration closes the underlying transport on completion or early halt.

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the blob and its underlying transport reader.

Reads up to max_bytes. Verification errors are returned as structured Regc.Error values.

Returns a lazy stream of verified blob chunks.

Types

read_result()

@type read_result() :: {:ok, binary()} | :eof | {:error, Regc.Error.t()}

t()

@type t() :: %Regc.Blob.Reader{metadata: Regc.Blob.Metadata.t(), pid: pid()}

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 blob and its underlying transport reader.

read(reader, max_bytes \\ 65536)

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

Reads up to max_bytes. Verification errors are returned as structured Regc.Error values.

stream(reader, chunk_bytes \\ 65536)

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

Returns a lazy stream of verified blob chunks.