Skip to main content

fidl_fuchsia_fxfs/
fidl_fuchsia_fxfs.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_fxfs_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct BlobCreatorCreateResponse {
16    pub writer: fidl::endpoints::ClientEnd<BlobWriterMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobCreatorCreateResponse {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct BlobReaderGetVmoResponse {
23    pub vmo: fidl::Vmo,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobReaderGetVmoResponse {}
27
28#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29pub struct BlobWriterGetVmoResponse {
30    pub vmo: fidl::Vmo,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BlobWriterGetVmoResponse {}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct FileBackedVolumeProviderOpenRequest {
37    pub parent_directory_token: fidl::NullableHandle,
38    pub name: String,
39    pub server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for FileBackedVolumeProviderOpenRequest
44{
45}
46
47#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
48pub struct BlobCreatorMarker;
49
50impl fidl::endpoints::ProtocolMarker for BlobCreatorMarker {
51    type Proxy = BlobCreatorProxy;
52    type RequestStream = BlobCreatorRequestStream;
53    #[cfg(target_os = "fuchsia")]
54    type SynchronousProxy = BlobCreatorSynchronousProxy;
55
56    const DEBUG_NAME: &'static str = "fuchsia.fxfs.BlobCreator";
57}
58impl fidl::endpoints::DiscoverableProtocolMarker for BlobCreatorMarker {}
59pub type BlobCreatorCreateResult =
60    Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>;
61pub type BlobCreatorNeedsOverwriteResult = Result<bool, i32>;
62
63pub trait BlobCreatorProxyInterface: Send + Sync {
64    type CreateResponseFut: std::future::Future<Output = Result<BlobCreatorCreateResult, fidl::Error>>
65        + Send;
66    fn r#create(&self, hash: &[u8; 32], allow_existing: bool) -> Self::CreateResponseFut;
67    type NeedsOverwriteResponseFut: std::future::Future<Output = Result<BlobCreatorNeedsOverwriteResult, fidl::Error>>
68        + Send;
69    fn r#needs_overwrite(&self, blob_hash: &[u8; 32]) -> Self::NeedsOverwriteResponseFut;
70}
71#[derive(Debug)]
72#[cfg(target_os = "fuchsia")]
73pub struct BlobCreatorSynchronousProxy {
74    client: fidl::client::sync::Client,
75}
76
77#[cfg(target_os = "fuchsia")]
78impl fidl::endpoints::SynchronousProxy for BlobCreatorSynchronousProxy {
79    type Proxy = BlobCreatorProxy;
80    type Protocol = BlobCreatorMarker;
81
82    fn from_channel(inner: fidl::Channel) -> Self {
83        Self::new(inner)
84    }
85
86    fn into_channel(self) -> fidl::Channel {
87        self.client.into_channel()
88    }
89
90    fn as_channel(&self) -> &fidl::Channel {
91        self.client.as_channel()
92    }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl BlobCreatorSynchronousProxy {
97    pub fn new(channel: fidl::Channel) -> Self {
98        Self { client: fidl::client::sync::Client::new(channel) }
99    }
100
101    pub fn into_channel(self) -> fidl::Channel {
102        self.client.into_channel()
103    }
104
105    /// Waits until an event arrives and returns it. It is safe for other
106    /// threads to make concurrent requests while waiting for an event.
107    pub fn wait_for_event(
108        &self,
109        deadline: zx::MonotonicInstant,
110    ) -> Result<BlobCreatorEvent, fidl::Error> {
111        BlobCreatorEvent::decode(self.client.wait_for_event::<BlobCreatorMarker>(deadline)?)
112    }
113
114    /// Creates a blob with the merkle root `hash`. If `allow_existing` is true, the server will
115    /// overwrite the existing blob if there is one. The server may fail this request with
116    /// `[CreateBlobError.ALREADY_EXISTS]` if there is already an inflight `BlobWriter` for the same
117    /// hash which has not been closed or completed. The client will truncate the blob with
118    /// [BlobWriter.GetVmo] and get a handle to a vmo in return. The client will then write blob
119    /// contents into the vmo and call [BlobWriter.BytesReady] on the 'writer` to signal to the
120    /// server that some number of bytes has been written to the vmo.
121    pub fn r#create(
122        &self,
123        mut hash: &[u8; 32],
124        mut allow_existing: bool,
125        ___deadline: zx::MonotonicInstant,
126    ) -> Result<BlobCreatorCreateResult, fidl::Error> {
127        let _response = self.client.send_query::<
128            BlobCreatorCreateRequest,
129            fidl::encoding::ResultType<BlobCreatorCreateResponse, CreateBlobError>,
130            BlobCreatorMarker,
131        >(
132            (hash, allow_existing,),
133            0x4288fe720cca70d7,
134            fidl::encoding::DynamicFlags::empty(),
135            ___deadline,
136        )?;
137        Ok(_response.map(|x| x.writer))
138    }
139
140    /// Given the hash of a blob, returns true if it should be overwritten using Create with
141    /// `allow_existing` set to true. Must respond the same as `BlobReader.GetVmo` in terms of
142    /// existence checks, responding ZX_ERR_NOT_FOUND under the same conditions.
143    pub fn r#needs_overwrite(
144        &self,
145        mut blob_hash: &[u8; 32],
146        ___deadline: zx::MonotonicInstant,
147    ) -> Result<BlobCreatorNeedsOverwriteResult, fidl::Error> {
148        let _response = self.client.send_query::<
149            BlobCreatorNeedsOverwriteRequest,
150            fidl::encoding::ResultType<BlobCreatorNeedsOverwriteResponse, i32>,
151            BlobCreatorMarker,
152        >(
153            (blob_hash,),
154            0x512e347a6be3e426,
155            fidl::encoding::DynamicFlags::empty(),
156            ___deadline,
157        )?;
158        Ok(_response.map(|x| x.needs_overwrite))
159    }
160}
161
162#[cfg(target_os = "fuchsia")]
163impl From<BlobCreatorSynchronousProxy> for zx::NullableHandle {
164    fn from(value: BlobCreatorSynchronousProxy) -> Self {
165        value.into_channel().into()
166    }
167}
168
169#[cfg(target_os = "fuchsia")]
170impl From<fidl::Channel> for BlobCreatorSynchronousProxy {
171    fn from(value: fidl::Channel) -> Self {
172        Self::new(value)
173    }
174}
175
176#[cfg(target_os = "fuchsia")]
177impl fidl::endpoints::FromClient for BlobCreatorSynchronousProxy {
178    type Protocol = BlobCreatorMarker;
179
180    fn from_client(value: fidl::endpoints::ClientEnd<BlobCreatorMarker>) -> Self {
181        Self::new(value.into_channel())
182    }
183}
184
185#[derive(Debug, Clone)]
186pub struct BlobCreatorProxy {
187    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
188}
189
190impl fidl::endpoints::Proxy for BlobCreatorProxy {
191    type Protocol = BlobCreatorMarker;
192
193    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
194        Self::new(inner)
195    }
196
197    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
198        self.client.into_channel().map_err(|client| Self { client })
199    }
200
201    fn as_channel(&self) -> &::fidl::AsyncChannel {
202        self.client.as_channel()
203    }
204}
205
206impl BlobCreatorProxy {
207    /// Create a new Proxy for fuchsia.fxfs/BlobCreator.
208    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
209        let protocol_name = <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
210        Self { client: fidl::client::Client::new(channel, protocol_name) }
211    }
212
213    /// Get a Stream of events from the remote end of the protocol.
214    ///
215    /// # Panics
216    ///
217    /// Panics if the event stream was already taken.
218    pub fn take_event_stream(&self) -> BlobCreatorEventStream {
219        BlobCreatorEventStream { event_receiver: self.client.take_event_receiver() }
220    }
221
222    /// Creates a blob with the merkle root `hash`. If `allow_existing` is true, the server will
223    /// overwrite the existing blob if there is one. The server may fail this request with
224    /// `[CreateBlobError.ALREADY_EXISTS]` if there is already an inflight `BlobWriter` for the same
225    /// hash which has not been closed or completed. The client will truncate the blob with
226    /// [BlobWriter.GetVmo] and get a handle to a vmo in return. The client will then write blob
227    /// contents into the vmo and call [BlobWriter.BytesReady] on the 'writer` to signal to the
228    /// server that some number of bytes has been written to the vmo.
229    pub fn r#create(
230        &self,
231        mut hash: &[u8; 32],
232        mut allow_existing: bool,
233    ) -> fidl::client::QueryResponseFut<
234        BlobCreatorCreateResult,
235        fidl::encoding::DefaultFuchsiaResourceDialect,
236    > {
237        BlobCreatorProxyInterface::r#create(self, hash, allow_existing)
238    }
239
240    /// Given the hash of a blob, returns true if it should be overwritten using Create with
241    /// `allow_existing` set to true. Must respond the same as `BlobReader.GetVmo` in terms of
242    /// existence checks, responding ZX_ERR_NOT_FOUND under the same conditions.
243    pub fn r#needs_overwrite(
244        &self,
245        mut blob_hash: &[u8; 32],
246    ) -> fidl::client::QueryResponseFut<
247        BlobCreatorNeedsOverwriteResult,
248        fidl::encoding::DefaultFuchsiaResourceDialect,
249    > {
250        BlobCreatorProxyInterface::r#needs_overwrite(self, blob_hash)
251    }
252}
253
254impl BlobCreatorProxyInterface for BlobCreatorProxy {
255    type CreateResponseFut = fidl::client::QueryResponseFut<
256        BlobCreatorCreateResult,
257        fidl::encoding::DefaultFuchsiaResourceDialect,
258    >;
259    fn r#create(&self, mut hash: &[u8; 32], mut allow_existing: bool) -> Self::CreateResponseFut {
260        fn _decode(
261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262        ) -> Result<BlobCreatorCreateResult, fidl::Error> {
263            let _response = fidl::client::decode_transaction_body::<
264                fidl::encoding::ResultType<BlobCreatorCreateResponse, CreateBlobError>,
265                fidl::encoding::DefaultFuchsiaResourceDialect,
266                0x4288fe720cca70d7,
267            >(_buf?)?;
268            Ok(_response.map(|x| x.writer))
269        }
270        self.client.send_query_and_decode::<BlobCreatorCreateRequest, BlobCreatorCreateResult>(
271            (hash, allow_existing),
272            0x4288fe720cca70d7,
273            fidl::encoding::DynamicFlags::empty(),
274            _decode,
275        )
276    }
277
278    type NeedsOverwriteResponseFut = fidl::client::QueryResponseFut<
279        BlobCreatorNeedsOverwriteResult,
280        fidl::encoding::DefaultFuchsiaResourceDialect,
281    >;
282    fn r#needs_overwrite(&self, mut blob_hash: &[u8; 32]) -> Self::NeedsOverwriteResponseFut {
283        fn _decode(
284            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
285        ) -> Result<BlobCreatorNeedsOverwriteResult, fidl::Error> {
286            let _response = fidl::client::decode_transaction_body::<
287                fidl::encoding::ResultType<BlobCreatorNeedsOverwriteResponse, i32>,
288                fidl::encoding::DefaultFuchsiaResourceDialect,
289                0x512e347a6be3e426,
290            >(_buf?)?;
291            Ok(_response.map(|x| x.needs_overwrite))
292        }
293        self.client.send_query_and_decode::<
294            BlobCreatorNeedsOverwriteRequest,
295            BlobCreatorNeedsOverwriteResult,
296        >(
297            (blob_hash,),
298            0x512e347a6be3e426,
299            fidl::encoding::DynamicFlags::empty(),
300            _decode,
301        )
302    }
303}
304
305pub struct BlobCreatorEventStream {
306    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
307}
308
309impl std::marker::Unpin for BlobCreatorEventStream {}
310
311impl futures::stream::FusedStream for BlobCreatorEventStream {
312    fn is_terminated(&self) -> bool {
313        self.event_receiver.is_terminated()
314    }
315}
316
317impl futures::Stream for BlobCreatorEventStream {
318    type Item = Result<BlobCreatorEvent, fidl::Error>;
319
320    fn poll_next(
321        mut self: std::pin::Pin<&mut Self>,
322        cx: &mut std::task::Context<'_>,
323    ) -> std::task::Poll<Option<Self::Item>> {
324        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
325            &mut self.event_receiver,
326            cx
327        )?) {
328            Some(buf) => std::task::Poll::Ready(Some(BlobCreatorEvent::decode(buf))),
329            None => std::task::Poll::Ready(None),
330        }
331    }
332}
333
334#[derive(Debug)]
335pub enum BlobCreatorEvent {}
336
337impl BlobCreatorEvent {
338    /// Decodes a message buffer as a [`BlobCreatorEvent`].
339    fn decode(
340        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
341    ) -> Result<BlobCreatorEvent, fidl::Error> {
342        let (bytes, _handles) = buf.split_mut();
343        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
344        debug_assert_eq!(tx_header.tx_id, 0);
345        match tx_header.ordinal {
346            _ => Err(fidl::Error::UnknownOrdinal {
347                ordinal: tx_header.ordinal,
348                protocol_name: <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
349            }),
350        }
351    }
352}
353
354/// A Stream of incoming requests for fuchsia.fxfs/BlobCreator.
355pub struct BlobCreatorRequestStream {
356    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
357    is_terminated: bool,
358}
359
360impl std::marker::Unpin for BlobCreatorRequestStream {}
361
362impl futures::stream::FusedStream for BlobCreatorRequestStream {
363    fn is_terminated(&self) -> bool {
364        self.is_terminated
365    }
366}
367
368impl fidl::endpoints::RequestStream for BlobCreatorRequestStream {
369    type Protocol = BlobCreatorMarker;
370    type ControlHandle = BlobCreatorControlHandle;
371
372    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
373        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
374    }
375
376    fn control_handle(&self) -> Self::ControlHandle {
377        BlobCreatorControlHandle { inner: self.inner.clone() }
378    }
379
380    fn into_inner(
381        self,
382    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
383    {
384        (self.inner, self.is_terminated)
385    }
386
387    fn from_inner(
388        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
389        is_terminated: bool,
390    ) -> Self {
391        Self { inner, is_terminated }
392    }
393}
394
395impl futures::Stream for BlobCreatorRequestStream {
396    type Item = Result<BlobCreatorRequest, fidl::Error>;
397
398    fn poll_next(
399        mut self: std::pin::Pin<&mut Self>,
400        cx: &mut std::task::Context<'_>,
401    ) -> std::task::Poll<Option<Self::Item>> {
402        let this = &mut *self;
403        if this.inner.check_shutdown(cx) {
404            this.is_terminated = true;
405            return std::task::Poll::Ready(None);
406        }
407        if this.is_terminated {
408            panic!("polled BlobCreatorRequestStream after completion");
409        }
410        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
411            |bytes, handles| {
412                match this.inner.channel().read_etc(cx, bytes, handles) {
413                    std::task::Poll::Ready(Ok(())) => {}
414                    std::task::Poll::Pending => return std::task::Poll::Pending,
415                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
416                        this.is_terminated = true;
417                        return std::task::Poll::Ready(None);
418                    }
419                    std::task::Poll::Ready(Err(e)) => {
420                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
421                            e.into(),
422                        ))));
423                    }
424                }
425
426                // A message has been received from the channel
427                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
428
429                std::task::Poll::Ready(Some(match header.ordinal {
430                    0x4288fe720cca70d7 => {
431                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
432                        let mut req = fidl::new_empty!(
433                            BlobCreatorCreateRequest,
434                            fidl::encoding::DefaultFuchsiaResourceDialect
435                        );
436                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobCreatorCreateRequest>(&header, _body_bytes, handles, &mut req)?;
437                        let control_handle = BlobCreatorControlHandle { inner: this.inner.clone() };
438                        Ok(BlobCreatorRequest::Create {
439                            hash: req.hash,
440                            allow_existing: req.allow_existing,
441
442                            responder: BlobCreatorCreateResponder {
443                                control_handle: std::mem::ManuallyDrop::new(control_handle),
444                                tx_id: header.tx_id,
445                            },
446                        })
447                    }
448                    0x512e347a6be3e426 => {
449                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
450                        let mut req = fidl::new_empty!(
451                            BlobCreatorNeedsOverwriteRequest,
452                            fidl::encoding::DefaultFuchsiaResourceDialect
453                        );
454                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobCreatorNeedsOverwriteRequest>(&header, _body_bytes, handles, &mut req)?;
455                        let control_handle = BlobCreatorControlHandle { inner: this.inner.clone() };
456                        Ok(BlobCreatorRequest::NeedsOverwrite {
457                            blob_hash: req.blob_hash,
458
459                            responder: BlobCreatorNeedsOverwriteResponder {
460                                control_handle: std::mem::ManuallyDrop::new(control_handle),
461                                tx_id: header.tx_id,
462                            },
463                        })
464                    }
465                    _ => Err(fidl::Error::UnknownOrdinal {
466                        ordinal: header.ordinal,
467                        protocol_name:
468                            <BlobCreatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
469                    }),
470                }))
471            },
472        )
473    }
474}
475
476#[derive(Debug)]
477pub enum BlobCreatorRequest {
478    /// Creates a blob with the merkle root `hash`. If `allow_existing` is true, the server will
479    /// overwrite the existing blob if there is one. The server may fail this request with
480    /// `[CreateBlobError.ALREADY_EXISTS]` if there is already an inflight `BlobWriter` for the same
481    /// hash which has not been closed or completed. The client will truncate the blob with
482    /// [BlobWriter.GetVmo] and get a handle to a vmo in return. The client will then write blob
483    /// contents into the vmo and call [BlobWriter.BytesReady] on the 'writer` to signal to the
484    /// server that some number of bytes has been written to the vmo.
485    Create { hash: [u8; 32], allow_existing: bool, responder: BlobCreatorCreateResponder },
486    /// Given the hash of a blob, returns true if it should be overwritten using Create with
487    /// `allow_existing` set to true. Must respond the same as `BlobReader.GetVmo` in terms of
488    /// existence checks, responding ZX_ERR_NOT_FOUND under the same conditions.
489    NeedsOverwrite { blob_hash: [u8; 32], responder: BlobCreatorNeedsOverwriteResponder },
490}
491
492impl BlobCreatorRequest {
493    #[allow(irrefutable_let_patterns)]
494    pub fn into_create(self) -> Option<([u8; 32], bool, BlobCreatorCreateResponder)> {
495        if let BlobCreatorRequest::Create { hash, allow_existing, responder } = self {
496            Some((hash, allow_existing, responder))
497        } else {
498            None
499        }
500    }
501
502    #[allow(irrefutable_let_patterns)]
503    pub fn into_needs_overwrite(self) -> Option<([u8; 32], BlobCreatorNeedsOverwriteResponder)> {
504        if let BlobCreatorRequest::NeedsOverwrite { blob_hash, responder } = self {
505            Some((blob_hash, responder))
506        } else {
507            None
508        }
509    }
510
511    /// Name of the method defined in FIDL
512    pub fn method_name(&self) -> &'static str {
513        match *self {
514            BlobCreatorRequest::Create { .. } => "create",
515            BlobCreatorRequest::NeedsOverwrite { .. } => "needs_overwrite",
516        }
517    }
518}
519
520#[derive(Debug, Clone)]
521pub struct BlobCreatorControlHandle {
522    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
523}
524
525impl BlobCreatorControlHandle {
526    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
527        self.inner.shutdown_with_epitaph(status.into())
528    }
529}
530
531impl fidl::endpoints::ControlHandle for BlobCreatorControlHandle {
532    fn shutdown(&self) {
533        self.inner.shutdown()
534    }
535
536    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
537        self.inner.shutdown_with_epitaph(status)
538    }
539
540    fn is_closed(&self) -> bool {
541        self.inner.channel().is_closed()
542    }
543    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
544        self.inner.channel().on_closed()
545    }
546
547    #[cfg(target_os = "fuchsia")]
548    fn signal_peer(
549        &self,
550        clear_mask: zx::Signals,
551        set_mask: zx::Signals,
552    ) -> Result<(), zx_status::Status> {
553        use fidl::Peered;
554        self.inner.channel().signal_peer(clear_mask, set_mask)
555    }
556}
557
558impl BlobCreatorControlHandle {}
559
560#[must_use = "FIDL methods require a response to be sent"]
561#[derive(Debug)]
562pub struct BlobCreatorCreateResponder {
563    control_handle: std::mem::ManuallyDrop<BlobCreatorControlHandle>,
564    tx_id: u32,
565}
566
567/// Set the the channel to be shutdown (see [`BlobCreatorControlHandle::shutdown`])
568/// if the responder is dropped without sending a response, so that the client
569/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
570impl std::ops::Drop for BlobCreatorCreateResponder {
571    fn drop(&mut self) {
572        self.control_handle.shutdown();
573        // Safety: drops once, never accessed again
574        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
575    }
576}
577
578impl fidl::endpoints::Responder for BlobCreatorCreateResponder {
579    type ControlHandle = BlobCreatorControlHandle;
580
581    fn control_handle(&self) -> &BlobCreatorControlHandle {
582        &self.control_handle
583    }
584
585    fn drop_without_shutdown(mut self) {
586        // Safety: drops once, never accessed again due to mem::forget
587        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
588        // Prevent Drop from running (which would shut down the channel)
589        std::mem::forget(self);
590    }
591}
592
593impl BlobCreatorCreateResponder {
594    /// Sends a response to the FIDL transaction.
595    ///
596    /// Sets the channel to shutdown if an error occurs.
597    pub fn send(
598        self,
599        mut result: Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>,
600    ) -> Result<(), fidl::Error> {
601        let _result = self.send_raw(result);
602        if _result.is_err() {
603            self.control_handle.shutdown();
604        }
605        self.drop_without_shutdown();
606        _result
607    }
608
609    /// Similar to "send" but does not shutdown the channel if an error occurs.
610    pub fn send_no_shutdown_on_err(
611        self,
612        mut result: Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>,
613    ) -> Result<(), fidl::Error> {
614        let _result = self.send_raw(result);
615        self.drop_without_shutdown();
616        _result
617    }
618
619    fn send_raw(
620        &self,
621        mut result: Result<fidl::endpoints::ClientEnd<BlobWriterMarker>, CreateBlobError>,
622    ) -> Result<(), fidl::Error> {
623        self.control_handle.inner.send::<fidl::encoding::ResultType<
624            BlobCreatorCreateResponse,
625            CreateBlobError,
626        >>(
627            result.map(|writer| (writer,)),
628            self.tx_id,
629            0x4288fe720cca70d7,
630            fidl::encoding::DynamicFlags::empty(),
631        )
632    }
633}
634
635#[must_use = "FIDL methods require a response to be sent"]
636#[derive(Debug)]
637pub struct BlobCreatorNeedsOverwriteResponder {
638    control_handle: std::mem::ManuallyDrop<BlobCreatorControlHandle>,
639    tx_id: u32,
640}
641
642/// Set the the channel to be shutdown (see [`BlobCreatorControlHandle::shutdown`])
643/// if the responder is dropped without sending a response, so that the client
644/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
645impl std::ops::Drop for BlobCreatorNeedsOverwriteResponder {
646    fn drop(&mut self) {
647        self.control_handle.shutdown();
648        // Safety: drops once, never accessed again
649        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
650    }
651}
652
653impl fidl::endpoints::Responder for BlobCreatorNeedsOverwriteResponder {
654    type ControlHandle = BlobCreatorControlHandle;
655
656    fn control_handle(&self) -> &BlobCreatorControlHandle {
657        &self.control_handle
658    }
659
660    fn drop_without_shutdown(mut self) {
661        // Safety: drops once, never accessed again due to mem::forget
662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
663        // Prevent Drop from running (which would shut down the channel)
664        std::mem::forget(self);
665    }
666}
667
668impl BlobCreatorNeedsOverwriteResponder {
669    /// Sends a response to the FIDL transaction.
670    ///
671    /// Sets the channel to shutdown if an error occurs.
672    pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
673        let _result = self.send_raw(result);
674        if _result.is_err() {
675            self.control_handle.shutdown();
676        }
677        self.drop_without_shutdown();
678        _result
679    }
680
681    /// Similar to "send" but does not shutdown the channel if an error occurs.
682    pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
683        let _result = self.send_raw(result);
684        self.drop_without_shutdown();
685        _result
686    }
687
688    fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
689        self.control_handle
690            .inner
691            .send::<fidl::encoding::ResultType<BlobCreatorNeedsOverwriteResponse, i32>>(
692                result.map(|needs_overwrite| (needs_overwrite,)),
693                self.tx_id,
694                0x512e347a6be3e426,
695                fidl::encoding::DynamicFlags::empty(),
696            )
697    }
698}
699
700#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
701pub struct BlobReaderMarker;
702
703impl fidl::endpoints::ProtocolMarker for BlobReaderMarker {
704    type Proxy = BlobReaderProxy;
705    type RequestStream = BlobReaderRequestStream;
706    #[cfg(target_os = "fuchsia")]
707    type SynchronousProxy = BlobReaderSynchronousProxy;
708
709    const DEBUG_NAME: &'static str = "fuchsia.fxfs.BlobReader";
710}
711impl fidl::endpoints::DiscoverableProtocolMarker for BlobReaderMarker {}
712pub type BlobReaderGetVmoResult = Result<fidl::Vmo, i32>;
713
714pub trait BlobReaderProxyInterface: Send + Sync {
715    type GetVmoResponseFut: std::future::Future<Output = Result<BlobReaderGetVmoResult, fidl::Error>>
716        + Send;
717    fn r#get_vmo(&self, blob_hash: &[u8; 32]) -> Self::GetVmoResponseFut;
718}
719#[derive(Debug)]
720#[cfg(target_os = "fuchsia")]
721pub struct BlobReaderSynchronousProxy {
722    client: fidl::client::sync::Client,
723}
724
725#[cfg(target_os = "fuchsia")]
726impl fidl::endpoints::SynchronousProxy for BlobReaderSynchronousProxy {
727    type Proxy = BlobReaderProxy;
728    type Protocol = BlobReaderMarker;
729
730    fn from_channel(inner: fidl::Channel) -> Self {
731        Self::new(inner)
732    }
733
734    fn into_channel(self) -> fidl::Channel {
735        self.client.into_channel()
736    }
737
738    fn as_channel(&self) -> &fidl::Channel {
739        self.client.as_channel()
740    }
741}
742
743#[cfg(target_os = "fuchsia")]
744impl BlobReaderSynchronousProxy {
745    pub fn new(channel: fidl::Channel) -> Self {
746        Self { client: fidl::client::sync::Client::new(channel) }
747    }
748
749    pub fn into_channel(self) -> fidl::Channel {
750        self.client.into_channel()
751    }
752
753    /// Waits until an event arrives and returns it. It is safe for other
754    /// threads to make concurrent requests while waiting for an event.
755    pub fn wait_for_event(
756        &self,
757        deadline: zx::MonotonicInstant,
758    ) -> Result<BlobReaderEvent, fidl::Error> {
759        BlobReaderEvent::decode(self.client.wait_for_event::<BlobReaderMarker>(deadline)?)
760    }
761
762    /// Given the hash of a blob, returns a VMO with its contents.
763    pub fn r#get_vmo(
764        &self,
765        mut blob_hash: &[u8; 32],
766        ___deadline: zx::MonotonicInstant,
767    ) -> Result<BlobReaderGetVmoResult, fidl::Error> {
768        let _response = self.client.send_query::<
769            BlobReaderGetVmoRequest,
770            fidl::encoding::ResultType<BlobReaderGetVmoResponse, i32>,
771            BlobReaderMarker,
772        >(
773            (blob_hash,),
774            0x2fa72823ef7f11f4,
775            fidl::encoding::DynamicFlags::empty(),
776            ___deadline,
777        )?;
778        Ok(_response.map(|x| x.vmo))
779    }
780}
781
782#[cfg(target_os = "fuchsia")]
783impl From<BlobReaderSynchronousProxy> for zx::NullableHandle {
784    fn from(value: BlobReaderSynchronousProxy) -> Self {
785        value.into_channel().into()
786    }
787}
788
789#[cfg(target_os = "fuchsia")]
790impl From<fidl::Channel> for BlobReaderSynchronousProxy {
791    fn from(value: fidl::Channel) -> Self {
792        Self::new(value)
793    }
794}
795
796#[cfg(target_os = "fuchsia")]
797impl fidl::endpoints::FromClient for BlobReaderSynchronousProxy {
798    type Protocol = BlobReaderMarker;
799
800    fn from_client(value: fidl::endpoints::ClientEnd<BlobReaderMarker>) -> Self {
801        Self::new(value.into_channel())
802    }
803}
804
805#[derive(Debug, Clone)]
806pub struct BlobReaderProxy {
807    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
808}
809
810impl fidl::endpoints::Proxy for BlobReaderProxy {
811    type Protocol = BlobReaderMarker;
812
813    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
814        Self::new(inner)
815    }
816
817    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
818        self.client.into_channel().map_err(|client| Self { client })
819    }
820
821    fn as_channel(&self) -> &::fidl::AsyncChannel {
822        self.client.as_channel()
823    }
824}
825
826impl BlobReaderProxy {
827    /// Create a new Proxy for fuchsia.fxfs/BlobReader.
828    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
829        let protocol_name = <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
830        Self { client: fidl::client::Client::new(channel, protocol_name) }
831    }
832
833    /// Get a Stream of events from the remote end of the protocol.
834    ///
835    /// # Panics
836    ///
837    /// Panics if the event stream was already taken.
838    pub fn take_event_stream(&self) -> BlobReaderEventStream {
839        BlobReaderEventStream { event_receiver: self.client.take_event_receiver() }
840    }
841
842    /// Given the hash of a blob, returns a VMO with its contents.
843    pub fn r#get_vmo(
844        &self,
845        mut blob_hash: &[u8; 32],
846    ) -> fidl::client::QueryResponseFut<
847        BlobReaderGetVmoResult,
848        fidl::encoding::DefaultFuchsiaResourceDialect,
849    > {
850        BlobReaderProxyInterface::r#get_vmo(self, blob_hash)
851    }
852}
853
854impl BlobReaderProxyInterface for BlobReaderProxy {
855    type GetVmoResponseFut = fidl::client::QueryResponseFut<
856        BlobReaderGetVmoResult,
857        fidl::encoding::DefaultFuchsiaResourceDialect,
858    >;
859    fn r#get_vmo(&self, mut blob_hash: &[u8; 32]) -> Self::GetVmoResponseFut {
860        fn _decode(
861            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
862        ) -> Result<BlobReaderGetVmoResult, fidl::Error> {
863            let _response = fidl::client::decode_transaction_body::<
864                fidl::encoding::ResultType<BlobReaderGetVmoResponse, i32>,
865                fidl::encoding::DefaultFuchsiaResourceDialect,
866                0x2fa72823ef7f11f4,
867            >(_buf?)?;
868            Ok(_response.map(|x| x.vmo))
869        }
870        self.client.send_query_and_decode::<BlobReaderGetVmoRequest, BlobReaderGetVmoResult>(
871            (blob_hash,),
872            0x2fa72823ef7f11f4,
873            fidl::encoding::DynamicFlags::empty(),
874            _decode,
875        )
876    }
877}
878
879pub struct BlobReaderEventStream {
880    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
881}
882
883impl std::marker::Unpin for BlobReaderEventStream {}
884
885impl futures::stream::FusedStream for BlobReaderEventStream {
886    fn is_terminated(&self) -> bool {
887        self.event_receiver.is_terminated()
888    }
889}
890
891impl futures::Stream for BlobReaderEventStream {
892    type Item = Result<BlobReaderEvent, fidl::Error>;
893
894    fn poll_next(
895        mut self: std::pin::Pin<&mut Self>,
896        cx: &mut std::task::Context<'_>,
897    ) -> std::task::Poll<Option<Self::Item>> {
898        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
899            &mut self.event_receiver,
900            cx
901        )?) {
902            Some(buf) => std::task::Poll::Ready(Some(BlobReaderEvent::decode(buf))),
903            None => std::task::Poll::Ready(None),
904        }
905    }
906}
907
908#[derive(Debug)]
909pub enum BlobReaderEvent {}
910
911impl BlobReaderEvent {
912    /// Decodes a message buffer as a [`BlobReaderEvent`].
913    fn decode(
914        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
915    ) -> Result<BlobReaderEvent, fidl::Error> {
916        let (bytes, _handles) = buf.split_mut();
917        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
918        debug_assert_eq!(tx_header.tx_id, 0);
919        match tx_header.ordinal {
920            _ => Err(fidl::Error::UnknownOrdinal {
921                ordinal: tx_header.ordinal,
922                protocol_name: <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
923            }),
924        }
925    }
926}
927
928/// A Stream of incoming requests for fuchsia.fxfs/BlobReader.
929pub struct BlobReaderRequestStream {
930    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
931    is_terminated: bool,
932}
933
934impl std::marker::Unpin for BlobReaderRequestStream {}
935
936impl futures::stream::FusedStream for BlobReaderRequestStream {
937    fn is_terminated(&self) -> bool {
938        self.is_terminated
939    }
940}
941
942impl fidl::endpoints::RequestStream for BlobReaderRequestStream {
943    type Protocol = BlobReaderMarker;
944    type ControlHandle = BlobReaderControlHandle;
945
946    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
947        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
948    }
949
950    fn control_handle(&self) -> Self::ControlHandle {
951        BlobReaderControlHandle { inner: self.inner.clone() }
952    }
953
954    fn into_inner(
955        self,
956    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
957    {
958        (self.inner, self.is_terminated)
959    }
960
961    fn from_inner(
962        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
963        is_terminated: bool,
964    ) -> Self {
965        Self { inner, is_terminated }
966    }
967}
968
969impl futures::Stream for BlobReaderRequestStream {
970    type Item = Result<BlobReaderRequest, fidl::Error>;
971
972    fn poll_next(
973        mut self: std::pin::Pin<&mut Self>,
974        cx: &mut std::task::Context<'_>,
975    ) -> std::task::Poll<Option<Self::Item>> {
976        let this = &mut *self;
977        if this.inner.check_shutdown(cx) {
978            this.is_terminated = true;
979            return std::task::Poll::Ready(None);
980        }
981        if this.is_terminated {
982            panic!("polled BlobReaderRequestStream after completion");
983        }
984        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
985            |bytes, handles| {
986                match this.inner.channel().read_etc(cx, bytes, handles) {
987                    std::task::Poll::Ready(Ok(())) => {}
988                    std::task::Poll::Pending => return std::task::Poll::Pending,
989                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
990                        this.is_terminated = true;
991                        return std::task::Poll::Ready(None);
992                    }
993                    std::task::Poll::Ready(Err(e)) => {
994                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
995                            e.into(),
996                        ))));
997                    }
998                }
999
1000                // A message has been received from the channel
1001                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1002
1003                std::task::Poll::Ready(Some(match header.ordinal {
1004                    0x2fa72823ef7f11f4 => {
1005                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1006                        let mut req = fidl::new_empty!(
1007                            BlobReaderGetVmoRequest,
1008                            fidl::encoding::DefaultFuchsiaResourceDialect
1009                        );
1010                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobReaderGetVmoRequest>(&header, _body_bytes, handles, &mut req)?;
1011                        let control_handle = BlobReaderControlHandle { inner: this.inner.clone() };
1012                        Ok(BlobReaderRequest::GetVmo {
1013                            blob_hash: req.blob_hash,
1014
1015                            responder: BlobReaderGetVmoResponder {
1016                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1017                                tx_id: header.tx_id,
1018                            },
1019                        })
1020                    }
1021                    _ => Err(fidl::Error::UnknownOrdinal {
1022                        ordinal: header.ordinal,
1023                        protocol_name:
1024                            <BlobReaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1025                    }),
1026                }))
1027            },
1028        )
1029    }
1030}
1031
1032#[derive(Debug)]
1033pub enum BlobReaderRequest {
1034    /// Given the hash of a blob, returns a VMO with its contents.
1035    GetVmo { blob_hash: [u8; 32], responder: BlobReaderGetVmoResponder },
1036}
1037
1038impl BlobReaderRequest {
1039    #[allow(irrefutable_let_patterns)]
1040    pub fn into_get_vmo(self) -> Option<([u8; 32], BlobReaderGetVmoResponder)> {
1041        if let BlobReaderRequest::GetVmo { blob_hash, responder } = self {
1042            Some((blob_hash, responder))
1043        } else {
1044            None
1045        }
1046    }
1047
1048    /// Name of the method defined in FIDL
1049    pub fn method_name(&self) -> &'static str {
1050        match *self {
1051            BlobReaderRequest::GetVmo { .. } => "get_vmo",
1052        }
1053    }
1054}
1055
1056#[derive(Debug, Clone)]
1057pub struct BlobReaderControlHandle {
1058    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1059}
1060
1061impl BlobReaderControlHandle {
1062    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1063        self.inner.shutdown_with_epitaph(status.into())
1064    }
1065}
1066
1067impl fidl::endpoints::ControlHandle for BlobReaderControlHandle {
1068    fn shutdown(&self) {
1069        self.inner.shutdown()
1070    }
1071
1072    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1073        self.inner.shutdown_with_epitaph(status)
1074    }
1075
1076    fn is_closed(&self) -> bool {
1077        self.inner.channel().is_closed()
1078    }
1079    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1080        self.inner.channel().on_closed()
1081    }
1082
1083    #[cfg(target_os = "fuchsia")]
1084    fn signal_peer(
1085        &self,
1086        clear_mask: zx::Signals,
1087        set_mask: zx::Signals,
1088    ) -> Result<(), zx_status::Status> {
1089        use fidl::Peered;
1090        self.inner.channel().signal_peer(clear_mask, set_mask)
1091    }
1092}
1093
1094impl BlobReaderControlHandle {}
1095
1096#[must_use = "FIDL methods require a response to be sent"]
1097#[derive(Debug)]
1098pub struct BlobReaderGetVmoResponder {
1099    control_handle: std::mem::ManuallyDrop<BlobReaderControlHandle>,
1100    tx_id: u32,
1101}
1102
1103/// Set the the channel to be shutdown (see [`BlobReaderControlHandle::shutdown`])
1104/// if the responder is dropped without sending a response, so that the client
1105/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1106impl std::ops::Drop for BlobReaderGetVmoResponder {
1107    fn drop(&mut self) {
1108        self.control_handle.shutdown();
1109        // Safety: drops once, never accessed again
1110        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1111    }
1112}
1113
1114impl fidl::endpoints::Responder for BlobReaderGetVmoResponder {
1115    type ControlHandle = BlobReaderControlHandle;
1116
1117    fn control_handle(&self) -> &BlobReaderControlHandle {
1118        &self.control_handle
1119    }
1120
1121    fn drop_without_shutdown(mut self) {
1122        // Safety: drops once, never accessed again due to mem::forget
1123        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1124        // Prevent Drop from running (which would shut down the channel)
1125        std::mem::forget(self);
1126    }
1127}
1128
1129impl BlobReaderGetVmoResponder {
1130    /// Sends a response to the FIDL transaction.
1131    ///
1132    /// Sets the channel to shutdown if an error occurs.
1133    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1134        let _result = self.send_raw(result);
1135        if _result.is_err() {
1136            self.control_handle.shutdown();
1137        }
1138        self.drop_without_shutdown();
1139        _result
1140    }
1141
1142    /// Similar to "send" but does not shutdown the channel if an error occurs.
1143    pub fn send_no_shutdown_on_err(
1144        self,
1145        mut result: Result<fidl::Vmo, i32>,
1146    ) -> Result<(), fidl::Error> {
1147        let _result = self.send_raw(result);
1148        self.drop_without_shutdown();
1149        _result
1150    }
1151
1152    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1153        self.control_handle.inner.send::<fidl::encoding::ResultType<BlobReaderGetVmoResponse, i32>>(
1154            result.map(|vmo| (vmo,)),
1155            self.tx_id,
1156            0x2fa72823ef7f11f4,
1157            fidl::encoding::DynamicFlags::empty(),
1158        )
1159    }
1160}
1161
1162#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1163pub struct BlobWriterMarker;
1164
1165impl fidl::endpoints::ProtocolMarker for BlobWriterMarker {
1166    type Proxy = BlobWriterProxy;
1167    type RequestStream = BlobWriterRequestStream;
1168    #[cfg(target_os = "fuchsia")]
1169    type SynchronousProxy = BlobWriterSynchronousProxy;
1170
1171    const DEBUG_NAME: &'static str = "(anonymous) BlobWriter";
1172}
1173pub type BlobWriterGetVmoResult = Result<fidl::Vmo, i32>;
1174pub type BlobWriterBytesReadyResult = Result<(), i32>;
1175
1176pub trait BlobWriterProxyInterface: Send + Sync {
1177    type GetVmoResponseFut: std::future::Future<Output = Result<BlobWriterGetVmoResult, fidl::Error>>
1178        + Send;
1179    fn r#get_vmo(&self, size: u64) -> Self::GetVmoResponseFut;
1180    type BytesReadyResponseFut: std::future::Future<Output = Result<BlobWriterBytesReadyResult, fidl::Error>>
1181        + Send;
1182    fn r#bytes_ready(&self, bytes_written: u64) -> Self::BytesReadyResponseFut;
1183}
1184#[derive(Debug)]
1185#[cfg(target_os = "fuchsia")]
1186pub struct BlobWriterSynchronousProxy {
1187    client: fidl::client::sync::Client,
1188}
1189
1190#[cfg(target_os = "fuchsia")]
1191impl fidl::endpoints::SynchronousProxy for BlobWriterSynchronousProxy {
1192    type Proxy = BlobWriterProxy;
1193    type Protocol = BlobWriterMarker;
1194
1195    fn from_channel(inner: fidl::Channel) -> Self {
1196        Self::new(inner)
1197    }
1198
1199    fn into_channel(self) -> fidl::Channel {
1200        self.client.into_channel()
1201    }
1202
1203    fn as_channel(&self) -> &fidl::Channel {
1204        self.client.as_channel()
1205    }
1206}
1207
1208#[cfg(target_os = "fuchsia")]
1209impl BlobWriterSynchronousProxy {
1210    pub fn new(channel: fidl::Channel) -> Self {
1211        Self { client: fidl::client::sync::Client::new(channel) }
1212    }
1213
1214    pub fn into_channel(self) -> fidl::Channel {
1215        self.client.into_channel()
1216    }
1217
1218    /// Waits until an event arrives and returns it. It is safe for other
1219    /// threads to make concurrent requests while waiting for an event.
1220    pub fn wait_for_event(
1221        &self,
1222        deadline: zx::MonotonicInstant,
1223    ) -> Result<BlobWriterEvent, fidl::Error> {
1224        BlobWriterEvent::decode(self.client.wait_for_event::<BlobWriterMarker>(deadline)?)
1225    }
1226
1227    /// Truncates the blob associated with this BlobWriter proxy to length `size`. Returns a handle
1228    /// to a `vmo` shared between the server and the client, which is implemented as a ring buffer.
1229    /// As the client writes blob contents into the `vmo`, it will call BytesReady to signal to the
1230    /// server that some number of bytes have been written.
1231    ///
1232    /// Ring Buffer Semantics
1233    /// The server sets the size of the vmo passed back to the client. The chunks that the client
1234    /// writes are arbitrarily sized and do not have any alignment guarantees. Any particular write
1235    /// can wrap around the ring buffer. The client can have several outstanding BytesReady
1236    /// requests but the client is responsible for not overwriting a given range in the ring buffer
1237    /// until the BytesReady request corresponding to that range has completed.
1238    pub fn r#get_vmo(
1239        &self,
1240        mut size: u64,
1241        ___deadline: zx::MonotonicInstant,
1242    ) -> Result<BlobWriterGetVmoResult, fidl::Error> {
1243        let _response = self.client.send_query::<
1244            BlobWriterGetVmoRequest,
1245            fidl::encoding::ResultType<BlobWriterGetVmoResponse, i32>,
1246            BlobWriterMarker,
1247        >(
1248            (size,),
1249            0x50c8988b12b6f893,
1250            fidl::encoding::DynamicFlags::empty(),
1251            ___deadline,
1252        )?;
1253        Ok(_response.map(|x| x.vmo))
1254    }
1255
1256    /// Indicates to the server that an additional `bytes_written` number of bytes have been
1257    /// written to the shared vmo and are ready to be read off the vmo and written to disk. The
1258    /// blob will be readable when the final BytesReady response is received by the client.
1259    pub fn r#bytes_ready(
1260        &self,
1261        mut bytes_written: u64,
1262        ___deadline: zx::MonotonicInstant,
1263    ) -> Result<BlobWriterBytesReadyResult, fidl::Error> {
1264        let _response = self.client.send_query::<
1265            BlobWriterBytesReadyRequest,
1266            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1267            BlobWriterMarker,
1268        >(
1269            (bytes_written,),
1270            0x7b308b473606c573,
1271            fidl::encoding::DynamicFlags::empty(),
1272            ___deadline,
1273        )?;
1274        Ok(_response.map(|x| x))
1275    }
1276}
1277
1278#[cfg(target_os = "fuchsia")]
1279impl From<BlobWriterSynchronousProxy> for zx::NullableHandle {
1280    fn from(value: BlobWriterSynchronousProxy) -> Self {
1281        value.into_channel().into()
1282    }
1283}
1284
1285#[cfg(target_os = "fuchsia")]
1286impl From<fidl::Channel> for BlobWriterSynchronousProxy {
1287    fn from(value: fidl::Channel) -> Self {
1288        Self::new(value)
1289    }
1290}
1291
1292#[cfg(target_os = "fuchsia")]
1293impl fidl::endpoints::FromClient for BlobWriterSynchronousProxy {
1294    type Protocol = BlobWriterMarker;
1295
1296    fn from_client(value: fidl::endpoints::ClientEnd<BlobWriterMarker>) -> Self {
1297        Self::new(value.into_channel())
1298    }
1299}
1300
1301#[derive(Debug, Clone)]
1302pub struct BlobWriterProxy {
1303    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1304}
1305
1306impl fidl::endpoints::Proxy for BlobWriterProxy {
1307    type Protocol = BlobWriterMarker;
1308
1309    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1310        Self::new(inner)
1311    }
1312
1313    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1314        self.client.into_channel().map_err(|client| Self { client })
1315    }
1316
1317    fn as_channel(&self) -> &::fidl::AsyncChannel {
1318        self.client.as_channel()
1319    }
1320}
1321
1322impl BlobWriterProxy {
1323    /// Create a new Proxy for fuchsia.fxfs/BlobWriter.
1324    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1325        let protocol_name = <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1326        Self { client: fidl::client::Client::new(channel, protocol_name) }
1327    }
1328
1329    /// Get a Stream of events from the remote end of the protocol.
1330    ///
1331    /// # Panics
1332    ///
1333    /// Panics if the event stream was already taken.
1334    pub fn take_event_stream(&self) -> BlobWriterEventStream {
1335        BlobWriterEventStream { event_receiver: self.client.take_event_receiver() }
1336    }
1337
1338    /// Truncates the blob associated with this BlobWriter proxy to length `size`. Returns a handle
1339    /// to a `vmo` shared between the server and the client, which is implemented as a ring buffer.
1340    /// As the client writes blob contents into the `vmo`, it will call BytesReady to signal to the
1341    /// server that some number of bytes have been written.
1342    ///
1343    /// Ring Buffer Semantics
1344    /// The server sets the size of the vmo passed back to the client. The chunks that the client
1345    /// writes are arbitrarily sized and do not have any alignment guarantees. Any particular write
1346    /// can wrap around the ring buffer. The client can have several outstanding BytesReady
1347    /// requests but the client is responsible for not overwriting a given range in the ring buffer
1348    /// until the BytesReady request corresponding to that range has completed.
1349    pub fn r#get_vmo(
1350        &self,
1351        mut size: u64,
1352    ) -> fidl::client::QueryResponseFut<
1353        BlobWriterGetVmoResult,
1354        fidl::encoding::DefaultFuchsiaResourceDialect,
1355    > {
1356        BlobWriterProxyInterface::r#get_vmo(self, size)
1357    }
1358
1359    /// Indicates to the server that an additional `bytes_written` number of bytes have been
1360    /// written to the shared vmo and are ready to be read off the vmo and written to disk. The
1361    /// blob will be readable when the final BytesReady response is received by the client.
1362    pub fn r#bytes_ready(
1363        &self,
1364        mut bytes_written: u64,
1365    ) -> fidl::client::QueryResponseFut<
1366        BlobWriterBytesReadyResult,
1367        fidl::encoding::DefaultFuchsiaResourceDialect,
1368    > {
1369        BlobWriterProxyInterface::r#bytes_ready(self, bytes_written)
1370    }
1371}
1372
1373impl BlobWriterProxyInterface for BlobWriterProxy {
1374    type GetVmoResponseFut = fidl::client::QueryResponseFut<
1375        BlobWriterGetVmoResult,
1376        fidl::encoding::DefaultFuchsiaResourceDialect,
1377    >;
1378    fn r#get_vmo(&self, mut size: u64) -> Self::GetVmoResponseFut {
1379        fn _decode(
1380            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1381        ) -> Result<BlobWriterGetVmoResult, fidl::Error> {
1382            let _response = fidl::client::decode_transaction_body::<
1383                fidl::encoding::ResultType<BlobWriterGetVmoResponse, i32>,
1384                fidl::encoding::DefaultFuchsiaResourceDialect,
1385                0x50c8988b12b6f893,
1386            >(_buf?)?;
1387            Ok(_response.map(|x| x.vmo))
1388        }
1389        self.client.send_query_and_decode::<BlobWriterGetVmoRequest, BlobWriterGetVmoResult>(
1390            (size,),
1391            0x50c8988b12b6f893,
1392            fidl::encoding::DynamicFlags::empty(),
1393            _decode,
1394        )
1395    }
1396
1397    type BytesReadyResponseFut = fidl::client::QueryResponseFut<
1398        BlobWriterBytesReadyResult,
1399        fidl::encoding::DefaultFuchsiaResourceDialect,
1400    >;
1401    fn r#bytes_ready(&self, mut bytes_written: u64) -> Self::BytesReadyResponseFut {
1402        fn _decode(
1403            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1404        ) -> Result<BlobWriterBytesReadyResult, fidl::Error> {
1405            let _response = fidl::client::decode_transaction_body::<
1406                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
1407                fidl::encoding::DefaultFuchsiaResourceDialect,
1408                0x7b308b473606c573,
1409            >(_buf?)?;
1410            Ok(_response.map(|x| x))
1411        }
1412        self.client
1413            .send_query_and_decode::<BlobWriterBytesReadyRequest, BlobWriterBytesReadyResult>(
1414                (bytes_written,),
1415                0x7b308b473606c573,
1416                fidl::encoding::DynamicFlags::empty(),
1417                _decode,
1418            )
1419    }
1420}
1421
1422pub struct BlobWriterEventStream {
1423    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1424}
1425
1426impl std::marker::Unpin for BlobWriterEventStream {}
1427
1428impl futures::stream::FusedStream for BlobWriterEventStream {
1429    fn is_terminated(&self) -> bool {
1430        self.event_receiver.is_terminated()
1431    }
1432}
1433
1434impl futures::Stream for BlobWriterEventStream {
1435    type Item = Result<BlobWriterEvent, fidl::Error>;
1436
1437    fn poll_next(
1438        mut self: std::pin::Pin<&mut Self>,
1439        cx: &mut std::task::Context<'_>,
1440    ) -> std::task::Poll<Option<Self::Item>> {
1441        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1442            &mut self.event_receiver,
1443            cx
1444        )?) {
1445            Some(buf) => std::task::Poll::Ready(Some(BlobWriterEvent::decode(buf))),
1446            None => std::task::Poll::Ready(None),
1447        }
1448    }
1449}
1450
1451#[derive(Debug)]
1452pub enum BlobWriterEvent {}
1453
1454impl BlobWriterEvent {
1455    /// Decodes a message buffer as a [`BlobWriterEvent`].
1456    fn decode(
1457        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1458    ) -> Result<BlobWriterEvent, fidl::Error> {
1459        let (bytes, _handles) = buf.split_mut();
1460        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1461        debug_assert_eq!(tx_header.tx_id, 0);
1462        match tx_header.ordinal {
1463            _ => Err(fidl::Error::UnknownOrdinal {
1464                ordinal: tx_header.ordinal,
1465                protocol_name: <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1466            }),
1467        }
1468    }
1469}
1470
1471/// A Stream of incoming requests for fuchsia.fxfs/BlobWriter.
1472pub struct BlobWriterRequestStream {
1473    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1474    is_terminated: bool,
1475}
1476
1477impl std::marker::Unpin for BlobWriterRequestStream {}
1478
1479impl futures::stream::FusedStream for BlobWriterRequestStream {
1480    fn is_terminated(&self) -> bool {
1481        self.is_terminated
1482    }
1483}
1484
1485impl fidl::endpoints::RequestStream for BlobWriterRequestStream {
1486    type Protocol = BlobWriterMarker;
1487    type ControlHandle = BlobWriterControlHandle;
1488
1489    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1490        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1491    }
1492
1493    fn control_handle(&self) -> Self::ControlHandle {
1494        BlobWriterControlHandle { inner: self.inner.clone() }
1495    }
1496
1497    fn into_inner(
1498        self,
1499    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1500    {
1501        (self.inner, self.is_terminated)
1502    }
1503
1504    fn from_inner(
1505        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1506        is_terminated: bool,
1507    ) -> Self {
1508        Self { inner, is_terminated }
1509    }
1510}
1511
1512impl futures::Stream for BlobWriterRequestStream {
1513    type Item = Result<BlobWriterRequest, fidl::Error>;
1514
1515    fn poll_next(
1516        mut self: std::pin::Pin<&mut Self>,
1517        cx: &mut std::task::Context<'_>,
1518    ) -> std::task::Poll<Option<Self::Item>> {
1519        let this = &mut *self;
1520        if this.inner.check_shutdown(cx) {
1521            this.is_terminated = true;
1522            return std::task::Poll::Ready(None);
1523        }
1524        if this.is_terminated {
1525            panic!("polled BlobWriterRequestStream after completion");
1526        }
1527        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1528            |bytes, handles| {
1529                match this.inner.channel().read_etc(cx, bytes, handles) {
1530                    std::task::Poll::Ready(Ok(())) => {}
1531                    std::task::Poll::Pending => return std::task::Poll::Pending,
1532                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1533                        this.is_terminated = true;
1534                        return std::task::Poll::Ready(None);
1535                    }
1536                    std::task::Poll::Ready(Err(e)) => {
1537                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1538                            e.into(),
1539                        ))));
1540                    }
1541                }
1542
1543                // A message has been received from the channel
1544                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1545
1546                std::task::Poll::Ready(Some(match header.ordinal {
1547                    0x50c8988b12b6f893 => {
1548                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1549                        let mut req = fidl::new_empty!(
1550                            BlobWriterGetVmoRequest,
1551                            fidl::encoding::DefaultFuchsiaResourceDialect
1552                        );
1553                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobWriterGetVmoRequest>(&header, _body_bytes, handles, &mut req)?;
1554                        let control_handle = BlobWriterControlHandle { inner: this.inner.clone() };
1555                        Ok(BlobWriterRequest::GetVmo {
1556                            size: req.size,
1557
1558                            responder: BlobWriterGetVmoResponder {
1559                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1560                                tx_id: header.tx_id,
1561                            },
1562                        })
1563                    }
1564                    0x7b308b473606c573 => {
1565                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1566                        let mut req = fidl::new_empty!(
1567                            BlobWriterBytesReadyRequest,
1568                            fidl::encoding::DefaultFuchsiaResourceDialect
1569                        );
1570                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BlobWriterBytesReadyRequest>(&header, _body_bytes, handles, &mut req)?;
1571                        let control_handle = BlobWriterControlHandle { inner: this.inner.clone() };
1572                        Ok(BlobWriterRequest::BytesReady {
1573                            bytes_written: req.bytes_written,
1574
1575                            responder: BlobWriterBytesReadyResponder {
1576                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1577                                tx_id: header.tx_id,
1578                            },
1579                        })
1580                    }
1581                    _ => Err(fidl::Error::UnknownOrdinal {
1582                        ordinal: header.ordinal,
1583                        protocol_name:
1584                            <BlobWriterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1585                    }),
1586                }))
1587            },
1588        )
1589    }
1590}
1591
1592#[derive(Debug)]
1593pub enum BlobWriterRequest {
1594    /// Truncates the blob associated with this BlobWriter proxy to length `size`. Returns a handle
1595    /// to a `vmo` shared between the server and the client, which is implemented as a ring buffer.
1596    /// As the client writes blob contents into the `vmo`, it will call BytesReady to signal to the
1597    /// server that some number of bytes have been written.
1598    ///
1599    /// Ring Buffer Semantics
1600    /// The server sets the size of the vmo passed back to the client. The chunks that the client
1601    /// writes are arbitrarily sized and do not have any alignment guarantees. Any particular write
1602    /// can wrap around the ring buffer. The client can have several outstanding BytesReady
1603    /// requests but the client is responsible for not overwriting a given range in the ring buffer
1604    /// until the BytesReady request corresponding to that range has completed.
1605    GetVmo { size: u64, responder: BlobWriterGetVmoResponder },
1606    /// Indicates to the server that an additional `bytes_written` number of bytes have been
1607    /// written to the shared vmo and are ready to be read off the vmo and written to disk. The
1608    /// blob will be readable when the final BytesReady response is received by the client.
1609    BytesReady { bytes_written: u64, responder: BlobWriterBytesReadyResponder },
1610}
1611
1612impl BlobWriterRequest {
1613    #[allow(irrefutable_let_patterns)]
1614    pub fn into_get_vmo(self) -> Option<(u64, BlobWriterGetVmoResponder)> {
1615        if let BlobWriterRequest::GetVmo { size, responder } = self {
1616            Some((size, responder))
1617        } else {
1618            None
1619        }
1620    }
1621
1622    #[allow(irrefutable_let_patterns)]
1623    pub fn into_bytes_ready(self) -> Option<(u64, BlobWriterBytesReadyResponder)> {
1624        if let BlobWriterRequest::BytesReady { bytes_written, responder } = self {
1625            Some((bytes_written, responder))
1626        } else {
1627            None
1628        }
1629    }
1630
1631    /// Name of the method defined in FIDL
1632    pub fn method_name(&self) -> &'static str {
1633        match *self {
1634            BlobWriterRequest::GetVmo { .. } => "get_vmo",
1635            BlobWriterRequest::BytesReady { .. } => "bytes_ready",
1636        }
1637    }
1638}
1639
1640#[derive(Debug, Clone)]
1641pub struct BlobWriterControlHandle {
1642    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1643}
1644
1645impl BlobWriterControlHandle {
1646    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1647        self.inner.shutdown_with_epitaph(status.into())
1648    }
1649}
1650
1651impl fidl::endpoints::ControlHandle for BlobWriterControlHandle {
1652    fn shutdown(&self) {
1653        self.inner.shutdown()
1654    }
1655
1656    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1657        self.inner.shutdown_with_epitaph(status)
1658    }
1659
1660    fn is_closed(&self) -> bool {
1661        self.inner.channel().is_closed()
1662    }
1663    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1664        self.inner.channel().on_closed()
1665    }
1666
1667    #[cfg(target_os = "fuchsia")]
1668    fn signal_peer(
1669        &self,
1670        clear_mask: zx::Signals,
1671        set_mask: zx::Signals,
1672    ) -> Result<(), zx_status::Status> {
1673        use fidl::Peered;
1674        self.inner.channel().signal_peer(clear_mask, set_mask)
1675    }
1676}
1677
1678impl BlobWriterControlHandle {}
1679
1680#[must_use = "FIDL methods require a response to be sent"]
1681#[derive(Debug)]
1682pub struct BlobWriterGetVmoResponder {
1683    control_handle: std::mem::ManuallyDrop<BlobWriterControlHandle>,
1684    tx_id: u32,
1685}
1686
1687/// Set the the channel to be shutdown (see [`BlobWriterControlHandle::shutdown`])
1688/// if the responder is dropped without sending a response, so that the client
1689/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1690impl std::ops::Drop for BlobWriterGetVmoResponder {
1691    fn drop(&mut self) {
1692        self.control_handle.shutdown();
1693        // Safety: drops once, never accessed again
1694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1695    }
1696}
1697
1698impl fidl::endpoints::Responder for BlobWriterGetVmoResponder {
1699    type ControlHandle = BlobWriterControlHandle;
1700
1701    fn control_handle(&self) -> &BlobWriterControlHandle {
1702        &self.control_handle
1703    }
1704
1705    fn drop_without_shutdown(mut self) {
1706        // Safety: drops once, never accessed again due to mem::forget
1707        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1708        // Prevent Drop from running (which would shut down the channel)
1709        std::mem::forget(self);
1710    }
1711}
1712
1713impl BlobWriterGetVmoResponder {
1714    /// Sends a response to the FIDL transaction.
1715    ///
1716    /// Sets the channel to shutdown if an error occurs.
1717    pub fn send(self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1718        let _result = self.send_raw(result);
1719        if _result.is_err() {
1720            self.control_handle.shutdown();
1721        }
1722        self.drop_without_shutdown();
1723        _result
1724    }
1725
1726    /// Similar to "send" but does not shutdown the channel if an error occurs.
1727    pub fn send_no_shutdown_on_err(
1728        self,
1729        mut result: Result<fidl::Vmo, i32>,
1730    ) -> Result<(), fidl::Error> {
1731        let _result = self.send_raw(result);
1732        self.drop_without_shutdown();
1733        _result
1734    }
1735
1736    fn send_raw(&self, mut result: Result<fidl::Vmo, i32>) -> Result<(), fidl::Error> {
1737        self.control_handle.inner.send::<fidl::encoding::ResultType<BlobWriterGetVmoResponse, i32>>(
1738            result.map(|vmo| (vmo,)),
1739            self.tx_id,
1740            0x50c8988b12b6f893,
1741            fidl::encoding::DynamicFlags::empty(),
1742        )
1743    }
1744}
1745
1746#[must_use = "FIDL methods require a response to be sent"]
1747#[derive(Debug)]
1748pub struct BlobWriterBytesReadyResponder {
1749    control_handle: std::mem::ManuallyDrop<BlobWriterControlHandle>,
1750    tx_id: u32,
1751}
1752
1753/// Set the the channel to be shutdown (see [`BlobWriterControlHandle::shutdown`])
1754/// if the responder is dropped without sending a response, so that the client
1755/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1756impl std::ops::Drop for BlobWriterBytesReadyResponder {
1757    fn drop(&mut self) {
1758        self.control_handle.shutdown();
1759        // Safety: drops once, never accessed again
1760        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1761    }
1762}
1763
1764impl fidl::endpoints::Responder for BlobWriterBytesReadyResponder {
1765    type ControlHandle = BlobWriterControlHandle;
1766
1767    fn control_handle(&self) -> &BlobWriterControlHandle {
1768        &self.control_handle
1769    }
1770
1771    fn drop_without_shutdown(mut self) {
1772        // Safety: drops once, never accessed again due to mem::forget
1773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1774        // Prevent Drop from running (which would shut down the channel)
1775        std::mem::forget(self);
1776    }
1777}
1778
1779impl BlobWriterBytesReadyResponder {
1780    /// Sends a response to the FIDL transaction.
1781    ///
1782    /// Sets the channel to shutdown if an error occurs.
1783    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1784        let _result = self.send_raw(result);
1785        if _result.is_err() {
1786            self.control_handle.shutdown();
1787        }
1788        self.drop_without_shutdown();
1789        _result
1790    }
1791
1792    /// Similar to "send" but does not shutdown the channel if an error occurs.
1793    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1794        let _result = self.send_raw(result);
1795        self.drop_without_shutdown();
1796        _result
1797    }
1798
1799    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1800        self.control_handle
1801            .inner
1802            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1803                result,
1804                self.tx_id,
1805                0x7b308b473606c573,
1806                fidl::encoding::DynamicFlags::empty(),
1807            )
1808    }
1809}
1810
1811#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1812pub struct CryptMarker;
1813
1814impl fidl::endpoints::ProtocolMarker for CryptMarker {
1815    type Proxy = CryptProxy;
1816    type RequestStream = CryptRequestStream;
1817    #[cfg(target_os = "fuchsia")]
1818    type SynchronousProxy = CryptSynchronousProxy;
1819
1820    const DEBUG_NAME: &'static str = "fuchsia.fxfs.Crypt";
1821}
1822impl fidl::endpoints::DiscoverableProtocolMarker for CryptMarker {}
1823pub type CryptCreateKeyResult = Result<([u8; 16], Vec<u8>, Vec<u8>), i32>;
1824pub type CryptCreateKeyWithIdResult = Result<(WrappedKey, Vec<u8>), i32>;
1825pub type CryptUnwrapKeyResult = Result<Vec<u8>, i32>;
1826
1827pub trait CryptProxyInterface: Send + Sync {
1828    type CreateKeyResponseFut: std::future::Future<Output = Result<CryptCreateKeyResult, fidl::Error>>
1829        + Send;
1830    fn r#create_key(&self, owner: u64, purpose: KeyPurpose) -> Self::CreateKeyResponseFut;
1831    type CreateKeyWithIdResponseFut: std::future::Future<Output = Result<CryptCreateKeyWithIdResult, fidl::Error>>
1832        + Send;
1833    fn r#create_key_with_id(
1834        &self,
1835        owner: u64,
1836        wrapping_key_id: &[u8; 16],
1837        object_type: ObjectType,
1838    ) -> Self::CreateKeyWithIdResponseFut;
1839    type UnwrapKeyResponseFut: std::future::Future<Output = Result<CryptUnwrapKeyResult, fidl::Error>>
1840        + Send;
1841    fn r#unwrap_key(&self, owner: u64, wrapped_key: &WrappedKey) -> Self::UnwrapKeyResponseFut;
1842}
1843#[derive(Debug)]
1844#[cfg(target_os = "fuchsia")]
1845pub struct CryptSynchronousProxy {
1846    client: fidl::client::sync::Client,
1847}
1848
1849#[cfg(target_os = "fuchsia")]
1850impl fidl::endpoints::SynchronousProxy for CryptSynchronousProxy {
1851    type Proxy = CryptProxy;
1852    type Protocol = CryptMarker;
1853
1854    fn from_channel(inner: fidl::Channel) -> Self {
1855        Self::new(inner)
1856    }
1857
1858    fn into_channel(self) -> fidl::Channel {
1859        self.client.into_channel()
1860    }
1861
1862    fn as_channel(&self) -> &fidl::Channel {
1863        self.client.as_channel()
1864    }
1865}
1866
1867#[cfg(target_os = "fuchsia")]
1868impl CryptSynchronousProxy {
1869    pub fn new(channel: fidl::Channel) -> Self {
1870        Self { client: fidl::client::sync::Client::new(channel) }
1871    }
1872
1873    pub fn into_channel(self) -> fidl::Channel {
1874        self.client.into_channel()
1875    }
1876
1877    /// Waits until an event arrives and returns it. It is safe for other
1878    /// threads to make concurrent requests while waiting for an event.
1879    pub fn wait_for_event(
1880        &self,
1881        deadline: zx::MonotonicInstant,
1882    ) -> Result<CryptEvent, fidl::Error> {
1883        CryptEvent::decode(self.client.wait_for_event::<CryptMarker>(deadline)?)
1884    }
1885
1886    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
1887    /// the owner of the key and must be supplied to `UnwrapKey`.  The crypt service chooses a
1888    /// `wrapping_key_id` which must be supplied to UnwrapKey.  The `wrapping_key_id` has no
1889    /// meaning to Fxfs.
1890    /// TODO(https://fxbug.dev/445189846): Add an `object_type` field to support inline encryption.
1891    pub fn r#create_key(
1892        &self,
1893        mut owner: u64,
1894        mut purpose: KeyPurpose,
1895        ___deadline: zx::MonotonicInstant,
1896    ) -> Result<CryptCreateKeyResult, fidl::Error> {
1897        let _response = self.client.send_query::<
1898            CryptCreateKeyRequest,
1899            fidl::encoding::ResultType<CryptCreateKeyResponse, i32>,
1900            CryptMarker,
1901        >(
1902            (owner, purpose,),
1903            0x6ec69b3aee7fdbba,
1904            fidl::encoding::DynamicFlags::empty(),
1905            ___deadline,
1906        )?;
1907        Ok(_response.map(|x| (x.wrapping_key_id, x.wrapped_key, x.unwrapped_key)))
1908    }
1909
1910    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
1911    /// the owner of the key and must be supplied to `UnwrapKey` along with  `wrapping_key_id`.
1912    /// The `wrapping_key_id` has no meaning to Fxfs.
1913    pub fn r#create_key_with_id(
1914        &self,
1915        mut owner: u64,
1916        mut wrapping_key_id: &[u8; 16],
1917        mut object_type: ObjectType,
1918        ___deadline: zx::MonotonicInstant,
1919    ) -> Result<CryptCreateKeyWithIdResult, fidl::Error> {
1920        let _response = self.client.send_query::<
1921            CryptCreateKeyWithIdRequest,
1922            fidl::encoding::ResultType<CryptCreateKeyWithIdResponse, i32>,
1923            CryptMarker,
1924        >(
1925            (owner, wrapping_key_id, object_type,),
1926            0x21e8076688700b50,
1927            fidl::encoding::DynamicFlags::empty(),
1928            ___deadline,
1929        )?;
1930        Ok(_response.map(|x| (x.wrapped_key, x.unwrapped_key)))
1931    }
1932
1933    /// Unwraps a key.  `owner` must be the same as that passed to `CreateKey`.
1934    /// This can fail due to permission reasons, but an incorrect key or owner will not fail;
1935    /// it will just return an unwrapped key that won't actually decrpyt the data.
1936    /// ZX_ERR_UNAVAILABLE is returned if the key is known but cannot be unwrapped (e.g. it is
1937    /// locked).
1938    /// ZX_ERR_NOT_FOUND is returned if the key is not known. In some cases, implementations are
1939    /// unable to tell the difference between the two, in which case, ZX_ERR_UNAVAILABLE is
1940    /// returned.
1941    pub fn r#unwrap_key(
1942        &self,
1943        mut owner: u64,
1944        mut wrapped_key: &WrappedKey,
1945        ___deadline: zx::MonotonicInstant,
1946    ) -> Result<CryptUnwrapKeyResult, fidl::Error> {
1947        let _response = self.client.send_query::<
1948            CryptUnwrapKeyRequest,
1949            fidl::encoding::ResultType<CryptUnwrapKeyResponse, i32>,
1950            CryptMarker,
1951        >(
1952            (owner, wrapped_key,),
1953            0x6ec34e2b64d46be9,
1954            fidl::encoding::DynamicFlags::empty(),
1955            ___deadline,
1956        )?;
1957        Ok(_response.map(|x| x.unwrapped_key))
1958    }
1959}
1960
1961#[cfg(target_os = "fuchsia")]
1962impl From<CryptSynchronousProxy> for zx::NullableHandle {
1963    fn from(value: CryptSynchronousProxy) -> Self {
1964        value.into_channel().into()
1965    }
1966}
1967
1968#[cfg(target_os = "fuchsia")]
1969impl From<fidl::Channel> for CryptSynchronousProxy {
1970    fn from(value: fidl::Channel) -> Self {
1971        Self::new(value)
1972    }
1973}
1974
1975#[cfg(target_os = "fuchsia")]
1976impl fidl::endpoints::FromClient for CryptSynchronousProxy {
1977    type Protocol = CryptMarker;
1978
1979    fn from_client(value: fidl::endpoints::ClientEnd<CryptMarker>) -> Self {
1980        Self::new(value.into_channel())
1981    }
1982}
1983
1984#[derive(Debug, Clone)]
1985pub struct CryptProxy {
1986    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1987}
1988
1989impl fidl::endpoints::Proxy for CryptProxy {
1990    type Protocol = CryptMarker;
1991
1992    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1993        Self::new(inner)
1994    }
1995
1996    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1997        self.client.into_channel().map_err(|client| Self { client })
1998    }
1999
2000    fn as_channel(&self) -> &::fidl::AsyncChannel {
2001        self.client.as_channel()
2002    }
2003}
2004
2005impl CryptProxy {
2006    /// Create a new Proxy for fuchsia.fxfs/Crypt.
2007    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2008        let protocol_name = <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2009        Self { client: fidl::client::Client::new(channel, protocol_name) }
2010    }
2011
2012    /// Get a Stream of events from the remote end of the protocol.
2013    ///
2014    /// # Panics
2015    ///
2016    /// Panics if the event stream was already taken.
2017    pub fn take_event_stream(&self) -> CryptEventStream {
2018        CryptEventStream { event_receiver: self.client.take_event_receiver() }
2019    }
2020
2021    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
2022    /// the owner of the key and must be supplied to `UnwrapKey`.  The crypt service chooses a
2023    /// `wrapping_key_id` which must be supplied to UnwrapKey.  The `wrapping_key_id` has no
2024    /// meaning to Fxfs.
2025    /// TODO(https://fxbug.dev/445189846): Add an `object_type` field to support inline encryption.
2026    pub fn r#create_key(
2027        &self,
2028        mut owner: u64,
2029        mut purpose: KeyPurpose,
2030    ) -> fidl::client::QueryResponseFut<
2031        CryptCreateKeyResult,
2032        fidl::encoding::DefaultFuchsiaResourceDialect,
2033    > {
2034        CryptProxyInterface::r#create_key(self, owner, purpose)
2035    }
2036
2037    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
2038    /// the owner of the key and must be supplied to `UnwrapKey` along with  `wrapping_key_id`.
2039    /// The `wrapping_key_id` has no meaning to Fxfs.
2040    pub fn r#create_key_with_id(
2041        &self,
2042        mut owner: u64,
2043        mut wrapping_key_id: &[u8; 16],
2044        mut object_type: ObjectType,
2045    ) -> fidl::client::QueryResponseFut<
2046        CryptCreateKeyWithIdResult,
2047        fidl::encoding::DefaultFuchsiaResourceDialect,
2048    > {
2049        CryptProxyInterface::r#create_key_with_id(self, owner, wrapping_key_id, object_type)
2050    }
2051
2052    /// Unwraps a key.  `owner` must be the same as that passed to `CreateKey`.
2053    /// This can fail due to permission reasons, but an incorrect key or owner will not fail;
2054    /// it will just return an unwrapped key that won't actually decrpyt the data.
2055    /// ZX_ERR_UNAVAILABLE is returned if the key is known but cannot be unwrapped (e.g. it is
2056    /// locked).
2057    /// ZX_ERR_NOT_FOUND is returned if the key is not known. In some cases, implementations are
2058    /// unable to tell the difference between the two, in which case, ZX_ERR_UNAVAILABLE is
2059    /// returned.
2060    pub fn r#unwrap_key(
2061        &self,
2062        mut owner: u64,
2063        mut wrapped_key: &WrappedKey,
2064    ) -> fidl::client::QueryResponseFut<
2065        CryptUnwrapKeyResult,
2066        fidl::encoding::DefaultFuchsiaResourceDialect,
2067    > {
2068        CryptProxyInterface::r#unwrap_key(self, owner, wrapped_key)
2069    }
2070}
2071
2072impl CryptProxyInterface for CryptProxy {
2073    type CreateKeyResponseFut = fidl::client::QueryResponseFut<
2074        CryptCreateKeyResult,
2075        fidl::encoding::DefaultFuchsiaResourceDialect,
2076    >;
2077    fn r#create_key(&self, mut owner: u64, mut purpose: KeyPurpose) -> Self::CreateKeyResponseFut {
2078        fn _decode(
2079            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2080        ) -> Result<CryptCreateKeyResult, fidl::Error> {
2081            let _response = fidl::client::decode_transaction_body::<
2082                fidl::encoding::ResultType<CryptCreateKeyResponse, i32>,
2083                fidl::encoding::DefaultFuchsiaResourceDialect,
2084                0x6ec69b3aee7fdbba,
2085            >(_buf?)?;
2086            Ok(_response.map(|x| (x.wrapping_key_id, x.wrapped_key, x.unwrapped_key)))
2087        }
2088        self.client.send_query_and_decode::<CryptCreateKeyRequest, CryptCreateKeyResult>(
2089            (owner, purpose),
2090            0x6ec69b3aee7fdbba,
2091            fidl::encoding::DynamicFlags::empty(),
2092            _decode,
2093        )
2094    }
2095
2096    type CreateKeyWithIdResponseFut = fidl::client::QueryResponseFut<
2097        CryptCreateKeyWithIdResult,
2098        fidl::encoding::DefaultFuchsiaResourceDialect,
2099    >;
2100    fn r#create_key_with_id(
2101        &self,
2102        mut owner: u64,
2103        mut wrapping_key_id: &[u8; 16],
2104        mut object_type: ObjectType,
2105    ) -> Self::CreateKeyWithIdResponseFut {
2106        fn _decode(
2107            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2108        ) -> Result<CryptCreateKeyWithIdResult, fidl::Error> {
2109            let _response = fidl::client::decode_transaction_body::<
2110                fidl::encoding::ResultType<CryptCreateKeyWithIdResponse, i32>,
2111                fidl::encoding::DefaultFuchsiaResourceDialect,
2112                0x21e8076688700b50,
2113            >(_buf?)?;
2114            Ok(_response.map(|x| (x.wrapped_key, x.unwrapped_key)))
2115        }
2116        self.client
2117            .send_query_and_decode::<CryptCreateKeyWithIdRequest, CryptCreateKeyWithIdResult>(
2118                (owner, wrapping_key_id, object_type),
2119                0x21e8076688700b50,
2120                fidl::encoding::DynamicFlags::empty(),
2121                _decode,
2122            )
2123    }
2124
2125    type UnwrapKeyResponseFut = fidl::client::QueryResponseFut<
2126        CryptUnwrapKeyResult,
2127        fidl::encoding::DefaultFuchsiaResourceDialect,
2128    >;
2129    fn r#unwrap_key(
2130        &self,
2131        mut owner: u64,
2132        mut wrapped_key: &WrappedKey,
2133    ) -> Self::UnwrapKeyResponseFut {
2134        fn _decode(
2135            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2136        ) -> Result<CryptUnwrapKeyResult, fidl::Error> {
2137            let _response = fidl::client::decode_transaction_body::<
2138                fidl::encoding::ResultType<CryptUnwrapKeyResponse, i32>,
2139                fidl::encoding::DefaultFuchsiaResourceDialect,
2140                0x6ec34e2b64d46be9,
2141            >(_buf?)?;
2142            Ok(_response.map(|x| x.unwrapped_key))
2143        }
2144        self.client.send_query_and_decode::<CryptUnwrapKeyRequest, CryptUnwrapKeyResult>(
2145            (owner, wrapped_key),
2146            0x6ec34e2b64d46be9,
2147            fidl::encoding::DynamicFlags::empty(),
2148            _decode,
2149        )
2150    }
2151}
2152
2153pub struct CryptEventStream {
2154    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2155}
2156
2157impl std::marker::Unpin for CryptEventStream {}
2158
2159impl futures::stream::FusedStream for CryptEventStream {
2160    fn is_terminated(&self) -> bool {
2161        self.event_receiver.is_terminated()
2162    }
2163}
2164
2165impl futures::Stream for CryptEventStream {
2166    type Item = Result<CryptEvent, fidl::Error>;
2167
2168    fn poll_next(
2169        mut self: std::pin::Pin<&mut Self>,
2170        cx: &mut std::task::Context<'_>,
2171    ) -> std::task::Poll<Option<Self::Item>> {
2172        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2173            &mut self.event_receiver,
2174            cx
2175        )?) {
2176            Some(buf) => std::task::Poll::Ready(Some(CryptEvent::decode(buf))),
2177            None => std::task::Poll::Ready(None),
2178        }
2179    }
2180}
2181
2182#[derive(Debug)]
2183pub enum CryptEvent {}
2184
2185impl CryptEvent {
2186    /// Decodes a message buffer as a [`CryptEvent`].
2187    fn decode(
2188        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2189    ) -> Result<CryptEvent, fidl::Error> {
2190        let (bytes, _handles) = buf.split_mut();
2191        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2192        debug_assert_eq!(tx_header.tx_id, 0);
2193        match tx_header.ordinal {
2194            _ => Err(fidl::Error::UnknownOrdinal {
2195                ordinal: tx_header.ordinal,
2196                protocol_name: <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2197            }),
2198        }
2199    }
2200}
2201
2202/// A Stream of incoming requests for fuchsia.fxfs/Crypt.
2203pub struct CryptRequestStream {
2204    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2205    is_terminated: bool,
2206}
2207
2208impl std::marker::Unpin for CryptRequestStream {}
2209
2210impl futures::stream::FusedStream for CryptRequestStream {
2211    fn is_terminated(&self) -> bool {
2212        self.is_terminated
2213    }
2214}
2215
2216impl fidl::endpoints::RequestStream for CryptRequestStream {
2217    type Protocol = CryptMarker;
2218    type ControlHandle = CryptControlHandle;
2219
2220    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2221        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2222    }
2223
2224    fn control_handle(&self) -> Self::ControlHandle {
2225        CryptControlHandle { inner: self.inner.clone() }
2226    }
2227
2228    fn into_inner(
2229        self,
2230    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2231    {
2232        (self.inner, self.is_terminated)
2233    }
2234
2235    fn from_inner(
2236        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2237        is_terminated: bool,
2238    ) -> Self {
2239        Self { inner, is_terminated }
2240    }
2241}
2242
2243impl futures::Stream for CryptRequestStream {
2244    type Item = Result<CryptRequest, fidl::Error>;
2245
2246    fn poll_next(
2247        mut self: std::pin::Pin<&mut Self>,
2248        cx: &mut std::task::Context<'_>,
2249    ) -> std::task::Poll<Option<Self::Item>> {
2250        let this = &mut *self;
2251        if this.inner.check_shutdown(cx) {
2252            this.is_terminated = true;
2253            return std::task::Poll::Ready(None);
2254        }
2255        if this.is_terminated {
2256            panic!("polled CryptRequestStream after completion");
2257        }
2258        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2259            |bytes, handles| {
2260                match this.inner.channel().read_etc(cx, bytes, handles) {
2261                    std::task::Poll::Ready(Ok(())) => {}
2262                    std::task::Poll::Pending => return std::task::Poll::Pending,
2263                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2264                        this.is_terminated = true;
2265                        return std::task::Poll::Ready(None);
2266                    }
2267                    std::task::Poll::Ready(Err(e)) => {
2268                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2269                            e.into(),
2270                        ))));
2271                    }
2272                }
2273
2274                // A message has been received from the channel
2275                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2276
2277                std::task::Poll::Ready(Some(match header.ordinal {
2278                    0x6ec69b3aee7fdbba => {
2279                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2280                        let mut req = fidl::new_empty!(
2281                            CryptCreateKeyRequest,
2282                            fidl::encoding::DefaultFuchsiaResourceDialect
2283                        );
2284                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptCreateKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2285                        let control_handle = CryptControlHandle { inner: this.inner.clone() };
2286                        Ok(CryptRequest::CreateKey {
2287                            owner: req.owner,
2288                            purpose: req.purpose,
2289
2290                            responder: CryptCreateKeyResponder {
2291                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2292                                tx_id: header.tx_id,
2293                            },
2294                        })
2295                    }
2296                    0x21e8076688700b50 => {
2297                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2298                        let mut req = fidl::new_empty!(
2299                            CryptCreateKeyWithIdRequest,
2300                            fidl::encoding::DefaultFuchsiaResourceDialect
2301                        );
2302                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptCreateKeyWithIdRequest>(&header, _body_bytes, handles, &mut req)?;
2303                        let control_handle = CryptControlHandle { inner: this.inner.clone() };
2304                        Ok(CryptRequest::CreateKeyWithId {
2305                            owner: req.owner,
2306                            wrapping_key_id: req.wrapping_key_id,
2307                            object_type: req.object_type,
2308
2309                            responder: CryptCreateKeyWithIdResponder {
2310                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2311                                tx_id: header.tx_id,
2312                            },
2313                        })
2314                    }
2315                    0x6ec34e2b64d46be9 => {
2316                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2317                        let mut req = fidl::new_empty!(
2318                            CryptUnwrapKeyRequest,
2319                            fidl::encoding::DefaultFuchsiaResourceDialect
2320                        );
2321                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptUnwrapKeyRequest>(&header, _body_bytes, handles, &mut req)?;
2322                        let control_handle = CryptControlHandle { inner: this.inner.clone() };
2323                        Ok(CryptRequest::UnwrapKey {
2324                            owner: req.owner,
2325                            wrapped_key: req.wrapped_key,
2326
2327                            responder: CryptUnwrapKeyResponder {
2328                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2329                                tx_id: header.tx_id,
2330                            },
2331                        })
2332                    }
2333                    _ => Err(fidl::Error::UnknownOrdinal {
2334                        ordinal: header.ordinal,
2335                        protocol_name: <CryptMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2336                    }),
2337                }))
2338            },
2339        )
2340    }
2341}
2342
2343#[derive(Debug)]
2344pub enum CryptRequest {
2345    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
2346    /// the owner of the key and must be supplied to `UnwrapKey`.  The crypt service chooses a
2347    /// `wrapping_key_id` which must be supplied to UnwrapKey.  The `wrapping_key_id` has no
2348    /// meaning to Fxfs.
2349    /// TODO(https://fxbug.dev/445189846): Add an `object_type` field to support inline encryption.
2350    CreateKey { owner: u64, purpose: KeyPurpose, responder: CryptCreateKeyResponder },
2351    /// Creates a new key wrapped with the key identified by `wrapping_key_id`.  `owner` identifies
2352    /// the owner of the key and must be supplied to `UnwrapKey` along with  `wrapping_key_id`.
2353    /// The `wrapping_key_id` has no meaning to Fxfs.
2354    CreateKeyWithId {
2355        owner: u64,
2356        wrapping_key_id: [u8; 16],
2357        object_type: ObjectType,
2358        responder: CryptCreateKeyWithIdResponder,
2359    },
2360    /// Unwraps a key.  `owner` must be the same as that passed to `CreateKey`.
2361    /// This can fail due to permission reasons, but an incorrect key or owner will not fail;
2362    /// it will just return an unwrapped key that won't actually decrpyt the data.
2363    /// ZX_ERR_UNAVAILABLE is returned if the key is known but cannot be unwrapped (e.g. it is
2364    /// locked).
2365    /// ZX_ERR_NOT_FOUND is returned if the key is not known. In some cases, implementations are
2366    /// unable to tell the difference between the two, in which case, ZX_ERR_UNAVAILABLE is
2367    /// returned.
2368    UnwrapKey { owner: u64, wrapped_key: WrappedKey, responder: CryptUnwrapKeyResponder },
2369}
2370
2371impl CryptRequest {
2372    #[allow(irrefutable_let_patterns)]
2373    pub fn into_create_key(self) -> Option<(u64, KeyPurpose, CryptCreateKeyResponder)> {
2374        if let CryptRequest::CreateKey { owner, purpose, responder } = self {
2375            Some((owner, purpose, responder))
2376        } else {
2377            None
2378        }
2379    }
2380
2381    #[allow(irrefutable_let_patterns)]
2382    pub fn into_create_key_with_id(
2383        self,
2384    ) -> Option<(u64, [u8; 16], ObjectType, CryptCreateKeyWithIdResponder)> {
2385        if let CryptRequest::CreateKeyWithId { owner, wrapping_key_id, object_type, responder } =
2386            self
2387        {
2388            Some((owner, wrapping_key_id, object_type, responder))
2389        } else {
2390            None
2391        }
2392    }
2393
2394    #[allow(irrefutable_let_patterns)]
2395    pub fn into_unwrap_key(self) -> Option<(u64, WrappedKey, CryptUnwrapKeyResponder)> {
2396        if let CryptRequest::UnwrapKey { owner, wrapped_key, responder } = self {
2397            Some((owner, wrapped_key, responder))
2398        } else {
2399            None
2400        }
2401    }
2402
2403    /// Name of the method defined in FIDL
2404    pub fn method_name(&self) -> &'static str {
2405        match *self {
2406            CryptRequest::CreateKey { .. } => "create_key",
2407            CryptRequest::CreateKeyWithId { .. } => "create_key_with_id",
2408            CryptRequest::UnwrapKey { .. } => "unwrap_key",
2409        }
2410    }
2411}
2412
2413#[derive(Debug, Clone)]
2414pub struct CryptControlHandle {
2415    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2416}
2417
2418impl CryptControlHandle {
2419    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2420        self.inner.shutdown_with_epitaph(status.into())
2421    }
2422}
2423
2424impl fidl::endpoints::ControlHandle for CryptControlHandle {
2425    fn shutdown(&self) {
2426        self.inner.shutdown()
2427    }
2428
2429    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2430        self.inner.shutdown_with_epitaph(status)
2431    }
2432
2433    fn is_closed(&self) -> bool {
2434        self.inner.channel().is_closed()
2435    }
2436    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2437        self.inner.channel().on_closed()
2438    }
2439
2440    #[cfg(target_os = "fuchsia")]
2441    fn signal_peer(
2442        &self,
2443        clear_mask: zx::Signals,
2444        set_mask: zx::Signals,
2445    ) -> Result<(), zx_status::Status> {
2446        use fidl::Peered;
2447        self.inner.channel().signal_peer(clear_mask, set_mask)
2448    }
2449}
2450
2451impl CryptControlHandle {}
2452
2453#[must_use = "FIDL methods require a response to be sent"]
2454#[derive(Debug)]
2455pub struct CryptCreateKeyResponder {
2456    control_handle: std::mem::ManuallyDrop<CryptControlHandle>,
2457    tx_id: u32,
2458}
2459
2460/// Set the the channel to be shutdown (see [`CryptControlHandle::shutdown`])
2461/// if the responder is dropped without sending a response, so that the client
2462/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2463impl std::ops::Drop for CryptCreateKeyResponder {
2464    fn drop(&mut self) {
2465        self.control_handle.shutdown();
2466        // Safety: drops once, never accessed again
2467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2468    }
2469}
2470
2471impl fidl::endpoints::Responder for CryptCreateKeyResponder {
2472    type ControlHandle = CryptControlHandle;
2473
2474    fn control_handle(&self) -> &CryptControlHandle {
2475        &self.control_handle
2476    }
2477
2478    fn drop_without_shutdown(mut self) {
2479        // Safety: drops once, never accessed again due to mem::forget
2480        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2481        // Prevent Drop from running (which would shut down the channel)
2482        std::mem::forget(self);
2483    }
2484}
2485
2486impl CryptCreateKeyResponder {
2487    /// Sends a response to the FIDL transaction.
2488    ///
2489    /// Sets the channel to shutdown if an error occurs.
2490    pub fn send(
2491        self,
2492        mut result: Result<(&[u8; 16], &[u8], &[u8]), i32>,
2493    ) -> Result<(), fidl::Error> {
2494        let _result = self.send_raw(result);
2495        if _result.is_err() {
2496            self.control_handle.shutdown();
2497        }
2498        self.drop_without_shutdown();
2499        _result
2500    }
2501
2502    /// Similar to "send" but does not shutdown the channel if an error occurs.
2503    pub fn send_no_shutdown_on_err(
2504        self,
2505        mut result: Result<(&[u8; 16], &[u8], &[u8]), i32>,
2506    ) -> Result<(), fidl::Error> {
2507        let _result = self.send_raw(result);
2508        self.drop_without_shutdown();
2509        _result
2510    }
2511
2512    fn send_raw(
2513        &self,
2514        mut result: Result<(&[u8; 16], &[u8], &[u8]), i32>,
2515    ) -> Result<(), fidl::Error> {
2516        self.control_handle.inner.send::<fidl::encoding::ResultType<CryptCreateKeyResponse, i32>>(
2517            result,
2518            self.tx_id,
2519            0x6ec69b3aee7fdbba,
2520            fidl::encoding::DynamicFlags::empty(),
2521        )
2522    }
2523}
2524
2525#[must_use = "FIDL methods require a response to be sent"]
2526#[derive(Debug)]
2527pub struct CryptCreateKeyWithIdResponder {
2528    control_handle: std::mem::ManuallyDrop<CryptControlHandle>,
2529    tx_id: u32,
2530}
2531
2532/// Set the the channel to be shutdown (see [`CryptControlHandle::shutdown`])
2533/// if the responder is dropped without sending a response, so that the client
2534/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2535impl std::ops::Drop for CryptCreateKeyWithIdResponder {
2536    fn drop(&mut self) {
2537        self.control_handle.shutdown();
2538        // Safety: drops once, never accessed again
2539        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2540    }
2541}
2542
2543impl fidl::endpoints::Responder for CryptCreateKeyWithIdResponder {
2544    type ControlHandle = CryptControlHandle;
2545
2546    fn control_handle(&self) -> &CryptControlHandle {
2547        &self.control_handle
2548    }
2549
2550    fn drop_without_shutdown(mut self) {
2551        // Safety: drops once, never accessed again due to mem::forget
2552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2553        // Prevent Drop from running (which would shut down the channel)
2554        std::mem::forget(self);
2555    }
2556}
2557
2558impl CryptCreateKeyWithIdResponder {
2559    /// Sends a response to the FIDL transaction.
2560    ///
2561    /// Sets the channel to shutdown if an error occurs.
2562    pub fn send(self, mut result: Result<(&WrappedKey, &[u8]), i32>) -> Result<(), fidl::Error> {
2563        let _result = self.send_raw(result);
2564        if _result.is_err() {
2565            self.control_handle.shutdown();
2566        }
2567        self.drop_without_shutdown();
2568        _result
2569    }
2570
2571    /// Similar to "send" but does not shutdown the channel if an error occurs.
2572    pub fn send_no_shutdown_on_err(
2573        self,
2574        mut result: Result<(&WrappedKey, &[u8]), i32>,
2575    ) -> Result<(), fidl::Error> {
2576        let _result = self.send_raw(result);
2577        self.drop_without_shutdown();
2578        _result
2579    }
2580
2581    fn send_raw(&self, mut result: Result<(&WrappedKey, &[u8]), i32>) -> Result<(), fidl::Error> {
2582        self.control_handle
2583            .inner
2584            .send::<fidl::encoding::ResultType<CryptCreateKeyWithIdResponse, i32>>(
2585                result,
2586                self.tx_id,
2587                0x21e8076688700b50,
2588                fidl::encoding::DynamicFlags::empty(),
2589            )
2590    }
2591}
2592
2593#[must_use = "FIDL methods require a response to be sent"]
2594#[derive(Debug)]
2595pub struct CryptUnwrapKeyResponder {
2596    control_handle: std::mem::ManuallyDrop<CryptControlHandle>,
2597    tx_id: u32,
2598}
2599
2600/// Set the the channel to be shutdown (see [`CryptControlHandle::shutdown`])
2601/// if the responder is dropped without sending a response, so that the client
2602/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2603impl std::ops::Drop for CryptUnwrapKeyResponder {
2604    fn drop(&mut self) {
2605        self.control_handle.shutdown();
2606        // Safety: drops once, never accessed again
2607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2608    }
2609}
2610
2611impl fidl::endpoints::Responder for CryptUnwrapKeyResponder {
2612    type ControlHandle = CryptControlHandle;
2613
2614    fn control_handle(&self) -> &CryptControlHandle {
2615        &self.control_handle
2616    }
2617
2618    fn drop_without_shutdown(mut self) {
2619        // Safety: drops once, never accessed again due to mem::forget
2620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2621        // Prevent Drop from running (which would shut down the channel)
2622        std::mem::forget(self);
2623    }
2624}
2625
2626impl CryptUnwrapKeyResponder {
2627    /// Sends a response to the FIDL transaction.
2628    ///
2629    /// Sets the channel to shutdown if an error occurs.
2630    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2631        let _result = self.send_raw(result);
2632        if _result.is_err() {
2633            self.control_handle.shutdown();
2634        }
2635        self.drop_without_shutdown();
2636        _result
2637    }
2638
2639    /// Similar to "send" but does not shutdown the channel if an error occurs.
2640    pub fn send_no_shutdown_on_err(
2641        self,
2642        mut result: Result<&[u8], i32>,
2643    ) -> Result<(), fidl::Error> {
2644        let _result = self.send_raw(result);
2645        self.drop_without_shutdown();
2646        _result
2647    }
2648
2649    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2650        self.control_handle.inner.send::<fidl::encoding::ResultType<CryptUnwrapKeyResponse, i32>>(
2651            result.map(|unwrapped_key| (unwrapped_key,)),
2652            self.tx_id,
2653            0x6ec34e2b64d46be9,
2654            fidl::encoding::DynamicFlags::empty(),
2655        )
2656    }
2657}
2658
2659#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2660pub struct CryptManagementMarker;
2661
2662impl fidl::endpoints::ProtocolMarker for CryptManagementMarker {
2663    type Proxy = CryptManagementProxy;
2664    type RequestStream = CryptManagementRequestStream;
2665    #[cfg(target_os = "fuchsia")]
2666    type SynchronousProxy = CryptManagementSynchronousProxy;
2667
2668    const DEBUG_NAME: &'static str = "fuchsia.fxfs.CryptManagement";
2669}
2670impl fidl::endpoints::DiscoverableProtocolMarker for CryptManagementMarker {}
2671pub type CryptManagementAddWrappingKeyResult = Result<(), i32>;
2672pub type CryptManagementSetActiveKeyResult = Result<(), i32>;
2673pub type CryptManagementForgetWrappingKeyResult = Result<(), i32>;
2674
2675pub trait CryptManagementProxyInterface: Send + Sync {
2676    type AddWrappingKeyResponseFut: std::future::Future<Output = Result<CryptManagementAddWrappingKeyResult, fidl::Error>>
2677        + Send;
2678    fn r#add_wrapping_key(
2679        &self,
2680        wrapping_key_id: &[u8; 16],
2681        key: &[u8],
2682    ) -> Self::AddWrappingKeyResponseFut;
2683    type SetActiveKeyResponseFut: std::future::Future<Output = Result<CryptManagementSetActiveKeyResult, fidl::Error>>
2684        + Send;
2685    fn r#set_active_key(
2686        &self,
2687        purpose: KeyPurpose,
2688        wrapping_key_id: &[u8; 16],
2689    ) -> Self::SetActiveKeyResponseFut;
2690    type ForgetWrappingKeyResponseFut: std::future::Future<Output = Result<CryptManagementForgetWrappingKeyResult, fidl::Error>>
2691        + Send;
2692    fn r#forget_wrapping_key(
2693        &self,
2694        wrapping_key_id: &[u8; 16],
2695    ) -> Self::ForgetWrappingKeyResponseFut;
2696}
2697#[derive(Debug)]
2698#[cfg(target_os = "fuchsia")]
2699pub struct CryptManagementSynchronousProxy {
2700    client: fidl::client::sync::Client,
2701}
2702
2703#[cfg(target_os = "fuchsia")]
2704impl fidl::endpoints::SynchronousProxy for CryptManagementSynchronousProxy {
2705    type Proxy = CryptManagementProxy;
2706    type Protocol = CryptManagementMarker;
2707
2708    fn from_channel(inner: fidl::Channel) -> Self {
2709        Self::new(inner)
2710    }
2711
2712    fn into_channel(self) -> fidl::Channel {
2713        self.client.into_channel()
2714    }
2715
2716    fn as_channel(&self) -> &fidl::Channel {
2717        self.client.as_channel()
2718    }
2719}
2720
2721#[cfg(target_os = "fuchsia")]
2722impl CryptManagementSynchronousProxy {
2723    pub fn new(channel: fidl::Channel) -> Self {
2724        Self { client: fidl::client::sync::Client::new(channel) }
2725    }
2726
2727    pub fn into_channel(self) -> fidl::Channel {
2728        self.client.into_channel()
2729    }
2730
2731    /// Waits until an event arrives and returns it. It is safe for other
2732    /// threads to make concurrent requests while waiting for an event.
2733    pub fn wait_for_event(
2734        &self,
2735        deadline: zx::MonotonicInstant,
2736    ) -> Result<CryptManagementEvent, fidl::Error> {
2737        CryptManagementEvent::decode(self.client.wait_for_event::<CryptManagementMarker>(deadline)?)
2738    }
2739
2740    /// Adds a new wrapping key to the Crypt service.  The new key will immediately be available
2741    /// for unwrapping keys (Crypt::UnwrapKeys) but won't be used for wrapping keys until
2742    /// CryptManagement::SetActiveKeys is called.
2743    pub fn r#add_wrapping_key(
2744        &self,
2745        mut wrapping_key_id: &[u8; 16],
2746        mut key: &[u8],
2747        ___deadline: zx::MonotonicInstant,
2748    ) -> Result<CryptManagementAddWrappingKeyResult, fidl::Error> {
2749        let _response = self.client.send_query::<
2750            CryptManagementAddWrappingKeyRequest,
2751            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2752            CryptManagementMarker,
2753        >(
2754            (wrapping_key_id, key,),
2755            0x59a5076762318bf,
2756            fidl::encoding::DynamicFlags::empty(),
2757            ___deadline,
2758        )?;
2759        Ok(_response.map(|x| x))
2760    }
2761
2762    /// Updates the key which will be used for wrapping keys (Crypt::CreateKey).  `purpose`
2763    /// describes which active key to modify.
2764    pub fn r#set_active_key(
2765        &self,
2766        mut purpose: KeyPurpose,
2767        mut wrapping_key_id: &[u8; 16],
2768        ___deadline: zx::MonotonicInstant,
2769    ) -> Result<CryptManagementSetActiveKeyResult, fidl::Error> {
2770        let _response = self.client.send_query::<
2771            CryptManagementSetActiveKeyRequest,
2772            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2773            CryptManagementMarker,
2774        >(
2775            (purpose, wrapping_key_id,),
2776            0x5e81d600442f2872,
2777            fidl::encoding::DynamicFlags::empty(),
2778            ___deadline,
2779        )?;
2780        Ok(_response.map(|x| x))
2781    }
2782
2783    /// Forgets a wrapping key, preventing its use for future key-unwrapping.  All future calls to
2784    /// Crypt::UnwrapKeys with that wrapping key ID will fail.
2785    /// If either the data or metadata part of the key is active, an error is returned.
2786    pub fn r#forget_wrapping_key(
2787        &self,
2788        mut wrapping_key_id: &[u8; 16],
2789        ___deadline: zx::MonotonicInstant,
2790    ) -> Result<CryptManagementForgetWrappingKeyResult, fidl::Error> {
2791        let _response = self.client.send_query::<
2792            CryptManagementForgetWrappingKeyRequest,
2793            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2794            CryptManagementMarker,
2795        >(
2796            (wrapping_key_id,),
2797            0x436d6d27696dfcf4,
2798            fidl::encoding::DynamicFlags::empty(),
2799            ___deadline,
2800        )?;
2801        Ok(_response.map(|x| x))
2802    }
2803}
2804
2805#[cfg(target_os = "fuchsia")]
2806impl From<CryptManagementSynchronousProxy> for zx::NullableHandle {
2807    fn from(value: CryptManagementSynchronousProxy) -> Self {
2808        value.into_channel().into()
2809    }
2810}
2811
2812#[cfg(target_os = "fuchsia")]
2813impl From<fidl::Channel> for CryptManagementSynchronousProxy {
2814    fn from(value: fidl::Channel) -> Self {
2815        Self::new(value)
2816    }
2817}
2818
2819#[cfg(target_os = "fuchsia")]
2820impl fidl::endpoints::FromClient for CryptManagementSynchronousProxy {
2821    type Protocol = CryptManagementMarker;
2822
2823    fn from_client(value: fidl::endpoints::ClientEnd<CryptManagementMarker>) -> Self {
2824        Self::new(value.into_channel())
2825    }
2826}
2827
2828#[derive(Debug, Clone)]
2829pub struct CryptManagementProxy {
2830    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2831}
2832
2833impl fidl::endpoints::Proxy for CryptManagementProxy {
2834    type Protocol = CryptManagementMarker;
2835
2836    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2837        Self::new(inner)
2838    }
2839
2840    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2841        self.client.into_channel().map_err(|client| Self { client })
2842    }
2843
2844    fn as_channel(&self) -> &::fidl::AsyncChannel {
2845        self.client.as_channel()
2846    }
2847}
2848
2849impl CryptManagementProxy {
2850    /// Create a new Proxy for fuchsia.fxfs/CryptManagement.
2851    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2852        let protocol_name = <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2853        Self { client: fidl::client::Client::new(channel, protocol_name) }
2854    }
2855
2856    /// Get a Stream of events from the remote end of the protocol.
2857    ///
2858    /// # Panics
2859    ///
2860    /// Panics if the event stream was already taken.
2861    pub fn take_event_stream(&self) -> CryptManagementEventStream {
2862        CryptManagementEventStream { event_receiver: self.client.take_event_receiver() }
2863    }
2864
2865    /// Adds a new wrapping key to the Crypt service.  The new key will immediately be available
2866    /// for unwrapping keys (Crypt::UnwrapKeys) but won't be used for wrapping keys until
2867    /// CryptManagement::SetActiveKeys is called.
2868    pub fn r#add_wrapping_key(
2869        &self,
2870        mut wrapping_key_id: &[u8; 16],
2871        mut key: &[u8],
2872    ) -> fidl::client::QueryResponseFut<
2873        CryptManagementAddWrappingKeyResult,
2874        fidl::encoding::DefaultFuchsiaResourceDialect,
2875    > {
2876        CryptManagementProxyInterface::r#add_wrapping_key(self, wrapping_key_id, key)
2877    }
2878
2879    /// Updates the key which will be used for wrapping keys (Crypt::CreateKey).  `purpose`
2880    /// describes which active key to modify.
2881    pub fn r#set_active_key(
2882        &self,
2883        mut purpose: KeyPurpose,
2884        mut wrapping_key_id: &[u8; 16],
2885    ) -> fidl::client::QueryResponseFut<
2886        CryptManagementSetActiveKeyResult,
2887        fidl::encoding::DefaultFuchsiaResourceDialect,
2888    > {
2889        CryptManagementProxyInterface::r#set_active_key(self, purpose, wrapping_key_id)
2890    }
2891
2892    /// Forgets a wrapping key, preventing its use for future key-unwrapping.  All future calls to
2893    /// Crypt::UnwrapKeys with that wrapping key ID will fail.
2894    /// If either the data or metadata part of the key is active, an error is returned.
2895    pub fn r#forget_wrapping_key(
2896        &self,
2897        mut wrapping_key_id: &[u8; 16],
2898    ) -> fidl::client::QueryResponseFut<
2899        CryptManagementForgetWrappingKeyResult,
2900        fidl::encoding::DefaultFuchsiaResourceDialect,
2901    > {
2902        CryptManagementProxyInterface::r#forget_wrapping_key(self, wrapping_key_id)
2903    }
2904}
2905
2906impl CryptManagementProxyInterface for CryptManagementProxy {
2907    type AddWrappingKeyResponseFut = fidl::client::QueryResponseFut<
2908        CryptManagementAddWrappingKeyResult,
2909        fidl::encoding::DefaultFuchsiaResourceDialect,
2910    >;
2911    fn r#add_wrapping_key(
2912        &self,
2913        mut wrapping_key_id: &[u8; 16],
2914        mut key: &[u8],
2915    ) -> Self::AddWrappingKeyResponseFut {
2916        fn _decode(
2917            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2918        ) -> Result<CryptManagementAddWrappingKeyResult, fidl::Error> {
2919            let _response = fidl::client::decode_transaction_body::<
2920                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2921                fidl::encoding::DefaultFuchsiaResourceDialect,
2922                0x59a5076762318bf,
2923            >(_buf?)?;
2924            Ok(_response.map(|x| x))
2925        }
2926        self.client.send_query_and_decode::<
2927            CryptManagementAddWrappingKeyRequest,
2928            CryptManagementAddWrappingKeyResult,
2929        >(
2930            (wrapping_key_id, key,),
2931            0x59a5076762318bf,
2932            fidl::encoding::DynamicFlags::empty(),
2933            _decode,
2934        )
2935    }
2936
2937    type SetActiveKeyResponseFut = fidl::client::QueryResponseFut<
2938        CryptManagementSetActiveKeyResult,
2939        fidl::encoding::DefaultFuchsiaResourceDialect,
2940    >;
2941    fn r#set_active_key(
2942        &self,
2943        mut purpose: KeyPurpose,
2944        mut wrapping_key_id: &[u8; 16],
2945    ) -> Self::SetActiveKeyResponseFut {
2946        fn _decode(
2947            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2948        ) -> Result<CryptManagementSetActiveKeyResult, fidl::Error> {
2949            let _response = fidl::client::decode_transaction_body::<
2950                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2951                fidl::encoding::DefaultFuchsiaResourceDialect,
2952                0x5e81d600442f2872,
2953            >(_buf?)?;
2954            Ok(_response.map(|x| x))
2955        }
2956        self.client.send_query_and_decode::<
2957            CryptManagementSetActiveKeyRequest,
2958            CryptManagementSetActiveKeyResult,
2959        >(
2960            (purpose, wrapping_key_id,),
2961            0x5e81d600442f2872,
2962            fidl::encoding::DynamicFlags::empty(),
2963            _decode,
2964        )
2965    }
2966
2967    type ForgetWrappingKeyResponseFut = fidl::client::QueryResponseFut<
2968        CryptManagementForgetWrappingKeyResult,
2969        fidl::encoding::DefaultFuchsiaResourceDialect,
2970    >;
2971    fn r#forget_wrapping_key(
2972        &self,
2973        mut wrapping_key_id: &[u8; 16],
2974    ) -> Self::ForgetWrappingKeyResponseFut {
2975        fn _decode(
2976            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2977        ) -> Result<CryptManagementForgetWrappingKeyResult, fidl::Error> {
2978            let _response = fidl::client::decode_transaction_body::<
2979                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
2980                fidl::encoding::DefaultFuchsiaResourceDialect,
2981                0x436d6d27696dfcf4,
2982            >(_buf?)?;
2983            Ok(_response.map(|x| x))
2984        }
2985        self.client.send_query_and_decode::<
2986            CryptManagementForgetWrappingKeyRequest,
2987            CryptManagementForgetWrappingKeyResult,
2988        >(
2989            (wrapping_key_id,),
2990            0x436d6d27696dfcf4,
2991            fidl::encoding::DynamicFlags::empty(),
2992            _decode,
2993        )
2994    }
2995}
2996
2997pub struct CryptManagementEventStream {
2998    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2999}
3000
3001impl std::marker::Unpin for CryptManagementEventStream {}
3002
3003impl futures::stream::FusedStream for CryptManagementEventStream {
3004    fn is_terminated(&self) -> bool {
3005        self.event_receiver.is_terminated()
3006    }
3007}
3008
3009impl futures::Stream for CryptManagementEventStream {
3010    type Item = Result<CryptManagementEvent, fidl::Error>;
3011
3012    fn poll_next(
3013        mut self: std::pin::Pin<&mut Self>,
3014        cx: &mut std::task::Context<'_>,
3015    ) -> std::task::Poll<Option<Self::Item>> {
3016        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3017            &mut self.event_receiver,
3018            cx
3019        )?) {
3020            Some(buf) => std::task::Poll::Ready(Some(CryptManagementEvent::decode(buf))),
3021            None => std::task::Poll::Ready(None),
3022        }
3023    }
3024}
3025
3026#[derive(Debug)]
3027pub enum CryptManagementEvent {}
3028
3029impl CryptManagementEvent {
3030    /// Decodes a message buffer as a [`CryptManagementEvent`].
3031    fn decode(
3032        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3033    ) -> Result<CryptManagementEvent, fidl::Error> {
3034        let (bytes, _handles) = buf.split_mut();
3035        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3036        debug_assert_eq!(tx_header.tx_id, 0);
3037        match tx_header.ordinal {
3038            _ => Err(fidl::Error::UnknownOrdinal {
3039                ordinal: tx_header.ordinal,
3040                protocol_name:
3041                    <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3042            }),
3043        }
3044    }
3045}
3046
3047/// A Stream of incoming requests for fuchsia.fxfs/CryptManagement.
3048pub struct CryptManagementRequestStream {
3049    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3050    is_terminated: bool,
3051}
3052
3053impl std::marker::Unpin for CryptManagementRequestStream {}
3054
3055impl futures::stream::FusedStream for CryptManagementRequestStream {
3056    fn is_terminated(&self) -> bool {
3057        self.is_terminated
3058    }
3059}
3060
3061impl fidl::endpoints::RequestStream for CryptManagementRequestStream {
3062    type Protocol = CryptManagementMarker;
3063    type ControlHandle = CryptManagementControlHandle;
3064
3065    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3066        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3067    }
3068
3069    fn control_handle(&self) -> Self::ControlHandle {
3070        CryptManagementControlHandle { inner: self.inner.clone() }
3071    }
3072
3073    fn into_inner(
3074        self,
3075    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3076    {
3077        (self.inner, self.is_terminated)
3078    }
3079
3080    fn from_inner(
3081        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3082        is_terminated: bool,
3083    ) -> Self {
3084        Self { inner, is_terminated }
3085    }
3086}
3087
3088impl futures::Stream for CryptManagementRequestStream {
3089    type Item = Result<CryptManagementRequest, fidl::Error>;
3090
3091    fn poll_next(
3092        mut self: std::pin::Pin<&mut Self>,
3093        cx: &mut std::task::Context<'_>,
3094    ) -> std::task::Poll<Option<Self::Item>> {
3095        let this = &mut *self;
3096        if this.inner.check_shutdown(cx) {
3097            this.is_terminated = true;
3098            return std::task::Poll::Ready(None);
3099        }
3100        if this.is_terminated {
3101            panic!("polled CryptManagementRequestStream after completion");
3102        }
3103        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3104            |bytes, handles| {
3105                match this.inner.channel().read_etc(cx, bytes, handles) {
3106                    std::task::Poll::Ready(Ok(())) => {}
3107                    std::task::Poll::Pending => return std::task::Poll::Pending,
3108                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3109                        this.is_terminated = true;
3110                        return std::task::Poll::Ready(None);
3111                    }
3112                    std::task::Poll::Ready(Err(e)) => {
3113                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3114                            e.into(),
3115                        ))));
3116                    }
3117                }
3118
3119                // A message has been received from the channel
3120                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3121
3122                std::task::Poll::Ready(Some(match header.ordinal {
3123                    0x59a5076762318bf => {
3124                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3125                        let mut req = fidl::new_empty!(
3126                            CryptManagementAddWrappingKeyRequest,
3127                            fidl::encoding::DefaultFuchsiaResourceDialect
3128                        );
3129                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptManagementAddWrappingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
3130                        let control_handle =
3131                            CryptManagementControlHandle { inner: this.inner.clone() };
3132                        Ok(CryptManagementRequest::AddWrappingKey {
3133                            wrapping_key_id: req.wrapping_key_id,
3134                            key: req.key,
3135
3136                            responder: CryptManagementAddWrappingKeyResponder {
3137                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3138                                tx_id: header.tx_id,
3139                            },
3140                        })
3141                    }
3142                    0x5e81d600442f2872 => {
3143                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3144                        let mut req = fidl::new_empty!(
3145                            CryptManagementSetActiveKeyRequest,
3146                            fidl::encoding::DefaultFuchsiaResourceDialect
3147                        );
3148                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptManagementSetActiveKeyRequest>(&header, _body_bytes, handles, &mut req)?;
3149                        let control_handle =
3150                            CryptManagementControlHandle { inner: this.inner.clone() };
3151                        Ok(CryptManagementRequest::SetActiveKey {
3152                            purpose: req.purpose,
3153                            wrapping_key_id: req.wrapping_key_id,
3154
3155                            responder: CryptManagementSetActiveKeyResponder {
3156                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3157                                tx_id: header.tx_id,
3158                            },
3159                        })
3160                    }
3161                    0x436d6d27696dfcf4 => {
3162                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3163                        let mut req = fidl::new_empty!(
3164                            CryptManagementForgetWrappingKeyRequest,
3165                            fidl::encoding::DefaultFuchsiaResourceDialect
3166                        );
3167                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CryptManagementForgetWrappingKeyRequest>(&header, _body_bytes, handles, &mut req)?;
3168                        let control_handle =
3169                            CryptManagementControlHandle { inner: this.inner.clone() };
3170                        Ok(CryptManagementRequest::ForgetWrappingKey {
3171                            wrapping_key_id: req.wrapping_key_id,
3172
3173                            responder: CryptManagementForgetWrappingKeyResponder {
3174                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3175                                tx_id: header.tx_id,
3176                            },
3177                        })
3178                    }
3179                    _ => Err(fidl::Error::UnknownOrdinal {
3180                        ordinal: header.ordinal,
3181                        protocol_name:
3182                            <CryptManagementMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3183                    }),
3184                }))
3185            },
3186        )
3187    }
3188}
3189
3190#[derive(Debug)]
3191pub enum CryptManagementRequest {
3192    /// Adds a new wrapping key to the Crypt service.  The new key will immediately be available
3193    /// for unwrapping keys (Crypt::UnwrapKeys) but won't be used for wrapping keys until
3194    /// CryptManagement::SetActiveKeys is called.
3195    AddWrappingKey {
3196        wrapping_key_id: [u8; 16],
3197        key: Vec<u8>,
3198        responder: CryptManagementAddWrappingKeyResponder,
3199    },
3200    /// Updates the key which will be used for wrapping keys (Crypt::CreateKey).  `purpose`
3201    /// describes which active key to modify.
3202    SetActiveKey {
3203        purpose: KeyPurpose,
3204        wrapping_key_id: [u8; 16],
3205        responder: CryptManagementSetActiveKeyResponder,
3206    },
3207    /// Forgets a wrapping key, preventing its use for future key-unwrapping.  All future calls to
3208    /// Crypt::UnwrapKeys with that wrapping key ID will fail.
3209    /// If either the data or metadata part of the key is active, an error is returned.
3210    ForgetWrappingKey {
3211        wrapping_key_id: [u8; 16],
3212        responder: CryptManagementForgetWrappingKeyResponder,
3213    },
3214}
3215
3216impl CryptManagementRequest {
3217    #[allow(irrefutable_let_patterns)]
3218    pub fn into_add_wrapping_key(
3219        self,
3220    ) -> Option<([u8; 16], Vec<u8>, CryptManagementAddWrappingKeyResponder)> {
3221        if let CryptManagementRequest::AddWrappingKey { wrapping_key_id, key, responder } = self {
3222            Some((wrapping_key_id, key, responder))
3223        } else {
3224            None
3225        }
3226    }
3227
3228    #[allow(irrefutable_let_patterns)]
3229    pub fn into_set_active_key(
3230        self,
3231    ) -> Option<(KeyPurpose, [u8; 16], CryptManagementSetActiveKeyResponder)> {
3232        if let CryptManagementRequest::SetActiveKey { purpose, wrapping_key_id, responder } = self {
3233            Some((purpose, wrapping_key_id, responder))
3234        } else {
3235            None
3236        }
3237    }
3238
3239    #[allow(irrefutable_let_patterns)]
3240    pub fn into_forget_wrapping_key(
3241        self,
3242    ) -> Option<([u8; 16], CryptManagementForgetWrappingKeyResponder)> {
3243        if let CryptManagementRequest::ForgetWrappingKey { wrapping_key_id, responder } = self {
3244            Some((wrapping_key_id, responder))
3245        } else {
3246            None
3247        }
3248    }
3249
3250    /// Name of the method defined in FIDL
3251    pub fn method_name(&self) -> &'static str {
3252        match *self {
3253            CryptManagementRequest::AddWrappingKey { .. } => "add_wrapping_key",
3254            CryptManagementRequest::SetActiveKey { .. } => "set_active_key",
3255            CryptManagementRequest::ForgetWrappingKey { .. } => "forget_wrapping_key",
3256        }
3257    }
3258}
3259
3260#[derive(Debug, Clone)]
3261pub struct CryptManagementControlHandle {
3262    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3263}
3264
3265impl CryptManagementControlHandle {
3266    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3267        self.inner.shutdown_with_epitaph(status.into())
3268    }
3269}
3270
3271impl fidl::endpoints::ControlHandle for CryptManagementControlHandle {
3272    fn shutdown(&self) {
3273        self.inner.shutdown()
3274    }
3275
3276    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3277        self.inner.shutdown_with_epitaph(status)
3278    }
3279
3280    fn is_closed(&self) -> bool {
3281        self.inner.channel().is_closed()
3282    }
3283    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3284        self.inner.channel().on_closed()
3285    }
3286
3287    #[cfg(target_os = "fuchsia")]
3288    fn signal_peer(
3289        &self,
3290        clear_mask: zx::Signals,
3291        set_mask: zx::Signals,
3292    ) -> Result<(), zx_status::Status> {
3293        use fidl::Peered;
3294        self.inner.channel().signal_peer(clear_mask, set_mask)
3295    }
3296}
3297
3298impl CryptManagementControlHandle {}
3299
3300#[must_use = "FIDL methods require a response to be sent"]
3301#[derive(Debug)]
3302pub struct CryptManagementAddWrappingKeyResponder {
3303    control_handle: std::mem::ManuallyDrop<CryptManagementControlHandle>,
3304    tx_id: u32,
3305}
3306
3307/// Set the the channel to be shutdown (see [`CryptManagementControlHandle::shutdown`])
3308/// if the responder is dropped without sending a response, so that the client
3309/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3310impl std::ops::Drop for CryptManagementAddWrappingKeyResponder {
3311    fn drop(&mut self) {
3312        self.control_handle.shutdown();
3313        // Safety: drops once, never accessed again
3314        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3315    }
3316}
3317
3318impl fidl::endpoints::Responder for CryptManagementAddWrappingKeyResponder {
3319    type ControlHandle = CryptManagementControlHandle;
3320
3321    fn control_handle(&self) -> &CryptManagementControlHandle {
3322        &self.control_handle
3323    }
3324
3325    fn drop_without_shutdown(mut self) {
3326        // Safety: drops once, never accessed again due to mem::forget
3327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3328        // Prevent Drop from running (which would shut down the channel)
3329        std::mem::forget(self);
3330    }
3331}
3332
3333impl CryptManagementAddWrappingKeyResponder {
3334    /// Sends a response to the FIDL transaction.
3335    ///
3336    /// Sets the channel to shutdown if an error occurs.
3337    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3338        let _result = self.send_raw(result);
3339        if _result.is_err() {
3340            self.control_handle.shutdown();
3341        }
3342        self.drop_without_shutdown();
3343        _result
3344    }
3345
3346    /// Similar to "send" but does not shutdown the channel if an error occurs.
3347    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3348        let _result = self.send_raw(result);
3349        self.drop_without_shutdown();
3350        _result
3351    }
3352
3353    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3354        self.control_handle
3355            .inner
3356            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3357                result,
3358                self.tx_id,
3359                0x59a5076762318bf,
3360                fidl::encoding::DynamicFlags::empty(),
3361            )
3362    }
3363}
3364
3365#[must_use = "FIDL methods require a response to be sent"]
3366#[derive(Debug)]
3367pub struct CryptManagementSetActiveKeyResponder {
3368    control_handle: std::mem::ManuallyDrop<CryptManagementControlHandle>,
3369    tx_id: u32,
3370}
3371
3372/// Set the the channel to be shutdown (see [`CryptManagementControlHandle::shutdown`])
3373/// if the responder is dropped without sending a response, so that the client
3374/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3375impl std::ops::Drop for CryptManagementSetActiveKeyResponder {
3376    fn drop(&mut self) {
3377        self.control_handle.shutdown();
3378        // Safety: drops once, never accessed again
3379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3380    }
3381}
3382
3383impl fidl::endpoints::Responder for CryptManagementSetActiveKeyResponder {
3384    type ControlHandle = CryptManagementControlHandle;
3385
3386    fn control_handle(&self) -> &CryptManagementControlHandle {
3387        &self.control_handle
3388    }
3389
3390    fn drop_without_shutdown(mut self) {
3391        // Safety: drops once, never accessed again due to mem::forget
3392        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3393        // Prevent Drop from running (which would shut down the channel)
3394        std::mem::forget(self);
3395    }
3396}
3397
3398impl CryptManagementSetActiveKeyResponder {
3399    /// Sends a response to the FIDL transaction.
3400    ///
3401    /// Sets the channel to shutdown if an error occurs.
3402    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3403        let _result = self.send_raw(result);
3404        if _result.is_err() {
3405            self.control_handle.shutdown();
3406        }
3407        self.drop_without_shutdown();
3408        _result
3409    }
3410
3411    /// Similar to "send" but does not shutdown the channel if an error occurs.
3412    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3413        let _result = self.send_raw(result);
3414        self.drop_without_shutdown();
3415        _result
3416    }
3417
3418    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3419        self.control_handle
3420            .inner
3421            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3422                result,
3423                self.tx_id,
3424                0x5e81d600442f2872,
3425                fidl::encoding::DynamicFlags::empty(),
3426            )
3427    }
3428}
3429
3430#[must_use = "FIDL methods require a response to be sent"]
3431#[derive(Debug)]
3432pub struct CryptManagementForgetWrappingKeyResponder {
3433    control_handle: std::mem::ManuallyDrop<CryptManagementControlHandle>,
3434    tx_id: u32,
3435}
3436
3437/// Set the the channel to be shutdown (see [`CryptManagementControlHandle::shutdown`])
3438/// if the responder is dropped without sending a response, so that the client
3439/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3440impl std::ops::Drop for CryptManagementForgetWrappingKeyResponder {
3441    fn drop(&mut self) {
3442        self.control_handle.shutdown();
3443        // Safety: drops once, never accessed again
3444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3445    }
3446}
3447
3448impl fidl::endpoints::Responder for CryptManagementForgetWrappingKeyResponder {
3449    type ControlHandle = CryptManagementControlHandle;
3450
3451    fn control_handle(&self) -> &CryptManagementControlHandle {
3452        &self.control_handle
3453    }
3454
3455    fn drop_without_shutdown(mut self) {
3456        // Safety: drops once, never accessed again due to mem::forget
3457        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3458        // Prevent Drop from running (which would shut down the channel)
3459        std::mem::forget(self);
3460    }
3461}
3462
3463impl CryptManagementForgetWrappingKeyResponder {
3464    /// Sends a response to the FIDL transaction.
3465    ///
3466    /// Sets the channel to shutdown if an error occurs.
3467    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3468        let _result = self.send_raw(result);
3469        if _result.is_err() {
3470            self.control_handle.shutdown();
3471        }
3472        self.drop_without_shutdown();
3473        _result
3474    }
3475
3476    /// Similar to "send" but does not shutdown the channel if an error occurs.
3477    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3478        let _result = self.send_raw(result);
3479        self.drop_without_shutdown();
3480        _result
3481    }
3482
3483    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
3484        self.control_handle
3485            .inner
3486            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
3487                result,
3488                self.tx_id,
3489                0x436d6d27696dfcf4,
3490                fidl::encoding::DynamicFlags::empty(),
3491            )
3492    }
3493}
3494
3495#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3496pub struct DebugMarker;
3497
3498impl fidl::endpoints::ProtocolMarker for DebugMarker {
3499    type Proxy = DebugProxy;
3500    type RequestStream = DebugRequestStream;
3501    #[cfg(target_os = "fuchsia")]
3502    type SynchronousProxy = DebugSynchronousProxy;
3503
3504    const DEBUG_NAME: &'static str = "fuchsia.fxfs.Debug";
3505}
3506impl fidl::endpoints::DiscoverableProtocolMarker for DebugMarker {}
3507pub type DebugCompactResult = Result<(), i32>;
3508pub type DebugDeleteProfileResult = Result<(), i32>;
3509pub type DebugRecordAndReplayProfileResult = Result<(), i32>;
3510pub type DebugReplayXorRecordProfileResult = Result<(), i32>;
3511pub type DebugStopProfileTasksResult = Result<(), i32>;
3512pub type DebugClearCachesResult = Result<(), i32>;
3513
3514pub trait DebugProxyInterface: Send + Sync {
3515    type CompactResponseFut: std::future::Future<Output = Result<DebugCompactResult, fidl::Error>>
3516        + Send;
3517    fn r#compact(&self) -> Self::CompactResponseFut;
3518    type DeleteProfileResponseFut: std::future::Future<Output = Result<DebugDeleteProfileResult, fidl::Error>>
3519        + Send;
3520    fn r#delete_profile(&self, volume: &str, profile: &str) -> Self::DeleteProfileResponseFut;
3521    type RecordAndReplayProfileResponseFut: std::future::Future<Output = Result<DebugRecordAndReplayProfileResult, fidl::Error>>
3522        + Send;
3523    fn r#record_and_replay_profile(
3524        &self,
3525        volume: Option<&str>,
3526        profile: &str,
3527        duration_secs: u32,
3528    ) -> Self::RecordAndReplayProfileResponseFut;
3529    type ReplayXorRecordProfileResponseFut: std::future::Future<Output = Result<DebugReplayXorRecordProfileResult, fidl::Error>>
3530        + Send;
3531    fn r#replay_xor_record_profile(
3532        &self,
3533        volume: &str,
3534        profile: &str,
3535        duration_secs: u32,
3536    ) -> Self::ReplayXorRecordProfileResponseFut;
3537    type StopProfileTasksResponseFut: std::future::Future<Output = Result<DebugStopProfileTasksResult, fidl::Error>>
3538        + Send;
3539    fn r#stop_profile_tasks(&self) -> Self::StopProfileTasksResponseFut;
3540    type ClearCachesResponseFut: std::future::Future<Output = Result<DebugClearCachesResult, fidl::Error>>
3541        + Send;
3542    fn r#clear_caches(&self) -> Self::ClearCachesResponseFut;
3543}
3544#[derive(Debug)]
3545#[cfg(target_os = "fuchsia")]
3546pub struct DebugSynchronousProxy {
3547    client: fidl::client::sync::Client,
3548}
3549
3550#[cfg(target_os = "fuchsia")]
3551impl fidl::endpoints::SynchronousProxy for DebugSynchronousProxy {
3552    type Proxy = DebugProxy;
3553    type Protocol = DebugMarker;
3554
3555    fn from_channel(inner: fidl::Channel) -> Self {
3556        Self::new(inner)
3557    }
3558
3559    fn into_channel(self) -> fidl::Channel {
3560        self.client.into_channel()
3561    }
3562
3563    fn as_channel(&self) -> &fidl::Channel {
3564        self.client.as_channel()
3565    }
3566}
3567
3568#[cfg(target_os = "fuchsia")]
3569impl DebugSynchronousProxy {
3570    pub fn new(channel: fidl::Channel) -> Self {
3571        Self { client: fidl::client::sync::Client::new(channel) }
3572    }
3573
3574    pub fn into_channel(self) -> fidl::Channel {
3575        self.client.into_channel()
3576    }
3577
3578    /// Waits until an event arrives and returns it. It is safe for other
3579    /// threads to make concurrent requests while waiting for an event.
3580    pub fn wait_for_event(
3581        &self,
3582        deadline: zx::MonotonicInstant,
3583    ) -> Result<DebugEvent, fidl::Error> {
3584        DebugEvent::decode(self.client.wait_for_event::<DebugMarker>(deadline)?)
3585    }
3586
3587    /// Forces a compaction.
3588    pub fn r#compact(
3589        &self,
3590        ___deadline: zx::MonotonicInstant,
3591    ) -> Result<DebugCompactResult, fidl::Error> {
3592        let _response = self.client.send_query::<
3593            fidl::encoding::EmptyPayload,
3594            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3595            DebugMarker,
3596        >(
3597            (),
3598            0x6553eb197306e489,
3599            fidl::encoding::DynamicFlags::empty(),
3600            ___deadline,
3601        )?;
3602        Ok(_response.map(|x| x))
3603    }
3604
3605    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
3606    /// active profile recording or replay.
3607    pub fn r#delete_profile(
3608        &self,
3609        mut volume: &str,
3610        mut profile: &str,
3611        ___deadline: zx::MonotonicInstant,
3612    ) -> Result<DebugDeleteProfileResult, fidl::Error> {
3613        let _response = self.client.send_query::<
3614            DebugDeleteProfileRequest,
3615            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3616            DebugMarker,
3617        >(
3618            (volume, profile,),
3619            0x54d9d4c9cf300a1e,
3620            fidl::encoding::DynamicFlags::empty(),
3621            ___deadline,
3622        )?;
3623        Ok(_response.map(|x| x))
3624    }
3625
3626    /// Begins recording a profile for a named volume for up to the given duration in seconds. If a
3627    /// profile already exists under the given name then it will begin replaying it as well. Fails
3628    /// if the volume isn't mounted or there is active profile recording or replay on the volume.
3629    /// Page faults for objects that do not get opened by a caller during the recording period will
3630    /// will be filtered out of the profile.
3631    ///
3632    /// This "record-while-replaying" strategy is meant to support boot-profiling in an environment
3633    /// where we don't explicitly know when the system has updated. By recording during replay and
3634    /// filtering objects without open events, Fxfs drops dead/replaced objects to refresh the
3635    /// profile.
3636    pub fn r#record_and_replay_profile(
3637        &self,
3638        mut volume: Option<&str>,
3639        mut profile: &str,
3640        mut duration_secs: u32,
3641        ___deadline: zx::MonotonicInstant,
3642    ) -> Result<DebugRecordAndReplayProfileResult, fidl::Error> {
3643        let _response = self.client.send_query::<
3644            DebugRecordAndReplayProfileRequest,
3645            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3646            DebugMarker,
3647        >(
3648            (volume, profile, duration_secs,),
3649            0x3973943f9b3a9010,
3650            fidl::encoding::DynamicFlags::empty(),
3651            ___deadline,
3652        )?;
3653        Ok(_response.map(|x| x))
3654    }
3655
3656    /// Replays a profile if one exists, and only records if one does not exist. Fails if the volume
3657    /// isn't mounted or there is active profile recording or replay on the volume.
3658    ///
3659    /// This profile method is meant to support app launch profiling. These profiles do not filter
3660    /// entries based on Open events since outside of the boot process objects may already be opened
3661    /// or cached in overlays like Starnix.
3662    pub fn r#replay_xor_record_profile(
3663        &self,
3664        mut volume: &str,
3665        mut profile: &str,
3666        mut duration_secs: u32,
3667        ___deadline: zx::MonotonicInstant,
3668    ) -> Result<DebugReplayXorRecordProfileResult, fidl::Error> {
3669        let _response = self.client.send_query::<
3670            DebugReplayXorRecordProfileRequest,
3671            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3672            DebugMarker,
3673        >(
3674            (volume, profile, duration_secs,),
3675            0x301678a1cebeef20,
3676            fidl::encoding::DynamicFlags::empty(),
3677            ___deadline,
3678        )?;
3679        Ok(_response.map(|x| x))
3680    }
3681
3682    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
3683    /// persisted.
3684    pub fn r#stop_profile_tasks(
3685        &self,
3686        ___deadline: zx::MonotonicInstant,
3687    ) -> Result<DebugStopProfileTasksResult, fidl::Error> {
3688        let _response = self.client.send_query::<
3689            fidl::encoding::EmptyPayload,
3690            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3691            DebugMarker,
3692        >(
3693            (),
3694            0x1657b945dd629177,
3695            fidl::encoding::DynamicFlags::empty(),
3696            ___deadline,
3697        )?;
3698        Ok(_response.map(|x| x))
3699    }
3700
3701    /// Clears the directory entry cache (dirent cache) for all volumes. This drops the strong
3702    /// references held by the cache to filesystem nodes (files and directories). If these nodes
3703    /// are not currently open elsewhere, they will be dropped, freeing their associated resources
3704    /// (including VMOs). Subsequent access to these paths will force Fxfs to recreate the nodes.
3705    /// Note that this does not clear other internal caches (e.g., CachingObjectHandle's caches
3706    /// used for LSM tree layers).
3707    pub fn r#clear_caches(
3708        &self,
3709        ___deadline: zx::MonotonicInstant,
3710    ) -> Result<DebugClearCachesResult, fidl::Error> {
3711        let _response = self.client.send_query::<
3712            fidl::encoding::EmptyPayload,
3713            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3714            DebugMarker,
3715        >(
3716            (),
3717            0x539de2a4580de767,
3718            fidl::encoding::DynamicFlags::empty(),
3719            ___deadline,
3720        )?;
3721        Ok(_response.map(|x| x))
3722    }
3723}
3724
3725#[cfg(target_os = "fuchsia")]
3726impl From<DebugSynchronousProxy> for zx::NullableHandle {
3727    fn from(value: DebugSynchronousProxy) -> Self {
3728        value.into_channel().into()
3729    }
3730}
3731
3732#[cfg(target_os = "fuchsia")]
3733impl From<fidl::Channel> for DebugSynchronousProxy {
3734    fn from(value: fidl::Channel) -> Self {
3735        Self::new(value)
3736    }
3737}
3738
3739#[cfg(target_os = "fuchsia")]
3740impl fidl::endpoints::FromClient for DebugSynchronousProxy {
3741    type Protocol = DebugMarker;
3742
3743    fn from_client(value: fidl::endpoints::ClientEnd<DebugMarker>) -> Self {
3744        Self::new(value.into_channel())
3745    }
3746}
3747
3748#[derive(Debug, Clone)]
3749pub struct DebugProxy {
3750    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3751}
3752
3753impl fidl::endpoints::Proxy for DebugProxy {
3754    type Protocol = DebugMarker;
3755
3756    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3757        Self::new(inner)
3758    }
3759
3760    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3761        self.client.into_channel().map_err(|client| Self { client })
3762    }
3763
3764    fn as_channel(&self) -> &::fidl::AsyncChannel {
3765        self.client.as_channel()
3766    }
3767}
3768
3769impl DebugProxy {
3770    /// Create a new Proxy for fuchsia.fxfs/Debug.
3771    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3772        let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3773        Self { client: fidl::client::Client::new(channel, protocol_name) }
3774    }
3775
3776    /// Get a Stream of events from the remote end of the protocol.
3777    ///
3778    /// # Panics
3779    ///
3780    /// Panics if the event stream was already taken.
3781    pub fn take_event_stream(&self) -> DebugEventStream {
3782        DebugEventStream { event_receiver: self.client.take_event_receiver() }
3783    }
3784
3785    /// Forces a compaction.
3786    pub fn r#compact(
3787        &self,
3788    ) -> fidl::client::QueryResponseFut<
3789        DebugCompactResult,
3790        fidl::encoding::DefaultFuchsiaResourceDialect,
3791    > {
3792        DebugProxyInterface::r#compact(self)
3793    }
3794
3795    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
3796    /// active profile recording or replay.
3797    pub fn r#delete_profile(
3798        &self,
3799        mut volume: &str,
3800        mut profile: &str,
3801    ) -> fidl::client::QueryResponseFut<
3802        DebugDeleteProfileResult,
3803        fidl::encoding::DefaultFuchsiaResourceDialect,
3804    > {
3805        DebugProxyInterface::r#delete_profile(self, volume, profile)
3806    }
3807
3808    /// Begins recording a profile for a named volume for up to the given duration in seconds. If a
3809    /// profile already exists under the given name then it will begin replaying it as well. Fails
3810    /// if the volume isn't mounted or there is active profile recording or replay on the volume.
3811    /// Page faults for objects that do not get opened by a caller during the recording period will
3812    /// will be filtered out of the profile.
3813    ///
3814    /// This "record-while-replaying" strategy is meant to support boot-profiling in an environment
3815    /// where we don't explicitly know when the system has updated. By recording during replay and
3816    /// filtering objects without open events, Fxfs drops dead/replaced objects to refresh the
3817    /// profile.
3818    pub fn r#record_and_replay_profile(
3819        &self,
3820        mut volume: Option<&str>,
3821        mut profile: &str,
3822        mut duration_secs: u32,
3823    ) -> fidl::client::QueryResponseFut<
3824        DebugRecordAndReplayProfileResult,
3825        fidl::encoding::DefaultFuchsiaResourceDialect,
3826    > {
3827        DebugProxyInterface::r#record_and_replay_profile(self, volume, profile, duration_secs)
3828    }
3829
3830    /// Replays a profile if one exists, and only records if one does not exist. Fails if the volume
3831    /// isn't mounted or there is active profile recording or replay on the volume.
3832    ///
3833    /// This profile method is meant to support app launch profiling. These profiles do not filter
3834    /// entries based on Open events since outside of the boot process objects may already be opened
3835    /// or cached in overlays like Starnix.
3836    pub fn r#replay_xor_record_profile(
3837        &self,
3838        mut volume: &str,
3839        mut profile: &str,
3840        mut duration_secs: u32,
3841    ) -> fidl::client::QueryResponseFut<
3842        DebugReplayXorRecordProfileResult,
3843        fidl::encoding::DefaultFuchsiaResourceDialect,
3844    > {
3845        DebugProxyInterface::r#replay_xor_record_profile(self, volume, profile, duration_secs)
3846    }
3847
3848    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
3849    /// persisted.
3850    pub fn r#stop_profile_tasks(
3851        &self,
3852    ) -> fidl::client::QueryResponseFut<
3853        DebugStopProfileTasksResult,
3854        fidl::encoding::DefaultFuchsiaResourceDialect,
3855    > {
3856        DebugProxyInterface::r#stop_profile_tasks(self)
3857    }
3858
3859    /// Clears the directory entry cache (dirent cache) for all volumes. This drops the strong
3860    /// references held by the cache to filesystem nodes (files and directories). If these nodes
3861    /// are not currently open elsewhere, they will be dropped, freeing their associated resources
3862    /// (including VMOs). Subsequent access to these paths will force Fxfs to recreate the nodes.
3863    /// Note that this does not clear other internal caches (e.g., CachingObjectHandle's caches
3864    /// used for LSM tree layers).
3865    pub fn r#clear_caches(
3866        &self,
3867    ) -> fidl::client::QueryResponseFut<
3868        DebugClearCachesResult,
3869        fidl::encoding::DefaultFuchsiaResourceDialect,
3870    > {
3871        DebugProxyInterface::r#clear_caches(self)
3872    }
3873}
3874
3875impl DebugProxyInterface for DebugProxy {
3876    type CompactResponseFut = fidl::client::QueryResponseFut<
3877        DebugCompactResult,
3878        fidl::encoding::DefaultFuchsiaResourceDialect,
3879    >;
3880    fn r#compact(&self) -> Self::CompactResponseFut {
3881        fn _decode(
3882            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3883        ) -> Result<DebugCompactResult, fidl::Error> {
3884            let _response = fidl::client::decode_transaction_body::<
3885                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3886                fidl::encoding::DefaultFuchsiaResourceDialect,
3887                0x6553eb197306e489,
3888            >(_buf?)?;
3889            Ok(_response.map(|x| x))
3890        }
3891        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DebugCompactResult>(
3892            (),
3893            0x6553eb197306e489,
3894            fidl::encoding::DynamicFlags::empty(),
3895            _decode,
3896        )
3897    }
3898
3899    type DeleteProfileResponseFut = fidl::client::QueryResponseFut<
3900        DebugDeleteProfileResult,
3901        fidl::encoding::DefaultFuchsiaResourceDialect,
3902    >;
3903    fn r#delete_profile(
3904        &self,
3905        mut volume: &str,
3906        mut profile: &str,
3907    ) -> Self::DeleteProfileResponseFut {
3908        fn _decode(
3909            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3910        ) -> Result<DebugDeleteProfileResult, fidl::Error> {
3911            let _response = fidl::client::decode_transaction_body::<
3912                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3913                fidl::encoding::DefaultFuchsiaResourceDialect,
3914                0x54d9d4c9cf300a1e,
3915            >(_buf?)?;
3916            Ok(_response.map(|x| x))
3917        }
3918        self.client.send_query_and_decode::<DebugDeleteProfileRequest, DebugDeleteProfileResult>(
3919            (volume, profile),
3920            0x54d9d4c9cf300a1e,
3921            fidl::encoding::DynamicFlags::empty(),
3922            _decode,
3923        )
3924    }
3925
3926    type RecordAndReplayProfileResponseFut = fidl::client::QueryResponseFut<
3927        DebugRecordAndReplayProfileResult,
3928        fidl::encoding::DefaultFuchsiaResourceDialect,
3929    >;
3930    fn r#record_and_replay_profile(
3931        &self,
3932        mut volume: Option<&str>,
3933        mut profile: &str,
3934        mut duration_secs: u32,
3935    ) -> Self::RecordAndReplayProfileResponseFut {
3936        fn _decode(
3937            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3938        ) -> Result<DebugRecordAndReplayProfileResult, fidl::Error> {
3939            let _response = fidl::client::decode_transaction_body::<
3940                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3941                fidl::encoding::DefaultFuchsiaResourceDialect,
3942                0x3973943f9b3a9010,
3943            >(_buf?)?;
3944            Ok(_response.map(|x| x))
3945        }
3946        self.client.send_query_and_decode::<
3947            DebugRecordAndReplayProfileRequest,
3948            DebugRecordAndReplayProfileResult,
3949        >(
3950            (volume, profile, duration_secs,),
3951            0x3973943f9b3a9010,
3952            fidl::encoding::DynamicFlags::empty(),
3953            _decode,
3954        )
3955    }
3956
3957    type ReplayXorRecordProfileResponseFut = fidl::client::QueryResponseFut<
3958        DebugReplayXorRecordProfileResult,
3959        fidl::encoding::DefaultFuchsiaResourceDialect,
3960    >;
3961    fn r#replay_xor_record_profile(
3962        &self,
3963        mut volume: &str,
3964        mut profile: &str,
3965        mut duration_secs: u32,
3966    ) -> Self::ReplayXorRecordProfileResponseFut {
3967        fn _decode(
3968            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3969        ) -> Result<DebugReplayXorRecordProfileResult, fidl::Error> {
3970            let _response = fidl::client::decode_transaction_body::<
3971                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3972                fidl::encoding::DefaultFuchsiaResourceDialect,
3973                0x301678a1cebeef20,
3974            >(_buf?)?;
3975            Ok(_response.map(|x| x))
3976        }
3977        self.client.send_query_and_decode::<
3978            DebugReplayXorRecordProfileRequest,
3979            DebugReplayXorRecordProfileResult,
3980        >(
3981            (volume, profile, duration_secs,),
3982            0x301678a1cebeef20,
3983            fidl::encoding::DynamicFlags::empty(),
3984            _decode,
3985        )
3986    }
3987
3988    type StopProfileTasksResponseFut = fidl::client::QueryResponseFut<
3989        DebugStopProfileTasksResult,
3990        fidl::encoding::DefaultFuchsiaResourceDialect,
3991    >;
3992    fn r#stop_profile_tasks(&self) -> Self::StopProfileTasksResponseFut {
3993        fn _decode(
3994            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3995        ) -> Result<DebugStopProfileTasksResult, fidl::Error> {
3996            let _response = fidl::client::decode_transaction_body::<
3997                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
3998                fidl::encoding::DefaultFuchsiaResourceDialect,
3999                0x1657b945dd629177,
4000            >(_buf?)?;
4001            Ok(_response.map(|x| x))
4002        }
4003        self.client
4004            .send_query_and_decode::<fidl::encoding::EmptyPayload, DebugStopProfileTasksResult>(
4005                (),
4006                0x1657b945dd629177,
4007                fidl::encoding::DynamicFlags::empty(),
4008                _decode,
4009            )
4010    }
4011
4012    type ClearCachesResponseFut = fidl::client::QueryResponseFut<
4013        DebugClearCachesResult,
4014        fidl::encoding::DefaultFuchsiaResourceDialect,
4015    >;
4016    fn r#clear_caches(&self) -> Self::ClearCachesResponseFut {
4017        fn _decode(
4018            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4019        ) -> Result<DebugClearCachesResult, fidl::Error> {
4020            let _response = fidl::client::decode_transaction_body::<
4021                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
4022                fidl::encoding::DefaultFuchsiaResourceDialect,
4023                0x539de2a4580de767,
4024            >(_buf?)?;
4025            Ok(_response.map(|x| x))
4026        }
4027        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DebugClearCachesResult>(
4028            (),
4029            0x539de2a4580de767,
4030            fidl::encoding::DynamicFlags::empty(),
4031            _decode,
4032        )
4033    }
4034}
4035
4036pub struct DebugEventStream {
4037    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4038}
4039
4040impl std::marker::Unpin for DebugEventStream {}
4041
4042impl futures::stream::FusedStream for DebugEventStream {
4043    fn is_terminated(&self) -> bool {
4044        self.event_receiver.is_terminated()
4045    }
4046}
4047
4048impl futures::Stream for DebugEventStream {
4049    type Item = Result<DebugEvent, fidl::Error>;
4050
4051    fn poll_next(
4052        mut self: std::pin::Pin<&mut Self>,
4053        cx: &mut std::task::Context<'_>,
4054    ) -> std::task::Poll<Option<Self::Item>> {
4055        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4056            &mut self.event_receiver,
4057            cx
4058        )?) {
4059            Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
4060            None => std::task::Poll::Ready(None),
4061        }
4062    }
4063}
4064
4065#[derive(Debug)]
4066pub enum DebugEvent {}
4067
4068impl DebugEvent {
4069    /// Decodes a message buffer as a [`DebugEvent`].
4070    fn decode(
4071        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4072    ) -> Result<DebugEvent, fidl::Error> {
4073        let (bytes, _handles) = buf.split_mut();
4074        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4075        debug_assert_eq!(tx_header.tx_id, 0);
4076        match tx_header.ordinal {
4077            _ => Err(fidl::Error::UnknownOrdinal {
4078                ordinal: tx_header.ordinal,
4079                protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4080            }),
4081        }
4082    }
4083}
4084
4085/// A Stream of incoming requests for fuchsia.fxfs/Debug.
4086pub struct DebugRequestStream {
4087    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4088    is_terminated: bool,
4089}
4090
4091impl std::marker::Unpin for DebugRequestStream {}
4092
4093impl futures::stream::FusedStream for DebugRequestStream {
4094    fn is_terminated(&self) -> bool {
4095        self.is_terminated
4096    }
4097}
4098
4099impl fidl::endpoints::RequestStream for DebugRequestStream {
4100    type Protocol = DebugMarker;
4101    type ControlHandle = DebugControlHandle;
4102
4103    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4104        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4105    }
4106
4107    fn control_handle(&self) -> Self::ControlHandle {
4108        DebugControlHandle { inner: self.inner.clone() }
4109    }
4110
4111    fn into_inner(
4112        self,
4113    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4114    {
4115        (self.inner, self.is_terminated)
4116    }
4117
4118    fn from_inner(
4119        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4120        is_terminated: bool,
4121    ) -> Self {
4122        Self { inner, is_terminated }
4123    }
4124}
4125
4126impl futures::Stream for DebugRequestStream {
4127    type Item = Result<DebugRequest, fidl::Error>;
4128
4129    fn poll_next(
4130        mut self: std::pin::Pin<&mut Self>,
4131        cx: &mut std::task::Context<'_>,
4132    ) -> std::task::Poll<Option<Self::Item>> {
4133        let this = &mut *self;
4134        if this.inner.check_shutdown(cx) {
4135            this.is_terminated = true;
4136            return std::task::Poll::Ready(None);
4137        }
4138        if this.is_terminated {
4139            panic!("polled DebugRequestStream after completion");
4140        }
4141        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4142            |bytes, handles| {
4143                match this.inner.channel().read_etc(cx, bytes, handles) {
4144                    std::task::Poll::Ready(Ok(())) => {}
4145                    std::task::Poll::Pending => return std::task::Poll::Pending,
4146                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4147                        this.is_terminated = true;
4148                        return std::task::Poll::Ready(None);
4149                    }
4150                    std::task::Poll::Ready(Err(e)) => {
4151                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4152                            e.into(),
4153                        ))));
4154                    }
4155                }
4156
4157                // A message has been received from the channel
4158                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4159
4160                std::task::Poll::Ready(Some(match header.ordinal {
4161                    0x6553eb197306e489 => {
4162                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4163                        let mut req = fidl::new_empty!(
4164                            fidl::encoding::EmptyPayload,
4165                            fidl::encoding::DefaultFuchsiaResourceDialect
4166                        );
4167                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4168                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
4169                        Ok(DebugRequest::Compact {
4170                            responder: DebugCompactResponder {
4171                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4172                                tx_id: header.tx_id,
4173                            },
4174                        })
4175                    }
4176                    0x54d9d4c9cf300a1e => {
4177                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4178                        let mut req = fidl::new_empty!(
4179                            DebugDeleteProfileRequest,
4180                            fidl::encoding::DefaultFuchsiaResourceDialect
4181                        );
4182                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugDeleteProfileRequest>(&header, _body_bytes, handles, &mut req)?;
4183                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
4184                        Ok(DebugRequest::DeleteProfile {
4185                            volume: req.volume,
4186                            profile: req.profile,
4187
4188                            responder: DebugDeleteProfileResponder {
4189                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4190                                tx_id: header.tx_id,
4191                            },
4192                        })
4193                    }
4194                    0x3973943f9b3a9010 => {
4195                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4196                        let mut req = fidl::new_empty!(
4197                            DebugRecordAndReplayProfileRequest,
4198                            fidl::encoding::DefaultFuchsiaResourceDialect
4199                        );
4200                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugRecordAndReplayProfileRequest>(&header, _body_bytes, handles, &mut req)?;
4201                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
4202                        Ok(DebugRequest::RecordAndReplayProfile {
4203                            volume: req.volume,
4204                            profile: req.profile,
4205                            duration_secs: req.duration_secs,
4206
4207                            responder: DebugRecordAndReplayProfileResponder {
4208                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4209                                tx_id: header.tx_id,
4210                            },
4211                        })
4212                    }
4213                    0x301678a1cebeef20 => {
4214                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4215                        let mut req = fidl::new_empty!(
4216                            DebugReplayXorRecordProfileRequest,
4217                            fidl::encoding::DefaultFuchsiaResourceDialect
4218                        );
4219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugReplayXorRecordProfileRequest>(&header, _body_bytes, handles, &mut req)?;
4220                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
4221                        Ok(DebugRequest::ReplayXorRecordProfile {
4222                            volume: req.volume,
4223                            profile: req.profile,
4224                            duration_secs: req.duration_secs,
4225
4226                            responder: DebugReplayXorRecordProfileResponder {
4227                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4228                                tx_id: header.tx_id,
4229                            },
4230                        })
4231                    }
4232                    0x1657b945dd629177 => {
4233                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4234                        let mut req = fidl::new_empty!(
4235                            fidl::encoding::EmptyPayload,
4236                            fidl::encoding::DefaultFuchsiaResourceDialect
4237                        );
4238                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4239                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
4240                        Ok(DebugRequest::StopProfileTasks {
4241                            responder: DebugStopProfileTasksResponder {
4242                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4243                                tx_id: header.tx_id,
4244                            },
4245                        })
4246                    }
4247                    0x539de2a4580de767 => {
4248                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4249                        let mut req = fidl::new_empty!(
4250                            fidl::encoding::EmptyPayload,
4251                            fidl::encoding::DefaultFuchsiaResourceDialect
4252                        );
4253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4254                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
4255                        Ok(DebugRequest::ClearCaches {
4256                            responder: DebugClearCachesResponder {
4257                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4258                                tx_id: header.tx_id,
4259                            },
4260                        })
4261                    }
4262                    _ => Err(fidl::Error::UnknownOrdinal {
4263                        ordinal: header.ordinal,
4264                        protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4265                    }),
4266                }))
4267            },
4268        )
4269    }
4270}
4271
4272/// This is an internal protocol for on-device debugging and testing only.
4273/// See `ffx fxfs help` for more details.
4274#[derive(Debug)]
4275pub enum DebugRequest {
4276    /// Forces a compaction.
4277    Compact { responder: DebugCompactResponder },
4278    /// Deletes a recorded profile from a volume. Fails if the volume isn't mounted or there is
4279    /// active profile recording or replay.
4280    DeleteProfile { volume: String, profile: String, responder: DebugDeleteProfileResponder },
4281    /// Begins recording a profile for a named volume for up to the given duration in seconds. If a
4282    /// profile already exists under the given name then it will begin replaying it as well. Fails
4283    /// if the volume isn't mounted or there is active profile recording or replay on the volume.
4284    /// Page faults for objects that do not get opened by a caller during the recording period will
4285    /// will be filtered out of the profile.
4286    ///
4287    /// This "record-while-replaying" strategy is meant to support boot-profiling in an environment
4288    /// where we don't explicitly know when the system has updated. By recording during replay and
4289    /// filtering objects without open events, Fxfs drops dead/replaced objects to refresh the
4290    /// profile.
4291    RecordAndReplayProfile {
4292        volume: Option<String>,
4293        profile: String,
4294        duration_secs: u32,
4295        responder: DebugRecordAndReplayProfileResponder,
4296    },
4297    /// Replays a profile if one exists, and only records if one does not exist. Fails if the volume
4298    /// isn't mounted or there is active profile recording or replay on the volume.
4299    ///
4300    /// This profile method is meant to support app launch profiling. These profiles do not filter
4301    /// entries based on Open events since outside of the boot process objects may already be opened
4302    /// or cached in overlays like Starnix.
4303    ReplayXorRecordProfile {
4304        volume: String,
4305        profile: String,
4306        duration_secs: u32,
4307        responder: DebugReplayXorRecordProfileResponder,
4308    },
4309    /// Stops all profile recording and replay activity. Ongoing recordings are completed and
4310    /// persisted.
4311    StopProfileTasks { responder: DebugStopProfileTasksResponder },
4312    /// Clears the directory entry cache (dirent cache) for all volumes. This drops the strong
4313    /// references held by the cache to filesystem nodes (files and directories). If these nodes
4314    /// are not currently open elsewhere, they will be dropped, freeing their associated resources
4315    /// (including VMOs). Subsequent access to these paths will force Fxfs to recreate the nodes.
4316    /// Note that this does not clear other internal caches (e.g., CachingObjectHandle's caches
4317    /// used for LSM tree layers).
4318    ClearCaches { responder: DebugClearCachesResponder },
4319}
4320
4321impl DebugRequest {
4322    #[allow(irrefutable_let_patterns)]
4323    pub fn into_compact(self) -> Option<(DebugCompactResponder)> {
4324        if let DebugRequest::Compact { responder } = self { Some((responder)) } else { None }
4325    }
4326
4327    #[allow(irrefutable_let_patterns)]
4328    pub fn into_delete_profile(self) -> Option<(String, String, DebugDeleteProfileResponder)> {
4329        if let DebugRequest::DeleteProfile { volume, profile, responder } = self {
4330            Some((volume, profile, responder))
4331        } else {
4332            None
4333        }
4334    }
4335
4336    #[allow(irrefutable_let_patterns)]
4337    pub fn into_record_and_replay_profile(
4338        self,
4339    ) -> Option<(Option<String>, String, u32, DebugRecordAndReplayProfileResponder)> {
4340        if let DebugRequest::RecordAndReplayProfile { volume, profile, duration_secs, responder } =
4341            self
4342        {
4343            Some((volume, profile, duration_secs, responder))
4344        } else {
4345            None
4346        }
4347    }
4348
4349    #[allow(irrefutable_let_patterns)]
4350    pub fn into_replay_xor_record_profile(
4351        self,
4352    ) -> Option<(String, String, u32, DebugReplayXorRecordProfileResponder)> {
4353        if let DebugRequest::ReplayXorRecordProfile { volume, profile, duration_secs, responder } =
4354            self
4355        {
4356            Some((volume, profile, duration_secs, responder))
4357        } else {
4358            None
4359        }
4360    }
4361
4362    #[allow(irrefutable_let_patterns)]
4363    pub fn into_stop_profile_tasks(self) -> Option<(DebugStopProfileTasksResponder)> {
4364        if let DebugRequest::StopProfileTasks { responder } = self {
4365            Some((responder))
4366        } else {
4367            None
4368        }
4369    }
4370
4371    #[allow(irrefutable_let_patterns)]
4372    pub fn into_clear_caches(self) -> Option<(DebugClearCachesResponder)> {
4373        if let DebugRequest::ClearCaches { responder } = self { Some((responder)) } else { None }
4374    }
4375
4376    /// Name of the method defined in FIDL
4377    pub fn method_name(&self) -> &'static str {
4378        match *self {
4379            DebugRequest::Compact { .. } => "compact",
4380            DebugRequest::DeleteProfile { .. } => "delete_profile",
4381            DebugRequest::RecordAndReplayProfile { .. } => "record_and_replay_profile",
4382            DebugRequest::ReplayXorRecordProfile { .. } => "replay_xor_record_profile",
4383            DebugRequest::StopProfileTasks { .. } => "stop_profile_tasks",
4384            DebugRequest::ClearCaches { .. } => "clear_caches",
4385        }
4386    }
4387}
4388
4389#[derive(Debug, Clone)]
4390pub struct DebugControlHandle {
4391    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4392}
4393
4394impl DebugControlHandle {
4395    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4396        self.inner.shutdown_with_epitaph(status.into())
4397    }
4398}
4399
4400impl fidl::endpoints::ControlHandle for DebugControlHandle {
4401    fn shutdown(&self) {
4402        self.inner.shutdown()
4403    }
4404
4405    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4406        self.inner.shutdown_with_epitaph(status)
4407    }
4408
4409    fn is_closed(&self) -> bool {
4410        self.inner.channel().is_closed()
4411    }
4412    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4413        self.inner.channel().on_closed()
4414    }
4415
4416    #[cfg(target_os = "fuchsia")]
4417    fn signal_peer(
4418        &self,
4419        clear_mask: zx::Signals,
4420        set_mask: zx::Signals,
4421    ) -> Result<(), zx_status::Status> {
4422        use fidl::Peered;
4423        self.inner.channel().signal_peer(clear_mask, set_mask)
4424    }
4425}
4426
4427impl DebugControlHandle {}
4428
4429#[must_use = "FIDL methods require a response to be sent"]
4430#[derive(Debug)]
4431pub struct DebugCompactResponder {
4432    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4433    tx_id: u32,
4434}
4435
4436/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4437/// if the responder is dropped without sending a response, so that the client
4438/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4439impl std::ops::Drop for DebugCompactResponder {
4440    fn drop(&mut self) {
4441        self.control_handle.shutdown();
4442        // Safety: drops once, never accessed again
4443        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4444    }
4445}
4446
4447impl fidl::endpoints::Responder for DebugCompactResponder {
4448    type ControlHandle = DebugControlHandle;
4449
4450    fn control_handle(&self) -> &DebugControlHandle {
4451        &self.control_handle
4452    }
4453
4454    fn drop_without_shutdown(mut self) {
4455        // Safety: drops once, never accessed again due to mem::forget
4456        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4457        // Prevent Drop from running (which would shut down the channel)
4458        std::mem::forget(self);
4459    }
4460}
4461
4462impl DebugCompactResponder {
4463    /// Sends a response to the FIDL transaction.
4464    ///
4465    /// Sets the channel to shutdown if an error occurs.
4466    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4467        let _result = self.send_raw(result);
4468        if _result.is_err() {
4469            self.control_handle.shutdown();
4470        }
4471        self.drop_without_shutdown();
4472        _result
4473    }
4474
4475    /// Similar to "send" but does not shutdown the channel if an error occurs.
4476    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4477        let _result = self.send_raw(result);
4478        self.drop_without_shutdown();
4479        _result
4480    }
4481
4482    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4483        self.control_handle
4484            .inner
4485            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4486                result,
4487                self.tx_id,
4488                0x6553eb197306e489,
4489                fidl::encoding::DynamicFlags::empty(),
4490            )
4491    }
4492}
4493
4494#[must_use = "FIDL methods require a response to be sent"]
4495#[derive(Debug)]
4496pub struct DebugDeleteProfileResponder {
4497    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4498    tx_id: u32,
4499}
4500
4501/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4502/// if the responder is dropped without sending a response, so that the client
4503/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4504impl std::ops::Drop for DebugDeleteProfileResponder {
4505    fn drop(&mut self) {
4506        self.control_handle.shutdown();
4507        // Safety: drops once, never accessed again
4508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4509    }
4510}
4511
4512impl fidl::endpoints::Responder for DebugDeleteProfileResponder {
4513    type ControlHandle = DebugControlHandle;
4514
4515    fn control_handle(&self) -> &DebugControlHandle {
4516        &self.control_handle
4517    }
4518
4519    fn drop_without_shutdown(mut self) {
4520        // Safety: drops once, never accessed again due to mem::forget
4521        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4522        // Prevent Drop from running (which would shut down the channel)
4523        std::mem::forget(self);
4524    }
4525}
4526
4527impl DebugDeleteProfileResponder {
4528    /// Sends a response to the FIDL transaction.
4529    ///
4530    /// Sets the channel to shutdown if an error occurs.
4531    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4532        let _result = self.send_raw(result);
4533        if _result.is_err() {
4534            self.control_handle.shutdown();
4535        }
4536        self.drop_without_shutdown();
4537        _result
4538    }
4539
4540    /// Similar to "send" but does not shutdown the channel if an error occurs.
4541    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4542        let _result = self.send_raw(result);
4543        self.drop_without_shutdown();
4544        _result
4545    }
4546
4547    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4548        self.control_handle
4549            .inner
4550            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4551                result,
4552                self.tx_id,
4553                0x54d9d4c9cf300a1e,
4554                fidl::encoding::DynamicFlags::empty(),
4555            )
4556    }
4557}
4558
4559#[must_use = "FIDL methods require a response to be sent"]
4560#[derive(Debug)]
4561pub struct DebugRecordAndReplayProfileResponder {
4562    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4563    tx_id: u32,
4564}
4565
4566/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4567/// if the responder is dropped without sending a response, so that the client
4568/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4569impl std::ops::Drop for DebugRecordAndReplayProfileResponder {
4570    fn drop(&mut self) {
4571        self.control_handle.shutdown();
4572        // Safety: drops once, never accessed again
4573        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4574    }
4575}
4576
4577impl fidl::endpoints::Responder for DebugRecordAndReplayProfileResponder {
4578    type ControlHandle = DebugControlHandle;
4579
4580    fn control_handle(&self) -> &DebugControlHandle {
4581        &self.control_handle
4582    }
4583
4584    fn drop_without_shutdown(mut self) {
4585        // Safety: drops once, never accessed again due to mem::forget
4586        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4587        // Prevent Drop from running (which would shut down the channel)
4588        std::mem::forget(self);
4589    }
4590}
4591
4592impl DebugRecordAndReplayProfileResponder {
4593    /// Sends a response to the FIDL transaction.
4594    ///
4595    /// Sets the channel to shutdown if an error occurs.
4596    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4597        let _result = self.send_raw(result);
4598        if _result.is_err() {
4599            self.control_handle.shutdown();
4600        }
4601        self.drop_without_shutdown();
4602        _result
4603    }
4604
4605    /// Similar to "send" but does not shutdown the channel if an error occurs.
4606    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4607        let _result = self.send_raw(result);
4608        self.drop_without_shutdown();
4609        _result
4610    }
4611
4612    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4613        self.control_handle
4614            .inner
4615            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4616                result,
4617                self.tx_id,
4618                0x3973943f9b3a9010,
4619                fidl::encoding::DynamicFlags::empty(),
4620            )
4621    }
4622}
4623
4624#[must_use = "FIDL methods require a response to be sent"]
4625#[derive(Debug)]
4626pub struct DebugReplayXorRecordProfileResponder {
4627    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4628    tx_id: u32,
4629}
4630
4631/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4632/// if the responder is dropped without sending a response, so that the client
4633/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4634impl std::ops::Drop for DebugReplayXorRecordProfileResponder {
4635    fn drop(&mut self) {
4636        self.control_handle.shutdown();
4637        // Safety: drops once, never accessed again
4638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4639    }
4640}
4641
4642impl fidl::endpoints::Responder for DebugReplayXorRecordProfileResponder {
4643    type ControlHandle = DebugControlHandle;
4644
4645    fn control_handle(&self) -> &DebugControlHandle {
4646        &self.control_handle
4647    }
4648
4649    fn drop_without_shutdown(mut self) {
4650        // Safety: drops once, never accessed again due to mem::forget
4651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4652        // Prevent Drop from running (which would shut down the channel)
4653        std::mem::forget(self);
4654    }
4655}
4656
4657impl DebugReplayXorRecordProfileResponder {
4658    /// Sends a response to the FIDL transaction.
4659    ///
4660    /// Sets the channel to shutdown if an error occurs.
4661    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4662        let _result = self.send_raw(result);
4663        if _result.is_err() {
4664            self.control_handle.shutdown();
4665        }
4666        self.drop_without_shutdown();
4667        _result
4668    }
4669
4670    /// Similar to "send" but does not shutdown the channel if an error occurs.
4671    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4672        let _result = self.send_raw(result);
4673        self.drop_without_shutdown();
4674        _result
4675    }
4676
4677    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4678        self.control_handle
4679            .inner
4680            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4681                result,
4682                self.tx_id,
4683                0x301678a1cebeef20,
4684                fidl::encoding::DynamicFlags::empty(),
4685            )
4686    }
4687}
4688
4689#[must_use = "FIDL methods require a response to be sent"]
4690#[derive(Debug)]
4691pub struct DebugStopProfileTasksResponder {
4692    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4693    tx_id: u32,
4694}
4695
4696/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4697/// if the responder is dropped without sending a response, so that the client
4698/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4699impl std::ops::Drop for DebugStopProfileTasksResponder {
4700    fn drop(&mut self) {
4701        self.control_handle.shutdown();
4702        // Safety: drops once, never accessed again
4703        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4704    }
4705}
4706
4707impl fidl::endpoints::Responder for DebugStopProfileTasksResponder {
4708    type ControlHandle = DebugControlHandle;
4709
4710    fn control_handle(&self) -> &DebugControlHandle {
4711        &self.control_handle
4712    }
4713
4714    fn drop_without_shutdown(mut self) {
4715        // Safety: drops once, never accessed again due to mem::forget
4716        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4717        // Prevent Drop from running (which would shut down the channel)
4718        std::mem::forget(self);
4719    }
4720}
4721
4722impl DebugStopProfileTasksResponder {
4723    /// Sends a response to the FIDL transaction.
4724    ///
4725    /// Sets the channel to shutdown if an error occurs.
4726    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4727        let _result = self.send_raw(result);
4728        if _result.is_err() {
4729            self.control_handle.shutdown();
4730        }
4731        self.drop_without_shutdown();
4732        _result
4733    }
4734
4735    /// Similar to "send" but does not shutdown the channel if an error occurs.
4736    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4737        let _result = self.send_raw(result);
4738        self.drop_without_shutdown();
4739        _result
4740    }
4741
4742    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4743        self.control_handle
4744            .inner
4745            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4746                result,
4747                self.tx_id,
4748                0x1657b945dd629177,
4749                fidl::encoding::DynamicFlags::empty(),
4750            )
4751    }
4752}
4753
4754#[must_use = "FIDL methods require a response to be sent"]
4755#[derive(Debug)]
4756pub struct DebugClearCachesResponder {
4757    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
4758    tx_id: u32,
4759}
4760
4761/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
4762/// if the responder is dropped without sending a response, so that the client
4763/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4764impl std::ops::Drop for DebugClearCachesResponder {
4765    fn drop(&mut self) {
4766        self.control_handle.shutdown();
4767        // Safety: drops once, never accessed again
4768        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4769    }
4770}
4771
4772impl fidl::endpoints::Responder for DebugClearCachesResponder {
4773    type ControlHandle = DebugControlHandle;
4774
4775    fn control_handle(&self) -> &DebugControlHandle {
4776        &self.control_handle
4777    }
4778
4779    fn drop_without_shutdown(mut self) {
4780        // Safety: drops once, never accessed again due to mem::forget
4781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4782        // Prevent Drop from running (which would shut down the channel)
4783        std::mem::forget(self);
4784    }
4785}
4786
4787impl DebugClearCachesResponder {
4788    /// Sends a response to the FIDL transaction.
4789    ///
4790    /// Sets the channel to shutdown if an error occurs.
4791    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4792        let _result = self.send_raw(result);
4793        if _result.is_err() {
4794            self.control_handle.shutdown();
4795        }
4796        self.drop_without_shutdown();
4797        _result
4798    }
4799
4800    /// Similar to "send" but does not shutdown the channel if an error occurs.
4801    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4802        let _result = self.send_raw(result);
4803        self.drop_without_shutdown();
4804        _result
4805    }
4806
4807    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
4808        self.control_handle
4809            .inner
4810            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
4811                result,
4812                self.tx_id,
4813                0x539de2a4580de767,
4814                fidl::encoding::DynamicFlags::empty(),
4815            )
4816    }
4817}
4818
4819#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4820pub struct FileBackedVolumeProviderMarker;
4821
4822impl fidl::endpoints::ProtocolMarker for FileBackedVolumeProviderMarker {
4823    type Proxy = FileBackedVolumeProviderProxy;
4824    type RequestStream = FileBackedVolumeProviderRequestStream;
4825    #[cfg(target_os = "fuchsia")]
4826    type SynchronousProxy = FileBackedVolumeProviderSynchronousProxy;
4827
4828    const DEBUG_NAME: &'static str = "fuchsia.fxfs.FileBackedVolumeProvider";
4829}
4830impl fidl::endpoints::DiscoverableProtocolMarker for FileBackedVolumeProviderMarker {}
4831
4832pub trait FileBackedVolumeProviderProxyInterface: Send + Sync {
4833    fn r#open(
4834        &self,
4835        parent_directory_token: fidl::NullableHandle,
4836        name: &str,
4837        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
4838    ) -> Result<(), fidl::Error>;
4839}
4840#[derive(Debug)]
4841#[cfg(target_os = "fuchsia")]
4842pub struct FileBackedVolumeProviderSynchronousProxy {
4843    client: fidl::client::sync::Client,
4844}
4845
4846#[cfg(target_os = "fuchsia")]
4847impl fidl::endpoints::SynchronousProxy for FileBackedVolumeProviderSynchronousProxy {
4848    type Proxy = FileBackedVolumeProviderProxy;
4849    type Protocol = FileBackedVolumeProviderMarker;
4850
4851    fn from_channel(inner: fidl::Channel) -> Self {
4852        Self::new(inner)
4853    }
4854
4855    fn into_channel(self) -> fidl::Channel {
4856        self.client.into_channel()
4857    }
4858
4859    fn as_channel(&self) -> &fidl::Channel {
4860        self.client.as_channel()
4861    }
4862}
4863
4864#[cfg(target_os = "fuchsia")]
4865impl FileBackedVolumeProviderSynchronousProxy {
4866    pub fn new(channel: fidl::Channel) -> Self {
4867        Self { client: fidl::client::sync::Client::new(channel) }
4868    }
4869
4870    pub fn into_channel(self) -> fidl::Channel {
4871        self.client.into_channel()
4872    }
4873
4874    /// Waits until an event arrives and returns it. It is safe for other
4875    /// threads to make concurrent requests while waiting for an event.
4876    pub fn wait_for_event(
4877        &self,
4878        deadline: zx::MonotonicInstant,
4879    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
4880        FileBackedVolumeProviderEvent::decode(
4881            self.client.wait_for_event::<FileBackedVolumeProviderMarker>(deadline)?,
4882        )
4883    }
4884
4885    /// Opens a file as a block device and starts serving block requests.
4886    ///
4887    /// `name` must refer to an existing file in the directory represented by
4888    /// `parent_directory_token`.
4889    ///
4890    /// The block size of the device will match the underlying filesystem's block size.  If the
4891    /// file's size is not a multiple of the block size, the apparent size of the device will be
4892    /// rounded down.
4893    ///
4894    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4895    /// directory connection must have the `MODIFY_DIRECTORY` right.
4896    ///
4897    /// Errors will be sent as an epitaph on `server_end`.
4898    pub fn r#open(
4899        &self,
4900        mut parent_directory_token: fidl::NullableHandle,
4901        mut name: &str,
4902        mut server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
4903    ) -> Result<(), fidl::Error> {
4904        self.client.send::<FileBackedVolumeProviderOpenRequest>(
4905            (parent_directory_token, name, server_end),
4906            0x67120b9fc9f319ee,
4907            fidl::encoding::DynamicFlags::empty(),
4908        )
4909    }
4910}
4911
4912#[cfg(target_os = "fuchsia")]
4913impl From<FileBackedVolumeProviderSynchronousProxy> for zx::NullableHandle {
4914    fn from(value: FileBackedVolumeProviderSynchronousProxy) -> Self {
4915        value.into_channel().into()
4916    }
4917}
4918
4919#[cfg(target_os = "fuchsia")]
4920impl From<fidl::Channel> for FileBackedVolumeProviderSynchronousProxy {
4921    fn from(value: fidl::Channel) -> Self {
4922        Self::new(value)
4923    }
4924}
4925
4926#[cfg(target_os = "fuchsia")]
4927impl fidl::endpoints::FromClient for FileBackedVolumeProviderSynchronousProxy {
4928    type Protocol = FileBackedVolumeProviderMarker;
4929
4930    fn from_client(value: fidl::endpoints::ClientEnd<FileBackedVolumeProviderMarker>) -> Self {
4931        Self::new(value.into_channel())
4932    }
4933}
4934
4935#[derive(Debug, Clone)]
4936pub struct FileBackedVolumeProviderProxy {
4937    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4938}
4939
4940impl fidl::endpoints::Proxy for FileBackedVolumeProviderProxy {
4941    type Protocol = FileBackedVolumeProviderMarker;
4942
4943    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4944        Self::new(inner)
4945    }
4946
4947    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4948        self.client.into_channel().map_err(|client| Self { client })
4949    }
4950
4951    fn as_channel(&self) -> &::fidl::AsyncChannel {
4952        self.client.as_channel()
4953    }
4954}
4955
4956impl FileBackedVolumeProviderProxy {
4957    /// Create a new Proxy for fuchsia.fxfs/FileBackedVolumeProvider.
4958    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4959        let protocol_name =
4960            <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4961        Self { client: fidl::client::Client::new(channel, protocol_name) }
4962    }
4963
4964    /// Get a Stream of events from the remote end of the protocol.
4965    ///
4966    /// # Panics
4967    ///
4968    /// Panics if the event stream was already taken.
4969    pub fn take_event_stream(&self) -> FileBackedVolumeProviderEventStream {
4970        FileBackedVolumeProviderEventStream { event_receiver: self.client.take_event_receiver() }
4971    }
4972
4973    /// Opens a file as a block device and starts serving block requests.
4974    ///
4975    /// `name` must refer to an existing file in the directory represented by
4976    /// `parent_directory_token`.
4977    ///
4978    /// The block size of the device will match the underlying filesystem's block size.  If the
4979    /// file's size is not a multiple of the block size, the apparent size of the device will be
4980    /// rounded down.
4981    ///
4982    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
4983    /// directory connection must have the `MODIFY_DIRECTORY` right.
4984    ///
4985    /// Errors will be sent as an epitaph on `server_end`.
4986    pub fn r#open(
4987        &self,
4988        mut parent_directory_token: fidl::NullableHandle,
4989        mut name: &str,
4990        mut server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
4991    ) -> Result<(), fidl::Error> {
4992        FileBackedVolumeProviderProxyInterface::r#open(
4993            self,
4994            parent_directory_token,
4995            name,
4996            server_end,
4997        )
4998    }
4999}
5000
5001impl FileBackedVolumeProviderProxyInterface for FileBackedVolumeProviderProxy {
5002    fn r#open(
5003        &self,
5004        mut parent_directory_token: fidl::NullableHandle,
5005        mut name: &str,
5006        mut server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
5007    ) -> Result<(), fidl::Error> {
5008        self.client.send::<FileBackedVolumeProviderOpenRequest>(
5009            (parent_directory_token, name, server_end),
5010            0x67120b9fc9f319ee,
5011            fidl::encoding::DynamicFlags::empty(),
5012        )
5013    }
5014}
5015
5016pub struct FileBackedVolumeProviderEventStream {
5017    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5018}
5019
5020impl std::marker::Unpin for FileBackedVolumeProviderEventStream {}
5021
5022impl futures::stream::FusedStream for FileBackedVolumeProviderEventStream {
5023    fn is_terminated(&self) -> bool {
5024        self.event_receiver.is_terminated()
5025    }
5026}
5027
5028impl futures::Stream for FileBackedVolumeProviderEventStream {
5029    type Item = Result<FileBackedVolumeProviderEvent, fidl::Error>;
5030
5031    fn poll_next(
5032        mut self: std::pin::Pin<&mut Self>,
5033        cx: &mut std::task::Context<'_>,
5034    ) -> std::task::Poll<Option<Self::Item>> {
5035        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5036            &mut self.event_receiver,
5037            cx
5038        )?) {
5039            Some(buf) => std::task::Poll::Ready(Some(FileBackedVolumeProviderEvent::decode(buf))),
5040            None => std::task::Poll::Ready(None),
5041        }
5042    }
5043}
5044
5045#[derive(Debug)]
5046pub enum FileBackedVolumeProviderEvent {}
5047
5048impl FileBackedVolumeProviderEvent {
5049    /// Decodes a message buffer as a [`FileBackedVolumeProviderEvent`].
5050    fn decode(
5051        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5052    ) -> Result<FileBackedVolumeProviderEvent, fidl::Error> {
5053        let (bytes, _handles) = buf.split_mut();
5054        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5055        debug_assert_eq!(tx_header.tx_id, 0);
5056        match tx_header.ordinal {
5057            _ => Err(fidl::Error::UnknownOrdinal {
5058                ordinal: tx_header.ordinal,
5059                protocol_name:
5060                    <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5061            }),
5062        }
5063    }
5064}
5065
5066/// A Stream of incoming requests for fuchsia.fxfs/FileBackedVolumeProvider.
5067pub struct FileBackedVolumeProviderRequestStream {
5068    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5069    is_terminated: bool,
5070}
5071
5072impl std::marker::Unpin for FileBackedVolumeProviderRequestStream {}
5073
5074impl futures::stream::FusedStream for FileBackedVolumeProviderRequestStream {
5075    fn is_terminated(&self) -> bool {
5076        self.is_terminated
5077    }
5078}
5079
5080impl fidl::endpoints::RequestStream for FileBackedVolumeProviderRequestStream {
5081    type Protocol = FileBackedVolumeProviderMarker;
5082    type ControlHandle = FileBackedVolumeProviderControlHandle;
5083
5084    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5085        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5086    }
5087
5088    fn control_handle(&self) -> Self::ControlHandle {
5089        FileBackedVolumeProviderControlHandle { inner: self.inner.clone() }
5090    }
5091
5092    fn into_inner(
5093        self,
5094    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5095    {
5096        (self.inner, self.is_terminated)
5097    }
5098
5099    fn from_inner(
5100        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5101        is_terminated: bool,
5102    ) -> Self {
5103        Self { inner, is_terminated }
5104    }
5105}
5106
5107impl futures::Stream for FileBackedVolumeProviderRequestStream {
5108    type Item = Result<FileBackedVolumeProviderRequest, fidl::Error>;
5109
5110    fn poll_next(
5111        mut self: std::pin::Pin<&mut Self>,
5112        cx: &mut std::task::Context<'_>,
5113    ) -> std::task::Poll<Option<Self::Item>> {
5114        let this = &mut *self;
5115        if this.inner.check_shutdown(cx) {
5116            this.is_terminated = true;
5117            return std::task::Poll::Ready(None);
5118        }
5119        if this.is_terminated {
5120            panic!("polled FileBackedVolumeProviderRequestStream after completion");
5121        }
5122        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5123            |bytes, handles| {
5124                match this.inner.channel().read_etc(cx, bytes, handles) {
5125                    std::task::Poll::Ready(Ok(())) => {}
5126                    std::task::Poll::Pending => return std::task::Poll::Pending,
5127                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5128                        this.is_terminated = true;
5129                        return std::task::Poll::Ready(None);
5130                    }
5131                    std::task::Poll::Ready(Err(e)) => {
5132                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5133                            e.into(),
5134                        ))));
5135                    }
5136                }
5137
5138                // A message has been received from the channel
5139                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5140
5141                std::task::Poll::Ready(Some(match header.ordinal {
5142                0x67120b9fc9f319ee => {
5143                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5144                    let mut req = fidl::new_empty!(FileBackedVolumeProviderOpenRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
5145                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FileBackedVolumeProviderOpenRequest>(&header, _body_bytes, handles, &mut req)?;
5146                    let control_handle = FileBackedVolumeProviderControlHandle {
5147                        inner: this.inner.clone(),
5148                    };
5149                    Ok(FileBackedVolumeProviderRequest::Open {parent_directory_token: req.parent_directory_token,
5150name: req.name,
5151server_end: req.server_end,
5152
5153                        control_handle,
5154                    })
5155                }
5156                _ => Err(fidl::Error::UnknownOrdinal {
5157                    ordinal: header.ordinal,
5158                    protocol_name: <FileBackedVolumeProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5159                }),
5160            }))
5161            },
5162        )
5163    }
5164}
5165
5166/// A protocol to serve the Volume protocol on a file-backed device.
5167#[derive(Debug)]
5168pub enum FileBackedVolumeProviderRequest {
5169    /// Opens a file as a block device and starts serving block requests.
5170    ///
5171    /// `name` must refer to an existing file in the directory represented by
5172    /// `parent_directory_token`.
5173    ///
5174    /// The block size of the device will match the underlying filesystem's block size.  If the
5175    /// file's size is not a multiple of the block size, the apparent size of the device will be
5176    /// rounded down.
5177    ///
5178    /// `parent_directory_token` is a token obtained via `fuchsia.io.Directory/GetToken`.  The
5179    /// directory connection must have the `MODIFY_DIRECTORY` right.
5180    ///
5181    /// Errors will be sent as an epitaph on `server_end`.
5182    Open {
5183        parent_directory_token: fidl::NullableHandle,
5184        name: String,
5185        server_end: fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
5186        control_handle: FileBackedVolumeProviderControlHandle,
5187    },
5188}
5189
5190impl FileBackedVolumeProviderRequest {
5191    #[allow(irrefutable_let_patterns)]
5192    pub fn into_open(
5193        self,
5194    ) -> Option<(
5195        fidl::NullableHandle,
5196        String,
5197        fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
5198        FileBackedVolumeProviderControlHandle,
5199    )> {
5200        if let FileBackedVolumeProviderRequest::Open {
5201            parent_directory_token,
5202            name,
5203            server_end,
5204            control_handle,
5205        } = self
5206        {
5207            Some((parent_directory_token, name, server_end, control_handle))
5208        } else {
5209            None
5210        }
5211    }
5212
5213    /// Name of the method defined in FIDL
5214    pub fn method_name(&self) -> &'static str {
5215        match *self {
5216            FileBackedVolumeProviderRequest::Open { .. } => "open",
5217        }
5218    }
5219}
5220
5221#[derive(Debug, Clone)]
5222pub struct FileBackedVolumeProviderControlHandle {
5223    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5224}
5225
5226impl FileBackedVolumeProviderControlHandle {
5227    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5228        self.inner.shutdown_with_epitaph(status.into())
5229    }
5230}
5231
5232impl fidl::endpoints::ControlHandle for FileBackedVolumeProviderControlHandle {
5233    fn shutdown(&self) {
5234        self.inner.shutdown()
5235    }
5236
5237    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5238        self.inner.shutdown_with_epitaph(status)
5239    }
5240
5241    fn is_closed(&self) -> bool {
5242        self.inner.channel().is_closed()
5243    }
5244    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5245        self.inner.channel().on_closed()
5246    }
5247
5248    #[cfg(target_os = "fuchsia")]
5249    fn signal_peer(
5250        &self,
5251        clear_mask: zx::Signals,
5252        set_mask: zx::Signals,
5253    ) -> Result<(), zx_status::Status> {
5254        use fidl::Peered;
5255        self.inner.channel().signal_peer(clear_mask, set_mask)
5256    }
5257}
5258
5259impl FileBackedVolumeProviderControlHandle {}
5260
5261#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5262pub struct ProjectIdMarker;
5263
5264impl fidl::endpoints::ProtocolMarker for ProjectIdMarker {
5265    type Proxy = ProjectIdProxy;
5266    type RequestStream = ProjectIdRequestStream;
5267    #[cfg(target_os = "fuchsia")]
5268    type SynchronousProxy = ProjectIdSynchronousProxy;
5269
5270    const DEBUG_NAME: &'static str = "fuchsia.fxfs.ProjectId";
5271}
5272impl fidl::endpoints::DiscoverableProtocolMarker for ProjectIdMarker {}
5273pub type ProjectIdSetLimitResult = Result<(), i32>;
5274pub type ProjectIdClearResult = Result<(), i32>;
5275pub type ProjectIdSetForNodeResult = Result<(), i32>;
5276pub type ProjectIdGetForNodeResult = Result<u64, i32>;
5277pub type ProjectIdClearForNodeResult = Result<(), i32>;
5278pub type ProjectIdListResult = Result<(Vec<u64>, Option<Box<ProjectIterToken>>), i32>;
5279pub type ProjectIdInfoResult = Result<(BytesAndNodes, BytesAndNodes), i32>;
5280
5281pub trait ProjectIdProxyInterface: Send + Sync {
5282    type SetLimitResponseFut: std::future::Future<Output = Result<ProjectIdSetLimitResult, fidl::Error>>
5283        + Send;
5284    fn r#set_limit(&self, project_id: u64, bytes: u64, nodes: u64) -> Self::SetLimitResponseFut;
5285    type ClearResponseFut: std::future::Future<Output = Result<ProjectIdClearResult, fidl::Error>>
5286        + Send;
5287    fn r#clear(&self, project_id: u64) -> Self::ClearResponseFut;
5288    type SetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdSetForNodeResult, fidl::Error>>
5289        + Send;
5290    fn r#set_for_node(&self, node_id: u64, project_id: u64) -> Self::SetForNodeResponseFut;
5291    type GetForNodeResponseFut: std::future::Future<Output = Result<ProjectIdGetForNodeResult, fidl::Error>>
5292        + Send;
5293    fn r#get_for_node(&self, node_id: u64) -> Self::GetForNodeResponseFut;
5294    type ClearForNodeResponseFut: std::future::Future<Output = Result<ProjectIdClearForNodeResult, fidl::Error>>
5295        + Send;
5296    fn r#clear_for_node(&self, node_id: u64) -> Self::ClearForNodeResponseFut;
5297    type ListResponseFut: std::future::Future<Output = Result<ProjectIdListResult, fidl::Error>>
5298        + Send;
5299    fn r#list(&self, token: Option<&ProjectIterToken>) -> Self::ListResponseFut;
5300    type InfoResponseFut: std::future::Future<Output = Result<ProjectIdInfoResult, fidl::Error>>
5301        + Send;
5302    fn r#info(&self, project_id: u64) -> Self::InfoResponseFut;
5303}
5304#[derive(Debug)]
5305#[cfg(target_os = "fuchsia")]
5306pub struct ProjectIdSynchronousProxy {
5307    client: fidl::client::sync::Client,
5308}
5309
5310#[cfg(target_os = "fuchsia")]
5311impl fidl::endpoints::SynchronousProxy for ProjectIdSynchronousProxy {
5312    type Proxy = ProjectIdProxy;
5313    type Protocol = ProjectIdMarker;
5314
5315    fn from_channel(inner: fidl::Channel) -> Self {
5316        Self::new(inner)
5317    }
5318
5319    fn into_channel(self) -> fidl::Channel {
5320        self.client.into_channel()
5321    }
5322
5323    fn as_channel(&self) -> &fidl::Channel {
5324        self.client.as_channel()
5325    }
5326}
5327
5328#[cfg(target_os = "fuchsia")]
5329impl ProjectIdSynchronousProxy {
5330    pub fn new(channel: fidl::Channel) -> Self {
5331        Self { client: fidl::client::sync::Client::new(channel) }
5332    }
5333
5334    pub fn into_channel(self) -> fidl::Channel {
5335        self.client.into_channel()
5336    }
5337
5338    /// Waits until an event arrives and returns it. It is safe for other
5339    /// threads to make concurrent requests while waiting for an event.
5340    pub fn wait_for_event(
5341        &self,
5342        deadline: zx::MonotonicInstant,
5343    ) -> Result<ProjectIdEvent, fidl::Error> {
5344        ProjectIdEvent::decode(self.client.wait_for_event::<ProjectIdMarker>(deadline)?)
5345    }
5346
5347    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
5348    /// current usage is accepted but may in the future prevent further increases. Returns
5349    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5350    pub fn r#set_limit(
5351        &self,
5352        mut project_id: u64,
5353        mut bytes: u64,
5354        mut nodes: u64,
5355        ___deadline: zx::MonotonicInstant,
5356    ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
5357        let _response = self.client.send_query::<
5358            ProjectIdSetLimitRequest,
5359            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5360            ProjectIdMarker,
5361        >(
5362            (project_id, bytes, nodes,),
5363            0x20b0fc1e0413876f,
5364            fidl::encoding::DynamicFlags::empty(),
5365            ___deadline,
5366        )?;
5367        Ok(_response.map(|x| x))
5368    }
5369
5370    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
5371    /// currently tracked. It will succeed even if the project is still in use more by one or more
5372    /// nodes.
5373    pub fn r#clear(
5374        &self,
5375        mut project_id: u64,
5376        ___deadline: zx::MonotonicInstant,
5377    ) -> Result<ProjectIdClearResult, fidl::Error> {
5378        let _response = self.client.send_query::<
5379            ProjectIdClearRequest,
5380            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5381            ProjectIdMarker,
5382        >(
5383            (project_id,),
5384            0x165b5f1e707863c1,
5385            fidl::encoding::DynamicFlags::empty(),
5386            ___deadline,
5387        )?;
5388        Ok(_response.map(|x| x))
5389    }
5390
5391    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
5392    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5393    pub fn r#set_for_node(
5394        &self,
5395        mut node_id: u64,
5396        mut project_id: u64,
5397        ___deadline: zx::MonotonicInstant,
5398    ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
5399        let _response = self.client.send_query::<
5400            ProjectIdSetForNodeRequest,
5401            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5402            ProjectIdMarker,
5403        >(
5404            (node_id, project_id,),
5405            0x4d7a8442dc58324c,
5406            fidl::encoding::DynamicFlags::empty(),
5407            ___deadline,
5408        )?;
5409        Ok(_response.map(|x| x))
5410    }
5411
5412    /// Get the project id based on a given node_id from a GetAttrs call.This will return
5413    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
5414    /// currently applied.
5415    pub fn r#get_for_node(
5416        &self,
5417        mut node_id: u64,
5418        ___deadline: zx::MonotonicInstant,
5419    ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
5420        let _response = self.client.send_query::<
5421            ProjectIdGetForNodeRequest,
5422            fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
5423            ProjectIdMarker,
5424        >(
5425            (node_id,),
5426            0x644073bdf2542573,
5427            fidl::encoding::DynamicFlags::empty(),
5428            ___deadline,
5429        )?;
5430        Ok(_response.map(|x| x.project_id))
5431    }
5432
5433    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
5434    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
5435    /// have no project id applied to it.
5436    pub fn r#clear_for_node(
5437        &self,
5438        mut node_id: u64,
5439        ___deadline: zx::MonotonicInstant,
5440    ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
5441        let _response = self.client.send_query::<
5442            ProjectIdClearForNodeRequest,
5443            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5444            ProjectIdMarker,
5445        >(
5446            (node_id,),
5447            0x3f2ca287bbfe6a62,
5448            fidl::encoding::DynamicFlags::empty(),
5449            ___deadline,
5450        )?;
5451        Ok(_response.map(|x| x))
5452    }
5453
5454    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
5455    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
5456    /// previously provided `next_token` the iteration continues where it left off. If there are
5457    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
5458    pub fn r#list(
5459        &self,
5460        mut token: Option<&ProjectIterToken>,
5461        ___deadline: zx::MonotonicInstant,
5462    ) -> Result<ProjectIdListResult, fidl::Error> {
5463        let _response = self.client.send_query::<
5464            ProjectIdListRequest,
5465            fidl::encoding::ResultType<ProjectIdListResponse, i32>,
5466            ProjectIdMarker,
5467        >(
5468            (token,),
5469            0x5505f95a36d522cc,
5470            fidl::encoding::DynamicFlags::empty(),
5471            ___deadline,
5472        )?;
5473        Ok(_response.map(|x| (x.entries, x.next_token)))
5474    }
5475
5476    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
5477    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
5478    pub fn r#info(
5479        &self,
5480        mut project_id: u64,
5481        ___deadline: zx::MonotonicInstant,
5482    ) -> Result<ProjectIdInfoResult, fidl::Error> {
5483        let _response = self.client.send_query::<
5484            ProjectIdInfoRequest,
5485            fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
5486            ProjectIdMarker,
5487        >(
5488            (project_id,),
5489            0x51b47743c9e2d1ab,
5490            fidl::encoding::DynamicFlags::empty(),
5491            ___deadline,
5492        )?;
5493        Ok(_response.map(|x| (x.limit, x.usage)))
5494    }
5495}
5496
5497#[cfg(target_os = "fuchsia")]
5498impl From<ProjectIdSynchronousProxy> for zx::NullableHandle {
5499    fn from(value: ProjectIdSynchronousProxy) -> Self {
5500        value.into_channel().into()
5501    }
5502}
5503
5504#[cfg(target_os = "fuchsia")]
5505impl From<fidl::Channel> for ProjectIdSynchronousProxy {
5506    fn from(value: fidl::Channel) -> Self {
5507        Self::new(value)
5508    }
5509}
5510
5511#[cfg(target_os = "fuchsia")]
5512impl fidl::endpoints::FromClient for ProjectIdSynchronousProxy {
5513    type Protocol = ProjectIdMarker;
5514
5515    fn from_client(value: fidl::endpoints::ClientEnd<ProjectIdMarker>) -> Self {
5516        Self::new(value.into_channel())
5517    }
5518}
5519
5520#[derive(Debug, Clone)]
5521pub struct ProjectIdProxy {
5522    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5523}
5524
5525impl fidl::endpoints::Proxy for ProjectIdProxy {
5526    type Protocol = ProjectIdMarker;
5527
5528    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5529        Self::new(inner)
5530    }
5531
5532    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5533        self.client.into_channel().map_err(|client| Self { client })
5534    }
5535
5536    fn as_channel(&self) -> &::fidl::AsyncChannel {
5537        self.client.as_channel()
5538    }
5539}
5540
5541impl ProjectIdProxy {
5542    /// Create a new Proxy for fuchsia.fxfs/ProjectId.
5543    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5544        let protocol_name = <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5545        Self { client: fidl::client::Client::new(channel, protocol_name) }
5546    }
5547
5548    /// Get a Stream of events from the remote end of the protocol.
5549    ///
5550    /// # Panics
5551    ///
5552    /// Panics if the event stream was already taken.
5553    pub fn take_event_stream(&self) -> ProjectIdEventStream {
5554        ProjectIdEventStream { event_receiver: self.client.take_event_receiver() }
5555    }
5556
5557    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
5558    /// current usage is accepted but may in the future prevent further increases. Returns
5559    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5560    pub fn r#set_limit(
5561        &self,
5562        mut project_id: u64,
5563        mut bytes: u64,
5564        mut nodes: u64,
5565    ) -> fidl::client::QueryResponseFut<
5566        ProjectIdSetLimitResult,
5567        fidl::encoding::DefaultFuchsiaResourceDialect,
5568    > {
5569        ProjectIdProxyInterface::r#set_limit(self, project_id, bytes, nodes)
5570    }
5571
5572    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
5573    /// currently tracked. It will succeed even if the project is still in use more by one or more
5574    /// nodes.
5575    pub fn r#clear(
5576        &self,
5577        mut project_id: u64,
5578    ) -> fidl::client::QueryResponseFut<
5579        ProjectIdClearResult,
5580        fidl::encoding::DefaultFuchsiaResourceDialect,
5581    > {
5582        ProjectIdProxyInterface::r#clear(self, project_id)
5583    }
5584
5585    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
5586    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
5587    pub fn r#set_for_node(
5588        &self,
5589        mut node_id: u64,
5590        mut project_id: u64,
5591    ) -> fidl::client::QueryResponseFut<
5592        ProjectIdSetForNodeResult,
5593        fidl::encoding::DefaultFuchsiaResourceDialect,
5594    > {
5595        ProjectIdProxyInterface::r#set_for_node(self, node_id, project_id)
5596    }
5597
5598    /// Get the project id based on a given node_id from a GetAttrs call.This will return
5599    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
5600    /// currently applied.
5601    pub fn r#get_for_node(
5602        &self,
5603        mut node_id: u64,
5604    ) -> fidl::client::QueryResponseFut<
5605        ProjectIdGetForNodeResult,
5606        fidl::encoding::DefaultFuchsiaResourceDialect,
5607    > {
5608        ProjectIdProxyInterface::r#get_for_node(self, node_id)
5609    }
5610
5611    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
5612    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
5613    /// have no project id applied to it.
5614    pub fn r#clear_for_node(
5615        &self,
5616        mut node_id: u64,
5617    ) -> fidl::client::QueryResponseFut<
5618        ProjectIdClearForNodeResult,
5619        fidl::encoding::DefaultFuchsiaResourceDialect,
5620    > {
5621        ProjectIdProxyInterface::r#clear_for_node(self, node_id)
5622    }
5623
5624    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
5625    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
5626    /// previously provided `next_token` the iteration continues where it left off. If there are
5627    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
5628    pub fn r#list(
5629        &self,
5630        mut token: Option<&ProjectIterToken>,
5631    ) -> fidl::client::QueryResponseFut<
5632        ProjectIdListResult,
5633        fidl::encoding::DefaultFuchsiaResourceDialect,
5634    > {
5635        ProjectIdProxyInterface::r#list(self, token)
5636    }
5637
5638    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
5639    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
5640    pub fn r#info(
5641        &self,
5642        mut project_id: u64,
5643    ) -> fidl::client::QueryResponseFut<
5644        ProjectIdInfoResult,
5645        fidl::encoding::DefaultFuchsiaResourceDialect,
5646    > {
5647        ProjectIdProxyInterface::r#info(self, project_id)
5648    }
5649}
5650
5651impl ProjectIdProxyInterface for ProjectIdProxy {
5652    type SetLimitResponseFut = fidl::client::QueryResponseFut<
5653        ProjectIdSetLimitResult,
5654        fidl::encoding::DefaultFuchsiaResourceDialect,
5655    >;
5656    fn r#set_limit(
5657        &self,
5658        mut project_id: u64,
5659        mut bytes: u64,
5660        mut nodes: u64,
5661    ) -> Self::SetLimitResponseFut {
5662        fn _decode(
5663            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5664        ) -> Result<ProjectIdSetLimitResult, fidl::Error> {
5665            let _response = fidl::client::decode_transaction_body::<
5666                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5667                fidl::encoding::DefaultFuchsiaResourceDialect,
5668                0x20b0fc1e0413876f,
5669            >(_buf?)?;
5670            Ok(_response.map(|x| x))
5671        }
5672        self.client.send_query_and_decode::<ProjectIdSetLimitRequest, ProjectIdSetLimitResult>(
5673            (project_id, bytes, nodes),
5674            0x20b0fc1e0413876f,
5675            fidl::encoding::DynamicFlags::empty(),
5676            _decode,
5677        )
5678    }
5679
5680    type ClearResponseFut = fidl::client::QueryResponseFut<
5681        ProjectIdClearResult,
5682        fidl::encoding::DefaultFuchsiaResourceDialect,
5683    >;
5684    fn r#clear(&self, mut project_id: u64) -> Self::ClearResponseFut {
5685        fn _decode(
5686            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5687        ) -> Result<ProjectIdClearResult, fidl::Error> {
5688            let _response = fidl::client::decode_transaction_body::<
5689                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5690                fidl::encoding::DefaultFuchsiaResourceDialect,
5691                0x165b5f1e707863c1,
5692            >(_buf?)?;
5693            Ok(_response.map(|x| x))
5694        }
5695        self.client.send_query_and_decode::<ProjectIdClearRequest, ProjectIdClearResult>(
5696            (project_id,),
5697            0x165b5f1e707863c1,
5698            fidl::encoding::DynamicFlags::empty(),
5699            _decode,
5700        )
5701    }
5702
5703    type SetForNodeResponseFut = fidl::client::QueryResponseFut<
5704        ProjectIdSetForNodeResult,
5705        fidl::encoding::DefaultFuchsiaResourceDialect,
5706    >;
5707    fn r#set_for_node(&self, mut node_id: u64, mut project_id: u64) -> Self::SetForNodeResponseFut {
5708        fn _decode(
5709            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5710        ) -> Result<ProjectIdSetForNodeResult, fidl::Error> {
5711            let _response = fidl::client::decode_transaction_body::<
5712                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5713                fidl::encoding::DefaultFuchsiaResourceDialect,
5714                0x4d7a8442dc58324c,
5715            >(_buf?)?;
5716            Ok(_response.map(|x| x))
5717        }
5718        self.client.send_query_and_decode::<ProjectIdSetForNodeRequest, ProjectIdSetForNodeResult>(
5719            (node_id, project_id),
5720            0x4d7a8442dc58324c,
5721            fidl::encoding::DynamicFlags::empty(),
5722            _decode,
5723        )
5724    }
5725
5726    type GetForNodeResponseFut = fidl::client::QueryResponseFut<
5727        ProjectIdGetForNodeResult,
5728        fidl::encoding::DefaultFuchsiaResourceDialect,
5729    >;
5730    fn r#get_for_node(&self, mut node_id: u64) -> Self::GetForNodeResponseFut {
5731        fn _decode(
5732            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5733        ) -> Result<ProjectIdGetForNodeResult, fidl::Error> {
5734            let _response = fidl::client::decode_transaction_body::<
5735                fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>,
5736                fidl::encoding::DefaultFuchsiaResourceDialect,
5737                0x644073bdf2542573,
5738            >(_buf?)?;
5739            Ok(_response.map(|x| x.project_id))
5740        }
5741        self.client.send_query_and_decode::<ProjectIdGetForNodeRequest, ProjectIdGetForNodeResult>(
5742            (node_id,),
5743            0x644073bdf2542573,
5744            fidl::encoding::DynamicFlags::empty(),
5745            _decode,
5746        )
5747    }
5748
5749    type ClearForNodeResponseFut = fidl::client::QueryResponseFut<
5750        ProjectIdClearForNodeResult,
5751        fidl::encoding::DefaultFuchsiaResourceDialect,
5752    >;
5753    fn r#clear_for_node(&self, mut node_id: u64) -> Self::ClearForNodeResponseFut {
5754        fn _decode(
5755            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5756        ) -> Result<ProjectIdClearForNodeResult, fidl::Error> {
5757            let _response = fidl::client::decode_transaction_body::<
5758                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5759                fidl::encoding::DefaultFuchsiaResourceDialect,
5760                0x3f2ca287bbfe6a62,
5761            >(_buf?)?;
5762            Ok(_response.map(|x| x))
5763        }
5764        self.client
5765            .send_query_and_decode::<ProjectIdClearForNodeRequest, ProjectIdClearForNodeResult>(
5766                (node_id,),
5767                0x3f2ca287bbfe6a62,
5768                fidl::encoding::DynamicFlags::empty(),
5769                _decode,
5770            )
5771    }
5772
5773    type ListResponseFut = fidl::client::QueryResponseFut<
5774        ProjectIdListResult,
5775        fidl::encoding::DefaultFuchsiaResourceDialect,
5776    >;
5777    fn r#list(&self, mut token: Option<&ProjectIterToken>) -> Self::ListResponseFut {
5778        fn _decode(
5779            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5780        ) -> Result<ProjectIdListResult, fidl::Error> {
5781            let _response = fidl::client::decode_transaction_body::<
5782                fidl::encoding::ResultType<ProjectIdListResponse, i32>,
5783                fidl::encoding::DefaultFuchsiaResourceDialect,
5784                0x5505f95a36d522cc,
5785            >(_buf?)?;
5786            Ok(_response.map(|x| (x.entries, x.next_token)))
5787        }
5788        self.client.send_query_and_decode::<ProjectIdListRequest, ProjectIdListResult>(
5789            (token,),
5790            0x5505f95a36d522cc,
5791            fidl::encoding::DynamicFlags::empty(),
5792            _decode,
5793        )
5794    }
5795
5796    type InfoResponseFut = fidl::client::QueryResponseFut<
5797        ProjectIdInfoResult,
5798        fidl::encoding::DefaultFuchsiaResourceDialect,
5799    >;
5800    fn r#info(&self, mut project_id: u64) -> Self::InfoResponseFut {
5801        fn _decode(
5802            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5803        ) -> Result<ProjectIdInfoResult, fidl::Error> {
5804            let _response = fidl::client::decode_transaction_body::<
5805                fidl::encoding::ResultType<ProjectIdInfoResponse, i32>,
5806                fidl::encoding::DefaultFuchsiaResourceDialect,
5807                0x51b47743c9e2d1ab,
5808            >(_buf?)?;
5809            Ok(_response.map(|x| (x.limit, x.usage)))
5810        }
5811        self.client.send_query_and_decode::<ProjectIdInfoRequest, ProjectIdInfoResult>(
5812            (project_id,),
5813            0x51b47743c9e2d1ab,
5814            fidl::encoding::DynamicFlags::empty(),
5815            _decode,
5816        )
5817    }
5818}
5819
5820pub struct ProjectIdEventStream {
5821    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5822}
5823
5824impl std::marker::Unpin for ProjectIdEventStream {}
5825
5826impl futures::stream::FusedStream for ProjectIdEventStream {
5827    fn is_terminated(&self) -> bool {
5828        self.event_receiver.is_terminated()
5829    }
5830}
5831
5832impl futures::Stream for ProjectIdEventStream {
5833    type Item = Result<ProjectIdEvent, fidl::Error>;
5834
5835    fn poll_next(
5836        mut self: std::pin::Pin<&mut Self>,
5837        cx: &mut std::task::Context<'_>,
5838    ) -> std::task::Poll<Option<Self::Item>> {
5839        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5840            &mut self.event_receiver,
5841            cx
5842        )?) {
5843            Some(buf) => std::task::Poll::Ready(Some(ProjectIdEvent::decode(buf))),
5844            None => std::task::Poll::Ready(None),
5845        }
5846    }
5847}
5848
5849#[derive(Debug)]
5850pub enum ProjectIdEvent {}
5851
5852impl ProjectIdEvent {
5853    /// Decodes a message buffer as a [`ProjectIdEvent`].
5854    fn decode(
5855        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5856    ) -> Result<ProjectIdEvent, fidl::Error> {
5857        let (bytes, _handles) = buf.split_mut();
5858        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5859        debug_assert_eq!(tx_header.tx_id, 0);
5860        match tx_header.ordinal {
5861            _ => Err(fidl::Error::UnknownOrdinal {
5862                ordinal: tx_header.ordinal,
5863                protocol_name: <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5864            }),
5865        }
5866    }
5867}
5868
5869/// A Stream of incoming requests for fuchsia.fxfs/ProjectId.
5870pub struct ProjectIdRequestStream {
5871    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5872    is_terminated: bool,
5873}
5874
5875impl std::marker::Unpin for ProjectIdRequestStream {}
5876
5877impl futures::stream::FusedStream for ProjectIdRequestStream {
5878    fn is_terminated(&self) -> bool {
5879        self.is_terminated
5880    }
5881}
5882
5883impl fidl::endpoints::RequestStream for ProjectIdRequestStream {
5884    type Protocol = ProjectIdMarker;
5885    type ControlHandle = ProjectIdControlHandle;
5886
5887    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5888        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5889    }
5890
5891    fn control_handle(&self) -> Self::ControlHandle {
5892        ProjectIdControlHandle { inner: self.inner.clone() }
5893    }
5894
5895    fn into_inner(
5896        self,
5897    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5898    {
5899        (self.inner, self.is_terminated)
5900    }
5901
5902    fn from_inner(
5903        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5904        is_terminated: bool,
5905    ) -> Self {
5906        Self { inner, is_terminated }
5907    }
5908}
5909
5910impl futures::Stream for ProjectIdRequestStream {
5911    type Item = Result<ProjectIdRequest, fidl::Error>;
5912
5913    fn poll_next(
5914        mut self: std::pin::Pin<&mut Self>,
5915        cx: &mut std::task::Context<'_>,
5916    ) -> std::task::Poll<Option<Self::Item>> {
5917        let this = &mut *self;
5918        if this.inner.check_shutdown(cx) {
5919            this.is_terminated = true;
5920            return std::task::Poll::Ready(None);
5921        }
5922        if this.is_terminated {
5923            panic!("polled ProjectIdRequestStream after completion");
5924        }
5925        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5926            |bytes, handles| {
5927                match this.inner.channel().read_etc(cx, bytes, handles) {
5928                    std::task::Poll::Ready(Ok(())) => {}
5929                    std::task::Poll::Pending => return std::task::Poll::Pending,
5930                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5931                        this.is_terminated = true;
5932                        return std::task::Poll::Ready(None);
5933                    }
5934                    std::task::Poll::Ready(Err(e)) => {
5935                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5936                            e.into(),
5937                        ))));
5938                    }
5939                }
5940
5941                // A message has been received from the channel
5942                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5943
5944                std::task::Poll::Ready(Some(match header.ordinal {
5945                    0x20b0fc1e0413876f => {
5946                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5947                        let mut req = fidl::new_empty!(
5948                            ProjectIdSetLimitRequest,
5949                            fidl::encoding::DefaultFuchsiaResourceDialect
5950                        );
5951                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdSetLimitRequest>(&header, _body_bytes, handles, &mut req)?;
5952                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5953                        Ok(ProjectIdRequest::SetLimit {
5954                            project_id: req.project_id,
5955                            bytes: req.bytes,
5956                            nodes: req.nodes,
5957
5958                            responder: ProjectIdSetLimitResponder {
5959                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5960                                tx_id: header.tx_id,
5961                            },
5962                        })
5963                    }
5964                    0x165b5f1e707863c1 => {
5965                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5966                        let mut req = fidl::new_empty!(
5967                            ProjectIdClearRequest,
5968                            fidl::encoding::DefaultFuchsiaResourceDialect
5969                        );
5970                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdClearRequest>(&header, _body_bytes, handles, &mut req)?;
5971                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5972                        Ok(ProjectIdRequest::Clear {
5973                            project_id: req.project_id,
5974
5975                            responder: ProjectIdClearResponder {
5976                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5977                                tx_id: header.tx_id,
5978                            },
5979                        })
5980                    }
5981                    0x4d7a8442dc58324c => {
5982                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5983                        let mut req = fidl::new_empty!(
5984                            ProjectIdSetForNodeRequest,
5985                            fidl::encoding::DefaultFuchsiaResourceDialect
5986                        );
5987                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdSetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
5988                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
5989                        Ok(ProjectIdRequest::SetForNode {
5990                            node_id: req.node_id,
5991                            project_id: req.project_id,
5992
5993                            responder: ProjectIdSetForNodeResponder {
5994                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5995                                tx_id: header.tx_id,
5996                            },
5997                        })
5998                    }
5999                    0x644073bdf2542573 => {
6000                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6001                        let mut req = fidl::new_empty!(
6002                            ProjectIdGetForNodeRequest,
6003                            fidl::encoding::DefaultFuchsiaResourceDialect
6004                        );
6005                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdGetForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
6006                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
6007                        Ok(ProjectIdRequest::GetForNode {
6008                            node_id: req.node_id,
6009
6010                            responder: ProjectIdGetForNodeResponder {
6011                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6012                                tx_id: header.tx_id,
6013                            },
6014                        })
6015                    }
6016                    0x3f2ca287bbfe6a62 => {
6017                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6018                        let mut req = fidl::new_empty!(
6019                            ProjectIdClearForNodeRequest,
6020                            fidl::encoding::DefaultFuchsiaResourceDialect
6021                        );
6022                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdClearForNodeRequest>(&header, _body_bytes, handles, &mut req)?;
6023                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
6024                        Ok(ProjectIdRequest::ClearForNode {
6025                            node_id: req.node_id,
6026
6027                            responder: ProjectIdClearForNodeResponder {
6028                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6029                                tx_id: header.tx_id,
6030                            },
6031                        })
6032                    }
6033                    0x5505f95a36d522cc => {
6034                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6035                        let mut req = fidl::new_empty!(
6036                            ProjectIdListRequest,
6037                            fidl::encoding::DefaultFuchsiaResourceDialect
6038                        );
6039                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdListRequest>(&header, _body_bytes, handles, &mut req)?;
6040                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
6041                        Ok(ProjectIdRequest::List {
6042                            token: req.token,
6043
6044                            responder: ProjectIdListResponder {
6045                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6046                                tx_id: header.tx_id,
6047                            },
6048                        })
6049                    }
6050                    0x51b47743c9e2d1ab => {
6051                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6052                        let mut req = fidl::new_empty!(
6053                            ProjectIdInfoRequest,
6054                            fidl::encoding::DefaultFuchsiaResourceDialect
6055                        );
6056                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProjectIdInfoRequest>(&header, _body_bytes, handles, &mut req)?;
6057                        let control_handle = ProjectIdControlHandle { inner: this.inner.clone() };
6058                        Ok(ProjectIdRequest::Info {
6059                            project_id: req.project_id,
6060
6061                            responder: ProjectIdInfoResponder {
6062                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6063                                tx_id: header.tx_id,
6064                            },
6065                        })
6066                    }
6067                    _ => Err(fidl::Error::UnknownOrdinal {
6068                        ordinal: header.ordinal,
6069                        protocol_name:
6070                            <ProjectIdMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6071                    }),
6072                }))
6073            },
6074        )
6075    }
6076}
6077
6078#[derive(Debug)]
6079pub enum ProjectIdRequest {
6080    /// Set the limit in bytes and node count for an XFS project id. Setting limits lower than
6081    /// current usage is accepted but may in the future prevent further increases. Returns
6082    ///  ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
6083    SetLimit { project_id: u64, bytes: u64, nodes: u64, responder: ProjectIdSetLimitResponder },
6084    /// Stop tracking a project id. This will return  ZX_ERR_NOT_FOUND if the project isn't
6085    /// currently tracked. It will succeed even if the project is still in use more by one or more
6086    /// nodes.
6087    Clear { project_id: u64, responder: ProjectIdClearResponder },
6088    /// Apply project id to a node_id from a GetAttrs call. This will return ZX_ERR_NOT_FOUND if
6089    /// node doesn't exist, and ZX_ERR_OUT_OF_RANGE if `project_id` is set to zero.
6090    SetForNode { node_id: u64, project_id: u64, responder: ProjectIdSetForNodeResponder },
6091    /// Get the project id based on a given node_id from a GetAttrs call.This will return
6092    /// ZX_ERR_NOT_FOUND if the node doesn't exist, and a `project_id` of zero if one is not
6093    /// currently applied.
6094    GetForNode { node_id: u64, responder: ProjectIdGetForNodeResponder },
6095    /// Remove any project id marker for a given node_id from a GetAttrs call. This will return
6096    /// ZX_ERR_NOT_FOUND if the node doesn't exist, or success if the node is found to currently
6097    /// have no project id applied to it.
6098    ClearForNode { node_id: u64, responder: ProjectIdClearForNodeResponder },
6099    /// Fetches project id numbers currently tracked with a limit or with non-zero usage from lowest
6100    /// to highest. If `token` is null, start at the beginning, if `token` is populated with a
6101    /// previously provided `next_token` the iteration continues where it left off. If there are
6102    /// more projects to be listed then `next_token` will be populated, otherwise it will be null.
6103    List { token: Option<Box<ProjectIterToken>>, responder: ProjectIdListResponder },
6104    /// Looks up the limit and usage for a tracked `project_id`. If the `project_id` does not have
6105    /// a limit set, or non-zero usage it will return ZX_ERR_NOT_FOUND.
6106    Info { project_id: u64, responder: ProjectIdInfoResponder },
6107}
6108
6109impl ProjectIdRequest {
6110    #[allow(irrefutable_let_patterns)]
6111    pub fn into_set_limit(self) -> Option<(u64, u64, u64, ProjectIdSetLimitResponder)> {
6112        if let ProjectIdRequest::SetLimit { project_id, bytes, nodes, responder } = self {
6113            Some((project_id, bytes, nodes, responder))
6114        } else {
6115            None
6116        }
6117    }
6118
6119    #[allow(irrefutable_let_patterns)]
6120    pub fn into_clear(self) -> Option<(u64, ProjectIdClearResponder)> {
6121        if let ProjectIdRequest::Clear { project_id, responder } = self {
6122            Some((project_id, responder))
6123        } else {
6124            None
6125        }
6126    }
6127
6128    #[allow(irrefutable_let_patterns)]
6129    pub fn into_set_for_node(self) -> Option<(u64, u64, ProjectIdSetForNodeResponder)> {
6130        if let ProjectIdRequest::SetForNode { node_id, project_id, responder } = self {
6131            Some((node_id, project_id, responder))
6132        } else {
6133            None
6134        }
6135    }
6136
6137    #[allow(irrefutable_let_patterns)]
6138    pub fn into_get_for_node(self) -> Option<(u64, ProjectIdGetForNodeResponder)> {
6139        if let ProjectIdRequest::GetForNode { node_id, responder } = self {
6140            Some((node_id, responder))
6141        } else {
6142            None
6143        }
6144    }
6145
6146    #[allow(irrefutable_let_patterns)]
6147    pub fn into_clear_for_node(self) -> Option<(u64, ProjectIdClearForNodeResponder)> {
6148        if let ProjectIdRequest::ClearForNode { node_id, responder } = self {
6149            Some((node_id, responder))
6150        } else {
6151            None
6152        }
6153    }
6154
6155    #[allow(irrefutable_let_patterns)]
6156    pub fn into_list(self) -> Option<(Option<Box<ProjectIterToken>>, ProjectIdListResponder)> {
6157        if let ProjectIdRequest::List { token, responder } = self {
6158            Some((token, responder))
6159        } else {
6160            None
6161        }
6162    }
6163
6164    #[allow(irrefutable_let_patterns)]
6165    pub fn into_info(self) -> Option<(u64, ProjectIdInfoResponder)> {
6166        if let ProjectIdRequest::Info { project_id, responder } = self {
6167            Some((project_id, responder))
6168        } else {
6169            None
6170        }
6171    }
6172
6173    /// Name of the method defined in FIDL
6174    pub fn method_name(&self) -> &'static str {
6175        match *self {
6176            ProjectIdRequest::SetLimit { .. } => "set_limit",
6177            ProjectIdRequest::Clear { .. } => "clear",
6178            ProjectIdRequest::SetForNode { .. } => "set_for_node",
6179            ProjectIdRequest::GetForNode { .. } => "get_for_node",
6180            ProjectIdRequest::ClearForNode { .. } => "clear_for_node",
6181            ProjectIdRequest::List { .. } => "list",
6182            ProjectIdRequest::Info { .. } => "info",
6183        }
6184    }
6185}
6186
6187#[derive(Debug, Clone)]
6188pub struct ProjectIdControlHandle {
6189    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6190}
6191
6192impl ProjectIdControlHandle {
6193    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6194        self.inner.shutdown_with_epitaph(status.into())
6195    }
6196}
6197
6198impl fidl::endpoints::ControlHandle for ProjectIdControlHandle {
6199    fn shutdown(&self) {
6200        self.inner.shutdown()
6201    }
6202
6203    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6204        self.inner.shutdown_with_epitaph(status)
6205    }
6206
6207    fn is_closed(&self) -> bool {
6208        self.inner.channel().is_closed()
6209    }
6210    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6211        self.inner.channel().on_closed()
6212    }
6213
6214    #[cfg(target_os = "fuchsia")]
6215    fn signal_peer(
6216        &self,
6217        clear_mask: zx::Signals,
6218        set_mask: zx::Signals,
6219    ) -> Result<(), zx_status::Status> {
6220        use fidl::Peered;
6221        self.inner.channel().signal_peer(clear_mask, set_mask)
6222    }
6223}
6224
6225impl ProjectIdControlHandle {}
6226
6227#[must_use = "FIDL methods require a response to be sent"]
6228#[derive(Debug)]
6229pub struct ProjectIdSetLimitResponder {
6230    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6231    tx_id: u32,
6232}
6233
6234/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6235/// if the responder is dropped without sending a response, so that the client
6236/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6237impl std::ops::Drop for ProjectIdSetLimitResponder {
6238    fn drop(&mut self) {
6239        self.control_handle.shutdown();
6240        // Safety: drops once, never accessed again
6241        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6242    }
6243}
6244
6245impl fidl::endpoints::Responder for ProjectIdSetLimitResponder {
6246    type ControlHandle = ProjectIdControlHandle;
6247
6248    fn control_handle(&self) -> &ProjectIdControlHandle {
6249        &self.control_handle
6250    }
6251
6252    fn drop_without_shutdown(mut self) {
6253        // Safety: drops once, never accessed again due to mem::forget
6254        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6255        // Prevent Drop from running (which would shut down the channel)
6256        std::mem::forget(self);
6257    }
6258}
6259
6260impl ProjectIdSetLimitResponder {
6261    /// Sends a response to the FIDL transaction.
6262    ///
6263    /// Sets the channel to shutdown if an error occurs.
6264    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6265        let _result = self.send_raw(result);
6266        if _result.is_err() {
6267            self.control_handle.shutdown();
6268        }
6269        self.drop_without_shutdown();
6270        _result
6271    }
6272
6273    /// Similar to "send" but does not shutdown the channel if an error occurs.
6274    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6275        let _result = self.send_raw(result);
6276        self.drop_without_shutdown();
6277        _result
6278    }
6279
6280    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6281        self.control_handle
6282            .inner
6283            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6284                result,
6285                self.tx_id,
6286                0x20b0fc1e0413876f,
6287                fidl::encoding::DynamicFlags::empty(),
6288            )
6289    }
6290}
6291
6292#[must_use = "FIDL methods require a response to be sent"]
6293#[derive(Debug)]
6294pub struct ProjectIdClearResponder {
6295    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6296    tx_id: u32,
6297}
6298
6299/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6300/// if the responder is dropped without sending a response, so that the client
6301/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6302impl std::ops::Drop for ProjectIdClearResponder {
6303    fn drop(&mut self) {
6304        self.control_handle.shutdown();
6305        // Safety: drops once, never accessed again
6306        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6307    }
6308}
6309
6310impl fidl::endpoints::Responder for ProjectIdClearResponder {
6311    type ControlHandle = ProjectIdControlHandle;
6312
6313    fn control_handle(&self) -> &ProjectIdControlHandle {
6314        &self.control_handle
6315    }
6316
6317    fn drop_without_shutdown(mut self) {
6318        // Safety: drops once, never accessed again due to mem::forget
6319        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6320        // Prevent Drop from running (which would shut down the channel)
6321        std::mem::forget(self);
6322    }
6323}
6324
6325impl ProjectIdClearResponder {
6326    /// Sends a response to the FIDL transaction.
6327    ///
6328    /// Sets the channel to shutdown if an error occurs.
6329    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6330        let _result = self.send_raw(result);
6331        if _result.is_err() {
6332            self.control_handle.shutdown();
6333        }
6334        self.drop_without_shutdown();
6335        _result
6336    }
6337
6338    /// Similar to "send" but does not shutdown the channel if an error occurs.
6339    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6340        let _result = self.send_raw(result);
6341        self.drop_without_shutdown();
6342        _result
6343    }
6344
6345    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6346        self.control_handle
6347            .inner
6348            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6349                result,
6350                self.tx_id,
6351                0x165b5f1e707863c1,
6352                fidl::encoding::DynamicFlags::empty(),
6353            )
6354    }
6355}
6356
6357#[must_use = "FIDL methods require a response to be sent"]
6358#[derive(Debug)]
6359pub struct ProjectIdSetForNodeResponder {
6360    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6361    tx_id: u32,
6362}
6363
6364/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6365/// if the responder is dropped without sending a response, so that the client
6366/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6367impl std::ops::Drop for ProjectIdSetForNodeResponder {
6368    fn drop(&mut self) {
6369        self.control_handle.shutdown();
6370        // Safety: drops once, never accessed again
6371        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6372    }
6373}
6374
6375impl fidl::endpoints::Responder for ProjectIdSetForNodeResponder {
6376    type ControlHandle = ProjectIdControlHandle;
6377
6378    fn control_handle(&self) -> &ProjectIdControlHandle {
6379        &self.control_handle
6380    }
6381
6382    fn drop_without_shutdown(mut self) {
6383        // Safety: drops once, never accessed again due to mem::forget
6384        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6385        // Prevent Drop from running (which would shut down the channel)
6386        std::mem::forget(self);
6387    }
6388}
6389
6390impl ProjectIdSetForNodeResponder {
6391    /// Sends a response to the FIDL transaction.
6392    ///
6393    /// Sets the channel to shutdown if an error occurs.
6394    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6395        let _result = self.send_raw(result);
6396        if _result.is_err() {
6397            self.control_handle.shutdown();
6398        }
6399        self.drop_without_shutdown();
6400        _result
6401    }
6402
6403    /// Similar to "send" but does not shutdown the channel if an error occurs.
6404    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6405        let _result = self.send_raw(result);
6406        self.drop_without_shutdown();
6407        _result
6408    }
6409
6410    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6411        self.control_handle
6412            .inner
6413            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6414                result,
6415                self.tx_id,
6416                0x4d7a8442dc58324c,
6417                fidl::encoding::DynamicFlags::empty(),
6418            )
6419    }
6420}
6421
6422#[must_use = "FIDL methods require a response to be sent"]
6423#[derive(Debug)]
6424pub struct ProjectIdGetForNodeResponder {
6425    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6426    tx_id: u32,
6427}
6428
6429/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6430/// if the responder is dropped without sending a response, so that the client
6431/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6432impl std::ops::Drop for ProjectIdGetForNodeResponder {
6433    fn drop(&mut self) {
6434        self.control_handle.shutdown();
6435        // Safety: drops once, never accessed again
6436        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6437    }
6438}
6439
6440impl fidl::endpoints::Responder for ProjectIdGetForNodeResponder {
6441    type ControlHandle = ProjectIdControlHandle;
6442
6443    fn control_handle(&self) -> &ProjectIdControlHandle {
6444        &self.control_handle
6445    }
6446
6447    fn drop_without_shutdown(mut self) {
6448        // Safety: drops once, never accessed again due to mem::forget
6449        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6450        // Prevent Drop from running (which would shut down the channel)
6451        std::mem::forget(self);
6452    }
6453}
6454
6455impl ProjectIdGetForNodeResponder {
6456    /// Sends a response to the FIDL transaction.
6457    ///
6458    /// Sets the channel to shutdown if an error occurs.
6459    pub fn send(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
6460        let _result = self.send_raw(result);
6461        if _result.is_err() {
6462            self.control_handle.shutdown();
6463        }
6464        self.drop_without_shutdown();
6465        _result
6466    }
6467
6468    /// Similar to "send" but does not shutdown the channel if an error occurs.
6469    pub fn send_no_shutdown_on_err(self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
6470        let _result = self.send_raw(result);
6471        self.drop_without_shutdown();
6472        _result
6473    }
6474
6475    fn send_raw(&self, mut result: Result<u64, i32>) -> Result<(), fidl::Error> {
6476        self.control_handle
6477            .inner
6478            .send::<fidl::encoding::ResultType<ProjectIdGetForNodeResponse, i32>>(
6479                result.map(|project_id| (project_id,)),
6480                self.tx_id,
6481                0x644073bdf2542573,
6482                fidl::encoding::DynamicFlags::empty(),
6483            )
6484    }
6485}
6486
6487#[must_use = "FIDL methods require a response to be sent"]
6488#[derive(Debug)]
6489pub struct ProjectIdClearForNodeResponder {
6490    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6491    tx_id: u32,
6492}
6493
6494/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6495/// if the responder is dropped without sending a response, so that the client
6496/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6497impl std::ops::Drop for ProjectIdClearForNodeResponder {
6498    fn drop(&mut self) {
6499        self.control_handle.shutdown();
6500        // Safety: drops once, never accessed again
6501        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6502    }
6503}
6504
6505impl fidl::endpoints::Responder for ProjectIdClearForNodeResponder {
6506    type ControlHandle = ProjectIdControlHandle;
6507
6508    fn control_handle(&self) -> &ProjectIdControlHandle {
6509        &self.control_handle
6510    }
6511
6512    fn drop_without_shutdown(mut self) {
6513        // Safety: drops once, never accessed again due to mem::forget
6514        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6515        // Prevent Drop from running (which would shut down the channel)
6516        std::mem::forget(self);
6517    }
6518}
6519
6520impl ProjectIdClearForNodeResponder {
6521    /// Sends a response to the FIDL transaction.
6522    ///
6523    /// Sets the channel to shutdown if an error occurs.
6524    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6525        let _result = self.send_raw(result);
6526        if _result.is_err() {
6527            self.control_handle.shutdown();
6528        }
6529        self.drop_without_shutdown();
6530        _result
6531    }
6532
6533    /// Similar to "send" but does not shutdown the channel if an error occurs.
6534    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6535        let _result = self.send_raw(result);
6536        self.drop_without_shutdown();
6537        _result
6538    }
6539
6540    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6541        self.control_handle
6542            .inner
6543            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6544                result,
6545                self.tx_id,
6546                0x3f2ca287bbfe6a62,
6547                fidl::encoding::DynamicFlags::empty(),
6548            )
6549    }
6550}
6551
6552#[must_use = "FIDL methods require a response to be sent"]
6553#[derive(Debug)]
6554pub struct ProjectIdListResponder {
6555    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6556    tx_id: u32,
6557}
6558
6559/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6560/// if the responder is dropped without sending a response, so that the client
6561/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6562impl std::ops::Drop for ProjectIdListResponder {
6563    fn drop(&mut self) {
6564        self.control_handle.shutdown();
6565        // Safety: drops once, never accessed again
6566        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6567    }
6568}
6569
6570impl fidl::endpoints::Responder for ProjectIdListResponder {
6571    type ControlHandle = ProjectIdControlHandle;
6572
6573    fn control_handle(&self) -> &ProjectIdControlHandle {
6574        &self.control_handle
6575    }
6576
6577    fn drop_without_shutdown(mut self) {
6578        // Safety: drops once, never accessed again due to mem::forget
6579        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6580        // Prevent Drop from running (which would shut down the channel)
6581        std::mem::forget(self);
6582    }
6583}
6584
6585impl ProjectIdListResponder {
6586    /// Sends a response to the FIDL transaction.
6587    ///
6588    /// Sets the channel to shutdown if an error occurs.
6589    pub fn send(
6590        self,
6591        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
6592    ) -> Result<(), fidl::Error> {
6593        let _result = self.send_raw(result);
6594        if _result.is_err() {
6595            self.control_handle.shutdown();
6596        }
6597        self.drop_without_shutdown();
6598        _result
6599    }
6600
6601    /// Similar to "send" but does not shutdown the channel if an error occurs.
6602    pub fn send_no_shutdown_on_err(
6603        self,
6604        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
6605    ) -> Result<(), fidl::Error> {
6606        let _result = self.send_raw(result);
6607        self.drop_without_shutdown();
6608        _result
6609    }
6610
6611    fn send_raw(
6612        &self,
6613        mut result: Result<(&[u64], Option<&ProjectIterToken>), i32>,
6614    ) -> Result<(), fidl::Error> {
6615        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdListResponse, i32>>(
6616            result,
6617            self.tx_id,
6618            0x5505f95a36d522cc,
6619            fidl::encoding::DynamicFlags::empty(),
6620        )
6621    }
6622}
6623
6624#[must_use = "FIDL methods require a response to be sent"]
6625#[derive(Debug)]
6626pub struct ProjectIdInfoResponder {
6627    control_handle: std::mem::ManuallyDrop<ProjectIdControlHandle>,
6628    tx_id: u32,
6629}
6630
6631/// Set the the channel to be shutdown (see [`ProjectIdControlHandle::shutdown`])
6632/// if the responder is dropped without sending a response, so that the client
6633/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6634impl std::ops::Drop for ProjectIdInfoResponder {
6635    fn drop(&mut self) {
6636        self.control_handle.shutdown();
6637        // Safety: drops once, never accessed again
6638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6639    }
6640}
6641
6642impl fidl::endpoints::Responder for ProjectIdInfoResponder {
6643    type ControlHandle = ProjectIdControlHandle;
6644
6645    fn control_handle(&self) -> &ProjectIdControlHandle {
6646        &self.control_handle
6647    }
6648
6649    fn drop_without_shutdown(mut self) {
6650        // Safety: drops once, never accessed again due to mem::forget
6651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6652        // Prevent Drop from running (which would shut down the channel)
6653        std::mem::forget(self);
6654    }
6655}
6656
6657impl ProjectIdInfoResponder {
6658    /// Sends a response to the FIDL transaction.
6659    ///
6660    /// Sets the channel to shutdown if an error occurs.
6661    pub fn send(
6662        self,
6663        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
6664    ) -> Result<(), fidl::Error> {
6665        let _result = self.send_raw(result);
6666        if _result.is_err() {
6667            self.control_handle.shutdown();
6668        }
6669        self.drop_without_shutdown();
6670        _result
6671    }
6672
6673    /// Similar to "send" but does not shutdown the channel if an error occurs.
6674    pub fn send_no_shutdown_on_err(
6675        self,
6676        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
6677    ) -> Result<(), fidl::Error> {
6678        let _result = self.send_raw(result);
6679        self.drop_without_shutdown();
6680        _result
6681    }
6682
6683    fn send_raw(
6684        &self,
6685        mut result: Result<(&BytesAndNodes, &BytesAndNodes), i32>,
6686    ) -> Result<(), fidl::Error> {
6687        self.control_handle.inner.send::<fidl::encoding::ResultType<ProjectIdInfoResponse, i32>>(
6688            result,
6689            self.tx_id,
6690            0x51b47743c9e2d1ab,
6691            fidl::encoding::DynamicFlags::empty(),
6692        )
6693    }
6694}
6695
6696#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6697pub struct VolumeInstallerMarker;
6698
6699impl fidl::endpoints::ProtocolMarker for VolumeInstallerMarker {
6700    type Proxy = VolumeInstallerProxy;
6701    type RequestStream = VolumeInstallerRequestStream;
6702    #[cfg(target_os = "fuchsia")]
6703    type SynchronousProxy = VolumeInstallerSynchronousProxy;
6704
6705    const DEBUG_NAME: &'static str = "fuchsia.fxfs.VolumeInstaller";
6706}
6707impl fidl::endpoints::DiscoverableProtocolMarker for VolumeInstallerMarker {}
6708pub type VolumeInstallerInstallResult = Result<(), i32>;
6709
6710pub trait VolumeInstallerProxyInterface: Send + Sync {
6711    type InstallResponseFut: std::future::Future<Output = Result<VolumeInstallerInstallResult, fidl::Error>>
6712        + Send;
6713    fn r#install(&self, src: &str, image_file: &str, dst: &str) -> Self::InstallResponseFut;
6714}
6715#[derive(Debug)]
6716#[cfg(target_os = "fuchsia")]
6717pub struct VolumeInstallerSynchronousProxy {
6718    client: fidl::client::sync::Client,
6719}
6720
6721#[cfg(target_os = "fuchsia")]
6722impl fidl::endpoints::SynchronousProxy for VolumeInstallerSynchronousProxy {
6723    type Proxy = VolumeInstallerProxy;
6724    type Protocol = VolumeInstallerMarker;
6725
6726    fn from_channel(inner: fidl::Channel) -> Self {
6727        Self::new(inner)
6728    }
6729
6730    fn into_channel(self) -> fidl::Channel {
6731        self.client.into_channel()
6732    }
6733
6734    fn as_channel(&self) -> &fidl::Channel {
6735        self.client.as_channel()
6736    }
6737}
6738
6739#[cfg(target_os = "fuchsia")]
6740impl VolumeInstallerSynchronousProxy {
6741    pub fn new(channel: fidl::Channel) -> Self {
6742        Self { client: fidl::client::sync::Client::new(channel) }
6743    }
6744
6745    pub fn into_channel(self) -> fidl::Channel {
6746        self.client.into_channel()
6747    }
6748
6749    /// Waits until an event arrives and returns it. It is safe for other
6750    /// threads to make concurrent requests while waiting for an event.
6751    pub fn wait_for_event(
6752        &self,
6753        deadline: zx::MonotonicInstant,
6754    ) -> Result<VolumeInstallerEvent, fidl::Error> {
6755        VolumeInstallerEvent::decode(self.client.wait_for_event::<VolumeInstallerMarker>(deadline)?)
6756    }
6757
6758    /// Using the partition image in `image_file` contained in the volume `src`, overwrites the
6759    /// volume `dst` with a volume of the same name from the image. On success, `src` will no longer
6760    /// exist. There must be no objects in `src` other than the image that contain extents.
6761    /// Neither `src` nor `dst` can be mounted or otherwise in-use.
6762    ///
6763    /// *WARNING*: This will delete the existing contents of `dst`.
6764    pub fn r#install(
6765        &self,
6766        mut src: &str,
6767        mut image_file: &str,
6768        mut dst: &str,
6769        ___deadline: zx::MonotonicInstant,
6770    ) -> Result<VolumeInstallerInstallResult, fidl::Error> {
6771        let _response = self.client.send_query::<
6772            VolumeInstallerInstallRequest,
6773            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6774            VolumeInstallerMarker,
6775        >(
6776            (src, image_file, dst,),
6777            0x4c340be8a504ee1c,
6778            fidl::encoding::DynamicFlags::empty(),
6779            ___deadline,
6780        )?;
6781        Ok(_response.map(|x| x))
6782    }
6783}
6784
6785#[cfg(target_os = "fuchsia")]
6786impl From<VolumeInstallerSynchronousProxy> for zx::NullableHandle {
6787    fn from(value: VolumeInstallerSynchronousProxy) -> Self {
6788        value.into_channel().into()
6789    }
6790}
6791
6792#[cfg(target_os = "fuchsia")]
6793impl From<fidl::Channel> for VolumeInstallerSynchronousProxy {
6794    fn from(value: fidl::Channel) -> Self {
6795        Self::new(value)
6796    }
6797}
6798
6799#[cfg(target_os = "fuchsia")]
6800impl fidl::endpoints::FromClient for VolumeInstallerSynchronousProxy {
6801    type Protocol = VolumeInstallerMarker;
6802
6803    fn from_client(value: fidl::endpoints::ClientEnd<VolumeInstallerMarker>) -> Self {
6804        Self::new(value.into_channel())
6805    }
6806}
6807
6808#[derive(Debug, Clone)]
6809pub struct VolumeInstallerProxy {
6810    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6811}
6812
6813impl fidl::endpoints::Proxy for VolumeInstallerProxy {
6814    type Protocol = VolumeInstallerMarker;
6815
6816    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6817        Self::new(inner)
6818    }
6819
6820    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6821        self.client.into_channel().map_err(|client| Self { client })
6822    }
6823
6824    fn as_channel(&self) -> &::fidl::AsyncChannel {
6825        self.client.as_channel()
6826    }
6827}
6828
6829impl VolumeInstallerProxy {
6830    /// Create a new Proxy for fuchsia.fxfs/VolumeInstaller.
6831    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6832        let protocol_name = <VolumeInstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6833        Self { client: fidl::client::Client::new(channel, protocol_name) }
6834    }
6835
6836    /// Get a Stream of events from the remote end of the protocol.
6837    ///
6838    /// # Panics
6839    ///
6840    /// Panics if the event stream was already taken.
6841    pub fn take_event_stream(&self) -> VolumeInstallerEventStream {
6842        VolumeInstallerEventStream { event_receiver: self.client.take_event_receiver() }
6843    }
6844
6845    /// Using the partition image in `image_file` contained in the volume `src`, overwrites the
6846    /// volume `dst` with a volume of the same name from the image. On success, `src` will no longer
6847    /// exist. There must be no objects in `src` other than the image that contain extents.
6848    /// Neither `src` nor `dst` can be mounted or otherwise in-use.
6849    ///
6850    /// *WARNING*: This will delete the existing contents of `dst`.
6851    pub fn r#install(
6852        &self,
6853        mut src: &str,
6854        mut image_file: &str,
6855        mut dst: &str,
6856    ) -> fidl::client::QueryResponseFut<
6857        VolumeInstallerInstallResult,
6858        fidl::encoding::DefaultFuchsiaResourceDialect,
6859    > {
6860        VolumeInstallerProxyInterface::r#install(self, src, image_file, dst)
6861    }
6862}
6863
6864impl VolumeInstallerProxyInterface for VolumeInstallerProxy {
6865    type InstallResponseFut = fidl::client::QueryResponseFut<
6866        VolumeInstallerInstallResult,
6867        fidl::encoding::DefaultFuchsiaResourceDialect,
6868    >;
6869    fn r#install(
6870        &self,
6871        mut src: &str,
6872        mut image_file: &str,
6873        mut dst: &str,
6874    ) -> Self::InstallResponseFut {
6875        fn _decode(
6876            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6877        ) -> Result<VolumeInstallerInstallResult, fidl::Error> {
6878            let _response = fidl::client::decode_transaction_body::<
6879                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
6880                fidl::encoding::DefaultFuchsiaResourceDialect,
6881                0x4c340be8a504ee1c,
6882            >(_buf?)?;
6883            Ok(_response.map(|x| x))
6884        }
6885        self.client
6886            .send_query_and_decode::<VolumeInstallerInstallRequest, VolumeInstallerInstallResult>(
6887                (src, image_file, dst),
6888                0x4c340be8a504ee1c,
6889                fidl::encoding::DynamicFlags::empty(),
6890                _decode,
6891            )
6892    }
6893}
6894
6895pub struct VolumeInstallerEventStream {
6896    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6897}
6898
6899impl std::marker::Unpin for VolumeInstallerEventStream {}
6900
6901impl futures::stream::FusedStream for VolumeInstallerEventStream {
6902    fn is_terminated(&self) -> bool {
6903        self.event_receiver.is_terminated()
6904    }
6905}
6906
6907impl futures::Stream for VolumeInstallerEventStream {
6908    type Item = Result<VolumeInstallerEvent, fidl::Error>;
6909
6910    fn poll_next(
6911        mut self: std::pin::Pin<&mut Self>,
6912        cx: &mut std::task::Context<'_>,
6913    ) -> std::task::Poll<Option<Self::Item>> {
6914        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6915            &mut self.event_receiver,
6916            cx
6917        )?) {
6918            Some(buf) => std::task::Poll::Ready(Some(VolumeInstallerEvent::decode(buf))),
6919            None => std::task::Poll::Ready(None),
6920        }
6921    }
6922}
6923
6924#[derive(Debug)]
6925pub enum VolumeInstallerEvent {}
6926
6927impl VolumeInstallerEvent {
6928    /// Decodes a message buffer as a [`VolumeInstallerEvent`].
6929    fn decode(
6930        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6931    ) -> Result<VolumeInstallerEvent, fidl::Error> {
6932        let (bytes, _handles) = buf.split_mut();
6933        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6934        debug_assert_eq!(tx_header.tx_id, 0);
6935        match tx_header.ordinal {
6936            _ => Err(fidl::Error::UnknownOrdinal {
6937                ordinal: tx_header.ordinal,
6938                protocol_name:
6939                    <VolumeInstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6940            }),
6941        }
6942    }
6943}
6944
6945/// A Stream of incoming requests for fuchsia.fxfs/VolumeInstaller.
6946pub struct VolumeInstallerRequestStream {
6947    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6948    is_terminated: bool,
6949}
6950
6951impl std::marker::Unpin for VolumeInstallerRequestStream {}
6952
6953impl futures::stream::FusedStream for VolumeInstallerRequestStream {
6954    fn is_terminated(&self) -> bool {
6955        self.is_terminated
6956    }
6957}
6958
6959impl fidl::endpoints::RequestStream for VolumeInstallerRequestStream {
6960    type Protocol = VolumeInstallerMarker;
6961    type ControlHandle = VolumeInstallerControlHandle;
6962
6963    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6964        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6965    }
6966
6967    fn control_handle(&self) -> Self::ControlHandle {
6968        VolumeInstallerControlHandle { inner: self.inner.clone() }
6969    }
6970
6971    fn into_inner(
6972        self,
6973    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6974    {
6975        (self.inner, self.is_terminated)
6976    }
6977
6978    fn from_inner(
6979        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6980        is_terminated: bool,
6981    ) -> Self {
6982        Self { inner, is_terminated }
6983    }
6984}
6985
6986impl futures::Stream for VolumeInstallerRequestStream {
6987    type Item = Result<VolumeInstallerRequest, fidl::Error>;
6988
6989    fn poll_next(
6990        mut self: std::pin::Pin<&mut Self>,
6991        cx: &mut std::task::Context<'_>,
6992    ) -> std::task::Poll<Option<Self::Item>> {
6993        let this = &mut *self;
6994        if this.inner.check_shutdown(cx) {
6995            this.is_terminated = true;
6996            return std::task::Poll::Ready(None);
6997        }
6998        if this.is_terminated {
6999            panic!("polled VolumeInstallerRequestStream after completion");
7000        }
7001        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7002            |bytes, handles| {
7003                match this.inner.channel().read_etc(cx, bytes, handles) {
7004                    std::task::Poll::Ready(Ok(())) => {}
7005                    std::task::Poll::Pending => return std::task::Poll::Pending,
7006                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7007                        this.is_terminated = true;
7008                        return std::task::Poll::Ready(None);
7009                    }
7010                    std::task::Poll::Ready(Err(e)) => {
7011                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7012                            e.into(),
7013                        ))));
7014                    }
7015                }
7016
7017                // A message has been received from the channel
7018                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7019
7020                std::task::Poll::Ready(Some(match header.ordinal {
7021                    0x4c340be8a504ee1c => {
7022                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7023                        let mut req = fidl::new_empty!(
7024                            VolumeInstallerInstallRequest,
7025                            fidl::encoding::DefaultFuchsiaResourceDialect
7026                        );
7027                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VolumeInstallerInstallRequest>(&header, _body_bytes, handles, &mut req)?;
7028                        let control_handle =
7029                            VolumeInstallerControlHandle { inner: this.inner.clone() };
7030                        Ok(VolumeInstallerRequest::Install {
7031                            src: req.src,
7032                            image_file: req.image_file,
7033                            dst: req.dst,
7034
7035                            responder: VolumeInstallerInstallResponder {
7036                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7037                                tx_id: header.tx_id,
7038                            },
7039                        })
7040                    }
7041                    _ => Err(fidl::Error::UnknownOrdinal {
7042                        ordinal: header.ordinal,
7043                        protocol_name:
7044                            <VolumeInstallerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7045                    }),
7046                }))
7047            },
7048        )
7049    }
7050}
7051
7052/// Allows installing a volume from an fxfs partition image.
7053#[derive(Debug)]
7054pub enum VolumeInstallerRequest {
7055    /// Using the partition image in `image_file` contained in the volume `src`, overwrites the
7056    /// volume `dst` with a volume of the same name from the image. On success, `src` will no longer
7057    /// exist. There must be no objects in `src` other than the image that contain extents.
7058    /// Neither `src` nor `dst` can be mounted or otherwise in-use.
7059    ///
7060    /// *WARNING*: This will delete the existing contents of `dst`.
7061    Install {
7062        src: String,
7063        image_file: String,
7064        dst: String,
7065        responder: VolumeInstallerInstallResponder,
7066    },
7067}
7068
7069impl VolumeInstallerRequest {
7070    #[allow(irrefutable_let_patterns)]
7071    pub fn into_install(self) -> Option<(String, String, String, VolumeInstallerInstallResponder)> {
7072        if let VolumeInstallerRequest::Install { src, image_file, dst, responder } = self {
7073            Some((src, image_file, dst, responder))
7074        } else {
7075            None
7076        }
7077    }
7078
7079    /// Name of the method defined in FIDL
7080    pub fn method_name(&self) -> &'static str {
7081        match *self {
7082            VolumeInstallerRequest::Install { .. } => "install",
7083        }
7084    }
7085}
7086
7087#[derive(Debug, Clone)]
7088pub struct VolumeInstallerControlHandle {
7089    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7090}
7091
7092impl VolumeInstallerControlHandle {
7093    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7094        self.inner.shutdown_with_epitaph(status.into())
7095    }
7096}
7097
7098impl fidl::endpoints::ControlHandle for VolumeInstallerControlHandle {
7099    fn shutdown(&self) {
7100        self.inner.shutdown()
7101    }
7102
7103    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7104        self.inner.shutdown_with_epitaph(status)
7105    }
7106
7107    fn is_closed(&self) -> bool {
7108        self.inner.channel().is_closed()
7109    }
7110    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7111        self.inner.channel().on_closed()
7112    }
7113
7114    #[cfg(target_os = "fuchsia")]
7115    fn signal_peer(
7116        &self,
7117        clear_mask: zx::Signals,
7118        set_mask: zx::Signals,
7119    ) -> Result<(), zx_status::Status> {
7120        use fidl::Peered;
7121        self.inner.channel().signal_peer(clear_mask, set_mask)
7122    }
7123}
7124
7125impl VolumeInstallerControlHandle {}
7126
7127#[must_use = "FIDL methods require a response to be sent"]
7128#[derive(Debug)]
7129pub struct VolumeInstallerInstallResponder {
7130    control_handle: std::mem::ManuallyDrop<VolumeInstallerControlHandle>,
7131    tx_id: u32,
7132}
7133
7134/// Set the the channel to be shutdown (see [`VolumeInstallerControlHandle::shutdown`])
7135/// if the responder is dropped without sending a response, so that the client
7136/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7137impl std::ops::Drop for VolumeInstallerInstallResponder {
7138    fn drop(&mut self) {
7139        self.control_handle.shutdown();
7140        // Safety: drops once, never accessed again
7141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7142    }
7143}
7144
7145impl fidl::endpoints::Responder for VolumeInstallerInstallResponder {
7146    type ControlHandle = VolumeInstallerControlHandle;
7147
7148    fn control_handle(&self) -> &VolumeInstallerControlHandle {
7149        &self.control_handle
7150    }
7151
7152    fn drop_without_shutdown(mut self) {
7153        // Safety: drops once, never accessed again due to mem::forget
7154        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7155        // Prevent Drop from running (which would shut down the channel)
7156        std::mem::forget(self);
7157    }
7158}
7159
7160impl VolumeInstallerInstallResponder {
7161    /// Sends a response to the FIDL transaction.
7162    ///
7163    /// Sets the channel to shutdown if an error occurs.
7164    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7165        let _result = self.send_raw(result);
7166        if _result.is_err() {
7167            self.control_handle.shutdown();
7168        }
7169        self.drop_without_shutdown();
7170        _result
7171    }
7172
7173    /// Similar to "send" but does not shutdown the channel if an error occurs.
7174    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7175        let _result = self.send_raw(result);
7176        self.drop_without_shutdown();
7177        _result
7178    }
7179
7180    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
7181        self.control_handle
7182            .inner
7183            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
7184                result,
7185                self.tx_id,
7186                0x4c340be8a504ee1c,
7187                fidl::encoding::DynamicFlags::empty(),
7188            )
7189    }
7190}
7191
7192mod internal {
7193    use super::*;
7194
7195    impl fidl::encoding::ResourceTypeMarker for BlobCreatorCreateResponse {
7196        type Borrowed<'a> = &'a mut Self;
7197        fn take_or_borrow<'a>(
7198            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7199        ) -> Self::Borrowed<'a> {
7200            value
7201        }
7202    }
7203
7204    unsafe impl fidl::encoding::TypeMarker for BlobCreatorCreateResponse {
7205        type Owned = Self;
7206
7207        #[inline(always)]
7208        fn inline_align(_context: fidl::encoding::Context) -> usize {
7209            4
7210        }
7211
7212        #[inline(always)]
7213        fn inline_size(_context: fidl::encoding::Context) -> usize {
7214            4
7215        }
7216    }
7217
7218    unsafe impl
7219        fidl::encoding::Encode<
7220            BlobCreatorCreateResponse,
7221            fidl::encoding::DefaultFuchsiaResourceDialect,
7222        > for &mut BlobCreatorCreateResponse
7223    {
7224        #[inline]
7225        unsafe fn encode(
7226            self,
7227            encoder: &mut fidl::encoding::Encoder<
7228                '_,
7229                fidl::encoding::DefaultFuchsiaResourceDialect,
7230            >,
7231            offset: usize,
7232            _depth: fidl::encoding::Depth,
7233        ) -> fidl::Result<()> {
7234            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
7235            // Delegate to tuple encoding.
7236            fidl::encoding::Encode::<BlobCreatorCreateResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7237                (
7238                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.writer),
7239                ),
7240                encoder, offset, _depth
7241            )
7242        }
7243    }
7244    unsafe impl<
7245        T0: fidl::encoding::Encode<
7246                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
7247                fidl::encoding::DefaultFuchsiaResourceDialect,
7248            >,
7249    >
7250        fidl::encoding::Encode<
7251            BlobCreatorCreateResponse,
7252            fidl::encoding::DefaultFuchsiaResourceDialect,
7253        > for (T0,)
7254    {
7255        #[inline]
7256        unsafe fn encode(
7257            self,
7258            encoder: &mut fidl::encoding::Encoder<
7259                '_,
7260                fidl::encoding::DefaultFuchsiaResourceDialect,
7261            >,
7262            offset: usize,
7263            depth: fidl::encoding::Depth,
7264        ) -> fidl::Result<()> {
7265            encoder.debug_check_bounds::<BlobCreatorCreateResponse>(offset);
7266            // Zero out padding regions. There's no need to apply masks
7267            // because the unmasked parts will be overwritten by fields.
7268            // Write the fields.
7269            self.0.encode(encoder, offset + 0, depth)?;
7270            Ok(())
7271        }
7272    }
7273
7274    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7275        for BlobCreatorCreateResponse
7276    {
7277        #[inline(always)]
7278        fn new_empty() -> Self {
7279            Self {
7280                writer: fidl::new_empty!(
7281                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
7282                    fidl::encoding::DefaultFuchsiaResourceDialect
7283                ),
7284            }
7285        }
7286
7287        #[inline]
7288        unsafe fn decode(
7289            &mut self,
7290            decoder: &mut fidl::encoding::Decoder<
7291                '_,
7292                fidl::encoding::DefaultFuchsiaResourceDialect,
7293            >,
7294            offset: usize,
7295            _depth: fidl::encoding::Depth,
7296        ) -> fidl::Result<()> {
7297            decoder.debug_check_bounds::<Self>(offset);
7298            // Verify that padding bytes are zero.
7299            fidl::decode!(
7300                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BlobWriterMarker>>,
7301                fidl::encoding::DefaultFuchsiaResourceDialect,
7302                &mut self.writer,
7303                decoder,
7304                offset + 0,
7305                _depth
7306            )?;
7307            Ok(())
7308        }
7309    }
7310
7311    impl fidl::encoding::ResourceTypeMarker for BlobReaderGetVmoResponse {
7312        type Borrowed<'a> = &'a mut Self;
7313        fn take_or_borrow<'a>(
7314            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7315        ) -> Self::Borrowed<'a> {
7316            value
7317        }
7318    }
7319
7320    unsafe impl fidl::encoding::TypeMarker for BlobReaderGetVmoResponse {
7321        type Owned = Self;
7322
7323        #[inline(always)]
7324        fn inline_align(_context: fidl::encoding::Context) -> usize {
7325            4
7326        }
7327
7328        #[inline(always)]
7329        fn inline_size(_context: fidl::encoding::Context) -> usize {
7330            4
7331        }
7332    }
7333
7334    unsafe impl
7335        fidl::encoding::Encode<
7336            BlobReaderGetVmoResponse,
7337            fidl::encoding::DefaultFuchsiaResourceDialect,
7338        > for &mut BlobReaderGetVmoResponse
7339    {
7340        #[inline]
7341        unsafe fn encode(
7342            self,
7343            encoder: &mut fidl::encoding::Encoder<
7344                '_,
7345                fidl::encoding::DefaultFuchsiaResourceDialect,
7346            >,
7347            offset: usize,
7348            _depth: fidl::encoding::Depth,
7349        ) -> fidl::Result<()> {
7350            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
7351            // Delegate to tuple encoding.
7352            fidl::encoding::Encode::<
7353                BlobReaderGetVmoResponse,
7354                fidl::encoding::DefaultFuchsiaResourceDialect,
7355            >::encode(
7356                (<fidl::encoding::HandleType<
7357                    fidl::Vmo,
7358                    { fidl::ObjectType::VMO.into_raw() },
7359                    2147483648,
7360                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7361                    &mut self.vmo
7362                ),),
7363                encoder,
7364                offset,
7365                _depth,
7366            )
7367        }
7368    }
7369    unsafe impl<
7370        T0: fidl::encoding::Encode<
7371                fidl::encoding::HandleType<
7372                    fidl::Vmo,
7373                    { fidl::ObjectType::VMO.into_raw() },
7374                    2147483648,
7375                >,
7376                fidl::encoding::DefaultFuchsiaResourceDialect,
7377            >,
7378    >
7379        fidl::encoding::Encode<
7380            BlobReaderGetVmoResponse,
7381            fidl::encoding::DefaultFuchsiaResourceDialect,
7382        > for (T0,)
7383    {
7384        #[inline]
7385        unsafe fn encode(
7386            self,
7387            encoder: &mut fidl::encoding::Encoder<
7388                '_,
7389                fidl::encoding::DefaultFuchsiaResourceDialect,
7390            >,
7391            offset: usize,
7392            depth: fidl::encoding::Depth,
7393        ) -> fidl::Result<()> {
7394            encoder.debug_check_bounds::<BlobReaderGetVmoResponse>(offset);
7395            // Zero out padding regions. There's no need to apply masks
7396            // because the unmasked parts will be overwritten by fields.
7397            // Write the fields.
7398            self.0.encode(encoder, offset + 0, depth)?;
7399            Ok(())
7400        }
7401    }
7402
7403    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7404        for BlobReaderGetVmoResponse
7405    {
7406        #[inline(always)]
7407        fn new_empty() -> Self {
7408            Self {
7409                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7410            }
7411        }
7412
7413        #[inline]
7414        unsafe fn decode(
7415            &mut self,
7416            decoder: &mut fidl::encoding::Decoder<
7417                '_,
7418                fidl::encoding::DefaultFuchsiaResourceDialect,
7419            >,
7420            offset: usize,
7421            _depth: fidl::encoding::Depth,
7422        ) -> fidl::Result<()> {
7423            decoder.debug_check_bounds::<Self>(offset);
7424            // Verify that padding bytes are zero.
7425            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
7426            Ok(())
7427        }
7428    }
7429
7430    impl fidl::encoding::ResourceTypeMarker for BlobWriterGetVmoResponse {
7431        type Borrowed<'a> = &'a mut Self;
7432        fn take_or_borrow<'a>(
7433            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7434        ) -> Self::Borrowed<'a> {
7435            value
7436        }
7437    }
7438
7439    unsafe impl fidl::encoding::TypeMarker for BlobWriterGetVmoResponse {
7440        type Owned = Self;
7441
7442        #[inline(always)]
7443        fn inline_align(_context: fidl::encoding::Context) -> usize {
7444            4
7445        }
7446
7447        #[inline(always)]
7448        fn inline_size(_context: fidl::encoding::Context) -> usize {
7449            4
7450        }
7451    }
7452
7453    unsafe impl
7454        fidl::encoding::Encode<
7455            BlobWriterGetVmoResponse,
7456            fidl::encoding::DefaultFuchsiaResourceDialect,
7457        > for &mut BlobWriterGetVmoResponse
7458    {
7459        #[inline]
7460        unsafe fn encode(
7461            self,
7462            encoder: &mut fidl::encoding::Encoder<
7463                '_,
7464                fidl::encoding::DefaultFuchsiaResourceDialect,
7465            >,
7466            offset: usize,
7467            _depth: fidl::encoding::Depth,
7468        ) -> fidl::Result<()> {
7469            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
7470            // Delegate to tuple encoding.
7471            fidl::encoding::Encode::<
7472                BlobWriterGetVmoResponse,
7473                fidl::encoding::DefaultFuchsiaResourceDialect,
7474            >::encode(
7475                (<fidl::encoding::HandleType<
7476                    fidl::Vmo,
7477                    { fidl::ObjectType::VMO.into_raw() },
7478                    2147483648,
7479                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7480                    &mut self.vmo
7481                ),),
7482                encoder,
7483                offset,
7484                _depth,
7485            )
7486        }
7487    }
7488    unsafe impl<
7489        T0: fidl::encoding::Encode<
7490                fidl::encoding::HandleType<
7491                    fidl::Vmo,
7492                    { fidl::ObjectType::VMO.into_raw() },
7493                    2147483648,
7494                >,
7495                fidl::encoding::DefaultFuchsiaResourceDialect,
7496            >,
7497    >
7498        fidl::encoding::Encode<
7499            BlobWriterGetVmoResponse,
7500            fidl::encoding::DefaultFuchsiaResourceDialect,
7501        > for (T0,)
7502    {
7503        #[inline]
7504        unsafe fn encode(
7505            self,
7506            encoder: &mut fidl::encoding::Encoder<
7507                '_,
7508                fidl::encoding::DefaultFuchsiaResourceDialect,
7509            >,
7510            offset: usize,
7511            depth: fidl::encoding::Depth,
7512        ) -> fidl::Result<()> {
7513            encoder.debug_check_bounds::<BlobWriterGetVmoResponse>(offset);
7514            // Zero out padding regions. There's no need to apply masks
7515            // because the unmasked parts will be overwritten by fields.
7516            // Write the fields.
7517            self.0.encode(encoder, offset + 0, depth)?;
7518            Ok(())
7519        }
7520    }
7521
7522    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7523        for BlobWriterGetVmoResponse
7524    {
7525        #[inline(always)]
7526        fn new_empty() -> Self {
7527            Self {
7528                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7529            }
7530        }
7531
7532        #[inline]
7533        unsafe fn decode(
7534            &mut self,
7535            decoder: &mut fidl::encoding::Decoder<
7536                '_,
7537                fidl::encoding::DefaultFuchsiaResourceDialect,
7538            >,
7539            offset: usize,
7540            _depth: fidl::encoding::Depth,
7541        ) -> fidl::Result<()> {
7542            decoder.debug_check_bounds::<Self>(offset);
7543            // Verify that padding bytes are zero.
7544            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
7545            Ok(())
7546        }
7547    }
7548
7549    impl fidl::encoding::ResourceTypeMarker for FileBackedVolumeProviderOpenRequest {
7550        type Borrowed<'a> = &'a mut Self;
7551        fn take_or_borrow<'a>(
7552            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7553        ) -> Self::Borrowed<'a> {
7554            value
7555        }
7556    }
7557
7558    unsafe impl fidl::encoding::TypeMarker for FileBackedVolumeProviderOpenRequest {
7559        type Owned = Self;
7560
7561        #[inline(always)]
7562        fn inline_align(_context: fidl::encoding::Context) -> usize {
7563            8
7564        }
7565
7566        #[inline(always)]
7567        fn inline_size(_context: fidl::encoding::Context) -> usize {
7568            32
7569        }
7570    }
7571
7572    unsafe impl
7573        fidl::encoding::Encode<
7574            FileBackedVolumeProviderOpenRequest,
7575            fidl::encoding::DefaultFuchsiaResourceDialect,
7576        > for &mut FileBackedVolumeProviderOpenRequest
7577    {
7578        #[inline]
7579        unsafe fn encode(
7580            self,
7581            encoder: &mut fidl::encoding::Encoder<
7582                '_,
7583                fidl::encoding::DefaultFuchsiaResourceDialect,
7584            >,
7585            offset: usize,
7586            _depth: fidl::encoding::Depth,
7587        ) -> fidl::Result<()> {
7588            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
7589            // Delegate to tuple encoding.
7590            fidl::encoding::Encode::<
7591                FileBackedVolumeProviderOpenRequest,
7592                fidl::encoding::DefaultFuchsiaResourceDialect,
7593            >::encode(
7594                (
7595                    <fidl::encoding::HandleType<
7596                        fidl::NullableHandle,
7597                        { fidl::ObjectType::NONE.into_raw() },
7598                        2147483648,
7599                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7600                        &mut self.parent_directory_token,
7601                    ),
7602                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(
7603                        &self.name,
7604                    ),
7605                    <fidl::encoding::Endpoint<
7606                        fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
7607                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7608                        &mut self.server_end
7609                    ),
7610                ),
7611                encoder,
7612                offset,
7613                _depth,
7614            )
7615        }
7616    }
7617    unsafe impl<
7618        T0: fidl::encoding::Encode<
7619                fidl::encoding::HandleType<
7620                    fidl::NullableHandle,
7621                    { fidl::ObjectType::NONE.into_raw() },
7622                    2147483648,
7623                >,
7624                fidl::encoding::DefaultFuchsiaResourceDialect,
7625            >,
7626        T1: fidl::encoding::Encode<
7627                fidl::encoding::BoundedString<255>,
7628                fidl::encoding::DefaultFuchsiaResourceDialect,
7629            >,
7630        T2: fidl::encoding::Encode<
7631                fidl::encoding::Endpoint<
7632                    fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
7633                >,
7634                fidl::encoding::DefaultFuchsiaResourceDialect,
7635            >,
7636    >
7637        fidl::encoding::Encode<
7638            FileBackedVolumeProviderOpenRequest,
7639            fidl::encoding::DefaultFuchsiaResourceDialect,
7640        > for (T0, T1, T2)
7641    {
7642        #[inline]
7643        unsafe fn encode(
7644            self,
7645            encoder: &mut fidl::encoding::Encoder<
7646                '_,
7647                fidl::encoding::DefaultFuchsiaResourceDialect,
7648            >,
7649            offset: usize,
7650            depth: fidl::encoding::Depth,
7651        ) -> fidl::Result<()> {
7652            encoder.debug_check_bounds::<FileBackedVolumeProviderOpenRequest>(offset);
7653            // Zero out padding regions. There's no need to apply masks
7654            // because the unmasked parts will be overwritten by fields.
7655            unsafe {
7656                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
7657                (ptr as *mut u64).write_unaligned(0);
7658            }
7659            unsafe {
7660                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
7661                (ptr as *mut u64).write_unaligned(0);
7662            }
7663            // Write the fields.
7664            self.0.encode(encoder, offset + 0, depth)?;
7665            self.1.encode(encoder, offset + 8, depth)?;
7666            self.2.encode(encoder, offset + 24, depth)?;
7667            Ok(())
7668        }
7669    }
7670
7671    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7672        for FileBackedVolumeProviderOpenRequest
7673    {
7674        #[inline(always)]
7675        fn new_empty() -> Self {
7676            Self {
7677                parent_directory_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7678                name: fidl::new_empty!(
7679                    fidl::encoding::BoundedString<255>,
7680                    fidl::encoding::DefaultFuchsiaResourceDialect
7681                ),
7682                server_end: fidl::new_empty!(
7683                    fidl::encoding::Endpoint<
7684                        fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
7685                    >,
7686                    fidl::encoding::DefaultFuchsiaResourceDialect
7687                ),
7688            }
7689        }
7690
7691        #[inline]
7692        unsafe fn decode(
7693            &mut self,
7694            decoder: &mut fidl::encoding::Decoder<
7695                '_,
7696                fidl::encoding::DefaultFuchsiaResourceDialect,
7697            >,
7698            offset: usize,
7699            _depth: fidl::encoding::Depth,
7700        ) -> fidl::Result<()> {
7701            decoder.debug_check_bounds::<Self>(offset);
7702            // Verify that padding bytes are zero.
7703            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7704            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7705            let mask = 0xffffffff00000000u64;
7706            let maskedval = padval & mask;
7707            if maskedval != 0 {
7708                return Err(fidl::Error::NonZeroPadding {
7709                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7710                });
7711            }
7712            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
7713            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7714            let mask = 0xffffffff00000000u64;
7715            let maskedval = padval & mask;
7716            if maskedval != 0 {
7717                return Err(fidl::Error::NonZeroPadding {
7718                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
7719                });
7720            }
7721            fidl::decode!(fidl::encoding::HandleType<fidl::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.parent_directory_token, decoder, offset + 0, _depth)?;
7722            fidl::decode!(
7723                fidl::encoding::BoundedString<255>,
7724                fidl::encoding::DefaultFuchsiaResourceDialect,
7725                &mut self.name,
7726                decoder,
7727                offset + 8,
7728                _depth
7729            )?;
7730            fidl::decode!(
7731                fidl::encoding::Endpoint<
7732                    fidl::endpoints::ServerEnd<fidl_fuchsia_storage_block::BlockMarker>,
7733                >,
7734                fidl::encoding::DefaultFuchsiaResourceDialect,
7735                &mut self.server_end,
7736                decoder,
7737                offset + 24,
7738                _depth
7739            )?;
7740            Ok(())
7741        }
7742    }
7743}