Struct aether_lib::link::Link  
source · [−]Expand description
Represents a single reliable Link to another peer
Fields
private_id: IdIdentity of the user that created this identity
peer_id: PublicIdPublic Identity of the other peer
Implementations
sourceimpl Link
 
impl Link
sourcepub fn new(
    id: Id, 
    socket: UdpSocket, 
    peer_addr: SocketAddr, 
    peer_id: PublicId, 
    send_seq: u32, 
    recv_seq: u32, 
    config: Config
) -> Result<Link, AetherError>
 
pub fn new(
    id: Id, 
    socket: UdpSocket, 
    peer_addr: SocketAddr, 
    peer_id: PublicId, 
    send_seq: u32, 
    recv_seq: u32, 
    config: Config
) -> Result<Link, AetherError>
Creates a new Link to another peer
Arguments
- id-- Idof the user that is creating this link
- socket- UDP socket used to communicate with the other peer
- peer_addr- Address of the other peer
- peer_id- Public Id of the other peer
- send_seq- Sending Sequence number that the Link needs to be initialised with
- recv_seq- Receiving Sequence number that the Link needs to be initialised with
- config- Configuration for Aether
pub fn enable_encryption(&mut self) -> Result<(), AetherError>
pub fn is_encrypted(&self) -> bool
sourcepub fn get_addr(&self) -> SocketAddr
 
pub fn get_addr(&self) -> SocketAddr
Get the SocketAddr of the peer
sourcepub fn send_packet(&self, packet: Packet) -> Result<(), AetherError>
 
pub fn send_packet(&self, packet: Packet) -> Result<(), AetherError>
sourcepub fn set_read_timout(&mut self, timeout: Duration)
 
pub fn set_read_timout(&mut self, timeout: Duration)
sourcepub fn recv_timeout(&self, timeout: Duration) -> Result<Vec<u8>, AetherError>
 
pub fn recv_timeout(&self, timeout: Duration) -> Result<Vec<u8>, AetherError>
Receive bytes from the other peer or return an error if the timeout is reached
Arguments
- timeout- Timeout to wait for receiving packets
Returns
- Vec<u8>- Buffer containing the received bytes
Errors
- AetherError::RecvTimeout- Timeout reached before receiving any bytes
- AetherError::LinkStopped-- Linkstopped before receiving any bytes
Other general errors might occur (refer to AetherError)
sourcepub fn recv(&self) -> Result<Vec<u8>, AetherError>
 
pub fn recv(&self) -> Result<Vec<u8>, AetherError>
Receive bytes from the other peer
Returns
- Vec<u8>- Buffer containing the received bytes
Errors
- AetherError::LinkStopped-- Linkstopped before receiving any bytes
- AetherError::LinkTimeout-- Linktimed out before receiving any bytes
Other general errors might occur (refer to AetherError)
sourcepub fn get_receiver(&self) -> Result<Receiver<Packet>, AetherError>
 
pub fn get_receiver(&self) -> Result<Receiver<Packet>, AetherError>
Returns a [Receiver] to receive packets from the output queue
sourcepub fn is_empty(&self) -> Result<bool, AetherError>
 
pub fn is_empty(&self) -> Result<bool, AetherError>
Returns true if no more packets needs to be sent Checks if both primary queue and batch queue are empty
sourcepub fn wait_empty(&self) -> Result<(), AetherError>
 
pub fn wait_empty(&self) -> Result<(), AetherError>
Waits and blocks the current thread until the Link is empty
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Link
impl Send for Link
impl Sync for Link
impl Unpin for Link
impl !UnwindSafe for Link
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
    T: ?Sized, 
 
impl<T> BorrowMut<T> for T where
    T: ?Sized, 
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
 
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more