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_fuchsia_hardware_vreg_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct VregMarker;
16
17impl fidl::endpoints::ProtocolMarker for VregMarker {
18 type Proxy = VregProxy;
19 type RequestStream = VregRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = VregSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hardware.vreg.Vreg";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for VregMarker {}
26pub type VregSetVoltageStepResult = Result<(), i32>;
27pub type VregGetVoltageStepResult = Result<u32, i32>;
28pub type VregSetStateResult = Result<(), i32>;
29pub type VregEnableResult = Result<(), i32>;
30pub type VregDisableResult = Result<(), i32>;
31pub type VregGetRegulatorParamsResult = Result<(u32, u32, u32), i32>;
32
33pub trait VregProxyInterface: Send + Sync {
34 type SetVoltageStepResponseFut: std::future::Future<Output = Result<VregSetVoltageStepResult, fidl::Error>>
35 + Send;
36 fn r#set_voltage_step(&self, step: u32) -> Self::SetVoltageStepResponseFut;
37 type GetVoltageStepResponseFut: std::future::Future<Output = Result<VregGetVoltageStepResult, fidl::Error>>
38 + Send;
39 fn r#get_voltage_step(&self) -> Self::GetVoltageStepResponseFut;
40 type SetStateResponseFut: std::future::Future<Output = Result<VregSetStateResult, fidl::Error>>
41 + Send;
42 fn r#set_state(&self, payload: &VregSetStateRequest) -> Self::SetStateResponseFut;
43 type EnableResponseFut: std::future::Future<Output = Result<VregEnableResult, fidl::Error>>
44 + Send;
45 fn r#enable(&self) -> Self::EnableResponseFut;
46 type DisableResponseFut: std::future::Future<Output = Result<VregDisableResult, fidl::Error>>
47 + Send;
48 fn r#disable(&self) -> Self::DisableResponseFut;
49 type GetRegulatorParamsResponseFut: std::future::Future<Output = Result<VregGetRegulatorParamsResult, fidl::Error>>
50 + Send;
51 fn r#get_regulator_params(&self) -> Self::GetRegulatorParamsResponseFut;
52}
53#[derive(Debug)]
54#[cfg(target_os = "fuchsia")]
55pub struct VregSynchronousProxy {
56 client: fidl::client::sync::Client,
57}
58
59#[cfg(target_os = "fuchsia")]
60impl fidl::endpoints::SynchronousProxy for VregSynchronousProxy {
61 type Proxy = VregProxy;
62 type Protocol = VregMarker;
63
64 fn from_channel(inner: fidl::Channel) -> Self {
65 Self::new(inner)
66 }
67
68 fn into_channel(self) -> fidl::Channel {
69 self.client.into_channel()
70 }
71
72 fn as_channel(&self) -> &fidl::Channel {
73 self.client.as_channel()
74 }
75}
76
77#[cfg(target_os = "fuchsia")]
78impl VregSynchronousProxy {
79 pub fn new(channel: fidl::Channel) -> Self {
80 Self { client: fidl::client::sync::Client::new(channel) }
81 }
82
83 pub fn into_channel(self) -> fidl::Channel {
84 self.client.into_channel()
85 }
86
87 pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<VregEvent, fidl::Error> {
90 VregEvent::decode(self.client.wait_for_event::<VregMarker>(deadline)?)
91 }
92
93 pub fn r#set_voltage_step(
94 &self,
95 mut step: u32,
96 ___deadline: zx::MonotonicInstant,
97 ) -> Result<VregSetVoltageStepResult, fidl::Error> {
98 let _response = self.client.send_query::<
99 VregSetVoltageStepRequest,
100 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
101 VregMarker,
102 >(
103 (step,),
104 0x89c04aa4d3929b9,
105 fidl::encoding::DynamicFlags::empty(),
106 ___deadline,
107 )?;
108 Ok(_response.map(|x| x))
109 }
110
111 pub fn r#get_voltage_step(
112 &self,
113 ___deadline: zx::MonotonicInstant,
114 ) -> Result<VregGetVoltageStepResult, fidl::Error> {
115 let _response = self.client.send_query::<
116 fidl::encoding::EmptyPayload,
117 fidl::encoding::ResultType<VregGetVoltageStepResponse, i32>,
118 VregMarker,
119 >(
120 (),
121 0x136c9faa076b55e1,
122 fidl::encoding::DynamicFlags::empty(),
123 ___deadline,
124 )?;
125 Ok(_response.map(|x| x.result))
126 }
127
128 pub fn r#set_state(
129 &self,
130 mut payload: &VregSetStateRequest,
131 ___deadline: zx::MonotonicInstant,
132 ) -> Result<VregSetStateResult, fidl::Error> {
133 let _response = self.client.send_query::<
134 VregSetStateRequest,
135 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
136 VregMarker,
137 >(
138 payload,
139 0x7fadd2556566a22e,
140 fidl::encoding::DynamicFlags::empty(),
141 ___deadline,
142 )?;
143 Ok(_response.map(|x| x))
144 }
145
146 pub fn r#enable(
147 &self,
148 ___deadline: zx::MonotonicInstant,
149 ) -> Result<VregEnableResult, fidl::Error> {
150 let _response = self.client.send_query::<
151 fidl::encoding::EmptyPayload,
152 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
153 VregMarker,
154 >(
155 (),
156 0xd2024213c6cde86,
157 fidl::encoding::DynamicFlags::empty(),
158 ___deadline,
159 )?;
160 Ok(_response.map(|x| x))
161 }
162
163 pub fn r#disable(
164 &self,
165 ___deadline: zx::MonotonicInstant,
166 ) -> Result<VregDisableResult, fidl::Error> {
167 let _response = self.client.send_query::<
168 fidl::encoding::EmptyPayload,
169 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
170 VregMarker,
171 >(
172 (),
173 0x61ba9b20b16637ad,
174 fidl::encoding::DynamicFlags::empty(),
175 ___deadline,
176 )?;
177 Ok(_response.map(|x| x))
178 }
179
180 pub fn r#get_regulator_params(
181 &self,
182 ___deadline: zx::MonotonicInstant,
183 ) -> Result<VregGetRegulatorParamsResult, fidl::Error> {
184 let _response = self.client.send_query::<
185 fidl::encoding::EmptyPayload,
186 fidl::encoding::ResultType<VregGetRegulatorParamsResponse, i32>,
187 VregMarker,
188 >(
189 (),
190 0x2336d00f8f794f8a,
191 fidl::encoding::DynamicFlags::empty(),
192 ___deadline,
193 )?;
194 Ok(_response.map(|x| (x.min_uv, x.step_size_uv, x.num_steps)))
195 }
196}
197
198#[cfg(target_os = "fuchsia")]
199impl From<VregSynchronousProxy> for zx::NullableHandle {
200 fn from(value: VregSynchronousProxy) -> Self {
201 value.into_channel().into()
202 }
203}
204
205#[cfg(target_os = "fuchsia")]
206impl From<fidl::Channel> for VregSynchronousProxy {
207 fn from(value: fidl::Channel) -> Self {
208 Self::new(value)
209 }
210}
211
212#[cfg(target_os = "fuchsia")]
213impl fidl::endpoints::FromClient for VregSynchronousProxy {
214 type Protocol = VregMarker;
215
216 fn from_client(value: fidl::endpoints::ClientEnd<VregMarker>) -> Self {
217 Self::new(value.into_channel())
218 }
219}
220
221#[derive(Debug, Clone)]
222pub struct VregProxy {
223 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
224}
225
226impl fidl::endpoints::Proxy for VregProxy {
227 type Protocol = VregMarker;
228
229 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
230 Self::new(inner)
231 }
232
233 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
234 self.client.into_channel().map_err(|client| Self { client })
235 }
236
237 fn as_channel(&self) -> &::fidl::AsyncChannel {
238 self.client.as_channel()
239 }
240}
241
242impl VregProxy {
243 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
245 let protocol_name = <VregMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
246 Self { client: fidl::client::Client::new(channel, protocol_name) }
247 }
248
249 pub fn take_event_stream(&self) -> VregEventStream {
255 VregEventStream { event_receiver: self.client.take_event_receiver() }
256 }
257
258 pub fn r#set_voltage_step(
259 &self,
260 mut step: u32,
261 ) -> fidl::client::QueryResponseFut<
262 VregSetVoltageStepResult,
263 fidl::encoding::DefaultFuchsiaResourceDialect,
264 > {
265 VregProxyInterface::r#set_voltage_step(self, step)
266 }
267
268 pub fn r#get_voltage_step(
269 &self,
270 ) -> fidl::client::QueryResponseFut<
271 VregGetVoltageStepResult,
272 fidl::encoding::DefaultFuchsiaResourceDialect,
273 > {
274 VregProxyInterface::r#get_voltage_step(self)
275 }
276
277 pub fn r#set_state(
278 &self,
279 mut payload: &VregSetStateRequest,
280 ) -> fidl::client::QueryResponseFut<
281 VregSetStateResult,
282 fidl::encoding::DefaultFuchsiaResourceDialect,
283 > {
284 VregProxyInterface::r#set_state(self, payload)
285 }
286
287 pub fn r#enable(
288 &self,
289 ) -> fidl::client::QueryResponseFut<
290 VregEnableResult,
291 fidl::encoding::DefaultFuchsiaResourceDialect,
292 > {
293 VregProxyInterface::r#enable(self)
294 }
295
296 pub fn r#disable(
297 &self,
298 ) -> fidl::client::QueryResponseFut<
299 VregDisableResult,
300 fidl::encoding::DefaultFuchsiaResourceDialect,
301 > {
302 VregProxyInterface::r#disable(self)
303 }
304
305 pub fn r#get_regulator_params(
306 &self,
307 ) -> fidl::client::QueryResponseFut<
308 VregGetRegulatorParamsResult,
309 fidl::encoding::DefaultFuchsiaResourceDialect,
310 > {
311 VregProxyInterface::r#get_regulator_params(self)
312 }
313}
314
315impl VregProxyInterface for VregProxy {
316 type SetVoltageStepResponseFut = fidl::client::QueryResponseFut<
317 VregSetVoltageStepResult,
318 fidl::encoding::DefaultFuchsiaResourceDialect,
319 >;
320 fn r#set_voltage_step(&self, mut step: u32) -> Self::SetVoltageStepResponseFut {
321 fn _decode(
322 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
323 ) -> Result<VregSetVoltageStepResult, fidl::Error> {
324 let _response = fidl::client::decode_transaction_body::<
325 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
326 fidl::encoding::DefaultFuchsiaResourceDialect,
327 0x89c04aa4d3929b9,
328 >(_buf?)?;
329 Ok(_response.map(|x| x))
330 }
331 self.client.send_query_and_decode::<VregSetVoltageStepRequest, VregSetVoltageStepResult>(
332 (step,),
333 0x89c04aa4d3929b9,
334 fidl::encoding::DynamicFlags::empty(),
335 _decode,
336 )
337 }
338
339 type GetVoltageStepResponseFut = fidl::client::QueryResponseFut<
340 VregGetVoltageStepResult,
341 fidl::encoding::DefaultFuchsiaResourceDialect,
342 >;
343 fn r#get_voltage_step(&self) -> Self::GetVoltageStepResponseFut {
344 fn _decode(
345 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
346 ) -> Result<VregGetVoltageStepResult, fidl::Error> {
347 let _response = fidl::client::decode_transaction_body::<
348 fidl::encoding::ResultType<VregGetVoltageStepResponse, i32>,
349 fidl::encoding::DefaultFuchsiaResourceDialect,
350 0x136c9faa076b55e1,
351 >(_buf?)?;
352 Ok(_response.map(|x| x.result))
353 }
354 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VregGetVoltageStepResult>(
355 (),
356 0x136c9faa076b55e1,
357 fidl::encoding::DynamicFlags::empty(),
358 _decode,
359 )
360 }
361
362 type SetStateResponseFut = fidl::client::QueryResponseFut<
363 VregSetStateResult,
364 fidl::encoding::DefaultFuchsiaResourceDialect,
365 >;
366 fn r#set_state(&self, mut payload: &VregSetStateRequest) -> Self::SetStateResponseFut {
367 fn _decode(
368 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
369 ) -> Result<VregSetStateResult, fidl::Error> {
370 let _response = fidl::client::decode_transaction_body::<
371 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
372 fidl::encoding::DefaultFuchsiaResourceDialect,
373 0x7fadd2556566a22e,
374 >(_buf?)?;
375 Ok(_response.map(|x| x))
376 }
377 self.client.send_query_and_decode::<VregSetStateRequest, VregSetStateResult>(
378 payload,
379 0x7fadd2556566a22e,
380 fidl::encoding::DynamicFlags::empty(),
381 _decode,
382 )
383 }
384
385 type EnableResponseFut = fidl::client::QueryResponseFut<
386 VregEnableResult,
387 fidl::encoding::DefaultFuchsiaResourceDialect,
388 >;
389 fn r#enable(&self) -> Self::EnableResponseFut {
390 fn _decode(
391 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
392 ) -> Result<VregEnableResult, fidl::Error> {
393 let _response = fidl::client::decode_transaction_body::<
394 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
395 fidl::encoding::DefaultFuchsiaResourceDialect,
396 0xd2024213c6cde86,
397 >(_buf?)?;
398 Ok(_response.map(|x| x))
399 }
400 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VregEnableResult>(
401 (),
402 0xd2024213c6cde86,
403 fidl::encoding::DynamicFlags::empty(),
404 _decode,
405 )
406 }
407
408 type DisableResponseFut = fidl::client::QueryResponseFut<
409 VregDisableResult,
410 fidl::encoding::DefaultFuchsiaResourceDialect,
411 >;
412 fn r#disable(&self) -> Self::DisableResponseFut {
413 fn _decode(
414 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
415 ) -> Result<VregDisableResult, fidl::Error> {
416 let _response = fidl::client::decode_transaction_body::<
417 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
418 fidl::encoding::DefaultFuchsiaResourceDialect,
419 0x61ba9b20b16637ad,
420 >(_buf?)?;
421 Ok(_response.map(|x| x))
422 }
423 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, VregDisableResult>(
424 (),
425 0x61ba9b20b16637ad,
426 fidl::encoding::DynamicFlags::empty(),
427 _decode,
428 )
429 }
430
431 type GetRegulatorParamsResponseFut = fidl::client::QueryResponseFut<
432 VregGetRegulatorParamsResult,
433 fidl::encoding::DefaultFuchsiaResourceDialect,
434 >;
435 fn r#get_regulator_params(&self) -> Self::GetRegulatorParamsResponseFut {
436 fn _decode(
437 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
438 ) -> Result<VregGetRegulatorParamsResult, fidl::Error> {
439 let _response = fidl::client::decode_transaction_body::<
440 fidl::encoding::ResultType<VregGetRegulatorParamsResponse, i32>,
441 fidl::encoding::DefaultFuchsiaResourceDialect,
442 0x2336d00f8f794f8a,
443 >(_buf?)?;
444 Ok(_response.map(|x| (x.min_uv, x.step_size_uv, x.num_steps)))
445 }
446 self.client
447 .send_query_and_decode::<fidl::encoding::EmptyPayload, VregGetRegulatorParamsResult>(
448 (),
449 0x2336d00f8f794f8a,
450 fidl::encoding::DynamicFlags::empty(),
451 _decode,
452 )
453 }
454}
455
456pub struct VregEventStream {
457 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
458}
459
460impl std::marker::Unpin for VregEventStream {}
461
462impl futures::stream::FusedStream for VregEventStream {
463 fn is_terminated(&self) -> bool {
464 self.event_receiver.is_terminated()
465 }
466}
467
468impl futures::Stream for VregEventStream {
469 type Item = Result<VregEvent, fidl::Error>;
470
471 fn poll_next(
472 mut self: std::pin::Pin<&mut Self>,
473 cx: &mut std::task::Context<'_>,
474 ) -> std::task::Poll<Option<Self::Item>> {
475 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
476 &mut self.event_receiver,
477 cx
478 )?) {
479 Some(buf) => std::task::Poll::Ready(Some(VregEvent::decode(buf))),
480 None => std::task::Poll::Ready(None),
481 }
482 }
483}
484
485#[derive(Debug)]
486pub enum VregEvent {}
487
488impl VregEvent {
489 fn decode(
491 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
492 ) -> Result<VregEvent, fidl::Error> {
493 let (bytes, _handles) = buf.split_mut();
494 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
495 debug_assert_eq!(tx_header.tx_id, 0);
496 match tx_header.ordinal {
497 _ => Err(fidl::Error::UnknownOrdinal {
498 ordinal: tx_header.ordinal,
499 protocol_name: <VregMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
500 }),
501 }
502 }
503}
504
505pub struct VregRequestStream {
507 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
508 is_terminated: bool,
509}
510
511impl std::marker::Unpin for VregRequestStream {}
512
513impl futures::stream::FusedStream for VregRequestStream {
514 fn is_terminated(&self) -> bool {
515 self.is_terminated
516 }
517}
518
519impl fidl::endpoints::RequestStream for VregRequestStream {
520 type Protocol = VregMarker;
521 type ControlHandle = VregControlHandle;
522
523 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
524 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
525 }
526
527 fn control_handle(&self) -> Self::ControlHandle {
528 VregControlHandle { inner: self.inner.clone() }
529 }
530
531 fn into_inner(
532 self,
533 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
534 {
535 (self.inner, self.is_terminated)
536 }
537
538 fn from_inner(
539 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
540 is_terminated: bool,
541 ) -> Self {
542 Self { inner, is_terminated }
543 }
544}
545
546impl futures::Stream for VregRequestStream {
547 type Item = Result<VregRequest, fidl::Error>;
548
549 fn poll_next(
550 mut self: std::pin::Pin<&mut Self>,
551 cx: &mut std::task::Context<'_>,
552 ) -> std::task::Poll<Option<Self::Item>> {
553 let this = &mut *self;
554 if this.inner.check_shutdown(cx) {
555 this.is_terminated = true;
556 return std::task::Poll::Ready(None);
557 }
558 if this.is_terminated {
559 panic!("polled VregRequestStream after completion");
560 }
561 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
562 |bytes, handles| {
563 match this.inner.channel().read_etc(cx, bytes, handles) {
564 std::task::Poll::Ready(Ok(())) => {}
565 std::task::Poll::Pending => return std::task::Poll::Pending,
566 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
567 this.is_terminated = true;
568 return std::task::Poll::Ready(None);
569 }
570 std::task::Poll::Ready(Err(e)) => {
571 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
572 e.into(),
573 ))));
574 }
575 }
576
577 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
579
580 std::task::Poll::Ready(Some(match header.ordinal {
581 0x89c04aa4d3929b9 => {
582 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
583 let mut req = fidl::new_empty!(
584 VregSetVoltageStepRequest,
585 fidl::encoding::DefaultFuchsiaResourceDialect
586 );
587 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VregSetVoltageStepRequest>(&header, _body_bytes, handles, &mut req)?;
588 let control_handle = VregControlHandle { inner: this.inner.clone() };
589 Ok(VregRequest::SetVoltageStep {
590 step: req.step,
591
592 responder: VregSetVoltageStepResponder {
593 control_handle: std::mem::ManuallyDrop::new(control_handle),
594 tx_id: header.tx_id,
595 },
596 })
597 }
598 0x136c9faa076b55e1 => {
599 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
600 let mut req = fidl::new_empty!(
601 fidl::encoding::EmptyPayload,
602 fidl::encoding::DefaultFuchsiaResourceDialect
603 );
604 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
605 let control_handle = VregControlHandle { inner: this.inner.clone() };
606 Ok(VregRequest::GetVoltageStep {
607 responder: VregGetVoltageStepResponder {
608 control_handle: std::mem::ManuallyDrop::new(control_handle),
609 tx_id: header.tx_id,
610 },
611 })
612 }
613 0x7fadd2556566a22e => {
614 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
615 let mut req = fidl::new_empty!(
616 VregSetStateRequest,
617 fidl::encoding::DefaultFuchsiaResourceDialect
618 );
619 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VregSetStateRequest>(&header, _body_bytes, handles, &mut req)?;
620 let control_handle = VregControlHandle { inner: this.inner.clone() };
621 Ok(VregRequest::SetState {
622 payload: req,
623 responder: VregSetStateResponder {
624 control_handle: std::mem::ManuallyDrop::new(control_handle),
625 tx_id: header.tx_id,
626 },
627 })
628 }
629 0xd2024213c6cde86 => {
630 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
631 let mut req = fidl::new_empty!(
632 fidl::encoding::EmptyPayload,
633 fidl::encoding::DefaultFuchsiaResourceDialect
634 );
635 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
636 let control_handle = VregControlHandle { inner: this.inner.clone() };
637 Ok(VregRequest::Enable {
638 responder: VregEnableResponder {
639 control_handle: std::mem::ManuallyDrop::new(control_handle),
640 tx_id: header.tx_id,
641 },
642 })
643 }
644 0x61ba9b20b16637ad => {
645 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
646 let mut req = fidl::new_empty!(
647 fidl::encoding::EmptyPayload,
648 fidl::encoding::DefaultFuchsiaResourceDialect
649 );
650 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
651 let control_handle = VregControlHandle { inner: this.inner.clone() };
652 Ok(VregRequest::Disable {
653 responder: VregDisableResponder {
654 control_handle: std::mem::ManuallyDrop::new(control_handle),
655 tx_id: header.tx_id,
656 },
657 })
658 }
659 0x2336d00f8f794f8a => {
660 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
661 let mut req = fidl::new_empty!(
662 fidl::encoding::EmptyPayload,
663 fidl::encoding::DefaultFuchsiaResourceDialect
664 );
665 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
666 let control_handle = VregControlHandle { inner: this.inner.clone() };
667 Ok(VregRequest::GetRegulatorParams {
668 responder: VregGetRegulatorParamsResponder {
669 control_handle: std::mem::ManuallyDrop::new(control_handle),
670 tx_id: header.tx_id,
671 },
672 })
673 }
674 _ => Err(fidl::Error::UnknownOrdinal {
675 ordinal: header.ordinal,
676 protocol_name: <VregMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
677 }),
678 }))
679 },
680 )
681 }
682}
683
684#[derive(Debug)]
685pub enum VregRequest {
686 SetVoltageStep { step: u32, responder: VregSetVoltageStepResponder },
687 GetVoltageStep { responder: VregGetVoltageStepResponder },
688 SetState { payload: VregSetStateRequest, responder: VregSetStateResponder },
689 Enable { responder: VregEnableResponder },
690 Disable { responder: VregDisableResponder },
691 GetRegulatorParams { responder: VregGetRegulatorParamsResponder },
692}
693
694impl VregRequest {
695 #[allow(irrefutable_let_patterns)]
696 pub fn into_set_voltage_step(self) -> Option<(u32, VregSetVoltageStepResponder)> {
697 if let VregRequest::SetVoltageStep { step, responder } = self {
698 Some((step, responder))
699 } else {
700 None
701 }
702 }
703
704 #[allow(irrefutable_let_patterns)]
705 pub fn into_get_voltage_step(self) -> Option<(VregGetVoltageStepResponder)> {
706 if let VregRequest::GetVoltageStep { responder } = self { Some((responder)) } else { None }
707 }
708
709 #[allow(irrefutable_let_patterns)]
710 pub fn into_set_state(self) -> Option<(VregSetStateRequest, VregSetStateResponder)> {
711 if let VregRequest::SetState { payload, responder } = self {
712 Some((payload, responder))
713 } else {
714 None
715 }
716 }
717
718 #[allow(irrefutable_let_patterns)]
719 pub fn into_enable(self) -> Option<(VregEnableResponder)> {
720 if let VregRequest::Enable { responder } = self { Some((responder)) } else { None }
721 }
722
723 #[allow(irrefutable_let_patterns)]
724 pub fn into_disable(self) -> Option<(VregDisableResponder)> {
725 if let VregRequest::Disable { responder } = self { Some((responder)) } else { None }
726 }
727
728 #[allow(irrefutable_let_patterns)]
729 pub fn into_get_regulator_params(self) -> Option<(VregGetRegulatorParamsResponder)> {
730 if let VregRequest::GetRegulatorParams { responder } = self {
731 Some((responder))
732 } else {
733 None
734 }
735 }
736
737 pub fn method_name(&self) -> &'static str {
739 match *self {
740 VregRequest::SetVoltageStep { .. } => "set_voltage_step",
741 VregRequest::GetVoltageStep { .. } => "get_voltage_step",
742 VregRequest::SetState { .. } => "set_state",
743 VregRequest::Enable { .. } => "enable",
744 VregRequest::Disable { .. } => "disable",
745 VregRequest::GetRegulatorParams { .. } => "get_regulator_params",
746 }
747 }
748}
749
750#[derive(Debug, Clone)]
751pub struct VregControlHandle {
752 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
753}
754
755impl VregControlHandle {
756 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
757 self.inner.shutdown_with_epitaph(status.into())
758 }
759}
760
761impl fidl::endpoints::ControlHandle for VregControlHandle {
762 fn shutdown(&self) {
763 self.inner.shutdown()
764 }
765
766 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
767 self.inner.shutdown_with_epitaph(status)
768 }
769
770 fn is_closed(&self) -> bool {
771 self.inner.channel().is_closed()
772 }
773 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
774 self.inner.channel().on_closed()
775 }
776
777 #[cfg(target_os = "fuchsia")]
778 fn signal_peer(
779 &self,
780 clear_mask: zx::Signals,
781 set_mask: zx::Signals,
782 ) -> Result<(), zx_status::Status> {
783 use fidl::Peered;
784 self.inner.channel().signal_peer(clear_mask, set_mask)
785 }
786}
787
788impl VregControlHandle {}
789
790#[must_use = "FIDL methods require a response to be sent"]
791#[derive(Debug)]
792pub struct VregSetVoltageStepResponder {
793 control_handle: std::mem::ManuallyDrop<VregControlHandle>,
794 tx_id: u32,
795}
796
797impl std::ops::Drop for VregSetVoltageStepResponder {
801 fn drop(&mut self) {
802 self.control_handle.shutdown();
803 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
805 }
806}
807
808impl fidl::endpoints::Responder for VregSetVoltageStepResponder {
809 type ControlHandle = VregControlHandle;
810
811 fn control_handle(&self) -> &VregControlHandle {
812 &self.control_handle
813 }
814
815 fn drop_without_shutdown(mut self) {
816 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
818 std::mem::forget(self);
820 }
821}
822
823impl VregSetVoltageStepResponder {
824 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
828 let _result = self.send_raw(result);
829 if _result.is_err() {
830 self.control_handle.shutdown();
831 }
832 self.drop_without_shutdown();
833 _result
834 }
835
836 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
838 let _result = self.send_raw(result);
839 self.drop_without_shutdown();
840 _result
841 }
842
843 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
844 self.control_handle
845 .inner
846 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
847 result,
848 self.tx_id,
849 0x89c04aa4d3929b9,
850 fidl::encoding::DynamicFlags::empty(),
851 )
852 }
853}
854
855#[must_use = "FIDL methods require a response to be sent"]
856#[derive(Debug)]
857pub struct VregGetVoltageStepResponder {
858 control_handle: std::mem::ManuallyDrop<VregControlHandle>,
859 tx_id: u32,
860}
861
862impl std::ops::Drop for VregGetVoltageStepResponder {
866 fn drop(&mut self) {
867 self.control_handle.shutdown();
868 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
870 }
871}
872
873impl fidl::endpoints::Responder for VregGetVoltageStepResponder {
874 type ControlHandle = VregControlHandle;
875
876 fn control_handle(&self) -> &VregControlHandle {
877 &self.control_handle
878 }
879
880 fn drop_without_shutdown(mut self) {
881 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
883 std::mem::forget(self);
885 }
886}
887
888impl VregGetVoltageStepResponder {
889 pub fn send(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
893 let _result = self.send_raw(result);
894 if _result.is_err() {
895 self.control_handle.shutdown();
896 }
897 self.drop_without_shutdown();
898 _result
899 }
900
901 pub fn send_no_shutdown_on_err(self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
903 let _result = self.send_raw(result);
904 self.drop_without_shutdown();
905 _result
906 }
907
908 fn send_raw(&self, mut result: Result<u32, i32>) -> Result<(), fidl::Error> {
909 self.control_handle
910 .inner
911 .send::<fidl::encoding::ResultType<VregGetVoltageStepResponse, i32>>(
912 result.map(|result| (result,)),
913 self.tx_id,
914 0x136c9faa076b55e1,
915 fidl::encoding::DynamicFlags::empty(),
916 )
917 }
918}
919
920#[must_use = "FIDL methods require a response to be sent"]
921#[derive(Debug)]
922pub struct VregSetStateResponder {
923 control_handle: std::mem::ManuallyDrop<VregControlHandle>,
924 tx_id: u32,
925}
926
927impl std::ops::Drop for VregSetStateResponder {
931 fn drop(&mut self) {
932 self.control_handle.shutdown();
933 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
935 }
936}
937
938impl fidl::endpoints::Responder for VregSetStateResponder {
939 type ControlHandle = VregControlHandle;
940
941 fn control_handle(&self) -> &VregControlHandle {
942 &self.control_handle
943 }
944
945 fn drop_without_shutdown(mut self) {
946 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
948 std::mem::forget(self);
950 }
951}
952
953impl VregSetStateResponder {
954 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
958 let _result = self.send_raw(result);
959 if _result.is_err() {
960 self.control_handle.shutdown();
961 }
962 self.drop_without_shutdown();
963 _result
964 }
965
966 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
968 let _result = self.send_raw(result);
969 self.drop_without_shutdown();
970 _result
971 }
972
973 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
974 self.control_handle
975 .inner
976 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
977 result,
978 self.tx_id,
979 0x7fadd2556566a22e,
980 fidl::encoding::DynamicFlags::empty(),
981 )
982 }
983}
984
985#[must_use = "FIDL methods require a response to be sent"]
986#[derive(Debug)]
987pub struct VregEnableResponder {
988 control_handle: std::mem::ManuallyDrop<VregControlHandle>,
989 tx_id: u32,
990}
991
992impl std::ops::Drop for VregEnableResponder {
996 fn drop(&mut self) {
997 self.control_handle.shutdown();
998 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1000 }
1001}
1002
1003impl fidl::endpoints::Responder for VregEnableResponder {
1004 type ControlHandle = VregControlHandle;
1005
1006 fn control_handle(&self) -> &VregControlHandle {
1007 &self.control_handle
1008 }
1009
1010 fn drop_without_shutdown(mut self) {
1011 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1013 std::mem::forget(self);
1015 }
1016}
1017
1018impl VregEnableResponder {
1019 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1023 let _result = self.send_raw(result);
1024 if _result.is_err() {
1025 self.control_handle.shutdown();
1026 }
1027 self.drop_without_shutdown();
1028 _result
1029 }
1030
1031 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1033 let _result = self.send_raw(result);
1034 self.drop_without_shutdown();
1035 _result
1036 }
1037
1038 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1039 self.control_handle
1040 .inner
1041 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1042 result,
1043 self.tx_id,
1044 0xd2024213c6cde86,
1045 fidl::encoding::DynamicFlags::empty(),
1046 )
1047 }
1048}
1049
1050#[must_use = "FIDL methods require a response to be sent"]
1051#[derive(Debug)]
1052pub struct VregDisableResponder {
1053 control_handle: std::mem::ManuallyDrop<VregControlHandle>,
1054 tx_id: u32,
1055}
1056
1057impl std::ops::Drop for VregDisableResponder {
1061 fn drop(&mut self) {
1062 self.control_handle.shutdown();
1063 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1065 }
1066}
1067
1068impl fidl::endpoints::Responder for VregDisableResponder {
1069 type ControlHandle = VregControlHandle;
1070
1071 fn control_handle(&self) -> &VregControlHandle {
1072 &self.control_handle
1073 }
1074
1075 fn drop_without_shutdown(mut self) {
1076 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1078 std::mem::forget(self);
1080 }
1081}
1082
1083impl VregDisableResponder {
1084 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1088 let _result = self.send_raw(result);
1089 if _result.is_err() {
1090 self.control_handle.shutdown();
1091 }
1092 self.drop_without_shutdown();
1093 _result
1094 }
1095
1096 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1098 let _result = self.send_raw(result);
1099 self.drop_without_shutdown();
1100 _result
1101 }
1102
1103 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1104 self.control_handle
1105 .inner
1106 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1107 result,
1108 self.tx_id,
1109 0x61ba9b20b16637ad,
1110 fidl::encoding::DynamicFlags::empty(),
1111 )
1112 }
1113}
1114
1115#[must_use = "FIDL methods require a response to be sent"]
1116#[derive(Debug)]
1117pub struct VregGetRegulatorParamsResponder {
1118 control_handle: std::mem::ManuallyDrop<VregControlHandle>,
1119 tx_id: u32,
1120}
1121
1122impl std::ops::Drop for VregGetRegulatorParamsResponder {
1126 fn drop(&mut self) {
1127 self.control_handle.shutdown();
1128 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1130 }
1131}
1132
1133impl fidl::endpoints::Responder for VregGetRegulatorParamsResponder {
1134 type ControlHandle = VregControlHandle;
1135
1136 fn control_handle(&self) -> &VregControlHandle {
1137 &self.control_handle
1138 }
1139
1140 fn drop_without_shutdown(mut self) {
1141 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1143 std::mem::forget(self);
1145 }
1146}
1147
1148impl VregGetRegulatorParamsResponder {
1149 pub fn send(self, mut result: Result<(u32, u32, u32), i32>) -> Result<(), fidl::Error> {
1153 let _result = self.send_raw(result);
1154 if _result.is_err() {
1155 self.control_handle.shutdown();
1156 }
1157 self.drop_without_shutdown();
1158 _result
1159 }
1160
1161 pub fn send_no_shutdown_on_err(
1163 self,
1164 mut result: Result<(u32, u32, u32), i32>,
1165 ) -> Result<(), fidl::Error> {
1166 let _result = self.send_raw(result);
1167 self.drop_without_shutdown();
1168 _result
1169 }
1170
1171 fn send_raw(&self, mut result: Result<(u32, u32, u32), i32>) -> Result<(), fidl::Error> {
1172 self.control_handle
1173 .inner
1174 .send::<fidl::encoding::ResultType<VregGetRegulatorParamsResponse, i32>>(
1175 result,
1176 self.tx_id,
1177 0x2336d00f8f794f8a,
1178 fidl::encoding::DynamicFlags::empty(),
1179 )
1180 }
1181}
1182
1183#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1184pub struct ServiceMarker;
1185
1186#[cfg(target_os = "fuchsia")]
1187impl fidl::endpoints::ServiceMarker for ServiceMarker {
1188 type Proxy = ServiceProxy;
1189 type Request = ServiceRequest;
1190 const SERVICE_NAME: &'static str = "fuchsia.hardware.vreg.Service";
1191}
1192
1193#[cfg(target_os = "fuchsia")]
1196pub enum ServiceRequest {
1197 Vreg(VregRequestStream),
1198}
1199
1200#[cfg(target_os = "fuchsia")]
1201impl fidl::endpoints::ServiceRequest for ServiceRequest {
1202 type Service = ServiceMarker;
1203
1204 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1205 match name {
1206 "vreg" => Self::Vreg(
1207 <VregRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1208 ),
1209 _ => panic!("no such member protocol name for service Service"),
1210 }
1211 }
1212
1213 fn member_names() -> &'static [&'static str] {
1214 &["vreg"]
1215 }
1216}
1217#[cfg(target_os = "fuchsia")]
1218pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1219
1220#[cfg(target_os = "fuchsia")]
1221impl fidl::endpoints::ServiceProxy for ServiceProxy {
1222 type Service = ServiceMarker;
1223
1224 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1225 Self(opener)
1226 }
1227}
1228
1229#[cfg(target_os = "fuchsia")]
1230impl ServiceProxy {
1231 pub fn connect_to_vreg(&self) -> Result<VregProxy, fidl::Error> {
1232 let (proxy, server_end) = fidl::endpoints::create_proxy::<VregMarker>();
1233 self.connect_channel_to_vreg(server_end)?;
1234 Ok(proxy)
1235 }
1236
1237 pub fn connect_to_vreg_sync(&self) -> Result<VregSynchronousProxy, fidl::Error> {
1240 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<VregMarker>();
1241 self.connect_channel_to_vreg(server_end)?;
1242 Ok(proxy)
1243 }
1244
1245 pub fn connect_channel_to_vreg(
1248 &self,
1249 server_end: fidl::endpoints::ServerEnd<VregMarker>,
1250 ) -> Result<(), fidl::Error> {
1251 self.0.open_member("vreg", server_end.into_channel())
1252 }
1253
1254 pub fn instance_name(&self) -> &str {
1255 self.0.instance_name()
1256 }
1257}
1258
1259mod internal {
1260 use super::*;
1261}