Struct swiftlet_quic::endpoint::Endpoint
source · pub struct Endpoint { /* private fields */ }
Expand description
The Quic Endpoint structure
Implementations§
source§impl Endpoint
impl Endpoint
sourcepub fn new_server(
bind_addr: SocketAddr,
alpn: &[u8],
cert_path: &str,
pkey_path: &str,
config: Config
) -> Result<Self, Error>
pub fn new_server( bind_addr: SocketAddr, alpn: &[u8], cert_path: &str, pkey_path: &str, config: Config ) -> Result<Self, Error>
Create a QUIC Server Endpoint
sourcepub fn new_client(
bind_addr: SocketAddr,
alpn: &[u8],
cert_path: &str,
config: Config
) -> Result<Self, Error>
pub fn new_client( bind_addr: SocketAddr, alpn: &[u8], cert_path: &str, config: Config ) -> Result<Self, Error>
Create a QUIC Client Endpoint
sourcepub fn add_client_connection(
&mut self,
peer_addr: SocketAddr,
server_name: &str
) -> Result<(), Error>
pub fn add_client_connection( &mut self, peer_addr: SocketAddr, server_name: &str ) -> Result<(), Error>
Add a connection for a Client Endpoint
Must be used on a Client and not a Server otherwise an error will be thrown
sourcepub fn new_client_with_first_connection(
bind_addr: SocketAddr,
alpn: &[u8],
cert_path: &str,
peer_addr: SocketAddr,
server_name: &str,
config: Config
) -> Result<Self, Error>
pub fn new_client_with_first_connection( bind_addr: SocketAddr, alpn: &[u8], cert_path: &str, peer_addr: SocketAddr, server_name: &str, config: Config ) -> Result<Self, Error>
Create a QUIC Client Endpoint with an initial connection
sourcepub fn get_num_connections(&self) -> usize
pub fn get_num_connections(&self) -> usize
Get the number of connections that the Endpoint is managing
sourcepub fn update_keep_alive_duration(&mut self, duration_opt: Option<Duration>)
pub fn update_keep_alive_duration(&mut self, duration_opt: Option<Duration>)
Update the keep alive duration time
Will disable the keep alive functionality if set to None
sourcepub fn close_connection(
&mut self,
cid: &ConnectionId,
error_code: u64
) -> Result<bool, Error>
pub fn close_connection( &mut self, cid: &ConnectionId, error_code: u64 ) -> Result<bool, Error>
Close a connection with a given error code value
Returns true when connection close process has started
sourcepub fn get_connection_socket_addr(
&mut self,
cid: &ConnectionId
) -> Result<SocketAddr, Error>
pub fn get_connection_socket_addr( &mut self, cid: &ConnectionId ) -> Result<SocketAddr, Error>
Get the socket address for a connection
This address could change if a backend connection migration happens (not currently implemented / expected)
sourcepub fn main_stream_send(
&mut self,
cid: &ConnectionId,
send_data: Vec<u8>
) -> Result<(), Error>
pub fn main_stream_send( &mut self, cid: &ConnectionId, send_data: Vec<u8> ) -> Result<(), Error>
Send data over the main stream. This data is queued up if it cannot be sent immediately.
The main stream is a reliable (ordered) stream that focuses on communicating high-priority, small(ish) messages between the server and client.
A reminder that the Endpoint connection will be taking ownership of the data so it can be sent out when possible
sourcepub fn rt_stream_send(
&mut self,
cid: &ConnectionId,
send_data: Option<Vec<u8>>,
last_send_of_time_segment: bool
) -> Result<(), Error>
pub fn rt_stream_send( &mut self, cid: &ConnectionId, send_data: Option<Vec<u8>>, last_send_of_time_segment: bool ) -> Result<(), Error>
Send data over the real-time stream. This data is queued up if it cannot be sent immediately.
The real-time “stream” is different than the main stream because it uses multiple incremental QUIC unidirectional streams in the backend where each stream id represents a single time segment that has unreliability the moment when the next single time segment arrives before the previous stream (time segment) had finished.
When last_send_of_time_segment is set to true, the currently transmitting time segment will finish after sending all the data that is in the queue (including the optional send_data) and the real-time stream id will be incremented for any future real-time stream send data.
If not all of the send data for a previous real-time stream id has made it to the peer by the time the next time segement real-time stream data is ready to be sent (with a call to this function) then the send queue will be cleared (unreliable transmission) and the next send data will take its place.
A reminder that the Endpoint connection will be taking ownership of the data so it can be sent out when possible
sourcepub fn background_stream_send(
&mut self,
cid: &ConnectionId,
send_data: Vec<u8>
) -> Result<(), Error>
pub fn background_stream_send( &mut self, cid: &ConnectionId, send_data: Vec<u8> ) -> Result<(), Error>
Send data over the background stream. This data is queued up if it cannot be sent immediately.
The background stream is a reliable (ordered) stream that focuses on communicating large(ish) messages between the server and client such as a file transfer.
A reminder that the Endpoint connection will be taking ownership of the data so it can be sent out when possible