aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgilles henaux <gill.henaux@gmail.com>2023-01-14 14:52:06 +0100
committergilles henaux <gill.henaux@gmail.com>2023-01-14 14:52:06 +0100
commit2cd1b6cd51b0db89050e4b9adf7bec1119b2cd09 (patch)
treee4c22ee6455a80867059caace0b06a1ed9c7ef17 /src
parente9507fbca7b3f87429e39094ef68fc4995c3aeab (diff)
[channels] Add a utility get_channel_id_from_type
Diffstat (limited to 'src')
-rw-r--r--src/shared/channel.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/shared/channel.rs b/src/shared/channel.rs
index 759e1b8..211f5a5 100644
--- a/src/shared/channel.rs
+++ b/src/shared/channel.rs
@@ -81,6 +81,20 @@ impl Channel {
}
}
+pub(crate) fn get_channel_id_from_type<F>(
+ channel_type: ChannelType,
+ mut multi_id_generator: F,
+) -> ChannelId
+where
+ F: FnMut() -> MultiChannelId,
+{
+ match channel_type {
+ ChannelType::OrderedReliable => ChannelId::OrderedReliable(multi_id_generator()),
+ ChannelType::UnorderedReliable => ChannelId::UnorderedReliable,
+ ChannelType::Unreliable => ChannelId::Unreliable,
+ }
+}
+
pub(crate) async fn ordered_reliable_channel_task(
connection: quinn::Connection,
_: mpsc::Sender<()>,