Karta.SMTP.ChunkReader (Karta v1.0.0)

Reads one BDAT chunk (RFC 3030 §2): exactly the declared number of octets, taken as they are (no dot-stuffing, no terminator).

Octets go to the sink while the message still has room (the bytes left under the size limit); after that they are counted and dropped, so a client can never make us store more than the limit. A reader made with discard/1 stores nothing: RFC 3030 §2 requires the server to read and discard the data of a BDAT command it refused.

Summary

Functions

Feeds bytes. Returns {:done, reader, rest} once the chunk is complete; rest follows it.

Types

t()

@type t() :: %Karta.SMTP.ChunkReader{
  remaining: non_neg_integer(),
  room: non_neg_integer(),
  sink: module() | nil,
  sink_state: term()
}

Functions

discard(size)

@spec discard(non_neg_integer()) :: t()

feed(r, data)

@spec feed(t(), binary()) :: {:more, t()} | {:done, t(), binary()}

Feeds bytes. Returns {:done, reader, rest} once the chunk is complete; rest follows it.

new(size, sink, sink_state, room)

@spec new(non_neg_integer(), module(), term(), non_neg_integer()) :: t()