use {
aeronet_transport::{
lane::{LaneIndex, LaneKind},
size::MinSize,
},
bevy_replicon::prelude::*,
};
#[must_use]
pub const fn to_lane_kind(channel: Channel) -> LaneKind {
match channel {
Channel::Unreliable => LaneKind::UnreliableUnordered,
Channel::Unordered => LaneKind::ReliableUnordered,
Channel::Ordered => LaneKind::ReliableOrdered,
}
}
#[must_use]
pub fn to_channel_id(lane_index: LaneIndex) -> usize {
usize::from(lane_index.0)
}
#[must_use]
pub fn to_lane_index(channel_id: usize) -> Option<LaneIndex> {
MinSize::try_from(channel_id).map(LaneIndex).ok()
}