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_diagnostics_system__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct SerialLogControlFreezeSerialForwardingResponse {
16 pub token: fidl::EventPair,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for SerialLogControlFreezeSerialForwardingResponse
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct SerialLogControlMarker;
26
27impl fidl::endpoints::ProtocolMarker for SerialLogControlMarker {
28 type Proxy = SerialLogControlProxy;
29 type RequestStream = SerialLogControlRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = SerialLogControlSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "fuchsia.diagnostics.system.SerialLogControl";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for SerialLogControlMarker {}
36
37pub trait SerialLogControlProxyInterface: Send + Sync {
38 type FreezeSerialForwardingResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
39 + Send;
40 fn r#freeze_serial_forwarding(&self) -> Self::FreezeSerialForwardingResponseFut;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct SerialLogControlSynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for SerialLogControlSynchronousProxy {
50 type Proxy = SerialLogControlProxy;
51 type Protocol = SerialLogControlMarker;
52
53 fn from_channel(inner: fidl::Channel) -> Self {
54 Self::new(inner)
55 }
56
57 fn into_channel(self) -> fidl::Channel {
58 self.client.into_channel()
59 }
60
61 fn as_channel(&self) -> &fidl::Channel {
62 self.client.as_channel()
63 }
64}
65
66#[cfg(target_os = "fuchsia")]
67impl SerialLogControlSynchronousProxy {
68 pub fn new(channel: fidl::Channel) -> Self {
69 let protocol_name = <SerialLogControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
70 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<SerialLogControlEvent, fidl::Error> {
83 SerialLogControlEvent::decode(self.client.wait_for_event(deadline)?)
84 }
85
86 pub fn r#freeze_serial_forwarding(
90 &self,
91 ___deadline: zx::MonotonicInstant,
92 ) -> Result<fidl::EventPair, fidl::Error> {
93 let _response = self.client.send_query::<
94 fidl::encoding::EmptyPayload,
95 fidl::encoding::FlexibleType<SerialLogControlFreezeSerialForwardingResponse>,
96 >(
97 (),
98 0x1904156ca205d617,
99 fidl::encoding::DynamicFlags::FLEXIBLE,
100 ___deadline,
101 )?
102 .into_result::<SerialLogControlMarker>("freeze_serial_forwarding")?;
103 Ok(_response.token)
104 }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl From<SerialLogControlSynchronousProxy> for zx::Handle {
109 fn from(value: SerialLogControlSynchronousProxy) -> Self {
110 value.into_channel().into()
111 }
112}
113
114#[cfg(target_os = "fuchsia")]
115impl From<fidl::Channel> for SerialLogControlSynchronousProxy {
116 fn from(value: fidl::Channel) -> Self {
117 Self::new(value)
118 }
119}
120
121#[cfg(target_os = "fuchsia")]
122impl fidl::endpoints::FromClient for SerialLogControlSynchronousProxy {
123 type Protocol = SerialLogControlMarker;
124
125 fn from_client(value: fidl::endpoints::ClientEnd<SerialLogControlMarker>) -> Self {
126 Self::new(value.into_channel())
127 }
128}
129
130#[derive(Debug, Clone)]
131pub struct SerialLogControlProxy {
132 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
133}
134
135impl fidl::endpoints::Proxy for SerialLogControlProxy {
136 type Protocol = SerialLogControlMarker;
137
138 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
139 Self::new(inner)
140 }
141
142 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
143 self.client.into_channel().map_err(|client| Self { client })
144 }
145
146 fn as_channel(&self) -> &::fidl::AsyncChannel {
147 self.client.as_channel()
148 }
149}
150
151impl SerialLogControlProxy {
152 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
154 let protocol_name = <SerialLogControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
155 Self { client: fidl::client::Client::new(channel, protocol_name) }
156 }
157
158 pub fn take_event_stream(&self) -> SerialLogControlEventStream {
164 SerialLogControlEventStream { event_receiver: self.client.take_event_receiver() }
165 }
166
167 pub fn r#freeze_serial_forwarding(
171 &self,
172 ) -> fidl::client::QueryResponseFut<
173 fidl::EventPair,
174 fidl::encoding::DefaultFuchsiaResourceDialect,
175 > {
176 SerialLogControlProxyInterface::r#freeze_serial_forwarding(self)
177 }
178}
179
180impl SerialLogControlProxyInterface for SerialLogControlProxy {
181 type FreezeSerialForwardingResponseFut = fidl::client::QueryResponseFut<
182 fidl::EventPair,
183 fidl::encoding::DefaultFuchsiaResourceDialect,
184 >;
185 fn r#freeze_serial_forwarding(&self) -> Self::FreezeSerialForwardingResponseFut {
186 fn _decode(
187 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
188 ) -> Result<fidl::EventPair, fidl::Error> {
189 let _response = fidl::client::decode_transaction_body::<
190 fidl::encoding::FlexibleType<SerialLogControlFreezeSerialForwardingResponse>,
191 fidl::encoding::DefaultFuchsiaResourceDialect,
192 0x1904156ca205d617,
193 >(_buf?)?
194 .into_result::<SerialLogControlMarker>("freeze_serial_forwarding")?;
195 Ok(_response.token)
196 }
197 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::EventPair>(
198 (),
199 0x1904156ca205d617,
200 fidl::encoding::DynamicFlags::FLEXIBLE,
201 _decode,
202 )
203 }
204}
205
206pub struct SerialLogControlEventStream {
207 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
208}
209
210impl std::marker::Unpin for SerialLogControlEventStream {}
211
212impl futures::stream::FusedStream for SerialLogControlEventStream {
213 fn is_terminated(&self) -> bool {
214 self.event_receiver.is_terminated()
215 }
216}
217
218impl futures::Stream for SerialLogControlEventStream {
219 type Item = Result<SerialLogControlEvent, 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(SerialLogControlEvent::decode(buf))),
230 None => std::task::Poll::Ready(None),
231 }
232 }
233}
234
235#[derive(Debug)]
236pub enum SerialLogControlEvent {
237 #[non_exhaustive]
238 _UnknownEvent {
239 ordinal: u64,
241 },
242}
243
244impl SerialLogControlEvent {
245 fn decode(
247 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
248 ) -> Result<SerialLogControlEvent, fidl::Error> {
249 let (bytes, _handles) = buf.split_mut();
250 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
251 debug_assert_eq!(tx_header.tx_id, 0);
252 match tx_header.ordinal {
253 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
254 Ok(SerialLogControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
255 }
256 _ => Err(fidl::Error::UnknownOrdinal {
257 ordinal: tx_header.ordinal,
258 protocol_name:
259 <SerialLogControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
260 }),
261 }
262 }
263}
264
265pub struct SerialLogControlRequestStream {
267 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
268 is_terminated: bool,
269}
270
271impl std::marker::Unpin for SerialLogControlRequestStream {}
272
273impl futures::stream::FusedStream for SerialLogControlRequestStream {
274 fn is_terminated(&self) -> bool {
275 self.is_terminated
276 }
277}
278
279impl fidl::endpoints::RequestStream for SerialLogControlRequestStream {
280 type Protocol = SerialLogControlMarker;
281 type ControlHandle = SerialLogControlControlHandle;
282
283 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
284 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
285 }
286
287 fn control_handle(&self) -> Self::ControlHandle {
288 SerialLogControlControlHandle { inner: self.inner.clone() }
289 }
290
291 fn into_inner(
292 self,
293 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
294 {
295 (self.inner, self.is_terminated)
296 }
297
298 fn from_inner(
299 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
300 is_terminated: bool,
301 ) -> Self {
302 Self { inner, is_terminated }
303 }
304}
305
306impl futures::Stream for SerialLogControlRequestStream {
307 type Item = Result<SerialLogControlRequest, fidl::Error>;
308
309 fn poll_next(
310 mut self: std::pin::Pin<&mut Self>,
311 cx: &mut std::task::Context<'_>,
312 ) -> std::task::Poll<Option<Self::Item>> {
313 let this = &mut *self;
314 if this.inner.check_shutdown(cx) {
315 this.is_terminated = true;
316 return std::task::Poll::Ready(None);
317 }
318 if this.is_terminated {
319 panic!("polled SerialLogControlRequestStream after completion");
320 }
321 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
322 |bytes, handles| {
323 match this.inner.channel().read_etc(cx, bytes, handles) {
324 std::task::Poll::Ready(Ok(())) => {}
325 std::task::Poll::Pending => return std::task::Poll::Pending,
326 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
327 this.is_terminated = true;
328 return std::task::Poll::Ready(None);
329 }
330 std::task::Poll::Ready(Err(e)) => {
331 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
332 e.into(),
333 ))))
334 }
335 }
336
337 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
339
340 std::task::Poll::Ready(Some(match header.ordinal {
341 0x1904156ca205d617 => {
342 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
343 let mut req = fidl::new_empty!(
344 fidl::encoding::EmptyPayload,
345 fidl::encoding::DefaultFuchsiaResourceDialect
346 );
347 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
348 let control_handle =
349 SerialLogControlControlHandle { inner: this.inner.clone() };
350 Ok(SerialLogControlRequest::FreezeSerialForwarding {
351 responder: SerialLogControlFreezeSerialForwardingResponder {
352 control_handle: std::mem::ManuallyDrop::new(control_handle),
353 tx_id: header.tx_id,
354 },
355 })
356 }
357 _ if header.tx_id == 0
358 && header
359 .dynamic_flags()
360 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
361 {
362 Ok(SerialLogControlRequest::_UnknownMethod {
363 ordinal: header.ordinal,
364 control_handle: SerialLogControlControlHandle {
365 inner: this.inner.clone(),
366 },
367 method_type: fidl::MethodType::OneWay,
368 })
369 }
370 _ if header
371 .dynamic_flags()
372 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
373 {
374 this.inner.send_framework_err(
375 fidl::encoding::FrameworkErr::UnknownMethod,
376 header.tx_id,
377 header.ordinal,
378 header.dynamic_flags(),
379 (bytes, handles),
380 )?;
381 Ok(SerialLogControlRequest::_UnknownMethod {
382 ordinal: header.ordinal,
383 control_handle: SerialLogControlControlHandle {
384 inner: this.inner.clone(),
385 },
386 method_type: fidl::MethodType::TwoWay,
387 })
388 }
389 _ => Err(fidl::Error::UnknownOrdinal {
390 ordinal: header.ordinal,
391 protocol_name:
392 <SerialLogControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
393 }),
394 }))
395 },
396 )
397 }
398}
399
400#[derive(Debug)]
401pub enum SerialLogControlRequest {
402 FreezeSerialForwarding { responder: SerialLogControlFreezeSerialForwardingResponder },
406 #[non_exhaustive]
408 _UnknownMethod {
409 ordinal: u64,
411 control_handle: SerialLogControlControlHandle,
412 method_type: fidl::MethodType,
413 },
414}
415
416impl SerialLogControlRequest {
417 #[allow(irrefutable_let_patterns)]
418 pub fn into_freeze_serial_forwarding(
419 self,
420 ) -> Option<(SerialLogControlFreezeSerialForwardingResponder)> {
421 if let SerialLogControlRequest::FreezeSerialForwarding { responder } = self {
422 Some((responder))
423 } else {
424 None
425 }
426 }
427
428 pub fn method_name(&self) -> &'static str {
430 match *self {
431 SerialLogControlRequest::FreezeSerialForwarding { .. } => "freeze_serial_forwarding",
432 SerialLogControlRequest::_UnknownMethod {
433 method_type: fidl::MethodType::OneWay,
434 ..
435 } => "unknown one-way method",
436 SerialLogControlRequest::_UnknownMethod {
437 method_type: fidl::MethodType::TwoWay,
438 ..
439 } => "unknown two-way method",
440 }
441 }
442}
443
444#[derive(Debug, Clone)]
445pub struct SerialLogControlControlHandle {
446 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
447}
448
449impl fidl::endpoints::ControlHandle for SerialLogControlControlHandle {
450 fn shutdown(&self) {
451 self.inner.shutdown()
452 }
453 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
454 self.inner.shutdown_with_epitaph(status)
455 }
456
457 fn is_closed(&self) -> bool {
458 self.inner.channel().is_closed()
459 }
460 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
461 self.inner.channel().on_closed()
462 }
463
464 #[cfg(target_os = "fuchsia")]
465 fn signal_peer(
466 &self,
467 clear_mask: zx::Signals,
468 set_mask: zx::Signals,
469 ) -> Result<(), zx_status::Status> {
470 use fidl::Peered;
471 self.inner.channel().signal_peer(clear_mask, set_mask)
472 }
473}
474
475impl SerialLogControlControlHandle {}
476
477#[must_use = "FIDL methods require a response to be sent"]
478#[derive(Debug)]
479pub struct SerialLogControlFreezeSerialForwardingResponder {
480 control_handle: std::mem::ManuallyDrop<SerialLogControlControlHandle>,
481 tx_id: u32,
482}
483
484impl std::ops::Drop for SerialLogControlFreezeSerialForwardingResponder {
488 fn drop(&mut self) {
489 self.control_handle.shutdown();
490 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492 }
493}
494
495impl fidl::endpoints::Responder for SerialLogControlFreezeSerialForwardingResponder {
496 type ControlHandle = SerialLogControlControlHandle;
497
498 fn control_handle(&self) -> &SerialLogControlControlHandle {
499 &self.control_handle
500 }
501
502 fn drop_without_shutdown(mut self) {
503 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505 std::mem::forget(self);
507 }
508}
509
510impl SerialLogControlFreezeSerialForwardingResponder {
511 pub fn send(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
515 let _result = self.send_raw(token);
516 if _result.is_err() {
517 self.control_handle.shutdown();
518 }
519 self.drop_without_shutdown();
520 _result
521 }
522
523 pub fn send_no_shutdown_on_err(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
525 let _result = self.send_raw(token);
526 self.drop_without_shutdown();
527 _result
528 }
529
530 fn send_raw(&self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
531 self.control_handle.inner.send::<fidl::encoding::FlexibleType<
532 SerialLogControlFreezeSerialForwardingResponse,
533 >>(
534 fidl::encoding::Flexible::new((token,)),
535 self.tx_id,
536 0x1904156ca205d617,
537 fidl::encoding::DynamicFlags::FLEXIBLE,
538 )
539 }
540}
541
542mod internal {
543 use super::*;
544
545 impl fidl::encoding::ResourceTypeMarker for SerialLogControlFreezeSerialForwardingResponse {
546 type Borrowed<'a> = &'a mut Self;
547 fn take_or_borrow<'a>(
548 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
549 ) -> Self::Borrowed<'a> {
550 value
551 }
552 }
553
554 unsafe impl fidl::encoding::TypeMarker for SerialLogControlFreezeSerialForwardingResponse {
555 type Owned = Self;
556
557 #[inline(always)]
558 fn inline_align(_context: fidl::encoding::Context) -> usize {
559 4
560 }
561
562 #[inline(always)]
563 fn inline_size(_context: fidl::encoding::Context) -> usize {
564 4
565 }
566 }
567
568 unsafe impl
569 fidl::encoding::Encode<
570 SerialLogControlFreezeSerialForwardingResponse,
571 fidl::encoding::DefaultFuchsiaResourceDialect,
572 > for &mut SerialLogControlFreezeSerialForwardingResponse
573 {
574 #[inline]
575 unsafe fn encode(
576 self,
577 encoder: &mut fidl::encoding::Encoder<
578 '_,
579 fidl::encoding::DefaultFuchsiaResourceDialect,
580 >,
581 offset: usize,
582 _depth: fidl::encoding::Depth,
583 ) -> fidl::Result<()> {
584 encoder.debug_check_bounds::<SerialLogControlFreezeSerialForwardingResponse>(offset);
585 fidl::encoding::Encode::<
587 SerialLogControlFreezeSerialForwardingResponse,
588 fidl::encoding::DefaultFuchsiaResourceDialect,
589 >::encode(
590 (<fidl::encoding::HandleType<
591 fidl::EventPair,
592 { fidl::ObjectType::EVENTPAIR.into_raw() },
593 2147483648,
594 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
595 &mut self.token
596 ),),
597 encoder,
598 offset,
599 _depth,
600 )
601 }
602 }
603 unsafe impl<
604 T0: fidl::encoding::Encode<
605 fidl::encoding::HandleType<
606 fidl::EventPair,
607 { fidl::ObjectType::EVENTPAIR.into_raw() },
608 2147483648,
609 >,
610 fidl::encoding::DefaultFuchsiaResourceDialect,
611 >,
612 >
613 fidl::encoding::Encode<
614 SerialLogControlFreezeSerialForwardingResponse,
615 fidl::encoding::DefaultFuchsiaResourceDialect,
616 > for (T0,)
617 {
618 #[inline]
619 unsafe fn encode(
620 self,
621 encoder: &mut fidl::encoding::Encoder<
622 '_,
623 fidl::encoding::DefaultFuchsiaResourceDialect,
624 >,
625 offset: usize,
626 depth: fidl::encoding::Depth,
627 ) -> fidl::Result<()> {
628 encoder.debug_check_bounds::<SerialLogControlFreezeSerialForwardingResponse>(offset);
629 self.0.encode(encoder, offset + 0, depth)?;
633 Ok(())
634 }
635 }
636
637 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
638 for SerialLogControlFreezeSerialForwardingResponse
639 {
640 #[inline(always)]
641 fn new_empty() -> Self {
642 Self {
643 token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
644 }
645 }
646
647 #[inline]
648 unsafe fn decode(
649 &mut self,
650 decoder: &mut fidl::encoding::Decoder<
651 '_,
652 fidl::encoding::DefaultFuchsiaResourceDialect,
653 >,
654 offset: usize,
655 _depth: fidl::encoding::Depth,
656 ) -> fidl::Result<()> {
657 decoder.debug_check_bounds::<Self>(offset);
658 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
660 Ok(())
661 }
662 }
663}