Struct uflow::client::Client

source ·
pub struct Client { /* private fields */ }
Expand description

Manages a single outbound uflow connection.

Implementations§

Opens a non-blocking UDP socket bound to an ephemeral address, and returns a corresponding Client object. A connection to the server at the provided destination address is initiated immediately.

An IPv4/IPv6 socket will be opened according to the type of the destination address.

Error Handling

Any errors resulting from socket initialization are forwarded to the caller. This function will panic if the provided client configuration is not valid.

Flushes outbound frames, then processes as many inbound frames as possible from the internal socket. Returns an iterator of Event objects to signal connection events and deliver packets received from the server.

Note 1: All events are considered delivered, even if the iterator is not consumed until the end.

Note 2: Internally, uflow uses the leaky bucket algorithm to control the rate at which UDP frames are sent. To ensure that data is transferred smoothly, this function should be called regularly and relatively frequently.

Sends as many outbound frames as possible.

Returns true if the connection is active, that is, a connection handshake has been completed and the remote host has not yet timed out or disconnected. Returns false otherwise.

Enqueues a packet for delivery to the server. The packet will be sent on the given channel according to the specified mode.

If a connection has not yet been established, the packet will remain enqueued until the connection succeeds. Otherwise, if the connection is not active, the packet will be silently discarded.

Error Handling

This function will panic if channel_id does not refer to a valid channel (channel_id >= CHANNEL_COUNT), or if data.len() exceeds the maximum packet size.

Gracefully terminates this connection once all packets have been sent.

If any outbound packets are pending, they will be sent prior to disconnecting. Reliable packets can be assumed to have been delievered, so long as the server does not also disconnect in the meantime. The connection will remain active until the next call to Client::step() with no pending outbound packets.

Gracefully terminates this connection as soon as possible.

If any outbound packets are pending, they may be flushed prior to disconnecting, but no packets are guaranteed to be received by the server. The connection will remain active until the next call to Client::step().

Returns the local address of the internal UDP socket.

Returns the address of the server.

Returns the current estimate of the round-trip time (RTT), in seconds.

If the RTT has not yet been computed, None is returned instead.

Returns the combined size of all outstanding packets (i.e. those which have not yet been acknowledged), in bytes.

This figure represents the amount of memory allocated for outgoing packets. Packets which are marked TimeSensitive are included in this total, even if they would not be sent.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.