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_driver_crash_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15#[repr(C)]
16pub struct CrashIntrospectFindDriverCrashRequest {
17 pub process_koid: u64,
18 pub thread_koid: u64,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22 for CrashIntrospectFindDriverCrashRequest
23{
24}
25
26#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
27pub struct CrashIntrospectMarker;
28
29impl fidl::endpoints::ProtocolMarker for CrashIntrospectMarker {
30 type Proxy = CrashIntrospectProxy;
31 type RequestStream = CrashIntrospectRequestStream;
32 #[cfg(target_os = "fuchsia")]
33 type SynchronousProxy = CrashIntrospectSynchronousProxy;
34
35 const DEBUG_NAME: &'static str = "fuchsia.driver.crash.CrashIntrospect";
36}
37impl fidl::endpoints::DiscoverableProtocolMarker for CrashIntrospectMarker {}
38pub type CrashIntrospectFindDriverCrashResult = Result<DriverCrashInfo, i32>;
39
40pub trait CrashIntrospectProxyInterface: Send + Sync {
41 type FindDriverCrashResponseFut: std::future::Future<Output = Result<CrashIntrospectFindDriverCrashResult, fidl::Error>>
42 + Send;
43 fn r#find_driver_crash(
44 &self,
45 process_koid: u64,
46 thread_koid: u64,
47 ) -> Self::FindDriverCrashResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct CrashIntrospectSynchronousProxy {
52 client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for CrashIntrospectSynchronousProxy {
57 type Proxy = CrashIntrospectProxy;
58 type Protocol = CrashIntrospectMarker;
59
60 fn from_channel(inner: fidl::Channel) -> Self {
61 Self::new(inner)
62 }
63
64 fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 fn as_channel(&self) -> &fidl::Channel {
69 self.client.as_channel()
70 }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl CrashIntrospectSynchronousProxy {
75 pub fn new(channel: fidl::Channel) -> Self {
76 Self { client: fidl::client::sync::Client::new(channel) }
77 }
78
79 pub fn into_channel(self) -> fidl::Channel {
80 self.client.into_channel()
81 }
82
83 pub fn wait_for_event(
86 &self,
87 deadline: zx::MonotonicInstant,
88 ) -> Result<CrashIntrospectEvent, fidl::Error> {
89 CrashIntrospectEvent::decode(self.client.wait_for_event::<CrashIntrospectMarker>(deadline)?)
90 }
91
92 pub fn r#find_driver_crash(
100 &self,
101 mut process_koid: u64,
102 mut thread_koid: u64,
103 ___deadline: zx::MonotonicInstant,
104 ) -> Result<CrashIntrospectFindDriverCrashResult, fidl::Error> {
105 let _response = self.client.send_query::<
106 CrashIntrospectFindDriverCrashRequest,
107 fidl::encoding::ResultType<CrashIntrospectFindDriverCrashResponse, i32>,
108 CrashIntrospectMarker,
109 >(
110 (process_koid, thread_koid,),
111 0x41237ffcc46267bc,
112 fidl::encoding::DynamicFlags::empty(),
113 ___deadline,
114 )?;
115 Ok(_response.map(|x| x.info))
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<CrashIntrospectSynchronousProxy> for zx::NullableHandle {
121 fn from(value: CrashIntrospectSynchronousProxy) -> Self {
122 value.into_channel().into()
123 }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl From<fidl::Channel> for CrashIntrospectSynchronousProxy {
128 fn from(value: fidl::Channel) -> Self {
129 Self::new(value)
130 }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl fidl::endpoints::FromClient for CrashIntrospectSynchronousProxy {
135 type Protocol = CrashIntrospectMarker;
136
137 fn from_client(value: fidl::endpoints::ClientEnd<CrashIntrospectMarker>) -> Self {
138 Self::new(value.into_channel())
139 }
140}
141
142#[derive(Debug, Clone)]
143pub struct CrashIntrospectProxy {
144 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
145}
146
147impl fidl::endpoints::Proxy for CrashIntrospectProxy {
148 type Protocol = CrashIntrospectMarker;
149
150 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
151 Self::new(inner)
152 }
153
154 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
155 self.client.into_channel().map_err(|client| Self { client })
156 }
157
158 fn as_channel(&self) -> &::fidl::AsyncChannel {
159 self.client.as_channel()
160 }
161}
162
163impl CrashIntrospectProxy {
164 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
166 let protocol_name = <CrashIntrospectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
167 Self { client: fidl::client::Client::new(channel, protocol_name) }
168 }
169
170 pub fn take_event_stream(&self) -> CrashIntrospectEventStream {
176 CrashIntrospectEventStream { event_receiver: self.client.take_event_receiver() }
177 }
178
179 pub fn r#find_driver_crash(
187 &self,
188 mut process_koid: u64,
189 mut thread_koid: u64,
190 ) -> fidl::client::QueryResponseFut<
191 CrashIntrospectFindDriverCrashResult,
192 fidl::encoding::DefaultFuchsiaResourceDialect,
193 > {
194 CrashIntrospectProxyInterface::r#find_driver_crash(self, process_koid, thread_koid)
195 }
196}
197
198impl CrashIntrospectProxyInterface for CrashIntrospectProxy {
199 type FindDriverCrashResponseFut = fidl::client::QueryResponseFut<
200 CrashIntrospectFindDriverCrashResult,
201 fidl::encoding::DefaultFuchsiaResourceDialect,
202 >;
203 fn r#find_driver_crash(
204 &self,
205 mut process_koid: u64,
206 mut thread_koid: u64,
207 ) -> Self::FindDriverCrashResponseFut {
208 fn _decode(
209 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
210 ) -> Result<CrashIntrospectFindDriverCrashResult, fidl::Error> {
211 let _response = fidl::client::decode_transaction_body::<
212 fidl::encoding::ResultType<CrashIntrospectFindDriverCrashResponse, i32>,
213 fidl::encoding::DefaultFuchsiaResourceDialect,
214 0x41237ffcc46267bc,
215 >(_buf?)?;
216 Ok(_response.map(|x| x.info))
217 }
218 self.client.send_query_and_decode::<
219 CrashIntrospectFindDriverCrashRequest,
220 CrashIntrospectFindDriverCrashResult,
221 >(
222 (process_koid, thread_koid,),
223 0x41237ffcc46267bc,
224 fidl::encoding::DynamicFlags::empty(),
225 _decode,
226 )
227 }
228}
229
230pub struct CrashIntrospectEventStream {
231 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
232}
233
234impl std::marker::Unpin for CrashIntrospectEventStream {}
235
236impl futures::stream::FusedStream for CrashIntrospectEventStream {
237 fn is_terminated(&self) -> bool {
238 self.event_receiver.is_terminated()
239 }
240}
241
242impl futures::Stream for CrashIntrospectEventStream {
243 type Item = Result<CrashIntrospectEvent, fidl::Error>;
244
245 fn poll_next(
246 mut self: std::pin::Pin<&mut Self>,
247 cx: &mut std::task::Context<'_>,
248 ) -> std::task::Poll<Option<Self::Item>> {
249 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
250 &mut self.event_receiver,
251 cx
252 )?) {
253 Some(buf) => std::task::Poll::Ready(Some(CrashIntrospectEvent::decode(buf))),
254 None => std::task::Poll::Ready(None),
255 }
256 }
257}
258
259#[derive(Debug)]
260pub enum CrashIntrospectEvent {}
261
262impl CrashIntrospectEvent {
263 fn decode(
265 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
266 ) -> Result<CrashIntrospectEvent, fidl::Error> {
267 let (bytes, _handles) = buf.split_mut();
268 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
269 debug_assert_eq!(tx_header.tx_id, 0);
270 match tx_header.ordinal {
271 _ => Err(fidl::Error::UnknownOrdinal {
272 ordinal: tx_header.ordinal,
273 protocol_name:
274 <CrashIntrospectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
275 }),
276 }
277 }
278}
279
280pub struct CrashIntrospectRequestStream {
282 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
283 is_terminated: bool,
284}
285
286impl std::marker::Unpin for CrashIntrospectRequestStream {}
287
288impl futures::stream::FusedStream for CrashIntrospectRequestStream {
289 fn is_terminated(&self) -> bool {
290 self.is_terminated
291 }
292}
293
294impl fidl::endpoints::RequestStream for CrashIntrospectRequestStream {
295 type Protocol = CrashIntrospectMarker;
296 type ControlHandle = CrashIntrospectControlHandle;
297
298 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
299 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
300 }
301
302 fn control_handle(&self) -> Self::ControlHandle {
303 CrashIntrospectControlHandle { inner: self.inner.clone() }
304 }
305
306 fn into_inner(
307 self,
308 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
309 {
310 (self.inner, self.is_terminated)
311 }
312
313 fn from_inner(
314 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
315 is_terminated: bool,
316 ) -> Self {
317 Self { inner, is_terminated }
318 }
319}
320
321impl futures::Stream for CrashIntrospectRequestStream {
322 type Item = Result<CrashIntrospectRequest, fidl::Error>;
323
324 fn poll_next(
325 mut self: std::pin::Pin<&mut Self>,
326 cx: &mut std::task::Context<'_>,
327 ) -> std::task::Poll<Option<Self::Item>> {
328 let this = &mut *self;
329 if this.inner.check_shutdown(cx) {
330 this.is_terminated = true;
331 return std::task::Poll::Ready(None);
332 }
333 if this.is_terminated {
334 panic!("polled CrashIntrospectRequestStream after completion");
335 }
336 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
337 |bytes, handles| {
338 match this.inner.channel().read_etc(cx, bytes, handles) {
339 std::task::Poll::Ready(Ok(())) => {}
340 std::task::Poll::Pending => return std::task::Poll::Pending,
341 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
342 this.is_terminated = true;
343 return std::task::Poll::Ready(None);
344 }
345 std::task::Poll::Ready(Err(e)) => {
346 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
347 e.into(),
348 ))));
349 }
350 }
351
352 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
354
355 std::task::Poll::Ready(Some(match header.ordinal {
356 0x41237ffcc46267bc => {
357 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
358 let mut req = fidl::new_empty!(
359 CrashIntrospectFindDriverCrashRequest,
360 fidl::encoding::DefaultFuchsiaResourceDialect
361 );
362 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CrashIntrospectFindDriverCrashRequest>(&header, _body_bytes, handles, &mut req)?;
363 let control_handle =
364 CrashIntrospectControlHandle { inner: this.inner.clone() };
365 Ok(CrashIntrospectRequest::FindDriverCrash {
366 process_koid: req.process_koid,
367 thread_koid: req.thread_koid,
368
369 responder: CrashIntrospectFindDriverCrashResponder {
370 control_handle: std::mem::ManuallyDrop::new(control_handle),
371 tx_id: header.tx_id,
372 },
373 })
374 }
375 _ => Err(fidl::Error::UnknownOrdinal {
376 ordinal: header.ordinal,
377 protocol_name:
378 <CrashIntrospectMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
379 }),
380 }))
381 },
382 )
383 }
384}
385
386#[derive(Debug)]
390pub enum CrashIntrospectRequest {
391 FindDriverCrash {
399 process_koid: u64,
400 thread_koid: u64,
401 responder: CrashIntrospectFindDriverCrashResponder,
402 },
403}
404
405impl CrashIntrospectRequest {
406 #[allow(irrefutable_let_patterns)]
407 pub fn into_find_driver_crash(
408 self,
409 ) -> Option<(u64, u64, CrashIntrospectFindDriverCrashResponder)> {
410 if let CrashIntrospectRequest::FindDriverCrash { process_koid, thread_koid, responder } =
411 self
412 {
413 Some((process_koid, thread_koid, responder))
414 } else {
415 None
416 }
417 }
418
419 pub fn method_name(&self) -> &'static str {
421 match *self {
422 CrashIntrospectRequest::FindDriverCrash { .. } => "find_driver_crash",
423 }
424 }
425}
426
427#[derive(Debug, Clone)]
428pub struct CrashIntrospectControlHandle {
429 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
430}
431
432impl CrashIntrospectControlHandle {
433 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
434 self.inner.shutdown_with_epitaph(status.into())
435 }
436}
437
438impl fidl::endpoints::ControlHandle for CrashIntrospectControlHandle {
439 fn shutdown(&self) {
440 self.inner.shutdown()
441 }
442
443 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
444 self.inner.shutdown_with_epitaph(status)
445 }
446
447 fn is_closed(&self) -> bool {
448 self.inner.channel().is_closed()
449 }
450 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
451 self.inner.channel().on_closed()
452 }
453
454 #[cfg(target_os = "fuchsia")]
455 fn signal_peer(
456 &self,
457 clear_mask: zx::Signals,
458 set_mask: zx::Signals,
459 ) -> Result<(), zx_status::Status> {
460 use fidl::Peered;
461 self.inner.channel().signal_peer(clear_mask, set_mask)
462 }
463}
464
465impl CrashIntrospectControlHandle {}
466
467#[must_use = "FIDL methods require a response to be sent"]
468#[derive(Debug)]
469pub struct CrashIntrospectFindDriverCrashResponder {
470 control_handle: std::mem::ManuallyDrop<CrashIntrospectControlHandle>,
471 tx_id: u32,
472}
473
474impl std::ops::Drop for CrashIntrospectFindDriverCrashResponder {
478 fn drop(&mut self) {
479 self.control_handle.shutdown();
480 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
482 }
483}
484
485impl fidl::endpoints::Responder for CrashIntrospectFindDriverCrashResponder {
486 type ControlHandle = CrashIntrospectControlHandle;
487
488 fn control_handle(&self) -> &CrashIntrospectControlHandle {
489 &self.control_handle
490 }
491
492 fn drop_without_shutdown(mut self) {
493 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
495 std::mem::forget(self);
497 }
498}
499
500impl CrashIntrospectFindDriverCrashResponder {
501 pub fn send(self, mut result: Result<&DriverCrashInfo, i32>) -> Result<(), fidl::Error> {
505 let _result = self.send_raw(result);
506 if _result.is_err() {
507 self.control_handle.shutdown();
508 }
509 self.drop_without_shutdown();
510 _result
511 }
512
513 pub fn send_no_shutdown_on_err(
515 self,
516 mut result: Result<&DriverCrashInfo, i32>,
517 ) -> Result<(), fidl::Error> {
518 let _result = self.send_raw(result);
519 self.drop_without_shutdown();
520 _result
521 }
522
523 fn send_raw(&self, mut result: Result<&DriverCrashInfo, i32>) -> Result<(), fidl::Error> {
524 self.control_handle.inner.send::<fidl::encoding::ResultType<
525 CrashIntrospectFindDriverCrashResponse,
526 i32,
527 >>(
528 result.map(|info| (info,)),
529 self.tx_id,
530 0x41237ffcc46267bc,
531 fidl::encoding::DynamicFlags::empty(),
532 )
533 }
534}
535
536mod internal {
537 use super::*;
538
539 impl fidl::encoding::ResourceTypeMarker for CrashIntrospectFindDriverCrashRequest {
540 type Borrowed<'a> = &'a mut Self;
541 fn take_or_borrow<'a>(
542 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
543 ) -> Self::Borrowed<'a> {
544 value
545 }
546 }
547
548 unsafe impl fidl::encoding::TypeMarker for CrashIntrospectFindDriverCrashRequest {
549 type Owned = Self;
550
551 #[inline(always)]
552 fn inline_align(_context: fidl::encoding::Context) -> usize {
553 8
554 }
555
556 #[inline(always)]
557 fn inline_size(_context: fidl::encoding::Context) -> usize {
558 16
559 }
560 #[inline(always)]
561 fn encode_is_copy() -> bool {
562 true
563 }
564
565 #[inline(always)]
566 fn decode_is_copy() -> bool {
567 true
568 }
569 }
570
571 unsafe impl
572 fidl::encoding::Encode<
573 CrashIntrospectFindDriverCrashRequest,
574 fidl::encoding::DefaultFuchsiaResourceDialect,
575 > for &mut CrashIntrospectFindDriverCrashRequest
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::<CrashIntrospectFindDriverCrashRequest>(offset);
588 unsafe {
589 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
591 (buf_ptr as *mut CrashIntrospectFindDriverCrashRequest)
592 .write_unaligned((self as *const CrashIntrospectFindDriverCrashRequest).read());
593 }
596 Ok(())
597 }
598 }
599 unsafe impl<
600 T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
601 T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
602 >
603 fidl::encoding::Encode<
604 CrashIntrospectFindDriverCrashRequest,
605 fidl::encoding::DefaultFuchsiaResourceDialect,
606 > for (T0, T1)
607 {
608 #[inline]
609 unsafe fn encode(
610 self,
611 encoder: &mut fidl::encoding::Encoder<
612 '_,
613 fidl::encoding::DefaultFuchsiaResourceDialect,
614 >,
615 offset: usize,
616 depth: fidl::encoding::Depth,
617 ) -> fidl::Result<()> {
618 encoder.debug_check_bounds::<CrashIntrospectFindDriverCrashRequest>(offset);
619 self.0.encode(encoder, offset + 0, depth)?;
623 self.1.encode(encoder, offset + 8, depth)?;
624 Ok(())
625 }
626 }
627
628 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
629 for CrashIntrospectFindDriverCrashRequest
630 {
631 #[inline(always)]
632 fn new_empty() -> Self {
633 Self {
634 process_koid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
635 thread_koid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
636 }
637 }
638
639 #[inline]
640 unsafe fn decode(
641 &mut self,
642 decoder: &mut fidl::encoding::Decoder<
643 '_,
644 fidl::encoding::DefaultFuchsiaResourceDialect,
645 >,
646 offset: usize,
647 _depth: fidl::encoding::Depth,
648 ) -> fidl::Result<()> {
649 decoder.debug_check_bounds::<Self>(offset);
650 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
651 unsafe {
654 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
655 }
656 Ok(())
657 }
658 }
659}