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_persist__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DataPersistenceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DataPersistenceMarker {
18 type Proxy = DataPersistenceProxy;
19 type RequestStream = DataPersistenceRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DataPersistenceSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.diagnostics.persist.DataPersistence";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DataPersistenceMarker {}
26
27pub trait DataPersistenceProxyInterface: Send + Sync {
28 type PersistResponseFut: std::future::Future<Output = Result<PersistResult, fidl::Error>> + Send;
29 fn r#persist(&self, tag: &str) -> Self::PersistResponseFut;
30 type PersistTagsResponseFut: std::future::Future<Output = Result<Vec<PersistResult>, fidl::Error>>
31 + Send;
32 fn r#persist_tags(&self, tags: &[String]) -> Self::PersistTagsResponseFut;
33}
34#[derive(Debug)]
35#[cfg(target_os = "fuchsia")]
36pub struct DataPersistenceSynchronousProxy {
37 client: fidl::client::sync::Client,
38}
39
40#[cfg(target_os = "fuchsia")]
41impl fidl::endpoints::SynchronousProxy for DataPersistenceSynchronousProxy {
42 type Proxy = DataPersistenceProxy;
43 type Protocol = DataPersistenceMarker;
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 DataPersistenceSynchronousProxy {
60 pub fn new(channel: fidl::Channel) -> Self {
61 let protocol_name = <DataPersistenceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
62 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
63 }
64
65 pub fn into_channel(self) -> fidl::Channel {
66 self.client.into_channel()
67 }
68
69 pub fn wait_for_event(
72 &self,
73 deadline: zx::MonotonicInstant,
74 ) -> Result<DataPersistenceEvent, fidl::Error> {
75 DataPersistenceEvent::decode(self.client.wait_for_event(deadline)?)
76 }
77
78 pub fn r#persist(
82 &self,
83 mut tag: &str,
84 ___deadline: zx::MonotonicInstant,
85 ) -> Result<PersistResult, fidl::Error> {
86 let _response = self
87 .client
88 .send_query::<DataPersistencePersistRequest, DataPersistencePersistResponse>(
89 (tag,),
90 0x6193adf95c67926e,
91 fidl::encoding::DynamicFlags::empty(),
92 ___deadline,
93 )?;
94 Ok(_response.result)
95 }
96
97 pub fn r#persist_tags(
101 &self,
102 mut tags: &[String],
103 ___deadline: zx::MonotonicInstant,
104 ) -> Result<Vec<PersistResult>, fidl::Error> {
105 let _response = self
106 .client
107 .send_query::<DataPersistencePersistTagsRequest, DataPersistencePersistTagsResponse>(
108 (tags,),
109 0x4a5f2795aceb0ae4,
110 fidl::encoding::DynamicFlags::empty(),
111 ___deadline,
112 )?;
113 Ok(_response.results)
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl From<DataPersistenceSynchronousProxy> for zx::Handle {
119 fn from(value: DataPersistenceSynchronousProxy) -> Self {
120 value.into_channel().into()
121 }
122}
123
124#[cfg(target_os = "fuchsia")]
125impl From<fidl::Channel> for DataPersistenceSynchronousProxy {
126 fn from(value: fidl::Channel) -> Self {
127 Self::new(value)
128 }
129}
130
131#[cfg(target_os = "fuchsia")]
132impl fidl::endpoints::FromClient for DataPersistenceSynchronousProxy {
133 type Protocol = DataPersistenceMarker;
134
135 fn from_client(value: fidl::endpoints::ClientEnd<DataPersistenceMarker>) -> Self {
136 Self::new(value.into_channel())
137 }
138}
139
140#[derive(Debug, Clone)]
141pub struct DataPersistenceProxy {
142 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
143}
144
145impl fidl::endpoints::Proxy for DataPersistenceProxy {
146 type Protocol = DataPersistenceMarker;
147
148 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
149 Self::new(inner)
150 }
151
152 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
153 self.client.into_channel().map_err(|client| Self { client })
154 }
155
156 fn as_channel(&self) -> &::fidl::AsyncChannel {
157 self.client.as_channel()
158 }
159}
160
161impl DataPersistenceProxy {
162 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
164 let protocol_name = <DataPersistenceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
165 Self { client: fidl::client::Client::new(channel, protocol_name) }
166 }
167
168 pub fn take_event_stream(&self) -> DataPersistenceEventStream {
174 DataPersistenceEventStream { event_receiver: self.client.take_event_receiver() }
175 }
176
177 pub fn r#persist(
181 &self,
182 mut tag: &str,
183 ) -> fidl::client::QueryResponseFut<PersistResult, fidl::encoding::DefaultFuchsiaResourceDialect>
184 {
185 DataPersistenceProxyInterface::r#persist(self, tag)
186 }
187
188 pub fn r#persist_tags(
192 &self,
193 mut tags: &[String],
194 ) -> fidl::client::QueryResponseFut<
195 Vec<PersistResult>,
196 fidl::encoding::DefaultFuchsiaResourceDialect,
197 > {
198 DataPersistenceProxyInterface::r#persist_tags(self, tags)
199 }
200}
201
202impl DataPersistenceProxyInterface for DataPersistenceProxy {
203 type PersistResponseFut = fidl::client::QueryResponseFut<
204 PersistResult,
205 fidl::encoding::DefaultFuchsiaResourceDialect,
206 >;
207 fn r#persist(&self, mut tag: &str) -> Self::PersistResponseFut {
208 fn _decode(
209 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
210 ) -> Result<PersistResult, fidl::Error> {
211 let _response = fidl::client::decode_transaction_body::<
212 DataPersistencePersistResponse,
213 fidl::encoding::DefaultFuchsiaResourceDialect,
214 0x6193adf95c67926e,
215 >(_buf?)?;
216 Ok(_response.result)
217 }
218 self.client.send_query_and_decode::<DataPersistencePersistRequest, PersistResult>(
219 (tag,),
220 0x6193adf95c67926e,
221 fidl::encoding::DynamicFlags::empty(),
222 _decode,
223 )
224 }
225
226 type PersistTagsResponseFut = fidl::client::QueryResponseFut<
227 Vec<PersistResult>,
228 fidl::encoding::DefaultFuchsiaResourceDialect,
229 >;
230 fn r#persist_tags(&self, mut tags: &[String]) -> Self::PersistTagsResponseFut {
231 fn _decode(
232 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
233 ) -> Result<Vec<PersistResult>, fidl::Error> {
234 let _response = fidl::client::decode_transaction_body::<
235 DataPersistencePersistTagsResponse,
236 fidl::encoding::DefaultFuchsiaResourceDialect,
237 0x4a5f2795aceb0ae4,
238 >(_buf?)?;
239 Ok(_response.results)
240 }
241 self.client.send_query_and_decode::<DataPersistencePersistTagsRequest, Vec<PersistResult>>(
242 (tags,),
243 0x4a5f2795aceb0ae4,
244 fidl::encoding::DynamicFlags::empty(),
245 _decode,
246 )
247 }
248}
249
250pub struct DataPersistenceEventStream {
251 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
252}
253
254impl std::marker::Unpin for DataPersistenceEventStream {}
255
256impl futures::stream::FusedStream for DataPersistenceEventStream {
257 fn is_terminated(&self) -> bool {
258 self.event_receiver.is_terminated()
259 }
260}
261
262impl futures::Stream for DataPersistenceEventStream {
263 type Item = Result<DataPersistenceEvent, fidl::Error>;
264
265 fn poll_next(
266 mut self: std::pin::Pin<&mut Self>,
267 cx: &mut std::task::Context<'_>,
268 ) -> std::task::Poll<Option<Self::Item>> {
269 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
270 &mut self.event_receiver,
271 cx
272 )?) {
273 Some(buf) => std::task::Poll::Ready(Some(DataPersistenceEvent::decode(buf))),
274 None => std::task::Poll::Ready(None),
275 }
276 }
277}
278
279#[derive(Debug)]
280pub enum DataPersistenceEvent {}
281
282impl DataPersistenceEvent {
283 fn decode(
285 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
286 ) -> Result<DataPersistenceEvent, fidl::Error> {
287 let (bytes, _handles) = buf.split_mut();
288 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
289 debug_assert_eq!(tx_header.tx_id, 0);
290 match tx_header.ordinal {
291 _ => Err(fidl::Error::UnknownOrdinal {
292 ordinal: tx_header.ordinal,
293 protocol_name:
294 <DataPersistenceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
295 }),
296 }
297 }
298}
299
300pub struct DataPersistenceRequestStream {
302 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303 is_terminated: bool,
304}
305
306impl std::marker::Unpin for DataPersistenceRequestStream {}
307
308impl futures::stream::FusedStream for DataPersistenceRequestStream {
309 fn is_terminated(&self) -> bool {
310 self.is_terminated
311 }
312}
313
314impl fidl::endpoints::RequestStream for DataPersistenceRequestStream {
315 type Protocol = DataPersistenceMarker;
316 type ControlHandle = DataPersistenceControlHandle;
317
318 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
319 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
320 }
321
322 fn control_handle(&self) -> Self::ControlHandle {
323 DataPersistenceControlHandle { inner: self.inner.clone() }
324 }
325
326 fn into_inner(
327 self,
328 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
329 {
330 (self.inner, self.is_terminated)
331 }
332
333 fn from_inner(
334 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
335 is_terminated: bool,
336 ) -> Self {
337 Self { inner, is_terminated }
338 }
339}
340
341impl futures::Stream for DataPersistenceRequestStream {
342 type Item = Result<DataPersistenceRequest, fidl::Error>;
343
344 fn poll_next(
345 mut self: std::pin::Pin<&mut Self>,
346 cx: &mut std::task::Context<'_>,
347 ) -> std::task::Poll<Option<Self::Item>> {
348 let this = &mut *self;
349 if this.inner.check_shutdown(cx) {
350 this.is_terminated = true;
351 return std::task::Poll::Ready(None);
352 }
353 if this.is_terminated {
354 panic!("polled DataPersistenceRequestStream after completion");
355 }
356 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
357 |bytes, handles| {
358 match this.inner.channel().read_etc(cx, bytes, handles) {
359 std::task::Poll::Ready(Ok(())) => {}
360 std::task::Poll::Pending => return std::task::Poll::Pending,
361 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
362 this.is_terminated = true;
363 return std::task::Poll::Ready(None);
364 }
365 std::task::Poll::Ready(Err(e)) => {
366 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
367 e.into(),
368 ))))
369 }
370 }
371
372 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
374
375 std::task::Poll::Ready(Some(match header.ordinal {
376 0x6193adf95c67926e => {
377 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
378 let mut req = fidl::new_empty!(
379 DataPersistencePersistRequest,
380 fidl::encoding::DefaultFuchsiaResourceDialect
381 );
382 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataPersistencePersistRequest>(&header, _body_bytes, handles, &mut req)?;
383 let control_handle =
384 DataPersistenceControlHandle { inner: this.inner.clone() };
385 Ok(DataPersistenceRequest::Persist {
386 tag: req.tag,
387
388 responder: DataPersistencePersistResponder {
389 control_handle: std::mem::ManuallyDrop::new(control_handle),
390 tx_id: header.tx_id,
391 },
392 })
393 }
394 0x4a5f2795aceb0ae4 => {
395 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
396 let mut req = fidl::new_empty!(
397 DataPersistencePersistTagsRequest,
398 fidl::encoding::DefaultFuchsiaResourceDialect
399 );
400 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DataPersistencePersistTagsRequest>(&header, _body_bytes, handles, &mut req)?;
401 let control_handle =
402 DataPersistenceControlHandle { inner: this.inner.clone() };
403 Ok(DataPersistenceRequest::PersistTags {
404 tags: req.tags,
405
406 responder: DataPersistencePersistTagsResponder {
407 control_handle: std::mem::ManuallyDrop::new(control_handle),
408 tx_id: header.tx_id,
409 },
410 })
411 }
412 _ => Err(fidl::Error::UnknownOrdinal {
413 ordinal: header.ordinal,
414 protocol_name:
415 <DataPersistenceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
416 }),
417 }))
418 },
419 )
420 }
421}
422
423#[derive(Debug)]
426pub enum DataPersistenceRequest {
427 Persist { tag: String, responder: DataPersistencePersistResponder },
431 PersistTags { tags: Vec<String>, responder: DataPersistencePersistTagsResponder },
435}
436
437impl DataPersistenceRequest {
438 #[allow(irrefutable_let_patterns)]
439 pub fn into_persist(self) -> Option<(String, DataPersistencePersistResponder)> {
440 if let DataPersistenceRequest::Persist { tag, responder } = self {
441 Some((tag, responder))
442 } else {
443 None
444 }
445 }
446
447 #[allow(irrefutable_let_patterns)]
448 pub fn into_persist_tags(self) -> Option<(Vec<String>, DataPersistencePersistTagsResponder)> {
449 if let DataPersistenceRequest::PersistTags { tags, responder } = self {
450 Some((tags, responder))
451 } else {
452 None
453 }
454 }
455
456 pub fn method_name(&self) -> &'static str {
458 match *self {
459 DataPersistenceRequest::Persist { .. } => "persist",
460 DataPersistenceRequest::PersistTags { .. } => "persist_tags",
461 }
462 }
463}
464
465#[derive(Debug, Clone)]
466pub struct DataPersistenceControlHandle {
467 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
468}
469
470impl fidl::endpoints::ControlHandle for DataPersistenceControlHandle {
471 fn shutdown(&self) {
472 self.inner.shutdown()
473 }
474 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
475 self.inner.shutdown_with_epitaph(status)
476 }
477
478 fn is_closed(&self) -> bool {
479 self.inner.channel().is_closed()
480 }
481 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
482 self.inner.channel().on_closed()
483 }
484
485 #[cfg(target_os = "fuchsia")]
486 fn signal_peer(
487 &self,
488 clear_mask: zx::Signals,
489 set_mask: zx::Signals,
490 ) -> Result<(), zx_status::Status> {
491 use fidl::Peered;
492 self.inner.channel().signal_peer(clear_mask, set_mask)
493 }
494}
495
496impl DataPersistenceControlHandle {}
497
498#[must_use = "FIDL methods require a response to be sent"]
499#[derive(Debug)]
500pub struct DataPersistencePersistResponder {
501 control_handle: std::mem::ManuallyDrop<DataPersistenceControlHandle>,
502 tx_id: u32,
503}
504
505impl std::ops::Drop for DataPersistencePersistResponder {
509 fn drop(&mut self) {
510 self.control_handle.shutdown();
511 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
513 }
514}
515
516impl fidl::endpoints::Responder for DataPersistencePersistResponder {
517 type ControlHandle = DataPersistenceControlHandle;
518
519 fn control_handle(&self) -> &DataPersistenceControlHandle {
520 &self.control_handle
521 }
522
523 fn drop_without_shutdown(mut self) {
524 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
526 std::mem::forget(self);
528 }
529}
530
531impl DataPersistencePersistResponder {
532 pub fn send(self, mut result: PersistResult) -> Result<(), fidl::Error> {
536 let _result = self.send_raw(result);
537 if _result.is_err() {
538 self.control_handle.shutdown();
539 }
540 self.drop_without_shutdown();
541 _result
542 }
543
544 pub fn send_no_shutdown_on_err(self, mut result: PersistResult) -> Result<(), fidl::Error> {
546 let _result = self.send_raw(result);
547 self.drop_without_shutdown();
548 _result
549 }
550
551 fn send_raw(&self, mut result: PersistResult) -> Result<(), fidl::Error> {
552 self.control_handle.inner.send::<DataPersistencePersistResponse>(
553 (result,),
554 self.tx_id,
555 0x6193adf95c67926e,
556 fidl::encoding::DynamicFlags::empty(),
557 )
558 }
559}
560
561#[must_use = "FIDL methods require a response to be sent"]
562#[derive(Debug)]
563pub struct DataPersistencePersistTagsResponder {
564 control_handle: std::mem::ManuallyDrop<DataPersistenceControlHandle>,
565 tx_id: u32,
566}
567
568impl std::ops::Drop for DataPersistencePersistTagsResponder {
572 fn drop(&mut self) {
573 self.control_handle.shutdown();
574 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
576 }
577}
578
579impl fidl::endpoints::Responder for DataPersistencePersistTagsResponder {
580 type ControlHandle = DataPersistenceControlHandle;
581
582 fn control_handle(&self) -> &DataPersistenceControlHandle {
583 &self.control_handle
584 }
585
586 fn drop_without_shutdown(mut self) {
587 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
589 std::mem::forget(self);
591 }
592}
593
594impl DataPersistencePersistTagsResponder {
595 pub fn send(self, mut results: &[PersistResult]) -> Result<(), fidl::Error> {
599 let _result = self.send_raw(results);
600 if _result.is_err() {
601 self.control_handle.shutdown();
602 }
603 self.drop_without_shutdown();
604 _result
605 }
606
607 pub fn send_no_shutdown_on_err(self, mut results: &[PersistResult]) -> Result<(), fidl::Error> {
609 let _result = self.send_raw(results);
610 self.drop_without_shutdown();
611 _result
612 }
613
614 fn send_raw(&self, mut results: &[PersistResult]) -> Result<(), fidl::Error> {
615 self.control_handle.inner.send::<DataPersistencePersistTagsResponse>(
616 (results,),
617 self.tx_id,
618 0x4a5f2795aceb0ae4,
619 fidl::encoding::DynamicFlags::empty(),
620 )
621 }
622}
623
624mod internal {
625 use super::*;
626}