fidl_fuchsia_reloaddriver_test/
fidl_fuchsia_reloaddriver_test.rs1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_reloaddriver_test__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct WaiterMarker;
16
17impl fidl::endpoints::ProtocolMarker for WaiterMarker {
18 type Proxy = WaiterProxy;
19 type RequestStream = WaiterRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = WaiterSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.reloaddriver.test.Waiter";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for WaiterMarker {}
26
27pub trait WaiterProxyInterface: Send + Sync {
28 fn r#ack(&self, from_node: &str, from_name: &str, status: i32) -> Result<(), fidl::Error>;
29}
30#[derive(Debug)]
31#[cfg(target_os = "fuchsia")]
32pub struct WaiterSynchronousProxy {
33 client: fidl::client::sync::Client,
34}
35
36#[cfg(target_os = "fuchsia")]
37impl fidl::endpoints::SynchronousProxy for WaiterSynchronousProxy {
38 type Proxy = WaiterProxy;
39 type Protocol = WaiterMarker;
40
41 fn from_channel(inner: fidl::Channel) -> Self {
42 Self::new(inner)
43 }
44
45 fn into_channel(self) -> fidl::Channel {
46 self.client.into_channel()
47 }
48
49 fn as_channel(&self) -> &fidl::Channel {
50 self.client.as_channel()
51 }
52}
53
54#[cfg(target_os = "fuchsia")]
55impl WaiterSynchronousProxy {
56 pub fn new(channel: fidl::Channel) -> Self {
57 let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
58 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
59 }
60
61 pub fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 pub fn wait_for_event(
68 &self,
69 deadline: zx::MonotonicInstant,
70 ) -> Result<WaiterEvent, fidl::Error> {
71 WaiterEvent::decode(self.client.wait_for_event(deadline)?)
72 }
73
74 pub fn r#ack(
75 &self,
76 mut from_node: &str,
77 mut from_name: &str,
78 mut status: i32,
79 ) -> Result<(), fidl::Error> {
80 self.client.send::<WaiterAckRequest>(
81 (from_node, from_name, status),
82 0x7e80870431180046,
83 fidl::encoding::DynamicFlags::empty(),
84 )
85 }
86}
87
88#[cfg(target_os = "fuchsia")]
89impl From<WaiterSynchronousProxy> for zx::Handle {
90 fn from(value: WaiterSynchronousProxy) -> Self {
91 value.into_channel().into()
92 }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl From<fidl::Channel> for WaiterSynchronousProxy {
97 fn from(value: fidl::Channel) -> Self {
98 Self::new(value)
99 }
100}
101
102#[cfg(target_os = "fuchsia")]
103impl fidl::endpoints::FromClient for WaiterSynchronousProxy {
104 type Protocol = WaiterMarker;
105
106 fn from_client(value: fidl::endpoints::ClientEnd<WaiterMarker>) -> Self {
107 Self::new(value.into_channel())
108 }
109}
110
111#[derive(Debug, Clone)]
112pub struct WaiterProxy {
113 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
114}
115
116impl fidl::endpoints::Proxy for WaiterProxy {
117 type Protocol = WaiterMarker;
118
119 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
120 Self::new(inner)
121 }
122
123 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
124 self.client.into_channel().map_err(|client| Self { client })
125 }
126
127 fn as_channel(&self) -> &::fidl::AsyncChannel {
128 self.client.as_channel()
129 }
130}
131
132impl WaiterProxy {
133 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
135 let protocol_name = <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
136 Self { client: fidl::client::Client::new(channel, protocol_name) }
137 }
138
139 pub fn take_event_stream(&self) -> WaiterEventStream {
145 WaiterEventStream { event_receiver: self.client.take_event_receiver() }
146 }
147
148 pub fn r#ack(
149 &self,
150 mut from_node: &str,
151 mut from_name: &str,
152 mut status: i32,
153 ) -> Result<(), fidl::Error> {
154 WaiterProxyInterface::r#ack(self, from_node, from_name, status)
155 }
156}
157
158impl WaiterProxyInterface for WaiterProxy {
159 fn r#ack(
160 &self,
161 mut from_node: &str,
162 mut from_name: &str,
163 mut status: i32,
164 ) -> Result<(), fidl::Error> {
165 self.client.send::<WaiterAckRequest>(
166 (from_node, from_name, status),
167 0x7e80870431180046,
168 fidl::encoding::DynamicFlags::empty(),
169 )
170 }
171}
172
173pub struct WaiterEventStream {
174 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
175}
176
177impl std::marker::Unpin for WaiterEventStream {}
178
179impl futures::stream::FusedStream for WaiterEventStream {
180 fn is_terminated(&self) -> bool {
181 self.event_receiver.is_terminated()
182 }
183}
184
185impl futures::Stream for WaiterEventStream {
186 type Item = Result<WaiterEvent, fidl::Error>;
187
188 fn poll_next(
189 mut self: std::pin::Pin<&mut Self>,
190 cx: &mut std::task::Context<'_>,
191 ) -> std::task::Poll<Option<Self::Item>> {
192 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
193 &mut self.event_receiver,
194 cx
195 )?) {
196 Some(buf) => std::task::Poll::Ready(Some(WaiterEvent::decode(buf))),
197 None => std::task::Poll::Ready(None),
198 }
199 }
200}
201
202#[derive(Debug)]
203pub enum WaiterEvent {}
204
205impl WaiterEvent {
206 fn decode(
208 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
209 ) -> Result<WaiterEvent, fidl::Error> {
210 let (bytes, _handles) = buf.split_mut();
211 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
212 debug_assert_eq!(tx_header.tx_id, 0);
213 match tx_header.ordinal {
214 _ => Err(fidl::Error::UnknownOrdinal {
215 ordinal: tx_header.ordinal,
216 protocol_name: <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
217 }),
218 }
219 }
220}
221
222pub struct WaiterRequestStream {
224 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
225 is_terminated: bool,
226}
227
228impl std::marker::Unpin for WaiterRequestStream {}
229
230impl futures::stream::FusedStream for WaiterRequestStream {
231 fn is_terminated(&self) -> bool {
232 self.is_terminated
233 }
234}
235
236impl fidl::endpoints::RequestStream for WaiterRequestStream {
237 type Protocol = WaiterMarker;
238 type ControlHandle = WaiterControlHandle;
239
240 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
241 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
242 }
243
244 fn control_handle(&self) -> Self::ControlHandle {
245 WaiterControlHandle { inner: self.inner.clone() }
246 }
247
248 fn into_inner(
249 self,
250 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
251 {
252 (self.inner, self.is_terminated)
253 }
254
255 fn from_inner(
256 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
257 is_terminated: bool,
258 ) -> Self {
259 Self { inner, is_terminated }
260 }
261}
262
263impl futures::Stream for WaiterRequestStream {
264 type Item = Result<WaiterRequest, fidl::Error>;
265
266 fn poll_next(
267 mut self: std::pin::Pin<&mut Self>,
268 cx: &mut std::task::Context<'_>,
269 ) -> std::task::Poll<Option<Self::Item>> {
270 let this = &mut *self;
271 if this.inner.check_shutdown(cx) {
272 this.is_terminated = true;
273 return std::task::Poll::Ready(None);
274 }
275 if this.is_terminated {
276 panic!("polled WaiterRequestStream after completion");
277 }
278 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
279 |bytes, handles| {
280 match this.inner.channel().read_etc(cx, bytes, handles) {
281 std::task::Poll::Ready(Ok(())) => {}
282 std::task::Poll::Pending => return std::task::Poll::Pending,
283 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
284 this.is_terminated = true;
285 return std::task::Poll::Ready(None);
286 }
287 std::task::Poll::Ready(Err(e)) => {
288 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
289 e.into(),
290 ))))
291 }
292 }
293
294 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
296
297 std::task::Poll::Ready(Some(match header.ordinal {
298 0x7e80870431180046 => {
299 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
300 let mut req = fidl::new_empty!(
301 WaiterAckRequest,
302 fidl::encoding::DefaultFuchsiaResourceDialect
303 );
304 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WaiterAckRequest>(&header, _body_bytes, handles, &mut req)?;
305 let control_handle = WaiterControlHandle { inner: this.inner.clone() };
306 Ok(WaiterRequest::Ack {
307 from_node: req.from_node,
308 from_name: req.from_name,
309 status: req.status,
310
311 control_handle,
312 })
313 }
314 _ => Err(fidl::Error::UnknownOrdinal {
315 ordinal: header.ordinal,
316 protocol_name:
317 <WaiterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
318 }),
319 }))
320 },
321 )
322 }
323}
324
325#[derive(Debug)]
326pub enum WaiterRequest {
327 Ack { from_node: String, from_name: String, status: i32, control_handle: WaiterControlHandle },
328}
329
330impl WaiterRequest {
331 #[allow(irrefutable_let_patterns)]
332 pub fn into_ack(self) -> Option<(String, String, i32, WaiterControlHandle)> {
333 if let WaiterRequest::Ack { from_node, from_name, status, control_handle } = self {
334 Some((from_node, from_name, status, control_handle))
335 } else {
336 None
337 }
338 }
339
340 pub fn method_name(&self) -> &'static str {
342 match *self {
343 WaiterRequest::Ack { .. } => "ack",
344 }
345 }
346}
347
348#[derive(Debug, Clone)]
349pub struct WaiterControlHandle {
350 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
351}
352
353impl fidl::endpoints::ControlHandle for WaiterControlHandle {
354 fn shutdown(&self) {
355 self.inner.shutdown()
356 }
357 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
358 self.inner.shutdown_with_epitaph(status)
359 }
360
361 fn is_closed(&self) -> bool {
362 self.inner.channel().is_closed()
363 }
364 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
365 self.inner.channel().on_closed()
366 }
367
368 #[cfg(target_os = "fuchsia")]
369 fn signal_peer(
370 &self,
371 clear_mask: zx::Signals,
372 set_mask: zx::Signals,
373 ) -> Result<(), zx_status::Status> {
374 use fidl::Peered;
375 self.inner.channel().signal_peer(clear_mask, set_mask)
376 }
377}
378
379impl WaiterControlHandle {}
380
381mod internal {
382 use super::*;
383}