pub struct RelayConnection { /* private fields */ }
Expand description
Relay connection for bidirectional data forwarding
Implementations§
Source§impl RelayConnection
impl RelayConnection
Sourcepub fn new(
session_id: u32,
peer_addr: SocketAddr,
config: RelayConnectionConfig,
event_sender: UnboundedSender<RelayEvent>,
action_receiver: UnboundedReceiver<RelayAction>,
) -> Self
pub fn new( session_id: u32, peer_addr: SocketAddr, config: RelayConnectionConfig, event_sender: UnboundedSender<RelayEvent>, action_receiver: UnboundedReceiver<RelayAction>, ) -> Self
Create a new relay connection
Sourcepub fn session_id(&self) -> u32
pub fn session_id(&self) -> u32
Get session ID
Sourcepub fn peer_addr(&self) -> SocketAddr
pub fn peer_addr(&self) -> SocketAddr
Get peer address
Sourcepub fn receive_data(&self, data: Vec<u8>) -> RelayResult<()>
pub fn receive_data(&self, data: Vec<u8>) -> RelayResult<()>
Receive data from the relay
Sourcepub fn next_outgoing(&self) -> Option<Vec<u8>>
pub fn next_outgoing(&self) -> Option<Vec<u8>>
Get next outgoing data packet
Sourcepub fn next_incoming(&self) -> Option<Vec<u8>>
pub fn next_incoming(&self) -> Option<Vec<u8>>
Get next incoming data packet
Sourcepub fn check_timeout(&self) -> RelayResult<()>
pub fn check_timeout(&self) -> RelayResult<()>
Check if connection has timed out
Sourcepub fn should_send_keep_alive(&self) -> bool
pub fn should_send_keep_alive(&self) -> bool
Check if keep-alive should be sent
Sourcepub fn send_keep_alive(&self) -> RelayResult<()>
pub fn send_keep_alive(&self) -> RelayResult<()>
Send keep-alive
Sourcepub fn terminate(&self, reason: String) -> RelayResult<()>
pub fn terminate(&self, reason: String) -> RelayResult<()>
Terminate the connection
Sourcepub fn get_stats(&self) -> ConnectionStats
pub fn get_stats(&self) -> ConnectionStats
Get connection statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RelayConnection
impl RefUnwindSafe for RelayConnection
impl Send for RelayConnection
impl Sync for RelayConnection
impl Unpin for RelayConnection
impl UnwindSafe for RelayConnection
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