Struct laminar::VirtualConnection[][src]

pub struct VirtualConnection {
    pub last_heard: Instant,
    pub last_sent: Instant,
    pub remote_address: SocketAddr,
    // some fields omitted
}

Contains the information about a certain ‘virtual connection’ over udp. This connections also keeps track of network quality, processing packets, buffering data related to connection etc.

Fields

last_heard: Instant

Last time we received a packet from this client

last_sent: Instant

Last time we sent a packet to this client

remote_address: SocketAddr

The address of the remote endpoint

Implementations

impl VirtualConnection[src]

pub fn new(
    addr: SocketAddr,
    config: &Config,
    time: Instant
) -> VirtualConnection
[src]

Creates and returns a new Connection that wraps the provided socket address

pub fn record_send(&mut self) -> bool[src]

Records that this connection has sent a packet. Returns whether the connection has become acknowledged because of this send.

pub fn record_recv(&mut self) -> bool[src]

Records that this connection has sent a packet. Returns whether the connection has become acknowledged because of this send.

pub fn is_established(&self) -> bool[src]

Returns if the connection has been established

pub fn packets_in_flight(&self) -> u16[src]

Returns the current number of not yet acknowledged packets

pub fn last_heard(&self, time: Instant) -> Duration[src]

Returns a Duration representing the interval since we last heard from the client

pub fn last_sent(&self, time: Instant) -> Duration[src]

Returns a Duration representing the interval since we last sent to the client

pub fn process_outgoing<'a>(
    &mut self,
    packet: PacketInfo<'a>,
    last_item_identifier: Option<u16>,
    time: Instant
) -> Result<OutgoingPackets<'a>>
[src]

Pre-processes the given buffer to be sent over the network.

pub fn process_incoming(
    &mut self,
    received_data: &[u8],
    time: Instant
) -> Result<IncomingPackets>
[src]

Processes the incoming data and returns a packet once the data is complete.

pub fn gather_dropped_packets(&mut self) -> Vec<SentPacket>[src]

Gathers dropped packets from the acknowledgment handler.

Note that after requesting dropped packets the dropped packets will be removed from this client.

Trait Implementations

impl Connection for VirtualConnection[src]

type SendEvent = Packet

Defines a user event type.

type ReceiveEvent = SocketEvent

Defines a connection event type.

fn create_connection(
    messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
    address: SocketAddr,
    time: Instant
) -> VirtualConnection
[src]

Creates new connection and initialize it by sending an connection event to the user.

  • address - defines a address that connection is associated with.
  • time - creation time, used by connection, so that it doesn’t get dropped immediately or send heartbeat packet.
  • initial_data - if initiated by remote host, this will hold that a packet data.

fn is_established(&self) -> bool[src]

Connections are considered established once they both have had a send and a receive.

fn should_drop(
    &mut self,
    messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
    time: Instant
) -> bool
[src]

Determines if the given Connection should be dropped due to its state.

fn process_packet(
    &mut self,
    messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
    payload: &[u8],
    time: Instant
)
[src]

Processes a received packet: parse it and emit an event.

fn process_event(
    &mut self,
    messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
    event: Self::SendEvent,
    time: Instant
)
[src]

Processes a received event and send a packet.

fn update(
    &mut self,
    messenger: &mut impl ConnectionMessenger<Self::ReceiveEvent>,
    time: Instant
)
[src]

Processes various connection-related tasks: resend dropped packets, send heartbeat packet, etc… This function gets called very frequently.

impl Debug for VirtualConnection[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V