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_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15#[repr(C)]
16pub struct ThreadKoidReporterReportMyThreadKoidRequest {
17 pub thread_koid: u64,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21 for ThreadKoidReporterReportMyThreadKoidRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct ThreadKoidReporterMarker;
27
28impl fidl::endpoints::ProtocolMarker for ThreadKoidReporterMarker {
29 type Proxy = ThreadKoidReporterProxy;
30 type RequestStream = ThreadKoidReporterRequestStream;
31 #[cfg(target_os = "fuchsia")]
32 type SynchronousProxy = ThreadKoidReporterSynchronousProxy;
33
34 const DEBUG_NAME: &'static str = "fuchsia.test.ThreadKoidReporter";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for ThreadKoidReporterMarker {}
37
38pub trait ThreadKoidReporterProxyInterface: Send + Sync {
39 fn r#report_my_thread_koid(&self, thread_koid: u64) -> Result<(), fidl::Error>;
40}
41#[derive(Debug)]
42#[cfg(target_os = "fuchsia")]
43pub struct ThreadKoidReporterSynchronousProxy {
44 client: fidl::client::sync::Client,
45}
46
47#[cfg(target_os = "fuchsia")]
48impl fidl::endpoints::SynchronousProxy for ThreadKoidReporterSynchronousProxy {
49 type Proxy = ThreadKoidReporterProxy;
50 type Protocol = ThreadKoidReporterMarker;
51
52 fn from_channel(inner: fidl::Channel) -> Self {
53 Self::new(inner)
54 }
55
56 fn into_channel(self) -> fidl::Channel {
57 self.client.into_channel()
58 }
59
60 fn as_channel(&self) -> &fidl::Channel {
61 self.client.as_channel()
62 }
63}
64
65#[cfg(target_os = "fuchsia")]
66impl ThreadKoidReporterSynchronousProxy {
67 pub fn new(channel: fidl::Channel) -> Self {
68 let protocol_name =
69 <ThreadKoidReporterMarker 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<ThreadKoidReporterEvent, fidl::Error> {
83 ThreadKoidReporterEvent::decode(self.client.wait_for_event(deadline)?)
84 }
85
86 pub fn r#report_my_thread_koid(&self, mut thread_koid: u64) -> Result<(), fidl::Error> {
88 self.client.send::<ThreadKoidReporterReportMyThreadKoidRequest>(
89 (thread_koid,),
90 0x58cb9144fdb465d0,
91 fidl::encoding::DynamicFlags::empty(),
92 )
93 }
94}
95
96#[cfg(target_os = "fuchsia")]
97impl From<ThreadKoidReporterSynchronousProxy> for zx::Handle {
98 fn from(value: ThreadKoidReporterSynchronousProxy) -> Self {
99 value.into_channel().into()
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<fidl::Channel> for ThreadKoidReporterSynchronousProxy {
105 fn from(value: fidl::Channel) -> Self {
106 Self::new(value)
107 }
108}
109
110#[derive(Debug, Clone)]
111pub struct ThreadKoidReporterProxy {
112 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
113}
114
115impl fidl::endpoints::Proxy for ThreadKoidReporterProxy {
116 type Protocol = ThreadKoidReporterMarker;
117
118 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
119 Self::new(inner)
120 }
121
122 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
123 self.client.into_channel().map_err(|client| Self { client })
124 }
125
126 fn as_channel(&self) -> &::fidl::AsyncChannel {
127 self.client.as_channel()
128 }
129}
130
131impl ThreadKoidReporterProxy {
132 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
134 let protocol_name =
135 <ThreadKoidReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
136 Self { client: fidl::client::Client::new(channel, protocol_name) }
137 }
138
139 pub fn take_event_stream(&self) -> ThreadKoidReporterEventStream {
145 ThreadKoidReporterEventStream { event_receiver: self.client.take_event_receiver() }
146 }
147
148 pub fn r#report_my_thread_koid(&self, mut thread_koid: u64) -> Result<(), fidl::Error> {
150 ThreadKoidReporterProxyInterface::r#report_my_thread_koid(self, thread_koid)
151 }
152}
153
154impl ThreadKoidReporterProxyInterface for ThreadKoidReporterProxy {
155 fn r#report_my_thread_koid(&self, mut thread_koid: u64) -> Result<(), fidl::Error> {
156 self.client.send::<ThreadKoidReporterReportMyThreadKoidRequest>(
157 (thread_koid,),
158 0x58cb9144fdb465d0,
159 fidl::encoding::DynamicFlags::empty(),
160 )
161 }
162}
163
164pub struct ThreadKoidReporterEventStream {
165 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
166}
167
168impl std::marker::Unpin for ThreadKoidReporterEventStream {}
169
170impl futures::stream::FusedStream for ThreadKoidReporterEventStream {
171 fn is_terminated(&self) -> bool {
172 self.event_receiver.is_terminated()
173 }
174}
175
176impl futures::Stream for ThreadKoidReporterEventStream {
177 type Item = Result<ThreadKoidReporterEvent, fidl::Error>;
178
179 fn poll_next(
180 mut self: std::pin::Pin<&mut Self>,
181 cx: &mut std::task::Context<'_>,
182 ) -> std::task::Poll<Option<Self::Item>> {
183 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
184 &mut self.event_receiver,
185 cx
186 )?) {
187 Some(buf) => std::task::Poll::Ready(Some(ThreadKoidReporterEvent::decode(buf))),
188 None => std::task::Poll::Ready(None),
189 }
190 }
191}
192
193#[derive(Debug)]
194pub enum ThreadKoidReporterEvent {}
195
196impl ThreadKoidReporterEvent {
197 fn decode(
199 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
200 ) -> Result<ThreadKoidReporterEvent, fidl::Error> {
201 let (bytes, _handles) = buf.split_mut();
202 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
203 debug_assert_eq!(tx_header.tx_id, 0);
204 match tx_header.ordinal {
205 _ => Err(fidl::Error::UnknownOrdinal {
206 ordinal: tx_header.ordinal,
207 protocol_name:
208 <ThreadKoidReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
209 }),
210 }
211 }
212}
213
214pub struct ThreadKoidReporterRequestStream {
216 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
217 is_terminated: bool,
218}
219
220impl std::marker::Unpin for ThreadKoidReporterRequestStream {}
221
222impl futures::stream::FusedStream for ThreadKoidReporterRequestStream {
223 fn is_terminated(&self) -> bool {
224 self.is_terminated
225 }
226}
227
228impl fidl::endpoints::RequestStream for ThreadKoidReporterRequestStream {
229 type Protocol = ThreadKoidReporterMarker;
230 type ControlHandle = ThreadKoidReporterControlHandle;
231
232 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
233 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
234 }
235
236 fn control_handle(&self) -> Self::ControlHandle {
237 ThreadKoidReporterControlHandle { inner: self.inner.clone() }
238 }
239
240 fn into_inner(
241 self,
242 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
243 {
244 (self.inner, self.is_terminated)
245 }
246
247 fn from_inner(
248 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
249 is_terminated: bool,
250 ) -> Self {
251 Self { inner, is_terminated }
252 }
253}
254
255impl futures::Stream for ThreadKoidReporterRequestStream {
256 type Item = Result<ThreadKoidReporterRequest, fidl::Error>;
257
258 fn poll_next(
259 mut self: std::pin::Pin<&mut Self>,
260 cx: &mut std::task::Context<'_>,
261 ) -> std::task::Poll<Option<Self::Item>> {
262 let this = &mut *self;
263 if this.inner.check_shutdown(cx) {
264 this.is_terminated = true;
265 return std::task::Poll::Ready(None);
266 }
267 if this.is_terminated {
268 panic!("polled ThreadKoidReporterRequestStream after completion");
269 }
270 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
271 |bytes, handles| {
272 match this.inner.channel().read_etc(cx, bytes, handles) {
273 std::task::Poll::Ready(Ok(())) => {}
274 std::task::Poll::Pending => return std::task::Poll::Pending,
275 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
276 this.is_terminated = true;
277 return std::task::Poll::Ready(None);
278 }
279 std::task::Poll::Ready(Err(e)) => {
280 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
281 e.into(),
282 ))))
283 }
284 }
285
286 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
288
289 std::task::Poll::Ready(Some(match header.ordinal {
290 0x58cb9144fdb465d0 => {
291 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
292 let mut req = fidl::new_empty!(ThreadKoidReporterReportMyThreadKoidRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
293 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ThreadKoidReporterReportMyThreadKoidRequest>(&header, _body_bytes, handles, &mut req)?;
294 let control_handle = ThreadKoidReporterControlHandle {
295 inner: this.inner.clone(),
296 };
297 Ok(ThreadKoidReporterRequest::ReportMyThreadKoid {thread_koid: req.thread_koid,
298
299 control_handle,
300 })
301 }
302 _ => Err(fidl::Error::UnknownOrdinal {
303 ordinal: header.ordinal,
304 protocol_name: <ThreadKoidReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
305 }),
306 }))
307 },
308 )
309 }
310}
311
312#[derive(Debug)]
316pub enum ThreadKoidReporterRequest {
317 ReportMyThreadKoid { thread_koid: u64, control_handle: ThreadKoidReporterControlHandle },
319}
320
321impl ThreadKoidReporterRequest {
322 #[allow(irrefutable_let_patterns)]
323 pub fn into_report_my_thread_koid(self) -> Option<(u64, ThreadKoidReporterControlHandle)> {
324 if let ThreadKoidReporterRequest::ReportMyThreadKoid { thread_koid, control_handle } = self
325 {
326 Some((thread_koid, control_handle))
327 } else {
328 None
329 }
330 }
331
332 pub fn method_name(&self) -> &'static str {
334 match *self {
335 ThreadKoidReporterRequest::ReportMyThreadKoid { .. } => "report_my_thread_koid",
336 }
337 }
338}
339
340#[derive(Debug, Clone)]
341pub struct ThreadKoidReporterControlHandle {
342 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
343}
344
345impl fidl::endpoints::ControlHandle for ThreadKoidReporterControlHandle {
346 fn shutdown(&self) {
347 self.inner.shutdown()
348 }
349 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
350 self.inner.shutdown_with_epitaph(status)
351 }
352
353 fn is_closed(&self) -> bool {
354 self.inner.channel().is_closed()
355 }
356 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
357 self.inner.channel().on_closed()
358 }
359
360 #[cfg(target_os = "fuchsia")]
361 fn signal_peer(
362 &self,
363 clear_mask: zx::Signals,
364 set_mask: zx::Signals,
365 ) -> Result<(), zx_status::Status> {
366 use fidl::Peered;
367 self.inner.channel().signal_peer(clear_mask, set_mask)
368 }
369}
370
371impl ThreadKoidReporterControlHandle {}
372
373mod internal {
374 use super::*;
375
376 impl fidl::encoding::ResourceTypeMarker for ThreadKoidReporterReportMyThreadKoidRequest {
377 type Borrowed<'a> = &'a mut Self;
378 fn take_or_borrow<'a>(
379 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
380 ) -> Self::Borrowed<'a> {
381 value
382 }
383 }
384
385 unsafe impl fidl::encoding::TypeMarker for ThreadKoidReporterReportMyThreadKoidRequest {
386 type Owned = Self;
387
388 #[inline(always)]
389 fn inline_align(_context: fidl::encoding::Context) -> usize {
390 8
391 }
392
393 #[inline(always)]
394 fn inline_size(_context: fidl::encoding::Context) -> usize {
395 8
396 }
397 #[inline(always)]
398 fn encode_is_copy() -> bool {
399 true
400 }
401
402 #[inline(always)]
403 fn decode_is_copy() -> bool {
404 true
405 }
406 }
407
408 unsafe impl
409 fidl::encoding::Encode<
410 ThreadKoidReporterReportMyThreadKoidRequest,
411 fidl::encoding::DefaultFuchsiaResourceDialect,
412 > for &mut ThreadKoidReporterReportMyThreadKoidRequest
413 {
414 #[inline]
415 unsafe fn encode(
416 self,
417 encoder: &mut fidl::encoding::Encoder<
418 '_,
419 fidl::encoding::DefaultFuchsiaResourceDialect,
420 >,
421 offset: usize,
422 _depth: fidl::encoding::Depth,
423 ) -> fidl::Result<()> {
424 encoder.debug_check_bounds::<ThreadKoidReporterReportMyThreadKoidRequest>(offset);
425 unsafe {
426 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
428 (buf_ptr as *mut ThreadKoidReporterReportMyThreadKoidRequest).write_unaligned(
429 (self as *const ThreadKoidReporterReportMyThreadKoidRequest).read(),
430 );
431 }
434 Ok(())
435 }
436 }
437 unsafe impl<T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>>
438 fidl::encoding::Encode<
439 ThreadKoidReporterReportMyThreadKoidRequest,
440 fidl::encoding::DefaultFuchsiaResourceDialect,
441 > for (T0,)
442 {
443 #[inline]
444 unsafe fn encode(
445 self,
446 encoder: &mut fidl::encoding::Encoder<
447 '_,
448 fidl::encoding::DefaultFuchsiaResourceDialect,
449 >,
450 offset: usize,
451 depth: fidl::encoding::Depth,
452 ) -> fidl::Result<()> {
453 encoder.debug_check_bounds::<ThreadKoidReporterReportMyThreadKoidRequest>(offset);
454 self.0.encode(encoder, offset + 0, depth)?;
458 Ok(())
459 }
460 }
461
462 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
463 for ThreadKoidReporterReportMyThreadKoidRequest
464 {
465 #[inline(always)]
466 fn new_empty() -> Self {
467 Self {
468 thread_koid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
469 }
470 }
471
472 #[inline]
473 unsafe fn decode(
474 &mut self,
475 decoder: &mut fidl::encoding::Decoder<
476 '_,
477 fidl::encoding::DefaultFuchsiaResourceDialect,
478 >,
479 offset: usize,
480 _depth: fidl::encoding::Depth,
481 ) -> fidl::Result<()> {
482 decoder.debug_check_bounds::<Self>(offset);
483 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
484 unsafe {
487 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
488 }
489 Ok(())
490 }
491 }
492}