structured_io v0.1.0 StructuredIO View Source

A process for performing I/O of structured data, such as markup or binary-encoded data.

Link to this section Summary

Types

An error result

Functions

Reads data from the specified structured_io beginning with the specified from and ending with the specified through. The operation is Unicode unsafe

Asynchronously writes iodata as a binary to the specified structured_io. The operation is Unicode unsafe

Reads data from the specified structured_io beginning with the specified from and ending with the specified through

Starts a StructuredIO process without links (outside a supervision tree)

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

Starts a StructuredIO process linked to the current process

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

Synchronously stops the specified structured_io process with a reason of :normal and an infinite timeout

Synchronously stops the specified structured_io process with the specified reason and an infinite timeout

Synchronously stops the specified structured_io process with the specified reason and timeout

Asynchronously writes chardata as a binary to the specified structured_io

Link to this section Types

Link to this type error() View Source
error() :: {:error, atom() | binary()}

An error result.

Link to this section Functions

Link to this function binread_across(structured_io, from, through) View Source
binread_across(GenServer.server(), binary(), binary()) :: StructuredIO.Scanner.match()

Reads data from the specified structured_io beginning with the specified from and ending with the specified through. The operation is Unicode unsafe.

If the data read does not begin with from, the result is an empty binary (""). Likewise, if through is not encountered, the result is an empty binary ("").

Examples

iex> {:ok, structured_io} = StructuredIO.start_link
iex> StructuredIO.binwrite structured_io,
...>                       <<0, 0, 0, 1, 2, 3, 255, 255>>
:ok
iex> StructuredIO.binread_across structured_io,
...>                             <<0, 0, 0>>,
...>                             <<255, 255, 255>>
""
iex> StructuredIO.binwrite structured_io,
...>                       <<255, 0, 0, 0, 4, 5, 6, 255, 255, 255>>
:ok
iex> StructuredIO.binread_across structured_io,
...>                             <<0, 0, 0>>,
...>                             <<255, 255, 255>>
<<0, 0, 0, 1, 2, 3, 255, 255, 255>>
iex> StructuredIO.binread_across structured_io,
...>                             <<0, 0, 0>>,
...>                             <<255, 255, 255>>
<<0, 0, 0, 4, 5, 6, 255, 255, 255>>
iex> StructuredIO.binread_across structured_io,
...>                             <<0, 0, 0>>,
...>                             <<255, 255, 255>>
""
Link to this function binwrite(structured_io, iodata) View Source
binwrite(GenServer.server(), iodata()) :: :ok | error()

Asynchronously writes iodata as a binary to the specified structured_io. The operation is Unicode unsafe.

See StructuredIO.binread_across/3 for examples.

Link to this function read_across(structured_io, from, through) View Source
read_across(GenServer.server(), binary(), binary()) :: binary()

Reads data from the specified structured_io beginning with the specified from and ending with the specified through.

If the data read does not begin with from, the result is an empty binary (""). Likewise, if through is not encountered, the result is an empty binary ("").

Examples

iex> {:ok, structured_io} = StructuredIO.start_link
iex> StructuredIO.write structured_io,
...>                    "<elem>foo</elem"
:ok
iex> StructuredIO.read_across structured_io,
...>                          "<elem>",
...>                          "</elem>"
""
iex> StructuredIO.write structured_io,
...>                    "><elem>bar</elem>"
:ok
iex> StructuredIO.read_across structured_io,
...>                          "<elem>",
...>                          "</elem>"
"<elem>foo</elem>"
iex> StructuredIO.read_across structured_io,
...>                          "<elem>",
...>                          "</elem>"
"<elem>bar</elem>"
iex> StructuredIO.read_across structured_io,
...>                          "<elem>",
...>                          "</elem>"
""

Starts a StructuredIO process without links (outside a supervision tree).

See StructuredIO.start_link/0.

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

See StructuredIO.start_link/2.

Starts a StructuredIO process linked to the current process.

See StructuredIO.binread_across/3 and StructuredIO.read_across/3 for examples.

Link to this function start_link(args, options) View Source
start_link([], GenServer.options()) :: GenServer.on_start()

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

Link to this function stop(structured_io) View Source
stop(GenServer.server()) :: :ok

Synchronously stops the specified structured_io process with a reason of :normal and an infinite timeout.

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

Synchronously stops the specified structured_io process with the specified reason and an infinite timeout.

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

Synchronously stops the specified structured_io process with the specified reason and timeout.

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

Asynchronously writes chardata as a binary to the specified structured_io.

See StructuredIO.read_across/3 and for examples.