### QuicAsyncPlugin Ready Check Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/async_plugin/struct.QuicAsyncPlugin.html Checks if the QuicAsyncPlugin has finished its setup. This is useful for plugins that depend on asynchronous operations. ```rust fn ready(&self, _app: &App) -> bool ``` -------------------------------- ### QuicAsyncPlugin Finish Method Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/async_plugin/struct.QuicAsyncPlugin.html Completes the plugin's setup after all other plugins are ready. Useful for plugins that have asynchronous dependencies. ```rust fn finish(&self, _app: &mut App) ``` -------------------------------- ### AsyncOrchestrator Setup Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/orchestrator/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Initializes the orchestrator with a specified number of worker threads. It sets up channels for communication between the dispatcher and workers. ```rust pub(crate) fn new(runtime: Handle, worker_count: usize) -> Self { let (tx, rx) = mpsc::channel(ORCHESTRATOR_CHANNEL_SIZE); // One channel per worker; the dispatcher holds the senders. let mut task_joins = Vec::with_capacity(worker_count + 1); let mut worker_senders = Vec::with_capacity(worker_count); for _ in 0..worker_count { let (worker_tx, worker_rx) = mpsc::channel(WORKER_CHANNEL_SIZE); worker_senders.push(worker_tx); task_joins.push(runtime.spawn(OrchestratorWorker::new(worker_rx).start())); } task_joins .push(runtime.spawn(OrchestratorDispatcher::new(rx, worker_senders).start())); let orchestrator = OrchestratorHandle::new(tx, runtime.clone()); Self { _task_joins: task_joins, orchestrator, } } ``` -------------------------------- ### DisconnectHandlerPlugin Setup Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/plugin.rs.html Sets up the DisconnectHandlerPlugin by adding systems to handle disconnections for connections, receive streams, and send streams during the Update schedule. ```rust use aeronet_io::connection::DisconnectReason; use bevy::{ app::{Plugin, Update}, ecs::{ entity::Entity, system::{Commands, Query}, }, }; use crate::common::{ connection::QuicConnection, stream::{receive::QuicReceiveStream, send::QuicSendStream}, }; /// A plugin which handles any connection or stream components which have been disconnected. /// /// Connection disconnects will trigger aeronet's [Disconnected][aeronet_io::connection::Disconnected] /// event. /// /// Streams will be disconnected without an event firing pub struct DisconnectHandlerPlugin; impl Plugin for DisconnectHandlerPlugin { fn build(&self, app: &mut bevy::app::App) { app.add_systems( Update, ( handle_connection_disconnections, handle_rec_stream_disconnections, handle_send_stream_disconnections, ), ); } } ``` -------------------------------- ### Add Default Bevy QUIC Plugins Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/index.html Add the default plugins to your Bevy app to enable QUIC networking functionality. This is the basic setup required for most applications. ```rust use bevy::prelude::*; use bevy_s2n_quic::QuicDefaultPlugins; App::new() .add_plugins(QuicDefaultPlugins); ``` -------------------------------- ### Plugin Implementation for QuicAsyncPlugin Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/async_plugin/struct.QuicAsyncPlugin.html?search= Implements the Plugin trait for QuicAsyncPlugin, defining methods for configuring the Bevy App, checking readiness, finishing setup, cleanup, and naming the plugin. ```rust fn build(&self, app: &mut App) fn ready(&self, _app: &App) -> bool fn finish(&self, _app: &mut App) fn cleanup(&self, _app: &mut App) fn name(&self) -> &str fn is_unique(&self) -> bool ``` -------------------------------- ### StreamId Methods Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/id.rs.html Provides methods for creating and accessing information about a StreamId. Includes functions to create a new StreamId, get the parent connection ID, get the owning connection ID, and get the stream's specific ID. ```rust impl StreamId { /// Creates a new StreamId with the relevant parent connection /// and the ID for this connection. pub fn new(connection_id: ConnectionId, id: u64) -> Self { Self { connection_id, id } } /// Gets the ID for the [QuicServer][crate::server::QuicServer] or /// [QuicClient][crate::client::QuicClient] that is the parent /// for this stream. pub fn parent_id(&self) -> QuicParentId { self.connection_id.parent_id() } /// Gets the ID for the relevant [QuicConnection][crate::common::connection::QuicConnection] /// that owns this stream. pub fn connection_id(&self) -> ConnectionId { self.connection_id } /// Get the ID for this specific stream, the ID is relative to its parent /// [QuicConnection][crate::common::connection::QuicConnection]. pub fn id(&self) -> u64 { self.id } } ``` -------------------------------- ### fn from_sample_(s: S) -> S Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/struct.QuicBidirectionalStreamAttempt.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new instance from a sample. ```APIDOC ## fn from_sample_(s: S) -> S ### Description Creates a new instance from a sample. ### Parameters * `s`: S - The sample value. ``` -------------------------------- ### OrchestratorWorker Start Method Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/orchestrator/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Starts the worker loop, which continuously polls assigned QuicTasks. It fetches new tasks when idle and processes existing ones, removing completed tasks. The worker exits when the dispatcher drops all senders. ```rust #[tracing::instrument(skip_all, name = "orchestrator_worker", fields(task_count = self.tasks.len()))] async fn start(mut self) { loop { if self.tasks.is_empty() { // No active tasks let count = self .task_rec .recv_many(&mut self.tasks, MAX_TASKS_PER_BATCH) .await; if count == 0 { // Dispatcher dropped all senders; this worker is done. break; } } else { while let Ok(task) = self.task_rec.try_recv() { self.tasks.push(task); } } let mut finished = Vec::new(); for (i, task) in self.tasks.iter_mut().enumerate() { let done = match task { QuicTask::Connection(t) => { matches!(t.poll_once().now_or_never(), Some(Some(_))) } QuicTask::Send(t) => { matches!(t.poll_once().now_or_never(), Some(Some(_))) } QuicTask::Receive(t) => { matches!(t.poll_once().now_or_never(), Some(Some(_))) } }; if done { finished.push(i); } } for idx in finished.into_iter().rev() { let removed = self.tasks.swap_remove(idx); info!("Removed quic task: {removed}"); } tokio::task::yield_now().await; } } ``` -------------------------------- ### Create from sample Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/async_plugin/struct.QuicAsyncPlugin.html?search= Creates a new instance from a sample. The implementation determines the conversion logic. ```rust fn from_sample_(s: S) -> S ``` -------------------------------- ### OrchestratorWorker Start Method Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/orchestrator/mod.rs.html Starts the worker loop, which continuously polls assigned QuicTasks. It handles receiving new tasks, processing existing ones, and removing completed tasks. The worker blocks when idle to conserve CPU. ```rust #[tracing::instrument(skip_all, name = "orchestrator_worker", fields(task_count = self.tasks.len()))] async fn start(mut self) { loop { if self.tasks.is_empty() { // No active tasks let count = self .task_rec .recv_many(&mut self.tasks, MAX_TASKS_PER_BATCH) .await; if count == 0 { // Dispatcher dropped all senders; this worker is done. break; } } else { while let Ok(task) = self.task_rec.try_recv() { self.tasks.push(task); } } let mut finished = Vec::new(); for (i, task) in self.tasks.iter_mut().enumerate() { let done = match task { QuicTask::Connection(t) => { matches!(t.poll_once().now_or_never(), Some(Some(_))) } QuicTask::Send(t) => { matches!(t.poll_once().now_or_never(), Some(Some(_))) } QuicTask::Receive(t) => { matches!(t.poll_once().now_or_never(), Some(Some(_))) } }; if done { finished.push(i); } } for idx in finished.into_iter().rev() { let removed = self.tasks.swap_remove(idx); info!("Removed quic task: {removed}"); } tokio::task::yield_now().await; } } ``` -------------------------------- ### Create and Bind QuicServer Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/server/mod.rs.html?search=u32+-%3E+bool Initializes a new QuicServer instance, binding it to a specified IP address with provided TLS certificates and private key. Requires a Tokio runtime handle. ```rust pub fn bind( runtime: &TokioRuntime, bind_ip: SocketAddr, certificate: C, private_key: PK, ) -> Result> { let handle = runtime.handle().clone(); let server = handle.block_on(build_server(bind_ip, certificate, private_key))?; let orchestrator = runtime.orchestrator().clone(); Ok(Self { runtime: handle, server, id: QuicParentId::generate_unique(QuicParentType::Server), orchestrator, }) } ``` -------------------------------- ### id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=u32+-%3E+bool Gets the ID information for both the parent and this connection. ```APIDOC ## id ### Description Gets the ID information for both the parent and this connection. ### Method `pub fn id(&self) -> ConnectionId` ### Parameters None ### Response #### Success Response (ConnectionId) - Returns the `ConnectionId` which includes parent and connection specific information. ### Response Example ```json { "example": "ConnectionId { parent: 123, id: 456 }" } ``` ``` -------------------------------- ### from_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/client/acceptor/struct.SimpleClientAcceptorPlugin.html?search=std%3A%3Avec A sample conversion function. ```APIDOC ## fn from_sample_(s: S) -> S ### Description A sample conversion function. ### Method `S::from_sample_(s: S)` ``` -------------------------------- ### id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/send.rs.html?search=u32+-%3E+bool Gets the full ID information for this specific stream. ```APIDOC ## id ### Description Gets the full ID information for this specific stream. ### Method `pub fn id(&self) -> StreamId` ### Parameters None ### Response - `StreamId`: The unique identifier for this stream. ### Example ```rust // Assuming 'stream' is an immutable reference to a SendStream object let stream_id = stream.id(); println!("Stream ID: {:?}", stream_id); ``` ``` -------------------------------- ### from_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/struct.QuicConnectionAttempt.html?search=std%3A%3Avec Creates a sample from a given value. ```APIDOC #### fn from_sample_(s: S) -> S Creates a sample from a given value. ``` -------------------------------- ### FromSample::from_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/session/struct.QuicAeronetPacketPlugin.html?search= Creates a new instance from a sample. ```APIDOC ## FromSample::from_sample_ ### Description Creates a new instance from a sample. ### Signature `fn from_sample_(s: S) -> S` ``` -------------------------------- ### id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Gets the ID information for both the parent and this specific connection. ```APIDOC ## id ### Description Gets the ID information for both the parent and this specific connection. ### Method `pub fn id(&self) -> ConnectionId` ### Parameters None ### Response #### Success Response (200) - **ConnectionId** - The combined ID of the parent and the connection. ### Response Example ```json { "example": { "parent_id": "client_123", "connection_id": "conn_abc" } } ``` ``` -------------------------------- ### New Connection Handle Task Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/task.rs.html?search= Creates a new `ConnectionHandleTask` instance. It initializes the task with the provided QUIC connection handle, orchestrator, open flag, and connection ID. ```rust pub(super) fn new( connection: ConnectionHandle, orchestrator: OrchestratorHandle, is_open: OpenFlag, connection_id: ConnectionId, ) -> Self { let remote_addr = connection.remote_addr(); Self { connection, is_open, remote_addr, connection_id, orchestrator, } } ``` -------------------------------- ### id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search= Gets the ID information for both the parent and this specific connection. ```APIDOC ## id ### Description Gets the ID information for both the parent and this specific connection. ### Method `pub fn id(&self) -> ConnectionId` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ConnectionId**: The combined ID information for the parent and the connection. #### Response Example None ``` -------------------------------- ### Sample Conversion Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/client/marker/struct.QuicClientMarker.html?search= Details the `FromSample` and `ToSample` trait implementations for converting between sample types. ```APIDOC ### `impl FromSample for S` #### `from_sample_` Method - **Signature**: `fn from_sample_(s: S) -> S` - **Description**: Creates a sample of type `S` from another sample of type `S`. This is a direct conversion. ### `impl ToSample for T where U: FromSample` #### `to_sample_` Method - **Signature**: `fn to_sample_(self) -> U` - **Description**: Converts `self` (of type `T`) into a sample of type `U`, provided that `U` implements `FromSample`. ``` -------------------------------- ### QuicSendStream::id Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/send/struct.QuicSendStream.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Gets the full ID information for this stream. ```APIDOC ## QuicSendStream::id ### Description Gets the the full ID information for this stream. ### Method `id` ### Returns - `StreamId` - The full ID of the stream. ``` -------------------------------- ### Get SendTask Stream ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/send.rs.html?search= Returns the `StreamId` associated with this `SendTask`. ```Rust pub(crate) fn id(&self) -> StreamId { self.stream_id } ``` -------------------------------- ### StreamId::parent_id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/id.rs.html?search= Gets the ID for the QuicServer or QuicClient that is the parent for this stream. ```APIDOC ## StreamId::parent_id ### Description Gets the ID for the [QuicServer][crate::server::QuicServer] or [QuicClient][crate::client::QuicClient] that is the parent for this stream. ### Signature ```rust pub fn parent_id(&self) -> QuicParentId ``` ### Returns - **QuicParentId** - The parent ID of the stream. ``` -------------------------------- ### Sample Conversion with ToSample and FromSample Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/session/struct.QuicSession.html These implementations provide mechanisms for converting between different sample types. `ToSample` allows converting the current type to type `U`, while `FromSample` allows creating an instance from type `T`. ```APIDOC ## impl ToSample for T ### Description Allows converting the current type to type `U`. ### Method `to_sample_()` ### Parameters - `self`: The instance to convert. ### Returns - `U`: The converted sample of type `U`. ``` ```APIDOC ## impl FromSample for U ### Description Allows creating an instance of type `U` from a sample of type `T`. ### Method `from_sample(sample: T)` ### Parameters - `sample`: The sample of type `T` to create the new instance from. ### Returns - `U`: The newly created instance of type `U`. ``` -------------------------------- ### parent_id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=u32+-%3E+bool Gets the ID information for the parent client or server for this connection. ```APIDOC ## parent_id ### Description Gets the ID information for the parent client or server for this connection. ### Method `pub fn parent_id(&self) -> QuicParentId` ### Parameters None ### Response #### Success Response (QuicParentId) - Returns the `QuicParentId` associated with this connection. ### Response Example ```json { "example": "QuicParentId { id: 123 }" } ``` ``` -------------------------------- ### SimpleClientAcceptorPlugin Implementation Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/client/acceptor.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This plugin adds a system to the Bevy app to handle the acceptance of new QUIC streams. It should be added to your Bevy app's plugins. ```rust use bevy::{ app::{Plugin, Update}, ecs::{ entity::Entity, query::With, system::{Commands, Query}, }, log::{error, tracing}, }; use crate::{client::marker::QuicClientMarker, common::connection::QuicConnection}; /// This plugin makes all clients accept all incoming streams and spawns them /// as components parented to their [QuicConnection]s in the ECS world. #[derive(Debug)] pub struct SimpleClientAcceptorPlugin; // TODO: probably switch this to a single acceptor for both client and server implementations impl Plugin for SimpleClientAcceptorPlugin { fn build(&self, app: &mut bevy::app::App) { app.add_systems(Update, accept_streams); } } fn accept_streams( mut commands: Commands, connection_query: Query<(Entity, &mut QuicConnection), With>, ) { for (connection_entity, mut connection) in connection_query { handle_stream_accept(&mut commands, connection_entity, &mut connection); } } #[tracing::instrument(name = "accept_client_stream", skip_all, fields(parent_id = %connection.parent_id()))] fn handle_stream_accept( commands: &mut Commands, connection_entity: Entity, connection: &mut QuicConnection, ) { match connection.accept_stream() { Ok(Some(peer_attempt)) => { commands.entity(connection_entity).with_children(|parent| { parent.spawn((peer_attempt, QuicClientMarker)); }); } Err(err) => { error!("Error accepting stream from connection: {}", err); } _ => {} } } ``` -------------------------------- ### Get Connection ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/task.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns the unique identifier for the current connection. ```rust pub(crate) fn id(&self) -> ConnectionId { self.connection_id } ``` -------------------------------- ### Build Default QUIC Client Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/client/mod.rs.html?search= Asynchronously builds a default QUIC client instance. It configures the client to listen on all available interfaces on port 0, allowing the OS to assign a port. ```rust async fn build() -> Client { Client::builder() .with_io("0.0.0.0:0") .expect("Unable to build client... are we... out of sockets??") .start() .expect("Unable to start client") } ``` -------------------------------- ### Get Connection ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/task.rs.html?search= Retrieves the unique identifier for the current connection. ```rust pub(crate) fn id(&self) -> ConnectionId { self.connection_id } ``` -------------------------------- ### QuicConnection::id Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/struct.QuicConnection.html Gets the ID information for both the parent and this specific connection. ```APIDOC ## QuicConnection::id ### Description Gets the ID information for both the parent and this connection. ### Method `&self` ### Returns `ConnectionId` ``` -------------------------------- ### from_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/session/struct.QuicAeronetPacketPlugin.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E A generic implementation of `FromSample` for `S`, returning the sample unchanged. ```APIDOC ## fn from_sample_(s: S) -> S ### Description Source evidence indicates this method returns the sample unchanged. ### Method `S::from_sample_(s: S)` ``` -------------------------------- ### Accepting Incoming QUIC Connections Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/server/acceptor.rs.html This system iterates through active `QuicServer` components, attempts to accept new connections, and spawns them as ECS entities with `QuicConnection` and `QuicServerMarker` components. Errors during connection acceptance are logged. ```rust fn accept_connections(mut commands: Commands, servers: Query<(&mut QuicServer, Entity)>) { for (mut server, entity) in servers { let res = server.accept_connection(); if let Err(e) = res { error!("Error handling server connection: {}", e); continue; } let conn = res.unwrap(); match conn { super::ConnectionPoll::None => continue, super::ConnectionPoll::ServerClosed => continue, super::ConnectionPoll::NewConnection(quic_connection) => { let bundle = (quic_connection, QuicServerMarker, ChildOf(entity)); commands.spawn(bundle); } } } } ``` -------------------------------- ### parent_id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/send.rs.html?search=u32+-%3E+bool Gets the ID information for the parent client or server associated with this stream. ```APIDOC ## parent_id ### Description Gets the ID information for the parent client or server associated with this stream. ### Method `pub fn parent_id(&self) -> QuicParentId` ### Parameters None ### Response - `QuicParentId`: The identifier for the parent connection (client or server). ### Example ```rust // Assuming 'stream' is an immutable reference to a SendStream object let parent_id = stream.parent_id(); println!("Parent ID: {:?}", parent_id); ``` ``` -------------------------------- ### parent_id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Gets the ID information for the parent client or server associated with this connection. ```APIDOC ## parent_id ### Description Gets the ID information for the parent client or server associated with this connection. ### Method `pub fn parent_id(&self) -> QuicParentId` ### Parameters None ### Response #### Success Response (200) - **QuicParentId** - The parent ID of the connection. ### Response Example ```json { "example": "client_123" } ``` ``` -------------------------------- ### QuicParentId Constructor and Getters Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/mod.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods to create QuicParentId instances, including generating a unique ID, and retrieving the parent ID and connection type. ```rust impl QuicParentId { pub fn new(parent_id: u64, parent_type: QuicParentType) -> Self { Self { parent_type, parent_id, } } pub fn generate_unique(parent_type: QuicParentType) -> Self { Self { parent_type, parent_id: IdGenerator::generate_unique(), } } /// Gets the unique ID for the parent structure. This is unique across all /// [QuicClient][crate::client::QuicClient] and [QuicServer][crate::server::QuicServer] /// instances. pub fn parent_id(&self) -> u64 { self.parent_id } /// Gets the type of connection created this network resource. pub fn connection_type(&self) -> QuicParentType { self.parent_type } } ``` -------------------------------- ### id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html Gets the unique identifier for this QUIC connection, including information about its parent. ```APIDOC ## id ### Description Gets the unique identifier for this QUIC connection, including information about its parent. ### Method `&self` (This is a method on a struct, not an HTTP method) ### Returns * `ConnectionId` - The unique identifier for the connection. ``` -------------------------------- ### SimpleServerAcceptorPlugin Implementation Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/server/acceptor.rs.html This plugin integrates into a Bevy application to automatically handle incoming QUIC connections and streams. It adds systems for accepting connections and streams to the update loop. ```rust use bevy::app::{Plugin, Update}; use bevy::ecs::entity::Entity; use bevy::ecs::hierarchy::ChildOf; use bevy::ecs::query::With; use bevy::ecs::system::{Commands, Query}; use bevy::log::{error, tracing}; use crate::common::connection::QuicConnection; use crate::server::{QuicServer, marker::QuicServerMarker}; /// This plugin makes servers automatically accept all incoming /// connections and streams and spawns them as components parented /// to their [QuicServer]s and [QuicConnection]s in the ECS world. #[derive(Debug)] pub struct SimpleServerAcceptorPlugin; impl Plugin for SimpleServerAcceptorPlugin { fn build(&self, app: &mut bevy::app::App) { app.add_systems(Update, accept_connections) .add_systems(Update, accept_streams); } } ``` -------------------------------- ### QuicClient Methods Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/client/struct.QuicClient.html?search=std%3A%3Avec Provides methods for creating and managing a QUIC client. This includes initializing the client with default or custom TLS settings and opening new connections. ```APIDOC ## QuicClient ### Description The component which represents a client. ### Methods #### `new(tokio_runtime: &TokioRuntime) -> Self` Construct a client with default TLS settings. This will not allow you to connect to servers with self-signed certs. #### `new_with_tls(tokio_runtime: &TokioRuntime, certificate: C) -> Result` Construct a client with custom TLS settings. This is commonly used for development purposes to allow custom certs. #### `id(&self) -> QuicParentId` The unique ID for this QUIC session. #### `open_connection(&mut self, connect: Connect) -> (QuicConnectionAttempt, QuicClientMarker)` Opens a new connection to the given `connect` target. Returns an attempt and an ID assigned to the connection. ``` -------------------------------- ### parent_id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search= Gets the ID information for the parent client or server associated with this connection. ```APIDOC ## parent_id ### Description Gets the ID information for the parent client or server associated with this connection. ### Method `pub fn parent_id(&self) -> QuicParentId` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **QuicParentId**: The ID of the parent client or server. #### Response Example None ``` -------------------------------- ### QuicReceiveStream::id Method Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/receive/struct.QuicReceiveStream.html?search=u32+-%3E+bool Gets the full ID information for this specific stream. ```rust pub fn id(&self) -> StreamId ``` -------------------------------- ### to_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/enum.QuicPeerStream.html?search= Converts the QuicPeerStream into a sample type `U`. ```APIDOC ## fn to_sample_(self) -> U ### Description Converts this type into a sample type `U`. ``` -------------------------------- ### Open Quic Connection Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/client/struct.QuicClient.html?search= Opens a new QUIC connection to a specified target. Returns a connection attempt status and a unique client marker. ```rust pub fn open_connection( &mut self, connect: Connect, ) -> (QuicConnectionAttempt, QuicClientMarker) ``` -------------------------------- ### Any Trait Implementation for QuicAsyncPlugin Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/async_plugin/struct.QuicAsyncPlugin.html Provides the `type_id` method, which gets the `TypeId` of the type. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Type Conversion (From/Into) Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/struct.QuicPeerStreamAttempt.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates direct type conversion using `From` and `Into` traits. ```APIDOC ## `impl From for T` ### `fn from(t: T) -> T` Returns the argument unchanged. ## `impl FromSample for S` ### `fn from_sample_(s: S) -> S` ## `impl Into for T` where U: From (No specific method documentation provided in source for `Into` trait itself, but implies conversion is possible if `U: From`) ``` -------------------------------- ### Get Stream ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/send.rs.html?search= Retrieves the full ID information for the current QUIC stream. ```Rust /// Gets the the full ID information for this stream. pub fn id(&self) -> StreamId { self.stream_id } ``` -------------------------------- ### parent_id Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html Gets the identifier for the parent entity (client or server) associated with this QUIC connection. ```APIDOC ## parent_id ### Description Gets the identifier for the parent entity (client or server) associated with this QUIC connection. ### Method `&self` (This is a method on a struct, not an HTTP method) ### Returns * `QuicParentId` - The identifier of the parent client or server. ``` -------------------------------- ### FromSample for S::from_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/attempt/enum.TaskError.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E A method to create an instance of S from a sample S. ```APIDOC ## fn from_sample_(s: S) -> S ### Description A method to create an instance of S from a sample S. ### Method `from_sample_` ``` -------------------------------- ### QuicSendStream::parent_id Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/send/struct.QuicSendStream.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Gets the ID information for the parent client or server associated with this stream. ```APIDOC ## QuicSendStream::parent_id ### Description Gets the ID information for the parent client or server for this stream. ### Method `parent_id` ### Returns - `QuicParentId` - The parent ID of the stream. ``` -------------------------------- ### from_components Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/struct.QuicConnectionAttempt.html?search=std%3A%3Avec Creates a bundle from components using a provided context and a function to extract components. ```APIDOC #### unsafe fn from_components(ctx: &mut T, func: &mut F) -> C where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>, Creates a bundle from components using a provided context and a function to extract components. ``` -------------------------------- ### QuicConnection::parent_id Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/struct.QuicConnection.html Gets the ID information for the parent client or server associated with this connection. ```APIDOC ## QuicConnection::parent_id ### Description Gets the ID information for the parent client or server for this connection. ### Method `&self` ### Returns `QuicParentId` ``` -------------------------------- ### QuicServer::bind Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/server/struct.QuicServer.html?search= Creates a new QuicServer and binds it to the given address with the provided certificate and private key. This function is essential for initializing a QUIC server. ```APIDOC ## QuicServer::bind ### Description Creates a new QuicServer and binds it to the given address with the given certificates. QUIC requires some form of TLS certificate, this function accepts the same kinds of certs the regular s2n-quic `bind()` function does. ### Method `pub fn bind( runtime: &TokioRuntime, bind_ip: SocketAddr, certificate: C, private_key: PK, ) -> Result>` ### Parameters - `runtime`: A reference to the TokioRuntime. - `bind_ip`: The `SocketAddr` to bind the server to. - `certificate`: The TLS certificate. - `private_key`: The private key for the certificate. ### Returns A `Result` containing the new `QuicServer` instance on success, or a `Box` on failure. ``` -------------------------------- ### Build QUIC Client with TLS Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/client/mod.rs.html?search= Asynchronously builds a QUIC client with custom TLS settings. It configures the client to listen on all available interfaces on port 0 and applies the provided TLS certificate. ```rust async fn build_tls(certificate: C) -> Result { let tls = s2n_quic_tls::Client::builder() .with_certificate(certificate)? .build()?; let client = Client::builder() .with_io("0.0.0.0:0") .expect("Unable to build client... are we... out of sockets??") .with_tls(tls) .expect("Invalid TLS") .start() .expect("Unable to start client"); Ok(client) } ``` -------------------------------- ### Get Connection ID Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/struct.QuicConnection.html Retrieves the ID information for both the parent and this specific QUIC connection. ```rust pub fn id(&self) -> ConnectionId ``` -------------------------------- ### Build QUIC Server Configuration Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/server/mod.rs.html?search=u32+-%3E+bool Asynchronously builds the s2n-quic Server instance with TLS configuration and IO binding. This is an internal helper function used by `QuicServer::bind`. ```rust async fn build_server( ip: SocketAddr, certificate: C, private_key: PK, ) -> Result> { let tls = s2n_quic_tls::Server::builder() .with_certificate(certificate, private_key)? .build()?; let server = Server::builder().with_tls(tls)?.with_io(ip)?.start()?; Ok(server) } ``` -------------------------------- ### QuicActionAttempt Methods Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/attempt/struct.QuicActionAttempt.html?search=u32+-%3E+bool Provides methods to create, poll for results, and get the ID of a QuicActionAttempt. ```APIDOC ## QuicActionAttempt Represents an asynchronous task that can be polled for its result. ### Methods #### `new(runtime: Handle, task: impl TaskResult + 'static + Send + Sync, id: I) -> Self` Creates a new `QuicActionAttempt`. - **runtime** (`Handle`): The runtime handle. - **task** (impl `TaskResult + 'static + Send + Sync`): The asynchronous task to be attempted. - **id** (`I`): The identifier for the attempt. #### `attempt_result(&mut self) -> Result` Attempts to retrieve the result of the asynchronous task. Returns `Ok(T)` if the task completed successfully, or `Err(QuicActionError)` if an error occurred. #### `id(&self) -> I` Returns the identifier of the `QuicActionAttempt`. ``` -------------------------------- ### OrchestratorHandle::new Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/orchestrator/handle.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new OrchestratorHandle. This is typically used internally by the orchestrator setup. ```rust pub(crate) fn new(sender: Sender, runtime: Handle) -> Self { Self { sender, runtime } } ``` -------------------------------- ### to_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/send/struct.QuicSendStream.html Converts the QuicSendStream into a sample of type `U`, where `U` implements `FromSample`. ```APIDOC ## fn to_sample_(self) -> U ``` -------------------------------- ### Bundle Creation from Components Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/struct.QuicPeerStreamAttempt.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides functionality to create a bundle from components using a context and a function. ```APIDOC ## `impl BundleFromComponents for C` where C: Component ### `unsafe fn from_components(ctx: &mut T, func: &mut F) -> C` where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a> ``` -------------------------------- ### Get Parent ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/send.rs.html?search= Retrieves the parent ID (client or server) for the current QUIC stream. ```Rust /// Gets the ID information for the parent client or server for this stream pub fn parent_id(&self) -> QuicParentId { self.stream_id.parent_id() } ``` -------------------------------- ### Connection Methods Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=std%3A%3Avec Provides documentation for the public methods of the Connection struct, allowing users to manage and query QUIC connections. ```APIDOC ## Connection Methods This section details the public methods available on the `Connection` struct. ### `close(&self, code: application::Error)` Closes the QUIC connection with a specified error code. - **code** (`application::Error`): The error code to use when closing the connection. ### `is_open(&self) -> bool` Returns `true` if the connection is currently open and active, `false` otherwise. ### `get_disconnect_reason(&mut self) -> Option` Retrieves the reason for the connection's disconnection, if it has been closed. - **Returns**: `Some(ConnectionDisconnectReason)` if the connection is closed, `None` if it is still open. ### `parent_id(&self) -> QuicParentId` Gets the ID information for the parent client or server associated with this connection. ### `id(&self) -> ConnectionId` Gets the ID information for both the parent and the current connection. ``` -------------------------------- ### Get Stream ID for RecTask Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/receive.rs.html?search= Returns the unique identifier for the receive task's stream. ```rust pub(crate) fn id(&self) -> StreamId { self.stream_id } ``` -------------------------------- ### get_disconnect_reason Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=u32+-%3E+bool Gets the disconnect reason if the stream has closed. Returns `None` if the stream is still open. ```APIDOC ## get_disconnect_reason ### Description Gets the disconnect reason if the stream has closed. Returns `None` if the stream is still open. ### Method `pub fn get_disconnect_reason(&mut self) -> Option` ### Parameters None ### Response #### Success Response (Option) - `Some(ConnectionDisconnectReason)` if the stream has closed. - `None` if the stream is still open. ### Response Example ```json { "example": "Some(ConnectionDisconnectReason { code: 0, reason: \"Success\" })" } ``` ``` -------------------------------- ### Borrowing and Mutability Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/struct.QuicPeerStreamAttempt.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to immutably and mutably borrow from a QuicPeerStreamAttempt. ```APIDOC ## `impl Borrow for T` ### `fn borrow(&self) -> &T` Immutably borrows from an owned value. ## `impl BorrowMut for T` ### `fn borrow_mut(&mut self) -> &mut T` Mutably borrows from an owned value. ``` -------------------------------- ### Any Trait Implementation for QuicAeronetPacketPlugin Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/session/struct.QuicAeronetPacketPlugin.html?search= Demonstrates the implementation of the Any trait for QuicAeronetPacketPlugin, enabling type identification and dynamic dispatch. ```rust impl Any for T { #[inline] fn type_id(&self) -> TypeId { TypeId::of::() } } ``` -------------------------------- ### to_string Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/enum.QuicParentType.html Converts the current value into a `String`. This is a standard way to get a string representation of a value. ```APIDOC ## fn to_string(&self) -> String ### Description Converts the given value to a `String`. ### Method `to_string` ``` -------------------------------- ### Get QuicClient ID Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/client/struct.QuicClient.html?search= Retrieves the unique ID for the current QUIC session associated with the QuicClient. ```rust pub fn id(&self) -> QuicParentId ``` -------------------------------- ### Initialize QuicReceiveStream Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/receive.rs.html Creates a new `QuicReceiveStream` instance. It sets up channels for inbound data, control messages, and errors, and spawns a task to handle receiving data from the QUIC stream. ```rust pub fn new( orchestrator: OrchestratorHandle, rec: ReceiveStream, parent_id: ConnectionId, ) -> Self { let stream_id = StreamId::new(parent_id, rec.id()); let addr = rec.connection().remote_addr(); let (receive_error_sender, receive_errors) = mpsc::channel(DEBUG_CHANNEL_SIZE); let (inbound_control, inbound_control_receiver) = mpsc::channel(CONTROL_CHANNEL_SIZE); let (inbound_data_sender, inbound_data) = mpsc::channel(INBOUND_CHANNEL_SIZE); let mut task_state = OnceLockState::new(); let task = RecTask { rec, control: inbound_control_receiver, inbound_sender: inbound_data_sender, receive_errors: receive_error_sender, disconnect_flag: None, task_state: task_state.clone(), addr, stream_id, }; let res = orchestrator.push_receive(task); if let Err(e) = res { error!( "Unable to push new task for stream {}, with reason: {}", stream_id, e ); let _ = task_state.set(ConnectionDisconnectReason::OrchestratorError); match e { mpsc::error::TrySendError::Full(mut task) | mpsc::error::TrySendError::Closed(mut task) => { task.stop_sending(ORCHESTRATOR_ERROR_CODE.into()); } } } Self { task_state, inbound_data, inbound_control, receive_errors, stream_id, _orchestrator: orchestrator, } } ``` -------------------------------- ### to_sample_ Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/struct.QuicConnectionAttempt.html Converts the type into another sample type. ```APIDOC ## fn to_sample_(self) -> U ### Description Converts the type into another sample type. ### Parameters #### Path Parameters - **self**: The instance to convert. ### Returns - `U`: The converted sample type. ``` -------------------------------- ### Get Full Connection ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=std%3A%3Avec Retrieves the combined ID information for both the parent and the current QUIC connection. ```rust /// Gets the ID information for both the parent and this connection pub fn id(&self) -> ConnectionId { self.connection_id } ``` -------------------------------- ### QuicServer Bundle Get Component IDs Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/server/struct.QuicServer.html?search= Retrieves component IDs for the QuicServer bundle from a `Components` registry. ```rust fn get_component_ids( components: &Components, ) -> impl Iterator> ``` -------------------------------- ### Accept New Connections Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/server/struct.QuicServer.html?search= Polls for and accepts any pending incoming QUIC connections to the server. This method is crucial for handling new clients. ```rust pub fn accept_connection(&mut self) -> Result ``` -------------------------------- ### DynamicBundle Component Handling Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/session/struct.QuicSession.html Methods for handling dynamic component bundles, including getting and applying components. ```APIDOC ## type Effect = () An operation on the entity that happens _after_ inserting this bundle. ``` ```APIDOC ## unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> ::Effect Moves the components out of the bundle. Read more ``` ```APIDOC ## unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit>, _entity: &mut EntityWorldMut<'_>, ) Applies the after-effects of spawning this bundle. Read more ``` -------------------------------- ### QuicClient::open_connection Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/client/struct.QuicClient.html?search= Initiates a new QUIC connection to a specified target. It returns an attempt object and a marker for the connection. ```APIDOC ## QuicClient::open_connection ### Description Opens a new connection to the given `connect` target. Returns an attempt and an ID assigned to the connection. ### Signature `pub fn open_connection(&mut self, connect: Connect) -> (QuicConnectionAttempt, QuicClientMarker)` ### Parameters * `connect`: The `Connect` struct specifying the target address and other connection details. ### Returns A tuple containing: * `QuicConnectionAttempt`: An object representing the connection attempt. * `QuicClientMarker`: A marker identifying the newly opened connection. ``` -------------------------------- ### Initialize QuicSendStream Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/send/struct.QuicSendStream.html Creates a new QuicSendStream instance. Requires an OrchestratorHandle, a SendStream, and a ConnectionId. ```rust pub fn new( orchestrator: OrchestratorHandle, send: SendStream, conn_id: ConnectionId, ) -> Self ``` -------------------------------- ### Get Full ID of QUIC Connection Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html Retrieves the combined ID information for both the parent and the current QUIC connection. ```rust pub fn id(&self) -> ConnectionId { self.connection_id } ``` -------------------------------- ### Get Parent Connection ID Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/connection/mod.rs.html?search=std%3A%3Avec Retrieves the ID information for the parent client or server associated with this QUIC connection. ```rust /// Gets the ID information for the parent client or server for this connection pub fn parent_id(&self) -> QuicParentId { self.connection_id.parent_id() } ``` -------------------------------- ### Bind QuicServer Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/server/struct.QuicServer.html Creates and binds a new QuicServer to a specified IP address with TLS certificates. This function is used to initialize the QUIC server. ```rust pub fn bind( runtime: &TokioRuntime, bind_ip: SocketAddr, certificate: C, private_key: PK, ) -> Result> ``` -------------------------------- ### Rust Bundle Trait for Components Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/stream/receive/struct.QuicReceiveStream.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines how a component can be used as a bundle, providing methods to get component IDs. ```rust impl Bundle for C where C: Component, { fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator> fn get_component_ids( components: &Components, ) -> impl Iterator> } ``` -------------------------------- ### Conversion and Sample Handling Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/common/connection/task/enum.ConnectionCommandError.html?search= Methods for converting between types and handling samples, including conversions to `Result` and custom sample types. ```APIDOC ## `IntoResult` Trait ### Description Converts a type into the system's output `Result` type. ### Method `into_result(self) -> Result` ## `FromSample` and `ToSample` Traits ### Description These traits facilitate conversions related to samples. `FromSample` allows creating a type from a sample, while `ToSample` allows converting a type into a sample. ### Methods - `FromSample::from_sample_(s: S) -> S`: Creates a sample from a given sample. - `ToSample::to_sample_(self) -> U`: Converts the type into a sample. ``` -------------------------------- ### DisconnectHandlerPlugin Setup Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/plugin.rs.html?search= Defines the DisconnectHandlerPlugin and registers systems to handle disconnections for connections, receive streams, and send streams. ```Rust use aeronet_io::connection::DisconnectReason; use bevy:: app::{Plugin, Update}, ecs:: entity::Entity, system::{Commands, Query}, }; use crate::common:: connection::QuicConnection, stream::{receive::QuicReceiveStream, send::QuicSendStream}, }; /// A plugin which handles any connection or stream components which have been disconnected. /// /// Connection disconnects will trigger aeronet's [Disconnected][aeronet_io::connection::Disconnected] /// event. /// /// Streams will be disconnected without an event firing pub struct DisconnectHandlerPlugin; impl Plugin for DisconnectHandlerPlugin { fn build(&self, app: &mut bevy::app::App) { app.add_systems( Update, ( handle_connection_disconnections, handle_rec_stream_disconnections, handle_send_stream_disconnections, ), ); } } ``` -------------------------------- ### QuicServer as Bevy Component Source: https://docs.rs/bevy-s2n-quic/latest/bevy_s2n_quic/server/struct.QuicServer.html?search=u32+-%3E+bool Demonstrates QuicServer's implementation as a Bevy ECS component, including its storage type and mutability. ```rust const STORAGE_TYPE: StorageType = ::bevy::ecs::component::StorageType::Table ``` ```rust type Mutability = Mutable ``` -------------------------------- ### Get disconnect reason Source: https://docs.rs/bevy-s2n-quic/latest/src/bevy_s2n_quic/common/stream/receive.rs.html Retrieves the reason for the stream's disconnection if it has closed. Returns `None` if the stream is still open. ```rust pub fn get_disconnect_reason(&mut self) -> Option { self.task_state.get_disconnect_reason() } ```