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