pub struct RUMClient { /* private fields */ }
Expand description
This structs encapsulates the tokio::net::TcpStream instance that will be our adapter for connecting and sending messages to a peer or server.
Implementations§
Source§impl RUMClient
impl RUMClient
Sourcepub async fn connect(ip: &str, port: u16) -> RUMResult<RUMClient>
pub async fn connect(ip: &str, port: u16) -> RUMResult<RUMClient>
Connect to peer and construct the client.
Sourcepub async fn accept(socket: TcpStream) -> RUMResult<RUMClient>
pub async fn accept(socket: TcpStream) -> RUMResult<RUMClient>
If a connection was already pre-established elsewhere, construct our client with the connected socket.
Sourcepub async fn send(&mut self, msg: &RUMNetMessage) -> RUMResult<()>
pub async fn send(&mut self, msg: &RUMNetMessage) -> RUMResult<()>
Send message to server.
Sourcepub async fn recv(&mut self) -> RUMResult<RUMNetMessage>
pub async fn recv(&mut self) -> RUMResult<RUMNetMessage>
Receive message from server. This method will make calls to RUMClient::recv_some indefinitely until we have the full message or stop receiving any data.
pub async fn wait_incoming(&self) -> RUMResult<bool>
Sourcepub async fn read_ready(&self) -> bool
pub async fn read_ready(&self) -> bool
Check if socket is ready for reading.
Sourcepub async fn write_ready(&self) -> bool
pub async fn write_ready(&self) -> bool
Check if socket is ready for writing.
Sourcepub async fn get_address(&self, local: bool) -> Option<RUMString>
pub async fn get_address(&self, local: bool) -> Option<RUMString>
Returns the peer address:port as a string.
pub fn is_disconnected(&self) -> bool
pub fn disconnect(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RUMClient
impl RefUnwindSafe for RUMClient
impl Send for RUMClient
impl Sync for RUMClient
impl Unpin for RUMClient
impl UnwindSafe for RUMClient
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