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
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
An error result.
Link to this section Functions
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>>
""
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.
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).
start([], GenServer.options()) :: GenServer.on_start()
Starts a StructuredIO
process without links (outside a
supervision tree) with the specified options
.
Starts a StructuredIO
process linked to the current process.
See StructuredIO.binread_across/3
and
StructuredIO.read_across/3
for examples.
start_link([], GenServer.options()) :: GenServer.on_start()
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.
stop(GenServer.server(), term()) :: :ok
Synchronously stops the specified structured_io
process with the specified
reason
and an infinite timeout.
stop(GenServer.server(), term(), timeout()) :: :ok
Synchronously stops the specified structured_io
process with the specified
reason
and timeout
.
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.