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.
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 Forget for RUMClient
impl Move for RUMClient
impl RefUnwindSafe for RUMClientwhere
PollEvented<TcpStream>: RefUnwindSafe,
impl Send for RUMClient
impl Sync for RUMClient
impl Unpin for RUMClient
impl UnsafeUnpin for RUMClientwhere
I32NotAllOnes: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
*const ArcInner<Handle> is !null: UnsafeUnpin,
PhantomData<ArcInner<Handle>>: UnsafeUnpin,
*const ArcInner<Handle> is !null: UnsafeUnpin,
PhantomData<ArcInner<Handle>>: UnsafeUnpin,
*const ArcInner<ScheduledIo> is !null: UnsafeUnpin,
PhantomData<ArcInner<ScheduledIo>>: UnsafeUnpin,
impl UnwindSafe for RUMClientwhere
PollEvented<TcpStream>: UnwindSafe,
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