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_memory_stacktrack_process__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct RegistryRegisterV1Request {
16 pub process: fidl::Process,
17 pub threads_table_vmo: fidl::Vmo,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for RegistryRegisterV1Request {}
21
22#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
23pub struct RegistryMarker;
24
25impl fidl::endpoints::ProtocolMarker for RegistryMarker {
26 type Proxy = RegistryProxy;
27 type RequestStream = RegistryRequestStream;
28 #[cfg(target_os = "fuchsia")]
29 type SynchronousProxy = RegistrySynchronousProxy;
30
31 const DEBUG_NAME: &'static str = "fuchsia.memory.stacktrack.process.Registry";
32}
33impl fidl::endpoints::DiscoverableProtocolMarker for RegistryMarker {}
34
35pub trait RegistryProxyInterface: Send + Sync {
36 fn r#register_v1(
37 &self,
38 process: fidl::Process,
39 threads_table_vmo: fidl::Vmo,
40 ) -> Result<(), fidl::Error>;
41}
42#[derive(Debug)]
43#[cfg(target_os = "fuchsia")]
44pub struct RegistrySynchronousProxy {
45 client: fidl::client::sync::Client,
46}
47
48#[cfg(target_os = "fuchsia")]
49impl fidl::endpoints::SynchronousProxy for RegistrySynchronousProxy {
50 type Proxy = RegistryProxy;
51 type Protocol = RegistryMarker;
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 RegistrySynchronousProxy {
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<RegistryEvent, fidl::Error> {
82 RegistryEvent::decode(self.client.wait_for_event::<RegistryMarker>(deadline)?)
83 }
84
85 pub fn r#register_v1(
91 &self,
92 mut process: fidl::Process,
93 mut threads_table_vmo: fidl::Vmo,
94 ) -> Result<(), fidl::Error> {
95 self.client.send::<RegistryRegisterV1Request>(
96 (process, threads_table_vmo),
97 0x125ecfa91eacf01b,
98 fidl::encoding::DynamicFlags::empty(),
99 )
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<RegistrySynchronousProxy> for zx::NullableHandle {
105 fn from(value: RegistrySynchronousProxy) -> Self {
106 value.into_channel().into()
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<fidl::Channel> for RegistrySynchronousProxy {
112 fn from(value: fidl::Channel) -> Self {
113 Self::new(value)
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl fidl::endpoints::FromClient for RegistrySynchronousProxy {
119 type Protocol = RegistryMarker;
120
121 fn from_client(value: fidl::endpoints::ClientEnd<RegistryMarker>) -> Self {
122 Self::new(value.into_channel())
123 }
124}
125
126#[derive(Debug, Clone)]
127pub struct RegistryProxy {
128 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
129}
130
131impl fidl::endpoints::Proxy for RegistryProxy {
132 type Protocol = RegistryMarker;
133
134 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
135 Self::new(inner)
136 }
137
138 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
139 self.client.into_channel().map_err(|client| Self { client })
140 }
141
142 fn as_channel(&self) -> &::fidl::AsyncChannel {
143 self.client.as_channel()
144 }
145}
146
147impl RegistryProxy {
148 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
150 let protocol_name = <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
151 Self { client: fidl::client::Client::new(channel, protocol_name) }
152 }
153
154 pub fn take_event_stream(&self) -> RegistryEventStream {
160 RegistryEventStream { event_receiver: self.client.take_event_receiver() }
161 }
162
163 pub fn r#register_v1(
169 &self,
170 mut process: fidl::Process,
171 mut threads_table_vmo: fidl::Vmo,
172 ) -> Result<(), fidl::Error> {
173 RegistryProxyInterface::r#register_v1(self, process, threads_table_vmo)
174 }
175}
176
177impl RegistryProxyInterface for RegistryProxy {
178 fn r#register_v1(
179 &self,
180 mut process: fidl::Process,
181 mut threads_table_vmo: fidl::Vmo,
182 ) -> Result<(), fidl::Error> {
183 self.client.send::<RegistryRegisterV1Request>(
184 (process, threads_table_vmo),
185 0x125ecfa91eacf01b,
186 fidl::encoding::DynamicFlags::empty(),
187 )
188 }
189}
190
191pub struct RegistryEventStream {
192 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
193}
194
195impl std::marker::Unpin for RegistryEventStream {}
196
197impl futures::stream::FusedStream for RegistryEventStream {
198 fn is_terminated(&self) -> bool {
199 self.event_receiver.is_terminated()
200 }
201}
202
203impl futures::Stream for RegistryEventStream {
204 type Item = Result<RegistryEvent, fidl::Error>;
205
206 fn poll_next(
207 mut self: std::pin::Pin<&mut Self>,
208 cx: &mut std::task::Context<'_>,
209 ) -> std::task::Poll<Option<Self::Item>> {
210 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
211 &mut self.event_receiver,
212 cx
213 )?) {
214 Some(buf) => std::task::Poll::Ready(Some(RegistryEvent::decode(buf))),
215 None => std::task::Poll::Ready(None),
216 }
217 }
218}
219
220#[derive(Debug)]
221pub enum RegistryEvent {
222 #[non_exhaustive]
223 _UnknownEvent {
224 ordinal: u64,
226 },
227}
228
229impl RegistryEvent {
230 fn decode(
232 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
233 ) -> Result<RegistryEvent, fidl::Error> {
234 let (bytes, _handles) = buf.split_mut();
235 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
236 debug_assert_eq!(tx_header.tx_id, 0);
237 match tx_header.ordinal {
238 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
239 Ok(RegistryEvent::_UnknownEvent { ordinal: tx_header.ordinal })
240 }
241 _ => Err(fidl::Error::UnknownOrdinal {
242 ordinal: tx_header.ordinal,
243 protocol_name: <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
244 }),
245 }
246 }
247}
248
249pub struct RegistryRequestStream {
251 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
252 is_terminated: bool,
253}
254
255impl std::marker::Unpin for RegistryRequestStream {}
256
257impl futures::stream::FusedStream for RegistryRequestStream {
258 fn is_terminated(&self) -> bool {
259 self.is_terminated
260 }
261}
262
263impl fidl::endpoints::RequestStream for RegistryRequestStream {
264 type Protocol = RegistryMarker;
265 type ControlHandle = RegistryControlHandle;
266
267 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
268 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
269 }
270
271 fn control_handle(&self) -> Self::ControlHandle {
272 RegistryControlHandle { inner: self.inner.clone() }
273 }
274
275 fn into_inner(
276 self,
277 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
278 {
279 (self.inner, self.is_terminated)
280 }
281
282 fn from_inner(
283 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
284 is_terminated: bool,
285 ) -> Self {
286 Self { inner, is_terminated }
287 }
288}
289
290impl futures::Stream for RegistryRequestStream {
291 type Item = Result<RegistryRequest, fidl::Error>;
292
293 fn poll_next(
294 mut self: std::pin::Pin<&mut Self>,
295 cx: &mut std::task::Context<'_>,
296 ) -> std::task::Poll<Option<Self::Item>> {
297 let this = &mut *self;
298 if this.inner.check_shutdown(cx) {
299 this.is_terminated = true;
300 return std::task::Poll::Ready(None);
301 }
302 if this.is_terminated {
303 panic!("polled RegistryRequestStream after completion");
304 }
305 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
306 |bytes, handles| {
307 match this.inner.channel().read_etc(cx, bytes, handles) {
308 std::task::Poll::Ready(Ok(())) => {}
309 std::task::Poll::Pending => return std::task::Poll::Pending,
310 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
311 this.is_terminated = true;
312 return std::task::Poll::Ready(None);
313 }
314 std::task::Poll::Ready(Err(e)) => {
315 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
316 e.into(),
317 ))));
318 }
319 }
320
321 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
323
324 std::task::Poll::Ready(Some(match header.ordinal {
325 0x125ecfa91eacf01b => {
326 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
327 let mut req = fidl::new_empty!(
328 RegistryRegisterV1Request,
329 fidl::encoding::DefaultFuchsiaResourceDialect
330 );
331 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RegistryRegisterV1Request>(&header, _body_bytes, handles, &mut req)?;
332 let control_handle = RegistryControlHandle { inner: this.inner.clone() };
333 Ok(RegistryRequest::RegisterV1 {
334 process: req.process,
335 threads_table_vmo: req.threads_table_vmo,
336
337 control_handle,
338 })
339 }
340 _ if header.tx_id == 0
341 && header
342 .dynamic_flags()
343 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
344 {
345 Ok(RegistryRequest::_UnknownMethod {
346 ordinal: header.ordinal,
347 control_handle: RegistryControlHandle { inner: this.inner.clone() },
348 method_type: fidl::MethodType::OneWay,
349 })
350 }
351 _ if header
352 .dynamic_flags()
353 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
354 {
355 this.inner.send_framework_err(
356 fidl::encoding::FrameworkErr::UnknownMethod,
357 header.tx_id,
358 header.ordinal,
359 header.dynamic_flags(),
360 (bytes, handles),
361 )?;
362 Ok(RegistryRequest::_UnknownMethod {
363 ordinal: header.ordinal,
364 control_handle: RegistryControlHandle { inner: this.inner.clone() },
365 method_type: fidl::MethodType::TwoWay,
366 })
367 }
368 _ => Err(fidl::Error::UnknownOrdinal {
369 ordinal: header.ordinal,
370 protocol_name:
371 <RegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
372 }),
373 }))
374 },
375 )
376 }
377}
378
379#[derive(Debug)]
381pub enum RegistryRequest {
382 RegisterV1 {
388 process: fidl::Process,
389 threads_table_vmo: fidl::Vmo,
390 control_handle: RegistryControlHandle,
391 },
392 #[non_exhaustive]
394 _UnknownMethod {
395 ordinal: u64,
397 control_handle: RegistryControlHandle,
398 method_type: fidl::MethodType,
399 },
400}
401
402impl RegistryRequest {
403 #[allow(irrefutable_let_patterns)]
404 pub fn into_register_v1(self) -> Option<(fidl::Process, fidl::Vmo, RegistryControlHandle)> {
405 if let RegistryRequest::RegisterV1 { process, threads_table_vmo, control_handle } = self {
406 Some((process, threads_table_vmo, control_handle))
407 } else {
408 None
409 }
410 }
411
412 pub fn method_name(&self) -> &'static str {
414 match *self {
415 RegistryRequest::RegisterV1 { .. } => "register_v1",
416 RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
417 "unknown one-way method"
418 }
419 RegistryRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
420 "unknown two-way method"
421 }
422 }
423 }
424}
425
426#[derive(Debug, Clone)]
427pub struct RegistryControlHandle {
428 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
429}
430
431impl fidl::endpoints::ControlHandle for RegistryControlHandle {
432 fn shutdown(&self) {
433 self.inner.shutdown()
434 }
435
436 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
437 self.inner.shutdown_with_epitaph(status)
438 }
439
440 fn is_closed(&self) -> bool {
441 self.inner.channel().is_closed()
442 }
443 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
444 self.inner.channel().on_closed()
445 }
446
447 #[cfg(target_os = "fuchsia")]
448 fn signal_peer(
449 &self,
450 clear_mask: zx::Signals,
451 set_mask: zx::Signals,
452 ) -> Result<(), zx_status::Status> {
453 use fidl::Peered;
454 self.inner.channel().signal_peer(clear_mask, set_mask)
455 }
456}
457
458impl RegistryControlHandle {}
459
460mod internal {
461 use super::*;
462
463 impl fidl::encoding::ResourceTypeMarker for RegistryRegisterV1Request {
464 type Borrowed<'a> = &'a mut Self;
465 fn take_or_borrow<'a>(
466 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
467 ) -> Self::Borrowed<'a> {
468 value
469 }
470 }
471
472 unsafe impl fidl::encoding::TypeMarker for RegistryRegisterV1Request {
473 type Owned = Self;
474
475 #[inline(always)]
476 fn inline_align(_context: fidl::encoding::Context) -> usize {
477 4
478 }
479
480 #[inline(always)]
481 fn inline_size(_context: fidl::encoding::Context) -> usize {
482 8
483 }
484 }
485
486 unsafe impl
487 fidl::encoding::Encode<
488 RegistryRegisterV1Request,
489 fidl::encoding::DefaultFuchsiaResourceDialect,
490 > for &mut RegistryRegisterV1Request
491 {
492 #[inline]
493 unsafe fn encode(
494 self,
495 encoder: &mut fidl::encoding::Encoder<
496 '_,
497 fidl::encoding::DefaultFuchsiaResourceDialect,
498 >,
499 offset: usize,
500 _depth: fidl::encoding::Depth,
501 ) -> fidl::Result<()> {
502 encoder.debug_check_bounds::<RegistryRegisterV1Request>(offset);
503 fidl::encoding::Encode::<
505 RegistryRegisterV1Request,
506 fidl::encoding::DefaultFuchsiaResourceDialect,
507 >::encode(
508 (
509 <fidl::encoding::HandleType<
510 fidl::Process,
511 { fidl::ObjectType::PROCESS.into_raw() },
512 49231,
513 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
514 &mut self.process
515 ),
516 <fidl::encoding::HandleType<
517 fidl::Vmo,
518 { fidl::ObjectType::VMO.into_raw() },
519 49255,
520 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
521 &mut self.threads_table_vmo,
522 ),
523 ),
524 encoder,
525 offset,
526 _depth,
527 )
528 }
529 }
530 unsafe impl<
531 T0: fidl::encoding::Encode<
532 fidl::encoding::HandleType<
533 fidl::Process,
534 { fidl::ObjectType::PROCESS.into_raw() },
535 49231,
536 >,
537 fidl::encoding::DefaultFuchsiaResourceDialect,
538 >,
539 T1: fidl::encoding::Encode<
540 fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>,
541 fidl::encoding::DefaultFuchsiaResourceDialect,
542 >,
543 >
544 fidl::encoding::Encode<
545 RegistryRegisterV1Request,
546 fidl::encoding::DefaultFuchsiaResourceDialect,
547 > for (T0, T1)
548 {
549 #[inline]
550 unsafe fn encode(
551 self,
552 encoder: &mut fidl::encoding::Encoder<
553 '_,
554 fidl::encoding::DefaultFuchsiaResourceDialect,
555 >,
556 offset: usize,
557 depth: fidl::encoding::Depth,
558 ) -> fidl::Result<()> {
559 encoder.debug_check_bounds::<RegistryRegisterV1Request>(offset);
560 self.0.encode(encoder, offset + 0, depth)?;
564 self.1.encode(encoder, offset + 4, depth)?;
565 Ok(())
566 }
567 }
568
569 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
570 for RegistryRegisterV1Request
571 {
572 #[inline(always)]
573 fn new_empty() -> Self {
574 Self {
575 process: fidl::new_empty!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 49231>, fidl::encoding::DefaultFuchsiaResourceDialect),
576 threads_table_vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>, fidl::encoding::DefaultFuchsiaResourceDialect),
577 }
578 }
579
580 #[inline]
581 unsafe fn decode(
582 &mut self,
583 decoder: &mut fidl::encoding::Decoder<
584 '_,
585 fidl::encoding::DefaultFuchsiaResourceDialect,
586 >,
587 offset: usize,
588 _depth: fidl::encoding::Depth,
589 ) -> fidl::Result<()> {
590 decoder.debug_check_bounds::<Self>(offset);
591 fidl::decode!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 49231>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.process, decoder, offset + 0, _depth)?;
593 fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 49255>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.threads_table_vmo, decoder, offset + 4, _depth)?;
594 Ok(())
595 }
596 }
597}