Allow API client to be made from connection

This commit is contained in:
Elara 2022-05-07 21:23:42 -07:00
parent b614138f6b
commit 0cbd6a48ae

View File

@ -1,6 +1,7 @@
package api
import (
"io"
"net"
"go.arsenm.dev/lrpc/client"
@ -25,6 +26,12 @@ func New(sockPath string) (*Client, error) {
return out, nil
}
func NewFromConn(conn io.ReadWriteCloser) *Client {
return &Client{
client: client.New(conn, codec.Default),
}
}
func (c *Client) Close() error {
return c.client.Close()
}