use bytes::BytesMut;
use crate::ipc::error::IpcError;
use super::IpcConnection;
pub async fn connect(endpoint: &str) -> Result<IpcConnection, IpcError> {
let stream = tokio::net::UnixStream::connect(endpoint).await?;
Ok(IpcConnection::from_unix_stream(stream))
}
impl IpcConnection {
pub fn from_unix_stream(stream: tokio::net::UnixStream) -> Self {
let (reader, writer) = tokio::io::split(stream);
IpcConnection {
reader,
writer,
read_buf: BytesMut::with_capacity(4096),
recv_timeout: None,
next_frame_request_id: 1,
}
}
}