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