structured_io v1.5.0 StructuredIO.Behaviour behaviour View Source

Defines a behavioral contract that is satisfied by StructuredIO.

Link to this section Summary

Callbacks

Returns a value that can be passed to Enum.into/2 or Enum.into/3 for writing data to the specified structured_io

Returns a value that can be passed to functions such as Enum.map/2 for reading data elements from the specified structured_io, using the specified StructuredIO function, and the specified left and/or right/operation

Gets the mode of the specified structured_io

Reads data from the specified structured_io in the specified quantity, or beginning with the specified binary value

Reads data from the specified structured_io beginning with the specified left and ending with the occurrence of the specified right that corresponds to it, inclusive

Reads data from the specified structured_io beginning with the specified left and ending with the first occurrence of the specified right, inclusive

Reads data from the specified structured_io beginning with the specified left and ending with the occurrence of the specified right that corresponds to it, exclusive

Reads data from the specified structured_io beginning with the specified left and ending with the first occurrence of the specified right, exclusive

Invokes the specified operation, changing the state of the specified structured_io only if the operation is successful. Success is indicated when the operation returns {:ok, term}, in which case only the term is returned

Reads data from the specified structured_io if and until the specified right is encountered, including right

Reads data from the specified structured_io if and until the specified right is encountered, excluding right

Starts a StructuredIO process without links (outside a supervision tree) with the specified mode and options

Starts a StructuredIO process linked to the current process with the specified mode and options

Stops the specified structured_io process

Writes the specified data to the specified structured_io

Link to this section Callbacks

Link to this callback collect(structured_io) View Source
collect(structured_io :: GenServer.server()) :: StructuredIO.Collector.t()

Returns a value that can be passed to Enum.into/2 or Enum.into/3 for writing data to the specified structured_io.

Link to this callback enumerate_with(structured_io, function, right) View Source
enumerate_with(
  structured_io :: GenServer.server(),
  function :: :read_through | :read_to,
  right :: StructuredIO.right()
) :: StructuredIO.Enumerator.t()
enumerate_with(
  structured_io :: GenServer.server(),
  function :: :read_complex,
  operation :: StructuredIO.operation()
) :: StructuredIO.Enumerator.t()
Link to this callback enumerate_with(structured_io, function, left, right) View Source
enumerate_with(
  structured_io :: GenServer.server(),
  function ::
    :read_across
    | :read_across_ignoring_overlap
    | :read_between
    | :read_between_ignoring_overlap,
  left :: StructuredIO.left(),
  right :: StructuredIO.right()
) :: StructuredIO.Enumerator.t()

Returns a value that can be passed to functions such as Enum.map/2 for reading data elements from the specified structured_io, using the specified StructuredIO function, and the specified left and/or right/operation.

Link to this callback mode(structured_io) View Source
mode(structured_io :: GenServer.server()) :: StructuredIO.mode()

Gets the mode of the specified structured_io.

Link to this callback read(structured_io, count_or_match, timeout) View Source
read(
  structured_io :: GenServer.server(),
  count_or_match :: StructuredIO.count() | StructuredIO.match(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io in the specified quantity, or beginning with the specified binary value.

Link to this callback read_across(structured_io, left, right, timeout) View Source
read_across(
  structured_io :: GenServer.server(),
  left :: StructuredIO.left(),
  right :: StructuredIO.right(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io beginning with the specified left and ending with the occurrence of the specified right that corresponds to it, inclusive.

Link to this callback read_across_ignoring_overlap(structured_io, left, right, timeout) View Source
read_across_ignoring_overlap(
  structured_io :: GenServer.server(),
  left :: StructuredIO.left(),
  right :: StructuredIO.right(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io beginning with the specified left and ending with the first occurrence of the specified right, inclusive.

Link to this callback read_between(structured_io, left, right, timeout) View Source
read_between(
  structured_io :: GenServer.server(),
  left :: StructuredIO.left(),
  right :: StructuredIO.right(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io beginning with the specified left and ending with the occurrence of the specified right that corresponds to it, exclusive.

Link to this callback read_between_ignoring_overlap(structured_io, left, right, timeout) View Source
read_between_ignoring_overlap(
  structured_io :: GenServer.server(),
  left :: StructuredIO.left(),
  right :: StructuredIO.right(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io beginning with the specified left and ending with the first occurrence of the specified right, exclusive.

Link to this callback read_complex(structured_io, operation, timeout) View Source
read_complex(
  structured_io :: GenServer.server(),
  operation :: StructuredIO.operation(),
  timeout :: timeout()
) :: any()

Invokes the specified operation, changing the state of the specified structured_io only if the operation is successful. Success is indicated when the operation returns {:ok, term}, in which case only the term is returned.

Link to this callback read_through(structured_io, right, timeout) View Source
read_through(
  structured_io :: GenServer.server(),
  right :: StructuredIO.right(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io if and until the specified right is encountered, including right.

Link to this callback read_to(structured_io, right, timeout) View Source
read_to(
  structured_io :: GenServer.server(),
  right :: StructuredIO.right(),
  timeout :: timeout()
) :: StructuredIO.match() | StructuredIO.error()

Reads data from the specified structured_io if and until the specified right is encountered, excluding right.

Link to this callback start(mode, options) View Source
start(mode :: StructuredIO.mode(), options :: GenServer.options()) ::
  GenServer.on_start()

Starts a StructuredIO process without links (outside a supervision tree) with the specified mode and options.

Link to this callback start_link(mode, options) View Source
start_link(mode :: StructuredIO.mode(), options :: GenServer.options()) ::
  GenServer.on_start()

Starts a StructuredIO process linked to the current process with the specified mode and options.

Link to this callback stop(structured_io, reason, timeout) View Source
stop(
  structured_io :: GenServer.server(),
  reason :: term(),
  timeout :: timeout()
) :: :ok

Stops the specified structured_io process.

Link to this callback write(structured_io, data) View Source
write(
  structured_io :: GenServer.server(),
  data :: iodata() | IO.chardata() | String.Chars.t()
) :: :ok | StructuredIO.error()

Writes the specified data to the specified structured_io.