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