pub struct RawTCPClient { /* private fields */ }
Expand description
Client to make TCP requests in the form of messages.
Messages can be any sequence of bytes, such as a serialized value. This library uses a 8-byte header to encode the size of the data sent.
Implementations§
Source§impl RawTCPClient
impl RawTCPClient
Sourcepub async fn connect(host: &str, port: u16) -> Result<Self>
pub async fn connect(host: &str, port: u16) -> Result<Self>
Connect to a TCP server at the given host
and port
.
Returns an error if the connection cannot be established.
Sourcepub async fn send(&mut self, message: &[u8]) -> Result<Vec<u8>>
pub async fn send(&mut self, message: &[u8]) -> Result<Vec<u8>>
Send a message and wait for a response, returning it verbatim.
Returns an error if there were errors while sending or receiving data, if the connection was closed by the server or if there were problems compressing/decompressing the data.
Server and client must both use compression or not use it.
Auto Trait Implementations§
impl !Freeze for RawTCPClient
impl RefUnwindSafe for RawTCPClient
impl Send for RawTCPClient
impl Sync for RawTCPClient
impl Unpin for RawTCPClient
impl UnwindSafe for RawTCPClient
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