ASDF.Sink (asdf v0.1.0)

Copy Markdown View Source

Where ASDF.write/3 puts bytes.

A path is a file. :binary means the caller wants the bytes back from ASDF.write/3 as {:ok, binary}.

Summary

Functions

Writes iodata to sink.

Functions

put(path, iodata)

@spec put(Path.t() | :binary, iodata()) ::
  :ok | {:ok, binary()} | {:error, ASDF.Error.t()}

Writes iodata to sink.

sink is :binary or a filesystem path. iodata is a binary or an iodata list. :binary returns {:ok, bytes}. A path returns :ok, or {:error, %ASDF.Error{reason: :io}} when the write fails. Does not raise.

Examples

iex> ASDF.Sink.put(:binary, ["ab", "c"])
{:ok, "abc"}

iex> path = Path.join([System.tmp_dir!(), "asdf-missing-sink", "nope.asdf"])
...> {:error, error} = ASDF.Sink.put(path, "hi")
...> error.reason
:io