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