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