pub struct Socket<Req, Resp> { /* private fields */ }Expand description
A hRPC socket.
Sockets only handle pings if you call .receive_message() continously.
See the respective socket transports used for more information on their behaviour.
The socket transports are located in crate::common::transport.
Implementations§
Source§impl<Req, Resp> Socket<Req, Resp>
impl<Req, Resp> Socket<Req, Resp>
Sourcepub async fn send_error(&mut self, err: HrpcError) -> Result<(), SocketError>
pub async fn send_error(&mut self, err: HrpcError) -> Result<(), SocketError>
Send an error over the socket.
Source§impl<Req, Resp> Socket<Req, Resp>
impl<Req, Resp> Socket<Req, Resp>
Sourcepub async fn receive_message(&mut self) -> Result<Resp, SocketError>
pub async fn receive_message(&mut self) -> Result<Resp, SocketError>
Receive a message from the socket.
§Notes
- This will block until getting a message (unless an error occurs).
- This will handle ping messages.
Sourcepub async fn send_message(&mut self, req: Req) -> Result<(), SocketError>
pub async fn send_message(&mut self, req: Req) -> Result<(), SocketError>
Send a message over the socket.
Sourcepub async fn ping(&mut self) -> Result<(), SocketError>
pub async fn ping(&mut self) -> Result<(), SocketError>
Send a ping over the socket.
Sourcepub async fn close(self) -> Result<(), SocketError>
pub async fn close(self) -> Result<(), SocketError>
Close the socket.
Sourcepub fn split(self) -> (WriteSocket<Req>, ReadSocket<Resp>)
pub fn split(self) -> (WriteSocket<Req>, ReadSocket<Resp>)
Split this socket into the write half and the read half.
Sourcepub fn combine(
write: WriteSocket<Req>,
read: ReadSocket<Resp>,
) -> Result<Self, CombineError>
pub fn combine( write: WriteSocket<Req>, read: ReadSocket<Resp>, ) -> Result<Self, CombineError>
Combine a write and read half back to a socket.
§Errors
- Returns
CombineErrorif the socket halfs aren’t split from the same socket.
Auto Trait Implementations§
impl<Req, Resp> !RefUnwindSafe for Socket<Req, Resp>
impl<Req, Resp> !UnwindSafe for Socket<Req, Resp>
impl<Req, Resp> Freeze for Socket<Req, Resp>
impl<Req, Resp> Send for Socket<Req, Resp>
impl<Req, Resp> Sync for Socket<Req, Resp>
impl<Req, Resp> Unpin for Socket<Req, Resp>
impl<Req, Resp> UnsafeUnpin for Socket<Req, Resp>
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