CSPEx v2.0.0-beta CSP.Buffer protocol View Source

Protocol that should be implemented for any struct that wants to act like a buffer.

Link to this section Summary

Functions

Reads a value from the buffer

Puts a value in the buffer

Link to this section Types

Link to this section Functions

Link to this function next(buffer) View Source
next(t()) :: {:ok, term(), t()} | :empty

Reads a value from the buffer.

Should return the value and the new buffer or the atom :empty if there are no more values left.

Link to this function put(buffer, value) View Source
put(t(), term()) :: {:ok, t()} | :error

Puts a value in the buffer.

Should return the new buffer or error if the value cannot be put for some reason.