View Source GenLSP.Communication.Adapter behaviour (gen_lsp v0.10.0)

Behaviour for implementing communication adapters for the GenLSP.Buffer module to use.

Existing implementations:

Link to this section Summary

Callbacks

Initialize the adapter.

Tells the adapter to begin listening for data.

Read from the client.

Write data to the client.

Link to this section Types

@type state() :: any()

Link to this section Callbacks

@callback init(args :: any()) :: {:ok, state()}

Initialize the adapter.

Here you should return any state that should be passed into the other callbacks.

@callback listen(state()) :: {:ok, state()}

Tells the adapter to begin listening for data.

@callback read(state(), String.t()) :: {:ok, term(), term()} | :eof | {:error, term()}

Read from the client.

This callback should read a packet of data from the client and return it as the second element in the tuple.

The third element can be used to return any data that as already been read from the client but still needs to be parsed into a packet.

@callback write(body :: String.t(), state()) :: :ok | {:error, term()}

Write data to the client.