Skip to main content

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