pub struct Client { /* private fields */ }
Expand description
Structure that represents how Server keeps connected clients. A write-only socket with human interface. A client cannot send a message directly to another client, whereas server can.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
tx: Sender<Packet>,
pk: &PublicKey,
ip_addr: IpAddr,
port: u16,
) -> Client
pub fn new( tx: Sender<Packet>, pk: &PublicKey, ip_addr: IpAddr, port: u16, ) -> Client
Create new Client
Sourcepub fn set_last_pong_resp(&mut self, time: Instant)
pub fn set_last_pong_resp(&mut self, time: Instant)
Set last_pong_resp
Sourcepub fn is_pong_timedout(&self) -> bool
pub fn is_pong_timedout(&self) -> bool
Check if PongResponse timed out
Sourcepub fn is_ping_interval_passed(&self) -> bool
pub fn is_ping_interval_passed(&self) -> bool
Check if Ping interval is elapsed
Sourcepub async fn send_route_response(
&self,
pk: &PublicKey,
connection_id: ConnectionId,
) -> Result<(), Error>
pub async fn send_route_response( &self, pk: &PublicKey, connection_id: ConnectionId, ) -> Result<(), Error>
Construct RouteResponse and send it to Client
Sourcepub async fn send_connect_notification(&self, connection_id: ConnectionId)
pub async fn send_connect_notification(&self, connection_id: ConnectionId)
Construct ConnectNotification and send it to Client ignoring IO error
Sourcepub async fn send_disconnect_notification(&self, connection_id: ConnectionId)
pub async fn send_disconnect_notification(&self, connection_id: ConnectionId)
Construct DisconnectNotification and send it to Client ignoring IO error
Sourcepub async fn send_pong_response(&self, ping_id: u64) -> Result<(), Error>
pub async fn send_pong_response(&self, ping_id: u64) -> Result<(), Error>
Construct PongResponse and send it to Client
Sourcepub async fn send_oob(&self, sender_pk: &PublicKey, data: Vec<u8>)
pub async fn send_oob(&self, sender_pk: &PublicKey, data: Vec<u8>)
Construct OobReceive and send it to Client ignoring IO error
Sourcepub async fn send_onion_response(
&self,
payload: InnerOnionResponse,
) -> Result<(), Error>
pub async fn send_onion_response( &self, payload: InnerOnionResponse, ) -> Result<(), Error>
Construct OnionResponse and send it to Client
Sourcepub async fn send_data(
&self,
connection_id: ConnectionId,
data: DataPayload,
) -> Result<(), Error>
pub async fn send_data( &self, connection_id: ConnectionId, data: DataPayload, ) -> Result<(), Error>
Construct Data and send it to Client
Sourcepub async fn send_ping_request(&mut self) -> Result<(), Error>
pub async fn send_ping_request(&mut self) -> Result<(), Error>
Construct PingRequest and send it to Client
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more