Struct sopht::ipc::Connection
source · pub struct Connection { /* private fields */ }
Expand description
structure containing the state of a connection to the sopht socket
Implementations§
source§impl Connection
impl Connection
sourcepub fn new(stream: UnixStream) -> Result<Self>
pub fn new(stream: UnixStream) -> Result<Self>
consumes a UnixStream
and tries to create a Connection
. this
function calls try_clone
on the stream and,
if this fails, returns a SocketError
. otherwise,
the connection is successfully created
sourcepub fn send(&mut self, cmd: &Message) -> Result<()>
pub fn send(&mut self, cmd: &Message) -> Result<()>
sends a Message
over the connection. this function can fail if
- the message fails to serialize
(
SerializeError
) - the connection is closed
(
ConnectionClosed
) - there is some other internal error on the
UnixStream
(SocketError
)
sourcepub fn recv(&mut self) -> Result<Message>
pub fn recv(&mut self) -> Result<Message>
attempts to receieve a Message
over the connection. this function
can fail if
- the received message fails to deserialize
(
SerializeError
) - the connection is closed
(
ConnectionClosed
) - there is some other internal error on the
UnixStream
(SocketError
)
sourcepub fn recv_command(&mut self) -> Result<Command>
pub fn recv_command(&mut self) -> Result<Command>
helper function that internally calls recv
, then
attempts to pull a Command
out of the Message
. if the message is
not a command, this function returns
WrongMessageKind
sourcepub fn recv_response(&mut self) -> Result<Response>
pub fn recv_response(&mut self) -> Result<Response>
helper function that internally calls recv
, then
attempts to pull a Response
out of the Message
. if the message
is not a command, this function returns
WrongMessageKind
Auto Trait Implementations§
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more