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_metrics_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct MetricEventLoggerQuerierMarker;
16
17impl fidl::endpoints::ProtocolMarker for MetricEventLoggerQuerierMarker {
18 type Proxy = MetricEventLoggerQuerierProxy;
19 type RequestStream = MetricEventLoggerQuerierRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = MetricEventLoggerQuerierSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.metrics.test.MetricEventLoggerQuerier";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for MetricEventLoggerQuerierMarker {}
26
27pub trait MetricEventLoggerQuerierProxyInterface: Send + Sync {
28 type WatchLogsResponseFut: std::future::Future<
29 Output = Result<(Vec<fidl_fuchsia_metrics::MetricEvent>, bool), fidl::Error>,
30 > + Send;
31 fn r#watch_logs(&self, project_id: u32, method: LogMethod) -> Self::WatchLogsResponseFut;
32 fn r#reset_logger(&self, project_id: u32, method: LogMethod) -> Result<(), fidl::Error>;
33}
34#[derive(Debug)]
35#[cfg(target_os = "fuchsia")]
36pub struct MetricEventLoggerQuerierSynchronousProxy {
37 client: fidl::client::sync::Client,
38}
39
40#[cfg(target_os = "fuchsia")]
41impl fidl::endpoints::SynchronousProxy for MetricEventLoggerQuerierSynchronousProxy {
42 type Proxy = MetricEventLoggerQuerierProxy;
43 type Protocol = MetricEventLoggerQuerierMarker;
44
45 fn from_channel(inner: fidl::Channel) -> Self {
46 Self::new(inner)
47 }
48
49 fn into_channel(self) -> fidl::Channel {
50 self.client.into_channel()
51 }
52
53 fn as_channel(&self) -> &fidl::Channel {
54 self.client.as_channel()
55 }
56}
57
58#[cfg(target_os = "fuchsia")]
59impl MetricEventLoggerQuerierSynchronousProxy {
60 pub fn new(channel: fidl::Channel) -> Self {
61 let protocol_name =
62 <MetricEventLoggerQuerierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
63 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
64 }
65
66 pub fn into_channel(self) -> fidl::Channel {
67 self.client.into_channel()
68 }
69
70 pub fn wait_for_event(
73 &self,
74 deadline: zx::MonotonicInstant,
75 ) -> Result<MetricEventLoggerQuerierEvent, fidl::Error> {
76 MetricEventLoggerQuerierEvent::decode(self.client.wait_for_event(deadline)?)
77 }
78
79 pub fn r#watch_logs(
91 &self,
92 mut project_id: u32,
93 mut method: LogMethod,
94 ___deadline: zx::MonotonicInstant,
95 ) -> Result<(Vec<fidl_fuchsia_metrics::MetricEvent>, bool), fidl::Error> {
96 let _response = self.client.send_query::<
97 MetricEventLoggerQuerierWatchLogsRequest,
98 MetricEventLoggerQuerierWatchLogsResponse,
99 >(
100 (project_id, method,),
101 0x42bdf7b98ef8dbea,
102 fidl::encoding::DynamicFlags::empty(),
103 ___deadline,
104 )?;
105 Ok((_response.events, _response.more))
106 }
107
108 pub fn r#reset_logger(
115 &self,
116 mut project_id: u32,
117 mut method: LogMethod,
118 ) -> Result<(), fidl::Error> {
119 self.client.send::<MetricEventLoggerQuerierResetLoggerRequest>(
120 (project_id, method),
121 0x16e0da7907d3190f,
122 fidl::encoding::DynamicFlags::empty(),
123 )
124 }
125}
126
127#[cfg(target_os = "fuchsia")]
128impl From<MetricEventLoggerQuerierSynchronousProxy> for zx::Handle {
129 fn from(value: MetricEventLoggerQuerierSynchronousProxy) -> Self {
130 value.into_channel().into()
131 }
132}
133
134#[cfg(target_os = "fuchsia")]
135impl From<fidl::Channel> for MetricEventLoggerQuerierSynchronousProxy {
136 fn from(value: fidl::Channel) -> Self {
137 Self::new(value)
138 }
139}
140
141#[derive(Debug, Clone)]
142pub struct MetricEventLoggerQuerierProxy {
143 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
144}
145
146impl fidl::endpoints::Proxy for MetricEventLoggerQuerierProxy {
147 type Protocol = MetricEventLoggerQuerierMarker;
148
149 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
150 Self::new(inner)
151 }
152
153 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
154 self.client.into_channel().map_err(|client| Self { client })
155 }
156
157 fn as_channel(&self) -> &::fidl::AsyncChannel {
158 self.client.as_channel()
159 }
160}
161
162impl MetricEventLoggerQuerierProxy {
163 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
165 let protocol_name =
166 <MetricEventLoggerQuerierMarker 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) -> MetricEventLoggerQuerierEventStream {
176 MetricEventLoggerQuerierEventStream { event_receiver: self.client.take_event_receiver() }
177 }
178
179 pub fn r#watch_logs(
191 &self,
192 mut project_id: u32,
193 mut method: LogMethod,
194 ) -> fidl::client::QueryResponseFut<
195 (Vec<fidl_fuchsia_metrics::MetricEvent>, bool),
196 fidl::encoding::DefaultFuchsiaResourceDialect,
197 > {
198 MetricEventLoggerQuerierProxyInterface::r#watch_logs(self, project_id, method)
199 }
200
201 pub fn r#reset_logger(
208 &self,
209 mut project_id: u32,
210 mut method: LogMethod,
211 ) -> Result<(), fidl::Error> {
212 MetricEventLoggerQuerierProxyInterface::r#reset_logger(self, project_id, method)
213 }
214}
215
216impl MetricEventLoggerQuerierProxyInterface for MetricEventLoggerQuerierProxy {
217 type WatchLogsResponseFut = fidl::client::QueryResponseFut<
218 (Vec<fidl_fuchsia_metrics::MetricEvent>, bool),
219 fidl::encoding::DefaultFuchsiaResourceDialect,
220 >;
221 fn r#watch_logs(
222 &self,
223 mut project_id: u32,
224 mut method: LogMethod,
225 ) -> Self::WatchLogsResponseFut {
226 fn _decode(
227 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
228 ) -> Result<(Vec<fidl_fuchsia_metrics::MetricEvent>, bool), fidl::Error> {
229 let _response = fidl::client::decode_transaction_body::<
230 MetricEventLoggerQuerierWatchLogsResponse,
231 fidl::encoding::DefaultFuchsiaResourceDialect,
232 0x42bdf7b98ef8dbea,
233 >(_buf?)?;
234 Ok((_response.events, _response.more))
235 }
236 self.client.send_query_and_decode::<
237 MetricEventLoggerQuerierWatchLogsRequest,
238 (Vec<fidl_fuchsia_metrics::MetricEvent>, bool),
239 >(
240 (project_id, method,),
241 0x42bdf7b98ef8dbea,
242 fidl::encoding::DynamicFlags::empty(),
243 _decode,
244 )
245 }
246
247 fn r#reset_logger(
248 &self,
249 mut project_id: u32,
250 mut method: LogMethod,
251 ) -> Result<(), fidl::Error> {
252 self.client.send::<MetricEventLoggerQuerierResetLoggerRequest>(
253 (project_id, method),
254 0x16e0da7907d3190f,
255 fidl::encoding::DynamicFlags::empty(),
256 )
257 }
258}
259
260pub struct MetricEventLoggerQuerierEventStream {
261 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
262}
263
264impl std::marker::Unpin for MetricEventLoggerQuerierEventStream {}
265
266impl futures::stream::FusedStream for MetricEventLoggerQuerierEventStream {
267 fn is_terminated(&self) -> bool {
268 self.event_receiver.is_terminated()
269 }
270}
271
272impl futures::Stream for MetricEventLoggerQuerierEventStream {
273 type Item = Result<MetricEventLoggerQuerierEvent, fidl::Error>;
274
275 fn poll_next(
276 mut self: std::pin::Pin<&mut Self>,
277 cx: &mut std::task::Context<'_>,
278 ) -> std::task::Poll<Option<Self::Item>> {
279 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
280 &mut self.event_receiver,
281 cx
282 )?) {
283 Some(buf) => std::task::Poll::Ready(Some(MetricEventLoggerQuerierEvent::decode(buf))),
284 None => std::task::Poll::Ready(None),
285 }
286 }
287}
288
289#[derive(Debug)]
290pub enum MetricEventLoggerQuerierEvent {}
291
292impl MetricEventLoggerQuerierEvent {
293 fn decode(
295 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
296 ) -> Result<MetricEventLoggerQuerierEvent, fidl::Error> {
297 let (bytes, _handles) = buf.split_mut();
298 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
299 debug_assert_eq!(tx_header.tx_id, 0);
300 match tx_header.ordinal {
301 _ => Err(fidl::Error::UnknownOrdinal {
302 ordinal: tx_header.ordinal,
303 protocol_name:
304 <MetricEventLoggerQuerierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
305 }),
306 }
307 }
308}
309
310pub struct MetricEventLoggerQuerierRequestStream {
312 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
313 is_terminated: bool,
314}
315
316impl std::marker::Unpin for MetricEventLoggerQuerierRequestStream {}
317
318impl futures::stream::FusedStream for MetricEventLoggerQuerierRequestStream {
319 fn is_terminated(&self) -> bool {
320 self.is_terminated
321 }
322}
323
324impl fidl::endpoints::RequestStream for MetricEventLoggerQuerierRequestStream {
325 type Protocol = MetricEventLoggerQuerierMarker;
326 type ControlHandle = MetricEventLoggerQuerierControlHandle;
327
328 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
329 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
330 }
331
332 fn control_handle(&self) -> Self::ControlHandle {
333 MetricEventLoggerQuerierControlHandle { inner: self.inner.clone() }
334 }
335
336 fn into_inner(
337 self,
338 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
339 {
340 (self.inner, self.is_terminated)
341 }
342
343 fn from_inner(
344 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
345 is_terminated: bool,
346 ) -> Self {
347 Self { inner, is_terminated }
348 }
349}
350
351impl futures::Stream for MetricEventLoggerQuerierRequestStream {
352 type Item = Result<MetricEventLoggerQuerierRequest, fidl::Error>;
353
354 fn poll_next(
355 mut self: std::pin::Pin<&mut Self>,
356 cx: &mut std::task::Context<'_>,
357 ) -> std::task::Poll<Option<Self::Item>> {
358 let this = &mut *self;
359 if this.inner.check_shutdown(cx) {
360 this.is_terminated = true;
361 return std::task::Poll::Ready(None);
362 }
363 if this.is_terminated {
364 panic!("polled MetricEventLoggerQuerierRequestStream after completion");
365 }
366 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
367 |bytes, handles| {
368 match this.inner.channel().read_etc(cx, bytes, handles) {
369 std::task::Poll::Ready(Ok(())) => {}
370 std::task::Poll::Pending => return std::task::Poll::Pending,
371 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
372 this.is_terminated = true;
373 return std::task::Poll::Ready(None);
374 }
375 std::task::Poll::Ready(Err(e)) => {
376 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
377 e.into(),
378 ))))
379 }
380 }
381
382 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
384
385 std::task::Poll::Ready(Some(match header.ordinal {
386 0x42bdf7b98ef8dbea => {
387 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
388 let mut req = fidl::new_empty!(MetricEventLoggerQuerierWatchLogsRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
389 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MetricEventLoggerQuerierWatchLogsRequest>(&header, _body_bytes, handles, &mut req)?;
390 let control_handle = MetricEventLoggerQuerierControlHandle {
391 inner: this.inner.clone(),
392 };
393 Ok(MetricEventLoggerQuerierRequest::WatchLogs {project_id: req.project_id,
394method: req.method,
395
396 responder: MetricEventLoggerQuerierWatchLogsResponder {
397 control_handle: std::mem::ManuallyDrop::new(control_handle),
398 tx_id: header.tx_id,
399 },
400 })
401 }
402 0x16e0da7907d3190f => {
403 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
404 let mut req = fidl::new_empty!(MetricEventLoggerQuerierResetLoggerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
405 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<MetricEventLoggerQuerierResetLoggerRequest>(&header, _body_bytes, handles, &mut req)?;
406 let control_handle = MetricEventLoggerQuerierControlHandle {
407 inner: this.inner.clone(),
408 };
409 Ok(MetricEventLoggerQuerierRequest::ResetLogger {project_id: req.project_id,
410method: req.method,
411
412 control_handle,
413 })
414 }
415 _ => Err(fidl::Error::UnknownOrdinal {
416 ordinal: header.ordinal,
417 protocol_name: <MetricEventLoggerQuerierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
418 }),
419 }))
420 },
421 )
422 }
423}
424
425#[derive(Debug)]
428pub enum MetricEventLoggerQuerierRequest {
429 WatchLogs {
441 project_id: u32,
442 method: LogMethod,
443 responder: MetricEventLoggerQuerierWatchLogsResponder,
444 },
445 ResetLogger {
452 project_id: u32,
453 method: LogMethod,
454 control_handle: MetricEventLoggerQuerierControlHandle,
455 },
456}
457
458impl MetricEventLoggerQuerierRequest {
459 #[allow(irrefutable_let_patterns)]
460 pub fn into_watch_logs(
461 self,
462 ) -> Option<(u32, LogMethod, MetricEventLoggerQuerierWatchLogsResponder)> {
463 if let MetricEventLoggerQuerierRequest::WatchLogs { project_id, method, responder } = self {
464 Some((project_id, method, responder))
465 } else {
466 None
467 }
468 }
469
470 #[allow(irrefutable_let_patterns)]
471 pub fn into_reset_logger(
472 self,
473 ) -> Option<(u32, LogMethod, MetricEventLoggerQuerierControlHandle)> {
474 if let MetricEventLoggerQuerierRequest::ResetLogger { project_id, method, control_handle } =
475 self
476 {
477 Some((project_id, method, control_handle))
478 } else {
479 None
480 }
481 }
482
483 pub fn method_name(&self) -> &'static str {
485 match *self {
486 MetricEventLoggerQuerierRequest::WatchLogs { .. } => "watch_logs",
487 MetricEventLoggerQuerierRequest::ResetLogger { .. } => "reset_logger",
488 }
489 }
490}
491
492#[derive(Debug, Clone)]
493pub struct MetricEventLoggerQuerierControlHandle {
494 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
495}
496
497impl fidl::endpoints::ControlHandle for MetricEventLoggerQuerierControlHandle {
498 fn shutdown(&self) {
499 self.inner.shutdown()
500 }
501 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
502 self.inner.shutdown_with_epitaph(status)
503 }
504
505 fn is_closed(&self) -> bool {
506 self.inner.channel().is_closed()
507 }
508 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
509 self.inner.channel().on_closed()
510 }
511
512 #[cfg(target_os = "fuchsia")]
513 fn signal_peer(
514 &self,
515 clear_mask: zx::Signals,
516 set_mask: zx::Signals,
517 ) -> Result<(), zx_status::Status> {
518 use fidl::Peered;
519 self.inner.channel().signal_peer(clear_mask, set_mask)
520 }
521}
522
523impl MetricEventLoggerQuerierControlHandle {}
524
525#[must_use = "FIDL methods require a response to be sent"]
526#[derive(Debug)]
527pub struct MetricEventLoggerQuerierWatchLogsResponder {
528 control_handle: std::mem::ManuallyDrop<MetricEventLoggerQuerierControlHandle>,
529 tx_id: u32,
530}
531
532impl std::ops::Drop for MetricEventLoggerQuerierWatchLogsResponder {
536 fn drop(&mut self) {
537 self.control_handle.shutdown();
538 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
540 }
541}
542
543impl fidl::endpoints::Responder for MetricEventLoggerQuerierWatchLogsResponder {
544 type ControlHandle = MetricEventLoggerQuerierControlHandle;
545
546 fn control_handle(&self) -> &MetricEventLoggerQuerierControlHandle {
547 &self.control_handle
548 }
549
550 fn drop_without_shutdown(mut self) {
551 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
553 std::mem::forget(self);
555 }
556}
557
558impl MetricEventLoggerQuerierWatchLogsResponder {
559 pub fn send(
563 self,
564 mut events: &[fidl_fuchsia_metrics::MetricEvent],
565 mut more: bool,
566 ) -> Result<(), fidl::Error> {
567 let _result = self.send_raw(events, more);
568 if _result.is_err() {
569 self.control_handle.shutdown();
570 }
571 self.drop_without_shutdown();
572 _result
573 }
574
575 pub fn send_no_shutdown_on_err(
577 self,
578 mut events: &[fidl_fuchsia_metrics::MetricEvent],
579 mut more: bool,
580 ) -> Result<(), fidl::Error> {
581 let _result = self.send_raw(events, more);
582 self.drop_without_shutdown();
583 _result
584 }
585
586 fn send_raw(
587 &self,
588 mut events: &[fidl_fuchsia_metrics::MetricEvent],
589 mut more: bool,
590 ) -> Result<(), fidl::Error> {
591 self.control_handle.inner.send::<MetricEventLoggerQuerierWatchLogsResponse>(
592 (events, more),
593 self.tx_id,
594 0x42bdf7b98ef8dbea,
595 fidl::encoding::DynamicFlags::empty(),
596 )
597 }
598}
599
600mod internal {
601 use super::*;
602}