use {
crate::nonblocking::quic::{ClientConnectionTracker, ConnectionPeerType},
quinn::Connection,
std::future::Future,
tokio_util::sync::CancellationToken,
};
pub(crate) trait ConnectionContext: Clone + Send + Sync {
fn peer_type(&self) -> ConnectionPeerType;
fn remote_pubkey(&self) -> Option<solana_pubkey::Pubkey>;
}
pub(crate) trait QosController<C: ConnectionContext> {
fn build_connection_context(&self, connection: &Connection) -> C;
fn try_add_connection(
&self,
client_connection_tracker: ClientConnectionTracker,
connection: &quinn::Connection,
context: &mut C,
) -> impl Future<Output = Option<CancellationToken>> + Send;
fn on_new_stream(&self, context: &C) -> impl Future<Output = ()> + Send;
fn on_stream_accepted(&self, context: &C);
fn on_stream_finished(&self, context: &C);
fn on_stream_error(&self, context: &C);
fn on_stream_closed(&self, context: &C);
fn remove_connection(
&self,
context: &C,
connection: Connection,
) -> impl Future<Output = usize> + Send;
}