fidl_fuchsia_hwinfo_mock/
fidl_fuchsia_hwinfo_mock.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_hwinfo_mock__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct SetterMarker;
16
17impl fidl::endpoints::ProtocolMarker for SetterMarker {
18 type Proxy = SetterProxy;
19 type RequestStream = SetterRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = SetterSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hwinfo.mock.Setter";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for SetterMarker {}
26
27pub trait SetterProxyInterface: Send + Sync {
28 type SetResponsesResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
29 fn r#set_responses(
30 &self,
31 device: &fidl_fuchsia_hwinfo::DeviceInfo,
32 product: &fidl_fuchsia_hwinfo::ProductInfo,
33 board: &fidl_fuchsia_hwinfo::BoardInfo,
34 ) -> Self::SetResponsesResponseFut;
35}
36#[derive(Debug)]
37#[cfg(target_os = "fuchsia")]
38pub struct SetterSynchronousProxy {
39 client: fidl::client::sync::Client,
40}
41
42#[cfg(target_os = "fuchsia")]
43impl fidl::endpoints::SynchronousProxy for SetterSynchronousProxy {
44 type Proxy = SetterProxy;
45 type Protocol = SetterMarker;
46
47 fn from_channel(inner: fidl::Channel) -> Self {
48 Self::new(inner)
49 }
50
51 fn into_channel(self) -> fidl::Channel {
52 self.client.into_channel()
53 }
54
55 fn as_channel(&self) -> &fidl::Channel {
56 self.client.as_channel()
57 }
58}
59
60#[cfg(target_os = "fuchsia")]
61impl SetterSynchronousProxy {
62 pub fn new(channel: fidl::Channel) -> Self {
63 let protocol_name = <SetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
64 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
65 }
66
67 pub fn into_channel(self) -> fidl::Channel {
68 self.client.into_channel()
69 }
70
71 pub fn wait_for_event(
74 &self,
75 deadline: zx::MonotonicInstant,
76 ) -> Result<SetterEvent, fidl::Error> {
77 SetterEvent::decode(self.client.wait_for_event(deadline)?)
78 }
79
80 pub fn r#set_responses(
86 &self,
87 mut device: &fidl_fuchsia_hwinfo::DeviceInfo,
88 mut product: &fidl_fuchsia_hwinfo::ProductInfo,
89 mut board: &fidl_fuchsia_hwinfo::BoardInfo,
90 ___deadline: zx::MonotonicInstant,
91 ) -> Result<(), fidl::Error> {
92 let _response =
93 self.client.send_query::<SetterSetResponsesRequest, fidl::encoding::EmptyPayload>(
94 (device, product, board),
95 0x491d2c44c662f96d,
96 fidl::encoding::DynamicFlags::empty(),
97 ___deadline,
98 )?;
99 Ok(_response)
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<SetterSynchronousProxy> for zx::Handle {
105 fn from(value: SetterSynchronousProxy) -> Self {
106 value.into_channel().into()
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<fidl::Channel> for SetterSynchronousProxy {
112 fn from(value: fidl::Channel) -> Self {
113 Self::new(value)
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl fidl::endpoints::FromClient for SetterSynchronousProxy {
119 type Protocol = SetterMarker;
120
121 fn from_client(value: fidl::endpoints::ClientEnd<SetterMarker>) -> Self {
122 Self::new(value.into_channel())
123 }
124}
125
126#[derive(Debug, Clone)]
127pub struct SetterProxy {
128 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
129}
130
131impl fidl::endpoints::Proxy for SetterProxy {
132 type Protocol = SetterMarker;
133
134 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
135 Self::new(inner)
136 }
137
138 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
139 self.client.into_channel().map_err(|client| Self { client })
140 }
141
142 fn as_channel(&self) -> &::fidl::AsyncChannel {
143 self.client.as_channel()
144 }
145}
146
147impl SetterProxy {
148 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
150 let protocol_name = <SetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
151 Self { client: fidl::client::Client::new(channel, protocol_name) }
152 }
153
154 pub fn take_event_stream(&self) -> SetterEventStream {
160 SetterEventStream { event_receiver: self.client.take_event_receiver() }
161 }
162
163 pub fn r#set_responses(
169 &self,
170 mut device: &fidl_fuchsia_hwinfo::DeviceInfo,
171 mut product: &fidl_fuchsia_hwinfo::ProductInfo,
172 mut board: &fidl_fuchsia_hwinfo::BoardInfo,
173 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
174 SetterProxyInterface::r#set_responses(self, device, product, board)
175 }
176}
177
178impl SetterProxyInterface for SetterProxy {
179 type SetResponsesResponseFut =
180 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
181 fn r#set_responses(
182 &self,
183 mut device: &fidl_fuchsia_hwinfo::DeviceInfo,
184 mut product: &fidl_fuchsia_hwinfo::ProductInfo,
185 mut board: &fidl_fuchsia_hwinfo::BoardInfo,
186 ) -> Self::SetResponsesResponseFut {
187 fn _decode(
188 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
189 ) -> Result<(), fidl::Error> {
190 let _response = fidl::client::decode_transaction_body::<
191 fidl::encoding::EmptyPayload,
192 fidl::encoding::DefaultFuchsiaResourceDialect,
193 0x491d2c44c662f96d,
194 >(_buf?)?;
195 Ok(_response)
196 }
197 self.client.send_query_and_decode::<SetterSetResponsesRequest, ()>(
198 (device, product, board),
199 0x491d2c44c662f96d,
200 fidl::encoding::DynamicFlags::empty(),
201 _decode,
202 )
203 }
204}
205
206pub struct SetterEventStream {
207 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
208}
209
210impl std::marker::Unpin for SetterEventStream {}
211
212impl futures::stream::FusedStream for SetterEventStream {
213 fn is_terminated(&self) -> bool {
214 self.event_receiver.is_terminated()
215 }
216}
217
218impl futures::Stream for SetterEventStream {
219 type Item = Result<SetterEvent, fidl::Error>;
220
221 fn poll_next(
222 mut self: std::pin::Pin<&mut Self>,
223 cx: &mut std::task::Context<'_>,
224 ) -> std::task::Poll<Option<Self::Item>> {
225 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
226 &mut self.event_receiver,
227 cx
228 )?) {
229 Some(buf) => std::task::Poll::Ready(Some(SetterEvent::decode(buf))),
230 None => std::task::Poll::Ready(None),
231 }
232 }
233}
234
235#[derive(Debug)]
236pub enum SetterEvent {}
237
238impl SetterEvent {
239 fn decode(
241 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
242 ) -> Result<SetterEvent, fidl::Error> {
243 let (bytes, _handles) = buf.split_mut();
244 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
245 debug_assert_eq!(tx_header.tx_id, 0);
246 match tx_header.ordinal {
247 _ => Err(fidl::Error::UnknownOrdinal {
248 ordinal: tx_header.ordinal,
249 protocol_name: <SetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
250 }),
251 }
252 }
253}
254
255pub struct SetterRequestStream {
257 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
258 is_terminated: bool,
259}
260
261impl std::marker::Unpin for SetterRequestStream {}
262
263impl futures::stream::FusedStream for SetterRequestStream {
264 fn is_terminated(&self) -> bool {
265 self.is_terminated
266 }
267}
268
269impl fidl::endpoints::RequestStream for SetterRequestStream {
270 type Protocol = SetterMarker;
271 type ControlHandle = SetterControlHandle;
272
273 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
274 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
275 }
276
277 fn control_handle(&self) -> Self::ControlHandle {
278 SetterControlHandle { inner: self.inner.clone() }
279 }
280
281 fn into_inner(
282 self,
283 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
284 {
285 (self.inner, self.is_terminated)
286 }
287
288 fn from_inner(
289 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
290 is_terminated: bool,
291 ) -> Self {
292 Self { inner, is_terminated }
293 }
294}
295
296impl futures::Stream for SetterRequestStream {
297 type Item = Result<SetterRequest, fidl::Error>;
298
299 fn poll_next(
300 mut self: std::pin::Pin<&mut Self>,
301 cx: &mut std::task::Context<'_>,
302 ) -> std::task::Poll<Option<Self::Item>> {
303 let this = &mut *self;
304 if this.inner.check_shutdown(cx) {
305 this.is_terminated = true;
306 return std::task::Poll::Ready(None);
307 }
308 if this.is_terminated {
309 panic!("polled SetterRequestStream after completion");
310 }
311 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
312 |bytes, handles| {
313 match this.inner.channel().read_etc(cx, bytes, handles) {
314 std::task::Poll::Ready(Ok(())) => {}
315 std::task::Poll::Pending => return std::task::Poll::Pending,
316 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
317 this.is_terminated = true;
318 return std::task::Poll::Ready(None);
319 }
320 std::task::Poll::Ready(Err(e)) => {
321 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
322 e.into(),
323 ))))
324 }
325 }
326
327 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
329
330 std::task::Poll::Ready(Some(match header.ordinal {
331 0x491d2c44c662f96d => {
332 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
333 let mut req = fidl::new_empty!(
334 SetterSetResponsesRequest,
335 fidl::encoding::DefaultFuchsiaResourceDialect
336 );
337 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SetterSetResponsesRequest>(&header, _body_bytes, handles, &mut req)?;
338 let control_handle = SetterControlHandle { inner: this.inner.clone() };
339 Ok(SetterRequest::SetResponses {
340 device: req.device,
341 product: req.product,
342 board: req.board,
343
344 responder: SetterSetResponsesResponder {
345 control_handle: std::mem::ManuallyDrop::new(control_handle),
346 tx_id: header.tx_id,
347 },
348 })
349 }
350 _ => Err(fidl::Error::UnknownOrdinal {
351 ordinal: header.ordinal,
352 protocol_name:
353 <SetterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
354 }),
355 }))
356 },
357 )
358 }
359}
360
361#[derive(Debug)]
363pub enum SetterRequest {
364 SetResponses {
370 device: fidl_fuchsia_hwinfo::DeviceInfo,
371 product: fidl_fuchsia_hwinfo::ProductInfo,
372 board: fidl_fuchsia_hwinfo::BoardInfo,
373 responder: SetterSetResponsesResponder,
374 },
375}
376
377impl SetterRequest {
378 #[allow(irrefutable_let_patterns)]
379 pub fn into_set_responses(
380 self,
381 ) -> Option<(
382 fidl_fuchsia_hwinfo::DeviceInfo,
383 fidl_fuchsia_hwinfo::ProductInfo,
384 fidl_fuchsia_hwinfo::BoardInfo,
385 SetterSetResponsesResponder,
386 )> {
387 if let SetterRequest::SetResponses { device, product, board, responder } = self {
388 Some((device, product, board, responder))
389 } else {
390 None
391 }
392 }
393
394 pub fn method_name(&self) -> &'static str {
396 match *self {
397 SetterRequest::SetResponses { .. } => "set_responses",
398 }
399 }
400}
401
402#[derive(Debug, Clone)]
403pub struct SetterControlHandle {
404 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
405}
406
407impl fidl::endpoints::ControlHandle for SetterControlHandle {
408 fn shutdown(&self) {
409 self.inner.shutdown()
410 }
411 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
412 self.inner.shutdown_with_epitaph(status)
413 }
414
415 fn is_closed(&self) -> bool {
416 self.inner.channel().is_closed()
417 }
418 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
419 self.inner.channel().on_closed()
420 }
421
422 #[cfg(target_os = "fuchsia")]
423 fn signal_peer(
424 &self,
425 clear_mask: zx::Signals,
426 set_mask: zx::Signals,
427 ) -> Result<(), zx_status::Status> {
428 use fidl::Peered;
429 self.inner.channel().signal_peer(clear_mask, set_mask)
430 }
431}
432
433impl SetterControlHandle {}
434
435#[must_use = "FIDL methods require a response to be sent"]
436#[derive(Debug)]
437pub struct SetterSetResponsesResponder {
438 control_handle: std::mem::ManuallyDrop<SetterControlHandle>,
439 tx_id: u32,
440}
441
442impl std::ops::Drop for SetterSetResponsesResponder {
446 fn drop(&mut self) {
447 self.control_handle.shutdown();
448 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
450 }
451}
452
453impl fidl::endpoints::Responder for SetterSetResponsesResponder {
454 type ControlHandle = SetterControlHandle;
455
456 fn control_handle(&self) -> &SetterControlHandle {
457 &self.control_handle
458 }
459
460 fn drop_without_shutdown(mut self) {
461 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
463 std::mem::forget(self);
465 }
466}
467
468impl SetterSetResponsesResponder {
469 pub fn send(self) -> Result<(), fidl::Error> {
473 let _result = self.send_raw();
474 if _result.is_err() {
475 self.control_handle.shutdown();
476 }
477 self.drop_without_shutdown();
478 _result
479 }
480
481 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
483 let _result = self.send_raw();
484 self.drop_without_shutdown();
485 _result
486 }
487
488 fn send_raw(&self) -> Result<(), fidl::Error> {
489 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
490 (),
491 self.tx_id,
492 0x491d2c44c662f96d,
493 fidl::encoding::DynamicFlags::empty(),
494 )
495 }
496}
497
498mod internal {
499 use super::*;
500}