use explicit::UnreachableExt as _;
use netstack3_base::socket::MaybeDualStack;
use netstack3_base::{Uninstantiable, UninstantiableWrapper};
use crate::internal::datagram::{
BoundSockets, DatagramBoundStateContext, DatagramIpSpecificSocketOptions,
DatagramSocketMapSpec, DatagramSocketSpec, DualStackConverter, IpExt, IpOptions,
NonDualStackConverter,
};
use crate::internal::spec_context::{
DatagramSpecBoundStateContext, DualStackDatagramSpecBoundStateContext,
NonDualStackDatagramSpecBoundStateContext,
};
impl<I: IpExt, S: DatagramSocketSpec, P: DatagramBoundStateContext<I, C, S>, C>
DatagramSpecBoundStateContext<I, UninstantiableWrapper<P>, C> for S
{
type IpSocketsCtx<'a> = P::IpSocketsCtx<'a>;
type DualStackContext = P::DualStackContext;
type NonDualStackContext = P::NonDualStackContext;
fn dual_stack_context(
core_ctx: &mut UninstantiableWrapper<P>,
) -> MaybeDualStack<&mut Self::DualStackContext, &mut Self::NonDualStackContext> {
core_ctx.uninstantiable_unreachable()
}
fn with_bound_sockets<
O,
F: FnOnce(
&mut Self::IpSocketsCtx<'_>,
&BoundSockets<
I,
P::WeakDeviceId,
<S as DatagramSocketSpec>::AddrSpec,
<S as DatagramSocketSpec>::SocketMapSpec<I, P::WeakDeviceId>,
>,
) -> O,
>(
core_ctx: &mut UninstantiableWrapper<P>,
_cb: F,
) -> O {
core_ctx.uninstantiable_unreachable()
}
fn with_bound_sockets_mut<
O,
F: FnOnce(
&mut Self::IpSocketsCtx<'_>,
&mut BoundSockets<
I,
P::WeakDeviceId,
<S as DatagramSocketSpec>::AddrSpec,
<S as DatagramSocketSpec>::SocketMapSpec<I, P::WeakDeviceId>,
>,
) -> O,
>(
core_ctx: &mut UninstantiableWrapper<P>,
_cb: F,
) -> O {
core_ctx.uninstantiable_unreachable()
}
fn with_transport_context<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>) -> O>(
core_ctx: &mut UninstantiableWrapper<P>,
_cb: F,
) -> O {
core_ctx.uninstantiable_unreachable()
}
}
impl<I: IpExt, S: DatagramSocketSpec, P: DatagramBoundStateContext<I, C, S>, C>
NonDualStackDatagramSpecBoundStateContext<I, UninstantiableWrapper<P>, C> for S
{
fn nds_converter(
core_ctx: &UninstantiableWrapper<P>,
) -> impl NonDualStackConverter<I, P::WeakDeviceId, Self> {
core_ctx.uninstantiable_unreachable::<Uninstantiable>()
}
}
impl<I: IpExt, S: DatagramSocketSpec, P: DatagramBoundStateContext<I, C, S>, C>
DualStackDatagramSpecBoundStateContext<I, UninstantiableWrapper<P>, C> for S
{
type IpSocketsCtx<'a> = UninstantiableWrapper<P::IpSocketsCtx<'a>>;
fn dual_stack_enabled(
core_ctx: &UninstantiableWrapper<P>,
_state: &impl AsRef<IpOptions<I, P::WeakDeviceId, S>>,
) -> bool {
core_ctx.uninstantiable_unreachable()
}
fn to_other_socket_options<'a>(
core_ctx: &UninstantiableWrapper<P>,
_state: &'a IpOptions<I, P::WeakDeviceId, S>,
) -> &'a DatagramIpSpecificSocketOptions<I::OtherVersion, P::WeakDeviceId> {
core_ctx.uninstantiable_unreachable()
}
fn ds_converter(
core_ctx: &UninstantiableWrapper<P>,
) -> impl DualStackConverter<I, P::WeakDeviceId, S> {
core_ctx.uninstantiable_unreachable::<Uninstantiable>()
}
fn to_other_bound_socket_id(
core_ctx: &UninstantiableWrapper<P>,
_id: &S::SocketId<I, P::WeakDeviceId>,
) -> <S::SocketMapSpec<I::OtherVersion, P::WeakDeviceId> as DatagramSocketMapSpec<
I::OtherVersion,
P::WeakDeviceId,
S::AddrSpec,
>>::BoundSocketId {
core_ctx.uninstantiable_unreachable()
}
fn with_both_bound_sockets_mut<
O,
F: FnOnce(
&mut Self::IpSocketsCtx<'_>,
&mut BoundSockets<I, P::WeakDeviceId, S::AddrSpec, S::SocketMapSpec<I, P::WeakDeviceId>>,
&mut BoundSockets<
I::OtherVersion,
P::WeakDeviceId,
S::AddrSpec,
S::SocketMapSpec<I::OtherVersion, P::WeakDeviceId>,
>,
) -> O,
>(
core_ctx: &mut UninstantiableWrapper<P>,
_cb: F,
) -> O {
core_ctx.uninstantiable_unreachable()
}
fn with_other_bound_sockets_mut<
O,
F: FnOnce(
&mut Self::IpSocketsCtx<'_>,
&mut BoundSockets<
I::OtherVersion,
P::WeakDeviceId,
S::AddrSpec,
S::SocketMapSpec<<I>::OtherVersion, P::WeakDeviceId>,
>,
) -> O,
>(
core_ctx: &mut UninstantiableWrapper<P>,
_cb: F,
) -> O {
core_ctx.uninstantiable_unreachable()
}
fn with_transport_context<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>) -> O>(
core_ctx: &mut UninstantiableWrapper<P>,
_cb: F,
) -> O {
core_ctx.uninstantiable_unreachable()
}
}