IrohBeam.Connection (iroh_beam v0.2.0)

View Source

Mutually authenticated Iroh connection.

Connections negotiate one explicit application ALPN and expose the remote key-derived endpoint identity. They are application transports, not Erlang distribution links.

Summary

Types

t()

@type t() :: %IrohBeam.Connection{
  alpn: String.t(),
  owner: pid(),
  remote_id: IrohBeam.EndpointId.t(),
  resource: reference(),
  role: :outgoing | :incoming,
  side: :client | :server,
  stable_id: non_neg_integer()
}

Functions

accept_bi(connection, options \\ [])

@spec accept_bi(
  t(),
  keyword()
) :: {:ok, IrohBeam.Stream.t()} | {:error, IrohBeam.Error.t()}

accept_uni(connection, options \\ [])

@spec accept_uni(
  t(),
  keyword()
) :: {:ok, IrohBeam.Stream.t()} | {:error, IrohBeam.Error.t()}

alpn(connection)

@spec alpn(t()) :: String.t()

close(connection)

@spec close(t()) :: :ok

close_reason(connection)

@spec close_reason(t()) :: nil | IrohBeam.Error.t()

closed(connection, timeout \\ 5000)

@spec closed(t(), timeout()) :: :ok | {:error, IrohBeam.Error.t()}

datagram_info(connection)

@spec datagram_info(t()) :: {:ok, map()} | {:error, IrohBeam.Error.t()}

info(connection)

@spec info(t()) :: {:ok, map()} | {:error, IrohBeam.Error.t()}

open_bi(connection, options \\ [])

@spec open_bi(
  t(),
  keyword()
) :: {:ok, IrohBeam.Stream.t()} | {:error, IrohBeam.Error.t()}

open_uni(connection, options \\ [])

@spec open_uni(
  t(),
  keyword()
) :: {:ok, IrohBeam.Stream.t()} | {:error, IrohBeam.Error.t()}

path(connection)

@spec path(t()) :: {:ok, map() | nil} | {:error, IrohBeam.Error.t()}

recv_datagram(connection, options \\ [])

@spec recv_datagram(
  t(),
  keyword()
) :: {:ok, binary()} | {:error, IrohBeam.Error.t()}

remote_id(connection)

@spec remote_id(t()) :: IrohBeam.EndpointId.t()

role(connection)

@spec role(t()) :: :outgoing | :incoming

send_datagram(connection, data, options \\ [])

@spec send_datagram(t(), binary(), keyword()) :: :ok | {:error, IrohBeam.Error.t()}

side(connection)

@spec side(t()) :: :client | :server

stable_id(connection)

@spec stable_id(t()) :: non_neg_integer()