1#![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_test_trippoint__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ControlMarker;
16
17impl fidl::endpoints::ProtocolMarker for ControlMarker {
18 type Proxy = ControlProxy;
19 type RequestStream = ControlRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ControlSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "(anonymous) Control";
24}
25
26pub trait ControlProxyInterface: Send + Sync {
27 type SetTemperatureCelsiusResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
28 + Send;
29 fn r#set_temperature_celsius(
30 &self,
31 status: i32,
32 temp: f32,
33 ) -> Self::SetTemperatureCelsiusResponseFut;
34}
35#[derive(Debug)]
36#[cfg(target_os = "fuchsia")]
37pub struct ControlSynchronousProxy {
38 client: fidl::client::sync::Client,
39}
40
41#[cfg(target_os = "fuchsia")]
42impl fidl::endpoints::SynchronousProxy for ControlSynchronousProxy {
43 type Proxy = ControlProxy;
44 type Protocol = ControlMarker;
45
46 fn from_channel(inner: fidl::Channel) -> Self {
47 Self::new(inner)
48 }
49
50 fn into_channel(self) -> fidl::Channel {
51 self.client.into_channel()
52 }
53
54 fn as_channel(&self) -> &fidl::Channel {
55 self.client.as_channel()
56 }
57}
58
59#[cfg(target_os = "fuchsia")]
60impl ControlSynchronousProxy {
61 pub fn new(channel: fidl::Channel) -> Self {
62 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64 }
65
66 pub fn into_channel(self) -> fidl::Channel {
67 self.client.into_channel()
68 }
69
70 pub fn wait_for_event(
73 &self,
74 deadline: zx::MonotonicInstant,
75 ) -> Result<ControlEvent, fidl::Error> {
76 ControlEvent::decode(self.client.wait_for_event(deadline)?)
77 }
78
79 pub fn r#set_temperature_celsius(
81 &self,
82 mut status: i32,
83 mut temp: f32,
84 ___deadline: zx::MonotonicInstant,
85 ) -> Result<(), fidl::Error> {
86 let _response = self
87 .client
88 .send_query::<ControlSetTemperatureCelsiusRequest, fidl::encoding::EmptyPayload>(
89 (status, temp),
90 0x1f4a3a4f2e8e34bc,
91 fidl::encoding::DynamicFlags::empty(),
92 ___deadline,
93 )?;
94 Ok(_response)
95 }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl From<ControlSynchronousProxy> for zx::Handle {
100 fn from(value: ControlSynchronousProxy) -> Self {
101 value.into_channel().into()
102 }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<fidl::Channel> for ControlSynchronousProxy {
107 fn from(value: fidl::Channel) -> Self {
108 Self::new(value)
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl fidl::endpoints::FromClient for ControlSynchronousProxy {
114 type Protocol = ControlMarker;
115
116 fn from_client(value: fidl::endpoints::ClientEnd<ControlMarker>) -> Self {
117 Self::new(value.into_channel())
118 }
119}
120
121#[derive(Debug, Clone)]
122pub struct ControlProxy {
123 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
124}
125
126impl fidl::endpoints::Proxy for ControlProxy {
127 type Protocol = ControlMarker;
128
129 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
130 Self::new(inner)
131 }
132
133 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
134 self.client.into_channel().map_err(|client| Self { client })
135 }
136
137 fn as_channel(&self) -> &::fidl::AsyncChannel {
138 self.client.as_channel()
139 }
140}
141
142impl ControlProxy {
143 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
145 let protocol_name = <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
146 Self { client: fidl::client::Client::new(channel, protocol_name) }
147 }
148
149 pub fn take_event_stream(&self) -> ControlEventStream {
155 ControlEventStream { event_receiver: self.client.take_event_receiver() }
156 }
157
158 pub fn r#set_temperature_celsius(
160 &self,
161 mut status: i32,
162 mut temp: f32,
163 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
164 ControlProxyInterface::r#set_temperature_celsius(self, status, temp)
165 }
166}
167
168impl ControlProxyInterface for ControlProxy {
169 type SetTemperatureCelsiusResponseFut =
170 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
171 fn r#set_temperature_celsius(
172 &self,
173 mut status: i32,
174 mut temp: f32,
175 ) -> Self::SetTemperatureCelsiusResponseFut {
176 fn _decode(
177 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
178 ) -> Result<(), fidl::Error> {
179 let _response = fidl::client::decode_transaction_body::<
180 fidl::encoding::EmptyPayload,
181 fidl::encoding::DefaultFuchsiaResourceDialect,
182 0x1f4a3a4f2e8e34bc,
183 >(_buf?)?;
184 Ok(_response)
185 }
186 self.client.send_query_and_decode::<ControlSetTemperatureCelsiusRequest, ()>(
187 (status, temp),
188 0x1f4a3a4f2e8e34bc,
189 fidl::encoding::DynamicFlags::empty(),
190 _decode,
191 )
192 }
193}
194
195pub struct ControlEventStream {
196 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
197}
198
199impl std::marker::Unpin for ControlEventStream {}
200
201impl futures::stream::FusedStream for ControlEventStream {
202 fn is_terminated(&self) -> bool {
203 self.event_receiver.is_terminated()
204 }
205}
206
207impl futures::Stream for ControlEventStream {
208 type Item = Result<ControlEvent, fidl::Error>;
209
210 fn poll_next(
211 mut self: std::pin::Pin<&mut Self>,
212 cx: &mut std::task::Context<'_>,
213 ) -> std::task::Poll<Option<Self::Item>> {
214 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
215 &mut self.event_receiver,
216 cx
217 )?) {
218 Some(buf) => std::task::Poll::Ready(Some(ControlEvent::decode(buf))),
219 None => std::task::Poll::Ready(None),
220 }
221 }
222}
223
224#[derive(Debug)]
225pub enum ControlEvent {}
226
227impl ControlEvent {
228 fn decode(
230 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
231 ) -> Result<ControlEvent, fidl::Error> {
232 let (bytes, _handles) = buf.split_mut();
233 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
234 debug_assert_eq!(tx_header.tx_id, 0);
235 match tx_header.ordinal {
236 _ => Err(fidl::Error::UnknownOrdinal {
237 ordinal: tx_header.ordinal,
238 protocol_name: <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
239 }),
240 }
241 }
242}
243
244pub struct ControlRequestStream {
246 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
247 is_terminated: bool,
248}
249
250impl std::marker::Unpin for ControlRequestStream {}
251
252impl futures::stream::FusedStream for ControlRequestStream {
253 fn is_terminated(&self) -> bool {
254 self.is_terminated
255 }
256}
257
258impl fidl::endpoints::RequestStream for ControlRequestStream {
259 type Protocol = ControlMarker;
260 type ControlHandle = ControlControlHandle;
261
262 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
263 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
264 }
265
266 fn control_handle(&self) -> Self::ControlHandle {
267 ControlControlHandle { inner: self.inner.clone() }
268 }
269
270 fn into_inner(
271 self,
272 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
273 {
274 (self.inner, self.is_terminated)
275 }
276
277 fn from_inner(
278 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
279 is_terminated: bool,
280 ) -> Self {
281 Self { inner, is_terminated }
282 }
283}
284
285impl futures::Stream for ControlRequestStream {
286 type Item = Result<ControlRequest, fidl::Error>;
287
288 fn poll_next(
289 mut self: std::pin::Pin<&mut Self>,
290 cx: &mut std::task::Context<'_>,
291 ) -> std::task::Poll<Option<Self::Item>> {
292 let this = &mut *self;
293 if this.inner.check_shutdown(cx) {
294 this.is_terminated = true;
295 return std::task::Poll::Ready(None);
296 }
297 if this.is_terminated {
298 panic!("polled ControlRequestStream after completion");
299 }
300 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
301 |bytes, handles| {
302 match this.inner.channel().read_etc(cx, bytes, handles) {
303 std::task::Poll::Ready(Ok(())) => {}
304 std::task::Poll::Pending => return std::task::Poll::Pending,
305 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
306 this.is_terminated = true;
307 return std::task::Poll::Ready(None);
308 }
309 std::task::Poll::Ready(Err(e)) => {
310 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
311 e.into(),
312 ))))
313 }
314 }
315
316 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
318
319 std::task::Poll::Ready(Some(match header.ordinal {
320 0x1f4a3a4f2e8e34bc => {
321 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
322 let mut req = fidl::new_empty!(
323 ControlSetTemperatureCelsiusRequest,
324 fidl::encoding::DefaultFuchsiaResourceDialect
325 );
326 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControlSetTemperatureCelsiusRequest>(&header, _body_bytes, handles, &mut req)?;
327 let control_handle = ControlControlHandle { inner: this.inner.clone() };
328 Ok(ControlRequest::SetTemperatureCelsius {
329 status: req.status,
330 temp: req.temp,
331
332 responder: ControlSetTemperatureCelsiusResponder {
333 control_handle: std::mem::ManuallyDrop::new(control_handle),
334 tx_id: header.tx_id,
335 },
336 })
337 }
338 _ => Err(fidl::Error::UnknownOrdinal {
339 ordinal: header.ordinal,
340 protocol_name:
341 <ControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
342 }),
343 }))
344 },
345 )
346 }
347}
348
349#[derive(Debug)]
350pub enum ControlRequest {
351 SetTemperatureCelsius {
353 status: i32,
354 temp: f32,
355 responder: ControlSetTemperatureCelsiusResponder,
356 },
357}
358
359impl ControlRequest {
360 #[allow(irrefutable_let_patterns)]
361 pub fn into_set_temperature_celsius(
362 self,
363 ) -> Option<(i32, f32, ControlSetTemperatureCelsiusResponder)> {
364 if let ControlRequest::SetTemperatureCelsius { status, temp, responder } = self {
365 Some((status, temp, responder))
366 } else {
367 None
368 }
369 }
370
371 pub fn method_name(&self) -> &'static str {
373 match *self {
374 ControlRequest::SetTemperatureCelsius { .. } => "set_temperature_celsius",
375 }
376 }
377}
378
379#[derive(Debug, Clone)]
380pub struct ControlControlHandle {
381 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
382}
383
384impl fidl::endpoints::ControlHandle for ControlControlHandle {
385 fn shutdown(&self) {
386 self.inner.shutdown()
387 }
388 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
389 self.inner.shutdown_with_epitaph(status)
390 }
391
392 fn is_closed(&self) -> bool {
393 self.inner.channel().is_closed()
394 }
395 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
396 self.inner.channel().on_closed()
397 }
398
399 #[cfg(target_os = "fuchsia")]
400 fn signal_peer(
401 &self,
402 clear_mask: zx::Signals,
403 set_mask: zx::Signals,
404 ) -> Result<(), zx_status::Status> {
405 use fidl::Peered;
406 self.inner.channel().signal_peer(clear_mask, set_mask)
407 }
408}
409
410impl ControlControlHandle {}
411
412#[must_use = "FIDL methods require a response to be sent"]
413#[derive(Debug)]
414pub struct ControlSetTemperatureCelsiusResponder {
415 control_handle: std::mem::ManuallyDrop<ControlControlHandle>,
416 tx_id: u32,
417}
418
419impl std::ops::Drop for ControlSetTemperatureCelsiusResponder {
423 fn drop(&mut self) {
424 self.control_handle.shutdown();
425 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
427 }
428}
429
430impl fidl::endpoints::Responder for ControlSetTemperatureCelsiusResponder {
431 type ControlHandle = ControlControlHandle;
432
433 fn control_handle(&self) -> &ControlControlHandle {
434 &self.control_handle
435 }
436
437 fn drop_without_shutdown(mut self) {
438 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
440 std::mem::forget(self);
442 }
443}
444
445impl ControlSetTemperatureCelsiusResponder {
446 pub fn send(self) -> Result<(), fidl::Error> {
450 let _result = self.send_raw();
451 if _result.is_err() {
452 self.control_handle.shutdown();
453 }
454 self.drop_without_shutdown();
455 _result
456 }
457
458 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
460 let _result = self.send_raw();
461 self.drop_without_shutdown();
462 _result
463 }
464
465 fn send_raw(&self) -> Result<(), fidl::Error> {
466 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
467 (),
468 self.tx_id,
469 0x1f4a3a4f2e8e34bc,
470 fidl::encoding::DynamicFlags::empty(),
471 )
472 }
473}
474
475#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
476pub struct ServiceMarker;
477
478#[cfg(target_os = "fuchsia")]
479impl fidl::endpoints::ServiceMarker for ServiceMarker {
480 type Proxy = ServiceProxy;
481 type Request = ServiceRequest;
482 const SERVICE_NAME: &'static str = "test.trippoint.Service";
483}
484
485#[cfg(target_os = "fuchsia")]
488pub enum ServiceRequest {
489 Control(ControlRequestStream),
490}
491
492#[cfg(target_os = "fuchsia")]
493impl fidl::endpoints::ServiceRequest for ServiceRequest {
494 type Service = ServiceMarker;
495
496 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
497 match name {
498 "control" => Self::Control(
499 <ControlRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
500 ),
501 _ => panic!("no such member protocol name for service Service"),
502 }
503 }
504
505 fn member_names() -> &'static [&'static str] {
506 &["control"]
507 }
508}
509#[cfg(target_os = "fuchsia")]
510pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
511
512#[cfg(target_os = "fuchsia")]
513impl fidl::endpoints::ServiceProxy for ServiceProxy {
514 type Service = ServiceMarker;
515
516 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
517 Self(opener)
518 }
519}
520
521#[cfg(target_os = "fuchsia")]
522impl ServiceProxy {
523 pub fn connect_to_control(&self) -> Result<ControlProxy, fidl::Error> {
524 let (proxy, server_end) = fidl::endpoints::create_proxy::<ControlMarker>();
525 self.connect_channel_to_control(server_end)?;
526 Ok(proxy)
527 }
528
529 pub fn connect_to_control_sync(&self) -> Result<ControlSynchronousProxy, fidl::Error> {
532 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<ControlMarker>();
533 self.connect_channel_to_control(server_end)?;
534 Ok(proxy)
535 }
536
537 pub fn connect_channel_to_control(
540 &self,
541 server_end: fidl::endpoints::ServerEnd<ControlMarker>,
542 ) -> Result<(), fidl::Error> {
543 self.0.open_member("control", server_end.into_channel())
544 }
545
546 pub fn instance_name(&self) -> &str {
547 self.0.instance_name()
548 }
549}
550
551mod internal {
552 use super::*;
553}