# `ExDlt645.Transport`
[🔗](https://github.com/Ultraluv/ex_dlt645/blob/v0.1.0/lib/ex_dlt645/transport.ex#L1)

Behaviour for DL/T 645 communication transport layers.

Decouples `ExDlt645.Master` and `ExDlt645.Slave` from hardware serial drivers,
allowing seamless switching between real serial ports (`Circuits.UART`),
in-memory virtual buses (`ExDlt645.Transport.Virtual`), and TCP connections
(`ExDlt645.Transport.Tcp`).

# `opts`

```elixir
@type opts() :: keyword()
```

# `transport_ref`

```elixir
@type transport_ref() :: pid() | term()
```

# `tty`

```elixir
@type tty() :: String.t() | atom() | term()
```

# `close`

```elixir
@callback close(transport_ref()) :: :ok | {:error, term()}
```

Closes the transport connection.

# `configure`

```elixir
@callback configure(transport_ref(), opts()) :: :ok | {:error, term()}
```

Reconfigures the transport.

# `flush`

```elixir
@callback flush(transport_ref(), :receive | :transmit | :both) :: :ok | {:error, term()}
```

Flushes input/output buffers in the transport.

# `open`

```elixir
@callback open(transport_ref(), tty(), opts()) :: :ok | {:error, term()}
```

Opens the transport connection for the given target / tty.

# `read`

```elixir
@callback read(transport_ref(), timeout()) ::
  {:ok, binary()}
  | {:ok, {:partial, binary()}}
  | {:ok, {:error, term(), term()}}
  | {:error, term()}
```

Reads data from the transport with a timeout.

# `start_link`

```elixir
@callback start_link(opts()) :: {:ok, transport_ref()} | {:error, term()}
```

Starts the transport process.

# `stop`

```elixir
@callback stop(transport_ref()) :: :ok
```

Stops the transport process.

# `write`

```elixir
@callback write(transport_ref(), binary()) :: :ok | {:error, term()}
```

Writes raw binary data over the transport.

# `resolve_transport`

```elixir
@spec resolve_transport(keyword(), tty()) :: module()
```

Resolves the transport module based on options and target identifier.

# `tcp_target?`

```elixir
@spec tcp_target?(term(), keyword()) :: boolean()
```

Checks if options or identifier represent a TCP connection.

# `virtual_tty?`

```elixir
@spec virtual_tty?(term()) :: boolean()
```

Checks if the identifier represents a virtual in-memory bus.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
