1use explicit::UnreachableExt as _;
6use netstack3_base::socket::MaybeDualStack;
7use netstack3_base::{Uninstantiable, UninstantiableWrapper};
8
9use crate::internal::datagram::{
10 BoundSockets, DatagramBindingsTypes, DatagramBoundStateContext,
11 DatagramIpSpecificSocketOptions, DatagramSocketMapSpec, DatagramSocketSpec, DualStackConverter,
12 IpExt, IpOptions, NonDualStackConverter,
13};
14use crate::internal::spec_context::{
15 DatagramSpecBoundStateContext, DualStackDatagramSpecBoundStateContext,
16 NonDualStackDatagramSpecBoundStateContext,
17};
18
19impl<
20 I: IpExt,
21 S: DatagramSocketSpec,
22 P: DatagramBoundStateContext<I, BC, S>,
23 BC: DatagramBindingsTypes,
24> DatagramSpecBoundStateContext<I, UninstantiableWrapper<P>, BC> for S
25{
26 type IpSocketsCtx<'a> = P::IpSocketsCtx<'a>;
27 type DualStackContext = P::DualStackContext;
28 type NonDualStackContext = P::NonDualStackContext;
29 fn dual_stack_context(
30 core_ctx: &UninstantiableWrapper<P>,
31 ) -> MaybeDualStack<&Self::DualStackContext, &Self::NonDualStackContext> {
32 core_ctx.uninstantiable_unreachable()
33 }
34 fn dual_stack_context_mut(
35 core_ctx: &mut UninstantiableWrapper<P>,
36 ) -> MaybeDualStack<&mut Self::DualStackContext, &mut Self::NonDualStackContext> {
37 core_ctx.uninstantiable_unreachable()
38 }
39 fn with_bound_sockets<
40 O,
41 F: FnOnce(
42 &mut Self::IpSocketsCtx<'_>,
43 &BoundSockets<
44 I,
45 P::WeakDeviceId,
46 <S as DatagramSocketSpec>::AddrSpec,
47 <S as DatagramSocketSpec>::SocketMapSpec<I, P::WeakDeviceId>,
48 >,
49 ) -> O,
50 >(
51 core_ctx: &mut UninstantiableWrapper<P>,
52 _cb: F,
53 ) -> O {
54 core_ctx.uninstantiable_unreachable()
55 }
56 fn with_bound_sockets_mut<
57 O,
58 F: FnOnce(
59 &mut Self::IpSocketsCtx<'_>,
60 &mut BoundSockets<
61 I,
62 P::WeakDeviceId,
63 <S as DatagramSocketSpec>::AddrSpec,
64 <S as DatagramSocketSpec>::SocketMapSpec<I, P::WeakDeviceId>,
65 >,
66 ) -> O,
67 >(
68 core_ctx: &mut UninstantiableWrapper<P>,
69 _cb: F,
70 ) -> O {
71 core_ctx.uninstantiable_unreachable()
72 }
73 fn with_transport_context<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>) -> O>(
74 core_ctx: &mut UninstantiableWrapper<P>,
75 _cb: F,
76 ) -> O {
77 core_ctx.uninstantiable_unreachable()
78 }
79}
80
81impl<
82 I: IpExt,
83 S: DatagramSocketSpec,
84 P: DatagramBoundStateContext<I, BC, S>,
85 BC: DatagramBindingsTypes,
86> NonDualStackDatagramSpecBoundStateContext<I, UninstantiableWrapper<P>, BC> for S
87{
88 fn nds_converter(
89 core_ctx: &UninstantiableWrapper<P>,
90 ) -> impl NonDualStackConverter<I, P::WeakDeviceId, Self> {
91 core_ctx.uninstantiable_unreachable::<Uninstantiable>()
92 }
93}
94
95impl<
96 I: IpExt,
97 S: DatagramSocketSpec,
98 P: DatagramBoundStateContext<I, BC, S>,
99 BC: DatagramBindingsTypes,
100> DualStackDatagramSpecBoundStateContext<I, UninstantiableWrapper<P>, BC> for S
101{
102 type IpSocketsCtx<'a> = UninstantiableWrapper<P::IpSocketsCtx<'a>>;
103
104 fn dual_stack_enabled(
105 core_ctx: &UninstantiableWrapper<P>,
106 _state: &impl AsRef<IpOptions<I, P::WeakDeviceId, S>>,
107 ) -> bool {
108 core_ctx.uninstantiable_unreachable()
109 }
110
111 fn to_other_socket_options<'a>(
112 core_ctx: &UninstantiableWrapper<P>,
113 _state: &'a IpOptions<I, P::WeakDeviceId, S>,
114 ) -> &'a DatagramIpSpecificSocketOptions<I::OtherVersion, P::WeakDeviceId> {
115 core_ctx.uninstantiable_unreachable()
116 }
117
118 fn ds_converter(
119 core_ctx: &UninstantiableWrapper<P>,
120 ) -> impl DualStackConverter<I, P::WeakDeviceId, S> {
121 core_ctx.uninstantiable_unreachable::<Uninstantiable>()
122 }
123
124 fn to_other_bound_socket_id(
125 core_ctx: &UninstantiableWrapper<P>,
126 _id: &S::SocketId<I, P::WeakDeviceId>,
127 ) -> <S::SocketMapSpec<I::OtherVersion, P::WeakDeviceId> as DatagramSocketMapSpec<
128 I::OtherVersion,
129 P::WeakDeviceId,
130 S::AddrSpec,
131 >>::BoundSocketId {
132 core_ctx.uninstantiable_unreachable()
133 }
134
135 fn with_both_bound_sockets_mut<
136 O,
137 F: FnOnce(
138 &mut Self::IpSocketsCtx<'_>,
139 &mut BoundSockets<I, P::WeakDeviceId, S::AddrSpec, S::SocketMapSpec<I, P::WeakDeviceId>>,
140 &mut BoundSockets<
141 I::OtherVersion,
142 P::WeakDeviceId,
143 S::AddrSpec,
144 S::SocketMapSpec<I::OtherVersion, P::WeakDeviceId>,
145 >,
146 ) -> O,
147 >(
148 core_ctx: &mut UninstantiableWrapper<P>,
149 _cb: F,
150 ) -> O {
151 core_ctx.uninstantiable_unreachable()
152 }
153
154 fn with_other_bound_sockets_mut<
155 O,
156 F: FnOnce(
157 &mut Self::IpSocketsCtx<'_>,
158 &mut BoundSockets<
159 I::OtherVersion,
160 P::WeakDeviceId,
161 S::AddrSpec,
162 S::SocketMapSpec<<I>::OtherVersion, P::WeakDeviceId>,
163 >,
164 ) -> O,
165 >(
166 core_ctx: &mut UninstantiableWrapper<P>,
167 _cb: F,
168 ) -> O {
169 core_ctx.uninstantiable_unreachable()
170 }
171
172 fn with_transport_context<O, F: FnOnce(&mut Self::IpSocketsCtx<'_>) -> O>(
173 core_ctx: &mut UninstantiableWrapper<P>,
174 _cb: F,
175 ) -> O {
176 core_ctx.uninstantiable_unreachable()
177 }
178}