Skip to main content

fdomain_fuchsia_sysmem2/
fdomain_fuchsia_sysmem2.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_sysmem2__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Default, PartialEq)]
14pub struct AllocatorAllocateNonSharedCollectionRequest {
15    pub collection_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
16    #[doc(hidden)]
17    pub __source_breaking: fidl::marker::SourceBreaking,
18}
19
20impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
21    for AllocatorAllocateNonSharedCollectionRequest
22{
23}
24
25#[derive(Debug, Default, PartialEq)]
26pub struct AllocatorAllocateSharedCollectionRequest {
27    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
33    for AllocatorAllocateSharedCollectionRequest
34{
35}
36
37#[derive(Debug, Default, PartialEq)]
38pub struct AllocatorBindSharedCollectionRequest {
39    pub token: Option<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
40    pub buffer_collection_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
41    #[doc(hidden)]
42    pub __source_breaking: fidl::marker::SourceBreaking,
43}
44
45impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
46    for AllocatorBindSharedCollectionRequest
47{
48}
49
50#[derive(Debug, Default, PartialEq)]
51pub struct AllocatorGetVmoInfoRequest {
52    /// `vmo` is required to be set; ownership is transferred to the server
53    /// so in most cases a client will duplicate a handle and transfer the
54    /// duplicate via this field.
55    pub vmo: Option<fdomain_client::Vmo>,
56    #[doc(hidden)]
57    pub __source_breaking: fidl::marker::SourceBreaking,
58}
59
60impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for AllocatorGetVmoInfoRequest {}
61
62#[derive(Debug, Default, PartialEq)]
63pub struct AllocatorGetVmoInfoResponse {
64    pub buffer_collection_id: Option<u64>,
65    pub buffer_index: Option<u64>,
66    pub close_weak_asap: Option<fdomain_client::EventPair>,
67    #[doc(hidden)]
68    pub __source_breaking: fidl::marker::SourceBreaking,
69}
70
71impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
72    for AllocatorGetVmoInfoResponse
73{
74}
75
76#[derive(Debug, Default, PartialEq)]
77pub struct BufferCollectionAttachLifetimeTrackingRequest {
78    pub server_end: Option<fdomain_client::EventPair>,
79    pub buffers_remaining: Option<u32>,
80    #[doc(hidden)]
81    pub __source_breaking: fidl::marker::SourceBreaking,
82}
83
84impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
85    for BufferCollectionAttachLifetimeTrackingRequest
86{
87}
88
89#[derive(Debug, Default, PartialEq)]
90pub struct BufferCollectionAttachTokenRequest {
91    pub rights_attenuation_mask: Option<fidl::Rights>,
92    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
93    #[doc(hidden)]
94    pub __source_breaking: fidl::marker::SourceBreaking,
95}
96
97impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
98    for BufferCollectionAttachTokenRequest
99{
100}
101
102/// Information about a buffer collection and its buffers.
103#[derive(Debug, Default, PartialEq)]
104pub struct BufferCollectionInfo {
105    /// These settings apply to all the buffers in the initial buffer
106    /// allocation.
107    ///
108    /// This field will always be set by sysmem.
109    pub settings: Option<SingleBufferSettings>,
110    /// VMO handles (and vmo_usable_start offset) for each buffer in the
111    /// collection.
112    ///
113    /// The size of this vector is the buffer_count (buffer_count is not sent
114    /// separately).
115    ///
116    /// All buffer VMO handles have identical size and access rights.  The size
117    /// is in settings.buffer_settings.size_bytes.
118    ///
119    /// The VMO access rights are determined based on the usages which the
120    /// client specified when allocating the buffer collection.  For example, a
121    /// client which expressed a read-only usage will receive VMOs without write
122    /// rights.  In addition, the rights can be attenuated by the parameter to
123    /// BufferCollectionToken.Duplicate() calls.
124    ///
125    /// This field will always have VmoBuffer(s) in it, even if the participant
126    /// specifies usage whieh does not require VMO handles.  This permits such a
127    /// participant to know the vmo_usable_start values, in case that's of any
128    /// use to the participant.
129    ///
130    /// This field will always be set by sysmem, even if the participant doesn't
131    /// specify any buffer usage (but the [`fuchsia.sysmem2/VmoBuffer.vmo`]
132    /// sub-field within this field won't be set in that case).
133    pub buffers: Option<Vec<VmoBuffer>>,
134    /// This number is unique among all logical buffer collections per boot.
135    ///
136    /// This ID number will be the same for all BufferCollectionToken(s),
137    /// BufferCollection(s), and BufferCollectionTokenGroup(s) associated with
138    /// the same logical buffer collection (derived from the same root token
139    /// created with fuchsia.sysmem2.Allocator.CreateSharedCollection, or with
140    /// CreateNonSharedCollection).
141    ///
142    /// The same ID can be retrieved from a BufferCollectionToken,
143    /// BufferCollection, or BufferCollectionTokenGroup using
144    /// GetBufferCollectionId (at the cost of a round-trip to sysmem and back).
145    ///
146    /// This field will always be set by sysmem.
147    pub buffer_collection_id: Option<u64>,
148    #[doc(hidden)]
149    pub __source_breaking: fidl::marker::SourceBreaking,
150}
151
152impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for BufferCollectionInfo {}
153
154#[derive(Debug, Default, PartialEq)]
155pub struct BufferCollectionSetConstraintsRequest {
156    pub constraints: Option<BufferCollectionConstraints>,
157    #[doc(hidden)]
158    pub __source_breaking: fidl::marker::SourceBreaking,
159}
160
161impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
162    for BufferCollectionSetConstraintsRequest
163{
164}
165
166#[derive(Debug, Default, PartialEq)]
167pub struct BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
168    pub group_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>>,
169    #[doc(hidden)]
170    pub __source_breaking: fidl::marker::SourceBreaking,
171}
172
173impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
174    for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
175{
176}
177
178#[derive(Debug, Default, PartialEq)]
179pub struct BufferCollectionTokenDuplicateRequest {
180    pub rights_attenuation_mask: Option<fidl::Rights>,
181    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
182    #[doc(hidden)]
183    pub __source_breaking: fidl::marker::SourceBreaking,
184}
185
186impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
187    for BufferCollectionTokenDuplicateRequest
188{
189}
190
191#[derive(Debug, Default, PartialEq)]
192pub struct BufferCollectionTokenGroupCreateChildRequest {
193    /// Must be set.
194    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
195    /// If not set, the default is `ZX_RIGHT_SAME_RIGHTS`.
196    pub rights_attenuation_mask: Option<fidl::Rights>,
197    #[doc(hidden)]
198    pub __source_breaking: fidl::marker::SourceBreaking,
199}
200
201impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
202    for BufferCollectionTokenGroupCreateChildRequest
203{
204}
205
206#[derive(Debug, Default, PartialEq)]
207pub struct BufferCollectionTokenGroupCreateChildrenSyncResponse {
208    pub tokens: Option<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>>,
209    #[doc(hidden)]
210    pub __source_breaking: fidl::marker::SourceBreaking,
211}
212
213impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
214    for BufferCollectionTokenGroupCreateChildrenSyncResponse
215{
216}
217
218#[derive(Debug, Default, PartialEq)]
219pub struct BufferCollectionTokenDuplicateSyncResponse {
220    pub tokens: Option<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>>,
221    #[doc(hidden)]
222    pub __source_breaking: fidl::marker::SourceBreaking,
223}
224
225impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
226    for BufferCollectionTokenDuplicateSyncResponse
227{
228}
229
230#[derive(Debug, Default, PartialEq)]
231pub struct BufferCollectionWaitForAllBuffersAllocatedResponse {
232    pub buffer_collection_info: Option<BufferCollectionInfo>,
233    #[doc(hidden)]
234    pub __source_breaking: fidl::marker::SourceBreaking,
235}
236
237impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
238    for BufferCollectionWaitForAllBuffersAllocatedResponse
239{
240}
241
242#[derive(Debug, Default, PartialEq)]
243pub struct NodeAttachNodeTrackingRequest {
244    /// This field must be set. This evenpair end will be closed after the
245    /// `Node` is closed or failed and the node's buffer counts are no
246    /// longer in effect in the logical buffer collection.
247    pub server_end: Option<fdomain_client::EventPair>,
248    #[doc(hidden)]
249    pub __source_breaking: fidl::marker::SourceBreaking,
250}
251
252impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
253    for NodeAttachNodeTrackingRequest
254{
255}
256
257#[derive(Debug, Default, PartialEq)]
258pub struct NodeIsAlternateForRequest {
259    pub node_ref: Option<fdomain_client::Event>,
260    #[doc(hidden)]
261    pub __source_breaking: fidl::marker::SourceBreaking,
262}
263
264impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeIsAlternateForRequest {}
265
266#[derive(Debug, Default, PartialEq)]
267pub struct NodeSetWeakOkRequest {
268    pub for_child_nodes_also: Option<bool>,
269    #[doc(hidden)]
270    pub __source_breaking: fidl::marker::SourceBreaking,
271}
272
273impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeSetWeakOkRequest {}
274
275#[derive(Debug, Default, PartialEq)]
276pub struct NodeGetNodeRefResponse {
277    pub node_ref: Option<fdomain_client::Event>,
278    #[doc(hidden)]
279    pub __source_breaking: fidl::marker::SourceBreaking,
280}
281
282impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeGetNodeRefResponse {}
283
284#[derive(Debug, Default, PartialEq)]
285pub struct VmoBuffer {
286    /// `vmo` can be un-set if a participant has only
287    /// [`fuchsia.sysmem2/BufferUsage.none`] set to `NONE_USAGE` (explicitly or
288    /// implicitly by [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
289    /// without `constraints` set).
290    pub vmo: Option<fdomain_client::Vmo>,
291    /// Offset within the VMO of the first usable byte. Must be < the VMO's size
292    /// in bytes, and leave sufficient room for BufferMemorySettings.size_bytes
293    /// before the end of the VMO.
294    ///
295    /// Currently sysmem will always set this field to 0, and in future, sysmem
296    /// won't set this field to a non-zero value unless all participants have
297    /// explicitly indicated support for non-zero vmo_usable_start (this
298    /// mechanism does not exist as of this comment). A participant that hasn't
299    /// explicitly indicated support for non-zero vmo_usable_start (all current
300    /// clients) should implicitly assume this field is set to 0 without
301    /// actually checking this field.
302    pub vmo_usable_start: Option<u64>,
303    /// This field is set iff `vmo` is a sysmem weak VMO handle.
304    ///
305    /// If the client sent `SetWeakOk`, the client must keep `close_weak_asap`
306    /// around for as long as `vmo`, and must notice `ZX_EVENTPAIR_PEER_CLOSED`.
307    /// If that signal occurs, the client must close `vmo` asap.
308    ///
309    /// If the `vmo` is a sysmem weak VMO handle but the client didn't send
310    /// `SetWeakOk`, this means that a holder of a parent node sent `SetWeakOk`
311    /// with `for_child_nodes_also` true, and the owner of that parent node is
312    /// responsible for paying attention to `close_weak_asap` and informing
313    /// child token participants to close handles. In this case the participant
314    /// that never sent `SetWeakOk` is allowed to retain and/or pay attention to
315    /// `close_weak_asap` (to close the handle faster, or for other reasons such
316    /// as diagnosing overall buffer cleanup timing), but is not required to
317    /// retain or pay attention to `close_weak_asap`.
318    ///
319    /// If sysmem closing the sysmem end of `close_weak_asap` does not result in
320    /// quick closure of all sysmem weak VMO handles to the buffer, that's
321    /// considered a VMO leak, and in that case sysmem will eventually complain
322    /// loudly via syslog (currently 5s later).
323    pub close_weak_asap: Option<fdomain_client::EventPair>,
324    #[doc(hidden)]
325    pub __source_breaking: fidl::marker::SourceBreaking,
326}
327
328impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {}
329
330#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
331pub struct AllocatorMarker;
332
333impl fdomain_client::fidl::ProtocolMarker for AllocatorMarker {
334    type Proxy = AllocatorProxy;
335    type RequestStream = AllocatorRequestStream;
336
337    const DEBUG_NAME: &'static str = "fuchsia.sysmem2.Allocator";
338}
339impl fdomain_client::fidl::DiscoverableProtocolMarker for AllocatorMarker {}
340pub type AllocatorGetVmoInfoResult = Result<AllocatorGetVmoInfoResponse, Error>;
341
342pub trait AllocatorProxyInterface: Send + Sync {
343    fn r#allocate_non_shared_collection(
344        &self,
345        payload: AllocatorAllocateNonSharedCollectionRequest,
346    ) -> Result<(), fidl::Error>;
347    fn r#allocate_shared_collection(
348        &self,
349        payload: AllocatorAllocateSharedCollectionRequest,
350    ) -> Result<(), fidl::Error>;
351    fn r#bind_shared_collection(
352        &self,
353        payload: AllocatorBindSharedCollectionRequest,
354    ) -> Result<(), fidl::Error>;
355    type ValidateBufferCollectionTokenResponseFut: std::future::Future<
356            Output = Result<AllocatorValidateBufferCollectionTokenResponse, fidl::Error>,
357        > + Send;
358    fn r#validate_buffer_collection_token(
359        &self,
360        payload: &AllocatorValidateBufferCollectionTokenRequest,
361    ) -> Self::ValidateBufferCollectionTokenResponseFut;
362    fn r#set_debug_client_info(
363        &self,
364        payload: &AllocatorSetDebugClientInfoRequest,
365    ) -> Result<(), fidl::Error>;
366    type GetVmoInfoResponseFut: std::future::Future<Output = Result<AllocatorGetVmoInfoResult, fidl::Error>>
367        + Send;
368    fn r#get_vmo_info(&self, payload: AllocatorGetVmoInfoRequest) -> Self::GetVmoInfoResponseFut;
369}
370
371#[derive(Debug, Clone)]
372pub struct AllocatorProxy {
373    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
374}
375
376impl fdomain_client::fidl::Proxy for AllocatorProxy {
377    type Protocol = AllocatorMarker;
378
379    fn from_channel(inner: fdomain_client::Channel) -> Self {
380        Self::new(inner)
381    }
382
383    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
384        self.client.into_channel().map_err(|client| Self { client })
385    }
386
387    fn as_channel(&self) -> &fdomain_client::Channel {
388        self.client.as_channel()
389    }
390}
391
392impl AllocatorProxy {
393    /// Create a new Proxy for fuchsia.sysmem2/Allocator.
394    pub fn new(channel: fdomain_client::Channel) -> Self {
395        let protocol_name = <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
396        Self { client: fidl::client::Client::new(channel, protocol_name) }
397    }
398
399    /// Get a Stream of events from the remote end of the protocol.
400    ///
401    /// # Panics
402    ///
403    /// Panics if the event stream was already taken.
404    pub fn take_event_stream(&self) -> AllocatorEventStream {
405        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
406    }
407
408    /// Allocates a buffer collection on behalf of a single client (aka
409    /// initiator) who is also the only participant (from the point of view of
410    /// sysmem).
411    ///
412    /// This call exists mainly for temp/testing purposes.  This call skips the
413    /// [`fuchsia.sysmem2/BufferCollectionToken`] stage, so there's no way to
414    /// allow another participant to specify its constraints.
415    ///
416    /// Real clients are encouraged to use
417    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] instead, and to
418    /// let relevant participants directly convey their own constraints to
419    /// sysmem by sending `BufferCollectionToken`s to those participants.
420    ///
421    /// + request `collection_request` The server end of the
422    ///   [`fuchsia.sysmem2/BufferCollection`].
423    pub fn r#allocate_non_shared_collection(
424        &self,
425        mut payload: AllocatorAllocateNonSharedCollectionRequest,
426    ) -> Result<(), fidl::Error> {
427        AllocatorProxyInterface::r#allocate_non_shared_collection(self, payload)
428    }
429
430    /// Creates a root [`fuchsia.sysmem2/BufferCollectionToken`].
431    ///
432    /// The `BufferCollectionToken` can be "duplicated" for distribution to
433    /// participants by using
434    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`]. Each
435    /// `BufferCollectionToken` can be converted into a
436    /// [`fuchsia.sysmem2.BufferCollection`] using
437    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`].
438    ///
439    /// Buffer constraints can be set via
440    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
441    ///
442    /// Success/failure to populate the buffer collection with buffers can be
443    /// determined from
444    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
445    ///
446    /// Closing the client end of a `BufferCollectionToken` or
447    /// `BufferCollection` (without `Release` first) will fail all client ends
448    /// in the same failure domain, which by default is all client ends of the
449    /// buffer collection. See
450    /// [`fuchsia.sysmem2/BufferCollection.SetDispensable`] and
451    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`] for ways to create
452    /// separate failure domains within a buffer collection.
453    pub fn r#allocate_shared_collection(
454        &self,
455        mut payload: AllocatorAllocateSharedCollectionRequest,
456    ) -> Result<(), fidl::Error> {
457        AllocatorProxyInterface::r#allocate_shared_collection(self, payload)
458    }
459
460    /// Convert a [`fuchsia.sysmem2/BufferCollectionToken`] into a
461    /// [`fuchsia.sysmem2/BufferCollection`].
462    ///
463    /// At the time of sending this message, the buffer collection hasn't yet
464    /// been populated with buffers - the participant must first also send
465    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] via the
466    /// `BufferCollection` client end.
467    ///
468    /// All `BufferCollectionToken`(s) duplicated from a root
469    /// `BufferCollectionToken` (created via `AllocateSharedCollection`) must be
470    /// "turned in" via `BindSharedCollection` (or `Release`ed), and all
471    /// existing `BufferCollection` client ends must have sent `SetConstraints`
472    /// before the logical BufferCollection will be populated with buffers (or
473    /// will fail if the overall set of constraints can't be satisfied).
474    ///
475    /// + request `token` The client endpoint of a channel whose server end was
476    ///   sent to sysmem using
477    ///   [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] or whose server
478    ///   end was sent to sysmem using
479    ///   [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`].  The token is
480    ///   being "turned in" in exchange for a
481    ///   [`fuchsia.sysmem2/BufferCollection`].
482    /// + request `buffer_collection_request` The server end of a
483    ///   [`fuchsia.sysmem2/BufferCollection`] channel.  The sender retains the
484    ///   client end. The `BufferCollection` channel is a single participant's
485    ///   connection to the logical buffer collection. Typically there will be
486    ///   other participants with their own `BufferCollection` channel to the
487    ///   logical buffer collection.
488    pub fn r#bind_shared_collection(
489        &self,
490        mut payload: AllocatorBindSharedCollectionRequest,
491    ) -> Result<(), fidl::Error> {
492        AllocatorProxyInterface::r#bind_shared_collection(self, payload)
493    }
494
495    /// Checks whether a [`fuchsia.sysmem2/BufferCollectionToken`] is known to
496    /// the sysmem server.
497    ///
498    /// With this call, the client can determine whether an incoming token is a
499    /// real sysmem token that is known to the sysmem server, without any risk
500    /// of getting stuck waiting forever on a potentially fake token to complete
501    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or
502    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] (or any other two-way
503    /// FIDL message). In cases where the client trusts the source of the token
504    /// to provide a real token, this call is not typically needed outside of
505    /// debugging.
506    ///
507    /// If the validate fails sometimes but succeeds other times, the source of
508    /// the token may itself not be calling
509    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] or
510    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after creating/duplicating the
511    /// token but before sending the token to the current client. It may be more
512    /// convenient for the source to use
513    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] to duplicate
514    /// token(s), since that call has the sync step built in. Or, the buffer
515    /// collection may be failing before this call is processed by the sysmem
516    /// server, as buffer collection failure cleans up sysmem's tracking of
517    /// associated tokens.
518    ///
519    /// This call has no effect on any token.
520    ///
521    /// + request `token_server_koid` The koid of the server end of a channel
522    ///   that might be a BufferCollectionToken channel.  This can be obtained
523    ///   via `zx_object_get_info` `ZX_INFO_HANDLE_BASIC` `related_koid`.
524    /// - response `is_known` true means sysmem knew of the token at the time
525    ///   sysmem processed the request, but doesn't guarantee that the token is
526    ///   still valid by the time the client receives the reply. What it does
527    ///   guarantee is that the token at least was a real token, so a two-way
528    ///   call to the token won't stall forever (will fail or succeed fairly
529    ///   quickly, not stall). This can already be known implicitly if the
530    ///   source of the token can be trusted to provide a real token. A false
531    ///   value means the token wasn't known to sysmem at the time sysmem
532    ///   processed this call, but the token may have previously been valid, or
533    ///   may yet become valid. Or if the sender of the token isn't trusted to
534    ///   provide a real token, the token may be fake. It's the responsibility
535    ///   of the sender to sync with sysmem to ensure that previously
536    ///   created/duplicated token(s) are known to sysmem, before sending the
537    ///   token(s) to other participants.
538    pub fn r#validate_buffer_collection_token(
539        &self,
540        mut payload: &AllocatorValidateBufferCollectionTokenRequest,
541    ) -> fidl::client::QueryResponseFut<
542        AllocatorValidateBufferCollectionTokenResponse,
543        fdomain_client::fidl::FDomainResourceDialect,
544    > {
545        AllocatorProxyInterface::r#validate_buffer_collection_token(self, payload)
546    }
547
548    /// Set information about the current client that can be used by sysmem to
549    /// help diagnose leaking memory and allocation stalls waiting for a
550    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
551    ///
552    /// This sets the debug client info on all [`fuchsia.sysmem2/Node`](s)
553    /// subsequently created by this this [`fuchsia.sysmem2/Allocator`]
554    /// including any [`fuchsia.sysmem2/BufferCollection`](s) created via
555    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] (in the absence of
556    /// any prior call to [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`],
557    /// these `BufferCollection`(s) have the same initial debug client info as
558    /// the token turned in to create the `BufferCollection`).
559    ///
560    /// This info can be subsequently overridden on a per-`Node` basis by
561    /// sending [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
562    ///
563    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
564    /// `Allocator` is the most efficient way to ensure that all
565    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
566    /// set, and is also more efficient than separately sending the same debug
567    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
568    /// created [`fuchsia.sysmem2/Node`].
569    ///
570    /// + request `name` This can be an arbitrary string, but the current
571    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
572    /// + request `id` This can be an arbitrary id, but the current process ID
573    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
574    pub fn r#set_debug_client_info(
575        &self,
576        mut payload: &AllocatorSetDebugClientInfoRequest,
577    ) -> Result<(), fidl::Error> {
578        AllocatorProxyInterface::r#set_debug_client_info(self, payload)
579    }
580
581    /// Given a handle to a sysmem-provided VMO, this returns additional info
582    /// about the corresponding sysmem logical buffer.
583    ///
584    /// Most callers will duplicate a VMO handle first and send the duplicate to
585    /// this call.
586    ///
587    /// If the client has created a child VMO of a sysmem-provided VMO, that
588    /// child VMO isn't considered a "sysmem VMO" for purposes of this call.
589    ///
590    /// + request `vmo` A handle to a sysmem-provided VMO (or see errors).
591    /// - response `buffer_collection_id` The buffer collection ID, which is
592    ///   unique per logical buffer collection per boot.
593    /// - response `buffer_index` The buffer index of the buffer within the
594    ///   buffer collection. This is the same as the index of the buffer within
595    ///   [`fuchsia.sysmem2/BufferCollectionInfo.buffers`]. The `buffer_index`
596    ///   is the same for all sysmem-delivered VMOs corresponding to the same
597    ///   logical buffer, even if the VMO koids differ. The `buffer_index` is
598    ///   only unique across buffers of a buffer collection. For a given buffer,
599    ///   the combination of `buffer_collection_id` and `buffer_index` is unique
600    ///   per boot.
601    /// - response `close_weak_asap` Iff `vmo` is a handle to a weak sysmem VMO,
602    ///   the `close_weak_asap` field will be set in the response. This handle
603    ///   will signal `ZX_EVENTPAIR_PEER_CLOSED` when all weak VMO handles to
604    ///   the buffer should be closed as soon as possible. This is signalled
605    ///   shortly after all strong sysmem VMOs to the buffer are closed
606    ///   (including any held indirectly via strong `BufferCollectionToken` or
607    ///   strong `BufferCollection`). Failure to close all weak sysmem VMO
608    ///   handles to the buffer quickly upon `ZX_EVENTPAIR_PEER_CLOSED` is
609    ///   considered a VMO leak caused by the client still holding a weak sysmem
610    ///   VMO handle and results in loud complaints to the log by sysmem. The
611    ///   buffers of a collection can be freed independently of each other. The
612    ///   `ZX_EVENTPAIR_PEER_CLOSED` may already be signalled before the
613    ///   response arrives at the client. A client that isn't prepared to handle
614    ///   weak sysmem VMOs, on seeing this field set, can close all handles to
615    ///   the buffer and fail any associated request.
616    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` - the vmo isn't a sysmem
617    ///   VMO. Both strong and weak sysmem VMOs can be passed to this call, and
618    ///   the VMO handle passed in to this call itself keeps the VMO's info
619    ///   alive for purposes of responding to this call. Because of this,
620    ///   ZX_ERR_NOT_FOUND errors are unambiguous (even if there are no other
621    ///   handles to the VMO when calling; even if other handles are closed
622    ///   before the GetVmoInfo response arrives at the client).
623    /// * error `[fuchsia.sysmem2/Error.HANDLE_ACCESS_DENIED]` The vmo isn't
624    ///   capable of being used with GetVmoInfo due to rights/capability
625    ///   attenuation. The VMO needs to be usable with [`zx_vmo_get_info`] with
626    ///   topic [`ZX_INFO_HANDLE_BASIC`].
627    /// * error `[fuchsia.sysmem2/Error.UNSPECIFIED]` The request failed for an
628    ///   unspecified reason. See the log for more info.
629    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The vmo field
630    ///   wasn't set, or there was some other problem with the request field(s).
631    pub fn r#get_vmo_info(
632        &self,
633        mut payload: AllocatorGetVmoInfoRequest,
634    ) -> fidl::client::QueryResponseFut<
635        AllocatorGetVmoInfoResult,
636        fdomain_client::fidl::FDomainResourceDialect,
637    > {
638        AllocatorProxyInterface::r#get_vmo_info(self, payload)
639    }
640}
641
642impl AllocatorProxyInterface for AllocatorProxy {
643    fn r#allocate_non_shared_collection(
644        &self,
645        mut payload: AllocatorAllocateNonSharedCollectionRequest,
646    ) -> Result<(), fidl::Error> {
647        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
648            &mut payload,
649            0x5ca681f025a80e44,
650            fidl::encoding::DynamicFlags::FLEXIBLE,
651        )
652    }
653
654    fn r#allocate_shared_collection(
655        &self,
656        mut payload: AllocatorAllocateSharedCollectionRequest,
657    ) -> Result<(), fidl::Error> {
658        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
659            &mut payload,
660            0x11a19ff51f0b49c1,
661            fidl::encoding::DynamicFlags::FLEXIBLE,
662        )
663    }
664
665    fn r#bind_shared_collection(
666        &self,
667        mut payload: AllocatorBindSharedCollectionRequest,
668    ) -> Result<(), fidl::Error> {
669        self.client.send::<AllocatorBindSharedCollectionRequest>(
670            &mut payload,
671            0x550916b0dc1d5b4e,
672            fidl::encoding::DynamicFlags::FLEXIBLE,
673        )
674    }
675
676    type ValidateBufferCollectionTokenResponseFut = fidl::client::QueryResponseFut<
677        AllocatorValidateBufferCollectionTokenResponse,
678        fdomain_client::fidl::FDomainResourceDialect,
679    >;
680    fn r#validate_buffer_collection_token(
681        &self,
682        mut payload: &AllocatorValidateBufferCollectionTokenRequest,
683    ) -> Self::ValidateBufferCollectionTokenResponseFut {
684        fn _decode(
685            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
686        ) -> Result<AllocatorValidateBufferCollectionTokenResponse, fidl::Error> {
687            let _response = fidl::client::decode_transaction_body::<
688                fidl::encoding::FlexibleType<AllocatorValidateBufferCollectionTokenResponse>,
689                fdomain_client::fidl::FDomainResourceDialect,
690                0x4c5ee91b02a7e68d,
691            >(_buf?)?
692            .into_result_fdomain::<AllocatorMarker>("validate_buffer_collection_token")?;
693            Ok(_response)
694        }
695        self.client.send_query_and_decode::<
696            AllocatorValidateBufferCollectionTokenRequest,
697            AllocatorValidateBufferCollectionTokenResponse,
698        >(
699            payload,
700            0x4c5ee91b02a7e68d,
701            fidl::encoding::DynamicFlags::FLEXIBLE,
702            _decode,
703        )
704    }
705
706    fn r#set_debug_client_info(
707        &self,
708        mut payload: &AllocatorSetDebugClientInfoRequest,
709    ) -> Result<(), fidl::Error> {
710        self.client.send::<AllocatorSetDebugClientInfoRequest>(
711            payload,
712            0x6f68f19a3f509c4d,
713            fidl::encoding::DynamicFlags::FLEXIBLE,
714        )
715    }
716
717    type GetVmoInfoResponseFut = fidl::client::QueryResponseFut<
718        AllocatorGetVmoInfoResult,
719        fdomain_client::fidl::FDomainResourceDialect,
720    >;
721    fn r#get_vmo_info(
722        &self,
723        mut payload: AllocatorGetVmoInfoRequest,
724    ) -> Self::GetVmoInfoResponseFut {
725        fn _decode(
726            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
727        ) -> Result<AllocatorGetVmoInfoResult, fidl::Error> {
728            let _response = fidl::client::decode_transaction_body::<
729                fidl::encoding::FlexibleResultType<AllocatorGetVmoInfoResponse, Error>,
730                fdomain_client::fidl::FDomainResourceDialect,
731                0x21a881120aa0ddf9,
732            >(_buf?)?
733            .into_result_fdomain::<AllocatorMarker>("get_vmo_info")?;
734            Ok(_response.map(|x| x))
735        }
736        self.client.send_query_and_decode::<AllocatorGetVmoInfoRequest, AllocatorGetVmoInfoResult>(
737            &mut payload,
738            0x21a881120aa0ddf9,
739            fidl::encoding::DynamicFlags::FLEXIBLE,
740            _decode,
741        )
742    }
743}
744
745pub struct AllocatorEventStream {
746    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
747}
748
749impl std::marker::Unpin for AllocatorEventStream {}
750
751impl futures::stream::FusedStream for AllocatorEventStream {
752    fn is_terminated(&self) -> bool {
753        self.event_receiver.is_terminated()
754    }
755}
756
757impl futures::Stream for AllocatorEventStream {
758    type Item = Result<AllocatorEvent, fidl::Error>;
759
760    fn poll_next(
761        mut self: std::pin::Pin<&mut Self>,
762        cx: &mut std::task::Context<'_>,
763    ) -> std::task::Poll<Option<Self::Item>> {
764        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
765            &mut self.event_receiver,
766            cx
767        )?) {
768            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
769            None => std::task::Poll::Ready(None),
770        }
771    }
772}
773
774#[derive(Debug)]
775pub enum AllocatorEvent {
776    #[non_exhaustive]
777    _UnknownEvent {
778        /// Ordinal of the event that was sent.
779        ordinal: u64,
780    },
781}
782
783impl AllocatorEvent {
784    /// Decodes a message buffer as a [`AllocatorEvent`].
785    fn decode(
786        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
787    ) -> Result<AllocatorEvent, fidl::Error> {
788        let (bytes, _handles) = buf.split_mut();
789        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
790        debug_assert_eq!(tx_header.tx_id, 0);
791        match tx_header.ordinal {
792            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
793                Ok(AllocatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
794            }
795            _ => Err(fidl::Error::UnknownOrdinal {
796                ordinal: tx_header.ordinal,
797                protocol_name:
798                    <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
799            }),
800        }
801    }
802}
803
804/// A Stream of incoming requests for fuchsia.sysmem2/Allocator.
805pub struct AllocatorRequestStream {
806    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
807    is_terminated: bool,
808}
809
810impl std::marker::Unpin for AllocatorRequestStream {}
811
812impl futures::stream::FusedStream for AllocatorRequestStream {
813    fn is_terminated(&self) -> bool {
814        self.is_terminated
815    }
816}
817
818impl fdomain_client::fidl::RequestStream for AllocatorRequestStream {
819    type Protocol = AllocatorMarker;
820    type ControlHandle = AllocatorControlHandle;
821
822    fn from_channel(channel: fdomain_client::Channel) -> Self {
823        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
824    }
825
826    fn control_handle(&self) -> Self::ControlHandle {
827        AllocatorControlHandle { inner: self.inner.clone() }
828    }
829
830    fn into_inner(
831        self,
832    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
833    {
834        (self.inner, self.is_terminated)
835    }
836
837    fn from_inner(
838        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
839        is_terminated: bool,
840    ) -> Self {
841        Self { inner, is_terminated }
842    }
843}
844
845impl futures::Stream for AllocatorRequestStream {
846    type Item = Result<AllocatorRequest, fidl::Error>;
847
848    fn poll_next(
849        mut self: std::pin::Pin<&mut Self>,
850        cx: &mut std::task::Context<'_>,
851    ) -> std::task::Poll<Option<Self::Item>> {
852        let this = &mut *self;
853        if this.inner.check_shutdown(cx) {
854            this.is_terminated = true;
855            return std::task::Poll::Ready(None);
856        }
857        if this.is_terminated {
858            panic!("polled AllocatorRequestStream after completion");
859        }
860        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
861            |bytes, handles| {
862                match this.inner.channel().read_etc(cx, bytes, handles) {
863                    std::task::Poll::Ready(Ok(())) => {}
864                    std::task::Poll::Pending => return std::task::Poll::Pending,
865                    std::task::Poll::Ready(Err(None)) => {
866                        this.is_terminated = true;
867                        return std::task::Poll::Ready(None);
868                    }
869                    std::task::Poll::Ready(Err(Some(e))) => {
870                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
871                            e.into(),
872                        ))));
873                    }
874                }
875
876                // A message has been received from the channel
877                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
878
879                std::task::Poll::Ready(Some(match header.ordinal {
880                    0x5ca681f025a80e44 => {
881                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
882                        let mut req = fidl::new_empty!(
883                            AllocatorAllocateNonSharedCollectionRequest,
884                            fdomain_client::fidl::FDomainResourceDialect
885                        );
886                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
887                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
888                        Ok(AllocatorRequest::AllocateNonSharedCollection {
889                            payload: req,
890                            control_handle,
891                        })
892                    }
893                    0x11a19ff51f0b49c1 => {
894                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
895                        let mut req = fidl::new_empty!(
896                            AllocatorAllocateSharedCollectionRequest,
897                            fdomain_client::fidl::FDomainResourceDialect
898                        );
899                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
900                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
901                        Ok(AllocatorRequest::AllocateSharedCollection {
902                            payload: req,
903                            control_handle,
904                        })
905                    }
906                    0x550916b0dc1d5b4e => {
907                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
908                        let mut req = fidl::new_empty!(
909                            AllocatorBindSharedCollectionRequest,
910                            fdomain_client::fidl::FDomainResourceDialect
911                        );
912                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
913                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
914                        Ok(AllocatorRequest::BindSharedCollection { payload: req, control_handle })
915                    }
916                    0x4c5ee91b02a7e68d => {
917                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
918                        let mut req = fidl::new_empty!(
919                            AllocatorValidateBufferCollectionTokenRequest,
920                            fdomain_client::fidl::FDomainResourceDialect
921                        );
922                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
923                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
924                        Ok(AllocatorRequest::ValidateBufferCollectionToken {
925                            payload: req,
926                            responder: AllocatorValidateBufferCollectionTokenResponder {
927                                control_handle: std::mem::ManuallyDrop::new(control_handle),
928                                tx_id: header.tx_id,
929                            },
930                        })
931                    }
932                    0x6f68f19a3f509c4d => {
933                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
934                        let mut req = fidl::new_empty!(
935                            AllocatorSetDebugClientInfoRequest,
936                            fdomain_client::fidl::FDomainResourceDialect
937                        );
938                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
939                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
940                        Ok(AllocatorRequest::SetDebugClientInfo { payload: req, control_handle })
941                    }
942                    0x21a881120aa0ddf9 => {
943                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
944                        let mut req = fidl::new_empty!(
945                            AllocatorGetVmoInfoRequest,
946                            fdomain_client::fidl::FDomainResourceDialect
947                        );
948                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorGetVmoInfoRequest>(&header, _body_bytes, handles, &mut req)?;
949                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
950                        Ok(AllocatorRequest::GetVmoInfo {
951                            payload: req,
952                            responder: AllocatorGetVmoInfoResponder {
953                                control_handle: std::mem::ManuallyDrop::new(control_handle),
954                                tx_id: header.tx_id,
955                            },
956                        })
957                    }
958                    _ if header.tx_id == 0
959                        && header
960                            .dynamic_flags()
961                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
962                    {
963                        Ok(AllocatorRequest::_UnknownMethod {
964                            ordinal: header.ordinal,
965                            control_handle: AllocatorControlHandle { inner: this.inner.clone() },
966                            method_type: fidl::MethodType::OneWay,
967                        })
968                    }
969                    _ if header
970                        .dynamic_flags()
971                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
972                    {
973                        this.inner.send_framework_err(
974                            fidl::encoding::FrameworkErr::UnknownMethod,
975                            header.tx_id,
976                            header.ordinal,
977                            header.dynamic_flags(),
978                            (bytes, handles),
979                        )?;
980                        Ok(AllocatorRequest::_UnknownMethod {
981                            ordinal: header.ordinal,
982                            control_handle: AllocatorControlHandle { inner: this.inner.clone() },
983                            method_type: fidl::MethodType::TwoWay,
984                        })
985                    }
986                    _ => Err(fidl::Error::UnknownOrdinal {
987                        ordinal: header.ordinal,
988                        protocol_name:
989                            <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
990                    }),
991                }))
992            },
993        )
994    }
995}
996
997/// Allocates system memory buffers.
998///
999/// Epitaphs are not used in this protocol.
1000#[derive(Debug)]
1001pub enum AllocatorRequest {
1002    /// Allocates a buffer collection on behalf of a single client (aka
1003    /// initiator) who is also the only participant (from the point of view of
1004    /// sysmem).
1005    ///
1006    /// This call exists mainly for temp/testing purposes.  This call skips the
1007    /// [`fuchsia.sysmem2/BufferCollectionToken`] stage, so there's no way to
1008    /// allow another participant to specify its constraints.
1009    ///
1010    /// Real clients are encouraged to use
1011    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] instead, and to
1012    /// let relevant participants directly convey their own constraints to
1013    /// sysmem by sending `BufferCollectionToken`s to those participants.
1014    ///
1015    /// + request `collection_request` The server end of the
1016    ///   [`fuchsia.sysmem2/BufferCollection`].
1017    AllocateNonSharedCollection {
1018        payload: AllocatorAllocateNonSharedCollectionRequest,
1019        control_handle: AllocatorControlHandle,
1020    },
1021    /// Creates a root [`fuchsia.sysmem2/BufferCollectionToken`].
1022    ///
1023    /// The `BufferCollectionToken` can be "duplicated" for distribution to
1024    /// participants by using
1025    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`]. Each
1026    /// `BufferCollectionToken` can be converted into a
1027    /// [`fuchsia.sysmem2.BufferCollection`] using
1028    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`].
1029    ///
1030    /// Buffer constraints can be set via
1031    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1032    ///
1033    /// Success/failure to populate the buffer collection with buffers can be
1034    /// determined from
1035    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
1036    ///
1037    /// Closing the client end of a `BufferCollectionToken` or
1038    /// `BufferCollection` (without `Release` first) will fail all client ends
1039    /// in the same failure domain, which by default is all client ends of the
1040    /// buffer collection. See
1041    /// [`fuchsia.sysmem2/BufferCollection.SetDispensable`] and
1042    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`] for ways to create
1043    /// separate failure domains within a buffer collection.
1044    AllocateSharedCollection {
1045        payload: AllocatorAllocateSharedCollectionRequest,
1046        control_handle: AllocatorControlHandle,
1047    },
1048    /// Convert a [`fuchsia.sysmem2/BufferCollectionToken`] into a
1049    /// [`fuchsia.sysmem2/BufferCollection`].
1050    ///
1051    /// At the time of sending this message, the buffer collection hasn't yet
1052    /// been populated with buffers - the participant must first also send
1053    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] via the
1054    /// `BufferCollection` client end.
1055    ///
1056    /// All `BufferCollectionToken`(s) duplicated from a root
1057    /// `BufferCollectionToken` (created via `AllocateSharedCollection`) must be
1058    /// "turned in" via `BindSharedCollection` (or `Release`ed), and all
1059    /// existing `BufferCollection` client ends must have sent `SetConstraints`
1060    /// before the logical BufferCollection will be populated with buffers (or
1061    /// will fail if the overall set of constraints can't be satisfied).
1062    ///
1063    /// + request `token` The client endpoint of a channel whose server end was
1064    ///   sent to sysmem using
1065    ///   [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] or whose server
1066    ///   end was sent to sysmem using
1067    ///   [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`].  The token is
1068    ///   being "turned in" in exchange for a
1069    ///   [`fuchsia.sysmem2/BufferCollection`].
1070    /// + request `buffer_collection_request` The server end of a
1071    ///   [`fuchsia.sysmem2/BufferCollection`] channel.  The sender retains the
1072    ///   client end. The `BufferCollection` channel is a single participant's
1073    ///   connection to the logical buffer collection. Typically there will be
1074    ///   other participants with their own `BufferCollection` channel to the
1075    ///   logical buffer collection.
1076    BindSharedCollection {
1077        payload: AllocatorBindSharedCollectionRequest,
1078        control_handle: AllocatorControlHandle,
1079    },
1080    /// Checks whether a [`fuchsia.sysmem2/BufferCollectionToken`] is known to
1081    /// the sysmem server.
1082    ///
1083    /// With this call, the client can determine whether an incoming token is a
1084    /// real sysmem token that is known to the sysmem server, without any risk
1085    /// of getting stuck waiting forever on a potentially fake token to complete
1086    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or
1087    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] (or any other two-way
1088    /// FIDL message). In cases where the client trusts the source of the token
1089    /// to provide a real token, this call is not typically needed outside of
1090    /// debugging.
1091    ///
1092    /// If the validate fails sometimes but succeeds other times, the source of
1093    /// the token may itself not be calling
1094    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] or
1095    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after creating/duplicating the
1096    /// token but before sending the token to the current client. It may be more
1097    /// convenient for the source to use
1098    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] to duplicate
1099    /// token(s), since that call has the sync step built in. Or, the buffer
1100    /// collection may be failing before this call is processed by the sysmem
1101    /// server, as buffer collection failure cleans up sysmem's tracking of
1102    /// associated tokens.
1103    ///
1104    /// This call has no effect on any token.
1105    ///
1106    /// + request `token_server_koid` The koid of the server end of a channel
1107    ///   that might be a BufferCollectionToken channel.  This can be obtained
1108    ///   via `zx_object_get_info` `ZX_INFO_HANDLE_BASIC` `related_koid`.
1109    /// - response `is_known` true means sysmem knew of the token at the time
1110    ///   sysmem processed the request, but doesn't guarantee that the token is
1111    ///   still valid by the time the client receives the reply. What it does
1112    ///   guarantee is that the token at least was a real token, so a two-way
1113    ///   call to the token won't stall forever (will fail or succeed fairly
1114    ///   quickly, not stall). This can already be known implicitly if the
1115    ///   source of the token can be trusted to provide a real token. A false
1116    ///   value means the token wasn't known to sysmem at the time sysmem
1117    ///   processed this call, but the token may have previously been valid, or
1118    ///   may yet become valid. Or if the sender of the token isn't trusted to
1119    ///   provide a real token, the token may be fake. It's the responsibility
1120    ///   of the sender to sync with sysmem to ensure that previously
1121    ///   created/duplicated token(s) are known to sysmem, before sending the
1122    ///   token(s) to other participants.
1123    ValidateBufferCollectionToken {
1124        payload: AllocatorValidateBufferCollectionTokenRequest,
1125        responder: AllocatorValidateBufferCollectionTokenResponder,
1126    },
1127    /// Set information about the current client that can be used by sysmem to
1128    /// help diagnose leaking memory and allocation stalls waiting for a
1129    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1130    ///
1131    /// This sets the debug client info on all [`fuchsia.sysmem2/Node`](s)
1132    /// subsequently created by this this [`fuchsia.sysmem2/Allocator`]
1133    /// including any [`fuchsia.sysmem2/BufferCollection`](s) created via
1134    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] (in the absence of
1135    /// any prior call to [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`],
1136    /// these `BufferCollection`(s) have the same initial debug client info as
1137    /// the token turned in to create the `BufferCollection`).
1138    ///
1139    /// This info can be subsequently overridden on a per-`Node` basis by
1140    /// sending [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
1141    ///
1142    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
1143    /// `Allocator` is the most efficient way to ensure that all
1144    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
1145    /// set, and is also more efficient than separately sending the same debug
1146    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
1147    /// created [`fuchsia.sysmem2/Node`].
1148    ///
1149    /// + request `name` This can be an arbitrary string, but the current
1150    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
1151    /// + request `id` This can be an arbitrary id, but the current process ID
1152    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
1153    SetDebugClientInfo {
1154        payload: AllocatorSetDebugClientInfoRequest,
1155        control_handle: AllocatorControlHandle,
1156    },
1157    /// Given a handle to a sysmem-provided VMO, this returns additional info
1158    /// about the corresponding sysmem logical buffer.
1159    ///
1160    /// Most callers will duplicate a VMO handle first and send the duplicate to
1161    /// this call.
1162    ///
1163    /// If the client has created a child VMO of a sysmem-provided VMO, that
1164    /// child VMO isn't considered a "sysmem VMO" for purposes of this call.
1165    ///
1166    /// + request `vmo` A handle to a sysmem-provided VMO (or see errors).
1167    /// - response `buffer_collection_id` The buffer collection ID, which is
1168    ///   unique per logical buffer collection per boot.
1169    /// - response `buffer_index` The buffer index of the buffer within the
1170    ///   buffer collection. This is the same as the index of the buffer within
1171    ///   [`fuchsia.sysmem2/BufferCollectionInfo.buffers`]. The `buffer_index`
1172    ///   is the same for all sysmem-delivered VMOs corresponding to the same
1173    ///   logical buffer, even if the VMO koids differ. The `buffer_index` is
1174    ///   only unique across buffers of a buffer collection. For a given buffer,
1175    ///   the combination of `buffer_collection_id` and `buffer_index` is unique
1176    ///   per boot.
1177    /// - response `close_weak_asap` Iff `vmo` is a handle to a weak sysmem VMO,
1178    ///   the `close_weak_asap` field will be set in the response. This handle
1179    ///   will signal `ZX_EVENTPAIR_PEER_CLOSED` when all weak VMO handles to
1180    ///   the buffer should be closed as soon as possible. This is signalled
1181    ///   shortly after all strong sysmem VMOs to the buffer are closed
1182    ///   (including any held indirectly via strong `BufferCollectionToken` or
1183    ///   strong `BufferCollection`). Failure to close all weak sysmem VMO
1184    ///   handles to the buffer quickly upon `ZX_EVENTPAIR_PEER_CLOSED` is
1185    ///   considered a VMO leak caused by the client still holding a weak sysmem
1186    ///   VMO handle and results in loud complaints to the log by sysmem. The
1187    ///   buffers of a collection can be freed independently of each other. The
1188    ///   `ZX_EVENTPAIR_PEER_CLOSED` may already be signalled before the
1189    ///   response arrives at the client. A client that isn't prepared to handle
1190    ///   weak sysmem VMOs, on seeing this field set, can close all handles to
1191    ///   the buffer and fail any associated request.
1192    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` - the vmo isn't a sysmem
1193    ///   VMO. Both strong and weak sysmem VMOs can be passed to this call, and
1194    ///   the VMO handle passed in to this call itself keeps the VMO's info
1195    ///   alive for purposes of responding to this call. Because of this,
1196    ///   ZX_ERR_NOT_FOUND errors are unambiguous (even if there are no other
1197    ///   handles to the VMO when calling; even if other handles are closed
1198    ///   before the GetVmoInfo response arrives at the client).
1199    /// * error `[fuchsia.sysmem2/Error.HANDLE_ACCESS_DENIED]` The vmo isn't
1200    ///   capable of being used with GetVmoInfo due to rights/capability
1201    ///   attenuation. The VMO needs to be usable with [`zx_vmo_get_info`] with
1202    ///   topic [`ZX_INFO_HANDLE_BASIC`].
1203    /// * error `[fuchsia.sysmem2/Error.UNSPECIFIED]` The request failed for an
1204    ///   unspecified reason. See the log for more info.
1205    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The vmo field
1206    ///   wasn't set, or there was some other problem with the request field(s).
1207    GetVmoInfo { payload: AllocatorGetVmoInfoRequest, responder: AllocatorGetVmoInfoResponder },
1208    /// An interaction was received which does not match any known method.
1209    #[non_exhaustive]
1210    _UnknownMethod {
1211        /// Ordinal of the method that was called.
1212        ordinal: u64,
1213        control_handle: AllocatorControlHandle,
1214        method_type: fidl::MethodType,
1215    },
1216}
1217
1218impl AllocatorRequest {
1219    #[allow(irrefutable_let_patterns)]
1220    pub fn into_allocate_non_shared_collection(
1221        self,
1222    ) -> Option<(AllocatorAllocateNonSharedCollectionRequest, AllocatorControlHandle)> {
1223        if let AllocatorRequest::AllocateNonSharedCollection { payload, control_handle } = self {
1224            Some((payload, control_handle))
1225        } else {
1226            None
1227        }
1228    }
1229
1230    #[allow(irrefutable_let_patterns)]
1231    pub fn into_allocate_shared_collection(
1232        self,
1233    ) -> Option<(AllocatorAllocateSharedCollectionRequest, AllocatorControlHandle)> {
1234        if let AllocatorRequest::AllocateSharedCollection { payload, control_handle } = self {
1235            Some((payload, control_handle))
1236        } else {
1237            None
1238        }
1239    }
1240
1241    #[allow(irrefutable_let_patterns)]
1242    pub fn into_bind_shared_collection(
1243        self,
1244    ) -> Option<(AllocatorBindSharedCollectionRequest, AllocatorControlHandle)> {
1245        if let AllocatorRequest::BindSharedCollection { payload, control_handle } = self {
1246            Some((payload, control_handle))
1247        } else {
1248            None
1249        }
1250    }
1251
1252    #[allow(irrefutable_let_patterns)]
1253    pub fn into_validate_buffer_collection_token(
1254        self,
1255    ) -> Option<(
1256        AllocatorValidateBufferCollectionTokenRequest,
1257        AllocatorValidateBufferCollectionTokenResponder,
1258    )> {
1259        if let AllocatorRequest::ValidateBufferCollectionToken { payload, responder } = self {
1260            Some((payload, responder))
1261        } else {
1262            None
1263        }
1264    }
1265
1266    #[allow(irrefutable_let_patterns)]
1267    pub fn into_set_debug_client_info(
1268        self,
1269    ) -> Option<(AllocatorSetDebugClientInfoRequest, AllocatorControlHandle)> {
1270        if let AllocatorRequest::SetDebugClientInfo { payload, control_handle } = self {
1271            Some((payload, control_handle))
1272        } else {
1273            None
1274        }
1275    }
1276
1277    #[allow(irrefutable_let_patterns)]
1278    pub fn into_get_vmo_info(
1279        self,
1280    ) -> Option<(AllocatorGetVmoInfoRequest, AllocatorGetVmoInfoResponder)> {
1281        if let AllocatorRequest::GetVmoInfo { payload, responder } = self {
1282            Some((payload, responder))
1283        } else {
1284            None
1285        }
1286    }
1287
1288    /// Name of the method defined in FIDL
1289    pub fn method_name(&self) -> &'static str {
1290        match *self {
1291            AllocatorRequest::AllocateNonSharedCollection { .. } => {
1292                "allocate_non_shared_collection"
1293            }
1294            AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1295            AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1296            AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1297                "validate_buffer_collection_token"
1298            }
1299            AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1300            AllocatorRequest::GetVmoInfo { .. } => "get_vmo_info",
1301            AllocatorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1302                "unknown one-way method"
1303            }
1304            AllocatorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1305                "unknown two-way method"
1306            }
1307        }
1308    }
1309}
1310
1311#[derive(Debug, Clone)]
1312pub struct AllocatorControlHandle {
1313    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1314}
1315
1316impl fdomain_client::fidl::ControlHandle for AllocatorControlHandle {
1317    fn shutdown(&self) {
1318        self.inner.shutdown()
1319    }
1320
1321    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1322        self.inner.shutdown_with_epitaph(status)
1323    }
1324
1325    fn is_closed(&self) -> bool {
1326        self.inner.channel().is_closed()
1327    }
1328    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1329        self.inner.channel().on_closed()
1330    }
1331}
1332
1333impl AllocatorControlHandle {}
1334
1335#[must_use = "FIDL methods require a response to be sent"]
1336#[derive(Debug)]
1337pub struct AllocatorValidateBufferCollectionTokenResponder {
1338    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1339    tx_id: u32,
1340}
1341
1342/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1343/// if the responder is dropped without sending a response, so that the client
1344/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1345impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1346    fn drop(&mut self) {
1347        self.control_handle.shutdown();
1348        // Safety: drops once, never accessed again
1349        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1350    }
1351}
1352
1353impl fdomain_client::fidl::Responder for AllocatorValidateBufferCollectionTokenResponder {
1354    type ControlHandle = AllocatorControlHandle;
1355
1356    fn control_handle(&self) -> &AllocatorControlHandle {
1357        &self.control_handle
1358    }
1359
1360    fn drop_without_shutdown(mut self) {
1361        // Safety: drops once, never accessed again due to mem::forget
1362        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1363        // Prevent Drop from running (which would shut down the channel)
1364        std::mem::forget(self);
1365    }
1366}
1367
1368impl AllocatorValidateBufferCollectionTokenResponder {
1369    /// Sends a response to the FIDL transaction.
1370    ///
1371    /// Sets the channel to shutdown if an error occurs.
1372    pub fn send(
1373        self,
1374        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1375    ) -> Result<(), fidl::Error> {
1376        let _result = self.send_raw(payload);
1377        if _result.is_err() {
1378            self.control_handle.shutdown();
1379        }
1380        self.drop_without_shutdown();
1381        _result
1382    }
1383
1384    /// Similar to "send" but does not shutdown the channel if an error occurs.
1385    pub fn send_no_shutdown_on_err(
1386        self,
1387        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1388    ) -> Result<(), fidl::Error> {
1389        let _result = self.send_raw(payload);
1390        self.drop_without_shutdown();
1391        _result
1392    }
1393
1394    fn send_raw(
1395        &self,
1396        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1397    ) -> Result<(), fidl::Error> {
1398        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1399            AllocatorValidateBufferCollectionTokenResponse,
1400        >>(
1401            fidl::encoding::Flexible::new(payload),
1402            self.tx_id,
1403            0x4c5ee91b02a7e68d,
1404            fidl::encoding::DynamicFlags::FLEXIBLE,
1405        )
1406    }
1407}
1408
1409#[must_use = "FIDL methods require a response to be sent"]
1410#[derive(Debug)]
1411pub struct AllocatorGetVmoInfoResponder {
1412    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1413    tx_id: u32,
1414}
1415
1416/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1417/// if the responder is dropped without sending a response, so that the client
1418/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1419impl std::ops::Drop for AllocatorGetVmoInfoResponder {
1420    fn drop(&mut self) {
1421        self.control_handle.shutdown();
1422        // Safety: drops once, never accessed again
1423        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1424    }
1425}
1426
1427impl fdomain_client::fidl::Responder for AllocatorGetVmoInfoResponder {
1428    type ControlHandle = AllocatorControlHandle;
1429
1430    fn control_handle(&self) -> &AllocatorControlHandle {
1431        &self.control_handle
1432    }
1433
1434    fn drop_without_shutdown(mut self) {
1435        // Safety: drops once, never accessed again due to mem::forget
1436        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1437        // Prevent Drop from running (which would shut down the channel)
1438        std::mem::forget(self);
1439    }
1440}
1441
1442impl AllocatorGetVmoInfoResponder {
1443    /// Sends a response to the FIDL transaction.
1444    ///
1445    /// Sets the channel to shutdown if an error occurs.
1446    pub fn send(
1447        self,
1448        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1449    ) -> Result<(), fidl::Error> {
1450        let _result = self.send_raw(result);
1451        if _result.is_err() {
1452            self.control_handle.shutdown();
1453        }
1454        self.drop_without_shutdown();
1455        _result
1456    }
1457
1458    /// Similar to "send" but does not shutdown the channel if an error occurs.
1459    pub fn send_no_shutdown_on_err(
1460        self,
1461        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1462    ) -> Result<(), fidl::Error> {
1463        let _result = self.send_raw(result);
1464        self.drop_without_shutdown();
1465        _result
1466    }
1467
1468    fn send_raw(
1469        &self,
1470        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1471    ) -> Result<(), fidl::Error> {
1472        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1473            AllocatorGetVmoInfoResponse,
1474            Error,
1475        >>(
1476            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1477            self.tx_id,
1478            0x21a881120aa0ddf9,
1479            fidl::encoding::DynamicFlags::FLEXIBLE,
1480        )
1481    }
1482}
1483
1484#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1485pub struct BufferCollectionMarker;
1486
1487impl fdomain_client::fidl::ProtocolMarker for BufferCollectionMarker {
1488    type Proxy = BufferCollectionProxy;
1489    type RequestStream = BufferCollectionRequestStream;
1490
1491    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1492}
1493pub type BufferCollectionWaitForAllBuffersAllocatedResult =
1494    Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>;
1495pub type BufferCollectionCheckAllBuffersAllocatedResult = Result<(), Error>;
1496
1497pub trait BufferCollectionProxyInterface: Send + Sync {
1498    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1499    fn r#sync(&self) -> Self::SyncResponseFut;
1500    fn r#release(&self) -> Result<(), fidl::Error>;
1501    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
1502    fn r#set_debug_client_info(
1503        &self,
1504        payload: &NodeSetDebugClientInfoRequest,
1505    ) -> Result<(), fidl::Error>;
1506    fn r#set_debug_timeout_log_deadline(
1507        &self,
1508        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
1509    ) -> Result<(), fidl::Error>;
1510    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1511    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
1512        + Send;
1513    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1514    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1515        + Send;
1516    fn r#is_alternate_for(
1517        &self,
1518        payload: NodeIsAlternateForRequest,
1519    ) -> Self::IsAlternateForResponseFut;
1520    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
1521        + Send;
1522    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
1523    fn r#set_weak(&self) -> Result<(), fidl::Error>;
1524    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
1525    fn r#attach_node_tracking(
1526        &self,
1527        payload: NodeAttachNodeTrackingRequest,
1528    ) -> Result<(), fidl::Error>;
1529    fn r#set_constraints(
1530        &self,
1531        payload: BufferCollectionSetConstraintsRequest,
1532    ) -> Result<(), fidl::Error>;
1533    type WaitForAllBuffersAllocatedResponseFut: std::future::Future<
1534            Output = Result<BufferCollectionWaitForAllBuffersAllocatedResult, fidl::Error>,
1535        > + Send;
1536    fn r#wait_for_all_buffers_allocated(&self) -> Self::WaitForAllBuffersAllocatedResponseFut;
1537    type CheckAllBuffersAllocatedResponseFut: std::future::Future<
1538            Output = Result<BufferCollectionCheckAllBuffersAllocatedResult, fidl::Error>,
1539        > + Send;
1540    fn r#check_all_buffers_allocated(&self) -> Self::CheckAllBuffersAllocatedResponseFut;
1541    fn r#attach_token(
1542        &self,
1543        payload: BufferCollectionAttachTokenRequest,
1544    ) -> Result<(), fidl::Error>;
1545    fn r#attach_lifetime_tracking(
1546        &self,
1547        payload: BufferCollectionAttachLifetimeTrackingRequest,
1548    ) -> Result<(), fidl::Error>;
1549}
1550
1551#[derive(Debug, Clone)]
1552pub struct BufferCollectionProxy {
1553    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1554}
1555
1556impl fdomain_client::fidl::Proxy for BufferCollectionProxy {
1557    type Protocol = BufferCollectionMarker;
1558
1559    fn from_channel(inner: fdomain_client::Channel) -> Self {
1560        Self::new(inner)
1561    }
1562
1563    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1564        self.client.into_channel().map_err(|client| Self { client })
1565    }
1566
1567    fn as_channel(&self) -> &fdomain_client::Channel {
1568        self.client.as_channel()
1569    }
1570}
1571
1572impl BufferCollectionProxy {
1573    /// Create a new Proxy for fuchsia.sysmem2/BufferCollection.
1574    pub fn new(channel: fdomain_client::Channel) -> Self {
1575        let protocol_name =
1576            <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1577        Self { client: fidl::client::Client::new(channel, protocol_name) }
1578    }
1579
1580    /// Get a Stream of events from the remote end of the protocol.
1581    ///
1582    /// # Panics
1583    ///
1584    /// Panics if the event stream was already taken.
1585    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
1586        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
1587    }
1588
1589    /// Ensure that previous messages have been received server side. This is
1590    /// particularly useful after previous messages that created new tokens,
1591    /// because a token must be known to the sysmem server before sending the
1592    /// token to another participant.
1593    ///
1594    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
1595    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
1596    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
1597    /// to mitigate the possibility of a hostile/fake
1598    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
1599    /// Another way is to pass the token to
1600    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
1601    /// the token as part of exchanging it for a
1602    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
1603    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
1604    /// of stalling.
1605    ///
1606    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
1607    /// and then starting and completing a `Sync`, it's then safe to send the
1608    /// `BufferCollectionToken` client ends to other participants knowing the
1609    /// server will recognize the tokens when they're sent by the other
1610    /// participants to sysmem in a
1611    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
1612    /// efficient way to create tokens while avoiding unnecessary round trips.
1613    ///
1614    /// Other options include waiting for each
1615    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
1616    /// individually (using separate call to `Sync` after each), or calling
1617    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
1618    /// converted to a `BufferCollection` via
1619    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
1620    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
1621    /// the sync step and can create multiple tokens at once.
1622    pub fn r#sync(
1623        &self,
1624    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1625        BufferCollectionProxyInterface::r#sync(self)
1626    }
1627
1628    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
1629    ///
1630    /// Normally a participant will convert a `BufferCollectionToken` into a
1631    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
1632    /// `Release` via the token (and then close the channel immediately or
1633    /// shortly later in response to server closing the server end), which
1634    /// avoids causing buffer collection failure. Without a prior `Release`,
1635    /// closing the `BufferCollectionToken` client end will cause buffer
1636    /// collection failure.
1637    ///
1638    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
1639    ///
1640    /// By default the server handles unexpected closure of a
1641    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
1642    /// first) by failing the buffer collection. Partly this is to expedite
1643    /// closing VMO handles to reclaim memory when any participant fails. If a
1644    /// participant would like to cleanly close a `BufferCollection` without
1645    /// causing buffer collection failure, the participant can send `Release`
1646    /// before closing the `BufferCollection` client end. The `Release` can
1647    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
1648    /// buffer collection won't require constraints from this node in order to
1649    /// allocate. If after `SetConstraints`, the constraints are retained and
1650    /// aggregated, despite the lack of `BufferCollection` connection at the
1651    /// time of constraints aggregation.
1652    ///
1653    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
1654    ///
1655    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
1656    /// end (without `Release` first) will trigger failure of the buffer
1657    /// collection. To close a `BufferCollectionTokenGroup` channel without
1658    /// failing the buffer collection, ensure that AllChildrenPresent() has been
1659    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
1660    /// client end.
1661    ///
1662    /// If `Release` occurs before
1663    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
1664    /// buffer collection will fail (triggered by reception of `Release` without
1665    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
1666    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
1667    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
1668    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
1669    /// close requires `AllChildrenPresent` (if not already sent), then
1670    /// `Release`, then close client end.
1671    ///
1672    /// If `Release` occurs after `AllChildrenPresent`, the children and all
1673    /// their constraints remain intact (just as they would if the
1674    /// `BufferCollectionTokenGroup` channel had remained open), and the client
1675    /// end close doesn't trigger buffer collection failure.
1676    ///
1677    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
1678    ///
1679    /// For brevity, the per-channel-protocol paragraphs above ignore the
1680    /// separate failure domain created by
1681    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
1682    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
1683    /// unexpectedly closes (without `Release` first) and that client end is
1684    /// under a failure domain, instead of failing the whole buffer collection,
1685    /// the failure domain is failed, but the buffer collection itself is
1686    /// isolated from failure of the failure domain. Such failure domains can be
1687    /// nested, in which case only the inner-most failure domain in which the
1688    /// `Node` resides fails.
1689    pub fn r#release(&self) -> Result<(), fidl::Error> {
1690        BufferCollectionProxyInterface::r#release(self)
1691    }
1692
1693    /// Set a name for VMOs in this buffer collection.
1694    ///
1695    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
1696    /// will be truncated to fit. The name of the vmo will be suffixed with the
1697    /// buffer index within the collection (if the suffix fits within
1698    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
1699    /// listed in the inspect data.
1700    ///
1701    /// The name only affects VMOs allocated after the name is set; this call
1702    /// does not rename existing VMOs. If multiple clients set different names
1703    /// then the larger priority value will win. Setting a new name with the
1704    /// same priority as a prior name doesn't change the name.
1705    ///
1706    /// All table fields are currently required.
1707    ///
1708    /// + request `priority` The name is only set if this is the first `SetName`
1709    ///   or if `priority` is greater than any previous `priority` value in
1710    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
1711    /// + request `name` The name for VMOs created under this buffer collection.
1712    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
1713        BufferCollectionProxyInterface::r#set_name(self, payload)
1714    }
1715
1716    /// Set information about the current client that can be used by sysmem to
1717    /// help diagnose leaking memory and allocation stalls waiting for a
1718    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1719    ///
1720    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
1721    /// `Node`(s) derived from this `Node`, unless overriden by
1722    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
1723    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
1724    ///
1725    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
1726    /// `Allocator` is the most efficient way to ensure that all
1727    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
1728    /// set, and is also more efficient than separately sending the same debug
1729    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
1730    /// created [`fuchsia.sysmem2/Node`].
1731    ///
1732    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
1733    /// indicate which client is closing their channel first, leading to subtree
1734    /// failure (which can be normal if the purpose of the subtree is over, but
1735    /// if happening earlier than expected, the client-channel-specific name can
1736    /// help diagnose where the failure is first coming from, from sysmem's
1737    /// point of view).
1738    ///
1739    /// All table fields are currently required.
1740    ///
1741    /// + request `name` This can be an arbitrary string, but the current
1742    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
1743    /// + request `id` This can be an arbitrary id, but the current process ID
1744    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
1745    pub fn r#set_debug_client_info(
1746        &self,
1747        mut payload: &NodeSetDebugClientInfoRequest,
1748    ) -> Result<(), fidl::Error> {
1749        BufferCollectionProxyInterface::r#set_debug_client_info(self, payload)
1750    }
1751
1752    /// Sysmem logs a warning if sysmem hasn't seen
1753    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
1754    /// within 5 seconds after creation of a new collection.
1755    ///
1756    /// Clients can call this method to change when the log is printed. If
1757    /// multiple client set the deadline, it's unspecified which deadline will
1758    /// take effect.
1759    ///
1760    /// In most cases the default works well.
1761    ///
1762    /// All table fields are currently required.
1763    ///
1764    /// + request `deadline` The time at which sysmem will start trying to log
1765    ///   the warning, unless all constraints are with sysmem by then.
1766    pub fn r#set_debug_timeout_log_deadline(
1767        &self,
1768        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
1769    ) -> Result<(), fidl::Error> {
1770        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
1771    }
1772
1773    /// This enables verbose logging for the buffer collection.
1774    ///
1775    /// Verbose logging includes constraints set via
1776    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
1777    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
1778    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
1779    /// the tree of `Node`(s).
1780    ///
1781    /// Normally sysmem prints only a single line complaint when aggregation
1782    /// fails, with just the specific detailed reason that aggregation failed,
1783    /// with little surrounding context.  While this is often enough to diagnose
1784    /// a problem if only a small change was made and everything was working
1785    /// before the small change, it's often not particularly helpful for getting
1786    /// a new buffer collection to work for the first time.  Especially with
1787    /// more complex trees of nodes, involving things like
1788    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
1789    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
1790    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
1791    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
1792    /// looks like and why it's failing a logical allocation, or why a tree or
1793    /// subtree is failing sooner than expected.
1794    ///
1795    /// The intent of the extra logging is to be acceptable from a performance
1796    /// point of view, under the assumption that verbose logging is only enabled
1797    /// on a low number of buffer collections. If we're not tracking down a bug,
1798    /// we shouldn't send this message.
1799    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1800        BufferCollectionProxyInterface::r#set_verbose_logging(self)
1801    }
1802
1803    /// This gets a handle that can be used as a parameter to
1804    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
1805    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
1806    /// client obtained this handle from this `Node`.
1807    ///
1808    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
1809    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
1810    /// despite the two calls typically being on different channels.
1811    ///
1812    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
1813    ///
1814    /// All table fields are currently required.
1815    ///
1816    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
1817    ///   different `Node` channel, to prove that the client obtained the handle
1818    ///   from this `Node`.
1819    pub fn r#get_node_ref(
1820        &self,
1821    ) -> fidl::client::QueryResponseFut<
1822        NodeGetNodeRefResponse,
1823        fdomain_client::fidl::FDomainResourceDialect,
1824    > {
1825        BufferCollectionProxyInterface::r#get_node_ref(self)
1826    }
1827
1828    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
1829    /// rooted at a different child token of a common parent
1830    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
1831    /// passed-in `node_ref`.
1832    ///
1833    /// This call is for assisting with admission control de-duplication, and
1834    /// with debugging.
1835    ///
1836    /// The `node_ref` must be obtained using
1837    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
1838    ///
1839    /// The `node_ref` can be a duplicated handle; it's not necessary to call
1840    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
1841    ///
1842    /// If a calling token may not actually be a valid token at all due to a
1843    /// potentially hostile/untrusted provider of the token, call
1844    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
1845    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
1846    /// never responds due to a calling token not being a real token (not really
1847    /// talking to sysmem).  Another option is to call
1848    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
1849    /// which also validates the token along with converting it to a
1850    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
1851    ///
1852    /// All table fields are currently required.
1853    ///
1854    /// - response `is_alternate`
1855    ///   - true: The first parent node in common between the calling node and
1856    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
1857    ///     that the calling `Node` and the `node_ref` `Node` will not have both
1858    ///     their constraints apply - rather sysmem will choose one or the other
1859    ///     of the constraints - never both.  This is because only one child of
1860    ///     a `BufferCollectionTokenGroup` is selected during logical
1861    ///     allocation, with only that one child's subtree contributing to
1862    ///     constraints aggregation.
1863    ///   - false: The first parent node in common between the calling `Node`
1864    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
1865    ///     Currently, this means the first parent node in common is a
1866    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
1867    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
1868    ///     `Node` may have both their constraints apply during constraints
1869    ///     aggregation of the logical allocation, if both `Node`(s) are
1870    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
1871    ///     this case, there is no `BufferCollectionTokenGroup` that will
1872    ///     directly prevent the two `Node`(s) from both being selected and
1873    ///     their constraints both aggregated, but even when false, one or both
1874    ///     `Node`(s) may still be eliminated from consideration if one or both
1875    ///     `Node`(s) has a direct or indirect parent
1876    ///     `BufferCollectionTokenGroup` which selects a child subtree other
1877    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
1878    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
1879    ///   associated with the same buffer collection as the calling `Node`.
1880    ///   Another reason for this error is if the `node_ref` is an
1881    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
1882    ///   a real `node_ref` obtained from `GetNodeRef`.
1883    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
1884    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
1885    ///   the needed rights expected on a real `node_ref`.
1886    /// * No other failing status codes are returned by this call.  However,
1887    ///   sysmem may add additional codes in future, so the client should have
1888    ///   sensible default handling for any failing status code.
1889    pub fn r#is_alternate_for(
1890        &self,
1891        mut payload: NodeIsAlternateForRequest,
1892    ) -> fidl::client::QueryResponseFut<
1893        NodeIsAlternateForResult,
1894        fdomain_client::fidl::FDomainResourceDialect,
1895    > {
1896        BufferCollectionProxyInterface::r#is_alternate_for(self, payload)
1897    }
1898
1899    /// Get the buffer collection ID. This ID is also available from
1900    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
1901    /// within the collection).
1902    ///
1903    /// This call is mainly useful in situations where we can't convey a
1904    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
1905    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
1906    /// handle, which can be joined back up with a `BufferCollection` client end
1907    /// that was created via a different path. Prefer to convey a
1908    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
1909    ///
1910    /// Trusting a `buffer_collection_id` value from a source other than sysmem
1911    /// is analogous to trusting a koid value from a source other than zircon.
1912    /// Both should be avoided unless really necessary, and both require
1913    /// caution. In some situations it may be reasonable to refer to a
1914    /// pre-established `BufferCollection` by `buffer_collection_id` via a
1915    /// protocol for efficiency reasons, but an incoming value purporting to be
1916    /// a `buffer_collection_id` is not sufficient alone to justify granting the
1917    /// sender of the `buffer_collection_id` any capability. The sender must
1918    /// first prove to a receiver that the sender has/had a VMO or has/had a
1919    /// `BufferCollectionToken` to the same collection by sending a handle that
1920    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
1921    /// `buffer_collection_id` value. The receiver should take care to avoid
1922    /// assuming that a sender had a `BufferCollectionToken` in cases where the
1923    /// sender has only proven that the sender had a VMO.
1924    ///
1925    /// - response `buffer_collection_id` This ID is unique per buffer
1926    ///   collection per boot. Each buffer is uniquely identified by the
1927    ///   `buffer_collection_id` and `buffer_index` together.
1928    pub fn r#get_buffer_collection_id(
1929        &self,
1930    ) -> fidl::client::QueryResponseFut<
1931        NodeGetBufferCollectionIdResponse,
1932        fdomain_client::fidl::FDomainResourceDialect,
1933    > {
1934        BufferCollectionProxyInterface::r#get_buffer_collection_id(self)
1935    }
1936
1937    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
1938    /// created after this message to weak, which means that a client's `Node`
1939    /// client end (or a child created after this message) is not alone
1940    /// sufficient to keep allocated VMOs alive.
1941    ///
1942    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
1943    /// `close_weak_asap`.
1944    ///
1945    /// This message is only permitted before the `Node` becomes ready for
1946    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
1947    ///   * `BufferCollectionToken`: any time
1948    ///   * `BufferCollection`: before `SetConstraints`
1949    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
1950    ///
1951    /// Currently, no conversion from strong `Node` to weak `Node` after ready
1952    /// for allocation is provided, but a client can simulate that by creating
1953    /// an additional `Node` before allocation and setting that additional
1954    /// `Node` to weak, and then potentially at some point later sending
1955    /// `Release` and closing the client end of the client's strong `Node`, but
1956    /// keeping the client's weak `Node`.
1957    ///
1958    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
1959    /// collection failure (all `Node` client end(s) will see
1960    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
1961    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
1962    /// this situation until all `Node`(s) are ready for allocation. For initial
1963    /// allocation to succeed, at least one strong `Node` is required to exist
1964    /// at allocation time, but after that client receives VMO handles, that
1965    /// client can `BufferCollection.Release` and close the client end without
1966    /// causing this type of failure.
1967    ///
1968    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
1969    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
1970    /// separately as appropriate.
1971    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
1972        BufferCollectionProxyInterface::r#set_weak(self)
1973    }
1974
1975    /// This indicates to sysmem that the client is prepared to pay attention to
1976    /// `close_weak_asap`.
1977    ///
1978    /// If sent, this message must be before
1979    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
1980    ///
1981    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
1982    /// send this message before `WaitForAllBuffersAllocated`, or a parent
1983    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
1984    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
1985    /// trigger buffer collection failure.
1986    ///
1987    /// This message is necessary because weak sysmem VMOs have not always been
1988    /// a thing, so older clients are not aware of the need to pay attention to
1989    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
1990    /// sysmem weak VMO handles asap. By having this message and requiring
1991    /// participants to indicate their acceptance of this aspect of the overall
1992    /// protocol, we avoid situations where an older client is delivered a weak
1993    /// VMO without any way for sysmem to get that VMO to close quickly later
1994    /// (and on a per-buffer basis).
1995    ///
1996    /// A participant that doesn't handle `close_weak_asap` and also doesn't
1997    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
1998    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
1999    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
2000    /// same participant has a child/delegate which does retrieve VMOs, that
2001    /// child/delegate will need to send `SetWeakOk` before
2002    /// `WaitForAllBuffersAllocated`.
2003    ///
2004    /// + request `for_child_nodes_also` If present and true, this means direct
2005    ///   child nodes of this node created after this message plus all
2006    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
2007    ///   those nodes. Any child node of this node that was created before this
2008    ///   message is not included. This setting is "sticky" in the sense that a
2009    ///   subsequent `SetWeakOk` without this bool set to true does not reset
2010    ///   the server-side bool. If this creates a problem for a participant, a
2011    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
2012    ///   tokens instead, as appropriate. A participant should only set
2013    ///   `for_child_nodes_also` true if the participant can really promise to
2014    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
2015    ///   weak VMO handles held by participants holding the corresponding child
2016    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
2017    ///   which are using sysmem(1) can be weak, despite the clients of those
2018    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
2019    ///   direct way to find out about `close_weak_asap`. This only applies to
2020    ///   descendents of this `Node` which are using sysmem(1), not to this
2021    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
2022    ///   token, which will fail allocation unless an ancestor of this `Node`
2023    ///   specified `for_child_nodes_also` true.
2024    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
2025        BufferCollectionProxyInterface::r#set_weak_ok(self, payload)
2026    }
2027
2028    /// The server_end will be closed after this `Node` and any child nodes have
2029    /// have released their buffer counts, making those counts available for
2030    /// reservation by a different `Node` via
2031    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
2032    ///
2033    /// The `Node` buffer counts may not be released until the entire tree of
2034    /// `Node`(s) is closed or failed, because
2035    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
2036    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
2037    /// `Node` buffer counts remain reserved until the orphaned node is later
2038    /// cleaned up.
2039    ///
2040    /// If the `Node` exceeds a fairly large number of attached eventpair server
2041    /// ends, a log message will indicate this and the `Node` (and the
2042    /// appropriate) sub-tree will fail.
2043    ///
2044    /// The `server_end` will remain open when
2045    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
2046    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
2047    /// [`fuchsia.sysmem2/BufferCollection`].
2048    ///
2049    /// This message can also be used with a
2050    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
2051    pub fn r#attach_node_tracking(
2052        &self,
2053        mut payload: NodeAttachNodeTrackingRequest,
2054    ) -> Result<(), fidl::Error> {
2055        BufferCollectionProxyInterface::r#attach_node_tracking(self, payload)
2056    }
2057
2058    /// Provide [`fuchsia.sysmem2/BufferCollectionConstraints`] to the buffer
2059    /// collection.
2060    ///
2061    /// A participant may only call
2062    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] up to once per
2063    /// [`fuchsia.sysmem2/BufferCollection`].
2064    ///
2065    /// For buffer allocation to be attempted, all holders of a
2066    /// `BufferCollection` client end need to call `SetConstraints` before
2067    /// sysmem will attempt to allocate buffers.
2068    ///
2069    /// + request `constraints` These are the constraints on the buffer
2070    ///   collection imposed by the sending client/participant.  The
2071    ///   `constraints` field is not required to be set. If not set, the client
2072    ///   is not setting any actual constraints, but is indicating that the
2073    ///   client has no constraints to set. A client that doesn't set the
2074    ///   `constraints` field won't receive any VMO handles, but can still find
2075    ///   out how many buffers were allocated and can still refer to buffers by
2076    ///   their `buffer_index`.
2077    pub fn r#set_constraints(
2078        &self,
2079        mut payload: BufferCollectionSetConstraintsRequest,
2080    ) -> Result<(), fidl::Error> {
2081        BufferCollectionProxyInterface::r#set_constraints(self, payload)
2082    }
2083
2084    /// Wait until all buffers are allocated.
2085    ///
2086    /// This FIDL call completes when buffers have been allocated, or completes
2087    /// with some failure detail if allocation has been attempted but failed.
2088    ///
2089    /// The following must occur before buffers will be allocated:
2090    ///   * All [`fuchsia.sysmem2/BufferCollectionToken`](s) of the buffer
2091    ///     collection must be turned in via `BindSharedCollection` to get a
2092    ///     [`fuchsia.sysmem2/BufferCollection`] (for brevity, this is assuming
2093    ///     [`fuchsia.sysmem2/BufferCollection.AttachToken`] isn't being used),
2094    ///     or have had [`fuchsia.sysmem2/BufferCollectionToken.Release`] sent
2095    ///     to them.
2096    ///   * All [`fuchsia.sysmem2/BufferCollection`](s) of the buffer collection
2097    ///     must have had [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
2098    ///     sent to them, or had [`fuchsia.sysmem2/BufferCollection.Release`]
2099    ///     sent to them.
2100    ///
2101    /// - result `buffer_collection_info` The VMO handles and other related
2102    ///   info.
2103    /// * error `[fuchsia.sysmem2/Error.NO_MEMORY]` The request is valid but
2104    ///   cannot be fulfilled due to resource exhaustion.
2105    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION`] The request is
2106    ///   malformed.
2107    /// * error `[fuchsia.sysmem2/Error.CONSTRAINTS_INTERSECTION_EMPTY`] The
2108    ///   request is valid but cannot be satisfied, perhaps due to hardware
2109    ///   limitations. This can happen if participants have incompatible
2110    ///   constraints (empty intersection, roughly speaking). See the log for
2111    ///   more info. In cases where a participant could potentially be treated
2112    ///   as optional, see [`BufferCollectionTokenGroup`]. When using
2113    ///   [`fuchsia.sysmem2/BufferCollection.AttachToken`], this will be the
2114    ///   error code if there aren't enough buffers in the pre-existing
2115    ///   collection to satisfy the constraints set on the attached token and
2116    ///   any sub-tree of tokens derived from the attached token.
2117    pub fn r#wait_for_all_buffers_allocated(
2118        &self,
2119    ) -> fidl::client::QueryResponseFut<
2120        BufferCollectionWaitForAllBuffersAllocatedResult,
2121        fdomain_client::fidl::FDomainResourceDialect,
2122    > {
2123        BufferCollectionProxyInterface::r#wait_for_all_buffers_allocated(self)
2124    }
2125
2126    /// Checks whether all the buffers have been allocated, in a polling
2127    /// fashion.
2128    ///
2129    /// * If the buffer collection has been allocated, returns success.
2130    /// * If the buffer collection failed allocation, returns the same
2131    ///   [`fuchsia.sysmem2/Error`] as
2132    ///   [`fuchsia.sysmem2/BufferCollection/WaitForAllBuffersAllocated`] would
2133    ///   return.
2134    /// * error [`fuchsia.sysmem2/Error.PENDING`] The buffer collection hasn't
2135    ///   attempted allocation yet. This means that WaitForAllBuffersAllocated
2136    ///   would not respond quickly.
2137    pub fn r#check_all_buffers_allocated(
2138        &self,
2139    ) -> fidl::client::QueryResponseFut<
2140        BufferCollectionCheckAllBuffersAllocatedResult,
2141        fdomain_client::fidl::FDomainResourceDialect,
2142    > {
2143        BufferCollectionProxyInterface::r#check_all_buffers_allocated(self)
2144    }
2145
2146    /// Create a new token to add a new participant to an existing logical
2147    /// buffer collection, if the existing collection's buffer counts,
2148    /// constraints, and participants allow.
2149    ///
2150    /// This can be useful in replacing a failed participant, and/or in
2151    /// adding/re-adding a participant after buffers have already been
2152    /// allocated.
2153    ///
2154    /// When [`fuchsia.sysmem2/BufferCollection.AttachToken`] is used, the sub
2155    /// tree rooted at the attached [`fuchsia.sysmem2/BufferCollectionToken`]
2156    /// goes through the normal procedure of setting constraints or closing
2157    /// [`fuchsia.sysmem2/Node`](s), and then appearing to allocate buffers from
2158    /// clients' point of view, despite the possibility that all the buffers
2159    /// were actually allocated previously. This process is called "logical
2160    /// allocation". Most instances of "allocation" in docs for other messages
2161    /// can also be read as "allocation or logical allocation" while remaining
2162    /// valid, but we just say "allocation" in most places for brevity/clarity
2163    /// of explanation, with the details of "logical allocation" left for the
2164    /// docs here on `AttachToken`.
2165    ///
2166    /// Failure of an attached `Node` does not propagate to the parent of the
2167    /// attached `Node`. More generally, failure of a child `Node` is blocked
2168    /// from reaching its parent `Node` if the child is attached, or if the
2169    /// child is dispensable and the failure occurred after logical allocation
2170    /// (see [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`]).
2171    ///
2172    /// A participant may in some scenarios choose to initially use a
2173    /// dispensable token for a given instance of a delegate participant, and
2174    /// then later if the first instance of that delegate participant fails, a
2175    /// new second instance of that delegate participant my be given a token
2176    /// created with `AttachToken`.
2177    ///
2178    /// From the point of view of the [`fuchsia.sysmem2/BufferCollectionToken`]
2179    /// client end, the token acts like any other token. The client can
2180    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] the token as needed,
2181    /// and can send the token to a different process/participant. The
2182    /// `BufferCollectionToken` `Node` should be converted to a
2183    /// `BufferCollection` `Node` as normal by sending
2184    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or can be closed
2185    /// without causing subtree failure by sending
2186    /// [`fuchsia.sysmem2/BufferCollectionToken.Release`]. Assuming the former,
2187    /// the [`fuchsia.sysmem2/BufferCollection.SetConstraints`] message or
2188    /// [`fuchsia.sysmem2/BufferCollection.Release`] message should be sent to
2189    /// the `BufferCollection`.
2190    ///
2191    /// Within the subtree, a success result from
2192    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] means
2193    /// the subtree participants' constraints were satisfiable using the
2194    /// already-existing buffer collection, the already-established
2195    /// [`fuchsia.sysmem2/BufferCollectionInfo`] including image format
2196    /// constraints, and the already-existing other participants (already added
2197    /// via successful logical allocation) and their specified buffer counts in
2198    /// their constraints. A failure result means the new participants'
2199    /// constraints cannot be satisfied using the existing buffer collection and
2200    /// its already-added participants. Creating a new collection instead may
2201    /// allow all participants' constraints to be satisfied, assuming
2202    /// `SetDispensable` is used in place of `AttachToken`, or a normal token is
2203    /// used.
2204    ///
2205    /// A token created with `AttachToken` performs constraints aggregation with
2206    /// all constraints currently in effect on the buffer collection, plus the
2207    /// attached token under consideration plus child tokens under the attached
2208    /// token which are not themselves an attached token or under such a token.
2209    /// Further subtrees under this subtree are considered for logical
2210    /// allocation only after this subtree has completed logical allocation.
2211    ///
2212    /// Assignment of existing buffers to participants'
2213    /// [`fuchsia.sysmem2/BufferCollectionConstraints.min_buffer_count_for_camping`]
2214    /// etc is first-come first-served, but a child can't logically allocate
2215    /// before all its parents have sent `SetConstraints`.
2216    ///
2217    /// See also [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`], which
2218    /// in contrast to `AttachToken`, has the created token `Node` + child
2219    /// `Node`(s) (in the created subtree but not in any subtree under this
2220    /// subtree) participate in constraints aggregation along with its parent
2221    /// during the parent's allocation or logical allocation.
2222    ///
2223    /// Similar to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], the
2224    /// newly created token needs to be [`fuchsia.sysmem2/Node.Sync`]ed to
2225    /// sysmem before the new token can be passed to `BindSharedCollection`. The
2226    /// `Sync` of the new token can be accomplished with
2227    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after converting the created
2228    /// `BufferCollectionToken` to a `BufferCollection`. Alternately,
2229    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on the new token also
2230    /// works. Or using [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`]
2231    /// works. As usual, a `BufferCollectionToken.Sync` can be started after any
2232    /// `BufferCollectionToken.Duplicate` messages have been sent via the newly
2233    /// created token, to also sync those additional tokens to sysmem using a
2234    /// single round-trip.
2235    ///
2236    /// All table fields are currently required.
2237    ///
2238    /// + request `rights_attentuation_mask` This allows attenuating the VMO
2239    ///   rights of the subtree. These values for `rights_attenuation_mask`
2240    ///   result in no attenuation (note that 0 is not on this list):
2241    ///   + ZX_RIGHT_SAME_RIGHTS (preferred)
2242    ///   + 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2243    /// + request `token_request` The server end of the `BufferCollectionToken`
2244    ///   channel. The client retains the client end.
2245    pub fn r#attach_token(
2246        &self,
2247        mut payload: BufferCollectionAttachTokenRequest,
2248    ) -> Result<(), fidl::Error> {
2249        BufferCollectionProxyInterface::r#attach_token(self, payload)
2250    }
2251
2252    /// Set up an eventpair to be signalled (`ZX_EVENTPAIR_PEER_CLOSED`) when
2253    /// buffers have been allocated and only the specified number of buffers (or
2254    /// fewer) remain in the buffer collection.
2255    ///
2256    /// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] allows a
2257    /// client to wait until an old buffer collection is fully or mostly
2258    /// deallocated before attempting allocation of a new buffer collection. The
2259    /// eventpair is only signalled when the buffers of this collection have
2260    /// been fully deallocated (not just un-referenced by clients, but all the
2261    /// memory consumed by those buffers has been fully reclaimed/recycled), or
2262    /// when allocation or logical allocation fails for the tree or subtree
2263    /// including this [`fuchsia.sysmem2/BufferCollection`].
2264    ///
2265    /// The eventpair won't be signalled until allocation or logical allocation
2266    /// has completed; until then, the collection's current buffer count is
2267    /// ignored.
2268    ///
2269    /// If logical allocation fails for an attached subtree (using
2270    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]), the server end of the
2271    /// eventpair will close during that failure regardless of the number of
2272    /// buffers potenitally allocated in the overall buffer collection. This is
2273    /// for logical allocation consistency with normal allocation.
2274    ///
2275    /// The lifetime signalled by this event includes asynchronous cleanup of
2276    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2277    /// holders of VMO handles to the buffers have closed those VMO handles.
2278    /// Therefore, clients should take care not to become blocked forever
2279    /// waiting for `ZX_EVENTPAIR_PEER_CLOSED` to be signalled if any of the
2280    /// participants using the logical buffer collection (including the waiter
2281    /// itself) are less trusted, less reliable, or potentially blocked by the
2282    /// wait itself. Waiting asynchronously is recommended. Setting a deadline
2283    /// for the client wait may be prudent, depending on details of how the
2284    /// collection and/or its VMOs are used or shared. Failure to allocate a
2285    /// new/replacement buffer collection is better than getting stuck forever.
2286    ///
2287    /// The sysmem server itself intentionally does not perform any waiting on
2288    /// already-failed collections' VMOs to finish cleaning up before attempting
2289    /// a new allocation, and the sysmem server intentionally doesn't retry
2290    /// allocation if a new allocation fails due to out of memory, even if that
2291    /// failure is potentially due to continued existence of an old collection's
2292    /// VMOs. This `AttachLifetimeTracking` message is how an initiator can
2293    /// mitigate too much overlap of old VMO lifetimes with new VMO lifetimes,
2294    /// as long as the waiting client is careful to not create a deadlock.
2295    ///
2296    /// Continued existence of old collections that are still cleaning up is not
2297    /// the only reason that a new allocation may fail due to insufficient
2298    /// memory, even if the new allocation is allocating physically contiguous
2299    /// buffers. Overall system memory pressure can also be the cause of failure
2300    /// to allocate a new collection. See also
2301    /// [`fuchsia.memorypressure/Provider`].
2302    ///
2303    /// `AttachLifetimeTracking` is meant to be compatible with other protocols
2304    /// with a similar `AttachLifetimeTracking` message; duplicates of the same
2305    /// `eventpair` handle (server end) can be sent via more than one
2306    /// `AttachLifetimeTracking` message to different protocols, and the
2307    /// `ZX_EVENTPAIR_PEER_CLOSED` will be signalled for the client end when all
2308    /// the conditions are met (all holders of duplicates have closed their
2309    /// server end handle(s)). Also, thanks to how eventpair endponts work, the
2310    /// client end can (also) be duplicated without preventing the
2311    /// `ZX_EVENTPAIR_PEER_CLOSED` signal.
2312    ///
2313    /// The server intentionally doesn't "trust" any signals set on the
2314    /// `server_end`. This mechanism intentionally uses only
2315    /// `ZX_EVENTPAIR_PEER_CLOSED` set on the client end, which can't be set
2316    /// "early", and is only set when all handles to the server end eventpair
2317    /// are closed. No meaning is associated with any of the other signals, and
2318    /// clients should ignore any other signal bits on either end of the
2319    /// `eventpair`.
2320    ///
2321    /// The `server_end` may lack `ZX_RIGHT_SIGNAL` or `ZX_RIGHT_SIGNAL_PEER`,
2322    /// but must have `ZX_RIGHT_DUPLICATE` (and must have `ZX_RIGHT_TRANSFER` to
2323    /// transfer without causing `BufferCollection` channel failure).
2324    ///
2325    /// All table fields are currently required.
2326    ///
2327    /// + request `server_end` This eventpair handle will be closed by the
2328    ///   sysmem server when buffers have been allocated initially and the
2329    ///   number of buffers is then less than or equal to `buffers_remaining`.
2330    /// + request `buffers_remaining` Wait for all but `buffers_remaining` (or
2331    ///   fewer) buffers to be fully deallocated. A number greater than zero can
2332    ///   be useful in situations where a known number of buffers are
2333    ///   intentionally not closed so that the data can continue to be used,
2334    ///   such as for keeping the last available video frame displayed in the UI
2335    ///   even if the video stream was using protected output buffers. It's
2336    ///   outside the scope of the `BufferCollection` interface (at least for
2337    ///   now) to determine how many buffers may be held without closing, but
2338    ///   it'll typically be in the range 0-2.
2339    pub fn r#attach_lifetime_tracking(
2340        &self,
2341        mut payload: BufferCollectionAttachLifetimeTrackingRequest,
2342    ) -> Result<(), fidl::Error> {
2343        BufferCollectionProxyInterface::r#attach_lifetime_tracking(self, payload)
2344    }
2345}
2346
2347impl BufferCollectionProxyInterface for BufferCollectionProxy {
2348    type SyncResponseFut =
2349        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2350    fn r#sync(&self) -> Self::SyncResponseFut {
2351        fn _decode(
2352            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2353        ) -> Result<(), fidl::Error> {
2354            let _response = fidl::client::decode_transaction_body::<
2355                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2356                fdomain_client::fidl::FDomainResourceDialect,
2357                0x11ac2555cf575b54,
2358            >(_buf?)?
2359            .into_result_fdomain::<BufferCollectionMarker>("sync")?;
2360            Ok(_response)
2361        }
2362        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2363            (),
2364            0x11ac2555cf575b54,
2365            fidl::encoding::DynamicFlags::FLEXIBLE,
2366            _decode,
2367        )
2368    }
2369
2370    fn r#release(&self) -> Result<(), fidl::Error> {
2371        self.client.send::<fidl::encoding::EmptyPayload>(
2372            (),
2373            0x6a5cae7d6d6e04c6,
2374            fidl::encoding::DynamicFlags::FLEXIBLE,
2375        )
2376    }
2377
2378    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
2379        self.client.send::<NodeSetNameRequest>(
2380            payload,
2381            0xb41f1624f48c1e9,
2382            fidl::encoding::DynamicFlags::FLEXIBLE,
2383        )
2384    }
2385
2386    fn r#set_debug_client_info(
2387        &self,
2388        mut payload: &NodeSetDebugClientInfoRequest,
2389    ) -> Result<(), fidl::Error> {
2390        self.client.send::<NodeSetDebugClientInfoRequest>(
2391            payload,
2392            0x5cde8914608d99b1,
2393            fidl::encoding::DynamicFlags::FLEXIBLE,
2394        )
2395    }
2396
2397    fn r#set_debug_timeout_log_deadline(
2398        &self,
2399        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
2400    ) -> Result<(), fidl::Error> {
2401        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
2402            payload,
2403            0x716b0af13d5c0806,
2404            fidl::encoding::DynamicFlags::FLEXIBLE,
2405        )
2406    }
2407
2408    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2409        self.client.send::<fidl::encoding::EmptyPayload>(
2410            (),
2411            0x5209c77415b4dfad,
2412            fidl::encoding::DynamicFlags::FLEXIBLE,
2413        )
2414    }
2415
2416    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
2417        NodeGetNodeRefResponse,
2418        fdomain_client::fidl::FDomainResourceDialect,
2419    >;
2420    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
2421        fn _decode(
2422            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2423        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
2424            let _response = fidl::client::decode_transaction_body::<
2425                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
2426                fdomain_client::fidl::FDomainResourceDialect,
2427                0x5b3d0e51614df053,
2428            >(_buf?)?
2429            .into_result_fdomain::<BufferCollectionMarker>("get_node_ref")?;
2430            Ok(_response)
2431        }
2432        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
2433            (),
2434            0x5b3d0e51614df053,
2435            fidl::encoding::DynamicFlags::FLEXIBLE,
2436            _decode,
2437        )
2438    }
2439
2440    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
2441        NodeIsAlternateForResult,
2442        fdomain_client::fidl::FDomainResourceDialect,
2443    >;
2444    fn r#is_alternate_for(
2445        &self,
2446        mut payload: NodeIsAlternateForRequest,
2447    ) -> Self::IsAlternateForResponseFut {
2448        fn _decode(
2449            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2450        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
2451            let _response = fidl::client::decode_transaction_body::<
2452                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
2453                fdomain_client::fidl::FDomainResourceDialect,
2454                0x3a58e00157e0825,
2455            >(_buf?)?
2456            .into_result_fdomain::<BufferCollectionMarker>("is_alternate_for")?;
2457            Ok(_response.map(|x| x))
2458        }
2459        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
2460            &mut payload,
2461            0x3a58e00157e0825,
2462            fidl::encoding::DynamicFlags::FLEXIBLE,
2463            _decode,
2464        )
2465    }
2466
2467    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
2468        NodeGetBufferCollectionIdResponse,
2469        fdomain_client::fidl::FDomainResourceDialect,
2470    >;
2471    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
2472        fn _decode(
2473            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2474        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
2475            let _response = fidl::client::decode_transaction_body::<
2476                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
2477                fdomain_client::fidl::FDomainResourceDialect,
2478                0x77d19a494b78ba8c,
2479            >(_buf?)?
2480            .into_result_fdomain::<BufferCollectionMarker>("get_buffer_collection_id")?;
2481            Ok(_response)
2482        }
2483        self.client.send_query_and_decode::<
2484            fidl::encoding::EmptyPayload,
2485            NodeGetBufferCollectionIdResponse,
2486        >(
2487            (),
2488            0x77d19a494b78ba8c,
2489            fidl::encoding::DynamicFlags::FLEXIBLE,
2490            _decode,
2491        )
2492    }
2493
2494    fn r#set_weak(&self) -> Result<(), fidl::Error> {
2495        self.client.send::<fidl::encoding::EmptyPayload>(
2496            (),
2497            0x22dd3ea514eeffe1,
2498            fidl::encoding::DynamicFlags::FLEXIBLE,
2499        )
2500    }
2501
2502    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
2503        self.client.send::<NodeSetWeakOkRequest>(
2504            &mut payload,
2505            0x38a44fc4d7724be9,
2506            fidl::encoding::DynamicFlags::FLEXIBLE,
2507        )
2508    }
2509
2510    fn r#attach_node_tracking(
2511        &self,
2512        mut payload: NodeAttachNodeTrackingRequest,
2513    ) -> Result<(), fidl::Error> {
2514        self.client.send::<NodeAttachNodeTrackingRequest>(
2515            &mut payload,
2516            0x3f22f2a293d3cdac,
2517            fidl::encoding::DynamicFlags::FLEXIBLE,
2518        )
2519    }
2520
2521    fn r#set_constraints(
2522        &self,
2523        mut payload: BufferCollectionSetConstraintsRequest,
2524    ) -> Result<(), fidl::Error> {
2525        self.client.send::<BufferCollectionSetConstraintsRequest>(
2526            &mut payload,
2527            0x1fde0f19d650197b,
2528            fidl::encoding::DynamicFlags::FLEXIBLE,
2529        )
2530    }
2531
2532    type WaitForAllBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2533        BufferCollectionWaitForAllBuffersAllocatedResult,
2534        fdomain_client::fidl::FDomainResourceDialect,
2535    >;
2536    fn r#wait_for_all_buffers_allocated(&self) -> Self::WaitForAllBuffersAllocatedResponseFut {
2537        fn _decode(
2538            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2539        ) -> Result<BufferCollectionWaitForAllBuffersAllocatedResult, fidl::Error> {
2540            let _response = fidl::client::decode_transaction_body::<
2541                fidl::encoding::FlexibleResultType<
2542                    BufferCollectionWaitForAllBuffersAllocatedResponse,
2543                    Error,
2544                >,
2545                fdomain_client::fidl::FDomainResourceDialect,
2546                0x62300344b61404e,
2547            >(_buf?)?
2548            .into_result_fdomain::<BufferCollectionMarker>("wait_for_all_buffers_allocated")?;
2549            Ok(_response.map(|x| x))
2550        }
2551        self.client.send_query_and_decode::<
2552            fidl::encoding::EmptyPayload,
2553            BufferCollectionWaitForAllBuffersAllocatedResult,
2554        >(
2555            (),
2556            0x62300344b61404e,
2557            fidl::encoding::DynamicFlags::FLEXIBLE,
2558            _decode,
2559        )
2560    }
2561
2562    type CheckAllBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2563        BufferCollectionCheckAllBuffersAllocatedResult,
2564        fdomain_client::fidl::FDomainResourceDialect,
2565    >;
2566    fn r#check_all_buffers_allocated(&self) -> Self::CheckAllBuffersAllocatedResponseFut {
2567        fn _decode(
2568            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2569        ) -> Result<BufferCollectionCheckAllBuffersAllocatedResult, fidl::Error> {
2570            let _response = fidl::client::decode_transaction_body::<
2571                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2572                fdomain_client::fidl::FDomainResourceDialect,
2573                0x35a5fe77ce939c10,
2574            >(_buf?)?
2575            .into_result_fdomain::<BufferCollectionMarker>("check_all_buffers_allocated")?;
2576            Ok(_response.map(|x| x))
2577        }
2578        self.client.send_query_and_decode::<
2579            fidl::encoding::EmptyPayload,
2580            BufferCollectionCheckAllBuffersAllocatedResult,
2581        >(
2582            (),
2583            0x35a5fe77ce939c10,
2584            fidl::encoding::DynamicFlags::FLEXIBLE,
2585            _decode,
2586        )
2587    }
2588
2589    fn r#attach_token(
2590        &self,
2591        mut payload: BufferCollectionAttachTokenRequest,
2592    ) -> Result<(), fidl::Error> {
2593        self.client.send::<BufferCollectionAttachTokenRequest>(
2594            &mut payload,
2595            0x46ac7d0008492982,
2596            fidl::encoding::DynamicFlags::FLEXIBLE,
2597        )
2598    }
2599
2600    fn r#attach_lifetime_tracking(
2601        &self,
2602        mut payload: BufferCollectionAttachLifetimeTrackingRequest,
2603    ) -> Result<(), fidl::Error> {
2604        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2605            &mut payload,
2606            0x3ecb510113116dcf,
2607            fidl::encoding::DynamicFlags::FLEXIBLE,
2608        )
2609    }
2610}
2611
2612pub struct BufferCollectionEventStream {
2613    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2614}
2615
2616impl std::marker::Unpin for BufferCollectionEventStream {}
2617
2618impl futures::stream::FusedStream for BufferCollectionEventStream {
2619    fn is_terminated(&self) -> bool {
2620        self.event_receiver.is_terminated()
2621    }
2622}
2623
2624impl futures::Stream for BufferCollectionEventStream {
2625    type Item = Result<BufferCollectionEvent, fidl::Error>;
2626
2627    fn poll_next(
2628        mut self: std::pin::Pin<&mut Self>,
2629        cx: &mut std::task::Context<'_>,
2630    ) -> std::task::Poll<Option<Self::Item>> {
2631        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2632            &mut self.event_receiver,
2633            cx
2634        )?) {
2635            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
2636            None => std::task::Poll::Ready(None),
2637        }
2638    }
2639}
2640
2641#[derive(Debug)]
2642pub enum BufferCollectionEvent {
2643    #[non_exhaustive]
2644    _UnknownEvent {
2645        /// Ordinal of the event that was sent.
2646        ordinal: u64,
2647    },
2648}
2649
2650impl BufferCollectionEvent {
2651    /// Decodes a message buffer as a [`BufferCollectionEvent`].
2652    fn decode(
2653        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2654    ) -> Result<BufferCollectionEvent, fidl::Error> {
2655        let (bytes, _handles) = buf.split_mut();
2656        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2657        debug_assert_eq!(tx_header.tx_id, 0);
2658        match tx_header.ordinal {
2659            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2660                Ok(BufferCollectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2661            }
2662            _ => Err(fidl::Error::UnknownOrdinal {
2663                ordinal: tx_header.ordinal,
2664                protocol_name:
2665                    <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2666            }),
2667        }
2668    }
2669}
2670
2671/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollection.
2672pub struct BufferCollectionRequestStream {
2673    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2674    is_terminated: bool,
2675}
2676
2677impl std::marker::Unpin for BufferCollectionRequestStream {}
2678
2679impl futures::stream::FusedStream for BufferCollectionRequestStream {
2680    fn is_terminated(&self) -> bool {
2681        self.is_terminated
2682    }
2683}
2684
2685impl fdomain_client::fidl::RequestStream for BufferCollectionRequestStream {
2686    type Protocol = BufferCollectionMarker;
2687    type ControlHandle = BufferCollectionControlHandle;
2688
2689    fn from_channel(channel: fdomain_client::Channel) -> Self {
2690        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2691    }
2692
2693    fn control_handle(&self) -> Self::ControlHandle {
2694        BufferCollectionControlHandle { inner: self.inner.clone() }
2695    }
2696
2697    fn into_inner(
2698        self,
2699    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2700    {
2701        (self.inner, self.is_terminated)
2702    }
2703
2704    fn from_inner(
2705        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2706        is_terminated: bool,
2707    ) -> Self {
2708        Self { inner, is_terminated }
2709    }
2710}
2711
2712impl futures::Stream for BufferCollectionRequestStream {
2713    type Item = Result<BufferCollectionRequest, fidl::Error>;
2714
2715    fn poll_next(
2716        mut self: std::pin::Pin<&mut Self>,
2717        cx: &mut std::task::Context<'_>,
2718    ) -> std::task::Poll<Option<Self::Item>> {
2719        let this = &mut *self;
2720        if this.inner.check_shutdown(cx) {
2721            this.is_terminated = true;
2722            return std::task::Poll::Ready(None);
2723        }
2724        if this.is_terminated {
2725            panic!("polled BufferCollectionRequestStream after completion");
2726        }
2727        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2728            |bytes, handles| {
2729                match this.inner.channel().read_etc(cx, bytes, handles) {
2730                    std::task::Poll::Ready(Ok(())) => {}
2731                    std::task::Poll::Pending => return std::task::Poll::Pending,
2732                    std::task::Poll::Ready(Err(None)) => {
2733                        this.is_terminated = true;
2734                        return std::task::Poll::Ready(None);
2735                    }
2736                    std::task::Poll::Ready(Err(Some(e))) => {
2737                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2738                            e.into(),
2739                        ))));
2740                    }
2741                }
2742
2743                // A message has been received from the channel
2744                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2745
2746                std::task::Poll::Ready(Some(match header.ordinal {
2747                0x11ac2555cf575b54 => {
2748                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2749                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2750                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2751                    let control_handle = BufferCollectionControlHandle {
2752                        inner: this.inner.clone(),
2753                    };
2754                    Ok(BufferCollectionRequest::Sync {
2755                        responder: BufferCollectionSyncResponder {
2756                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2757                            tx_id: header.tx_id,
2758                        },
2759                    })
2760                }
2761                0x6a5cae7d6d6e04c6 => {
2762                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2763                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2764                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2765                    let control_handle = BufferCollectionControlHandle {
2766                        inner: this.inner.clone(),
2767                    };
2768                    Ok(BufferCollectionRequest::Release {
2769                        control_handle,
2770                    })
2771                }
2772                0xb41f1624f48c1e9 => {
2773                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2774                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
2775                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
2776                    let control_handle = BufferCollectionControlHandle {
2777                        inner: this.inner.clone(),
2778                    };
2779                    Ok(BufferCollectionRequest::SetName {payload: req,
2780                        control_handle,
2781                    })
2782                }
2783                0x5cde8914608d99b1 => {
2784                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2785                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
2786                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
2787                    let control_handle = BufferCollectionControlHandle {
2788                        inner: this.inner.clone(),
2789                    };
2790                    Ok(BufferCollectionRequest::SetDebugClientInfo {payload: req,
2791                        control_handle,
2792                    })
2793                }
2794                0x716b0af13d5c0806 => {
2795                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2796                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
2797                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2798                    let control_handle = BufferCollectionControlHandle {
2799                        inner: this.inner.clone(),
2800                    };
2801                    Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {payload: req,
2802                        control_handle,
2803                    })
2804                }
2805                0x5209c77415b4dfad => {
2806                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2807                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2808                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2809                    let control_handle = BufferCollectionControlHandle {
2810                        inner: this.inner.clone(),
2811                    };
2812                    Ok(BufferCollectionRequest::SetVerboseLogging {
2813                        control_handle,
2814                    })
2815                }
2816                0x5b3d0e51614df053 => {
2817                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2818                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2819                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2820                    let control_handle = BufferCollectionControlHandle {
2821                        inner: this.inner.clone(),
2822                    };
2823                    Ok(BufferCollectionRequest::GetNodeRef {
2824                        responder: BufferCollectionGetNodeRefResponder {
2825                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2826                            tx_id: header.tx_id,
2827                        },
2828                    })
2829                }
2830                0x3a58e00157e0825 => {
2831                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2832                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
2833                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
2834                    let control_handle = BufferCollectionControlHandle {
2835                        inner: this.inner.clone(),
2836                    };
2837                    Ok(BufferCollectionRequest::IsAlternateFor {payload: req,
2838                        responder: BufferCollectionIsAlternateForResponder {
2839                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2840                            tx_id: header.tx_id,
2841                        },
2842                    })
2843                }
2844                0x77d19a494b78ba8c => {
2845                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2846                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2847                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2848                    let control_handle = BufferCollectionControlHandle {
2849                        inner: this.inner.clone(),
2850                    };
2851                    Ok(BufferCollectionRequest::GetBufferCollectionId {
2852                        responder: BufferCollectionGetBufferCollectionIdResponder {
2853                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2854                            tx_id: header.tx_id,
2855                        },
2856                    })
2857                }
2858                0x22dd3ea514eeffe1 => {
2859                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2860                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2861                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2862                    let control_handle = BufferCollectionControlHandle {
2863                        inner: this.inner.clone(),
2864                    };
2865                    Ok(BufferCollectionRequest::SetWeak {
2866                        control_handle,
2867                    })
2868                }
2869                0x38a44fc4d7724be9 => {
2870                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2871                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
2872                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
2873                    let control_handle = BufferCollectionControlHandle {
2874                        inner: this.inner.clone(),
2875                    };
2876                    Ok(BufferCollectionRequest::SetWeakOk {payload: req,
2877                        control_handle,
2878                    })
2879                }
2880                0x3f22f2a293d3cdac => {
2881                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2882                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
2883                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
2884                    let control_handle = BufferCollectionControlHandle {
2885                        inner: this.inner.clone(),
2886                    };
2887                    Ok(BufferCollectionRequest::AttachNodeTracking {payload: req,
2888                        control_handle,
2889                    })
2890                }
2891                0x1fde0f19d650197b => {
2892                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2893                    let mut req = fidl::new_empty!(BufferCollectionSetConstraintsRequest, fdomain_client::fidl::FDomainResourceDialect);
2894                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
2895                    let control_handle = BufferCollectionControlHandle {
2896                        inner: this.inner.clone(),
2897                    };
2898                    Ok(BufferCollectionRequest::SetConstraints {payload: req,
2899                        control_handle,
2900                    })
2901                }
2902                0x62300344b61404e => {
2903                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2904                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2905                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2906                    let control_handle = BufferCollectionControlHandle {
2907                        inner: this.inner.clone(),
2908                    };
2909                    Ok(BufferCollectionRequest::WaitForAllBuffersAllocated {
2910                        responder: BufferCollectionWaitForAllBuffersAllocatedResponder {
2911                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2912                            tx_id: header.tx_id,
2913                        },
2914                    })
2915                }
2916                0x35a5fe77ce939c10 => {
2917                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2918                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2919                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2920                    let control_handle = BufferCollectionControlHandle {
2921                        inner: this.inner.clone(),
2922                    };
2923                    Ok(BufferCollectionRequest::CheckAllBuffersAllocated {
2924                        responder: BufferCollectionCheckAllBuffersAllocatedResponder {
2925                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2926                            tx_id: header.tx_id,
2927                        },
2928                    })
2929                }
2930                0x46ac7d0008492982 => {
2931                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2932                    let mut req = fidl::new_empty!(BufferCollectionAttachTokenRequest, fdomain_client::fidl::FDomainResourceDialect);
2933                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
2934                    let control_handle = BufferCollectionControlHandle {
2935                        inner: this.inner.clone(),
2936                    };
2937                    Ok(BufferCollectionRequest::AttachToken {payload: req,
2938                        control_handle,
2939                    })
2940                }
2941                0x3ecb510113116dcf => {
2942                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2943                    let mut req = fidl::new_empty!(BufferCollectionAttachLifetimeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
2944                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
2945                    let control_handle = BufferCollectionControlHandle {
2946                        inner: this.inner.clone(),
2947                    };
2948                    Ok(BufferCollectionRequest::AttachLifetimeTracking {payload: req,
2949                        control_handle,
2950                    })
2951                }
2952                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2953                    Ok(BufferCollectionRequest::_UnknownMethod {
2954                        ordinal: header.ordinal,
2955                        control_handle: BufferCollectionControlHandle { inner: this.inner.clone() },
2956                        method_type: fidl::MethodType::OneWay,
2957                    })
2958                }
2959                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2960                    this.inner.send_framework_err(
2961                        fidl::encoding::FrameworkErr::UnknownMethod,
2962                        header.tx_id,
2963                        header.ordinal,
2964                        header.dynamic_flags(),
2965                        (bytes, handles),
2966                    )?;
2967                    Ok(BufferCollectionRequest::_UnknownMethod {
2968                        ordinal: header.ordinal,
2969                        control_handle: BufferCollectionControlHandle { inner: this.inner.clone() },
2970                        method_type: fidl::MethodType::TwoWay,
2971                    })
2972                }
2973                _ => Err(fidl::Error::UnknownOrdinal {
2974                    ordinal: header.ordinal,
2975                    protocol_name: <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2976                }),
2977            }))
2978            },
2979        )
2980    }
2981}
2982
2983/// [`fuchsia.sysmem2/BufferCollection`] is a connection directly from a
2984/// participant to sysmem re. a buffer collection; often the buffer collection
2985/// is shared with other participants which have their own `BufferCollection`
2986/// client end(s) associated with the same buffer collection.  In other words,
2987/// an instance of the `BufferCollection` interface is a view of a buffer
2988/// collection, not the buffer collection itself.
2989///
2990/// The `BufferCollection` connection exists to facilitate async indication of
2991/// when the buffer collection has been populated with buffers.
2992///
2993/// Also, the channel's closure by the sysmem server is an indication to the
2994/// client that the client should close all VMO handles that were obtained from
2995/// the `BufferCollection` ASAP.
2996///
2997/// Some buffer collections can use enough memory that it can be worth avoiding
2998/// allocation overlap (in time) using
2999/// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] so that the
3000/// initiator can tell when enough buffers of the buffer collection have been
3001/// fully deallocated prior to the initiator allocating a new buffer collection.
3002///
3003/// Epitaphs are not used in this protocol.
3004#[derive(Debug)]
3005pub enum BufferCollectionRequest {
3006    /// Ensure that previous messages have been received server side. This is
3007    /// particularly useful after previous messages that created new tokens,
3008    /// because a token must be known to the sysmem server before sending the
3009    /// token to another participant.
3010    ///
3011    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
3012    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
3013    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
3014    /// to mitigate the possibility of a hostile/fake
3015    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
3016    /// Another way is to pass the token to
3017    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
3018    /// the token as part of exchanging it for a
3019    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
3020    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
3021    /// of stalling.
3022    ///
3023    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
3024    /// and then starting and completing a `Sync`, it's then safe to send the
3025    /// `BufferCollectionToken` client ends to other participants knowing the
3026    /// server will recognize the tokens when they're sent by the other
3027    /// participants to sysmem in a
3028    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
3029    /// efficient way to create tokens while avoiding unnecessary round trips.
3030    ///
3031    /// Other options include waiting for each
3032    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
3033    /// individually (using separate call to `Sync` after each), or calling
3034    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
3035    /// converted to a `BufferCollection` via
3036    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
3037    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
3038    /// the sync step and can create multiple tokens at once.
3039    Sync { responder: BufferCollectionSyncResponder },
3040    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
3041    ///
3042    /// Normally a participant will convert a `BufferCollectionToken` into a
3043    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
3044    /// `Release` via the token (and then close the channel immediately or
3045    /// shortly later in response to server closing the server end), which
3046    /// avoids causing buffer collection failure. Without a prior `Release`,
3047    /// closing the `BufferCollectionToken` client end will cause buffer
3048    /// collection failure.
3049    ///
3050    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
3051    ///
3052    /// By default the server handles unexpected closure of a
3053    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
3054    /// first) by failing the buffer collection. Partly this is to expedite
3055    /// closing VMO handles to reclaim memory when any participant fails. If a
3056    /// participant would like to cleanly close a `BufferCollection` without
3057    /// causing buffer collection failure, the participant can send `Release`
3058    /// before closing the `BufferCollection` client end. The `Release` can
3059    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
3060    /// buffer collection won't require constraints from this node in order to
3061    /// allocate. If after `SetConstraints`, the constraints are retained and
3062    /// aggregated, despite the lack of `BufferCollection` connection at the
3063    /// time of constraints aggregation.
3064    ///
3065    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
3066    ///
3067    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
3068    /// end (without `Release` first) will trigger failure of the buffer
3069    /// collection. To close a `BufferCollectionTokenGroup` channel without
3070    /// failing the buffer collection, ensure that AllChildrenPresent() has been
3071    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
3072    /// client end.
3073    ///
3074    /// If `Release` occurs before
3075    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
3076    /// buffer collection will fail (triggered by reception of `Release` without
3077    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
3078    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
3079    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
3080    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
3081    /// close requires `AllChildrenPresent` (if not already sent), then
3082    /// `Release`, then close client end.
3083    ///
3084    /// If `Release` occurs after `AllChildrenPresent`, the children and all
3085    /// their constraints remain intact (just as they would if the
3086    /// `BufferCollectionTokenGroup` channel had remained open), and the client
3087    /// end close doesn't trigger buffer collection failure.
3088    ///
3089    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
3090    ///
3091    /// For brevity, the per-channel-protocol paragraphs above ignore the
3092    /// separate failure domain created by
3093    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
3094    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
3095    /// unexpectedly closes (without `Release` first) and that client end is
3096    /// under a failure domain, instead of failing the whole buffer collection,
3097    /// the failure domain is failed, but the buffer collection itself is
3098    /// isolated from failure of the failure domain. Such failure domains can be
3099    /// nested, in which case only the inner-most failure domain in which the
3100    /// `Node` resides fails.
3101    Release { control_handle: BufferCollectionControlHandle },
3102    /// Set a name for VMOs in this buffer collection.
3103    ///
3104    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
3105    /// will be truncated to fit. The name of the vmo will be suffixed with the
3106    /// buffer index within the collection (if the suffix fits within
3107    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
3108    /// listed in the inspect data.
3109    ///
3110    /// The name only affects VMOs allocated after the name is set; this call
3111    /// does not rename existing VMOs. If multiple clients set different names
3112    /// then the larger priority value will win. Setting a new name with the
3113    /// same priority as a prior name doesn't change the name.
3114    ///
3115    /// All table fields are currently required.
3116    ///
3117    /// + request `priority` The name is only set if this is the first `SetName`
3118    ///   or if `priority` is greater than any previous `priority` value in
3119    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
3120    /// + request `name` The name for VMOs created under this buffer collection.
3121    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionControlHandle },
3122    /// Set information about the current client that can be used by sysmem to
3123    /// help diagnose leaking memory and allocation stalls waiting for a
3124    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
3125    ///
3126    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
3127    /// `Node`(s) derived from this `Node`, unless overriden by
3128    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
3129    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
3130    ///
3131    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
3132    /// `Allocator` is the most efficient way to ensure that all
3133    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
3134    /// set, and is also more efficient than separately sending the same debug
3135    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
3136    /// created [`fuchsia.sysmem2/Node`].
3137    ///
3138    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
3139    /// indicate which client is closing their channel first, leading to subtree
3140    /// failure (which can be normal if the purpose of the subtree is over, but
3141    /// if happening earlier than expected, the client-channel-specific name can
3142    /// help diagnose where the failure is first coming from, from sysmem's
3143    /// point of view).
3144    ///
3145    /// All table fields are currently required.
3146    ///
3147    /// + request `name` This can be an arbitrary string, but the current
3148    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
3149    /// + request `id` This can be an arbitrary id, but the current process ID
3150    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
3151    SetDebugClientInfo {
3152        payload: NodeSetDebugClientInfoRequest,
3153        control_handle: BufferCollectionControlHandle,
3154    },
3155    /// Sysmem logs a warning if sysmem hasn't seen
3156    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
3157    /// within 5 seconds after creation of a new collection.
3158    ///
3159    /// Clients can call this method to change when the log is printed. If
3160    /// multiple client set the deadline, it's unspecified which deadline will
3161    /// take effect.
3162    ///
3163    /// In most cases the default works well.
3164    ///
3165    /// All table fields are currently required.
3166    ///
3167    /// + request `deadline` The time at which sysmem will start trying to log
3168    ///   the warning, unless all constraints are with sysmem by then.
3169    SetDebugTimeoutLogDeadline {
3170        payload: NodeSetDebugTimeoutLogDeadlineRequest,
3171        control_handle: BufferCollectionControlHandle,
3172    },
3173    /// This enables verbose logging for the buffer collection.
3174    ///
3175    /// Verbose logging includes constraints set via
3176    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
3177    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
3178    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
3179    /// the tree of `Node`(s).
3180    ///
3181    /// Normally sysmem prints only a single line complaint when aggregation
3182    /// fails, with just the specific detailed reason that aggregation failed,
3183    /// with little surrounding context.  While this is often enough to diagnose
3184    /// a problem if only a small change was made and everything was working
3185    /// before the small change, it's often not particularly helpful for getting
3186    /// a new buffer collection to work for the first time.  Especially with
3187    /// more complex trees of nodes, involving things like
3188    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
3189    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
3190    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
3191    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
3192    /// looks like and why it's failing a logical allocation, or why a tree or
3193    /// subtree is failing sooner than expected.
3194    ///
3195    /// The intent of the extra logging is to be acceptable from a performance
3196    /// point of view, under the assumption that verbose logging is only enabled
3197    /// on a low number of buffer collections. If we're not tracking down a bug,
3198    /// we shouldn't send this message.
3199    SetVerboseLogging { control_handle: BufferCollectionControlHandle },
3200    /// This gets a handle that can be used as a parameter to
3201    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
3202    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
3203    /// client obtained this handle from this `Node`.
3204    ///
3205    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
3206    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
3207    /// despite the two calls typically being on different channels.
3208    ///
3209    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
3210    ///
3211    /// All table fields are currently required.
3212    ///
3213    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
3214    ///   different `Node` channel, to prove that the client obtained the handle
3215    ///   from this `Node`.
3216    GetNodeRef { responder: BufferCollectionGetNodeRefResponder },
3217    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
3218    /// rooted at a different child token of a common parent
3219    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
3220    /// passed-in `node_ref`.
3221    ///
3222    /// This call is for assisting with admission control de-duplication, and
3223    /// with debugging.
3224    ///
3225    /// The `node_ref` must be obtained using
3226    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
3227    ///
3228    /// The `node_ref` can be a duplicated handle; it's not necessary to call
3229    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
3230    ///
3231    /// If a calling token may not actually be a valid token at all due to a
3232    /// potentially hostile/untrusted provider of the token, call
3233    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
3234    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
3235    /// never responds due to a calling token not being a real token (not really
3236    /// talking to sysmem).  Another option is to call
3237    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
3238    /// which also validates the token along with converting it to a
3239    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
3240    ///
3241    /// All table fields are currently required.
3242    ///
3243    /// - response `is_alternate`
3244    ///   - true: The first parent node in common between the calling node and
3245    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
3246    ///     that the calling `Node` and the `node_ref` `Node` will not have both
3247    ///     their constraints apply - rather sysmem will choose one or the other
3248    ///     of the constraints - never both.  This is because only one child of
3249    ///     a `BufferCollectionTokenGroup` is selected during logical
3250    ///     allocation, with only that one child's subtree contributing to
3251    ///     constraints aggregation.
3252    ///   - false: The first parent node in common between the calling `Node`
3253    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
3254    ///     Currently, this means the first parent node in common is a
3255    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
3256    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
3257    ///     `Node` may have both their constraints apply during constraints
3258    ///     aggregation of the logical allocation, if both `Node`(s) are
3259    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
3260    ///     this case, there is no `BufferCollectionTokenGroup` that will
3261    ///     directly prevent the two `Node`(s) from both being selected and
3262    ///     their constraints both aggregated, but even when false, one or both
3263    ///     `Node`(s) may still be eliminated from consideration if one or both
3264    ///     `Node`(s) has a direct or indirect parent
3265    ///     `BufferCollectionTokenGroup` which selects a child subtree other
3266    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
3267    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
3268    ///   associated with the same buffer collection as the calling `Node`.
3269    ///   Another reason for this error is if the `node_ref` is an
3270    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
3271    ///   a real `node_ref` obtained from `GetNodeRef`.
3272    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
3273    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
3274    ///   the needed rights expected on a real `node_ref`.
3275    /// * No other failing status codes are returned by this call.  However,
3276    ///   sysmem may add additional codes in future, so the client should have
3277    ///   sensible default handling for any failing status code.
3278    IsAlternateFor {
3279        payload: NodeIsAlternateForRequest,
3280        responder: BufferCollectionIsAlternateForResponder,
3281    },
3282    /// Get the buffer collection ID. This ID is also available from
3283    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
3284    /// within the collection).
3285    ///
3286    /// This call is mainly useful in situations where we can't convey a
3287    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
3288    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
3289    /// handle, which can be joined back up with a `BufferCollection` client end
3290    /// that was created via a different path. Prefer to convey a
3291    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
3292    ///
3293    /// Trusting a `buffer_collection_id` value from a source other than sysmem
3294    /// is analogous to trusting a koid value from a source other than zircon.
3295    /// Both should be avoided unless really necessary, and both require
3296    /// caution. In some situations it may be reasonable to refer to a
3297    /// pre-established `BufferCollection` by `buffer_collection_id` via a
3298    /// protocol for efficiency reasons, but an incoming value purporting to be
3299    /// a `buffer_collection_id` is not sufficient alone to justify granting the
3300    /// sender of the `buffer_collection_id` any capability. The sender must
3301    /// first prove to a receiver that the sender has/had a VMO or has/had a
3302    /// `BufferCollectionToken` to the same collection by sending a handle that
3303    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
3304    /// `buffer_collection_id` value. The receiver should take care to avoid
3305    /// assuming that a sender had a `BufferCollectionToken` in cases where the
3306    /// sender has only proven that the sender had a VMO.
3307    ///
3308    /// - response `buffer_collection_id` This ID is unique per buffer
3309    ///   collection per boot. Each buffer is uniquely identified by the
3310    ///   `buffer_collection_id` and `buffer_index` together.
3311    GetBufferCollectionId { responder: BufferCollectionGetBufferCollectionIdResponder },
3312    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
3313    /// created after this message to weak, which means that a client's `Node`
3314    /// client end (or a child created after this message) is not alone
3315    /// sufficient to keep allocated VMOs alive.
3316    ///
3317    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
3318    /// `close_weak_asap`.
3319    ///
3320    /// This message is only permitted before the `Node` becomes ready for
3321    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
3322    ///   * `BufferCollectionToken`: any time
3323    ///   * `BufferCollection`: before `SetConstraints`
3324    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
3325    ///
3326    /// Currently, no conversion from strong `Node` to weak `Node` after ready
3327    /// for allocation is provided, but a client can simulate that by creating
3328    /// an additional `Node` before allocation and setting that additional
3329    /// `Node` to weak, and then potentially at some point later sending
3330    /// `Release` and closing the client end of the client's strong `Node`, but
3331    /// keeping the client's weak `Node`.
3332    ///
3333    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
3334    /// collection failure (all `Node` client end(s) will see
3335    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
3336    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
3337    /// this situation until all `Node`(s) are ready for allocation. For initial
3338    /// allocation to succeed, at least one strong `Node` is required to exist
3339    /// at allocation time, but after that client receives VMO handles, that
3340    /// client can `BufferCollection.Release` and close the client end without
3341    /// causing this type of failure.
3342    ///
3343    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
3344    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
3345    /// separately as appropriate.
3346    SetWeak { control_handle: BufferCollectionControlHandle },
3347    /// This indicates to sysmem that the client is prepared to pay attention to
3348    /// `close_weak_asap`.
3349    ///
3350    /// If sent, this message must be before
3351    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
3352    ///
3353    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
3354    /// send this message before `WaitForAllBuffersAllocated`, or a parent
3355    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
3356    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
3357    /// trigger buffer collection failure.
3358    ///
3359    /// This message is necessary because weak sysmem VMOs have not always been
3360    /// a thing, so older clients are not aware of the need to pay attention to
3361    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
3362    /// sysmem weak VMO handles asap. By having this message and requiring
3363    /// participants to indicate their acceptance of this aspect of the overall
3364    /// protocol, we avoid situations where an older client is delivered a weak
3365    /// VMO without any way for sysmem to get that VMO to close quickly later
3366    /// (and on a per-buffer basis).
3367    ///
3368    /// A participant that doesn't handle `close_weak_asap` and also doesn't
3369    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
3370    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
3371    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
3372    /// same participant has a child/delegate which does retrieve VMOs, that
3373    /// child/delegate will need to send `SetWeakOk` before
3374    /// `WaitForAllBuffersAllocated`.
3375    ///
3376    /// + request `for_child_nodes_also` If present and true, this means direct
3377    ///   child nodes of this node created after this message plus all
3378    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
3379    ///   those nodes. Any child node of this node that was created before this
3380    ///   message is not included. This setting is "sticky" in the sense that a
3381    ///   subsequent `SetWeakOk` without this bool set to true does not reset
3382    ///   the server-side bool. If this creates a problem for a participant, a
3383    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
3384    ///   tokens instead, as appropriate. A participant should only set
3385    ///   `for_child_nodes_also` true if the participant can really promise to
3386    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
3387    ///   weak VMO handles held by participants holding the corresponding child
3388    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
3389    ///   which are using sysmem(1) can be weak, despite the clients of those
3390    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
3391    ///   direct way to find out about `close_weak_asap`. This only applies to
3392    ///   descendents of this `Node` which are using sysmem(1), not to this
3393    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
3394    ///   token, which will fail allocation unless an ancestor of this `Node`
3395    ///   specified `for_child_nodes_also` true.
3396    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: BufferCollectionControlHandle },
3397    /// The server_end will be closed after this `Node` and any child nodes have
3398    /// have released their buffer counts, making those counts available for
3399    /// reservation by a different `Node` via
3400    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
3401    ///
3402    /// The `Node` buffer counts may not be released until the entire tree of
3403    /// `Node`(s) is closed or failed, because
3404    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
3405    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
3406    /// `Node` buffer counts remain reserved until the orphaned node is later
3407    /// cleaned up.
3408    ///
3409    /// If the `Node` exceeds a fairly large number of attached eventpair server
3410    /// ends, a log message will indicate this and the `Node` (and the
3411    /// appropriate) sub-tree will fail.
3412    ///
3413    /// The `server_end` will remain open when
3414    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
3415    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
3416    /// [`fuchsia.sysmem2/BufferCollection`].
3417    ///
3418    /// This message can also be used with a
3419    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
3420    AttachNodeTracking {
3421        payload: NodeAttachNodeTrackingRequest,
3422        control_handle: BufferCollectionControlHandle,
3423    },
3424    /// Provide [`fuchsia.sysmem2/BufferCollectionConstraints`] to the buffer
3425    /// collection.
3426    ///
3427    /// A participant may only call
3428    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] up to once per
3429    /// [`fuchsia.sysmem2/BufferCollection`].
3430    ///
3431    /// For buffer allocation to be attempted, all holders of a
3432    /// `BufferCollection` client end need to call `SetConstraints` before
3433    /// sysmem will attempt to allocate buffers.
3434    ///
3435    /// + request `constraints` These are the constraints on the buffer
3436    ///   collection imposed by the sending client/participant.  The
3437    ///   `constraints` field is not required to be set. If not set, the client
3438    ///   is not setting any actual constraints, but is indicating that the
3439    ///   client has no constraints to set. A client that doesn't set the
3440    ///   `constraints` field won't receive any VMO handles, but can still find
3441    ///   out how many buffers were allocated and can still refer to buffers by
3442    ///   their `buffer_index`.
3443    SetConstraints {
3444        payload: BufferCollectionSetConstraintsRequest,
3445        control_handle: BufferCollectionControlHandle,
3446    },
3447    /// Wait until all buffers are allocated.
3448    ///
3449    /// This FIDL call completes when buffers have been allocated, or completes
3450    /// with some failure detail if allocation has been attempted but failed.
3451    ///
3452    /// The following must occur before buffers will be allocated:
3453    ///   * All [`fuchsia.sysmem2/BufferCollectionToken`](s) of the buffer
3454    ///     collection must be turned in via `BindSharedCollection` to get a
3455    ///     [`fuchsia.sysmem2/BufferCollection`] (for brevity, this is assuming
3456    ///     [`fuchsia.sysmem2/BufferCollection.AttachToken`] isn't being used),
3457    ///     or have had [`fuchsia.sysmem2/BufferCollectionToken.Release`] sent
3458    ///     to them.
3459    ///   * All [`fuchsia.sysmem2/BufferCollection`](s) of the buffer collection
3460    ///     must have had [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
3461    ///     sent to them, or had [`fuchsia.sysmem2/BufferCollection.Release`]
3462    ///     sent to them.
3463    ///
3464    /// - result `buffer_collection_info` The VMO handles and other related
3465    ///   info.
3466    /// * error `[fuchsia.sysmem2/Error.NO_MEMORY]` The request is valid but
3467    ///   cannot be fulfilled due to resource exhaustion.
3468    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION`] The request is
3469    ///   malformed.
3470    /// * error `[fuchsia.sysmem2/Error.CONSTRAINTS_INTERSECTION_EMPTY`] The
3471    ///   request is valid but cannot be satisfied, perhaps due to hardware
3472    ///   limitations. This can happen if participants have incompatible
3473    ///   constraints (empty intersection, roughly speaking). See the log for
3474    ///   more info. In cases where a participant could potentially be treated
3475    ///   as optional, see [`BufferCollectionTokenGroup`]. When using
3476    ///   [`fuchsia.sysmem2/BufferCollection.AttachToken`], this will be the
3477    ///   error code if there aren't enough buffers in the pre-existing
3478    ///   collection to satisfy the constraints set on the attached token and
3479    ///   any sub-tree of tokens derived from the attached token.
3480    WaitForAllBuffersAllocated { responder: BufferCollectionWaitForAllBuffersAllocatedResponder },
3481    /// Checks whether all the buffers have been allocated, in a polling
3482    /// fashion.
3483    ///
3484    /// * If the buffer collection has been allocated, returns success.
3485    /// * If the buffer collection failed allocation, returns the same
3486    ///   [`fuchsia.sysmem2/Error`] as
3487    ///   [`fuchsia.sysmem2/BufferCollection/WaitForAllBuffersAllocated`] would
3488    ///   return.
3489    /// * error [`fuchsia.sysmem2/Error.PENDING`] The buffer collection hasn't
3490    ///   attempted allocation yet. This means that WaitForAllBuffersAllocated
3491    ///   would not respond quickly.
3492    CheckAllBuffersAllocated { responder: BufferCollectionCheckAllBuffersAllocatedResponder },
3493    /// Create a new token to add a new participant to an existing logical
3494    /// buffer collection, if the existing collection's buffer counts,
3495    /// constraints, and participants allow.
3496    ///
3497    /// This can be useful in replacing a failed participant, and/or in
3498    /// adding/re-adding a participant after buffers have already been
3499    /// allocated.
3500    ///
3501    /// When [`fuchsia.sysmem2/BufferCollection.AttachToken`] is used, the sub
3502    /// tree rooted at the attached [`fuchsia.sysmem2/BufferCollectionToken`]
3503    /// goes through the normal procedure of setting constraints or closing
3504    /// [`fuchsia.sysmem2/Node`](s), and then appearing to allocate buffers from
3505    /// clients' point of view, despite the possibility that all the buffers
3506    /// were actually allocated previously. This process is called "logical
3507    /// allocation". Most instances of "allocation" in docs for other messages
3508    /// can also be read as "allocation or logical allocation" while remaining
3509    /// valid, but we just say "allocation" in most places for brevity/clarity
3510    /// of explanation, with the details of "logical allocation" left for the
3511    /// docs here on `AttachToken`.
3512    ///
3513    /// Failure of an attached `Node` does not propagate to the parent of the
3514    /// attached `Node`. More generally, failure of a child `Node` is blocked
3515    /// from reaching its parent `Node` if the child is attached, or if the
3516    /// child is dispensable and the failure occurred after logical allocation
3517    /// (see [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`]).
3518    ///
3519    /// A participant may in some scenarios choose to initially use a
3520    /// dispensable token for a given instance of a delegate participant, and
3521    /// then later if the first instance of that delegate participant fails, a
3522    /// new second instance of that delegate participant my be given a token
3523    /// created with `AttachToken`.
3524    ///
3525    /// From the point of view of the [`fuchsia.sysmem2/BufferCollectionToken`]
3526    /// client end, the token acts like any other token. The client can
3527    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] the token as needed,
3528    /// and can send the token to a different process/participant. The
3529    /// `BufferCollectionToken` `Node` should be converted to a
3530    /// `BufferCollection` `Node` as normal by sending
3531    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or can be closed
3532    /// without causing subtree failure by sending
3533    /// [`fuchsia.sysmem2/BufferCollectionToken.Release`]. Assuming the former,
3534    /// the [`fuchsia.sysmem2/BufferCollection.SetConstraints`] message or
3535    /// [`fuchsia.sysmem2/BufferCollection.Release`] message should be sent to
3536    /// the `BufferCollection`.
3537    ///
3538    /// Within the subtree, a success result from
3539    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] means
3540    /// the subtree participants' constraints were satisfiable using the
3541    /// already-existing buffer collection, the already-established
3542    /// [`fuchsia.sysmem2/BufferCollectionInfo`] including image format
3543    /// constraints, and the already-existing other participants (already added
3544    /// via successful logical allocation) and their specified buffer counts in
3545    /// their constraints. A failure result means the new participants'
3546    /// constraints cannot be satisfied using the existing buffer collection and
3547    /// its already-added participants. Creating a new collection instead may
3548    /// allow all participants' constraints to be satisfied, assuming
3549    /// `SetDispensable` is used in place of `AttachToken`, or a normal token is
3550    /// used.
3551    ///
3552    /// A token created with `AttachToken` performs constraints aggregation with
3553    /// all constraints currently in effect on the buffer collection, plus the
3554    /// attached token under consideration plus child tokens under the attached
3555    /// token which are not themselves an attached token or under such a token.
3556    /// Further subtrees under this subtree are considered for logical
3557    /// allocation only after this subtree has completed logical allocation.
3558    ///
3559    /// Assignment of existing buffers to participants'
3560    /// [`fuchsia.sysmem2/BufferCollectionConstraints.min_buffer_count_for_camping`]
3561    /// etc is first-come first-served, but a child can't logically allocate
3562    /// before all its parents have sent `SetConstraints`.
3563    ///
3564    /// See also [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`], which
3565    /// in contrast to `AttachToken`, has the created token `Node` + child
3566    /// `Node`(s) (in the created subtree but not in any subtree under this
3567    /// subtree) participate in constraints aggregation along with its parent
3568    /// during the parent's allocation or logical allocation.
3569    ///
3570    /// Similar to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], the
3571    /// newly created token needs to be [`fuchsia.sysmem2/Node.Sync`]ed to
3572    /// sysmem before the new token can be passed to `BindSharedCollection`. The
3573    /// `Sync` of the new token can be accomplished with
3574    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after converting the created
3575    /// `BufferCollectionToken` to a `BufferCollection`. Alternately,
3576    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on the new token also
3577    /// works. Or using [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`]
3578    /// works. As usual, a `BufferCollectionToken.Sync` can be started after any
3579    /// `BufferCollectionToken.Duplicate` messages have been sent via the newly
3580    /// created token, to also sync those additional tokens to sysmem using a
3581    /// single round-trip.
3582    ///
3583    /// All table fields are currently required.
3584    ///
3585    /// + request `rights_attentuation_mask` This allows attenuating the VMO
3586    ///   rights of the subtree. These values for `rights_attenuation_mask`
3587    ///   result in no attenuation (note that 0 is not on this list):
3588    ///   + ZX_RIGHT_SAME_RIGHTS (preferred)
3589    ///   + 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3590    /// + request `token_request` The server end of the `BufferCollectionToken`
3591    ///   channel. The client retains the client end.
3592    AttachToken {
3593        payload: BufferCollectionAttachTokenRequest,
3594        control_handle: BufferCollectionControlHandle,
3595    },
3596    /// Set up an eventpair to be signalled (`ZX_EVENTPAIR_PEER_CLOSED`) when
3597    /// buffers have been allocated and only the specified number of buffers (or
3598    /// fewer) remain in the buffer collection.
3599    ///
3600    /// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] allows a
3601    /// client to wait until an old buffer collection is fully or mostly
3602    /// deallocated before attempting allocation of a new buffer collection. The
3603    /// eventpair is only signalled when the buffers of this collection have
3604    /// been fully deallocated (not just un-referenced by clients, but all the
3605    /// memory consumed by those buffers has been fully reclaimed/recycled), or
3606    /// when allocation or logical allocation fails for the tree or subtree
3607    /// including this [`fuchsia.sysmem2/BufferCollection`].
3608    ///
3609    /// The eventpair won't be signalled until allocation or logical allocation
3610    /// has completed; until then, the collection's current buffer count is
3611    /// ignored.
3612    ///
3613    /// If logical allocation fails for an attached subtree (using
3614    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]), the server end of the
3615    /// eventpair will close during that failure regardless of the number of
3616    /// buffers potenitally allocated in the overall buffer collection. This is
3617    /// for logical allocation consistency with normal allocation.
3618    ///
3619    /// The lifetime signalled by this event includes asynchronous cleanup of
3620    /// allocated buffers, and this asynchronous cleanup cannot occur until all
3621    /// holders of VMO handles to the buffers have closed those VMO handles.
3622    /// Therefore, clients should take care not to become blocked forever
3623    /// waiting for `ZX_EVENTPAIR_PEER_CLOSED` to be signalled if any of the
3624    /// participants using the logical buffer collection (including the waiter
3625    /// itself) are less trusted, less reliable, or potentially blocked by the
3626    /// wait itself. Waiting asynchronously is recommended. Setting a deadline
3627    /// for the client wait may be prudent, depending on details of how the
3628    /// collection and/or its VMOs are used or shared. Failure to allocate a
3629    /// new/replacement buffer collection is better than getting stuck forever.
3630    ///
3631    /// The sysmem server itself intentionally does not perform any waiting on
3632    /// already-failed collections' VMOs to finish cleaning up before attempting
3633    /// a new allocation, and the sysmem server intentionally doesn't retry
3634    /// allocation if a new allocation fails due to out of memory, even if that
3635    /// failure is potentially due to continued existence of an old collection's
3636    /// VMOs. This `AttachLifetimeTracking` message is how an initiator can
3637    /// mitigate too much overlap of old VMO lifetimes with new VMO lifetimes,
3638    /// as long as the waiting client is careful to not create a deadlock.
3639    ///
3640    /// Continued existence of old collections that are still cleaning up is not
3641    /// the only reason that a new allocation may fail due to insufficient
3642    /// memory, even if the new allocation is allocating physically contiguous
3643    /// buffers. Overall system memory pressure can also be the cause of failure
3644    /// to allocate a new collection. See also
3645    /// [`fuchsia.memorypressure/Provider`].
3646    ///
3647    /// `AttachLifetimeTracking` is meant to be compatible with other protocols
3648    /// with a similar `AttachLifetimeTracking` message; duplicates of the same
3649    /// `eventpair` handle (server end) can be sent via more than one
3650    /// `AttachLifetimeTracking` message to different protocols, and the
3651    /// `ZX_EVENTPAIR_PEER_CLOSED` will be signalled for the client end when all
3652    /// the conditions are met (all holders of duplicates have closed their
3653    /// server end handle(s)). Also, thanks to how eventpair endponts work, the
3654    /// client end can (also) be duplicated without preventing the
3655    /// `ZX_EVENTPAIR_PEER_CLOSED` signal.
3656    ///
3657    /// The server intentionally doesn't "trust" any signals set on the
3658    /// `server_end`. This mechanism intentionally uses only
3659    /// `ZX_EVENTPAIR_PEER_CLOSED` set on the client end, which can't be set
3660    /// "early", and is only set when all handles to the server end eventpair
3661    /// are closed. No meaning is associated with any of the other signals, and
3662    /// clients should ignore any other signal bits on either end of the
3663    /// `eventpair`.
3664    ///
3665    /// The `server_end` may lack `ZX_RIGHT_SIGNAL` or `ZX_RIGHT_SIGNAL_PEER`,
3666    /// but must have `ZX_RIGHT_DUPLICATE` (and must have `ZX_RIGHT_TRANSFER` to
3667    /// transfer without causing `BufferCollection` channel failure).
3668    ///
3669    /// All table fields are currently required.
3670    ///
3671    /// + request `server_end` This eventpair handle will be closed by the
3672    ///   sysmem server when buffers have been allocated initially and the
3673    ///   number of buffers is then less than or equal to `buffers_remaining`.
3674    /// + request `buffers_remaining` Wait for all but `buffers_remaining` (or
3675    ///   fewer) buffers to be fully deallocated. A number greater than zero can
3676    ///   be useful in situations where a known number of buffers are
3677    ///   intentionally not closed so that the data can continue to be used,
3678    ///   such as for keeping the last available video frame displayed in the UI
3679    ///   even if the video stream was using protected output buffers. It's
3680    ///   outside the scope of the `BufferCollection` interface (at least for
3681    ///   now) to determine how many buffers may be held without closing, but
3682    ///   it'll typically be in the range 0-2.
3683    AttachLifetimeTracking {
3684        payload: BufferCollectionAttachLifetimeTrackingRequest,
3685        control_handle: BufferCollectionControlHandle,
3686    },
3687    /// An interaction was received which does not match any known method.
3688    #[non_exhaustive]
3689    _UnknownMethod {
3690        /// Ordinal of the method that was called.
3691        ordinal: u64,
3692        control_handle: BufferCollectionControlHandle,
3693        method_type: fidl::MethodType,
3694    },
3695}
3696
3697impl BufferCollectionRequest {
3698    #[allow(irrefutable_let_patterns)]
3699    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
3700        if let BufferCollectionRequest::Sync { responder } = self {
3701            Some((responder))
3702        } else {
3703            None
3704        }
3705    }
3706
3707    #[allow(irrefutable_let_patterns)]
3708    pub fn into_release(self) -> Option<(BufferCollectionControlHandle)> {
3709        if let BufferCollectionRequest::Release { control_handle } = self {
3710            Some((control_handle))
3711        } else {
3712            None
3713        }
3714    }
3715
3716    #[allow(irrefutable_let_patterns)]
3717    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, BufferCollectionControlHandle)> {
3718        if let BufferCollectionRequest::SetName { payload, control_handle } = self {
3719            Some((payload, control_handle))
3720        } else {
3721            None
3722        }
3723    }
3724
3725    #[allow(irrefutable_let_patterns)]
3726    pub fn into_set_debug_client_info(
3727        self,
3728    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionControlHandle)> {
3729        if let BufferCollectionRequest::SetDebugClientInfo { payload, control_handle } = self {
3730            Some((payload, control_handle))
3731        } else {
3732            None
3733        }
3734    }
3735
3736    #[allow(irrefutable_let_patterns)]
3737    pub fn into_set_debug_timeout_log_deadline(
3738        self,
3739    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionControlHandle)> {
3740        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { payload, control_handle } =
3741            self
3742        {
3743            Some((payload, control_handle))
3744        } else {
3745            None
3746        }
3747    }
3748
3749    #[allow(irrefutable_let_patterns)]
3750    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
3751        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
3752            Some((control_handle))
3753        } else {
3754            None
3755        }
3756    }
3757
3758    #[allow(irrefutable_let_patterns)]
3759    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
3760        if let BufferCollectionRequest::GetNodeRef { responder } = self {
3761            Some((responder))
3762        } else {
3763            None
3764        }
3765    }
3766
3767    #[allow(irrefutable_let_patterns)]
3768    pub fn into_is_alternate_for(
3769        self,
3770    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionIsAlternateForResponder)> {
3771        if let BufferCollectionRequest::IsAlternateFor { payload, responder } = self {
3772            Some((payload, responder))
3773        } else {
3774            None
3775        }
3776    }
3777
3778    #[allow(irrefutable_let_patterns)]
3779    pub fn into_get_buffer_collection_id(
3780        self,
3781    ) -> Option<(BufferCollectionGetBufferCollectionIdResponder)> {
3782        if let BufferCollectionRequest::GetBufferCollectionId { responder } = self {
3783            Some((responder))
3784        } else {
3785            None
3786        }
3787    }
3788
3789    #[allow(irrefutable_let_patterns)]
3790    pub fn into_set_weak(self) -> Option<(BufferCollectionControlHandle)> {
3791        if let BufferCollectionRequest::SetWeak { control_handle } = self {
3792            Some((control_handle))
3793        } else {
3794            None
3795        }
3796    }
3797
3798    #[allow(irrefutable_let_patterns)]
3799    pub fn into_set_weak_ok(self) -> Option<(NodeSetWeakOkRequest, BufferCollectionControlHandle)> {
3800        if let BufferCollectionRequest::SetWeakOk { payload, control_handle } = self {
3801            Some((payload, control_handle))
3802        } else {
3803            None
3804        }
3805    }
3806
3807    #[allow(irrefutable_let_patterns)]
3808    pub fn into_attach_node_tracking(
3809        self,
3810    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionControlHandle)> {
3811        if let BufferCollectionRequest::AttachNodeTracking { payload, control_handle } = self {
3812            Some((payload, control_handle))
3813        } else {
3814            None
3815        }
3816    }
3817
3818    #[allow(irrefutable_let_patterns)]
3819    pub fn into_set_constraints(
3820        self,
3821    ) -> Option<(BufferCollectionSetConstraintsRequest, BufferCollectionControlHandle)> {
3822        if let BufferCollectionRequest::SetConstraints { payload, control_handle } = self {
3823            Some((payload, control_handle))
3824        } else {
3825            None
3826        }
3827    }
3828
3829    #[allow(irrefutable_let_patterns)]
3830    pub fn into_wait_for_all_buffers_allocated(
3831        self,
3832    ) -> Option<(BufferCollectionWaitForAllBuffersAllocatedResponder)> {
3833        if let BufferCollectionRequest::WaitForAllBuffersAllocated { responder } = self {
3834            Some((responder))
3835        } else {
3836            None
3837        }
3838    }
3839
3840    #[allow(irrefutable_let_patterns)]
3841    pub fn into_check_all_buffers_allocated(
3842        self,
3843    ) -> Option<(BufferCollectionCheckAllBuffersAllocatedResponder)> {
3844        if let BufferCollectionRequest::CheckAllBuffersAllocated { responder } = self {
3845            Some((responder))
3846        } else {
3847            None
3848        }
3849    }
3850
3851    #[allow(irrefutable_let_patterns)]
3852    pub fn into_attach_token(
3853        self,
3854    ) -> Option<(BufferCollectionAttachTokenRequest, BufferCollectionControlHandle)> {
3855        if let BufferCollectionRequest::AttachToken { payload, control_handle } = self {
3856            Some((payload, control_handle))
3857        } else {
3858            None
3859        }
3860    }
3861
3862    #[allow(irrefutable_let_patterns)]
3863    pub fn into_attach_lifetime_tracking(
3864        self,
3865    ) -> Option<(BufferCollectionAttachLifetimeTrackingRequest, BufferCollectionControlHandle)>
3866    {
3867        if let BufferCollectionRequest::AttachLifetimeTracking { payload, control_handle } = self {
3868            Some((payload, control_handle))
3869        } else {
3870            None
3871        }
3872    }
3873
3874    /// Name of the method defined in FIDL
3875    pub fn method_name(&self) -> &'static str {
3876        match *self {
3877            BufferCollectionRequest::Sync { .. } => "sync",
3878            BufferCollectionRequest::Release { .. } => "release",
3879            BufferCollectionRequest::SetName { .. } => "set_name",
3880            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
3881            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
3882                "set_debug_timeout_log_deadline"
3883            }
3884            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
3885            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
3886            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
3887            BufferCollectionRequest::GetBufferCollectionId { .. } => "get_buffer_collection_id",
3888            BufferCollectionRequest::SetWeak { .. } => "set_weak",
3889            BufferCollectionRequest::SetWeakOk { .. } => "set_weak_ok",
3890            BufferCollectionRequest::AttachNodeTracking { .. } => "attach_node_tracking",
3891            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
3892            BufferCollectionRequest::WaitForAllBuffersAllocated { .. } => {
3893                "wait_for_all_buffers_allocated"
3894            }
3895            BufferCollectionRequest::CheckAllBuffersAllocated { .. } => {
3896                "check_all_buffers_allocated"
3897            }
3898            BufferCollectionRequest::AttachToken { .. } => "attach_token",
3899            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
3900            BufferCollectionRequest::_UnknownMethod {
3901                method_type: fidl::MethodType::OneWay,
3902                ..
3903            } => "unknown one-way method",
3904            BufferCollectionRequest::_UnknownMethod {
3905                method_type: fidl::MethodType::TwoWay,
3906                ..
3907            } => "unknown two-way method",
3908        }
3909    }
3910}
3911
3912#[derive(Debug, Clone)]
3913pub struct BufferCollectionControlHandle {
3914    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3915}
3916
3917impl fdomain_client::fidl::ControlHandle for BufferCollectionControlHandle {
3918    fn shutdown(&self) {
3919        self.inner.shutdown()
3920    }
3921
3922    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3923        self.inner.shutdown_with_epitaph(status)
3924    }
3925
3926    fn is_closed(&self) -> bool {
3927        self.inner.channel().is_closed()
3928    }
3929    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3930        self.inner.channel().on_closed()
3931    }
3932}
3933
3934impl BufferCollectionControlHandle {}
3935
3936#[must_use = "FIDL methods require a response to be sent"]
3937#[derive(Debug)]
3938pub struct BufferCollectionSyncResponder {
3939    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3940    tx_id: u32,
3941}
3942
3943/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3944/// if the responder is dropped without sending a response, so that the client
3945/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3946impl std::ops::Drop for BufferCollectionSyncResponder {
3947    fn drop(&mut self) {
3948        self.control_handle.shutdown();
3949        // Safety: drops once, never accessed again
3950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3951    }
3952}
3953
3954impl fdomain_client::fidl::Responder for BufferCollectionSyncResponder {
3955    type ControlHandle = BufferCollectionControlHandle;
3956
3957    fn control_handle(&self) -> &BufferCollectionControlHandle {
3958        &self.control_handle
3959    }
3960
3961    fn drop_without_shutdown(mut self) {
3962        // Safety: drops once, never accessed again due to mem::forget
3963        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3964        // Prevent Drop from running (which would shut down the channel)
3965        std::mem::forget(self);
3966    }
3967}
3968
3969impl BufferCollectionSyncResponder {
3970    /// Sends a response to the FIDL transaction.
3971    ///
3972    /// Sets the channel to shutdown if an error occurs.
3973    pub fn send(self) -> Result<(), fidl::Error> {
3974        let _result = self.send_raw();
3975        if _result.is_err() {
3976            self.control_handle.shutdown();
3977        }
3978        self.drop_without_shutdown();
3979        _result
3980    }
3981
3982    /// Similar to "send" but does not shutdown the channel if an error occurs.
3983    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3984        let _result = self.send_raw();
3985        self.drop_without_shutdown();
3986        _result
3987    }
3988
3989    fn send_raw(&self) -> Result<(), fidl::Error> {
3990        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3991            fidl::encoding::Flexible::new(()),
3992            self.tx_id,
3993            0x11ac2555cf575b54,
3994            fidl::encoding::DynamicFlags::FLEXIBLE,
3995        )
3996    }
3997}
3998
3999#[must_use = "FIDL methods require a response to be sent"]
4000#[derive(Debug)]
4001pub struct BufferCollectionGetNodeRefResponder {
4002    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4003    tx_id: u32,
4004}
4005
4006/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4007/// if the responder is dropped without sending a response, so that the client
4008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4009impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
4010    fn drop(&mut self) {
4011        self.control_handle.shutdown();
4012        // Safety: drops once, never accessed again
4013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4014    }
4015}
4016
4017impl fdomain_client::fidl::Responder for BufferCollectionGetNodeRefResponder {
4018    type ControlHandle = BufferCollectionControlHandle;
4019
4020    fn control_handle(&self) -> &BufferCollectionControlHandle {
4021        &self.control_handle
4022    }
4023
4024    fn drop_without_shutdown(mut self) {
4025        // Safety: drops once, never accessed again due to mem::forget
4026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4027        // Prevent Drop from running (which would shut down the channel)
4028        std::mem::forget(self);
4029    }
4030}
4031
4032impl BufferCollectionGetNodeRefResponder {
4033    /// Sends a response to the FIDL transaction.
4034    ///
4035    /// Sets the channel to shutdown if an error occurs.
4036    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
4037        let _result = self.send_raw(payload);
4038        if _result.is_err() {
4039            self.control_handle.shutdown();
4040        }
4041        self.drop_without_shutdown();
4042        _result
4043    }
4044
4045    /// Similar to "send" but does not shutdown the channel if an error occurs.
4046    pub fn send_no_shutdown_on_err(
4047        self,
4048        mut payload: NodeGetNodeRefResponse,
4049    ) -> Result<(), fidl::Error> {
4050        let _result = self.send_raw(payload);
4051        self.drop_without_shutdown();
4052        _result
4053    }
4054
4055    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
4056        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
4057            fidl::encoding::Flexible::new(&mut payload),
4058            self.tx_id,
4059            0x5b3d0e51614df053,
4060            fidl::encoding::DynamicFlags::FLEXIBLE,
4061        )
4062    }
4063}
4064
4065#[must_use = "FIDL methods require a response to be sent"]
4066#[derive(Debug)]
4067pub struct BufferCollectionIsAlternateForResponder {
4068    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4069    tx_id: u32,
4070}
4071
4072/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4073/// if the responder is dropped without sending a response, so that the client
4074/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4075impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
4076    fn drop(&mut self) {
4077        self.control_handle.shutdown();
4078        // Safety: drops once, never accessed again
4079        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4080    }
4081}
4082
4083impl fdomain_client::fidl::Responder for BufferCollectionIsAlternateForResponder {
4084    type ControlHandle = BufferCollectionControlHandle;
4085
4086    fn control_handle(&self) -> &BufferCollectionControlHandle {
4087        &self.control_handle
4088    }
4089
4090    fn drop_without_shutdown(mut self) {
4091        // Safety: drops once, never accessed again due to mem::forget
4092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4093        // Prevent Drop from running (which would shut down the channel)
4094        std::mem::forget(self);
4095    }
4096}
4097
4098impl BufferCollectionIsAlternateForResponder {
4099    /// Sends a response to the FIDL transaction.
4100    ///
4101    /// Sets the channel to shutdown if an error occurs.
4102    pub fn send(
4103        self,
4104        mut result: Result<&NodeIsAlternateForResponse, Error>,
4105    ) -> Result<(), fidl::Error> {
4106        let _result = self.send_raw(result);
4107        if _result.is_err() {
4108            self.control_handle.shutdown();
4109        }
4110        self.drop_without_shutdown();
4111        _result
4112    }
4113
4114    /// Similar to "send" but does not shutdown the channel if an error occurs.
4115    pub fn send_no_shutdown_on_err(
4116        self,
4117        mut result: Result<&NodeIsAlternateForResponse, Error>,
4118    ) -> Result<(), fidl::Error> {
4119        let _result = self.send_raw(result);
4120        self.drop_without_shutdown();
4121        _result
4122    }
4123
4124    fn send_raw(
4125        &self,
4126        mut result: Result<&NodeIsAlternateForResponse, Error>,
4127    ) -> Result<(), fidl::Error> {
4128        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4129            NodeIsAlternateForResponse,
4130            Error,
4131        >>(
4132            fidl::encoding::FlexibleResult::new(result),
4133            self.tx_id,
4134            0x3a58e00157e0825,
4135            fidl::encoding::DynamicFlags::FLEXIBLE,
4136        )
4137    }
4138}
4139
4140#[must_use = "FIDL methods require a response to be sent"]
4141#[derive(Debug)]
4142pub struct BufferCollectionGetBufferCollectionIdResponder {
4143    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4144    tx_id: u32,
4145}
4146
4147/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4148/// if the responder is dropped without sending a response, so that the client
4149/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4150impl std::ops::Drop for BufferCollectionGetBufferCollectionIdResponder {
4151    fn drop(&mut self) {
4152        self.control_handle.shutdown();
4153        // Safety: drops once, never accessed again
4154        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4155    }
4156}
4157
4158impl fdomain_client::fidl::Responder for BufferCollectionGetBufferCollectionIdResponder {
4159    type ControlHandle = BufferCollectionControlHandle;
4160
4161    fn control_handle(&self) -> &BufferCollectionControlHandle {
4162        &self.control_handle
4163    }
4164
4165    fn drop_without_shutdown(mut self) {
4166        // Safety: drops once, never accessed again due to mem::forget
4167        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4168        // Prevent Drop from running (which would shut down the channel)
4169        std::mem::forget(self);
4170    }
4171}
4172
4173impl BufferCollectionGetBufferCollectionIdResponder {
4174    /// Sends a response to the FIDL transaction.
4175    ///
4176    /// Sets the channel to shutdown if an error occurs.
4177    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
4178        let _result = self.send_raw(payload);
4179        if _result.is_err() {
4180            self.control_handle.shutdown();
4181        }
4182        self.drop_without_shutdown();
4183        _result
4184    }
4185
4186    /// Similar to "send" but does not shutdown the channel if an error occurs.
4187    pub fn send_no_shutdown_on_err(
4188        self,
4189        mut payload: &NodeGetBufferCollectionIdResponse,
4190    ) -> Result<(), fidl::Error> {
4191        let _result = self.send_raw(payload);
4192        self.drop_without_shutdown();
4193        _result
4194    }
4195
4196    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
4197        self.control_handle
4198            .inner
4199            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
4200                fidl::encoding::Flexible::new(payload),
4201                self.tx_id,
4202                0x77d19a494b78ba8c,
4203                fidl::encoding::DynamicFlags::FLEXIBLE,
4204            )
4205    }
4206}
4207
4208#[must_use = "FIDL methods require a response to be sent"]
4209#[derive(Debug)]
4210pub struct BufferCollectionWaitForAllBuffersAllocatedResponder {
4211    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4212    tx_id: u32,
4213}
4214
4215/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4216/// if the responder is dropped without sending a response, so that the client
4217/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4218impl std::ops::Drop for BufferCollectionWaitForAllBuffersAllocatedResponder {
4219    fn drop(&mut self) {
4220        self.control_handle.shutdown();
4221        // Safety: drops once, never accessed again
4222        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4223    }
4224}
4225
4226impl fdomain_client::fidl::Responder for BufferCollectionWaitForAllBuffersAllocatedResponder {
4227    type ControlHandle = BufferCollectionControlHandle;
4228
4229    fn control_handle(&self) -> &BufferCollectionControlHandle {
4230        &self.control_handle
4231    }
4232
4233    fn drop_without_shutdown(mut self) {
4234        // Safety: drops once, never accessed again due to mem::forget
4235        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4236        // Prevent Drop from running (which would shut down the channel)
4237        std::mem::forget(self);
4238    }
4239}
4240
4241impl BufferCollectionWaitForAllBuffersAllocatedResponder {
4242    /// Sends a response to the FIDL transaction.
4243    ///
4244    /// Sets the channel to shutdown if an error occurs.
4245    pub fn send(
4246        self,
4247        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4248    ) -> Result<(), fidl::Error> {
4249        let _result = self.send_raw(result);
4250        if _result.is_err() {
4251            self.control_handle.shutdown();
4252        }
4253        self.drop_without_shutdown();
4254        _result
4255    }
4256
4257    /// Similar to "send" but does not shutdown the channel if an error occurs.
4258    pub fn send_no_shutdown_on_err(
4259        self,
4260        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4261    ) -> Result<(), fidl::Error> {
4262        let _result = self.send_raw(result);
4263        self.drop_without_shutdown();
4264        _result
4265    }
4266
4267    fn send_raw(
4268        &self,
4269        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4270    ) -> Result<(), fidl::Error> {
4271        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4272            BufferCollectionWaitForAllBuffersAllocatedResponse,
4273            Error,
4274        >>(
4275            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4276            self.tx_id,
4277            0x62300344b61404e,
4278            fidl::encoding::DynamicFlags::FLEXIBLE,
4279        )
4280    }
4281}
4282
4283#[must_use = "FIDL methods require a response to be sent"]
4284#[derive(Debug)]
4285pub struct BufferCollectionCheckAllBuffersAllocatedResponder {
4286    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4287    tx_id: u32,
4288}
4289
4290/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4291/// if the responder is dropped without sending a response, so that the client
4292/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4293impl std::ops::Drop for BufferCollectionCheckAllBuffersAllocatedResponder {
4294    fn drop(&mut self) {
4295        self.control_handle.shutdown();
4296        // Safety: drops once, never accessed again
4297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4298    }
4299}
4300
4301impl fdomain_client::fidl::Responder for BufferCollectionCheckAllBuffersAllocatedResponder {
4302    type ControlHandle = BufferCollectionControlHandle;
4303
4304    fn control_handle(&self) -> &BufferCollectionControlHandle {
4305        &self.control_handle
4306    }
4307
4308    fn drop_without_shutdown(mut self) {
4309        // Safety: drops once, never accessed again due to mem::forget
4310        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4311        // Prevent Drop from running (which would shut down the channel)
4312        std::mem::forget(self);
4313    }
4314}
4315
4316impl BufferCollectionCheckAllBuffersAllocatedResponder {
4317    /// Sends a response to the FIDL transaction.
4318    ///
4319    /// Sets the channel to shutdown if an error occurs.
4320    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4321        let _result = self.send_raw(result);
4322        if _result.is_err() {
4323            self.control_handle.shutdown();
4324        }
4325        self.drop_without_shutdown();
4326        _result
4327    }
4328
4329    /// Similar to "send" but does not shutdown the channel if an error occurs.
4330    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4331        let _result = self.send_raw(result);
4332        self.drop_without_shutdown();
4333        _result
4334    }
4335
4336    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4337        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4338            fidl::encoding::EmptyStruct,
4339            Error,
4340        >>(
4341            fidl::encoding::FlexibleResult::new(result),
4342            self.tx_id,
4343            0x35a5fe77ce939c10,
4344            fidl::encoding::DynamicFlags::FLEXIBLE,
4345        )
4346    }
4347}
4348
4349#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4350pub struct BufferCollectionTokenMarker;
4351
4352impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenMarker {
4353    type Proxy = BufferCollectionTokenProxy;
4354    type RequestStream = BufferCollectionTokenRequestStream;
4355
4356    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
4357}
4358
4359pub trait BufferCollectionTokenProxyInterface: Send + Sync {
4360    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4361    fn r#sync(&self) -> Self::SyncResponseFut;
4362    fn r#release(&self) -> Result<(), fidl::Error>;
4363    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
4364    fn r#set_debug_client_info(
4365        &self,
4366        payload: &NodeSetDebugClientInfoRequest,
4367    ) -> Result<(), fidl::Error>;
4368    fn r#set_debug_timeout_log_deadline(
4369        &self,
4370        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
4371    ) -> Result<(), fidl::Error>;
4372    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
4373    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
4374        + Send;
4375    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
4376    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
4377        + Send;
4378    fn r#is_alternate_for(
4379        &self,
4380        payload: NodeIsAlternateForRequest,
4381    ) -> Self::IsAlternateForResponseFut;
4382    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
4383        + Send;
4384    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
4385    fn r#set_weak(&self) -> Result<(), fidl::Error>;
4386    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
4387    fn r#attach_node_tracking(
4388        &self,
4389        payload: NodeAttachNodeTrackingRequest,
4390    ) -> Result<(), fidl::Error>;
4391    type DuplicateSyncResponseFut: std::future::Future<
4392            Output = Result<BufferCollectionTokenDuplicateSyncResponse, fidl::Error>,
4393        > + Send;
4394    fn r#duplicate_sync(
4395        &self,
4396        payload: &BufferCollectionTokenDuplicateSyncRequest,
4397    ) -> Self::DuplicateSyncResponseFut;
4398    fn r#duplicate(
4399        &self,
4400        payload: BufferCollectionTokenDuplicateRequest,
4401    ) -> Result<(), fidl::Error>;
4402    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
4403    fn r#create_buffer_collection_token_group(
4404        &self,
4405        payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
4406    ) -> Result<(), fidl::Error>;
4407}
4408
4409#[derive(Debug, Clone)]
4410pub struct BufferCollectionTokenProxy {
4411    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4412}
4413
4414impl fdomain_client::fidl::Proxy for BufferCollectionTokenProxy {
4415    type Protocol = BufferCollectionTokenMarker;
4416
4417    fn from_channel(inner: fdomain_client::Channel) -> Self {
4418        Self::new(inner)
4419    }
4420
4421    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4422        self.client.into_channel().map_err(|client| Self { client })
4423    }
4424
4425    fn as_channel(&self) -> &fdomain_client::Channel {
4426        self.client.as_channel()
4427    }
4428}
4429
4430impl BufferCollectionTokenProxy {
4431    /// Create a new Proxy for fuchsia.sysmem2/BufferCollectionToken.
4432    pub fn new(channel: fdomain_client::Channel) -> Self {
4433        let protocol_name =
4434            <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4435        Self { client: fidl::client::Client::new(channel, protocol_name) }
4436    }
4437
4438    /// Get a Stream of events from the remote end of the protocol.
4439    ///
4440    /// # Panics
4441    ///
4442    /// Panics if the event stream was already taken.
4443    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
4444        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
4445    }
4446
4447    /// Ensure that previous messages have been received server side. This is
4448    /// particularly useful after previous messages that created new tokens,
4449    /// because a token must be known to the sysmem server before sending the
4450    /// token to another participant.
4451    ///
4452    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
4453    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
4454    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
4455    /// to mitigate the possibility of a hostile/fake
4456    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
4457    /// Another way is to pass the token to
4458    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
4459    /// the token as part of exchanging it for a
4460    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
4461    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
4462    /// of stalling.
4463    ///
4464    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
4465    /// and then starting and completing a `Sync`, it's then safe to send the
4466    /// `BufferCollectionToken` client ends to other participants knowing the
4467    /// server will recognize the tokens when they're sent by the other
4468    /// participants to sysmem in a
4469    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
4470    /// efficient way to create tokens while avoiding unnecessary round trips.
4471    ///
4472    /// Other options include waiting for each
4473    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
4474    /// individually (using separate call to `Sync` after each), or calling
4475    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
4476    /// converted to a `BufferCollection` via
4477    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
4478    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
4479    /// the sync step and can create multiple tokens at once.
4480    pub fn r#sync(
4481        &self,
4482    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
4483        BufferCollectionTokenProxyInterface::r#sync(self)
4484    }
4485
4486    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
4487    ///
4488    /// Normally a participant will convert a `BufferCollectionToken` into a
4489    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
4490    /// `Release` via the token (and then close the channel immediately or
4491    /// shortly later in response to server closing the server end), which
4492    /// avoids causing buffer collection failure. Without a prior `Release`,
4493    /// closing the `BufferCollectionToken` client end will cause buffer
4494    /// collection failure.
4495    ///
4496    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
4497    ///
4498    /// By default the server handles unexpected closure of a
4499    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
4500    /// first) by failing the buffer collection. Partly this is to expedite
4501    /// closing VMO handles to reclaim memory when any participant fails. If a
4502    /// participant would like to cleanly close a `BufferCollection` without
4503    /// causing buffer collection failure, the participant can send `Release`
4504    /// before closing the `BufferCollection` client end. The `Release` can
4505    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
4506    /// buffer collection won't require constraints from this node in order to
4507    /// allocate. If after `SetConstraints`, the constraints are retained and
4508    /// aggregated, despite the lack of `BufferCollection` connection at the
4509    /// time of constraints aggregation.
4510    ///
4511    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
4512    ///
4513    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
4514    /// end (without `Release` first) will trigger failure of the buffer
4515    /// collection. To close a `BufferCollectionTokenGroup` channel without
4516    /// failing the buffer collection, ensure that AllChildrenPresent() has been
4517    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
4518    /// client end.
4519    ///
4520    /// If `Release` occurs before
4521    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
4522    /// buffer collection will fail (triggered by reception of `Release` without
4523    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
4524    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
4525    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
4526    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
4527    /// close requires `AllChildrenPresent` (if not already sent), then
4528    /// `Release`, then close client end.
4529    ///
4530    /// If `Release` occurs after `AllChildrenPresent`, the children and all
4531    /// their constraints remain intact (just as they would if the
4532    /// `BufferCollectionTokenGroup` channel had remained open), and the client
4533    /// end close doesn't trigger buffer collection failure.
4534    ///
4535    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
4536    ///
4537    /// For brevity, the per-channel-protocol paragraphs above ignore the
4538    /// separate failure domain created by
4539    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
4540    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
4541    /// unexpectedly closes (without `Release` first) and that client end is
4542    /// under a failure domain, instead of failing the whole buffer collection,
4543    /// the failure domain is failed, but the buffer collection itself is
4544    /// isolated from failure of the failure domain. Such failure domains can be
4545    /// nested, in which case only the inner-most failure domain in which the
4546    /// `Node` resides fails.
4547    pub fn r#release(&self) -> Result<(), fidl::Error> {
4548        BufferCollectionTokenProxyInterface::r#release(self)
4549    }
4550
4551    /// Set a name for VMOs in this buffer collection.
4552    ///
4553    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
4554    /// will be truncated to fit. The name of the vmo will be suffixed with the
4555    /// buffer index within the collection (if the suffix fits within
4556    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
4557    /// listed in the inspect data.
4558    ///
4559    /// The name only affects VMOs allocated after the name is set; this call
4560    /// does not rename existing VMOs. If multiple clients set different names
4561    /// then the larger priority value will win. Setting a new name with the
4562    /// same priority as a prior name doesn't change the name.
4563    ///
4564    /// All table fields are currently required.
4565    ///
4566    /// + request `priority` The name is only set if this is the first `SetName`
4567    ///   or if `priority` is greater than any previous `priority` value in
4568    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
4569    /// + request `name` The name for VMOs created under this buffer collection.
4570    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
4571        BufferCollectionTokenProxyInterface::r#set_name(self, payload)
4572    }
4573
4574    /// Set information about the current client that can be used by sysmem to
4575    /// help diagnose leaking memory and allocation stalls waiting for a
4576    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
4577    ///
4578    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
4579    /// `Node`(s) derived from this `Node`, unless overriden by
4580    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
4581    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
4582    ///
4583    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
4584    /// `Allocator` is the most efficient way to ensure that all
4585    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
4586    /// set, and is also more efficient than separately sending the same debug
4587    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
4588    /// created [`fuchsia.sysmem2/Node`].
4589    ///
4590    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
4591    /// indicate which client is closing their channel first, leading to subtree
4592    /// failure (which can be normal if the purpose of the subtree is over, but
4593    /// if happening earlier than expected, the client-channel-specific name can
4594    /// help diagnose where the failure is first coming from, from sysmem's
4595    /// point of view).
4596    ///
4597    /// All table fields are currently required.
4598    ///
4599    /// + request `name` This can be an arbitrary string, but the current
4600    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
4601    /// + request `id` This can be an arbitrary id, but the current process ID
4602    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
4603    pub fn r#set_debug_client_info(
4604        &self,
4605        mut payload: &NodeSetDebugClientInfoRequest,
4606    ) -> Result<(), fidl::Error> {
4607        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, payload)
4608    }
4609
4610    /// Sysmem logs a warning if sysmem hasn't seen
4611    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
4612    /// within 5 seconds after creation of a new collection.
4613    ///
4614    /// Clients can call this method to change when the log is printed. If
4615    /// multiple client set the deadline, it's unspecified which deadline will
4616    /// take effect.
4617    ///
4618    /// In most cases the default works well.
4619    ///
4620    /// All table fields are currently required.
4621    ///
4622    /// + request `deadline` The time at which sysmem will start trying to log
4623    ///   the warning, unless all constraints are with sysmem by then.
4624    pub fn r#set_debug_timeout_log_deadline(
4625        &self,
4626        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
4627    ) -> Result<(), fidl::Error> {
4628        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
4629    }
4630
4631    /// This enables verbose logging for the buffer collection.
4632    ///
4633    /// Verbose logging includes constraints set via
4634    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
4635    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
4636    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
4637    /// the tree of `Node`(s).
4638    ///
4639    /// Normally sysmem prints only a single line complaint when aggregation
4640    /// fails, with just the specific detailed reason that aggregation failed,
4641    /// with little surrounding context.  While this is often enough to diagnose
4642    /// a problem if only a small change was made and everything was working
4643    /// before the small change, it's often not particularly helpful for getting
4644    /// a new buffer collection to work for the first time.  Especially with
4645    /// more complex trees of nodes, involving things like
4646    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
4647    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
4648    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
4649    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
4650    /// looks like and why it's failing a logical allocation, or why a tree or
4651    /// subtree is failing sooner than expected.
4652    ///
4653    /// The intent of the extra logging is to be acceptable from a performance
4654    /// point of view, under the assumption that verbose logging is only enabled
4655    /// on a low number of buffer collections. If we're not tracking down a bug,
4656    /// we shouldn't send this message.
4657    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4658        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
4659    }
4660
4661    /// This gets a handle that can be used as a parameter to
4662    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
4663    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
4664    /// client obtained this handle from this `Node`.
4665    ///
4666    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
4667    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
4668    /// despite the two calls typically being on different channels.
4669    ///
4670    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
4671    ///
4672    /// All table fields are currently required.
4673    ///
4674    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
4675    ///   different `Node` channel, to prove that the client obtained the handle
4676    ///   from this `Node`.
4677    pub fn r#get_node_ref(
4678        &self,
4679    ) -> fidl::client::QueryResponseFut<
4680        NodeGetNodeRefResponse,
4681        fdomain_client::fidl::FDomainResourceDialect,
4682    > {
4683        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
4684    }
4685
4686    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
4687    /// rooted at a different child token of a common parent
4688    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
4689    /// passed-in `node_ref`.
4690    ///
4691    /// This call is for assisting with admission control de-duplication, and
4692    /// with debugging.
4693    ///
4694    /// The `node_ref` must be obtained using
4695    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
4696    ///
4697    /// The `node_ref` can be a duplicated handle; it's not necessary to call
4698    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
4699    ///
4700    /// If a calling token may not actually be a valid token at all due to a
4701    /// potentially hostile/untrusted provider of the token, call
4702    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
4703    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
4704    /// never responds due to a calling token not being a real token (not really
4705    /// talking to sysmem).  Another option is to call
4706    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
4707    /// which also validates the token along with converting it to a
4708    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
4709    ///
4710    /// All table fields are currently required.
4711    ///
4712    /// - response `is_alternate`
4713    ///   - true: The first parent node in common between the calling node and
4714    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
4715    ///     that the calling `Node` and the `node_ref` `Node` will not have both
4716    ///     their constraints apply - rather sysmem will choose one or the other
4717    ///     of the constraints - never both.  This is because only one child of
4718    ///     a `BufferCollectionTokenGroup` is selected during logical
4719    ///     allocation, with only that one child's subtree contributing to
4720    ///     constraints aggregation.
4721    ///   - false: The first parent node in common between the calling `Node`
4722    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
4723    ///     Currently, this means the first parent node in common is a
4724    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
4725    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
4726    ///     `Node` may have both their constraints apply during constraints
4727    ///     aggregation of the logical allocation, if both `Node`(s) are
4728    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
4729    ///     this case, there is no `BufferCollectionTokenGroup` that will
4730    ///     directly prevent the two `Node`(s) from both being selected and
4731    ///     their constraints both aggregated, but even when false, one or both
4732    ///     `Node`(s) may still be eliminated from consideration if one or both
4733    ///     `Node`(s) has a direct or indirect parent
4734    ///     `BufferCollectionTokenGroup` which selects a child subtree other
4735    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
4736    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
4737    ///   associated with the same buffer collection as the calling `Node`.
4738    ///   Another reason for this error is if the `node_ref` is an
4739    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
4740    ///   a real `node_ref` obtained from `GetNodeRef`.
4741    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
4742    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
4743    ///   the needed rights expected on a real `node_ref`.
4744    /// * No other failing status codes are returned by this call.  However,
4745    ///   sysmem may add additional codes in future, so the client should have
4746    ///   sensible default handling for any failing status code.
4747    pub fn r#is_alternate_for(
4748        &self,
4749        mut payload: NodeIsAlternateForRequest,
4750    ) -> fidl::client::QueryResponseFut<
4751        NodeIsAlternateForResult,
4752        fdomain_client::fidl::FDomainResourceDialect,
4753    > {
4754        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, payload)
4755    }
4756
4757    /// Get the buffer collection ID. This ID is also available from
4758    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
4759    /// within the collection).
4760    ///
4761    /// This call is mainly useful in situations where we can't convey a
4762    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
4763    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
4764    /// handle, which can be joined back up with a `BufferCollection` client end
4765    /// that was created via a different path. Prefer to convey a
4766    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
4767    ///
4768    /// Trusting a `buffer_collection_id` value from a source other than sysmem
4769    /// is analogous to trusting a koid value from a source other than zircon.
4770    /// Both should be avoided unless really necessary, and both require
4771    /// caution. In some situations it may be reasonable to refer to a
4772    /// pre-established `BufferCollection` by `buffer_collection_id` via a
4773    /// protocol for efficiency reasons, but an incoming value purporting to be
4774    /// a `buffer_collection_id` is not sufficient alone to justify granting the
4775    /// sender of the `buffer_collection_id` any capability. The sender must
4776    /// first prove to a receiver that the sender has/had a VMO or has/had a
4777    /// `BufferCollectionToken` to the same collection by sending a handle that
4778    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
4779    /// `buffer_collection_id` value. The receiver should take care to avoid
4780    /// assuming that a sender had a `BufferCollectionToken` in cases where the
4781    /// sender has only proven that the sender had a VMO.
4782    ///
4783    /// - response `buffer_collection_id` This ID is unique per buffer
4784    ///   collection per boot. Each buffer is uniquely identified by the
4785    ///   `buffer_collection_id` and `buffer_index` together.
4786    pub fn r#get_buffer_collection_id(
4787        &self,
4788    ) -> fidl::client::QueryResponseFut<
4789        NodeGetBufferCollectionIdResponse,
4790        fdomain_client::fidl::FDomainResourceDialect,
4791    > {
4792        BufferCollectionTokenProxyInterface::r#get_buffer_collection_id(self)
4793    }
4794
4795    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
4796    /// created after this message to weak, which means that a client's `Node`
4797    /// client end (or a child created after this message) is not alone
4798    /// sufficient to keep allocated VMOs alive.
4799    ///
4800    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
4801    /// `close_weak_asap`.
4802    ///
4803    /// This message is only permitted before the `Node` becomes ready for
4804    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
4805    ///   * `BufferCollectionToken`: any time
4806    ///   * `BufferCollection`: before `SetConstraints`
4807    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
4808    ///
4809    /// Currently, no conversion from strong `Node` to weak `Node` after ready
4810    /// for allocation is provided, but a client can simulate that by creating
4811    /// an additional `Node` before allocation and setting that additional
4812    /// `Node` to weak, and then potentially at some point later sending
4813    /// `Release` and closing the client end of the client's strong `Node`, but
4814    /// keeping the client's weak `Node`.
4815    ///
4816    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
4817    /// collection failure (all `Node` client end(s) will see
4818    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
4819    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
4820    /// this situation until all `Node`(s) are ready for allocation. For initial
4821    /// allocation to succeed, at least one strong `Node` is required to exist
4822    /// at allocation time, but after that client receives VMO handles, that
4823    /// client can `BufferCollection.Release` and close the client end without
4824    /// causing this type of failure.
4825    ///
4826    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
4827    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
4828    /// separately as appropriate.
4829    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
4830        BufferCollectionTokenProxyInterface::r#set_weak(self)
4831    }
4832
4833    /// This indicates to sysmem that the client is prepared to pay attention to
4834    /// `close_weak_asap`.
4835    ///
4836    /// If sent, this message must be before
4837    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
4838    ///
4839    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
4840    /// send this message before `WaitForAllBuffersAllocated`, or a parent
4841    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
4842    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
4843    /// trigger buffer collection failure.
4844    ///
4845    /// This message is necessary because weak sysmem VMOs have not always been
4846    /// a thing, so older clients are not aware of the need to pay attention to
4847    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
4848    /// sysmem weak VMO handles asap. By having this message and requiring
4849    /// participants to indicate their acceptance of this aspect of the overall
4850    /// protocol, we avoid situations where an older client is delivered a weak
4851    /// VMO without any way for sysmem to get that VMO to close quickly later
4852    /// (and on a per-buffer basis).
4853    ///
4854    /// A participant that doesn't handle `close_weak_asap` and also doesn't
4855    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
4856    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
4857    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
4858    /// same participant has a child/delegate which does retrieve VMOs, that
4859    /// child/delegate will need to send `SetWeakOk` before
4860    /// `WaitForAllBuffersAllocated`.
4861    ///
4862    /// + request `for_child_nodes_also` If present and true, this means direct
4863    ///   child nodes of this node created after this message plus all
4864    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
4865    ///   those nodes. Any child node of this node that was created before this
4866    ///   message is not included. This setting is "sticky" in the sense that a
4867    ///   subsequent `SetWeakOk` without this bool set to true does not reset
4868    ///   the server-side bool. If this creates a problem for a participant, a
4869    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
4870    ///   tokens instead, as appropriate. A participant should only set
4871    ///   `for_child_nodes_also` true if the participant can really promise to
4872    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
4873    ///   weak VMO handles held by participants holding the corresponding child
4874    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
4875    ///   which are using sysmem(1) can be weak, despite the clients of those
4876    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
4877    ///   direct way to find out about `close_weak_asap`. This only applies to
4878    ///   descendents of this `Node` which are using sysmem(1), not to this
4879    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
4880    ///   token, which will fail allocation unless an ancestor of this `Node`
4881    ///   specified `for_child_nodes_also` true.
4882    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
4883        BufferCollectionTokenProxyInterface::r#set_weak_ok(self, payload)
4884    }
4885
4886    /// The server_end will be closed after this `Node` and any child nodes have
4887    /// have released their buffer counts, making those counts available for
4888    /// reservation by a different `Node` via
4889    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
4890    ///
4891    /// The `Node` buffer counts may not be released until the entire tree of
4892    /// `Node`(s) is closed or failed, because
4893    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
4894    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
4895    /// `Node` buffer counts remain reserved until the orphaned node is later
4896    /// cleaned up.
4897    ///
4898    /// If the `Node` exceeds a fairly large number of attached eventpair server
4899    /// ends, a log message will indicate this and the `Node` (and the
4900    /// appropriate) sub-tree will fail.
4901    ///
4902    /// The `server_end` will remain open when
4903    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
4904    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
4905    /// [`fuchsia.sysmem2/BufferCollection`].
4906    ///
4907    /// This message can also be used with a
4908    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
4909    pub fn r#attach_node_tracking(
4910        &self,
4911        mut payload: NodeAttachNodeTrackingRequest,
4912    ) -> Result<(), fidl::Error> {
4913        BufferCollectionTokenProxyInterface::r#attach_node_tracking(self, payload)
4914    }
4915
4916    /// Create additional [`fuchsia.sysmem2/BufferCollectionToken`](s) from this
4917    /// one, referring to the same buffer collection.
4918    ///
4919    /// The created tokens are children of this token in the
4920    /// [`fuchsia.sysmem2/Node`] heirarchy.
4921    ///
4922    /// This method can be used to add more participants, by transferring the
4923    /// newly created tokens to additional participants.
4924    ///
4925    /// A new token will be returned for each entry in the
4926    /// `rights_attenuation_masks` array.
4927    ///
4928    /// If the called token may not actually be a valid token due to a
4929    /// potentially hostile/untrusted provider of the token, consider using
4930    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
4931    /// instead of potentially getting stuck indefinitely if
4932    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] never responds
4933    /// due to the calling token not being a real token.
4934    ///
4935    /// In contrast to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], no
4936    /// separate [`fuchsia.sysmem2/Node.Sync`] is needed after calling this
4937    /// method, because the sync step is included in this call, at the cost of a
4938    /// round trip during this call.
4939    ///
4940    /// All tokens must be turned in to sysmem via
4941    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
4942    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
4943    /// successfully allocate buffers (or to logically allocate buffers in the
4944    /// case of subtrees involving
4945    /// [`fuchsia.sysmem2/BufferCollectionToken.AttachToken`]).
4946    ///
4947    /// All table fields are currently required.
4948    ///
4949    /// + request `rights_attenuation_mask` In each entry of
4950    ///   `rights_attenuation_masks`, rights bits that are zero will be absent
4951    ///   in the buffer VMO rights obtainable via the corresponding returned
4952    ///   token. This allows an initiator or intermediary participant to
4953    ///   attenuate the rights available to a participant. This does not allow a
4954    ///   participant to gain rights that the participant doesn't already have.
4955    ///   The value `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no
4956    ///   attenuation should be applied.
4957    /// - response `tokens` The client ends of each newly created token.
4958    pub fn r#duplicate_sync(
4959        &self,
4960        mut payload: &BufferCollectionTokenDuplicateSyncRequest,
4961    ) -> fidl::client::QueryResponseFut<
4962        BufferCollectionTokenDuplicateSyncResponse,
4963        fdomain_client::fidl::FDomainResourceDialect,
4964    > {
4965        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, payload)
4966    }
4967
4968    /// Create an additional [`fuchsia.sysmem2/BufferCollectionToken`] from this
4969    /// one, referring to the same buffer collection.
4970    ///
4971    /// The created token is a child of this token in the
4972    /// [`fuchsia.sysmem2/Node`] heirarchy.
4973    ///
4974    /// This method can be used to add a participant, by transferring the newly
4975    /// created token to another participant.
4976    ///
4977    /// This one-way message can be used instead of the two-way
4978    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] FIDL call in
4979    /// performance sensitive cases where it would be undesireable to wait for
4980    /// sysmem to respond to
4981    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or when the
4982    /// client code isn't structured to make it easy to duplicate all the needed
4983    /// tokens at once.
4984    ///
4985    /// After sending one or more `Duplicate` messages, and before sending the
4986    /// newly created child tokens to other participants (or to other
4987    /// [`fuchsia.sysmem2/Allocator`] channels), the client must send a
4988    /// [`fuchsia.sysmem2/Node.Sync`] and wait for the `Sync` response. The
4989    /// `Sync` call can be made on the token, or on the `BufferCollection`
4990    /// obtained by passing this token to `BindSharedCollection`.  Either will
4991    /// ensure that the server knows about the tokens created via `Duplicate`
4992    /// before the other participant sends the token to the server via separate
4993    /// `Allocator` channel.
4994    ///
4995    /// All tokens must be turned in via
4996    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
4997    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
4998    /// successfully allocate buffers.
4999    ///
5000    /// All table fields are currently required.
5001    ///
5002    /// + request `rights_attenuation_mask` The rights bits that are zero in
5003    ///   this mask will be absent in the buffer VMO rights obtainable via the
5004    ///   client end of `token_request`. This allows an initiator or
5005    ///   intermediary participant to attenuate the rights available to a
5006    ///   delegate participant. This does not allow a participant to gain rights
5007    ///   that the participant doesn't already have. The value
5008    ///   `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no attenuation
5009    ///   should be applied.
5010    ///   + These values for rights_attenuation_mask result in no attenuation:
5011    ///     + `ZX_RIGHT_SAME_RIGHTS` (preferred)
5012    ///     + 0xFFFFFFFF (this is reasonable when an attenuation mask is
5013    ///       computed)
5014    ///     + 0 (deprecated - do not use 0 - an ERROR will go to the log)
5015    /// + request `token_request` is the server end of a `BufferCollectionToken`
5016    ///   channel. The client end of this channel acts as another participant in
5017    ///   the shared buffer collection.
5018    pub fn r#duplicate(
5019        &self,
5020        mut payload: BufferCollectionTokenDuplicateRequest,
5021    ) -> Result<(), fidl::Error> {
5022        BufferCollectionTokenProxyInterface::r#duplicate(self, payload)
5023    }
5024
5025    /// Set this [`fuchsia.sysmem2/BufferCollectionToken`] to dispensable.
5026    ///
5027    /// When the `BufferCollectionToken` is converted to a
5028    /// [`fuchsia.sysmem2/BufferCollection`], the dispensable status applies to
5029    /// the `BufferCollection` also.
5030    ///
5031    /// Normally, if a client closes a [`fuchsia.sysmem2/BufferCollection`]
5032    /// client end without having sent
5033    /// [`fuchsia.sysmem2/BufferCollection.Release`] first, the
5034    /// `BufferCollection` [`fuchisa.sysmem2/Node`] will fail, which also
5035    /// propagates failure to the parent [`fuchsia.sysmem2/Node`] and so on up
5036    /// to the root `Node`, which fails the whole buffer collection. In
5037    /// contrast, a dispensable `Node` can fail after buffers are allocated
5038    /// without causing failure of its parent in the [`fuchsia.sysmem2/Node`]
5039    /// heirarchy.
5040    ///
5041    /// The dispensable `Node` participates in constraints aggregation along
5042    /// with its parent before buffer allocation. If the dispensable `Node`
5043    /// fails before buffers are allocated, the failure propagates to the
5044    /// dispensable `Node`'s parent.
5045    ///
5046    /// After buffers are allocated, failure of the dispensable `Node` (or any
5047    /// child of the dispensable `Node`) does not propagate to the dispensable
5048    /// `Node`'s parent. Failure does propagate from a normal child of a
5049    /// dispensable `Node` to the dispensable `Node`.  Failure of a child is
5050    /// blocked from reaching its parent if the child is attached using
5051    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or if the child is
5052    /// dispensable and the failure occurred after allocation.
5053    ///
5054    /// A dispensable `Node` can be used in cases where a participant needs to
5055    /// provide constraints, but after buffers are allocated, the participant
5056    /// can fail without causing buffer collection failure from the parent
5057    /// `Node`'s point of view.
5058    ///
5059    /// In contrast, `BufferCollection.AttachToken` can be used to create a
5060    /// `BufferCollectionToken` which does not participate in constraints
5061    /// aggregation with its parent `Node`, and whose failure at any time does
5062    /// not propagate to its parent `Node`, and whose potential delay providing
5063    /// constraints does not prevent the parent `Node` from completing its
5064    /// buffer allocation.
5065    ///
5066    /// An initiator (creator of the root `Node` using
5067    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`]) may in some
5068    /// scenarios choose to initially use a dispensable `Node` for a first
5069    /// instance of a participant, and then later if the first instance of that
5070    /// participant fails, a new second instance of that participant my be given
5071    /// a `BufferCollectionToken` created with `AttachToken`.
5072    ///
5073    /// Normally a client will `SetDispensable` on a `BufferCollectionToken`
5074    /// shortly before sending the dispensable `BufferCollectionToken` to a
5075    /// delegate participant. Because `SetDispensable` prevents propagation of
5076    /// child `Node` failure to parent `Node`(s), if the client was relying on
5077    /// noticing child failure via failure of the parent `Node` retained by the
5078    /// client, the client may instead need to notice failure via other means.
5079    /// If other means aren't available/convenient, the client can instead
5080    /// retain the dispensable `Node` and create a child `Node` under that to
5081    /// send to the delegate participant, retaining this `Node` in order to
5082    /// notice failure of the subtree rooted at this `Node` via this `Node`'s
5083    /// ZX_CHANNEL_PEER_CLOSED signal, and take whatever action is appropriate
5084    /// (e.g. starting a new instance of the delegate participant and handing it
5085    /// a `BufferCollectionToken` created using
5086    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or propagate failure
5087    /// and clean up in a client-specific way).
5088    ///
5089    /// While it is possible (and potentially useful) to `SetDispensable` on a
5090    /// direct child of a `BufferCollectionTokenGroup` `Node`, it isn't possible
5091    /// to later replace a failed dispensable `Node` that was a direct child of
5092    /// a `BufferCollectionTokenGroup` with a new token using `AttachToken`
5093    /// (since there's no `AttachToken` on a group). Instead, to enable
5094    /// `AttachToken` replacement in this case, create an additional
5095    /// non-dispensable token that's a direct child of the group and make the
5096    /// existing dispensable token a child of the additional token.  This way,
5097    /// the additional token that is a direct child of the group has
5098    /// `BufferCollection.AttachToken` which can be used to replace the failed
5099    /// dispensable token.
5100    ///
5101    /// `SetDispensable` on an already-dispensable token is idempotent.
5102    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5103        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
5104    }
5105
5106    /// Create a logical OR among a set of tokens, called a
5107    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
5108    ///
5109    /// Most sysmem clients and many participants don't need to care about this
5110    /// message or about `BufferCollectionTokenGroup`(s). However, in some cases
5111    /// a participant wants to attempt to include one set of delegate
5112    /// participants, but if constraints don't combine successfully that way,
5113    /// fall back to a different (possibly overlapping) set of delegate
5114    /// participants, and/or fall back to a less demanding strategy (in terms of
5115    /// how strict the [`fuchisa.sysmem2/BufferCollectionConstraints`] are,
5116    /// across all involved delegate participants). In such cases, a
5117    /// `BufferCollectionTokenGroup` is useful.
5118    ///
5119    /// A `BufferCollectionTokenGroup` is used to create a 1 of N OR among N
5120    /// child [`fuchsia.sysmem2/BufferCollectionToken`](s).  The child tokens
5121    /// which are not selected during aggregation will fail (close), which a
5122    /// potential participant should notice when their `BufferCollection`
5123    /// channel client endpoint sees PEER_CLOSED, allowing the participant to
5124    /// clean up the speculative usage that didn't end up happening (this is
5125    /// simimlar to a normal `BufferCollection` server end closing on failure to
5126    /// allocate a logical buffer collection or later async failure of a buffer
5127    /// collection).
5128    ///
5129    /// See comments on protocol `BufferCollectionTokenGroup`.
5130    ///
5131    /// Any `rights_attenuation_mask` or `AttachToken`/`SetDispensable` to be
5132    /// applied to the whole group can be achieved with a
5133    /// `BufferCollectionToken` for this purpose as a direct parent of the
5134    /// `BufferCollectionTokenGroup`.
5135    ///
5136    /// All table fields are currently required.
5137    ///
5138    /// + request `group_request` The server end of a
5139    ///   `BufferCollectionTokenGroup` channel to be served by sysmem.
5140    pub fn r#create_buffer_collection_token_group(
5141        &self,
5142        mut payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
5143    ) -> Result<(), fidl::Error> {
5144        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(self, payload)
5145    }
5146}
5147
5148impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
5149    type SyncResponseFut =
5150        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
5151    fn r#sync(&self) -> Self::SyncResponseFut {
5152        fn _decode(
5153            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5154        ) -> Result<(), fidl::Error> {
5155            let _response = fidl::client::decode_transaction_body::<
5156                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5157                fdomain_client::fidl::FDomainResourceDialect,
5158                0x11ac2555cf575b54,
5159            >(_buf?)?
5160            .into_result_fdomain::<BufferCollectionTokenMarker>("sync")?;
5161            Ok(_response)
5162        }
5163        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5164            (),
5165            0x11ac2555cf575b54,
5166            fidl::encoding::DynamicFlags::FLEXIBLE,
5167            _decode,
5168        )
5169    }
5170
5171    fn r#release(&self) -> Result<(), fidl::Error> {
5172        self.client.send::<fidl::encoding::EmptyPayload>(
5173            (),
5174            0x6a5cae7d6d6e04c6,
5175            fidl::encoding::DynamicFlags::FLEXIBLE,
5176        )
5177    }
5178
5179    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
5180        self.client.send::<NodeSetNameRequest>(
5181            payload,
5182            0xb41f1624f48c1e9,
5183            fidl::encoding::DynamicFlags::FLEXIBLE,
5184        )
5185    }
5186
5187    fn r#set_debug_client_info(
5188        &self,
5189        mut payload: &NodeSetDebugClientInfoRequest,
5190    ) -> Result<(), fidl::Error> {
5191        self.client.send::<NodeSetDebugClientInfoRequest>(
5192            payload,
5193            0x5cde8914608d99b1,
5194            fidl::encoding::DynamicFlags::FLEXIBLE,
5195        )
5196    }
5197
5198    fn r#set_debug_timeout_log_deadline(
5199        &self,
5200        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
5201    ) -> Result<(), fidl::Error> {
5202        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5203            payload,
5204            0x716b0af13d5c0806,
5205            fidl::encoding::DynamicFlags::FLEXIBLE,
5206        )
5207    }
5208
5209    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5210        self.client.send::<fidl::encoding::EmptyPayload>(
5211            (),
5212            0x5209c77415b4dfad,
5213            fidl::encoding::DynamicFlags::FLEXIBLE,
5214        )
5215    }
5216
5217    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
5218        NodeGetNodeRefResponse,
5219        fdomain_client::fidl::FDomainResourceDialect,
5220    >;
5221    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5222        fn _decode(
5223            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5224        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
5225            let _response = fidl::client::decode_transaction_body::<
5226                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
5227                fdomain_client::fidl::FDomainResourceDialect,
5228                0x5b3d0e51614df053,
5229            >(_buf?)?
5230            .into_result_fdomain::<BufferCollectionTokenMarker>("get_node_ref")?;
5231            Ok(_response)
5232        }
5233        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
5234            (),
5235            0x5b3d0e51614df053,
5236            fidl::encoding::DynamicFlags::FLEXIBLE,
5237            _decode,
5238        )
5239    }
5240
5241    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5242        NodeIsAlternateForResult,
5243        fdomain_client::fidl::FDomainResourceDialect,
5244    >;
5245    fn r#is_alternate_for(
5246        &self,
5247        mut payload: NodeIsAlternateForRequest,
5248    ) -> Self::IsAlternateForResponseFut {
5249        fn _decode(
5250            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5251        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5252            let _response = fidl::client::decode_transaction_body::<
5253                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
5254                fdomain_client::fidl::FDomainResourceDialect,
5255                0x3a58e00157e0825,
5256            >(_buf?)?
5257            .into_result_fdomain::<BufferCollectionTokenMarker>("is_alternate_for")?;
5258            Ok(_response.map(|x| x))
5259        }
5260        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5261            &mut payload,
5262            0x3a58e00157e0825,
5263            fidl::encoding::DynamicFlags::FLEXIBLE,
5264            _decode,
5265        )
5266    }
5267
5268    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
5269        NodeGetBufferCollectionIdResponse,
5270        fdomain_client::fidl::FDomainResourceDialect,
5271    >;
5272    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
5273        fn _decode(
5274            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5275        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
5276            let _response = fidl::client::decode_transaction_body::<
5277                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
5278                fdomain_client::fidl::FDomainResourceDialect,
5279                0x77d19a494b78ba8c,
5280            >(_buf?)?
5281            .into_result_fdomain::<BufferCollectionTokenMarker>("get_buffer_collection_id")?;
5282            Ok(_response)
5283        }
5284        self.client.send_query_and_decode::<
5285            fidl::encoding::EmptyPayload,
5286            NodeGetBufferCollectionIdResponse,
5287        >(
5288            (),
5289            0x77d19a494b78ba8c,
5290            fidl::encoding::DynamicFlags::FLEXIBLE,
5291            _decode,
5292        )
5293    }
5294
5295    fn r#set_weak(&self) -> Result<(), fidl::Error> {
5296        self.client.send::<fidl::encoding::EmptyPayload>(
5297            (),
5298            0x22dd3ea514eeffe1,
5299            fidl::encoding::DynamicFlags::FLEXIBLE,
5300        )
5301    }
5302
5303    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
5304        self.client.send::<NodeSetWeakOkRequest>(
5305            &mut payload,
5306            0x38a44fc4d7724be9,
5307            fidl::encoding::DynamicFlags::FLEXIBLE,
5308        )
5309    }
5310
5311    fn r#attach_node_tracking(
5312        &self,
5313        mut payload: NodeAttachNodeTrackingRequest,
5314    ) -> Result<(), fidl::Error> {
5315        self.client.send::<NodeAttachNodeTrackingRequest>(
5316            &mut payload,
5317            0x3f22f2a293d3cdac,
5318            fidl::encoding::DynamicFlags::FLEXIBLE,
5319        )
5320    }
5321
5322    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
5323        BufferCollectionTokenDuplicateSyncResponse,
5324        fdomain_client::fidl::FDomainResourceDialect,
5325    >;
5326    fn r#duplicate_sync(
5327        &self,
5328        mut payload: &BufferCollectionTokenDuplicateSyncRequest,
5329    ) -> Self::DuplicateSyncResponseFut {
5330        fn _decode(
5331            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5332        ) -> Result<BufferCollectionTokenDuplicateSyncResponse, fidl::Error> {
5333            let _response = fidl::client::decode_transaction_body::<
5334                fidl::encoding::FlexibleType<BufferCollectionTokenDuplicateSyncResponse>,
5335                fdomain_client::fidl::FDomainResourceDialect,
5336                0x1c1af9919d1ca45c,
5337            >(_buf?)?
5338            .into_result_fdomain::<BufferCollectionTokenMarker>("duplicate_sync")?;
5339            Ok(_response)
5340        }
5341        self.client.send_query_and_decode::<
5342            BufferCollectionTokenDuplicateSyncRequest,
5343            BufferCollectionTokenDuplicateSyncResponse,
5344        >(
5345            payload,
5346            0x1c1af9919d1ca45c,
5347            fidl::encoding::DynamicFlags::FLEXIBLE,
5348            _decode,
5349        )
5350    }
5351
5352    fn r#duplicate(
5353        &self,
5354        mut payload: BufferCollectionTokenDuplicateRequest,
5355    ) -> Result<(), fidl::Error> {
5356        self.client.send::<BufferCollectionTokenDuplicateRequest>(
5357            &mut payload,
5358            0x73e78f92ee7fb887,
5359            fidl::encoding::DynamicFlags::FLEXIBLE,
5360        )
5361    }
5362
5363    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5364        self.client.send::<fidl::encoding::EmptyPayload>(
5365            (),
5366            0x228acf979254df8b,
5367            fidl::encoding::DynamicFlags::FLEXIBLE,
5368        )
5369    }
5370
5371    fn r#create_buffer_collection_token_group(
5372        &self,
5373        mut payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
5374    ) -> Result<(), fidl::Error> {
5375        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
5376            &mut payload,
5377            0x30f8d48e77bd36f2,
5378            fidl::encoding::DynamicFlags::FLEXIBLE,
5379        )
5380    }
5381}
5382
5383pub struct BufferCollectionTokenEventStream {
5384    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5385}
5386
5387impl std::marker::Unpin for BufferCollectionTokenEventStream {}
5388
5389impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
5390    fn is_terminated(&self) -> bool {
5391        self.event_receiver.is_terminated()
5392    }
5393}
5394
5395impl futures::Stream for BufferCollectionTokenEventStream {
5396    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
5397
5398    fn poll_next(
5399        mut self: std::pin::Pin<&mut Self>,
5400        cx: &mut std::task::Context<'_>,
5401    ) -> std::task::Poll<Option<Self::Item>> {
5402        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5403            &mut self.event_receiver,
5404            cx
5405        )?) {
5406            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
5407            None => std::task::Poll::Ready(None),
5408        }
5409    }
5410}
5411
5412#[derive(Debug)]
5413pub enum BufferCollectionTokenEvent {
5414    #[non_exhaustive]
5415    _UnknownEvent {
5416        /// Ordinal of the event that was sent.
5417        ordinal: u64,
5418    },
5419}
5420
5421impl BufferCollectionTokenEvent {
5422    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
5423    fn decode(
5424        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5425    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
5426        let (bytes, _handles) = buf.split_mut();
5427        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5428        debug_assert_eq!(tx_header.tx_id, 0);
5429        match tx_header.ordinal {
5430            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5431                Ok(BufferCollectionTokenEvent::_UnknownEvent {
5432                    ordinal: tx_header.ordinal,
5433                })
5434            }
5435            _ => Err(fidl::Error::UnknownOrdinal {
5436                ordinal: tx_header.ordinal,
5437                protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5438            })
5439        }
5440    }
5441}
5442
5443/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollectionToken.
5444pub struct BufferCollectionTokenRequestStream {
5445    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5446    is_terminated: bool,
5447}
5448
5449impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
5450
5451impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
5452    fn is_terminated(&self) -> bool {
5453        self.is_terminated
5454    }
5455}
5456
5457impl fdomain_client::fidl::RequestStream for BufferCollectionTokenRequestStream {
5458    type Protocol = BufferCollectionTokenMarker;
5459    type ControlHandle = BufferCollectionTokenControlHandle;
5460
5461    fn from_channel(channel: fdomain_client::Channel) -> Self {
5462        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5463    }
5464
5465    fn control_handle(&self) -> Self::ControlHandle {
5466        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
5467    }
5468
5469    fn into_inner(
5470        self,
5471    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
5472    {
5473        (self.inner, self.is_terminated)
5474    }
5475
5476    fn from_inner(
5477        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5478        is_terminated: bool,
5479    ) -> Self {
5480        Self { inner, is_terminated }
5481    }
5482}
5483
5484impl futures::Stream for BufferCollectionTokenRequestStream {
5485    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
5486
5487    fn poll_next(
5488        mut self: std::pin::Pin<&mut Self>,
5489        cx: &mut std::task::Context<'_>,
5490    ) -> std::task::Poll<Option<Self::Item>> {
5491        let this = &mut *self;
5492        if this.inner.check_shutdown(cx) {
5493            this.is_terminated = true;
5494            return std::task::Poll::Ready(None);
5495        }
5496        if this.is_terminated {
5497            panic!("polled BufferCollectionTokenRequestStream after completion");
5498        }
5499        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5500            |bytes, handles| {
5501                match this.inner.channel().read_etc(cx, bytes, handles) {
5502                    std::task::Poll::Ready(Ok(())) => {}
5503                    std::task::Poll::Pending => return std::task::Poll::Pending,
5504                    std::task::Poll::Ready(Err(None)) => {
5505                        this.is_terminated = true;
5506                        return std::task::Poll::Ready(None);
5507                    }
5508                    std::task::Poll::Ready(Err(Some(e))) => {
5509                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5510                            e.into(),
5511                        ))));
5512                    }
5513                }
5514
5515                // A message has been received from the channel
5516                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5517
5518                std::task::Poll::Ready(Some(match header.ordinal {
5519                0x11ac2555cf575b54 => {
5520                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5521                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5522                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5523                    let control_handle = BufferCollectionTokenControlHandle {
5524                        inner: this.inner.clone(),
5525                    };
5526                    Ok(BufferCollectionTokenRequest::Sync {
5527                        responder: BufferCollectionTokenSyncResponder {
5528                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5529                            tx_id: header.tx_id,
5530                        },
5531                    })
5532                }
5533                0x6a5cae7d6d6e04c6 => {
5534                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5535                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5536                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5537                    let control_handle = BufferCollectionTokenControlHandle {
5538                        inner: this.inner.clone(),
5539                    };
5540                    Ok(BufferCollectionTokenRequest::Release {
5541                        control_handle,
5542                    })
5543                }
5544                0xb41f1624f48c1e9 => {
5545                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5546                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
5547                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5548                    let control_handle = BufferCollectionTokenControlHandle {
5549                        inner: this.inner.clone(),
5550                    };
5551                    Ok(BufferCollectionTokenRequest::SetName {payload: req,
5552                        control_handle,
5553                    })
5554                }
5555                0x5cde8914608d99b1 => {
5556                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5557                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
5558                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5559                    let control_handle = BufferCollectionTokenControlHandle {
5560                        inner: this.inner.clone(),
5561                    };
5562                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {payload: req,
5563                        control_handle,
5564                    })
5565                }
5566                0x716b0af13d5c0806 => {
5567                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5568                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
5569                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5570                    let control_handle = BufferCollectionTokenControlHandle {
5571                        inner: this.inner.clone(),
5572                    };
5573                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {payload: req,
5574                        control_handle,
5575                    })
5576                }
5577                0x5209c77415b4dfad => {
5578                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5579                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5580                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5581                    let control_handle = BufferCollectionTokenControlHandle {
5582                        inner: this.inner.clone(),
5583                    };
5584                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
5585                        control_handle,
5586                    })
5587                }
5588                0x5b3d0e51614df053 => {
5589                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5590                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5591                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5592                    let control_handle = BufferCollectionTokenControlHandle {
5593                        inner: this.inner.clone(),
5594                    };
5595                    Ok(BufferCollectionTokenRequest::GetNodeRef {
5596                        responder: BufferCollectionTokenGetNodeRefResponder {
5597                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5598                            tx_id: header.tx_id,
5599                        },
5600                    })
5601                }
5602                0x3a58e00157e0825 => {
5603                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5604                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
5605                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5606                    let control_handle = BufferCollectionTokenControlHandle {
5607                        inner: this.inner.clone(),
5608                    };
5609                    Ok(BufferCollectionTokenRequest::IsAlternateFor {payload: req,
5610                        responder: BufferCollectionTokenIsAlternateForResponder {
5611                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5612                            tx_id: header.tx_id,
5613                        },
5614                    })
5615                }
5616                0x77d19a494b78ba8c => {
5617                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5618                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5619                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5620                    let control_handle = BufferCollectionTokenControlHandle {
5621                        inner: this.inner.clone(),
5622                    };
5623                    Ok(BufferCollectionTokenRequest::GetBufferCollectionId {
5624                        responder: BufferCollectionTokenGetBufferCollectionIdResponder {
5625                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5626                            tx_id: header.tx_id,
5627                        },
5628                    })
5629                }
5630                0x22dd3ea514eeffe1 => {
5631                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5632                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5633                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5634                    let control_handle = BufferCollectionTokenControlHandle {
5635                        inner: this.inner.clone(),
5636                    };
5637                    Ok(BufferCollectionTokenRequest::SetWeak {
5638                        control_handle,
5639                    })
5640                }
5641                0x38a44fc4d7724be9 => {
5642                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5643                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
5644                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
5645                    let control_handle = BufferCollectionTokenControlHandle {
5646                        inner: this.inner.clone(),
5647                    };
5648                    Ok(BufferCollectionTokenRequest::SetWeakOk {payload: req,
5649                        control_handle,
5650                    })
5651                }
5652                0x3f22f2a293d3cdac => {
5653                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5654                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
5655                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
5656                    let control_handle = BufferCollectionTokenControlHandle {
5657                        inner: this.inner.clone(),
5658                    };
5659                    Ok(BufferCollectionTokenRequest::AttachNodeTracking {payload: req,
5660                        control_handle,
5661                    })
5662                }
5663                0x1c1af9919d1ca45c => {
5664                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5665                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
5666                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5667                    let control_handle = BufferCollectionTokenControlHandle {
5668                        inner: this.inner.clone(),
5669                    };
5670                    Ok(BufferCollectionTokenRequest::DuplicateSync {payload: req,
5671                        responder: BufferCollectionTokenDuplicateSyncResponder {
5672                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5673                            tx_id: header.tx_id,
5674                        },
5675                    })
5676                }
5677                0x73e78f92ee7fb887 => {
5678                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5679                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fdomain_client::fidl::FDomainResourceDialect);
5680                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
5681                    let control_handle = BufferCollectionTokenControlHandle {
5682                        inner: this.inner.clone(),
5683                    };
5684                    Ok(BufferCollectionTokenRequest::Duplicate {payload: req,
5685                        control_handle,
5686                    })
5687                }
5688                0x228acf979254df8b => {
5689                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5690                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5691                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5692                    let control_handle = BufferCollectionTokenControlHandle {
5693                        inner: this.inner.clone(),
5694                    };
5695                    Ok(BufferCollectionTokenRequest::SetDispensable {
5696                        control_handle,
5697                    })
5698                }
5699                0x30f8d48e77bd36f2 => {
5700                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5701                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fdomain_client::fidl::FDomainResourceDialect);
5702                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
5703                    let control_handle = BufferCollectionTokenControlHandle {
5704                        inner: this.inner.clone(),
5705                    };
5706                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {payload: req,
5707                        control_handle,
5708                    })
5709                }
5710                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5711                    Ok(BufferCollectionTokenRequest::_UnknownMethod {
5712                        ordinal: header.ordinal,
5713                        control_handle: BufferCollectionTokenControlHandle { inner: this.inner.clone() },
5714                        method_type: fidl::MethodType::OneWay,
5715                    })
5716                }
5717                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5718                    this.inner.send_framework_err(
5719                        fidl::encoding::FrameworkErr::UnknownMethod,
5720                        header.tx_id,
5721                        header.ordinal,
5722                        header.dynamic_flags(),
5723                        (bytes, handles),
5724                    )?;
5725                    Ok(BufferCollectionTokenRequest::_UnknownMethod {
5726                        ordinal: header.ordinal,
5727                        control_handle: BufferCollectionTokenControlHandle { inner: this.inner.clone() },
5728                        method_type: fidl::MethodType::TwoWay,
5729                    })
5730                }
5731                _ => Err(fidl::Error::UnknownOrdinal {
5732                    ordinal: header.ordinal,
5733                    protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5734                }),
5735            }))
5736            },
5737        )
5738    }
5739}
5740
5741/// A [`fuchsia.sysmem2/BufferCollectionToken`] is not a buffer collection, but
5742/// rather is a way to identify a specific potential shared buffer collection,
5743/// and a way to distribute that potential shared buffer collection to
5744/// additional participants prior to the buffer collection allocating any
5745/// buffers.
5746///
5747/// Epitaphs are not used in this protocol.
5748///
5749/// We use a channel for the `BufferCollectionToken` instead of a single
5750/// `eventpair` (pair) because this way we can detect error conditions like a
5751/// participant failing mid-create.
5752#[derive(Debug)]
5753pub enum BufferCollectionTokenRequest {
5754    /// Ensure that previous messages have been received server side. This is
5755    /// particularly useful after previous messages that created new tokens,
5756    /// because a token must be known to the sysmem server before sending the
5757    /// token to another participant.
5758    ///
5759    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
5760    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
5761    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
5762    /// to mitigate the possibility of a hostile/fake
5763    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
5764    /// Another way is to pass the token to
5765    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
5766    /// the token as part of exchanging it for a
5767    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
5768    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
5769    /// of stalling.
5770    ///
5771    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
5772    /// and then starting and completing a `Sync`, it's then safe to send the
5773    /// `BufferCollectionToken` client ends to other participants knowing the
5774    /// server will recognize the tokens when they're sent by the other
5775    /// participants to sysmem in a
5776    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
5777    /// efficient way to create tokens while avoiding unnecessary round trips.
5778    ///
5779    /// Other options include waiting for each
5780    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
5781    /// individually (using separate call to `Sync` after each), or calling
5782    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
5783    /// converted to a `BufferCollection` via
5784    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
5785    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
5786    /// the sync step and can create multiple tokens at once.
5787    Sync { responder: BufferCollectionTokenSyncResponder },
5788    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
5789    ///
5790    /// Normally a participant will convert a `BufferCollectionToken` into a
5791    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
5792    /// `Release` via the token (and then close the channel immediately or
5793    /// shortly later in response to server closing the server end), which
5794    /// avoids causing buffer collection failure. Without a prior `Release`,
5795    /// closing the `BufferCollectionToken` client end will cause buffer
5796    /// collection failure.
5797    ///
5798    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
5799    ///
5800    /// By default the server handles unexpected closure of a
5801    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
5802    /// first) by failing the buffer collection. Partly this is to expedite
5803    /// closing VMO handles to reclaim memory when any participant fails. If a
5804    /// participant would like to cleanly close a `BufferCollection` without
5805    /// causing buffer collection failure, the participant can send `Release`
5806    /// before closing the `BufferCollection` client end. The `Release` can
5807    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
5808    /// buffer collection won't require constraints from this node in order to
5809    /// allocate. If after `SetConstraints`, the constraints are retained and
5810    /// aggregated, despite the lack of `BufferCollection` connection at the
5811    /// time of constraints aggregation.
5812    ///
5813    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
5814    ///
5815    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
5816    /// end (without `Release` first) will trigger failure of the buffer
5817    /// collection. To close a `BufferCollectionTokenGroup` channel without
5818    /// failing the buffer collection, ensure that AllChildrenPresent() has been
5819    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
5820    /// client end.
5821    ///
5822    /// If `Release` occurs before
5823    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
5824    /// buffer collection will fail (triggered by reception of `Release` without
5825    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
5826    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
5827    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
5828    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
5829    /// close requires `AllChildrenPresent` (if not already sent), then
5830    /// `Release`, then close client end.
5831    ///
5832    /// If `Release` occurs after `AllChildrenPresent`, the children and all
5833    /// their constraints remain intact (just as they would if the
5834    /// `BufferCollectionTokenGroup` channel had remained open), and the client
5835    /// end close doesn't trigger buffer collection failure.
5836    ///
5837    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
5838    ///
5839    /// For brevity, the per-channel-protocol paragraphs above ignore the
5840    /// separate failure domain created by
5841    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
5842    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
5843    /// unexpectedly closes (without `Release` first) and that client end is
5844    /// under a failure domain, instead of failing the whole buffer collection,
5845    /// the failure domain is failed, but the buffer collection itself is
5846    /// isolated from failure of the failure domain. Such failure domains can be
5847    /// nested, in which case only the inner-most failure domain in which the
5848    /// `Node` resides fails.
5849    Release { control_handle: BufferCollectionTokenControlHandle },
5850    /// Set a name for VMOs in this buffer collection.
5851    ///
5852    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
5853    /// will be truncated to fit. The name of the vmo will be suffixed with the
5854    /// buffer index within the collection (if the suffix fits within
5855    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
5856    /// listed in the inspect data.
5857    ///
5858    /// The name only affects VMOs allocated after the name is set; this call
5859    /// does not rename existing VMOs. If multiple clients set different names
5860    /// then the larger priority value will win. Setting a new name with the
5861    /// same priority as a prior name doesn't change the name.
5862    ///
5863    /// All table fields are currently required.
5864    ///
5865    /// + request `priority` The name is only set if this is the first `SetName`
5866    ///   or if `priority` is greater than any previous `priority` value in
5867    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
5868    /// + request `name` The name for VMOs created under this buffer collection.
5869    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionTokenControlHandle },
5870    /// Set information about the current client that can be used by sysmem to
5871    /// help diagnose leaking memory and allocation stalls waiting for a
5872    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
5873    ///
5874    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
5875    /// `Node`(s) derived from this `Node`, unless overriden by
5876    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
5877    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
5878    ///
5879    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
5880    /// `Allocator` is the most efficient way to ensure that all
5881    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
5882    /// set, and is also more efficient than separately sending the same debug
5883    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
5884    /// created [`fuchsia.sysmem2/Node`].
5885    ///
5886    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
5887    /// indicate which client is closing their channel first, leading to subtree
5888    /// failure (which can be normal if the purpose of the subtree is over, but
5889    /// if happening earlier than expected, the client-channel-specific name can
5890    /// help diagnose where the failure is first coming from, from sysmem's
5891    /// point of view).
5892    ///
5893    /// All table fields are currently required.
5894    ///
5895    /// + request `name` This can be an arbitrary string, but the current
5896    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
5897    /// + request `id` This can be an arbitrary id, but the current process ID
5898    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
5899    SetDebugClientInfo {
5900        payload: NodeSetDebugClientInfoRequest,
5901        control_handle: BufferCollectionTokenControlHandle,
5902    },
5903    /// Sysmem logs a warning if sysmem hasn't seen
5904    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
5905    /// within 5 seconds after creation of a new collection.
5906    ///
5907    /// Clients can call this method to change when the log is printed. If
5908    /// multiple client set the deadline, it's unspecified which deadline will
5909    /// take effect.
5910    ///
5911    /// In most cases the default works well.
5912    ///
5913    /// All table fields are currently required.
5914    ///
5915    /// + request `deadline` The time at which sysmem will start trying to log
5916    ///   the warning, unless all constraints are with sysmem by then.
5917    SetDebugTimeoutLogDeadline {
5918        payload: NodeSetDebugTimeoutLogDeadlineRequest,
5919        control_handle: BufferCollectionTokenControlHandle,
5920    },
5921    /// This enables verbose logging for the buffer collection.
5922    ///
5923    /// Verbose logging includes constraints set via
5924    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
5925    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
5926    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
5927    /// the tree of `Node`(s).
5928    ///
5929    /// Normally sysmem prints only a single line complaint when aggregation
5930    /// fails, with just the specific detailed reason that aggregation failed,
5931    /// with little surrounding context.  While this is often enough to diagnose
5932    /// a problem if only a small change was made and everything was working
5933    /// before the small change, it's often not particularly helpful for getting
5934    /// a new buffer collection to work for the first time.  Especially with
5935    /// more complex trees of nodes, involving things like
5936    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
5937    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
5938    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
5939    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
5940    /// looks like and why it's failing a logical allocation, or why a tree or
5941    /// subtree is failing sooner than expected.
5942    ///
5943    /// The intent of the extra logging is to be acceptable from a performance
5944    /// point of view, under the assumption that verbose logging is only enabled
5945    /// on a low number of buffer collections. If we're not tracking down a bug,
5946    /// we shouldn't send this message.
5947    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
5948    /// This gets a handle that can be used as a parameter to
5949    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
5950    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
5951    /// client obtained this handle from this `Node`.
5952    ///
5953    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
5954    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
5955    /// despite the two calls typically being on different channels.
5956    ///
5957    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
5958    ///
5959    /// All table fields are currently required.
5960    ///
5961    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
5962    ///   different `Node` channel, to prove that the client obtained the handle
5963    ///   from this `Node`.
5964    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
5965    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
5966    /// rooted at a different child token of a common parent
5967    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
5968    /// passed-in `node_ref`.
5969    ///
5970    /// This call is for assisting with admission control de-duplication, and
5971    /// with debugging.
5972    ///
5973    /// The `node_ref` must be obtained using
5974    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
5975    ///
5976    /// The `node_ref` can be a duplicated handle; it's not necessary to call
5977    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
5978    ///
5979    /// If a calling token may not actually be a valid token at all due to a
5980    /// potentially hostile/untrusted provider of the token, call
5981    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
5982    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
5983    /// never responds due to a calling token not being a real token (not really
5984    /// talking to sysmem).  Another option is to call
5985    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
5986    /// which also validates the token along with converting it to a
5987    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
5988    ///
5989    /// All table fields are currently required.
5990    ///
5991    /// - response `is_alternate`
5992    ///   - true: The first parent node in common between the calling node and
5993    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
5994    ///     that the calling `Node` and the `node_ref` `Node` will not have both
5995    ///     their constraints apply - rather sysmem will choose one or the other
5996    ///     of the constraints - never both.  This is because only one child of
5997    ///     a `BufferCollectionTokenGroup` is selected during logical
5998    ///     allocation, with only that one child's subtree contributing to
5999    ///     constraints aggregation.
6000    ///   - false: The first parent node in common between the calling `Node`
6001    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
6002    ///     Currently, this means the first parent node in common is a
6003    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
6004    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
6005    ///     `Node` may have both their constraints apply during constraints
6006    ///     aggregation of the logical allocation, if both `Node`(s) are
6007    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
6008    ///     this case, there is no `BufferCollectionTokenGroup` that will
6009    ///     directly prevent the two `Node`(s) from both being selected and
6010    ///     their constraints both aggregated, but even when false, one or both
6011    ///     `Node`(s) may still be eliminated from consideration if one or both
6012    ///     `Node`(s) has a direct or indirect parent
6013    ///     `BufferCollectionTokenGroup` which selects a child subtree other
6014    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
6015    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
6016    ///   associated with the same buffer collection as the calling `Node`.
6017    ///   Another reason for this error is if the `node_ref` is an
6018    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
6019    ///   a real `node_ref` obtained from `GetNodeRef`.
6020    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
6021    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
6022    ///   the needed rights expected on a real `node_ref`.
6023    /// * No other failing status codes are returned by this call.  However,
6024    ///   sysmem may add additional codes in future, so the client should have
6025    ///   sensible default handling for any failing status code.
6026    IsAlternateFor {
6027        payload: NodeIsAlternateForRequest,
6028        responder: BufferCollectionTokenIsAlternateForResponder,
6029    },
6030    /// Get the buffer collection ID. This ID is also available from
6031    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
6032    /// within the collection).
6033    ///
6034    /// This call is mainly useful in situations where we can't convey a
6035    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
6036    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
6037    /// handle, which can be joined back up with a `BufferCollection` client end
6038    /// that was created via a different path. Prefer to convey a
6039    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
6040    ///
6041    /// Trusting a `buffer_collection_id` value from a source other than sysmem
6042    /// is analogous to trusting a koid value from a source other than zircon.
6043    /// Both should be avoided unless really necessary, and both require
6044    /// caution. In some situations it may be reasonable to refer to a
6045    /// pre-established `BufferCollection` by `buffer_collection_id` via a
6046    /// protocol for efficiency reasons, but an incoming value purporting to be
6047    /// a `buffer_collection_id` is not sufficient alone to justify granting the
6048    /// sender of the `buffer_collection_id` any capability. The sender must
6049    /// first prove to a receiver that the sender has/had a VMO or has/had a
6050    /// `BufferCollectionToken` to the same collection by sending a handle that
6051    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
6052    /// `buffer_collection_id` value. The receiver should take care to avoid
6053    /// assuming that a sender had a `BufferCollectionToken` in cases where the
6054    /// sender has only proven that the sender had a VMO.
6055    ///
6056    /// - response `buffer_collection_id` This ID is unique per buffer
6057    ///   collection per boot. Each buffer is uniquely identified by the
6058    ///   `buffer_collection_id` and `buffer_index` together.
6059    GetBufferCollectionId { responder: BufferCollectionTokenGetBufferCollectionIdResponder },
6060    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
6061    /// created after this message to weak, which means that a client's `Node`
6062    /// client end (or a child created after this message) is not alone
6063    /// sufficient to keep allocated VMOs alive.
6064    ///
6065    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
6066    /// `close_weak_asap`.
6067    ///
6068    /// This message is only permitted before the `Node` becomes ready for
6069    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
6070    ///   * `BufferCollectionToken`: any time
6071    ///   * `BufferCollection`: before `SetConstraints`
6072    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
6073    ///
6074    /// Currently, no conversion from strong `Node` to weak `Node` after ready
6075    /// for allocation is provided, but a client can simulate that by creating
6076    /// an additional `Node` before allocation and setting that additional
6077    /// `Node` to weak, and then potentially at some point later sending
6078    /// `Release` and closing the client end of the client's strong `Node`, but
6079    /// keeping the client's weak `Node`.
6080    ///
6081    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
6082    /// collection failure (all `Node` client end(s) will see
6083    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
6084    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
6085    /// this situation until all `Node`(s) are ready for allocation. For initial
6086    /// allocation to succeed, at least one strong `Node` is required to exist
6087    /// at allocation time, but after that client receives VMO handles, that
6088    /// client can `BufferCollection.Release` and close the client end without
6089    /// causing this type of failure.
6090    ///
6091    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
6092    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
6093    /// separately as appropriate.
6094    SetWeak { control_handle: BufferCollectionTokenControlHandle },
6095    /// This indicates to sysmem that the client is prepared to pay attention to
6096    /// `close_weak_asap`.
6097    ///
6098    /// If sent, this message must be before
6099    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
6100    ///
6101    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
6102    /// send this message before `WaitForAllBuffersAllocated`, or a parent
6103    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
6104    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
6105    /// trigger buffer collection failure.
6106    ///
6107    /// This message is necessary because weak sysmem VMOs have not always been
6108    /// a thing, so older clients are not aware of the need to pay attention to
6109    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
6110    /// sysmem weak VMO handles asap. By having this message and requiring
6111    /// participants to indicate their acceptance of this aspect of the overall
6112    /// protocol, we avoid situations where an older client is delivered a weak
6113    /// VMO without any way for sysmem to get that VMO to close quickly later
6114    /// (and on a per-buffer basis).
6115    ///
6116    /// A participant that doesn't handle `close_weak_asap` and also doesn't
6117    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
6118    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
6119    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
6120    /// same participant has a child/delegate which does retrieve VMOs, that
6121    /// child/delegate will need to send `SetWeakOk` before
6122    /// `WaitForAllBuffersAllocated`.
6123    ///
6124    /// + request `for_child_nodes_also` If present and true, this means direct
6125    ///   child nodes of this node created after this message plus all
6126    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
6127    ///   those nodes. Any child node of this node that was created before this
6128    ///   message is not included. This setting is "sticky" in the sense that a
6129    ///   subsequent `SetWeakOk` without this bool set to true does not reset
6130    ///   the server-side bool. If this creates a problem for a participant, a
6131    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
6132    ///   tokens instead, as appropriate. A participant should only set
6133    ///   `for_child_nodes_also` true if the participant can really promise to
6134    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
6135    ///   weak VMO handles held by participants holding the corresponding child
6136    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
6137    ///   which are using sysmem(1) can be weak, despite the clients of those
6138    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
6139    ///   direct way to find out about `close_weak_asap`. This only applies to
6140    ///   descendents of this `Node` which are using sysmem(1), not to this
6141    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
6142    ///   token, which will fail allocation unless an ancestor of this `Node`
6143    ///   specified `for_child_nodes_also` true.
6144    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: BufferCollectionTokenControlHandle },
6145    /// The server_end will be closed after this `Node` and any child nodes have
6146    /// have released their buffer counts, making those counts available for
6147    /// reservation by a different `Node` via
6148    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
6149    ///
6150    /// The `Node` buffer counts may not be released until the entire tree of
6151    /// `Node`(s) is closed or failed, because
6152    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
6153    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
6154    /// `Node` buffer counts remain reserved until the orphaned node is later
6155    /// cleaned up.
6156    ///
6157    /// If the `Node` exceeds a fairly large number of attached eventpair server
6158    /// ends, a log message will indicate this and the `Node` (and the
6159    /// appropriate) sub-tree will fail.
6160    ///
6161    /// The `server_end` will remain open when
6162    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
6163    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
6164    /// [`fuchsia.sysmem2/BufferCollection`].
6165    ///
6166    /// This message can also be used with a
6167    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
6168    AttachNodeTracking {
6169        payload: NodeAttachNodeTrackingRequest,
6170        control_handle: BufferCollectionTokenControlHandle,
6171    },
6172    /// Create additional [`fuchsia.sysmem2/BufferCollectionToken`](s) from this
6173    /// one, referring to the same buffer collection.
6174    ///
6175    /// The created tokens are children of this token in the
6176    /// [`fuchsia.sysmem2/Node`] heirarchy.
6177    ///
6178    /// This method can be used to add more participants, by transferring the
6179    /// newly created tokens to additional participants.
6180    ///
6181    /// A new token will be returned for each entry in the
6182    /// `rights_attenuation_masks` array.
6183    ///
6184    /// If the called token may not actually be a valid token due to a
6185    /// potentially hostile/untrusted provider of the token, consider using
6186    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
6187    /// instead of potentially getting stuck indefinitely if
6188    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] never responds
6189    /// due to the calling token not being a real token.
6190    ///
6191    /// In contrast to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], no
6192    /// separate [`fuchsia.sysmem2/Node.Sync`] is needed after calling this
6193    /// method, because the sync step is included in this call, at the cost of a
6194    /// round trip during this call.
6195    ///
6196    /// All tokens must be turned in to sysmem via
6197    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
6198    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
6199    /// successfully allocate buffers (or to logically allocate buffers in the
6200    /// case of subtrees involving
6201    /// [`fuchsia.sysmem2/BufferCollectionToken.AttachToken`]).
6202    ///
6203    /// All table fields are currently required.
6204    ///
6205    /// + request `rights_attenuation_mask` In each entry of
6206    ///   `rights_attenuation_masks`, rights bits that are zero will be absent
6207    ///   in the buffer VMO rights obtainable via the corresponding returned
6208    ///   token. This allows an initiator or intermediary participant to
6209    ///   attenuate the rights available to a participant. This does not allow a
6210    ///   participant to gain rights that the participant doesn't already have.
6211    ///   The value `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no
6212    ///   attenuation should be applied.
6213    /// - response `tokens` The client ends of each newly created token.
6214    DuplicateSync {
6215        payload: BufferCollectionTokenDuplicateSyncRequest,
6216        responder: BufferCollectionTokenDuplicateSyncResponder,
6217    },
6218    /// Create an additional [`fuchsia.sysmem2/BufferCollectionToken`] from this
6219    /// one, referring to the same buffer collection.
6220    ///
6221    /// The created token is a child of this token in the
6222    /// [`fuchsia.sysmem2/Node`] heirarchy.
6223    ///
6224    /// This method can be used to add a participant, by transferring the newly
6225    /// created token to another participant.
6226    ///
6227    /// This one-way message can be used instead of the two-way
6228    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] FIDL call in
6229    /// performance sensitive cases where it would be undesireable to wait for
6230    /// sysmem to respond to
6231    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or when the
6232    /// client code isn't structured to make it easy to duplicate all the needed
6233    /// tokens at once.
6234    ///
6235    /// After sending one or more `Duplicate` messages, and before sending the
6236    /// newly created child tokens to other participants (or to other
6237    /// [`fuchsia.sysmem2/Allocator`] channels), the client must send a
6238    /// [`fuchsia.sysmem2/Node.Sync`] and wait for the `Sync` response. The
6239    /// `Sync` call can be made on the token, or on the `BufferCollection`
6240    /// obtained by passing this token to `BindSharedCollection`.  Either will
6241    /// ensure that the server knows about the tokens created via `Duplicate`
6242    /// before the other participant sends the token to the server via separate
6243    /// `Allocator` channel.
6244    ///
6245    /// All tokens must be turned in via
6246    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
6247    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
6248    /// successfully allocate buffers.
6249    ///
6250    /// All table fields are currently required.
6251    ///
6252    /// + request `rights_attenuation_mask` The rights bits that are zero in
6253    ///   this mask will be absent in the buffer VMO rights obtainable via the
6254    ///   client end of `token_request`. This allows an initiator or
6255    ///   intermediary participant to attenuate the rights available to a
6256    ///   delegate participant. This does not allow a participant to gain rights
6257    ///   that the participant doesn't already have. The value
6258    ///   `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no attenuation
6259    ///   should be applied.
6260    ///   + These values for rights_attenuation_mask result in no attenuation:
6261    ///     + `ZX_RIGHT_SAME_RIGHTS` (preferred)
6262    ///     + 0xFFFFFFFF (this is reasonable when an attenuation mask is
6263    ///       computed)
6264    ///     + 0 (deprecated - do not use 0 - an ERROR will go to the log)
6265    /// + request `token_request` is the server end of a `BufferCollectionToken`
6266    ///   channel. The client end of this channel acts as another participant in
6267    ///   the shared buffer collection.
6268    Duplicate {
6269        payload: BufferCollectionTokenDuplicateRequest,
6270        control_handle: BufferCollectionTokenControlHandle,
6271    },
6272    /// Set this [`fuchsia.sysmem2/BufferCollectionToken`] to dispensable.
6273    ///
6274    /// When the `BufferCollectionToken` is converted to a
6275    /// [`fuchsia.sysmem2/BufferCollection`], the dispensable status applies to
6276    /// the `BufferCollection` also.
6277    ///
6278    /// Normally, if a client closes a [`fuchsia.sysmem2/BufferCollection`]
6279    /// client end without having sent
6280    /// [`fuchsia.sysmem2/BufferCollection.Release`] first, the
6281    /// `BufferCollection` [`fuchisa.sysmem2/Node`] will fail, which also
6282    /// propagates failure to the parent [`fuchsia.sysmem2/Node`] and so on up
6283    /// to the root `Node`, which fails the whole buffer collection. In
6284    /// contrast, a dispensable `Node` can fail after buffers are allocated
6285    /// without causing failure of its parent in the [`fuchsia.sysmem2/Node`]
6286    /// heirarchy.
6287    ///
6288    /// The dispensable `Node` participates in constraints aggregation along
6289    /// with its parent before buffer allocation. If the dispensable `Node`
6290    /// fails before buffers are allocated, the failure propagates to the
6291    /// dispensable `Node`'s parent.
6292    ///
6293    /// After buffers are allocated, failure of the dispensable `Node` (or any
6294    /// child of the dispensable `Node`) does not propagate to the dispensable
6295    /// `Node`'s parent. Failure does propagate from a normal child of a
6296    /// dispensable `Node` to the dispensable `Node`.  Failure of a child is
6297    /// blocked from reaching its parent if the child is attached using
6298    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or if the child is
6299    /// dispensable and the failure occurred after allocation.
6300    ///
6301    /// A dispensable `Node` can be used in cases where a participant needs to
6302    /// provide constraints, but after buffers are allocated, the participant
6303    /// can fail without causing buffer collection failure from the parent
6304    /// `Node`'s point of view.
6305    ///
6306    /// In contrast, `BufferCollection.AttachToken` can be used to create a
6307    /// `BufferCollectionToken` which does not participate in constraints
6308    /// aggregation with its parent `Node`, and whose failure at any time does
6309    /// not propagate to its parent `Node`, and whose potential delay providing
6310    /// constraints does not prevent the parent `Node` from completing its
6311    /// buffer allocation.
6312    ///
6313    /// An initiator (creator of the root `Node` using
6314    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`]) may in some
6315    /// scenarios choose to initially use a dispensable `Node` for a first
6316    /// instance of a participant, and then later if the first instance of that
6317    /// participant fails, a new second instance of that participant my be given
6318    /// a `BufferCollectionToken` created with `AttachToken`.
6319    ///
6320    /// Normally a client will `SetDispensable` on a `BufferCollectionToken`
6321    /// shortly before sending the dispensable `BufferCollectionToken` to a
6322    /// delegate participant. Because `SetDispensable` prevents propagation of
6323    /// child `Node` failure to parent `Node`(s), if the client was relying on
6324    /// noticing child failure via failure of the parent `Node` retained by the
6325    /// client, the client may instead need to notice failure via other means.
6326    /// If other means aren't available/convenient, the client can instead
6327    /// retain the dispensable `Node` and create a child `Node` under that to
6328    /// send to the delegate participant, retaining this `Node` in order to
6329    /// notice failure of the subtree rooted at this `Node` via this `Node`'s
6330    /// ZX_CHANNEL_PEER_CLOSED signal, and take whatever action is appropriate
6331    /// (e.g. starting a new instance of the delegate participant and handing it
6332    /// a `BufferCollectionToken` created using
6333    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or propagate failure
6334    /// and clean up in a client-specific way).
6335    ///
6336    /// While it is possible (and potentially useful) to `SetDispensable` on a
6337    /// direct child of a `BufferCollectionTokenGroup` `Node`, it isn't possible
6338    /// to later replace a failed dispensable `Node` that was a direct child of
6339    /// a `BufferCollectionTokenGroup` with a new token using `AttachToken`
6340    /// (since there's no `AttachToken` on a group). Instead, to enable
6341    /// `AttachToken` replacement in this case, create an additional
6342    /// non-dispensable token that's a direct child of the group and make the
6343    /// existing dispensable token a child of the additional token.  This way,
6344    /// the additional token that is a direct child of the group has
6345    /// `BufferCollection.AttachToken` which can be used to replace the failed
6346    /// dispensable token.
6347    ///
6348    /// `SetDispensable` on an already-dispensable token is idempotent.
6349    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
6350    /// Create a logical OR among a set of tokens, called a
6351    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
6352    ///
6353    /// Most sysmem clients and many participants don't need to care about this
6354    /// message or about `BufferCollectionTokenGroup`(s). However, in some cases
6355    /// a participant wants to attempt to include one set of delegate
6356    /// participants, but if constraints don't combine successfully that way,
6357    /// fall back to a different (possibly overlapping) set of delegate
6358    /// participants, and/or fall back to a less demanding strategy (in terms of
6359    /// how strict the [`fuchisa.sysmem2/BufferCollectionConstraints`] are,
6360    /// across all involved delegate participants). In such cases, a
6361    /// `BufferCollectionTokenGroup` is useful.
6362    ///
6363    /// A `BufferCollectionTokenGroup` is used to create a 1 of N OR among N
6364    /// child [`fuchsia.sysmem2/BufferCollectionToken`](s).  The child tokens
6365    /// which are not selected during aggregation will fail (close), which a
6366    /// potential participant should notice when their `BufferCollection`
6367    /// channel client endpoint sees PEER_CLOSED, allowing the participant to
6368    /// clean up the speculative usage that didn't end up happening (this is
6369    /// simimlar to a normal `BufferCollection` server end closing on failure to
6370    /// allocate a logical buffer collection or later async failure of a buffer
6371    /// collection).
6372    ///
6373    /// See comments on protocol `BufferCollectionTokenGroup`.
6374    ///
6375    /// Any `rights_attenuation_mask` or `AttachToken`/`SetDispensable` to be
6376    /// applied to the whole group can be achieved with a
6377    /// `BufferCollectionToken` for this purpose as a direct parent of the
6378    /// `BufferCollectionTokenGroup`.
6379    ///
6380    /// All table fields are currently required.
6381    ///
6382    /// + request `group_request` The server end of a
6383    ///   `BufferCollectionTokenGroup` channel to be served by sysmem.
6384    CreateBufferCollectionTokenGroup {
6385        payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
6386        control_handle: BufferCollectionTokenControlHandle,
6387    },
6388    /// An interaction was received which does not match any known method.
6389    #[non_exhaustive]
6390    _UnknownMethod {
6391        /// Ordinal of the method that was called.
6392        ordinal: u64,
6393        control_handle: BufferCollectionTokenControlHandle,
6394        method_type: fidl::MethodType,
6395    },
6396}
6397
6398impl BufferCollectionTokenRequest {
6399    #[allow(irrefutable_let_patterns)]
6400    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
6401        if let BufferCollectionTokenRequest::Sync { responder } = self {
6402            Some((responder))
6403        } else {
6404            None
6405        }
6406    }
6407
6408    #[allow(irrefutable_let_patterns)]
6409    pub fn into_release(self) -> Option<(BufferCollectionTokenControlHandle)> {
6410        if let BufferCollectionTokenRequest::Release { control_handle } = self {
6411            Some((control_handle))
6412        } else {
6413            None
6414        }
6415    }
6416
6417    #[allow(irrefutable_let_patterns)]
6418    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, BufferCollectionTokenControlHandle)> {
6419        if let BufferCollectionTokenRequest::SetName { payload, control_handle } = self {
6420            Some((payload, control_handle))
6421        } else {
6422            None
6423        }
6424    }
6425
6426    #[allow(irrefutable_let_patterns)]
6427    pub fn into_set_debug_client_info(
6428        self,
6429    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionTokenControlHandle)> {
6430        if let BufferCollectionTokenRequest::SetDebugClientInfo { payload, control_handle } = self {
6431            Some((payload, control_handle))
6432        } else {
6433            None
6434        }
6435    }
6436
6437    #[allow(irrefutable_let_patterns)]
6438    pub fn into_set_debug_timeout_log_deadline(
6439        self,
6440    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionTokenControlHandle)> {
6441        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
6442            payload,
6443            control_handle,
6444        } = self
6445        {
6446            Some((payload, control_handle))
6447        } else {
6448            None
6449        }
6450    }
6451
6452    #[allow(irrefutable_let_patterns)]
6453    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
6454        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
6455            Some((control_handle))
6456        } else {
6457            None
6458        }
6459    }
6460
6461    #[allow(irrefutable_let_patterns)]
6462    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
6463        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
6464            Some((responder))
6465        } else {
6466            None
6467        }
6468    }
6469
6470    #[allow(irrefutable_let_patterns)]
6471    pub fn into_is_alternate_for(
6472        self,
6473    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionTokenIsAlternateForResponder)> {
6474        if let BufferCollectionTokenRequest::IsAlternateFor { payload, responder } = self {
6475            Some((payload, responder))
6476        } else {
6477            None
6478        }
6479    }
6480
6481    #[allow(irrefutable_let_patterns)]
6482    pub fn into_get_buffer_collection_id(
6483        self,
6484    ) -> Option<(BufferCollectionTokenGetBufferCollectionIdResponder)> {
6485        if let BufferCollectionTokenRequest::GetBufferCollectionId { responder } = self {
6486            Some((responder))
6487        } else {
6488            None
6489        }
6490    }
6491
6492    #[allow(irrefutable_let_patterns)]
6493    pub fn into_set_weak(self) -> Option<(BufferCollectionTokenControlHandle)> {
6494        if let BufferCollectionTokenRequest::SetWeak { control_handle } = self {
6495            Some((control_handle))
6496        } else {
6497            None
6498        }
6499    }
6500
6501    #[allow(irrefutable_let_patterns)]
6502    pub fn into_set_weak_ok(
6503        self,
6504    ) -> Option<(NodeSetWeakOkRequest, BufferCollectionTokenControlHandle)> {
6505        if let BufferCollectionTokenRequest::SetWeakOk { payload, control_handle } = self {
6506            Some((payload, control_handle))
6507        } else {
6508            None
6509        }
6510    }
6511
6512    #[allow(irrefutable_let_patterns)]
6513    pub fn into_attach_node_tracking(
6514        self,
6515    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionTokenControlHandle)> {
6516        if let BufferCollectionTokenRequest::AttachNodeTracking { payload, control_handle } = self {
6517            Some((payload, control_handle))
6518        } else {
6519            None
6520        }
6521    }
6522
6523    #[allow(irrefutable_let_patterns)]
6524    pub fn into_duplicate_sync(
6525        self,
6526    ) -> Option<(
6527        BufferCollectionTokenDuplicateSyncRequest,
6528        BufferCollectionTokenDuplicateSyncResponder,
6529    )> {
6530        if let BufferCollectionTokenRequest::DuplicateSync { payload, responder } = self {
6531            Some((payload, responder))
6532        } else {
6533            None
6534        }
6535    }
6536
6537    #[allow(irrefutable_let_patterns)]
6538    pub fn into_duplicate(
6539        self,
6540    ) -> Option<(BufferCollectionTokenDuplicateRequest, BufferCollectionTokenControlHandle)> {
6541        if let BufferCollectionTokenRequest::Duplicate { payload, control_handle } = self {
6542            Some((payload, control_handle))
6543        } else {
6544            None
6545        }
6546    }
6547
6548    #[allow(irrefutable_let_patterns)]
6549    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
6550        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
6551            Some((control_handle))
6552        } else {
6553            None
6554        }
6555    }
6556
6557    #[allow(irrefutable_let_patterns)]
6558    pub fn into_create_buffer_collection_token_group(
6559        self,
6560    ) -> Option<(
6561        BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
6562        BufferCollectionTokenControlHandle,
6563    )> {
6564        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
6565            payload,
6566            control_handle,
6567        } = self
6568        {
6569            Some((payload, control_handle))
6570        } else {
6571            None
6572        }
6573    }
6574
6575    /// Name of the method defined in FIDL
6576    pub fn method_name(&self) -> &'static str {
6577        match *self {
6578            BufferCollectionTokenRequest::Sync { .. } => "sync",
6579            BufferCollectionTokenRequest::Release { .. } => "release",
6580            BufferCollectionTokenRequest::SetName { .. } => "set_name",
6581            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6582            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
6583                "set_debug_timeout_log_deadline"
6584            }
6585            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6586            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
6587            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
6588            BufferCollectionTokenRequest::GetBufferCollectionId { .. } => {
6589                "get_buffer_collection_id"
6590            }
6591            BufferCollectionTokenRequest::SetWeak { .. } => "set_weak",
6592            BufferCollectionTokenRequest::SetWeakOk { .. } => "set_weak_ok",
6593            BufferCollectionTokenRequest::AttachNodeTracking { .. } => "attach_node_tracking",
6594            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
6595            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
6596            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
6597            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
6598                "create_buffer_collection_token_group"
6599            }
6600            BufferCollectionTokenRequest::_UnknownMethod {
6601                method_type: fidl::MethodType::OneWay,
6602                ..
6603            } => "unknown one-way method",
6604            BufferCollectionTokenRequest::_UnknownMethod {
6605                method_type: fidl::MethodType::TwoWay,
6606                ..
6607            } => "unknown two-way method",
6608        }
6609    }
6610}
6611
6612#[derive(Debug, Clone)]
6613pub struct BufferCollectionTokenControlHandle {
6614    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6615}
6616
6617impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenControlHandle {
6618    fn shutdown(&self) {
6619        self.inner.shutdown()
6620    }
6621
6622    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6623        self.inner.shutdown_with_epitaph(status)
6624    }
6625
6626    fn is_closed(&self) -> bool {
6627        self.inner.channel().is_closed()
6628    }
6629    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6630        self.inner.channel().on_closed()
6631    }
6632}
6633
6634impl BufferCollectionTokenControlHandle {}
6635
6636#[must_use = "FIDL methods require a response to be sent"]
6637#[derive(Debug)]
6638pub struct BufferCollectionTokenSyncResponder {
6639    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6640    tx_id: u32,
6641}
6642
6643/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6644/// if the responder is dropped without sending a response, so that the client
6645/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6646impl std::ops::Drop for BufferCollectionTokenSyncResponder {
6647    fn drop(&mut self) {
6648        self.control_handle.shutdown();
6649        // Safety: drops once, never accessed again
6650        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6651    }
6652}
6653
6654impl fdomain_client::fidl::Responder for BufferCollectionTokenSyncResponder {
6655    type ControlHandle = BufferCollectionTokenControlHandle;
6656
6657    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6658        &self.control_handle
6659    }
6660
6661    fn drop_without_shutdown(mut self) {
6662        // Safety: drops once, never accessed again due to mem::forget
6663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6664        // Prevent Drop from running (which would shut down the channel)
6665        std::mem::forget(self);
6666    }
6667}
6668
6669impl BufferCollectionTokenSyncResponder {
6670    /// Sends a response to the FIDL transaction.
6671    ///
6672    /// Sets the channel to shutdown if an error occurs.
6673    pub fn send(self) -> Result<(), fidl::Error> {
6674        let _result = self.send_raw();
6675        if _result.is_err() {
6676            self.control_handle.shutdown();
6677        }
6678        self.drop_without_shutdown();
6679        _result
6680    }
6681
6682    /// Similar to "send" but does not shutdown the channel if an error occurs.
6683    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6684        let _result = self.send_raw();
6685        self.drop_without_shutdown();
6686        _result
6687    }
6688
6689    fn send_raw(&self) -> Result<(), fidl::Error> {
6690        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
6691            fidl::encoding::Flexible::new(()),
6692            self.tx_id,
6693            0x11ac2555cf575b54,
6694            fidl::encoding::DynamicFlags::FLEXIBLE,
6695        )
6696    }
6697}
6698
6699#[must_use = "FIDL methods require a response to be sent"]
6700#[derive(Debug)]
6701pub struct BufferCollectionTokenGetNodeRefResponder {
6702    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6703    tx_id: u32,
6704}
6705
6706/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6707/// if the responder is dropped without sending a response, so that the client
6708/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6709impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
6710    fn drop(&mut self) {
6711        self.control_handle.shutdown();
6712        // Safety: drops once, never accessed again
6713        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6714    }
6715}
6716
6717impl fdomain_client::fidl::Responder for BufferCollectionTokenGetNodeRefResponder {
6718    type ControlHandle = BufferCollectionTokenControlHandle;
6719
6720    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6721        &self.control_handle
6722    }
6723
6724    fn drop_without_shutdown(mut self) {
6725        // Safety: drops once, never accessed again due to mem::forget
6726        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6727        // Prevent Drop from running (which would shut down the channel)
6728        std::mem::forget(self);
6729    }
6730}
6731
6732impl BufferCollectionTokenGetNodeRefResponder {
6733    /// Sends a response to the FIDL transaction.
6734    ///
6735    /// Sets the channel to shutdown if an error occurs.
6736    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
6737        let _result = self.send_raw(payload);
6738        if _result.is_err() {
6739            self.control_handle.shutdown();
6740        }
6741        self.drop_without_shutdown();
6742        _result
6743    }
6744
6745    /// Similar to "send" but does not shutdown the channel if an error occurs.
6746    pub fn send_no_shutdown_on_err(
6747        self,
6748        mut payload: NodeGetNodeRefResponse,
6749    ) -> Result<(), fidl::Error> {
6750        let _result = self.send_raw(payload);
6751        self.drop_without_shutdown();
6752        _result
6753    }
6754
6755    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
6756        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
6757            fidl::encoding::Flexible::new(&mut payload),
6758            self.tx_id,
6759            0x5b3d0e51614df053,
6760            fidl::encoding::DynamicFlags::FLEXIBLE,
6761        )
6762    }
6763}
6764
6765#[must_use = "FIDL methods require a response to be sent"]
6766#[derive(Debug)]
6767pub struct BufferCollectionTokenIsAlternateForResponder {
6768    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6769    tx_id: u32,
6770}
6771
6772/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6773/// if the responder is dropped without sending a response, so that the client
6774/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6775impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
6776    fn drop(&mut self) {
6777        self.control_handle.shutdown();
6778        // Safety: drops once, never accessed again
6779        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6780    }
6781}
6782
6783impl fdomain_client::fidl::Responder for BufferCollectionTokenIsAlternateForResponder {
6784    type ControlHandle = BufferCollectionTokenControlHandle;
6785
6786    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6787        &self.control_handle
6788    }
6789
6790    fn drop_without_shutdown(mut self) {
6791        // Safety: drops once, never accessed again due to mem::forget
6792        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6793        // Prevent Drop from running (which would shut down the channel)
6794        std::mem::forget(self);
6795    }
6796}
6797
6798impl BufferCollectionTokenIsAlternateForResponder {
6799    /// Sends a response to the FIDL transaction.
6800    ///
6801    /// Sets the channel to shutdown if an error occurs.
6802    pub fn send(
6803        self,
6804        mut result: Result<&NodeIsAlternateForResponse, Error>,
6805    ) -> Result<(), fidl::Error> {
6806        let _result = self.send_raw(result);
6807        if _result.is_err() {
6808            self.control_handle.shutdown();
6809        }
6810        self.drop_without_shutdown();
6811        _result
6812    }
6813
6814    /// Similar to "send" but does not shutdown the channel if an error occurs.
6815    pub fn send_no_shutdown_on_err(
6816        self,
6817        mut result: Result<&NodeIsAlternateForResponse, Error>,
6818    ) -> Result<(), fidl::Error> {
6819        let _result = self.send_raw(result);
6820        self.drop_without_shutdown();
6821        _result
6822    }
6823
6824    fn send_raw(
6825        &self,
6826        mut result: Result<&NodeIsAlternateForResponse, Error>,
6827    ) -> Result<(), fidl::Error> {
6828        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6829            NodeIsAlternateForResponse,
6830            Error,
6831        >>(
6832            fidl::encoding::FlexibleResult::new(result),
6833            self.tx_id,
6834            0x3a58e00157e0825,
6835            fidl::encoding::DynamicFlags::FLEXIBLE,
6836        )
6837    }
6838}
6839
6840#[must_use = "FIDL methods require a response to be sent"]
6841#[derive(Debug)]
6842pub struct BufferCollectionTokenGetBufferCollectionIdResponder {
6843    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6844    tx_id: u32,
6845}
6846
6847/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6848/// if the responder is dropped without sending a response, so that the client
6849/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6850impl std::ops::Drop for BufferCollectionTokenGetBufferCollectionIdResponder {
6851    fn drop(&mut self) {
6852        self.control_handle.shutdown();
6853        // Safety: drops once, never accessed again
6854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6855    }
6856}
6857
6858impl fdomain_client::fidl::Responder for BufferCollectionTokenGetBufferCollectionIdResponder {
6859    type ControlHandle = BufferCollectionTokenControlHandle;
6860
6861    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6862        &self.control_handle
6863    }
6864
6865    fn drop_without_shutdown(mut self) {
6866        // Safety: drops once, never accessed again due to mem::forget
6867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6868        // Prevent Drop from running (which would shut down the channel)
6869        std::mem::forget(self);
6870    }
6871}
6872
6873impl BufferCollectionTokenGetBufferCollectionIdResponder {
6874    /// Sends a response to the FIDL transaction.
6875    ///
6876    /// Sets the channel to shutdown if an error occurs.
6877    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
6878        let _result = self.send_raw(payload);
6879        if _result.is_err() {
6880            self.control_handle.shutdown();
6881        }
6882        self.drop_without_shutdown();
6883        _result
6884    }
6885
6886    /// Similar to "send" but does not shutdown the channel if an error occurs.
6887    pub fn send_no_shutdown_on_err(
6888        self,
6889        mut payload: &NodeGetBufferCollectionIdResponse,
6890    ) -> Result<(), fidl::Error> {
6891        let _result = self.send_raw(payload);
6892        self.drop_without_shutdown();
6893        _result
6894    }
6895
6896    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
6897        self.control_handle
6898            .inner
6899            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
6900                fidl::encoding::Flexible::new(payload),
6901                self.tx_id,
6902                0x77d19a494b78ba8c,
6903                fidl::encoding::DynamicFlags::FLEXIBLE,
6904            )
6905    }
6906}
6907
6908#[must_use = "FIDL methods require a response to be sent"]
6909#[derive(Debug)]
6910pub struct BufferCollectionTokenDuplicateSyncResponder {
6911    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6912    tx_id: u32,
6913}
6914
6915/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6916/// if the responder is dropped without sending a response, so that the client
6917/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6918impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
6919    fn drop(&mut self) {
6920        self.control_handle.shutdown();
6921        // Safety: drops once, never accessed again
6922        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6923    }
6924}
6925
6926impl fdomain_client::fidl::Responder for BufferCollectionTokenDuplicateSyncResponder {
6927    type ControlHandle = BufferCollectionTokenControlHandle;
6928
6929    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6930        &self.control_handle
6931    }
6932
6933    fn drop_without_shutdown(mut self) {
6934        // Safety: drops once, never accessed again due to mem::forget
6935        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6936        // Prevent Drop from running (which would shut down the channel)
6937        std::mem::forget(self);
6938    }
6939}
6940
6941impl BufferCollectionTokenDuplicateSyncResponder {
6942    /// Sends a response to the FIDL transaction.
6943    ///
6944    /// Sets the channel to shutdown if an error occurs.
6945    pub fn send(
6946        self,
6947        mut payload: BufferCollectionTokenDuplicateSyncResponse,
6948    ) -> Result<(), fidl::Error> {
6949        let _result = self.send_raw(payload);
6950        if _result.is_err() {
6951            self.control_handle.shutdown();
6952        }
6953        self.drop_without_shutdown();
6954        _result
6955    }
6956
6957    /// Similar to "send" but does not shutdown the channel if an error occurs.
6958    pub fn send_no_shutdown_on_err(
6959        self,
6960        mut payload: BufferCollectionTokenDuplicateSyncResponse,
6961    ) -> Result<(), fidl::Error> {
6962        let _result = self.send_raw(payload);
6963        self.drop_without_shutdown();
6964        _result
6965    }
6966
6967    fn send_raw(
6968        &self,
6969        mut payload: BufferCollectionTokenDuplicateSyncResponse,
6970    ) -> Result<(), fidl::Error> {
6971        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
6972            BufferCollectionTokenDuplicateSyncResponse,
6973        >>(
6974            fidl::encoding::Flexible::new(&mut payload),
6975            self.tx_id,
6976            0x1c1af9919d1ca45c,
6977            fidl::encoding::DynamicFlags::FLEXIBLE,
6978        )
6979    }
6980}
6981
6982#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6983pub struct BufferCollectionTokenGroupMarker;
6984
6985impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenGroupMarker {
6986    type Proxy = BufferCollectionTokenGroupProxy;
6987    type RequestStream = BufferCollectionTokenGroupRequestStream;
6988
6989    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
6990}
6991
6992pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
6993    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6994    fn r#sync(&self) -> Self::SyncResponseFut;
6995    fn r#release(&self) -> Result<(), fidl::Error>;
6996    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
6997    fn r#set_debug_client_info(
6998        &self,
6999        payload: &NodeSetDebugClientInfoRequest,
7000    ) -> Result<(), fidl::Error>;
7001    fn r#set_debug_timeout_log_deadline(
7002        &self,
7003        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7004    ) -> Result<(), fidl::Error>;
7005    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
7006    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
7007        + Send;
7008    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
7009    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
7010        + Send;
7011    fn r#is_alternate_for(
7012        &self,
7013        payload: NodeIsAlternateForRequest,
7014    ) -> Self::IsAlternateForResponseFut;
7015    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
7016        + Send;
7017    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
7018    fn r#set_weak(&self) -> Result<(), fidl::Error>;
7019    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
7020    fn r#attach_node_tracking(
7021        &self,
7022        payload: NodeAttachNodeTrackingRequest,
7023    ) -> Result<(), fidl::Error>;
7024    fn r#create_child(
7025        &self,
7026        payload: BufferCollectionTokenGroupCreateChildRequest,
7027    ) -> Result<(), fidl::Error>;
7028    type CreateChildrenSyncResponseFut: std::future::Future<
7029            Output = Result<BufferCollectionTokenGroupCreateChildrenSyncResponse, fidl::Error>,
7030        > + Send;
7031    fn r#create_children_sync(
7032        &self,
7033        payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7034    ) -> Self::CreateChildrenSyncResponseFut;
7035    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
7036}
7037
7038#[derive(Debug, Clone)]
7039pub struct BufferCollectionTokenGroupProxy {
7040    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
7041}
7042
7043impl fdomain_client::fidl::Proxy for BufferCollectionTokenGroupProxy {
7044    type Protocol = BufferCollectionTokenGroupMarker;
7045
7046    fn from_channel(inner: fdomain_client::Channel) -> Self {
7047        Self::new(inner)
7048    }
7049
7050    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
7051        self.client.into_channel().map_err(|client| Self { client })
7052    }
7053
7054    fn as_channel(&self) -> &fdomain_client::Channel {
7055        self.client.as_channel()
7056    }
7057}
7058
7059impl BufferCollectionTokenGroupProxy {
7060    /// Create a new Proxy for fuchsia.sysmem2/BufferCollectionTokenGroup.
7061    pub fn new(channel: fdomain_client::Channel) -> Self {
7062        let protocol_name =
7063            <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
7064        Self { client: fidl::client::Client::new(channel, protocol_name) }
7065    }
7066
7067    /// Get a Stream of events from the remote end of the protocol.
7068    ///
7069    /// # Panics
7070    ///
7071    /// Panics if the event stream was already taken.
7072    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
7073        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
7074    }
7075
7076    /// Ensure that previous messages have been received server side. This is
7077    /// particularly useful after previous messages that created new tokens,
7078    /// because a token must be known to the sysmem server before sending the
7079    /// token to another participant.
7080    ///
7081    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
7082    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
7083    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
7084    /// to mitigate the possibility of a hostile/fake
7085    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
7086    /// Another way is to pass the token to
7087    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
7088    /// the token as part of exchanging it for a
7089    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
7090    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
7091    /// of stalling.
7092    ///
7093    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
7094    /// and then starting and completing a `Sync`, it's then safe to send the
7095    /// `BufferCollectionToken` client ends to other participants knowing the
7096    /// server will recognize the tokens when they're sent by the other
7097    /// participants to sysmem in a
7098    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
7099    /// efficient way to create tokens while avoiding unnecessary round trips.
7100    ///
7101    /// Other options include waiting for each
7102    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
7103    /// individually (using separate call to `Sync` after each), or calling
7104    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
7105    /// converted to a `BufferCollection` via
7106    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
7107    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
7108    /// the sync step and can create multiple tokens at once.
7109    pub fn r#sync(
7110        &self,
7111    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
7112        BufferCollectionTokenGroupProxyInterface::r#sync(self)
7113    }
7114
7115    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
7116    ///
7117    /// Normally a participant will convert a `BufferCollectionToken` into a
7118    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
7119    /// `Release` via the token (and then close the channel immediately or
7120    /// shortly later in response to server closing the server end), which
7121    /// avoids causing buffer collection failure. Without a prior `Release`,
7122    /// closing the `BufferCollectionToken` client end will cause buffer
7123    /// collection failure.
7124    ///
7125    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
7126    ///
7127    /// By default the server handles unexpected closure of a
7128    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
7129    /// first) by failing the buffer collection. Partly this is to expedite
7130    /// closing VMO handles to reclaim memory when any participant fails. If a
7131    /// participant would like to cleanly close a `BufferCollection` without
7132    /// causing buffer collection failure, the participant can send `Release`
7133    /// before closing the `BufferCollection` client end. The `Release` can
7134    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
7135    /// buffer collection won't require constraints from this node in order to
7136    /// allocate. If after `SetConstraints`, the constraints are retained and
7137    /// aggregated, despite the lack of `BufferCollection` connection at the
7138    /// time of constraints aggregation.
7139    ///
7140    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
7141    ///
7142    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
7143    /// end (without `Release` first) will trigger failure of the buffer
7144    /// collection. To close a `BufferCollectionTokenGroup` channel without
7145    /// failing the buffer collection, ensure that AllChildrenPresent() has been
7146    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
7147    /// client end.
7148    ///
7149    /// If `Release` occurs before
7150    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
7151    /// buffer collection will fail (triggered by reception of `Release` without
7152    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
7153    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
7154    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
7155    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
7156    /// close requires `AllChildrenPresent` (if not already sent), then
7157    /// `Release`, then close client end.
7158    ///
7159    /// If `Release` occurs after `AllChildrenPresent`, the children and all
7160    /// their constraints remain intact (just as they would if the
7161    /// `BufferCollectionTokenGroup` channel had remained open), and the client
7162    /// end close doesn't trigger buffer collection failure.
7163    ///
7164    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
7165    ///
7166    /// For brevity, the per-channel-protocol paragraphs above ignore the
7167    /// separate failure domain created by
7168    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
7169    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
7170    /// unexpectedly closes (without `Release` first) and that client end is
7171    /// under a failure domain, instead of failing the whole buffer collection,
7172    /// the failure domain is failed, but the buffer collection itself is
7173    /// isolated from failure of the failure domain. Such failure domains can be
7174    /// nested, in which case only the inner-most failure domain in which the
7175    /// `Node` resides fails.
7176    pub fn r#release(&self) -> Result<(), fidl::Error> {
7177        BufferCollectionTokenGroupProxyInterface::r#release(self)
7178    }
7179
7180    /// Set a name for VMOs in this buffer collection.
7181    ///
7182    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
7183    /// will be truncated to fit. The name of the vmo will be suffixed with the
7184    /// buffer index within the collection (if the suffix fits within
7185    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
7186    /// listed in the inspect data.
7187    ///
7188    /// The name only affects VMOs allocated after the name is set; this call
7189    /// does not rename existing VMOs. If multiple clients set different names
7190    /// then the larger priority value will win. Setting a new name with the
7191    /// same priority as a prior name doesn't change the name.
7192    ///
7193    /// All table fields are currently required.
7194    ///
7195    /// + request `priority` The name is only set if this is the first `SetName`
7196    ///   or if `priority` is greater than any previous `priority` value in
7197    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
7198    /// + request `name` The name for VMOs created under this buffer collection.
7199    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
7200        BufferCollectionTokenGroupProxyInterface::r#set_name(self, payload)
7201    }
7202
7203    /// Set information about the current client that can be used by sysmem to
7204    /// help diagnose leaking memory and allocation stalls waiting for a
7205    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
7206    ///
7207    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
7208    /// `Node`(s) derived from this `Node`, unless overriden by
7209    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
7210    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
7211    ///
7212    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
7213    /// `Allocator` is the most efficient way to ensure that all
7214    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
7215    /// set, and is also more efficient than separately sending the same debug
7216    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
7217    /// created [`fuchsia.sysmem2/Node`].
7218    ///
7219    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
7220    /// indicate which client is closing their channel first, leading to subtree
7221    /// failure (which can be normal if the purpose of the subtree is over, but
7222    /// if happening earlier than expected, the client-channel-specific name can
7223    /// help diagnose where the failure is first coming from, from sysmem's
7224    /// point of view).
7225    ///
7226    /// All table fields are currently required.
7227    ///
7228    /// + request `name` This can be an arbitrary string, but the current
7229    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
7230    /// + request `id` This can be an arbitrary id, but the current process ID
7231    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
7232    pub fn r#set_debug_client_info(
7233        &self,
7234        mut payload: &NodeSetDebugClientInfoRequest,
7235    ) -> Result<(), fidl::Error> {
7236        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, payload)
7237    }
7238
7239    /// Sysmem logs a warning if sysmem hasn't seen
7240    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
7241    /// within 5 seconds after creation of a new collection.
7242    ///
7243    /// Clients can call this method to change when the log is printed. If
7244    /// multiple client set the deadline, it's unspecified which deadline will
7245    /// take effect.
7246    ///
7247    /// In most cases the default works well.
7248    ///
7249    /// All table fields are currently required.
7250    ///
7251    /// + request `deadline` The time at which sysmem will start trying to log
7252    ///   the warning, unless all constraints are with sysmem by then.
7253    pub fn r#set_debug_timeout_log_deadline(
7254        &self,
7255        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7256    ) -> Result<(), fidl::Error> {
7257        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
7258    }
7259
7260    /// This enables verbose logging for the buffer collection.
7261    ///
7262    /// Verbose logging includes constraints set via
7263    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
7264    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
7265    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
7266    /// the tree of `Node`(s).
7267    ///
7268    /// Normally sysmem prints only a single line complaint when aggregation
7269    /// fails, with just the specific detailed reason that aggregation failed,
7270    /// with little surrounding context.  While this is often enough to diagnose
7271    /// a problem if only a small change was made and everything was working
7272    /// before the small change, it's often not particularly helpful for getting
7273    /// a new buffer collection to work for the first time.  Especially with
7274    /// more complex trees of nodes, involving things like
7275    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
7276    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
7277    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
7278    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
7279    /// looks like and why it's failing a logical allocation, or why a tree or
7280    /// subtree is failing sooner than expected.
7281    ///
7282    /// The intent of the extra logging is to be acceptable from a performance
7283    /// point of view, under the assumption that verbose logging is only enabled
7284    /// on a low number of buffer collections. If we're not tracking down a bug,
7285    /// we shouldn't send this message.
7286    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7287        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
7288    }
7289
7290    /// This gets a handle that can be used as a parameter to
7291    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
7292    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
7293    /// client obtained this handle from this `Node`.
7294    ///
7295    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
7296    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
7297    /// despite the two calls typically being on different channels.
7298    ///
7299    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
7300    ///
7301    /// All table fields are currently required.
7302    ///
7303    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
7304    ///   different `Node` channel, to prove that the client obtained the handle
7305    ///   from this `Node`.
7306    pub fn r#get_node_ref(
7307        &self,
7308    ) -> fidl::client::QueryResponseFut<
7309        NodeGetNodeRefResponse,
7310        fdomain_client::fidl::FDomainResourceDialect,
7311    > {
7312        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
7313    }
7314
7315    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
7316    /// rooted at a different child token of a common parent
7317    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
7318    /// passed-in `node_ref`.
7319    ///
7320    /// This call is for assisting with admission control de-duplication, and
7321    /// with debugging.
7322    ///
7323    /// The `node_ref` must be obtained using
7324    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
7325    ///
7326    /// The `node_ref` can be a duplicated handle; it's not necessary to call
7327    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
7328    ///
7329    /// If a calling token may not actually be a valid token at all due to a
7330    /// potentially hostile/untrusted provider of the token, call
7331    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
7332    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
7333    /// never responds due to a calling token not being a real token (not really
7334    /// talking to sysmem).  Another option is to call
7335    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
7336    /// which also validates the token along with converting it to a
7337    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
7338    ///
7339    /// All table fields are currently required.
7340    ///
7341    /// - response `is_alternate`
7342    ///   - true: The first parent node in common between the calling node and
7343    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
7344    ///     that the calling `Node` and the `node_ref` `Node` will not have both
7345    ///     their constraints apply - rather sysmem will choose one or the other
7346    ///     of the constraints - never both.  This is because only one child of
7347    ///     a `BufferCollectionTokenGroup` is selected during logical
7348    ///     allocation, with only that one child's subtree contributing to
7349    ///     constraints aggregation.
7350    ///   - false: The first parent node in common between the calling `Node`
7351    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
7352    ///     Currently, this means the first parent node in common is a
7353    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
7354    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
7355    ///     `Node` may have both their constraints apply during constraints
7356    ///     aggregation of the logical allocation, if both `Node`(s) are
7357    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
7358    ///     this case, there is no `BufferCollectionTokenGroup` that will
7359    ///     directly prevent the two `Node`(s) from both being selected and
7360    ///     their constraints both aggregated, but even when false, one or both
7361    ///     `Node`(s) may still be eliminated from consideration if one or both
7362    ///     `Node`(s) has a direct or indirect parent
7363    ///     `BufferCollectionTokenGroup` which selects a child subtree other
7364    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
7365    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
7366    ///   associated with the same buffer collection as the calling `Node`.
7367    ///   Another reason for this error is if the `node_ref` is an
7368    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
7369    ///   a real `node_ref` obtained from `GetNodeRef`.
7370    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
7371    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
7372    ///   the needed rights expected on a real `node_ref`.
7373    /// * No other failing status codes are returned by this call.  However,
7374    ///   sysmem may add additional codes in future, so the client should have
7375    ///   sensible default handling for any failing status code.
7376    pub fn r#is_alternate_for(
7377        &self,
7378        mut payload: NodeIsAlternateForRequest,
7379    ) -> fidl::client::QueryResponseFut<
7380        NodeIsAlternateForResult,
7381        fdomain_client::fidl::FDomainResourceDialect,
7382    > {
7383        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, payload)
7384    }
7385
7386    /// Get the buffer collection ID. This ID is also available from
7387    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
7388    /// within the collection).
7389    ///
7390    /// This call is mainly useful in situations where we can't convey a
7391    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
7392    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
7393    /// handle, which can be joined back up with a `BufferCollection` client end
7394    /// that was created via a different path. Prefer to convey a
7395    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
7396    ///
7397    /// Trusting a `buffer_collection_id` value from a source other than sysmem
7398    /// is analogous to trusting a koid value from a source other than zircon.
7399    /// Both should be avoided unless really necessary, and both require
7400    /// caution. In some situations it may be reasonable to refer to a
7401    /// pre-established `BufferCollection` by `buffer_collection_id` via a
7402    /// protocol for efficiency reasons, but an incoming value purporting to be
7403    /// a `buffer_collection_id` is not sufficient alone to justify granting the
7404    /// sender of the `buffer_collection_id` any capability. The sender must
7405    /// first prove to a receiver that the sender has/had a VMO or has/had a
7406    /// `BufferCollectionToken` to the same collection by sending a handle that
7407    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
7408    /// `buffer_collection_id` value. The receiver should take care to avoid
7409    /// assuming that a sender had a `BufferCollectionToken` in cases where the
7410    /// sender has only proven that the sender had a VMO.
7411    ///
7412    /// - response `buffer_collection_id` This ID is unique per buffer
7413    ///   collection per boot. Each buffer is uniquely identified by the
7414    ///   `buffer_collection_id` and `buffer_index` together.
7415    pub fn r#get_buffer_collection_id(
7416        &self,
7417    ) -> fidl::client::QueryResponseFut<
7418        NodeGetBufferCollectionIdResponse,
7419        fdomain_client::fidl::FDomainResourceDialect,
7420    > {
7421        BufferCollectionTokenGroupProxyInterface::r#get_buffer_collection_id(self)
7422    }
7423
7424    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
7425    /// created after this message to weak, which means that a client's `Node`
7426    /// client end (or a child created after this message) is not alone
7427    /// sufficient to keep allocated VMOs alive.
7428    ///
7429    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
7430    /// `close_weak_asap`.
7431    ///
7432    /// This message is only permitted before the `Node` becomes ready for
7433    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
7434    ///   * `BufferCollectionToken`: any time
7435    ///   * `BufferCollection`: before `SetConstraints`
7436    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
7437    ///
7438    /// Currently, no conversion from strong `Node` to weak `Node` after ready
7439    /// for allocation is provided, but a client can simulate that by creating
7440    /// an additional `Node` before allocation and setting that additional
7441    /// `Node` to weak, and then potentially at some point later sending
7442    /// `Release` and closing the client end of the client's strong `Node`, but
7443    /// keeping the client's weak `Node`.
7444    ///
7445    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
7446    /// collection failure (all `Node` client end(s) will see
7447    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
7448    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
7449    /// this situation until all `Node`(s) are ready for allocation. For initial
7450    /// allocation to succeed, at least one strong `Node` is required to exist
7451    /// at allocation time, but after that client receives VMO handles, that
7452    /// client can `BufferCollection.Release` and close the client end without
7453    /// causing this type of failure.
7454    ///
7455    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
7456    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
7457    /// separately as appropriate.
7458    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
7459        BufferCollectionTokenGroupProxyInterface::r#set_weak(self)
7460    }
7461
7462    /// This indicates to sysmem that the client is prepared to pay attention to
7463    /// `close_weak_asap`.
7464    ///
7465    /// If sent, this message must be before
7466    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
7467    ///
7468    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
7469    /// send this message before `WaitForAllBuffersAllocated`, or a parent
7470    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
7471    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
7472    /// trigger buffer collection failure.
7473    ///
7474    /// This message is necessary because weak sysmem VMOs have not always been
7475    /// a thing, so older clients are not aware of the need to pay attention to
7476    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
7477    /// sysmem weak VMO handles asap. By having this message and requiring
7478    /// participants to indicate their acceptance of this aspect of the overall
7479    /// protocol, we avoid situations where an older client is delivered a weak
7480    /// VMO without any way for sysmem to get that VMO to close quickly later
7481    /// (and on a per-buffer basis).
7482    ///
7483    /// A participant that doesn't handle `close_weak_asap` and also doesn't
7484    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
7485    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
7486    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
7487    /// same participant has a child/delegate which does retrieve VMOs, that
7488    /// child/delegate will need to send `SetWeakOk` before
7489    /// `WaitForAllBuffersAllocated`.
7490    ///
7491    /// + request `for_child_nodes_also` If present and true, this means direct
7492    ///   child nodes of this node created after this message plus all
7493    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
7494    ///   those nodes. Any child node of this node that was created before this
7495    ///   message is not included. This setting is "sticky" in the sense that a
7496    ///   subsequent `SetWeakOk` without this bool set to true does not reset
7497    ///   the server-side bool. If this creates a problem for a participant, a
7498    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
7499    ///   tokens instead, as appropriate. A participant should only set
7500    ///   `for_child_nodes_also` true if the participant can really promise to
7501    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
7502    ///   weak VMO handles held by participants holding the corresponding child
7503    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
7504    ///   which are using sysmem(1) can be weak, despite the clients of those
7505    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
7506    ///   direct way to find out about `close_weak_asap`. This only applies to
7507    ///   descendents of this `Node` which are using sysmem(1), not to this
7508    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
7509    ///   token, which will fail allocation unless an ancestor of this `Node`
7510    ///   specified `for_child_nodes_also` true.
7511    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
7512        BufferCollectionTokenGroupProxyInterface::r#set_weak_ok(self, payload)
7513    }
7514
7515    /// The server_end will be closed after this `Node` and any child nodes have
7516    /// have released their buffer counts, making those counts available for
7517    /// reservation by a different `Node` via
7518    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
7519    ///
7520    /// The `Node` buffer counts may not be released until the entire tree of
7521    /// `Node`(s) is closed or failed, because
7522    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
7523    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
7524    /// `Node` buffer counts remain reserved until the orphaned node is later
7525    /// cleaned up.
7526    ///
7527    /// If the `Node` exceeds a fairly large number of attached eventpair server
7528    /// ends, a log message will indicate this and the `Node` (and the
7529    /// appropriate) sub-tree will fail.
7530    ///
7531    /// The `server_end` will remain open when
7532    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
7533    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
7534    /// [`fuchsia.sysmem2/BufferCollection`].
7535    ///
7536    /// This message can also be used with a
7537    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
7538    pub fn r#attach_node_tracking(
7539        &self,
7540        mut payload: NodeAttachNodeTrackingRequest,
7541    ) -> Result<(), fidl::Error> {
7542        BufferCollectionTokenGroupProxyInterface::r#attach_node_tracking(self, payload)
7543    }
7544
7545    /// Create a child [`fuchsia.sysmem2/BufferCollectionToken`]. Only one child
7546    /// (including its children) will be selected during allocation (or logical
7547    /// allocation).
7548    ///
7549    /// Before passing the client end of this token to
7550    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], completion of
7551    /// [`fuchsia.sysmem2/Node.Sync`] after
7552    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] is required.
7553    /// Or the client can use
7554    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`] which
7555    /// essentially includes the `Sync`.
7556    ///
7557    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
7558    /// fail the group's subtree and close the connection.
7559    ///
7560    /// After all children have been created, send AllChildrenPresent.
7561    ///
7562    /// + request `token_request` The server end of the new token channel.
7563    /// + request `rights_attenuation_mask` If ZX_RIGHT_SAME_RIGHTS, the created
7564    ///   token allows the holder to get the same rights to buffers as the
7565    ///   parent token (of the group) had. When the value isn't
7566    ///   ZX_RIGHT_SAME_RIGHTS, the value is interpretted as a bitmask with 0
7567    ///   bits ensuring those rights are attentuated, so 0xFFFFFFFF is a synonym
7568    ///   for ZX_RIGHT_SAME_RIGHTS. The value 0 is not allowed and intentionally
7569    ///   causes subtree failure.
7570    pub fn r#create_child(
7571        &self,
7572        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7573    ) -> Result<(), fidl::Error> {
7574        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
7575    }
7576
7577    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7578    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`], no
7579    /// [`fuchsia.sysmem2/Node.Sync`] is required before passing the client end
7580    /// of a returned token to
7581    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`].
7582    ///
7583    /// The lower-index child tokens are higher priority (attempted sooner) than
7584    /// higher-index child tokens.
7585    ///
7586    /// As per all child tokens, successful aggregation will choose exactly one
7587    /// child among all created children (across all children created across
7588    /// potentially multiple calls to
7589    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] and
7590    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`]).
7591    ///
7592    /// The maximum permissible total number of children per group, and total
7593    /// number of nodes in an overall tree (from the root) are capped to limits
7594    /// which are not configurable via these protocols.
7595    ///
7596    /// Sending CreateChildrenSync after AllChildrenPresent is not permitted;
7597    /// this will fail the group's subtree and close the connection.
7598    ///
7599    /// After all children have been created, send AllChildrenPresent.
7600    ///
7601    /// + request `rights_attentuation_masks` The size of the
7602    ///   `rights_attentuation_masks` determines the number of created child
7603    ///   tokens. The value ZX_RIGHT_SAME_RIGHTS doesn't attenuate any rights.
7604    ///   The value 0xFFFFFFFF is a synonym for ZX_RIGHT_SAME_RIGHTS. For any
7605    ///   other value, each 0 bit in the mask attenuates that right.
7606    /// - response `tokens` The created child tokens.
7607    pub fn r#create_children_sync(
7608        &self,
7609        mut payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7610    ) -> fidl::client::QueryResponseFut<
7611        BufferCollectionTokenGroupCreateChildrenSyncResponse,
7612        fdomain_client::fidl::FDomainResourceDialect,
7613    > {
7614        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(self, payload)
7615    }
7616
7617    /// Indicate that no more children will be created.
7618    ///
7619    /// After creating all children, the client should send
7620    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent`] to
7621    /// inform sysmem that no more children will be created, so that sysmem can
7622    /// know when it's ok to start aggregating constraints.
7623    ///
7624    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
7625    /// fail the group's subtree and close the connection.
7626    ///
7627    /// If [`fuchsia.sysmem2/Node.Release`] is to be sent, it should be sent
7628    /// after `AllChildrenPresent`, else failure of the group's subtree will be
7629    /// triggered. This is intentionally not analogous to how `Release` without
7630    /// prior [`fuchsia.sysmem2/BufferCollection.SetConstraints`] doesn't cause
7631    /// subtree failure.
7632    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7633        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
7634    }
7635}
7636
7637impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
7638    type SyncResponseFut =
7639        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7640    fn r#sync(&self) -> Self::SyncResponseFut {
7641        fn _decode(
7642            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7643        ) -> Result<(), fidl::Error> {
7644            let _response = fidl::client::decode_transaction_body::<
7645                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
7646                fdomain_client::fidl::FDomainResourceDialect,
7647                0x11ac2555cf575b54,
7648            >(_buf?)?
7649            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("sync")?;
7650            Ok(_response)
7651        }
7652        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7653            (),
7654            0x11ac2555cf575b54,
7655            fidl::encoding::DynamicFlags::FLEXIBLE,
7656            _decode,
7657        )
7658    }
7659
7660    fn r#release(&self) -> Result<(), fidl::Error> {
7661        self.client.send::<fidl::encoding::EmptyPayload>(
7662            (),
7663            0x6a5cae7d6d6e04c6,
7664            fidl::encoding::DynamicFlags::FLEXIBLE,
7665        )
7666    }
7667
7668    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
7669        self.client.send::<NodeSetNameRequest>(
7670            payload,
7671            0xb41f1624f48c1e9,
7672            fidl::encoding::DynamicFlags::FLEXIBLE,
7673        )
7674    }
7675
7676    fn r#set_debug_client_info(
7677        &self,
7678        mut payload: &NodeSetDebugClientInfoRequest,
7679    ) -> Result<(), fidl::Error> {
7680        self.client.send::<NodeSetDebugClientInfoRequest>(
7681            payload,
7682            0x5cde8914608d99b1,
7683            fidl::encoding::DynamicFlags::FLEXIBLE,
7684        )
7685    }
7686
7687    fn r#set_debug_timeout_log_deadline(
7688        &self,
7689        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7690    ) -> Result<(), fidl::Error> {
7691        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7692            payload,
7693            0x716b0af13d5c0806,
7694            fidl::encoding::DynamicFlags::FLEXIBLE,
7695        )
7696    }
7697
7698    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7699        self.client.send::<fidl::encoding::EmptyPayload>(
7700            (),
7701            0x5209c77415b4dfad,
7702            fidl::encoding::DynamicFlags::FLEXIBLE,
7703        )
7704    }
7705
7706    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
7707        NodeGetNodeRefResponse,
7708        fdomain_client::fidl::FDomainResourceDialect,
7709    >;
7710    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7711        fn _decode(
7712            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7713        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
7714            let _response = fidl::client::decode_transaction_body::<
7715                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
7716                fdomain_client::fidl::FDomainResourceDialect,
7717                0x5b3d0e51614df053,
7718            >(_buf?)?
7719            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("get_node_ref")?;
7720            Ok(_response)
7721        }
7722        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
7723            (),
7724            0x5b3d0e51614df053,
7725            fidl::encoding::DynamicFlags::FLEXIBLE,
7726            _decode,
7727        )
7728    }
7729
7730    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7731        NodeIsAlternateForResult,
7732        fdomain_client::fidl::FDomainResourceDialect,
7733    >;
7734    fn r#is_alternate_for(
7735        &self,
7736        mut payload: NodeIsAlternateForRequest,
7737    ) -> Self::IsAlternateForResponseFut {
7738        fn _decode(
7739            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7740        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7741            let _response = fidl::client::decode_transaction_body::<
7742                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
7743                fdomain_client::fidl::FDomainResourceDialect,
7744                0x3a58e00157e0825,
7745            >(_buf?)?
7746            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("is_alternate_for")?;
7747            Ok(_response.map(|x| x))
7748        }
7749        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7750            &mut payload,
7751            0x3a58e00157e0825,
7752            fidl::encoding::DynamicFlags::FLEXIBLE,
7753            _decode,
7754        )
7755    }
7756
7757    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
7758        NodeGetBufferCollectionIdResponse,
7759        fdomain_client::fidl::FDomainResourceDialect,
7760    >;
7761    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
7762        fn _decode(
7763            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7764        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
7765            let _response = fidl::client::decode_transaction_body::<
7766                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
7767                fdomain_client::fidl::FDomainResourceDialect,
7768                0x77d19a494b78ba8c,
7769            >(_buf?)?
7770            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("get_buffer_collection_id")?;
7771            Ok(_response)
7772        }
7773        self.client.send_query_and_decode::<
7774            fidl::encoding::EmptyPayload,
7775            NodeGetBufferCollectionIdResponse,
7776        >(
7777            (),
7778            0x77d19a494b78ba8c,
7779            fidl::encoding::DynamicFlags::FLEXIBLE,
7780            _decode,
7781        )
7782    }
7783
7784    fn r#set_weak(&self) -> Result<(), fidl::Error> {
7785        self.client.send::<fidl::encoding::EmptyPayload>(
7786            (),
7787            0x22dd3ea514eeffe1,
7788            fidl::encoding::DynamicFlags::FLEXIBLE,
7789        )
7790    }
7791
7792    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
7793        self.client.send::<NodeSetWeakOkRequest>(
7794            &mut payload,
7795            0x38a44fc4d7724be9,
7796            fidl::encoding::DynamicFlags::FLEXIBLE,
7797        )
7798    }
7799
7800    fn r#attach_node_tracking(
7801        &self,
7802        mut payload: NodeAttachNodeTrackingRequest,
7803    ) -> Result<(), fidl::Error> {
7804        self.client.send::<NodeAttachNodeTrackingRequest>(
7805            &mut payload,
7806            0x3f22f2a293d3cdac,
7807            fidl::encoding::DynamicFlags::FLEXIBLE,
7808        )
7809    }
7810
7811    fn r#create_child(
7812        &self,
7813        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7814    ) -> Result<(), fidl::Error> {
7815        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
7816            &mut payload,
7817            0x41a0075d419f30c5,
7818            fidl::encoding::DynamicFlags::FLEXIBLE,
7819        )
7820    }
7821
7822    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
7823        BufferCollectionTokenGroupCreateChildrenSyncResponse,
7824        fdomain_client::fidl::FDomainResourceDialect,
7825    >;
7826    fn r#create_children_sync(
7827        &self,
7828        mut payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7829    ) -> Self::CreateChildrenSyncResponseFut {
7830        fn _decode(
7831            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7832        ) -> Result<BufferCollectionTokenGroupCreateChildrenSyncResponse, fidl::Error> {
7833            let _response = fidl::client::decode_transaction_body::<
7834                fidl::encoding::FlexibleType<BufferCollectionTokenGroupCreateChildrenSyncResponse>,
7835                fdomain_client::fidl::FDomainResourceDialect,
7836                0x15dea448c536070a,
7837            >(_buf?)?
7838            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("create_children_sync")?;
7839            Ok(_response)
7840        }
7841        self.client.send_query_and_decode::<
7842            BufferCollectionTokenGroupCreateChildrenSyncRequest,
7843            BufferCollectionTokenGroupCreateChildrenSyncResponse,
7844        >(
7845            payload,
7846            0x15dea448c536070a,
7847            fidl::encoding::DynamicFlags::FLEXIBLE,
7848            _decode,
7849        )
7850    }
7851
7852    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7853        self.client.send::<fidl::encoding::EmptyPayload>(
7854            (),
7855            0x5c327e4a23391312,
7856            fidl::encoding::DynamicFlags::FLEXIBLE,
7857        )
7858    }
7859}
7860
7861pub struct BufferCollectionTokenGroupEventStream {
7862    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
7863}
7864
7865impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
7866
7867impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
7868    fn is_terminated(&self) -> bool {
7869        self.event_receiver.is_terminated()
7870    }
7871}
7872
7873impl futures::Stream for BufferCollectionTokenGroupEventStream {
7874    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
7875
7876    fn poll_next(
7877        mut self: std::pin::Pin<&mut Self>,
7878        cx: &mut std::task::Context<'_>,
7879    ) -> std::task::Poll<Option<Self::Item>> {
7880        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7881            &mut self.event_receiver,
7882            cx
7883        )?) {
7884            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
7885            None => std::task::Poll::Ready(None),
7886        }
7887    }
7888}
7889
7890#[derive(Debug)]
7891pub enum BufferCollectionTokenGroupEvent {
7892    #[non_exhaustive]
7893    _UnknownEvent {
7894        /// Ordinal of the event that was sent.
7895        ordinal: u64,
7896    },
7897}
7898
7899impl BufferCollectionTokenGroupEvent {
7900    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
7901    fn decode(
7902        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7903    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
7904        let (bytes, _handles) = buf.split_mut();
7905        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7906        debug_assert_eq!(tx_header.tx_id, 0);
7907        match tx_header.ordinal {
7908            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7909                Ok(BufferCollectionTokenGroupEvent::_UnknownEvent {
7910                    ordinal: tx_header.ordinal,
7911                })
7912            }
7913            _ => Err(fidl::Error::UnknownOrdinal {
7914                ordinal: tx_header.ordinal,
7915                protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7916            })
7917        }
7918    }
7919}
7920
7921/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollectionTokenGroup.
7922pub struct BufferCollectionTokenGroupRequestStream {
7923    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7924    is_terminated: bool,
7925}
7926
7927impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
7928
7929impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
7930    fn is_terminated(&self) -> bool {
7931        self.is_terminated
7932    }
7933}
7934
7935impl fdomain_client::fidl::RequestStream for BufferCollectionTokenGroupRequestStream {
7936    type Protocol = BufferCollectionTokenGroupMarker;
7937    type ControlHandle = BufferCollectionTokenGroupControlHandle;
7938
7939    fn from_channel(channel: fdomain_client::Channel) -> Self {
7940        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7941    }
7942
7943    fn control_handle(&self) -> Self::ControlHandle {
7944        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
7945    }
7946
7947    fn into_inner(
7948        self,
7949    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
7950    {
7951        (self.inner, self.is_terminated)
7952    }
7953
7954    fn from_inner(
7955        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7956        is_terminated: bool,
7957    ) -> Self {
7958        Self { inner, is_terminated }
7959    }
7960}
7961
7962impl futures::Stream for BufferCollectionTokenGroupRequestStream {
7963    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
7964
7965    fn poll_next(
7966        mut self: std::pin::Pin<&mut Self>,
7967        cx: &mut std::task::Context<'_>,
7968    ) -> std::task::Poll<Option<Self::Item>> {
7969        let this = &mut *self;
7970        if this.inner.check_shutdown(cx) {
7971            this.is_terminated = true;
7972            return std::task::Poll::Ready(None);
7973        }
7974        if this.is_terminated {
7975            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
7976        }
7977        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
7978            |bytes, handles| {
7979                match this.inner.channel().read_etc(cx, bytes, handles) {
7980                    std::task::Poll::Ready(Ok(())) => {}
7981                    std::task::Poll::Pending => return std::task::Poll::Pending,
7982                    std::task::Poll::Ready(Err(None)) => {
7983                        this.is_terminated = true;
7984                        return std::task::Poll::Ready(None);
7985                    }
7986                    std::task::Poll::Ready(Err(Some(e))) => {
7987                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7988                            e.into(),
7989                        ))));
7990                    }
7991                }
7992
7993                // A message has been received from the channel
7994                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7995
7996                std::task::Poll::Ready(Some(match header.ordinal {
7997                0x11ac2555cf575b54 => {
7998                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7999                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8000                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8001                    let control_handle = BufferCollectionTokenGroupControlHandle {
8002                        inner: this.inner.clone(),
8003                    };
8004                    Ok(BufferCollectionTokenGroupRequest::Sync {
8005                        responder: BufferCollectionTokenGroupSyncResponder {
8006                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8007                            tx_id: header.tx_id,
8008                        },
8009                    })
8010                }
8011                0x6a5cae7d6d6e04c6 => {
8012                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8013                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8014                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8015                    let control_handle = BufferCollectionTokenGroupControlHandle {
8016                        inner: this.inner.clone(),
8017                    };
8018                    Ok(BufferCollectionTokenGroupRequest::Release {
8019                        control_handle,
8020                    })
8021                }
8022                0xb41f1624f48c1e9 => {
8023                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8024                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
8025                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
8026                    let control_handle = BufferCollectionTokenGroupControlHandle {
8027                        inner: this.inner.clone(),
8028                    };
8029                    Ok(BufferCollectionTokenGroupRequest::SetName {payload: req,
8030                        control_handle,
8031                    })
8032                }
8033                0x5cde8914608d99b1 => {
8034                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8035                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
8036                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
8037                    let control_handle = BufferCollectionTokenGroupControlHandle {
8038                        inner: this.inner.clone(),
8039                    };
8040                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {payload: req,
8041                        control_handle,
8042                    })
8043                }
8044                0x716b0af13d5c0806 => {
8045                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8046                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
8047                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
8048                    let control_handle = BufferCollectionTokenGroupControlHandle {
8049                        inner: this.inner.clone(),
8050                    };
8051                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {payload: req,
8052                        control_handle,
8053                    })
8054                }
8055                0x5209c77415b4dfad => {
8056                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8057                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8058                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8059                    let control_handle = BufferCollectionTokenGroupControlHandle {
8060                        inner: this.inner.clone(),
8061                    };
8062                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
8063                        control_handle,
8064                    })
8065                }
8066                0x5b3d0e51614df053 => {
8067                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8068                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8069                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8070                    let control_handle = BufferCollectionTokenGroupControlHandle {
8071                        inner: this.inner.clone(),
8072                    };
8073                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
8074                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
8075                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8076                            tx_id: header.tx_id,
8077                        },
8078                    })
8079                }
8080                0x3a58e00157e0825 => {
8081                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8082                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
8083                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
8084                    let control_handle = BufferCollectionTokenGroupControlHandle {
8085                        inner: this.inner.clone(),
8086                    };
8087                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {payload: req,
8088                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
8089                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8090                            tx_id: header.tx_id,
8091                        },
8092                    })
8093                }
8094                0x77d19a494b78ba8c => {
8095                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8096                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8097                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8098                    let control_handle = BufferCollectionTokenGroupControlHandle {
8099                        inner: this.inner.clone(),
8100                    };
8101                    Ok(BufferCollectionTokenGroupRequest::GetBufferCollectionId {
8102                        responder: BufferCollectionTokenGroupGetBufferCollectionIdResponder {
8103                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8104                            tx_id: header.tx_id,
8105                        },
8106                    })
8107                }
8108                0x22dd3ea514eeffe1 => {
8109                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8110                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8111                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8112                    let control_handle = BufferCollectionTokenGroupControlHandle {
8113                        inner: this.inner.clone(),
8114                    };
8115                    Ok(BufferCollectionTokenGroupRequest::SetWeak {
8116                        control_handle,
8117                    })
8118                }
8119                0x38a44fc4d7724be9 => {
8120                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8121                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
8122                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
8123                    let control_handle = BufferCollectionTokenGroupControlHandle {
8124                        inner: this.inner.clone(),
8125                    };
8126                    Ok(BufferCollectionTokenGroupRequest::SetWeakOk {payload: req,
8127                        control_handle,
8128                    })
8129                }
8130                0x3f22f2a293d3cdac => {
8131                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8132                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
8133                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
8134                    let control_handle = BufferCollectionTokenGroupControlHandle {
8135                        inner: this.inner.clone(),
8136                    };
8137                    Ok(BufferCollectionTokenGroupRequest::AttachNodeTracking {payload: req,
8138                        control_handle,
8139                    })
8140                }
8141                0x41a0075d419f30c5 => {
8142                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8143                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fdomain_client::fidl::FDomainResourceDialect);
8144                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
8145                    let control_handle = BufferCollectionTokenGroupControlHandle {
8146                        inner: this.inner.clone(),
8147                    };
8148                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
8149                        control_handle,
8150                    })
8151                }
8152                0x15dea448c536070a => {
8153                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8154                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
8155                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
8156                    let control_handle = BufferCollectionTokenGroupControlHandle {
8157                        inner: this.inner.clone(),
8158                    };
8159                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {payload: req,
8160                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
8161                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8162                            tx_id: header.tx_id,
8163                        },
8164                    })
8165                }
8166                0x5c327e4a23391312 => {
8167                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8168                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8169                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8170                    let control_handle = BufferCollectionTokenGroupControlHandle {
8171                        inner: this.inner.clone(),
8172                    };
8173                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
8174                        control_handle,
8175                    })
8176                }
8177                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8178                    Ok(BufferCollectionTokenGroupRequest::_UnknownMethod {
8179                        ordinal: header.ordinal,
8180                        control_handle: BufferCollectionTokenGroupControlHandle { inner: this.inner.clone() },
8181                        method_type: fidl::MethodType::OneWay,
8182                    })
8183                }
8184                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8185                    this.inner.send_framework_err(
8186                        fidl::encoding::FrameworkErr::UnknownMethod,
8187                        header.tx_id,
8188                        header.ordinal,
8189                        header.dynamic_flags(),
8190                        (bytes, handles),
8191                    )?;
8192                    Ok(BufferCollectionTokenGroupRequest::_UnknownMethod {
8193                        ordinal: header.ordinal,
8194                        control_handle: BufferCollectionTokenGroupControlHandle { inner: this.inner.clone() },
8195                        method_type: fidl::MethodType::TwoWay,
8196                    })
8197                }
8198                _ => Err(fidl::Error::UnknownOrdinal {
8199                    ordinal: header.ordinal,
8200                    protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8201                }),
8202            }))
8203            },
8204        )
8205    }
8206}
8207
8208/// The sysmem implementation is consistent with a logical / conceptual model of
8209/// allocation / logical allocation as follows:
8210///
8211/// As usual, a logical allocation considers either the root and all nodes with
8212/// connectivity to the root that don't transit a [`fuchsia.sysmem2/Node`]
8213/// created with [`fuchsia.sysmem2/BufferCollection.AttachToken`], or a subtree
8214/// rooted at an `AttachToken` `Node` and all `Node`(s) with connectivity to
8215/// that subtree that don't transit another `AttachToken`.  This is called the
8216/// logical allocation pruned subtree, or pruned subtree for short.
8217///
8218/// During constraints aggregation, each
8219/// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] will select a single child
8220/// `Node` among its direct children. The rest of the children will appear to
8221/// fail the logical allocation, while the selected child may succeed.
8222///
8223/// When more than one `BufferCollectionTokenGroup` exists in the overall
8224/// logical allocation pruned subtree, the relative priority between two groups
8225/// is equivalent to their ordering in a DFS pre-order iteration of the tree,
8226/// with parents higher priority than children, and left children higher
8227/// priority than right children.
8228///
8229/// When a particular child of a group is selected (whether provisionally during
8230/// a constraints aggregation attempt, or as a final selection), the
8231/// non-selection of other children of the group will "hide" any other groups
8232/// under those non-selected children.
8233///
8234/// Within a logical allocation, aggregation is attempted first by provisionally
8235/// selecting child 0 of the highest-priority group, and child 0 of the next
8236/// highest-priority group that isn't hidden by the provisional selections so
8237/// far, etc.
8238///
8239/// If that aggregation attempt fails, aggregation will be attempted with the
8240/// ordinal 0 child of all the same groups except the lowest priority non-hidden
8241/// group which will provisionally select its ordinal 1 child (and then child 2
8242/// and so on). If a new lowest-priority group is un-hidden as provisional
8243/// selections are updated, that newly un-hidden lowest-priority group has all
8244/// its children considered in order, before changing the provisional selection
8245/// in the former lowest-priority group. In terms of result, this is equivalent
8246/// to systematic enumeration of all possible combinations of choices in a
8247/// counting-like order updating the lowest-priority group the most often and
8248/// the highest-priority group the least often. Rather than actually attempting
8249/// aggregation with all the combinations, we can skip over combinations which
8250/// are redundant/equivalent due to hiding without any change to the result.
8251///
8252/// Attempted constraint aggregations of enumerated non-equivalent combinations
8253/// of choices continue in this manner until either (a) all aggregation attempts
8254/// fail in which case the overall logical allocation fails, or (b) until an
8255/// attempted aggregation succeeds, in which case buffer allocation (if needed;
8256/// if this is the pruned subtree rooted at the overall root `Node`) is
8257/// attempted once. If buffer allocation based on the first successful
8258/// constraints aggregation fails, the overall logical allocation fails (there
8259/// is no buffer allocation retry / re-attempt). If buffer allocation succeeds
8260/// (or is not needed due to being a pruned subtree that doesn't include the
8261/// root), the logical allocation succeeds.
8262///
8263/// If this prioritization scheme cannot reasonably work for your usage of
8264/// sysmem, please don't hesitate to contact sysmem folks to discuss potentially
8265/// adding a way to achieve what you need.
8266///
8267/// Please avoid creating a large number of `BufferCollectionTokenGroup`(s) per
8268/// logical allocation, especially with large number of children overall, and
8269/// especially in cases where aggregation may reasonably be expected to often
8270/// fail using ordinal 0 children and possibly with later children as well.
8271/// Sysmem mitigates potentially high time complexity of evaluating too many
8272/// child combinations/selections across too many groups by simply failing
8273/// logical allocation beyond a certain (fairly high, but not huge) max number
8274/// of considered group child combinations/selections. More advanced (and more
8275/// complicated) mitigation is not anticipated to be practically necessary or
8276/// worth the added complexity. Please contact sysmem folks if the max limit is
8277/// getting hit or if you anticipate it getting hit, to discuss potential
8278/// options.
8279///
8280/// Prefer to use multiple [`fuchsia.sysmem2/ImageFormatConstraints`] in a
8281/// single [`fuchsia.sysmem2/BufferCollectionConstraints`] when feasible (when a
8282/// participant just needs to express the ability to work with more than a
8283/// single [`fuchsia.images2/PixelFormat`], with sysmem choosing which
8284/// `PixelFormat` to use among those supported by all participants).
8285///
8286/// Similar to [`fuchsia.sysmem2/BufferCollectionToken`] and
8287/// [`fuchsia.sysmem2/BufferCollection`], closure of the
8288/// `BufferCollectionTokenGroup` channel without sending
8289/// [`fuchsia.sysmem2/Node.Release`] first will cause buffer collection failure
8290/// (or subtree failure if using
8291/// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
8292/// [`fuchsia.sysmem2/BufferCollection.AttachToken`] and the
8293/// `BufferCollectionTokenGroup` is part of a subtree under such a node that
8294/// doesn't propagate failure to its parent).
8295///
8296/// Epitaphs are not used in this protocol.
8297#[derive(Debug)]
8298pub enum BufferCollectionTokenGroupRequest {
8299    /// Ensure that previous messages have been received server side. This is
8300    /// particularly useful after previous messages that created new tokens,
8301    /// because a token must be known to the sysmem server before sending the
8302    /// token to another participant.
8303    ///
8304    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
8305    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
8306    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
8307    /// to mitigate the possibility of a hostile/fake
8308    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
8309    /// Another way is to pass the token to
8310    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
8311    /// the token as part of exchanging it for a
8312    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
8313    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
8314    /// of stalling.
8315    ///
8316    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
8317    /// and then starting and completing a `Sync`, it's then safe to send the
8318    /// `BufferCollectionToken` client ends to other participants knowing the
8319    /// server will recognize the tokens when they're sent by the other
8320    /// participants to sysmem in a
8321    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
8322    /// efficient way to create tokens while avoiding unnecessary round trips.
8323    ///
8324    /// Other options include waiting for each
8325    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
8326    /// individually (using separate call to `Sync` after each), or calling
8327    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
8328    /// converted to a `BufferCollection` via
8329    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
8330    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
8331    /// the sync step and can create multiple tokens at once.
8332    Sync { responder: BufferCollectionTokenGroupSyncResponder },
8333    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
8334    ///
8335    /// Normally a participant will convert a `BufferCollectionToken` into a
8336    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
8337    /// `Release` via the token (and then close the channel immediately or
8338    /// shortly later in response to server closing the server end), which
8339    /// avoids causing buffer collection failure. Without a prior `Release`,
8340    /// closing the `BufferCollectionToken` client end will cause buffer
8341    /// collection failure.
8342    ///
8343    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
8344    ///
8345    /// By default the server handles unexpected closure of a
8346    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
8347    /// first) by failing the buffer collection. Partly this is to expedite
8348    /// closing VMO handles to reclaim memory when any participant fails. If a
8349    /// participant would like to cleanly close a `BufferCollection` without
8350    /// causing buffer collection failure, the participant can send `Release`
8351    /// before closing the `BufferCollection` client end. The `Release` can
8352    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
8353    /// buffer collection won't require constraints from this node in order to
8354    /// allocate. If after `SetConstraints`, the constraints are retained and
8355    /// aggregated, despite the lack of `BufferCollection` connection at the
8356    /// time of constraints aggregation.
8357    ///
8358    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
8359    ///
8360    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
8361    /// end (without `Release` first) will trigger failure of the buffer
8362    /// collection. To close a `BufferCollectionTokenGroup` channel without
8363    /// failing the buffer collection, ensure that AllChildrenPresent() has been
8364    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
8365    /// client end.
8366    ///
8367    /// If `Release` occurs before
8368    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
8369    /// buffer collection will fail (triggered by reception of `Release` without
8370    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
8371    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
8372    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
8373    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
8374    /// close requires `AllChildrenPresent` (if not already sent), then
8375    /// `Release`, then close client end.
8376    ///
8377    /// If `Release` occurs after `AllChildrenPresent`, the children and all
8378    /// their constraints remain intact (just as they would if the
8379    /// `BufferCollectionTokenGroup` channel had remained open), and the client
8380    /// end close doesn't trigger buffer collection failure.
8381    ///
8382    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
8383    ///
8384    /// For brevity, the per-channel-protocol paragraphs above ignore the
8385    /// separate failure domain created by
8386    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
8387    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
8388    /// unexpectedly closes (without `Release` first) and that client end is
8389    /// under a failure domain, instead of failing the whole buffer collection,
8390    /// the failure domain is failed, but the buffer collection itself is
8391    /// isolated from failure of the failure domain. Such failure domains can be
8392    /// nested, in which case only the inner-most failure domain in which the
8393    /// `Node` resides fails.
8394    Release { control_handle: BufferCollectionTokenGroupControlHandle },
8395    /// Set a name for VMOs in this buffer collection.
8396    ///
8397    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
8398    /// will be truncated to fit. The name of the vmo will be suffixed with the
8399    /// buffer index within the collection (if the suffix fits within
8400    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
8401    /// listed in the inspect data.
8402    ///
8403    /// The name only affects VMOs allocated after the name is set; this call
8404    /// does not rename existing VMOs. If multiple clients set different names
8405    /// then the larger priority value will win. Setting a new name with the
8406    /// same priority as a prior name doesn't change the name.
8407    ///
8408    /// All table fields are currently required.
8409    ///
8410    /// + request `priority` The name is only set if this is the first `SetName`
8411    ///   or if `priority` is greater than any previous `priority` value in
8412    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
8413    /// + request `name` The name for VMOs created under this buffer collection.
8414    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionTokenGroupControlHandle },
8415    /// Set information about the current client that can be used by sysmem to
8416    /// help diagnose leaking memory and allocation stalls waiting for a
8417    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
8418    ///
8419    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
8420    /// `Node`(s) derived from this `Node`, unless overriden by
8421    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
8422    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
8423    ///
8424    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
8425    /// `Allocator` is the most efficient way to ensure that all
8426    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
8427    /// set, and is also more efficient than separately sending the same debug
8428    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
8429    /// created [`fuchsia.sysmem2/Node`].
8430    ///
8431    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
8432    /// indicate which client is closing their channel first, leading to subtree
8433    /// failure (which can be normal if the purpose of the subtree is over, but
8434    /// if happening earlier than expected, the client-channel-specific name can
8435    /// help diagnose where the failure is first coming from, from sysmem's
8436    /// point of view).
8437    ///
8438    /// All table fields are currently required.
8439    ///
8440    /// + request `name` This can be an arbitrary string, but the current
8441    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
8442    /// + request `id` This can be an arbitrary id, but the current process ID
8443    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
8444    SetDebugClientInfo {
8445        payload: NodeSetDebugClientInfoRequest,
8446        control_handle: BufferCollectionTokenGroupControlHandle,
8447    },
8448    /// Sysmem logs a warning if sysmem hasn't seen
8449    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
8450    /// within 5 seconds after creation of a new collection.
8451    ///
8452    /// Clients can call this method to change when the log is printed. If
8453    /// multiple client set the deadline, it's unspecified which deadline will
8454    /// take effect.
8455    ///
8456    /// In most cases the default works well.
8457    ///
8458    /// All table fields are currently required.
8459    ///
8460    /// + request `deadline` The time at which sysmem will start trying to log
8461    ///   the warning, unless all constraints are with sysmem by then.
8462    SetDebugTimeoutLogDeadline {
8463        payload: NodeSetDebugTimeoutLogDeadlineRequest,
8464        control_handle: BufferCollectionTokenGroupControlHandle,
8465    },
8466    /// This enables verbose logging for the buffer collection.
8467    ///
8468    /// Verbose logging includes constraints set via
8469    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
8470    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
8471    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
8472    /// the tree of `Node`(s).
8473    ///
8474    /// Normally sysmem prints only a single line complaint when aggregation
8475    /// fails, with just the specific detailed reason that aggregation failed,
8476    /// with little surrounding context.  While this is often enough to diagnose
8477    /// a problem if only a small change was made and everything was working
8478    /// before the small change, it's often not particularly helpful for getting
8479    /// a new buffer collection to work for the first time.  Especially with
8480    /// more complex trees of nodes, involving things like
8481    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
8482    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
8483    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
8484    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
8485    /// looks like and why it's failing a logical allocation, or why a tree or
8486    /// subtree is failing sooner than expected.
8487    ///
8488    /// The intent of the extra logging is to be acceptable from a performance
8489    /// point of view, under the assumption that verbose logging is only enabled
8490    /// on a low number of buffer collections. If we're not tracking down a bug,
8491    /// we shouldn't send this message.
8492    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
8493    /// This gets a handle that can be used as a parameter to
8494    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
8495    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
8496    /// client obtained this handle from this `Node`.
8497    ///
8498    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
8499    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
8500    /// despite the two calls typically being on different channels.
8501    ///
8502    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
8503    ///
8504    /// All table fields are currently required.
8505    ///
8506    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
8507    ///   different `Node` channel, to prove that the client obtained the handle
8508    ///   from this `Node`.
8509    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
8510    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
8511    /// rooted at a different child token of a common parent
8512    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
8513    /// passed-in `node_ref`.
8514    ///
8515    /// This call is for assisting with admission control de-duplication, and
8516    /// with debugging.
8517    ///
8518    /// The `node_ref` must be obtained using
8519    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
8520    ///
8521    /// The `node_ref` can be a duplicated handle; it's not necessary to call
8522    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
8523    ///
8524    /// If a calling token may not actually be a valid token at all due to a
8525    /// potentially hostile/untrusted provider of the token, call
8526    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
8527    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
8528    /// never responds due to a calling token not being a real token (not really
8529    /// talking to sysmem).  Another option is to call
8530    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
8531    /// which also validates the token along with converting it to a
8532    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
8533    ///
8534    /// All table fields are currently required.
8535    ///
8536    /// - response `is_alternate`
8537    ///   - true: The first parent node in common between the calling node and
8538    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
8539    ///     that the calling `Node` and the `node_ref` `Node` will not have both
8540    ///     their constraints apply - rather sysmem will choose one or the other
8541    ///     of the constraints - never both.  This is because only one child of
8542    ///     a `BufferCollectionTokenGroup` is selected during logical
8543    ///     allocation, with only that one child's subtree contributing to
8544    ///     constraints aggregation.
8545    ///   - false: The first parent node in common between the calling `Node`
8546    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
8547    ///     Currently, this means the first parent node in common is a
8548    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
8549    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
8550    ///     `Node` may have both their constraints apply during constraints
8551    ///     aggregation of the logical allocation, if both `Node`(s) are
8552    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
8553    ///     this case, there is no `BufferCollectionTokenGroup` that will
8554    ///     directly prevent the two `Node`(s) from both being selected and
8555    ///     their constraints both aggregated, but even when false, one or both
8556    ///     `Node`(s) may still be eliminated from consideration if one or both
8557    ///     `Node`(s) has a direct or indirect parent
8558    ///     `BufferCollectionTokenGroup` which selects a child subtree other
8559    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
8560    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
8561    ///   associated with the same buffer collection as the calling `Node`.
8562    ///   Another reason for this error is if the `node_ref` is an
8563    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
8564    ///   a real `node_ref` obtained from `GetNodeRef`.
8565    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
8566    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
8567    ///   the needed rights expected on a real `node_ref`.
8568    /// * No other failing status codes are returned by this call.  However,
8569    ///   sysmem may add additional codes in future, so the client should have
8570    ///   sensible default handling for any failing status code.
8571    IsAlternateFor {
8572        payload: NodeIsAlternateForRequest,
8573        responder: BufferCollectionTokenGroupIsAlternateForResponder,
8574    },
8575    /// Get the buffer collection ID. This ID is also available from
8576    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
8577    /// within the collection).
8578    ///
8579    /// This call is mainly useful in situations where we can't convey a
8580    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
8581    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
8582    /// handle, which can be joined back up with a `BufferCollection` client end
8583    /// that was created via a different path. Prefer to convey a
8584    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
8585    ///
8586    /// Trusting a `buffer_collection_id` value from a source other than sysmem
8587    /// is analogous to trusting a koid value from a source other than zircon.
8588    /// Both should be avoided unless really necessary, and both require
8589    /// caution. In some situations it may be reasonable to refer to a
8590    /// pre-established `BufferCollection` by `buffer_collection_id` via a
8591    /// protocol for efficiency reasons, but an incoming value purporting to be
8592    /// a `buffer_collection_id` is not sufficient alone to justify granting the
8593    /// sender of the `buffer_collection_id` any capability. The sender must
8594    /// first prove to a receiver that the sender has/had a VMO or has/had a
8595    /// `BufferCollectionToken` to the same collection by sending a handle that
8596    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
8597    /// `buffer_collection_id` value. The receiver should take care to avoid
8598    /// assuming that a sender had a `BufferCollectionToken` in cases where the
8599    /// sender has only proven that the sender had a VMO.
8600    ///
8601    /// - response `buffer_collection_id` This ID is unique per buffer
8602    ///   collection per boot. Each buffer is uniquely identified by the
8603    ///   `buffer_collection_id` and `buffer_index` together.
8604    GetBufferCollectionId { responder: BufferCollectionTokenGroupGetBufferCollectionIdResponder },
8605    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
8606    /// created after this message to weak, which means that a client's `Node`
8607    /// client end (or a child created after this message) is not alone
8608    /// sufficient to keep allocated VMOs alive.
8609    ///
8610    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
8611    /// `close_weak_asap`.
8612    ///
8613    /// This message is only permitted before the `Node` becomes ready for
8614    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
8615    ///   * `BufferCollectionToken`: any time
8616    ///   * `BufferCollection`: before `SetConstraints`
8617    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
8618    ///
8619    /// Currently, no conversion from strong `Node` to weak `Node` after ready
8620    /// for allocation is provided, but a client can simulate that by creating
8621    /// an additional `Node` before allocation and setting that additional
8622    /// `Node` to weak, and then potentially at some point later sending
8623    /// `Release` and closing the client end of the client's strong `Node`, but
8624    /// keeping the client's weak `Node`.
8625    ///
8626    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
8627    /// collection failure (all `Node` client end(s) will see
8628    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
8629    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
8630    /// this situation until all `Node`(s) are ready for allocation. For initial
8631    /// allocation to succeed, at least one strong `Node` is required to exist
8632    /// at allocation time, but after that client receives VMO handles, that
8633    /// client can `BufferCollection.Release` and close the client end without
8634    /// causing this type of failure.
8635    ///
8636    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
8637    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
8638    /// separately as appropriate.
8639    SetWeak { control_handle: BufferCollectionTokenGroupControlHandle },
8640    /// This indicates to sysmem that the client is prepared to pay attention to
8641    /// `close_weak_asap`.
8642    ///
8643    /// If sent, this message must be before
8644    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
8645    ///
8646    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
8647    /// send this message before `WaitForAllBuffersAllocated`, or a parent
8648    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
8649    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
8650    /// trigger buffer collection failure.
8651    ///
8652    /// This message is necessary because weak sysmem VMOs have not always been
8653    /// a thing, so older clients are not aware of the need to pay attention to
8654    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
8655    /// sysmem weak VMO handles asap. By having this message and requiring
8656    /// participants to indicate their acceptance of this aspect of the overall
8657    /// protocol, we avoid situations where an older client is delivered a weak
8658    /// VMO without any way for sysmem to get that VMO to close quickly later
8659    /// (and on a per-buffer basis).
8660    ///
8661    /// A participant that doesn't handle `close_weak_asap` and also doesn't
8662    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
8663    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
8664    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
8665    /// same participant has a child/delegate which does retrieve VMOs, that
8666    /// child/delegate will need to send `SetWeakOk` before
8667    /// `WaitForAllBuffersAllocated`.
8668    ///
8669    /// + request `for_child_nodes_also` If present and true, this means direct
8670    ///   child nodes of this node created after this message plus all
8671    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
8672    ///   those nodes. Any child node of this node that was created before this
8673    ///   message is not included. This setting is "sticky" in the sense that a
8674    ///   subsequent `SetWeakOk` without this bool set to true does not reset
8675    ///   the server-side bool. If this creates a problem for a participant, a
8676    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
8677    ///   tokens instead, as appropriate. A participant should only set
8678    ///   `for_child_nodes_also` true if the participant can really promise to
8679    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
8680    ///   weak VMO handles held by participants holding the corresponding child
8681    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
8682    ///   which are using sysmem(1) can be weak, despite the clients of those
8683    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
8684    ///   direct way to find out about `close_weak_asap`. This only applies to
8685    ///   descendents of this `Node` which are using sysmem(1), not to this
8686    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
8687    ///   token, which will fail allocation unless an ancestor of this `Node`
8688    ///   specified `for_child_nodes_also` true.
8689    SetWeakOk {
8690        payload: NodeSetWeakOkRequest,
8691        control_handle: BufferCollectionTokenGroupControlHandle,
8692    },
8693    /// The server_end will be closed after this `Node` and any child nodes have
8694    /// have released their buffer counts, making those counts available for
8695    /// reservation by a different `Node` via
8696    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
8697    ///
8698    /// The `Node` buffer counts may not be released until the entire tree of
8699    /// `Node`(s) is closed or failed, because
8700    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
8701    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
8702    /// `Node` buffer counts remain reserved until the orphaned node is later
8703    /// cleaned up.
8704    ///
8705    /// If the `Node` exceeds a fairly large number of attached eventpair server
8706    /// ends, a log message will indicate this and the `Node` (and the
8707    /// appropriate) sub-tree will fail.
8708    ///
8709    /// The `server_end` will remain open when
8710    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
8711    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
8712    /// [`fuchsia.sysmem2/BufferCollection`].
8713    ///
8714    /// This message can also be used with a
8715    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
8716    AttachNodeTracking {
8717        payload: NodeAttachNodeTrackingRequest,
8718        control_handle: BufferCollectionTokenGroupControlHandle,
8719    },
8720    /// Create a child [`fuchsia.sysmem2/BufferCollectionToken`]. Only one child
8721    /// (including its children) will be selected during allocation (or logical
8722    /// allocation).
8723    ///
8724    /// Before passing the client end of this token to
8725    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], completion of
8726    /// [`fuchsia.sysmem2/Node.Sync`] after
8727    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] is required.
8728    /// Or the client can use
8729    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`] which
8730    /// essentially includes the `Sync`.
8731    ///
8732    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
8733    /// fail the group's subtree and close the connection.
8734    ///
8735    /// After all children have been created, send AllChildrenPresent.
8736    ///
8737    /// + request `token_request` The server end of the new token channel.
8738    /// + request `rights_attenuation_mask` If ZX_RIGHT_SAME_RIGHTS, the created
8739    ///   token allows the holder to get the same rights to buffers as the
8740    ///   parent token (of the group) had. When the value isn't
8741    ///   ZX_RIGHT_SAME_RIGHTS, the value is interpretted as a bitmask with 0
8742    ///   bits ensuring those rights are attentuated, so 0xFFFFFFFF is a synonym
8743    ///   for ZX_RIGHT_SAME_RIGHTS. The value 0 is not allowed and intentionally
8744    ///   causes subtree failure.
8745    CreateChild {
8746        payload: BufferCollectionTokenGroupCreateChildRequest,
8747        control_handle: BufferCollectionTokenGroupControlHandle,
8748    },
8749    /// Create 1 or more child tokens at once, synchronously.  In contrast to
8750    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`], no
8751    /// [`fuchsia.sysmem2/Node.Sync`] is required before passing the client end
8752    /// of a returned token to
8753    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`].
8754    ///
8755    /// The lower-index child tokens are higher priority (attempted sooner) than
8756    /// higher-index child tokens.
8757    ///
8758    /// As per all child tokens, successful aggregation will choose exactly one
8759    /// child among all created children (across all children created across
8760    /// potentially multiple calls to
8761    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] and
8762    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`]).
8763    ///
8764    /// The maximum permissible total number of children per group, and total
8765    /// number of nodes in an overall tree (from the root) are capped to limits
8766    /// which are not configurable via these protocols.
8767    ///
8768    /// Sending CreateChildrenSync after AllChildrenPresent is not permitted;
8769    /// this will fail the group's subtree and close the connection.
8770    ///
8771    /// After all children have been created, send AllChildrenPresent.
8772    ///
8773    /// + request `rights_attentuation_masks` The size of the
8774    ///   `rights_attentuation_masks` determines the number of created child
8775    ///   tokens. The value ZX_RIGHT_SAME_RIGHTS doesn't attenuate any rights.
8776    ///   The value 0xFFFFFFFF is a synonym for ZX_RIGHT_SAME_RIGHTS. For any
8777    ///   other value, each 0 bit in the mask attenuates that right.
8778    /// - response `tokens` The created child tokens.
8779    CreateChildrenSync {
8780        payload: BufferCollectionTokenGroupCreateChildrenSyncRequest,
8781        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
8782    },
8783    /// Indicate that no more children will be created.
8784    ///
8785    /// After creating all children, the client should send
8786    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent`] to
8787    /// inform sysmem that no more children will be created, so that sysmem can
8788    /// know when it's ok to start aggregating constraints.
8789    ///
8790    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
8791    /// fail the group's subtree and close the connection.
8792    ///
8793    /// If [`fuchsia.sysmem2/Node.Release`] is to be sent, it should be sent
8794    /// after `AllChildrenPresent`, else failure of the group's subtree will be
8795    /// triggered. This is intentionally not analogous to how `Release` without
8796    /// prior [`fuchsia.sysmem2/BufferCollection.SetConstraints`] doesn't cause
8797    /// subtree failure.
8798    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
8799    /// An interaction was received which does not match any known method.
8800    #[non_exhaustive]
8801    _UnknownMethod {
8802        /// Ordinal of the method that was called.
8803        ordinal: u64,
8804        control_handle: BufferCollectionTokenGroupControlHandle,
8805        method_type: fidl::MethodType,
8806    },
8807}
8808
8809impl BufferCollectionTokenGroupRequest {
8810    #[allow(irrefutable_let_patterns)]
8811    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
8812        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
8813            Some((responder))
8814        } else {
8815            None
8816        }
8817    }
8818
8819    #[allow(irrefutable_let_patterns)]
8820    pub fn into_release(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8821        if let BufferCollectionTokenGroupRequest::Release { control_handle } = self {
8822            Some((control_handle))
8823        } else {
8824            None
8825        }
8826    }
8827
8828    #[allow(irrefutable_let_patterns)]
8829    pub fn into_set_name(
8830        self,
8831    ) -> Option<(NodeSetNameRequest, BufferCollectionTokenGroupControlHandle)> {
8832        if let BufferCollectionTokenGroupRequest::SetName { payload, control_handle } = self {
8833            Some((payload, control_handle))
8834        } else {
8835            None
8836        }
8837    }
8838
8839    #[allow(irrefutable_let_patterns)]
8840    pub fn into_set_debug_client_info(
8841        self,
8842    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionTokenGroupControlHandle)> {
8843        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { payload, control_handle } =
8844            self
8845        {
8846            Some((payload, control_handle))
8847        } else {
8848            None
8849        }
8850    }
8851
8852    #[allow(irrefutable_let_patterns)]
8853    pub fn into_set_debug_timeout_log_deadline(
8854        self,
8855    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionTokenGroupControlHandle)>
8856    {
8857        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
8858            payload,
8859            control_handle,
8860        } = self
8861        {
8862            Some((payload, control_handle))
8863        } else {
8864            None
8865        }
8866    }
8867
8868    #[allow(irrefutable_let_patterns)]
8869    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8870        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
8871            Some((control_handle))
8872        } else {
8873            None
8874        }
8875    }
8876
8877    #[allow(irrefutable_let_patterns)]
8878    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
8879        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
8880            Some((responder))
8881        } else {
8882            None
8883        }
8884    }
8885
8886    #[allow(irrefutable_let_patterns)]
8887    pub fn into_is_alternate_for(
8888        self,
8889    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionTokenGroupIsAlternateForResponder)>
8890    {
8891        if let BufferCollectionTokenGroupRequest::IsAlternateFor { payload, responder } = self {
8892            Some((payload, responder))
8893        } else {
8894            None
8895        }
8896    }
8897
8898    #[allow(irrefutable_let_patterns)]
8899    pub fn into_get_buffer_collection_id(
8900        self,
8901    ) -> Option<(BufferCollectionTokenGroupGetBufferCollectionIdResponder)> {
8902        if let BufferCollectionTokenGroupRequest::GetBufferCollectionId { responder } = self {
8903            Some((responder))
8904        } else {
8905            None
8906        }
8907    }
8908
8909    #[allow(irrefutable_let_patterns)]
8910    pub fn into_set_weak(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8911        if let BufferCollectionTokenGroupRequest::SetWeak { control_handle } = self {
8912            Some((control_handle))
8913        } else {
8914            None
8915        }
8916    }
8917
8918    #[allow(irrefutable_let_patterns)]
8919    pub fn into_set_weak_ok(
8920        self,
8921    ) -> Option<(NodeSetWeakOkRequest, BufferCollectionTokenGroupControlHandle)> {
8922        if let BufferCollectionTokenGroupRequest::SetWeakOk { payload, control_handle } = self {
8923            Some((payload, control_handle))
8924        } else {
8925            None
8926        }
8927    }
8928
8929    #[allow(irrefutable_let_patterns)]
8930    pub fn into_attach_node_tracking(
8931        self,
8932    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionTokenGroupControlHandle)> {
8933        if let BufferCollectionTokenGroupRequest::AttachNodeTracking { payload, control_handle } =
8934            self
8935        {
8936            Some((payload, control_handle))
8937        } else {
8938            None
8939        }
8940    }
8941
8942    #[allow(irrefutable_let_patterns)]
8943    pub fn into_create_child(
8944        self,
8945    ) -> Option<(
8946        BufferCollectionTokenGroupCreateChildRequest,
8947        BufferCollectionTokenGroupControlHandle,
8948    )> {
8949        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
8950            Some((payload, control_handle))
8951        } else {
8952            None
8953        }
8954    }
8955
8956    #[allow(irrefutable_let_patterns)]
8957    pub fn into_create_children_sync(
8958        self,
8959    ) -> Option<(
8960        BufferCollectionTokenGroupCreateChildrenSyncRequest,
8961        BufferCollectionTokenGroupCreateChildrenSyncResponder,
8962    )> {
8963        if let BufferCollectionTokenGroupRequest::CreateChildrenSync { payload, responder } = self {
8964            Some((payload, responder))
8965        } else {
8966            None
8967        }
8968    }
8969
8970    #[allow(irrefutable_let_patterns)]
8971    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
8972        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
8973            Some((control_handle))
8974        } else {
8975            None
8976        }
8977    }
8978
8979    /// Name of the method defined in FIDL
8980    pub fn method_name(&self) -> &'static str {
8981        match *self {
8982            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
8983            BufferCollectionTokenGroupRequest::Release { .. } => "release",
8984            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
8985            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
8986            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
8987                "set_debug_timeout_log_deadline"
8988            }
8989            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
8990            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
8991            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
8992            BufferCollectionTokenGroupRequest::GetBufferCollectionId { .. } => {
8993                "get_buffer_collection_id"
8994            }
8995            BufferCollectionTokenGroupRequest::SetWeak { .. } => "set_weak",
8996            BufferCollectionTokenGroupRequest::SetWeakOk { .. } => "set_weak_ok",
8997            BufferCollectionTokenGroupRequest::AttachNodeTracking { .. } => "attach_node_tracking",
8998            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
8999            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
9000            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
9001            BufferCollectionTokenGroupRequest::_UnknownMethod {
9002                method_type: fidl::MethodType::OneWay,
9003                ..
9004            } => "unknown one-way method",
9005            BufferCollectionTokenGroupRequest::_UnknownMethod {
9006                method_type: fidl::MethodType::TwoWay,
9007                ..
9008            } => "unknown two-way method",
9009        }
9010    }
9011}
9012
9013#[derive(Debug, Clone)]
9014pub struct BufferCollectionTokenGroupControlHandle {
9015    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9016}
9017
9018impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenGroupControlHandle {
9019    fn shutdown(&self) {
9020        self.inner.shutdown()
9021    }
9022
9023    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9024        self.inner.shutdown_with_epitaph(status)
9025    }
9026
9027    fn is_closed(&self) -> bool {
9028        self.inner.channel().is_closed()
9029    }
9030    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9031        self.inner.channel().on_closed()
9032    }
9033}
9034
9035impl BufferCollectionTokenGroupControlHandle {}
9036
9037#[must_use = "FIDL methods require a response to be sent"]
9038#[derive(Debug)]
9039pub struct BufferCollectionTokenGroupSyncResponder {
9040    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9041    tx_id: u32,
9042}
9043
9044/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9045/// if the responder is dropped without sending a response, so that the client
9046/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9047impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
9048    fn drop(&mut self) {
9049        self.control_handle.shutdown();
9050        // Safety: drops once, never accessed again
9051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9052    }
9053}
9054
9055impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupSyncResponder {
9056    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9057
9058    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9059        &self.control_handle
9060    }
9061
9062    fn drop_without_shutdown(mut self) {
9063        // Safety: drops once, never accessed again due to mem::forget
9064        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9065        // Prevent Drop from running (which would shut down the channel)
9066        std::mem::forget(self);
9067    }
9068}
9069
9070impl BufferCollectionTokenGroupSyncResponder {
9071    /// Sends a response to the FIDL transaction.
9072    ///
9073    /// Sets the channel to shutdown if an error occurs.
9074    pub fn send(self) -> Result<(), fidl::Error> {
9075        let _result = self.send_raw();
9076        if _result.is_err() {
9077            self.control_handle.shutdown();
9078        }
9079        self.drop_without_shutdown();
9080        _result
9081    }
9082
9083    /// Similar to "send" but does not shutdown the channel if an error occurs.
9084    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9085        let _result = self.send_raw();
9086        self.drop_without_shutdown();
9087        _result
9088    }
9089
9090    fn send_raw(&self) -> Result<(), fidl::Error> {
9091        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
9092            fidl::encoding::Flexible::new(()),
9093            self.tx_id,
9094            0x11ac2555cf575b54,
9095            fidl::encoding::DynamicFlags::FLEXIBLE,
9096        )
9097    }
9098}
9099
9100#[must_use = "FIDL methods require a response to be sent"]
9101#[derive(Debug)]
9102pub struct BufferCollectionTokenGroupGetNodeRefResponder {
9103    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9104    tx_id: u32,
9105}
9106
9107/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9108/// if the responder is dropped without sending a response, so that the client
9109/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9110impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
9111    fn drop(&mut self) {
9112        self.control_handle.shutdown();
9113        // Safety: drops once, never accessed again
9114        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9115    }
9116}
9117
9118impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
9119    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9120
9121    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9122        &self.control_handle
9123    }
9124
9125    fn drop_without_shutdown(mut self) {
9126        // Safety: drops once, never accessed again due to mem::forget
9127        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9128        // Prevent Drop from running (which would shut down the channel)
9129        std::mem::forget(self);
9130    }
9131}
9132
9133impl BufferCollectionTokenGroupGetNodeRefResponder {
9134    /// Sends a response to the FIDL transaction.
9135    ///
9136    /// Sets the channel to shutdown if an error occurs.
9137    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
9138        let _result = self.send_raw(payload);
9139        if _result.is_err() {
9140            self.control_handle.shutdown();
9141        }
9142        self.drop_without_shutdown();
9143        _result
9144    }
9145
9146    /// Similar to "send" but does not shutdown the channel if an error occurs.
9147    pub fn send_no_shutdown_on_err(
9148        self,
9149        mut payload: NodeGetNodeRefResponse,
9150    ) -> Result<(), fidl::Error> {
9151        let _result = self.send_raw(payload);
9152        self.drop_without_shutdown();
9153        _result
9154    }
9155
9156    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
9157        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
9158            fidl::encoding::Flexible::new(&mut payload),
9159            self.tx_id,
9160            0x5b3d0e51614df053,
9161            fidl::encoding::DynamicFlags::FLEXIBLE,
9162        )
9163    }
9164}
9165
9166#[must_use = "FIDL methods require a response to be sent"]
9167#[derive(Debug)]
9168pub struct BufferCollectionTokenGroupIsAlternateForResponder {
9169    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9170    tx_id: u32,
9171}
9172
9173/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9174/// if the responder is dropped without sending a response, so that the client
9175/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9176impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
9177    fn drop(&mut self) {
9178        self.control_handle.shutdown();
9179        // Safety: drops once, never accessed again
9180        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9181    }
9182}
9183
9184impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
9185    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9186
9187    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9188        &self.control_handle
9189    }
9190
9191    fn drop_without_shutdown(mut self) {
9192        // Safety: drops once, never accessed again due to mem::forget
9193        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9194        // Prevent Drop from running (which would shut down the channel)
9195        std::mem::forget(self);
9196    }
9197}
9198
9199impl BufferCollectionTokenGroupIsAlternateForResponder {
9200    /// Sends a response to the FIDL transaction.
9201    ///
9202    /// Sets the channel to shutdown if an error occurs.
9203    pub fn send(
9204        self,
9205        mut result: Result<&NodeIsAlternateForResponse, Error>,
9206    ) -> Result<(), fidl::Error> {
9207        let _result = self.send_raw(result);
9208        if _result.is_err() {
9209            self.control_handle.shutdown();
9210        }
9211        self.drop_without_shutdown();
9212        _result
9213    }
9214
9215    /// Similar to "send" but does not shutdown the channel if an error occurs.
9216    pub fn send_no_shutdown_on_err(
9217        self,
9218        mut result: Result<&NodeIsAlternateForResponse, Error>,
9219    ) -> Result<(), fidl::Error> {
9220        let _result = self.send_raw(result);
9221        self.drop_without_shutdown();
9222        _result
9223    }
9224
9225    fn send_raw(
9226        &self,
9227        mut result: Result<&NodeIsAlternateForResponse, Error>,
9228    ) -> Result<(), fidl::Error> {
9229        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
9230            NodeIsAlternateForResponse,
9231            Error,
9232        >>(
9233            fidl::encoding::FlexibleResult::new(result),
9234            self.tx_id,
9235            0x3a58e00157e0825,
9236            fidl::encoding::DynamicFlags::FLEXIBLE,
9237        )
9238    }
9239}
9240
9241#[must_use = "FIDL methods require a response to be sent"]
9242#[derive(Debug)]
9243pub struct BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9244    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9245    tx_id: u32,
9246}
9247
9248/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9249/// if the responder is dropped without sending a response, so that the client
9250/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9251impl std::ops::Drop for BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9252    fn drop(&mut self) {
9253        self.control_handle.shutdown();
9254        // Safety: drops once, never accessed again
9255        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9256    }
9257}
9258
9259impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9260    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9261
9262    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9263        &self.control_handle
9264    }
9265
9266    fn drop_without_shutdown(mut self) {
9267        // Safety: drops once, never accessed again due to mem::forget
9268        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9269        // Prevent Drop from running (which would shut down the channel)
9270        std::mem::forget(self);
9271    }
9272}
9273
9274impl BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9275    /// Sends a response to the FIDL transaction.
9276    ///
9277    /// Sets the channel to shutdown if an error occurs.
9278    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
9279        let _result = self.send_raw(payload);
9280        if _result.is_err() {
9281            self.control_handle.shutdown();
9282        }
9283        self.drop_without_shutdown();
9284        _result
9285    }
9286
9287    /// Similar to "send" but does not shutdown the channel if an error occurs.
9288    pub fn send_no_shutdown_on_err(
9289        self,
9290        mut payload: &NodeGetBufferCollectionIdResponse,
9291    ) -> Result<(), fidl::Error> {
9292        let _result = self.send_raw(payload);
9293        self.drop_without_shutdown();
9294        _result
9295    }
9296
9297    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
9298        self.control_handle
9299            .inner
9300            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
9301                fidl::encoding::Flexible::new(payload),
9302                self.tx_id,
9303                0x77d19a494b78ba8c,
9304                fidl::encoding::DynamicFlags::FLEXIBLE,
9305            )
9306    }
9307}
9308
9309#[must_use = "FIDL methods require a response to be sent"]
9310#[derive(Debug)]
9311pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
9312    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9313    tx_id: u32,
9314}
9315
9316/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9317/// if the responder is dropped without sending a response, so that the client
9318/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9319impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
9320    fn drop(&mut self) {
9321        self.control_handle.shutdown();
9322        // Safety: drops once, never accessed again
9323        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9324    }
9325}
9326
9327impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
9328    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9329
9330    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9331        &self.control_handle
9332    }
9333
9334    fn drop_without_shutdown(mut self) {
9335        // Safety: drops once, never accessed again due to mem::forget
9336        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9337        // Prevent Drop from running (which would shut down the channel)
9338        std::mem::forget(self);
9339    }
9340}
9341
9342impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
9343    /// Sends a response to the FIDL transaction.
9344    ///
9345    /// Sets the channel to shutdown if an error occurs.
9346    pub fn send(
9347        self,
9348        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9349    ) -> Result<(), fidl::Error> {
9350        let _result = self.send_raw(payload);
9351        if _result.is_err() {
9352            self.control_handle.shutdown();
9353        }
9354        self.drop_without_shutdown();
9355        _result
9356    }
9357
9358    /// Similar to "send" but does not shutdown the channel if an error occurs.
9359    pub fn send_no_shutdown_on_err(
9360        self,
9361        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9362    ) -> Result<(), fidl::Error> {
9363        let _result = self.send_raw(payload);
9364        self.drop_without_shutdown();
9365        _result
9366    }
9367
9368    fn send_raw(
9369        &self,
9370        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9371    ) -> Result<(), fidl::Error> {
9372        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
9373            BufferCollectionTokenGroupCreateChildrenSyncResponse,
9374        >>(
9375            fidl::encoding::Flexible::new(&mut payload),
9376            self.tx_id,
9377            0x15dea448c536070a,
9378            fidl::encoding::DynamicFlags::FLEXIBLE,
9379        )
9380    }
9381}
9382
9383#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9384pub struct NodeMarker;
9385
9386impl fdomain_client::fidl::ProtocolMarker for NodeMarker {
9387    type Proxy = NodeProxy;
9388    type RequestStream = NodeRequestStream;
9389
9390    const DEBUG_NAME: &'static str = "(anonymous) Node";
9391}
9392pub type NodeIsAlternateForResult = Result<NodeIsAlternateForResponse, Error>;
9393
9394pub trait NodeProxyInterface: Send + Sync {
9395    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9396    fn r#sync(&self) -> Self::SyncResponseFut;
9397    fn r#release(&self) -> Result<(), fidl::Error>;
9398    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
9399    fn r#set_debug_client_info(
9400        &self,
9401        payload: &NodeSetDebugClientInfoRequest,
9402    ) -> Result<(), fidl::Error>;
9403    fn r#set_debug_timeout_log_deadline(
9404        &self,
9405        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9406    ) -> Result<(), fidl::Error>;
9407    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
9408    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
9409        + Send;
9410    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
9411    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
9412        + Send;
9413    fn r#is_alternate_for(
9414        &self,
9415        payload: NodeIsAlternateForRequest,
9416    ) -> Self::IsAlternateForResponseFut;
9417    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
9418        + Send;
9419    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
9420    fn r#set_weak(&self) -> Result<(), fidl::Error>;
9421    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
9422    fn r#attach_node_tracking(
9423        &self,
9424        payload: NodeAttachNodeTrackingRequest,
9425    ) -> Result<(), fidl::Error>;
9426}
9427
9428#[derive(Debug, Clone)]
9429pub struct NodeProxy {
9430    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9431}
9432
9433impl fdomain_client::fidl::Proxy for NodeProxy {
9434    type Protocol = NodeMarker;
9435
9436    fn from_channel(inner: fdomain_client::Channel) -> Self {
9437        Self::new(inner)
9438    }
9439
9440    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9441        self.client.into_channel().map_err(|client| Self { client })
9442    }
9443
9444    fn as_channel(&self) -> &fdomain_client::Channel {
9445        self.client.as_channel()
9446    }
9447}
9448
9449impl NodeProxy {
9450    /// Create a new Proxy for fuchsia.sysmem2/Node.
9451    pub fn new(channel: fdomain_client::Channel) -> Self {
9452        let protocol_name = <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9453        Self { client: fidl::client::Client::new(channel, protocol_name) }
9454    }
9455
9456    /// Get a Stream of events from the remote end of the protocol.
9457    ///
9458    /// # Panics
9459    ///
9460    /// Panics if the event stream was already taken.
9461    pub fn take_event_stream(&self) -> NodeEventStream {
9462        NodeEventStream { event_receiver: self.client.take_event_receiver() }
9463    }
9464
9465    /// Ensure that previous messages have been received server side. This is
9466    /// particularly useful after previous messages that created new tokens,
9467    /// because a token must be known to the sysmem server before sending the
9468    /// token to another participant.
9469    ///
9470    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
9471    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
9472    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
9473    /// to mitigate the possibility of a hostile/fake
9474    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
9475    /// Another way is to pass the token to
9476    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
9477    /// the token as part of exchanging it for a
9478    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
9479    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
9480    /// of stalling.
9481    ///
9482    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
9483    /// and then starting and completing a `Sync`, it's then safe to send the
9484    /// `BufferCollectionToken` client ends to other participants knowing the
9485    /// server will recognize the tokens when they're sent by the other
9486    /// participants to sysmem in a
9487    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
9488    /// efficient way to create tokens while avoiding unnecessary round trips.
9489    ///
9490    /// Other options include waiting for each
9491    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
9492    /// individually (using separate call to `Sync` after each), or calling
9493    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
9494    /// converted to a `BufferCollection` via
9495    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
9496    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
9497    /// the sync step and can create multiple tokens at once.
9498    pub fn r#sync(
9499        &self,
9500    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9501        NodeProxyInterface::r#sync(self)
9502    }
9503
9504    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
9505    ///
9506    /// Normally a participant will convert a `BufferCollectionToken` into a
9507    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
9508    /// `Release` via the token (and then close the channel immediately or
9509    /// shortly later in response to server closing the server end), which
9510    /// avoids causing buffer collection failure. Without a prior `Release`,
9511    /// closing the `BufferCollectionToken` client end will cause buffer
9512    /// collection failure.
9513    ///
9514    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
9515    ///
9516    /// By default the server handles unexpected closure of a
9517    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
9518    /// first) by failing the buffer collection. Partly this is to expedite
9519    /// closing VMO handles to reclaim memory when any participant fails. If a
9520    /// participant would like to cleanly close a `BufferCollection` without
9521    /// causing buffer collection failure, the participant can send `Release`
9522    /// before closing the `BufferCollection` client end. The `Release` can
9523    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
9524    /// buffer collection won't require constraints from this node in order to
9525    /// allocate. If after `SetConstraints`, the constraints are retained and
9526    /// aggregated, despite the lack of `BufferCollection` connection at the
9527    /// time of constraints aggregation.
9528    ///
9529    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
9530    ///
9531    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
9532    /// end (without `Release` first) will trigger failure of the buffer
9533    /// collection. To close a `BufferCollectionTokenGroup` channel without
9534    /// failing the buffer collection, ensure that AllChildrenPresent() has been
9535    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
9536    /// client end.
9537    ///
9538    /// If `Release` occurs before
9539    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
9540    /// buffer collection will fail (triggered by reception of `Release` without
9541    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
9542    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
9543    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
9544    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
9545    /// close requires `AllChildrenPresent` (if not already sent), then
9546    /// `Release`, then close client end.
9547    ///
9548    /// If `Release` occurs after `AllChildrenPresent`, the children and all
9549    /// their constraints remain intact (just as they would if the
9550    /// `BufferCollectionTokenGroup` channel had remained open), and the client
9551    /// end close doesn't trigger buffer collection failure.
9552    ///
9553    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
9554    ///
9555    /// For brevity, the per-channel-protocol paragraphs above ignore the
9556    /// separate failure domain created by
9557    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
9558    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
9559    /// unexpectedly closes (without `Release` first) and that client end is
9560    /// under a failure domain, instead of failing the whole buffer collection,
9561    /// the failure domain is failed, but the buffer collection itself is
9562    /// isolated from failure of the failure domain. Such failure domains can be
9563    /// nested, in which case only the inner-most failure domain in which the
9564    /// `Node` resides fails.
9565    pub fn r#release(&self) -> Result<(), fidl::Error> {
9566        NodeProxyInterface::r#release(self)
9567    }
9568
9569    /// Set a name for VMOs in this buffer collection.
9570    ///
9571    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
9572    /// will be truncated to fit. The name of the vmo will be suffixed with the
9573    /// buffer index within the collection (if the suffix fits within
9574    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
9575    /// listed in the inspect data.
9576    ///
9577    /// The name only affects VMOs allocated after the name is set; this call
9578    /// does not rename existing VMOs. If multiple clients set different names
9579    /// then the larger priority value will win. Setting a new name with the
9580    /// same priority as a prior name doesn't change the name.
9581    ///
9582    /// All table fields are currently required.
9583    ///
9584    /// + request `priority` The name is only set if this is the first `SetName`
9585    ///   or if `priority` is greater than any previous `priority` value in
9586    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
9587    /// + request `name` The name for VMOs created under this buffer collection.
9588    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
9589        NodeProxyInterface::r#set_name(self, payload)
9590    }
9591
9592    /// Set information about the current client that can be used by sysmem to
9593    /// help diagnose leaking memory and allocation stalls waiting for a
9594    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
9595    ///
9596    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
9597    /// `Node`(s) derived from this `Node`, unless overriden by
9598    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
9599    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
9600    ///
9601    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
9602    /// `Allocator` is the most efficient way to ensure that all
9603    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
9604    /// set, and is also more efficient than separately sending the same debug
9605    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
9606    /// created [`fuchsia.sysmem2/Node`].
9607    ///
9608    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
9609    /// indicate which client is closing their channel first, leading to subtree
9610    /// failure (which can be normal if the purpose of the subtree is over, but
9611    /// if happening earlier than expected, the client-channel-specific name can
9612    /// help diagnose where the failure is first coming from, from sysmem's
9613    /// point of view).
9614    ///
9615    /// All table fields are currently required.
9616    ///
9617    /// + request `name` This can be an arbitrary string, but the current
9618    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
9619    /// + request `id` This can be an arbitrary id, but the current process ID
9620    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
9621    pub fn r#set_debug_client_info(
9622        &self,
9623        mut payload: &NodeSetDebugClientInfoRequest,
9624    ) -> Result<(), fidl::Error> {
9625        NodeProxyInterface::r#set_debug_client_info(self, payload)
9626    }
9627
9628    /// Sysmem logs a warning if sysmem hasn't seen
9629    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
9630    /// within 5 seconds after creation of a new collection.
9631    ///
9632    /// Clients can call this method to change when the log is printed. If
9633    /// multiple client set the deadline, it's unspecified which deadline will
9634    /// take effect.
9635    ///
9636    /// In most cases the default works well.
9637    ///
9638    /// All table fields are currently required.
9639    ///
9640    /// + request `deadline` The time at which sysmem will start trying to log
9641    ///   the warning, unless all constraints are with sysmem by then.
9642    pub fn r#set_debug_timeout_log_deadline(
9643        &self,
9644        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9645    ) -> Result<(), fidl::Error> {
9646        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
9647    }
9648
9649    /// This enables verbose logging for the buffer collection.
9650    ///
9651    /// Verbose logging includes constraints set via
9652    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
9653    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
9654    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
9655    /// the tree of `Node`(s).
9656    ///
9657    /// Normally sysmem prints only a single line complaint when aggregation
9658    /// fails, with just the specific detailed reason that aggregation failed,
9659    /// with little surrounding context.  While this is often enough to diagnose
9660    /// a problem if only a small change was made and everything was working
9661    /// before the small change, it's often not particularly helpful for getting
9662    /// a new buffer collection to work for the first time.  Especially with
9663    /// more complex trees of nodes, involving things like
9664    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
9665    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
9666    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
9667    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
9668    /// looks like and why it's failing a logical allocation, or why a tree or
9669    /// subtree is failing sooner than expected.
9670    ///
9671    /// The intent of the extra logging is to be acceptable from a performance
9672    /// point of view, under the assumption that verbose logging is only enabled
9673    /// on a low number of buffer collections. If we're not tracking down a bug,
9674    /// we shouldn't send this message.
9675    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9676        NodeProxyInterface::r#set_verbose_logging(self)
9677    }
9678
9679    /// This gets a handle that can be used as a parameter to
9680    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
9681    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
9682    /// client obtained this handle from this `Node`.
9683    ///
9684    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
9685    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
9686    /// despite the two calls typically being on different channels.
9687    ///
9688    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
9689    ///
9690    /// All table fields are currently required.
9691    ///
9692    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
9693    ///   different `Node` channel, to prove that the client obtained the handle
9694    ///   from this `Node`.
9695    pub fn r#get_node_ref(
9696        &self,
9697    ) -> fidl::client::QueryResponseFut<
9698        NodeGetNodeRefResponse,
9699        fdomain_client::fidl::FDomainResourceDialect,
9700    > {
9701        NodeProxyInterface::r#get_node_ref(self)
9702    }
9703
9704    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
9705    /// rooted at a different child token of a common parent
9706    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
9707    /// passed-in `node_ref`.
9708    ///
9709    /// This call is for assisting with admission control de-duplication, and
9710    /// with debugging.
9711    ///
9712    /// The `node_ref` must be obtained using
9713    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
9714    ///
9715    /// The `node_ref` can be a duplicated handle; it's not necessary to call
9716    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
9717    ///
9718    /// If a calling token may not actually be a valid token at all due to a
9719    /// potentially hostile/untrusted provider of the token, call
9720    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
9721    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
9722    /// never responds due to a calling token not being a real token (not really
9723    /// talking to sysmem).  Another option is to call
9724    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
9725    /// which also validates the token along with converting it to a
9726    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
9727    ///
9728    /// All table fields are currently required.
9729    ///
9730    /// - response `is_alternate`
9731    ///   - true: The first parent node in common between the calling node and
9732    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
9733    ///     that the calling `Node` and the `node_ref` `Node` will not have both
9734    ///     their constraints apply - rather sysmem will choose one or the other
9735    ///     of the constraints - never both.  This is because only one child of
9736    ///     a `BufferCollectionTokenGroup` is selected during logical
9737    ///     allocation, with only that one child's subtree contributing to
9738    ///     constraints aggregation.
9739    ///   - false: The first parent node in common between the calling `Node`
9740    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
9741    ///     Currently, this means the first parent node in common is a
9742    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
9743    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
9744    ///     `Node` may have both their constraints apply during constraints
9745    ///     aggregation of the logical allocation, if both `Node`(s) are
9746    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
9747    ///     this case, there is no `BufferCollectionTokenGroup` that will
9748    ///     directly prevent the two `Node`(s) from both being selected and
9749    ///     their constraints both aggregated, but even when false, one or both
9750    ///     `Node`(s) may still be eliminated from consideration if one or both
9751    ///     `Node`(s) has a direct or indirect parent
9752    ///     `BufferCollectionTokenGroup` which selects a child subtree other
9753    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
9754    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
9755    ///   associated with the same buffer collection as the calling `Node`.
9756    ///   Another reason for this error is if the `node_ref` is an
9757    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
9758    ///   a real `node_ref` obtained from `GetNodeRef`.
9759    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
9760    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
9761    ///   the needed rights expected on a real `node_ref`.
9762    /// * No other failing status codes are returned by this call.  However,
9763    ///   sysmem may add additional codes in future, so the client should have
9764    ///   sensible default handling for any failing status code.
9765    pub fn r#is_alternate_for(
9766        &self,
9767        mut payload: NodeIsAlternateForRequest,
9768    ) -> fidl::client::QueryResponseFut<
9769        NodeIsAlternateForResult,
9770        fdomain_client::fidl::FDomainResourceDialect,
9771    > {
9772        NodeProxyInterface::r#is_alternate_for(self, payload)
9773    }
9774
9775    /// Get the buffer collection ID. This ID is also available from
9776    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
9777    /// within the collection).
9778    ///
9779    /// This call is mainly useful in situations where we can't convey a
9780    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
9781    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
9782    /// handle, which can be joined back up with a `BufferCollection` client end
9783    /// that was created via a different path. Prefer to convey a
9784    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
9785    ///
9786    /// Trusting a `buffer_collection_id` value from a source other than sysmem
9787    /// is analogous to trusting a koid value from a source other than zircon.
9788    /// Both should be avoided unless really necessary, and both require
9789    /// caution. In some situations it may be reasonable to refer to a
9790    /// pre-established `BufferCollection` by `buffer_collection_id` via a
9791    /// protocol for efficiency reasons, but an incoming value purporting to be
9792    /// a `buffer_collection_id` is not sufficient alone to justify granting the
9793    /// sender of the `buffer_collection_id` any capability. The sender must
9794    /// first prove to a receiver that the sender has/had a VMO or has/had a
9795    /// `BufferCollectionToken` to the same collection by sending a handle that
9796    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
9797    /// `buffer_collection_id` value. The receiver should take care to avoid
9798    /// assuming that a sender had a `BufferCollectionToken` in cases where the
9799    /// sender has only proven that the sender had a VMO.
9800    ///
9801    /// - response `buffer_collection_id` This ID is unique per buffer
9802    ///   collection per boot. Each buffer is uniquely identified by the
9803    ///   `buffer_collection_id` and `buffer_index` together.
9804    pub fn r#get_buffer_collection_id(
9805        &self,
9806    ) -> fidl::client::QueryResponseFut<
9807        NodeGetBufferCollectionIdResponse,
9808        fdomain_client::fidl::FDomainResourceDialect,
9809    > {
9810        NodeProxyInterface::r#get_buffer_collection_id(self)
9811    }
9812
9813    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
9814    /// created after this message to weak, which means that a client's `Node`
9815    /// client end (or a child created after this message) is not alone
9816    /// sufficient to keep allocated VMOs alive.
9817    ///
9818    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
9819    /// `close_weak_asap`.
9820    ///
9821    /// This message is only permitted before the `Node` becomes ready for
9822    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
9823    ///   * `BufferCollectionToken`: any time
9824    ///   * `BufferCollection`: before `SetConstraints`
9825    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
9826    ///
9827    /// Currently, no conversion from strong `Node` to weak `Node` after ready
9828    /// for allocation is provided, but a client can simulate that by creating
9829    /// an additional `Node` before allocation and setting that additional
9830    /// `Node` to weak, and then potentially at some point later sending
9831    /// `Release` and closing the client end of the client's strong `Node`, but
9832    /// keeping the client's weak `Node`.
9833    ///
9834    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
9835    /// collection failure (all `Node` client end(s) will see
9836    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
9837    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
9838    /// this situation until all `Node`(s) are ready for allocation. For initial
9839    /// allocation to succeed, at least one strong `Node` is required to exist
9840    /// at allocation time, but after that client receives VMO handles, that
9841    /// client can `BufferCollection.Release` and close the client end without
9842    /// causing this type of failure.
9843    ///
9844    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
9845    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
9846    /// separately as appropriate.
9847    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
9848        NodeProxyInterface::r#set_weak(self)
9849    }
9850
9851    /// This indicates to sysmem that the client is prepared to pay attention to
9852    /// `close_weak_asap`.
9853    ///
9854    /// If sent, this message must be before
9855    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
9856    ///
9857    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
9858    /// send this message before `WaitForAllBuffersAllocated`, or a parent
9859    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
9860    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
9861    /// trigger buffer collection failure.
9862    ///
9863    /// This message is necessary because weak sysmem VMOs have not always been
9864    /// a thing, so older clients are not aware of the need to pay attention to
9865    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
9866    /// sysmem weak VMO handles asap. By having this message and requiring
9867    /// participants to indicate their acceptance of this aspect of the overall
9868    /// protocol, we avoid situations where an older client is delivered a weak
9869    /// VMO without any way for sysmem to get that VMO to close quickly later
9870    /// (and on a per-buffer basis).
9871    ///
9872    /// A participant that doesn't handle `close_weak_asap` and also doesn't
9873    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
9874    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
9875    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
9876    /// same participant has a child/delegate which does retrieve VMOs, that
9877    /// child/delegate will need to send `SetWeakOk` before
9878    /// `WaitForAllBuffersAllocated`.
9879    ///
9880    /// + request `for_child_nodes_also` If present and true, this means direct
9881    ///   child nodes of this node created after this message plus all
9882    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
9883    ///   those nodes. Any child node of this node that was created before this
9884    ///   message is not included. This setting is "sticky" in the sense that a
9885    ///   subsequent `SetWeakOk` without this bool set to true does not reset
9886    ///   the server-side bool. If this creates a problem for a participant, a
9887    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
9888    ///   tokens instead, as appropriate. A participant should only set
9889    ///   `for_child_nodes_also` true if the participant can really promise to
9890    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
9891    ///   weak VMO handles held by participants holding the corresponding child
9892    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
9893    ///   which are using sysmem(1) can be weak, despite the clients of those
9894    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
9895    ///   direct way to find out about `close_weak_asap`. This only applies to
9896    ///   descendents of this `Node` which are using sysmem(1), not to this
9897    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
9898    ///   token, which will fail allocation unless an ancestor of this `Node`
9899    ///   specified `for_child_nodes_also` true.
9900    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
9901        NodeProxyInterface::r#set_weak_ok(self, payload)
9902    }
9903
9904    /// The server_end will be closed after this `Node` and any child nodes have
9905    /// have released their buffer counts, making those counts available for
9906    /// reservation by a different `Node` via
9907    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
9908    ///
9909    /// The `Node` buffer counts may not be released until the entire tree of
9910    /// `Node`(s) is closed or failed, because
9911    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
9912    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
9913    /// `Node` buffer counts remain reserved until the orphaned node is later
9914    /// cleaned up.
9915    ///
9916    /// If the `Node` exceeds a fairly large number of attached eventpair server
9917    /// ends, a log message will indicate this and the `Node` (and the
9918    /// appropriate) sub-tree will fail.
9919    ///
9920    /// The `server_end` will remain open when
9921    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
9922    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
9923    /// [`fuchsia.sysmem2/BufferCollection`].
9924    ///
9925    /// This message can also be used with a
9926    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
9927    pub fn r#attach_node_tracking(
9928        &self,
9929        mut payload: NodeAttachNodeTrackingRequest,
9930    ) -> Result<(), fidl::Error> {
9931        NodeProxyInterface::r#attach_node_tracking(self, payload)
9932    }
9933}
9934
9935impl NodeProxyInterface for NodeProxy {
9936    type SyncResponseFut =
9937        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9938    fn r#sync(&self) -> Self::SyncResponseFut {
9939        fn _decode(
9940            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9941        ) -> Result<(), fidl::Error> {
9942            let _response = fidl::client::decode_transaction_body::<
9943                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
9944                fdomain_client::fidl::FDomainResourceDialect,
9945                0x11ac2555cf575b54,
9946            >(_buf?)?
9947            .into_result_fdomain::<NodeMarker>("sync")?;
9948            Ok(_response)
9949        }
9950        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9951            (),
9952            0x11ac2555cf575b54,
9953            fidl::encoding::DynamicFlags::FLEXIBLE,
9954            _decode,
9955        )
9956    }
9957
9958    fn r#release(&self) -> Result<(), fidl::Error> {
9959        self.client.send::<fidl::encoding::EmptyPayload>(
9960            (),
9961            0x6a5cae7d6d6e04c6,
9962            fidl::encoding::DynamicFlags::FLEXIBLE,
9963        )
9964    }
9965
9966    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
9967        self.client.send::<NodeSetNameRequest>(
9968            payload,
9969            0xb41f1624f48c1e9,
9970            fidl::encoding::DynamicFlags::FLEXIBLE,
9971        )
9972    }
9973
9974    fn r#set_debug_client_info(
9975        &self,
9976        mut payload: &NodeSetDebugClientInfoRequest,
9977    ) -> Result<(), fidl::Error> {
9978        self.client.send::<NodeSetDebugClientInfoRequest>(
9979            payload,
9980            0x5cde8914608d99b1,
9981            fidl::encoding::DynamicFlags::FLEXIBLE,
9982        )
9983    }
9984
9985    fn r#set_debug_timeout_log_deadline(
9986        &self,
9987        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9988    ) -> Result<(), fidl::Error> {
9989        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
9990            payload,
9991            0x716b0af13d5c0806,
9992            fidl::encoding::DynamicFlags::FLEXIBLE,
9993        )
9994    }
9995
9996    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9997        self.client.send::<fidl::encoding::EmptyPayload>(
9998            (),
9999            0x5209c77415b4dfad,
10000            fidl::encoding::DynamicFlags::FLEXIBLE,
10001        )
10002    }
10003
10004    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
10005        NodeGetNodeRefResponse,
10006        fdomain_client::fidl::FDomainResourceDialect,
10007    >;
10008    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
10009        fn _decode(
10010            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10011        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
10012            let _response = fidl::client::decode_transaction_body::<
10013                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
10014                fdomain_client::fidl::FDomainResourceDialect,
10015                0x5b3d0e51614df053,
10016            >(_buf?)?
10017            .into_result_fdomain::<NodeMarker>("get_node_ref")?;
10018            Ok(_response)
10019        }
10020        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
10021            (),
10022            0x5b3d0e51614df053,
10023            fidl::encoding::DynamicFlags::FLEXIBLE,
10024            _decode,
10025        )
10026    }
10027
10028    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
10029        NodeIsAlternateForResult,
10030        fdomain_client::fidl::FDomainResourceDialect,
10031    >;
10032    fn r#is_alternate_for(
10033        &self,
10034        mut payload: NodeIsAlternateForRequest,
10035    ) -> Self::IsAlternateForResponseFut {
10036        fn _decode(
10037            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10038        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
10039            let _response = fidl::client::decode_transaction_body::<
10040                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
10041                fdomain_client::fidl::FDomainResourceDialect,
10042                0x3a58e00157e0825,
10043            >(_buf?)?
10044            .into_result_fdomain::<NodeMarker>("is_alternate_for")?;
10045            Ok(_response.map(|x| x))
10046        }
10047        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
10048            &mut payload,
10049            0x3a58e00157e0825,
10050            fidl::encoding::DynamicFlags::FLEXIBLE,
10051            _decode,
10052        )
10053    }
10054
10055    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
10056        NodeGetBufferCollectionIdResponse,
10057        fdomain_client::fidl::FDomainResourceDialect,
10058    >;
10059    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
10060        fn _decode(
10061            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10062        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
10063            let _response = fidl::client::decode_transaction_body::<
10064                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
10065                fdomain_client::fidl::FDomainResourceDialect,
10066                0x77d19a494b78ba8c,
10067            >(_buf?)?
10068            .into_result_fdomain::<NodeMarker>("get_buffer_collection_id")?;
10069            Ok(_response)
10070        }
10071        self.client.send_query_and_decode::<
10072            fidl::encoding::EmptyPayload,
10073            NodeGetBufferCollectionIdResponse,
10074        >(
10075            (),
10076            0x77d19a494b78ba8c,
10077            fidl::encoding::DynamicFlags::FLEXIBLE,
10078            _decode,
10079        )
10080    }
10081
10082    fn r#set_weak(&self) -> Result<(), fidl::Error> {
10083        self.client.send::<fidl::encoding::EmptyPayload>(
10084            (),
10085            0x22dd3ea514eeffe1,
10086            fidl::encoding::DynamicFlags::FLEXIBLE,
10087        )
10088    }
10089
10090    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
10091        self.client.send::<NodeSetWeakOkRequest>(
10092            &mut payload,
10093            0x38a44fc4d7724be9,
10094            fidl::encoding::DynamicFlags::FLEXIBLE,
10095        )
10096    }
10097
10098    fn r#attach_node_tracking(
10099        &self,
10100        mut payload: NodeAttachNodeTrackingRequest,
10101    ) -> Result<(), fidl::Error> {
10102        self.client.send::<NodeAttachNodeTrackingRequest>(
10103            &mut payload,
10104            0x3f22f2a293d3cdac,
10105            fidl::encoding::DynamicFlags::FLEXIBLE,
10106        )
10107    }
10108}
10109
10110pub struct NodeEventStream {
10111    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10112}
10113
10114impl std::marker::Unpin for NodeEventStream {}
10115
10116impl futures::stream::FusedStream for NodeEventStream {
10117    fn is_terminated(&self) -> bool {
10118        self.event_receiver.is_terminated()
10119    }
10120}
10121
10122impl futures::Stream for NodeEventStream {
10123    type Item = Result<NodeEvent, fidl::Error>;
10124
10125    fn poll_next(
10126        mut self: std::pin::Pin<&mut Self>,
10127        cx: &mut std::task::Context<'_>,
10128    ) -> std::task::Poll<Option<Self::Item>> {
10129        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10130            &mut self.event_receiver,
10131            cx
10132        )?) {
10133            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
10134            None => std::task::Poll::Ready(None),
10135        }
10136    }
10137}
10138
10139#[derive(Debug)]
10140pub enum NodeEvent {
10141    #[non_exhaustive]
10142    _UnknownEvent {
10143        /// Ordinal of the event that was sent.
10144        ordinal: u64,
10145    },
10146}
10147
10148impl NodeEvent {
10149    /// Decodes a message buffer as a [`NodeEvent`].
10150    fn decode(
10151        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10152    ) -> Result<NodeEvent, fidl::Error> {
10153        let (bytes, _handles) = buf.split_mut();
10154        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10155        debug_assert_eq!(tx_header.tx_id, 0);
10156        match tx_header.ordinal {
10157            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
10158                Ok(NodeEvent::_UnknownEvent { ordinal: tx_header.ordinal })
10159            }
10160            _ => Err(fidl::Error::UnknownOrdinal {
10161                ordinal: tx_header.ordinal,
10162                protocol_name: <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10163            }),
10164        }
10165    }
10166}
10167
10168/// A Stream of incoming requests for fuchsia.sysmem2/Node.
10169pub struct NodeRequestStream {
10170    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10171    is_terminated: bool,
10172}
10173
10174impl std::marker::Unpin for NodeRequestStream {}
10175
10176impl futures::stream::FusedStream for NodeRequestStream {
10177    fn is_terminated(&self) -> bool {
10178        self.is_terminated
10179    }
10180}
10181
10182impl fdomain_client::fidl::RequestStream for NodeRequestStream {
10183    type Protocol = NodeMarker;
10184    type ControlHandle = NodeControlHandle;
10185
10186    fn from_channel(channel: fdomain_client::Channel) -> Self {
10187        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10188    }
10189
10190    fn control_handle(&self) -> Self::ControlHandle {
10191        NodeControlHandle { inner: self.inner.clone() }
10192    }
10193
10194    fn into_inner(
10195        self,
10196    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10197    {
10198        (self.inner, self.is_terminated)
10199    }
10200
10201    fn from_inner(
10202        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10203        is_terminated: bool,
10204    ) -> Self {
10205        Self { inner, is_terminated }
10206    }
10207}
10208
10209impl futures::Stream for NodeRequestStream {
10210    type Item = Result<NodeRequest, fidl::Error>;
10211
10212    fn poll_next(
10213        mut self: std::pin::Pin<&mut Self>,
10214        cx: &mut std::task::Context<'_>,
10215    ) -> std::task::Poll<Option<Self::Item>> {
10216        let this = &mut *self;
10217        if this.inner.check_shutdown(cx) {
10218            this.is_terminated = true;
10219            return std::task::Poll::Ready(None);
10220        }
10221        if this.is_terminated {
10222            panic!("polled NodeRequestStream after completion");
10223        }
10224        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10225            |bytes, handles| {
10226                match this.inner.channel().read_etc(cx, bytes, handles) {
10227                    std::task::Poll::Ready(Ok(())) => {}
10228                    std::task::Poll::Pending => return std::task::Poll::Pending,
10229                    std::task::Poll::Ready(Err(None)) => {
10230                        this.is_terminated = true;
10231                        return std::task::Poll::Ready(None);
10232                    }
10233                    std::task::Poll::Ready(Err(Some(e))) => {
10234                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10235                            e.into(),
10236                        ))));
10237                    }
10238                }
10239
10240                // A message has been received from the channel
10241                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10242
10243                std::task::Poll::Ready(Some(match header.ordinal {
10244                    0x11ac2555cf575b54 => {
10245                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10246                        let mut req = fidl::new_empty!(
10247                            fidl::encoding::EmptyPayload,
10248                            fdomain_client::fidl::FDomainResourceDialect
10249                        );
10250                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10251                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10252                        Ok(NodeRequest::Sync {
10253                            responder: NodeSyncResponder {
10254                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10255                                tx_id: header.tx_id,
10256                            },
10257                        })
10258                    }
10259                    0x6a5cae7d6d6e04c6 => {
10260                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10261                        let mut req = fidl::new_empty!(
10262                            fidl::encoding::EmptyPayload,
10263                            fdomain_client::fidl::FDomainResourceDialect
10264                        );
10265                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10266                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10267                        Ok(NodeRequest::Release { control_handle })
10268                    }
10269                    0xb41f1624f48c1e9 => {
10270                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10271                        let mut req = fidl::new_empty!(
10272                            NodeSetNameRequest,
10273                            fdomain_client::fidl::FDomainResourceDialect
10274                        );
10275                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
10276                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10277                        Ok(NodeRequest::SetName { payload: req, control_handle })
10278                    }
10279                    0x5cde8914608d99b1 => {
10280                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10281                        let mut req = fidl::new_empty!(
10282                            NodeSetDebugClientInfoRequest,
10283                            fdomain_client::fidl::FDomainResourceDialect
10284                        );
10285                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
10286                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10287                        Ok(NodeRequest::SetDebugClientInfo { payload: req, control_handle })
10288                    }
10289                    0x716b0af13d5c0806 => {
10290                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10291                        let mut req = fidl::new_empty!(
10292                            NodeSetDebugTimeoutLogDeadlineRequest,
10293                            fdomain_client::fidl::FDomainResourceDialect
10294                        );
10295                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
10296                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10297                        Ok(NodeRequest::SetDebugTimeoutLogDeadline { payload: req, control_handle })
10298                    }
10299                    0x5209c77415b4dfad => {
10300                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10301                        let mut req = fidl::new_empty!(
10302                            fidl::encoding::EmptyPayload,
10303                            fdomain_client::fidl::FDomainResourceDialect
10304                        );
10305                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10306                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10307                        Ok(NodeRequest::SetVerboseLogging { control_handle })
10308                    }
10309                    0x5b3d0e51614df053 => {
10310                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10311                        let mut req = fidl::new_empty!(
10312                            fidl::encoding::EmptyPayload,
10313                            fdomain_client::fidl::FDomainResourceDialect
10314                        );
10315                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10316                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10317                        Ok(NodeRequest::GetNodeRef {
10318                            responder: NodeGetNodeRefResponder {
10319                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10320                                tx_id: header.tx_id,
10321                            },
10322                        })
10323                    }
10324                    0x3a58e00157e0825 => {
10325                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10326                        let mut req = fidl::new_empty!(
10327                            NodeIsAlternateForRequest,
10328                            fdomain_client::fidl::FDomainResourceDialect
10329                        );
10330                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
10331                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10332                        Ok(NodeRequest::IsAlternateFor {
10333                            payload: req,
10334                            responder: NodeIsAlternateForResponder {
10335                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10336                                tx_id: header.tx_id,
10337                            },
10338                        })
10339                    }
10340                    0x77d19a494b78ba8c => {
10341                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10342                        let mut req = fidl::new_empty!(
10343                            fidl::encoding::EmptyPayload,
10344                            fdomain_client::fidl::FDomainResourceDialect
10345                        );
10346                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10347                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10348                        Ok(NodeRequest::GetBufferCollectionId {
10349                            responder: NodeGetBufferCollectionIdResponder {
10350                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10351                                tx_id: header.tx_id,
10352                            },
10353                        })
10354                    }
10355                    0x22dd3ea514eeffe1 => {
10356                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10357                        let mut req = fidl::new_empty!(
10358                            fidl::encoding::EmptyPayload,
10359                            fdomain_client::fidl::FDomainResourceDialect
10360                        );
10361                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10362                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10363                        Ok(NodeRequest::SetWeak { control_handle })
10364                    }
10365                    0x38a44fc4d7724be9 => {
10366                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10367                        let mut req = fidl::new_empty!(
10368                            NodeSetWeakOkRequest,
10369                            fdomain_client::fidl::FDomainResourceDialect
10370                        );
10371                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
10372                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10373                        Ok(NodeRequest::SetWeakOk { payload: req, control_handle })
10374                    }
10375                    0x3f22f2a293d3cdac => {
10376                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10377                        let mut req = fidl::new_empty!(
10378                            NodeAttachNodeTrackingRequest,
10379                            fdomain_client::fidl::FDomainResourceDialect
10380                        );
10381                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
10382                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10383                        Ok(NodeRequest::AttachNodeTracking { payload: req, control_handle })
10384                    }
10385                    _ if header.tx_id == 0
10386                        && header
10387                            .dynamic_flags()
10388                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
10389                    {
10390                        Ok(NodeRequest::_UnknownMethod {
10391                            ordinal: header.ordinal,
10392                            control_handle: NodeControlHandle { inner: this.inner.clone() },
10393                            method_type: fidl::MethodType::OneWay,
10394                        })
10395                    }
10396                    _ if header
10397                        .dynamic_flags()
10398                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
10399                    {
10400                        this.inner.send_framework_err(
10401                            fidl::encoding::FrameworkErr::UnknownMethod,
10402                            header.tx_id,
10403                            header.ordinal,
10404                            header.dynamic_flags(),
10405                            (bytes, handles),
10406                        )?;
10407                        Ok(NodeRequest::_UnknownMethod {
10408                            ordinal: header.ordinal,
10409                            control_handle: NodeControlHandle { inner: this.inner.clone() },
10410                            method_type: fidl::MethodType::TwoWay,
10411                        })
10412                    }
10413                    _ => Err(fidl::Error::UnknownOrdinal {
10414                        ordinal: header.ordinal,
10415                        protocol_name:
10416                            <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10417                    }),
10418                }))
10419            },
10420        )
10421    }
10422}
10423
10424/// This protocol is the parent protocol for all nodes in the tree established
10425/// by [`fuchsia.sysmem2/BufferCollectionToken`] creation and
10426/// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] creation, including
10427/// [`fuchsia.sysmem2/BufferCollectionToken`](s) which have since been converted
10428/// to a [`fuchsia.sysmem2/BufferCollection`] channel.
10429///
10430/// Epitaphs are not used in this protocol.
10431#[derive(Debug)]
10432pub enum NodeRequest {
10433    /// Ensure that previous messages have been received server side. This is
10434    /// particularly useful after previous messages that created new tokens,
10435    /// because a token must be known to the sysmem server before sending the
10436    /// token to another participant.
10437    ///
10438    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
10439    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
10440    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
10441    /// to mitigate the possibility of a hostile/fake
10442    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
10443    /// Another way is to pass the token to
10444    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
10445    /// the token as part of exchanging it for a
10446    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
10447    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
10448    /// of stalling.
10449    ///
10450    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
10451    /// and then starting and completing a `Sync`, it's then safe to send the
10452    /// `BufferCollectionToken` client ends to other participants knowing the
10453    /// server will recognize the tokens when they're sent by the other
10454    /// participants to sysmem in a
10455    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
10456    /// efficient way to create tokens while avoiding unnecessary round trips.
10457    ///
10458    /// Other options include waiting for each
10459    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
10460    /// individually (using separate call to `Sync` after each), or calling
10461    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
10462    /// converted to a `BufferCollection` via
10463    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
10464    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
10465    /// the sync step and can create multiple tokens at once.
10466    Sync { responder: NodeSyncResponder },
10467    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
10468    ///
10469    /// Normally a participant will convert a `BufferCollectionToken` into a
10470    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
10471    /// `Release` via the token (and then close the channel immediately or
10472    /// shortly later in response to server closing the server end), which
10473    /// avoids causing buffer collection failure. Without a prior `Release`,
10474    /// closing the `BufferCollectionToken` client end will cause buffer
10475    /// collection failure.
10476    ///
10477    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
10478    ///
10479    /// By default the server handles unexpected closure of a
10480    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
10481    /// first) by failing the buffer collection. Partly this is to expedite
10482    /// closing VMO handles to reclaim memory when any participant fails. If a
10483    /// participant would like to cleanly close a `BufferCollection` without
10484    /// causing buffer collection failure, the participant can send `Release`
10485    /// before closing the `BufferCollection` client end. The `Release` can
10486    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
10487    /// buffer collection won't require constraints from this node in order to
10488    /// allocate. If after `SetConstraints`, the constraints are retained and
10489    /// aggregated, despite the lack of `BufferCollection` connection at the
10490    /// time of constraints aggregation.
10491    ///
10492    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
10493    ///
10494    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
10495    /// end (without `Release` first) will trigger failure of the buffer
10496    /// collection. To close a `BufferCollectionTokenGroup` channel without
10497    /// failing the buffer collection, ensure that AllChildrenPresent() has been
10498    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
10499    /// client end.
10500    ///
10501    /// If `Release` occurs before
10502    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
10503    /// buffer collection will fail (triggered by reception of `Release` without
10504    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
10505    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
10506    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
10507    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
10508    /// close requires `AllChildrenPresent` (if not already sent), then
10509    /// `Release`, then close client end.
10510    ///
10511    /// If `Release` occurs after `AllChildrenPresent`, the children and all
10512    /// their constraints remain intact (just as they would if the
10513    /// `BufferCollectionTokenGroup` channel had remained open), and the client
10514    /// end close doesn't trigger buffer collection failure.
10515    ///
10516    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
10517    ///
10518    /// For brevity, the per-channel-protocol paragraphs above ignore the
10519    /// separate failure domain created by
10520    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
10521    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
10522    /// unexpectedly closes (without `Release` first) and that client end is
10523    /// under a failure domain, instead of failing the whole buffer collection,
10524    /// the failure domain is failed, but the buffer collection itself is
10525    /// isolated from failure of the failure domain. Such failure domains can be
10526    /// nested, in which case only the inner-most failure domain in which the
10527    /// `Node` resides fails.
10528    Release { control_handle: NodeControlHandle },
10529    /// Set a name for VMOs in this buffer collection.
10530    ///
10531    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
10532    /// will be truncated to fit. The name of the vmo will be suffixed with the
10533    /// buffer index within the collection (if the suffix fits within
10534    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
10535    /// listed in the inspect data.
10536    ///
10537    /// The name only affects VMOs allocated after the name is set; this call
10538    /// does not rename existing VMOs. If multiple clients set different names
10539    /// then the larger priority value will win. Setting a new name with the
10540    /// same priority as a prior name doesn't change the name.
10541    ///
10542    /// All table fields are currently required.
10543    ///
10544    /// + request `priority` The name is only set if this is the first `SetName`
10545    ///   or if `priority` is greater than any previous `priority` value in
10546    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
10547    /// + request `name` The name for VMOs created under this buffer collection.
10548    SetName { payload: NodeSetNameRequest, control_handle: NodeControlHandle },
10549    /// Set information about the current client that can be used by sysmem to
10550    /// help diagnose leaking memory and allocation stalls waiting for a
10551    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
10552    ///
10553    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
10554    /// `Node`(s) derived from this `Node`, unless overriden by
10555    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
10556    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
10557    ///
10558    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
10559    /// `Allocator` is the most efficient way to ensure that all
10560    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
10561    /// set, and is also more efficient than separately sending the same debug
10562    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
10563    /// created [`fuchsia.sysmem2/Node`].
10564    ///
10565    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
10566    /// indicate which client is closing their channel first, leading to subtree
10567    /// failure (which can be normal if the purpose of the subtree is over, but
10568    /// if happening earlier than expected, the client-channel-specific name can
10569    /// help diagnose where the failure is first coming from, from sysmem's
10570    /// point of view).
10571    ///
10572    /// All table fields are currently required.
10573    ///
10574    /// + request `name` This can be an arbitrary string, but the current
10575    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
10576    /// + request `id` This can be an arbitrary id, but the current process ID
10577    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
10578    SetDebugClientInfo { payload: NodeSetDebugClientInfoRequest, control_handle: NodeControlHandle },
10579    /// Sysmem logs a warning if sysmem hasn't seen
10580    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
10581    /// within 5 seconds after creation of a new collection.
10582    ///
10583    /// Clients can call this method to change when the log is printed. If
10584    /// multiple client set the deadline, it's unspecified which deadline will
10585    /// take effect.
10586    ///
10587    /// In most cases the default works well.
10588    ///
10589    /// All table fields are currently required.
10590    ///
10591    /// + request `deadline` The time at which sysmem will start trying to log
10592    ///   the warning, unless all constraints are with sysmem by then.
10593    SetDebugTimeoutLogDeadline {
10594        payload: NodeSetDebugTimeoutLogDeadlineRequest,
10595        control_handle: NodeControlHandle,
10596    },
10597    /// This enables verbose logging for the buffer collection.
10598    ///
10599    /// Verbose logging includes constraints set via
10600    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
10601    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
10602    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
10603    /// the tree of `Node`(s).
10604    ///
10605    /// Normally sysmem prints only a single line complaint when aggregation
10606    /// fails, with just the specific detailed reason that aggregation failed,
10607    /// with little surrounding context.  While this is often enough to diagnose
10608    /// a problem if only a small change was made and everything was working
10609    /// before the small change, it's often not particularly helpful for getting
10610    /// a new buffer collection to work for the first time.  Especially with
10611    /// more complex trees of nodes, involving things like
10612    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
10613    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
10614    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
10615    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
10616    /// looks like and why it's failing a logical allocation, or why a tree or
10617    /// subtree is failing sooner than expected.
10618    ///
10619    /// The intent of the extra logging is to be acceptable from a performance
10620    /// point of view, under the assumption that verbose logging is only enabled
10621    /// on a low number of buffer collections. If we're not tracking down a bug,
10622    /// we shouldn't send this message.
10623    SetVerboseLogging { control_handle: NodeControlHandle },
10624    /// This gets a handle that can be used as a parameter to
10625    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
10626    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
10627    /// client obtained this handle from this `Node`.
10628    ///
10629    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
10630    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
10631    /// despite the two calls typically being on different channels.
10632    ///
10633    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
10634    ///
10635    /// All table fields are currently required.
10636    ///
10637    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
10638    ///   different `Node` channel, to prove that the client obtained the handle
10639    ///   from this `Node`.
10640    GetNodeRef { responder: NodeGetNodeRefResponder },
10641    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
10642    /// rooted at a different child token of a common parent
10643    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
10644    /// passed-in `node_ref`.
10645    ///
10646    /// This call is for assisting with admission control de-duplication, and
10647    /// with debugging.
10648    ///
10649    /// The `node_ref` must be obtained using
10650    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
10651    ///
10652    /// The `node_ref` can be a duplicated handle; it's not necessary to call
10653    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
10654    ///
10655    /// If a calling token may not actually be a valid token at all due to a
10656    /// potentially hostile/untrusted provider of the token, call
10657    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
10658    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
10659    /// never responds due to a calling token not being a real token (not really
10660    /// talking to sysmem).  Another option is to call
10661    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
10662    /// which also validates the token along with converting it to a
10663    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
10664    ///
10665    /// All table fields are currently required.
10666    ///
10667    /// - response `is_alternate`
10668    ///   - true: The first parent node in common between the calling node and
10669    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
10670    ///     that the calling `Node` and the `node_ref` `Node` will not have both
10671    ///     their constraints apply - rather sysmem will choose one or the other
10672    ///     of the constraints - never both.  This is because only one child of
10673    ///     a `BufferCollectionTokenGroup` is selected during logical
10674    ///     allocation, with only that one child's subtree contributing to
10675    ///     constraints aggregation.
10676    ///   - false: The first parent node in common between the calling `Node`
10677    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
10678    ///     Currently, this means the first parent node in common is a
10679    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
10680    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
10681    ///     `Node` may have both their constraints apply during constraints
10682    ///     aggregation of the logical allocation, if both `Node`(s) are
10683    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
10684    ///     this case, there is no `BufferCollectionTokenGroup` that will
10685    ///     directly prevent the two `Node`(s) from both being selected and
10686    ///     their constraints both aggregated, but even when false, one or both
10687    ///     `Node`(s) may still be eliminated from consideration if one or both
10688    ///     `Node`(s) has a direct or indirect parent
10689    ///     `BufferCollectionTokenGroup` which selects a child subtree other
10690    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
10691    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
10692    ///   associated with the same buffer collection as the calling `Node`.
10693    ///   Another reason for this error is if the `node_ref` is an
10694    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
10695    ///   a real `node_ref` obtained from `GetNodeRef`.
10696    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
10697    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
10698    ///   the needed rights expected on a real `node_ref`.
10699    /// * No other failing status codes are returned by this call.  However,
10700    ///   sysmem may add additional codes in future, so the client should have
10701    ///   sensible default handling for any failing status code.
10702    IsAlternateFor { payload: NodeIsAlternateForRequest, responder: NodeIsAlternateForResponder },
10703    /// Get the buffer collection ID. This ID is also available from
10704    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
10705    /// within the collection).
10706    ///
10707    /// This call is mainly useful in situations where we can't convey a
10708    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
10709    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
10710    /// handle, which can be joined back up with a `BufferCollection` client end
10711    /// that was created via a different path. Prefer to convey a
10712    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
10713    ///
10714    /// Trusting a `buffer_collection_id` value from a source other than sysmem
10715    /// is analogous to trusting a koid value from a source other than zircon.
10716    /// Both should be avoided unless really necessary, and both require
10717    /// caution. In some situations it may be reasonable to refer to a
10718    /// pre-established `BufferCollection` by `buffer_collection_id` via a
10719    /// protocol for efficiency reasons, but an incoming value purporting to be
10720    /// a `buffer_collection_id` is not sufficient alone to justify granting the
10721    /// sender of the `buffer_collection_id` any capability. The sender must
10722    /// first prove to a receiver that the sender has/had a VMO or has/had a
10723    /// `BufferCollectionToken` to the same collection by sending a handle that
10724    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
10725    /// `buffer_collection_id` value. The receiver should take care to avoid
10726    /// assuming that a sender had a `BufferCollectionToken` in cases where the
10727    /// sender has only proven that the sender had a VMO.
10728    ///
10729    /// - response `buffer_collection_id` This ID is unique per buffer
10730    ///   collection per boot. Each buffer is uniquely identified by the
10731    ///   `buffer_collection_id` and `buffer_index` together.
10732    GetBufferCollectionId { responder: NodeGetBufferCollectionIdResponder },
10733    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
10734    /// created after this message to weak, which means that a client's `Node`
10735    /// client end (or a child created after this message) is not alone
10736    /// sufficient to keep allocated VMOs alive.
10737    ///
10738    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
10739    /// `close_weak_asap`.
10740    ///
10741    /// This message is only permitted before the `Node` becomes ready for
10742    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
10743    ///   * `BufferCollectionToken`: any time
10744    ///   * `BufferCollection`: before `SetConstraints`
10745    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
10746    ///
10747    /// Currently, no conversion from strong `Node` to weak `Node` after ready
10748    /// for allocation is provided, but a client can simulate that by creating
10749    /// an additional `Node` before allocation and setting that additional
10750    /// `Node` to weak, and then potentially at some point later sending
10751    /// `Release` and closing the client end of the client's strong `Node`, but
10752    /// keeping the client's weak `Node`.
10753    ///
10754    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
10755    /// collection failure (all `Node` client end(s) will see
10756    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
10757    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
10758    /// this situation until all `Node`(s) are ready for allocation. For initial
10759    /// allocation to succeed, at least one strong `Node` is required to exist
10760    /// at allocation time, but after that client receives VMO handles, that
10761    /// client can `BufferCollection.Release` and close the client end without
10762    /// causing this type of failure.
10763    ///
10764    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
10765    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
10766    /// separately as appropriate.
10767    SetWeak { control_handle: NodeControlHandle },
10768    /// This indicates to sysmem that the client is prepared to pay attention to
10769    /// `close_weak_asap`.
10770    ///
10771    /// If sent, this message must be before
10772    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
10773    ///
10774    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
10775    /// send this message before `WaitForAllBuffersAllocated`, or a parent
10776    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
10777    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
10778    /// trigger buffer collection failure.
10779    ///
10780    /// This message is necessary because weak sysmem VMOs have not always been
10781    /// a thing, so older clients are not aware of the need to pay attention to
10782    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
10783    /// sysmem weak VMO handles asap. By having this message and requiring
10784    /// participants to indicate their acceptance of this aspect of the overall
10785    /// protocol, we avoid situations where an older client is delivered a weak
10786    /// VMO without any way for sysmem to get that VMO to close quickly later
10787    /// (and on a per-buffer basis).
10788    ///
10789    /// A participant that doesn't handle `close_weak_asap` and also doesn't
10790    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
10791    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
10792    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
10793    /// same participant has a child/delegate which does retrieve VMOs, that
10794    /// child/delegate will need to send `SetWeakOk` before
10795    /// `WaitForAllBuffersAllocated`.
10796    ///
10797    /// + request `for_child_nodes_also` If present and true, this means direct
10798    ///   child nodes of this node created after this message plus all
10799    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
10800    ///   those nodes. Any child node of this node that was created before this
10801    ///   message is not included. This setting is "sticky" in the sense that a
10802    ///   subsequent `SetWeakOk` without this bool set to true does not reset
10803    ///   the server-side bool. If this creates a problem for a participant, a
10804    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
10805    ///   tokens instead, as appropriate. A participant should only set
10806    ///   `for_child_nodes_also` true if the participant can really promise to
10807    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
10808    ///   weak VMO handles held by participants holding the corresponding child
10809    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
10810    ///   which are using sysmem(1) can be weak, despite the clients of those
10811    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
10812    ///   direct way to find out about `close_weak_asap`. This only applies to
10813    ///   descendents of this `Node` which are using sysmem(1), not to this
10814    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
10815    ///   token, which will fail allocation unless an ancestor of this `Node`
10816    ///   specified `for_child_nodes_also` true.
10817    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: NodeControlHandle },
10818    /// The server_end will be closed after this `Node` and any child nodes have
10819    /// have released their buffer counts, making those counts available for
10820    /// reservation by a different `Node` via
10821    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
10822    ///
10823    /// The `Node` buffer counts may not be released until the entire tree of
10824    /// `Node`(s) is closed or failed, because
10825    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
10826    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
10827    /// `Node` buffer counts remain reserved until the orphaned node is later
10828    /// cleaned up.
10829    ///
10830    /// If the `Node` exceeds a fairly large number of attached eventpair server
10831    /// ends, a log message will indicate this and the `Node` (and the
10832    /// appropriate) sub-tree will fail.
10833    ///
10834    /// The `server_end` will remain open when
10835    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
10836    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
10837    /// [`fuchsia.sysmem2/BufferCollection`].
10838    ///
10839    /// This message can also be used with a
10840    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
10841    AttachNodeTracking { payload: NodeAttachNodeTrackingRequest, control_handle: NodeControlHandle },
10842    /// An interaction was received which does not match any known method.
10843    #[non_exhaustive]
10844    _UnknownMethod {
10845        /// Ordinal of the method that was called.
10846        ordinal: u64,
10847        control_handle: NodeControlHandle,
10848        method_type: fidl::MethodType,
10849    },
10850}
10851
10852impl NodeRequest {
10853    #[allow(irrefutable_let_patterns)]
10854    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
10855        if let NodeRequest::Sync { responder } = self { Some((responder)) } else { None }
10856    }
10857
10858    #[allow(irrefutable_let_patterns)]
10859    pub fn into_release(self) -> Option<(NodeControlHandle)> {
10860        if let NodeRequest::Release { control_handle } = self {
10861            Some((control_handle))
10862        } else {
10863            None
10864        }
10865    }
10866
10867    #[allow(irrefutable_let_patterns)]
10868    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, NodeControlHandle)> {
10869        if let NodeRequest::SetName { payload, control_handle } = self {
10870            Some((payload, control_handle))
10871        } else {
10872            None
10873        }
10874    }
10875
10876    #[allow(irrefutable_let_patterns)]
10877    pub fn into_set_debug_client_info(
10878        self,
10879    ) -> Option<(NodeSetDebugClientInfoRequest, NodeControlHandle)> {
10880        if let NodeRequest::SetDebugClientInfo { payload, control_handle } = self {
10881            Some((payload, control_handle))
10882        } else {
10883            None
10884        }
10885    }
10886
10887    #[allow(irrefutable_let_patterns)]
10888    pub fn into_set_debug_timeout_log_deadline(
10889        self,
10890    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, NodeControlHandle)> {
10891        if let NodeRequest::SetDebugTimeoutLogDeadline { payload, control_handle } = self {
10892            Some((payload, control_handle))
10893        } else {
10894            None
10895        }
10896    }
10897
10898    #[allow(irrefutable_let_patterns)]
10899    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
10900        if let NodeRequest::SetVerboseLogging { control_handle } = self {
10901            Some((control_handle))
10902        } else {
10903            None
10904        }
10905    }
10906
10907    #[allow(irrefutable_let_patterns)]
10908    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
10909        if let NodeRequest::GetNodeRef { responder } = self { Some((responder)) } else { None }
10910    }
10911
10912    #[allow(irrefutable_let_patterns)]
10913    pub fn into_is_alternate_for(
10914        self,
10915    ) -> Option<(NodeIsAlternateForRequest, NodeIsAlternateForResponder)> {
10916        if let NodeRequest::IsAlternateFor { payload, responder } = self {
10917            Some((payload, responder))
10918        } else {
10919            None
10920        }
10921    }
10922
10923    #[allow(irrefutable_let_patterns)]
10924    pub fn into_get_buffer_collection_id(self) -> Option<(NodeGetBufferCollectionIdResponder)> {
10925        if let NodeRequest::GetBufferCollectionId { responder } = self {
10926            Some((responder))
10927        } else {
10928            None
10929        }
10930    }
10931
10932    #[allow(irrefutable_let_patterns)]
10933    pub fn into_set_weak(self) -> Option<(NodeControlHandle)> {
10934        if let NodeRequest::SetWeak { control_handle } = self {
10935            Some((control_handle))
10936        } else {
10937            None
10938        }
10939    }
10940
10941    #[allow(irrefutable_let_patterns)]
10942    pub fn into_set_weak_ok(self) -> Option<(NodeSetWeakOkRequest, NodeControlHandle)> {
10943        if let NodeRequest::SetWeakOk { payload, control_handle } = self {
10944            Some((payload, control_handle))
10945        } else {
10946            None
10947        }
10948    }
10949
10950    #[allow(irrefutable_let_patterns)]
10951    pub fn into_attach_node_tracking(
10952        self,
10953    ) -> Option<(NodeAttachNodeTrackingRequest, NodeControlHandle)> {
10954        if let NodeRequest::AttachNodeTracking { payload, control_handle } = self {
10955            Some((payload, control_handle))
10956        } else {
10957            None
10958        }
10959    }
10960
10961    /// Name of the method defined in FIDL
10962    pub fn method_name(&self) -> &'static str {
10963        match *self {
10964            NodeRequest::Sync { .. } => "sync",
10965            NodeRequest::Release { .. } => "release",
10966            NodeRequest::SetName { .. } => "set_name",
10967            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
10968            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
10969            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
10970            NodeRequest::GetNodeRef { .. } => "get_node_ref",
10971            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
10972            NodeRequest::GetBufferCollectionId { .. } => "get_buffer_collection_id",
10973            NodeRequest::SetWeak { .. } => "set_weak",
10974            NodeRequest::SetWeakOk { .. } => "set_weak_ok",
10975            NodeRequest::AttachNodeTracking { .. } => "attach_node_tracking",
10976            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
10977                "unknown one-way method"
10978            }
10979            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
10980                "unknown two-way method"
10981            }
10982        }
10983    }
10984}
10985
10986#[derive(Debug, Clone)]
10987pub struct NodeControlHandle {
10988    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10989}
10990
10991impl fdomain_client::fidl::ControlHandle for NodeControlHandle {
10992    fn shutdown(&self) {
10993        self.inner.shutdown()
10994    }
10995
10996    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
10997        self.inner.shutdown_with_epitaph(status)
10998    }
10999
11000    fn is_closed(&self) -> bool {
11001        self.inner.channel().is_closed()
11002    }
11003    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
11004        self.inner.channel().on_closed()
11005    }
11006}
11007
11008impl NodeControlHandle {}
11009
11010#[must_use = "FIDL methods require a response to be sent"]
11011#[derive(Debug)]
11012pub struct NodeSyncResponder {
11013    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11014    tx_id: u32,
11015}
11016
11017/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11018/// if the responder is dropped without sending a response, so that the client
11019/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11020impl std::ops::Drop for NodeSyncResponder {
11021    fn drop(&mut self) {
11022        self.control_handle.shutdown();
11023        // Safety: drops once, never accessed again
11024        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11025    }
11026}
11027
11028impl fdomain_client::fidl::Responder for NodeSyncResponder {
11029    type ControlHandle = NodeControlHandle;
11030
11031    fn control_handle(&self) -> &NodeControlHandle {
11032        &self.control_handle
11033    }
11034
11035    fn drop_without_shutdown(mut self) {
11036        // Safety: drops once, never accessed again due to mem::forget
11037        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11038        // Prevent Drop from running (which would shut down the channel)
11039        std::mem::forget(self);
11040    }
11041}
11042
11043impl NodeSyncResponder {
11044    /// Sends a response to the FIDL transaction.
11045    ///
11046    /// Sets the channel to shutdown if an error occurs.
11047    pub fn send(self) -> Result<(), fidl::Error> {
11048        let _result = self.send_raw();
11049        if _result.is_err() {
11050            self.control_handle.shutdown();
11051        }
11052        self.drop_without_shutdown();
11053        _result
11054    }
11055
11056    /// Similar to "send" but does not shutdown the channel if an error occurs.
11057    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11058        let _result = self.send_raw();
11059        self.drop_without_shutdown();
11060        _result
11061    }
11062
11063    fn send_raw(&self) -> Result<(), fidl::Error> {
11064        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
11065            fidl::encoding::Flexible::new(()),
11066            self.tx_id,
11067            0x11ac2555cf575b54,
11068            fidl::encoding::DynamicFlags::FLEXIBLE,
11069        )
11070    }
11071}
11072
11073#[must_use = "FIDL methods require a response to be sent"]
11074#[derive(Debug)]
11075pub struct NodeGetNodeRefResponder {
11076    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11077    tx_id: u32,
11078}
11079
11080/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11081/// if the responder is dropped without sending a response, so that the client
11082/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11083impl std::ops::Drop for NodeGetNodeRefResponder {
11084    fn drop(&mut self) {
11085        self.control_handle.shutdown();
11086        // Safety: drops once, never accessed again
11087        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11088    }
11089}
11090
11091impl fdomain_client::fidl::Responder for NodeGetNodeRefResponder {
11092    type ControlHandle = NodeControlHandle;
11093
11094    fn control_handle(&self) -> &NodeControlHandle {
11095        &self.control_handle
11096    }
11097
11098    fn drop_without_shutdown(mut self) {
11099        // Safety: drops once, never accessed again due to mem::forget
11100        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11101        // Prevent Drop from running (which would shut down the channel)
11102        std::mem::forget(self);
11103    }
11104}
11105
11106impl NodeGetNodeRefResponder {
11107    /// Sends a response to the FIDL transaction.
11108    ///
11109    /// Sets the channel to shutdown if an error occurs.
11110    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
11111        let _result = self.send_raw(payload);
11112        if _result.is_err() {
11113            self.control_handle.shutdown();
11114        }
11115        self.drop_without_shutdown();
11116        _result
11117    }
11118
11119    /// Similar to "send" but does not shutdown the channel if an error occurs.
11120    pub fn send_no_shutdown_on_err(
11121        self,
11122        mut payload: NodeGetNodeRefResponse,
11123    ) -> Result<(), fidl::Error> {
11124        let _result = self.send_raw(payload);
11125        self.drop_without_shutdown();
11126        _result
11127    }
11128
11129    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
11130        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
11131            fidl::encoding::Flexible::new(&mut payload),
11132            self.tx_id,
11133            0x5b3d0e51614df053,
11134            fidl::encoding::DynamicFlags::FLEXIBLE,
11135        )
11136    }
11137}
11138
11139#[must_use = "FIDL methods require a response to be sent"]
11140#[derive(Debug)]
11141pub struct NodeIsAlternateForResponder {
11142    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11143    tx_id: u32,
11144}
11145
11146/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11147/// if the responder is dropped without sending a response, so that the client
11148/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11149impl std::ops::Drop for NodeIsAlternateForResponder {
11150    fn drop(&mut self) {
11151        self.control_handle.shutdown();
11152        // Safety: drops once, never accessed again
11153        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11154    }
11155}
11156
11157impl fdomain_client::fidl::Responder for NodeIsAlternateForResponder {
11158    type ControlHandle = NodeControlHandle;
11159
11160    fn control_handle(&self) -> &NodeControlHandle {
11161        &self.control_handle
11162    }
11163
11164    fn drop_without_shutdown(mut self) {
11165        // Safety: drops once, never accessed again due to mem::forget
11166        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11167        // Prevent Drop from running (which would shut down the channel)
11168        std::mem::forget(self);
11169    }
11170}
11171
11172impl NodeIsAlternateForResponder {
11173    /// Sends a response to the FIDL transaction.
11174    ///
11175    /// Sets the channel to shutdown if an error occurs.
11176    pub fn send(
11177        self,
11178        mut result: Result<&NodeIsAlternateForResponse, Error>,
11179    ) -> Result<(), fidl::Error> {
11180        let _result = self.send_raw(result);
11181        if _result.is_err() {
11182            self.control_handle.shutdown();
11183        }
11184        self.drop_without_shutdown();
11185        _result
11186    }
11187
11188    /// Similar to "send" but does not shutdown the channel if an error occurs.
11189    pub fn send_no_shutdown_on_err(
11190        self,
11191        mut result: Result<&NodeIsAlternateForResponse, Error>,
11192    ) -> Result<(), fidl::Error> {
11193        let _result = self.send_raw(result);
11194        self.drop_without_shutdown();
11195        _result
11196    }
11197
11198    fn send_raw(
11199        &self,
11200        mut result: Result<&NodeIsAlternateForResponse, Error>,
11201    ) -> Result<(), fidl::Error> {
11202        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
11203            NodeIsAlternateForResponse,
11204            Error,
11205        >>(
11206            fidl::encoding::FlexibleResult::new(result),
11207            self.tx_id,
11208            0x3a58e00157e0825,
11209            fidl::encoding::DynamicFlags::FLEXIBLE,
11210        )
11211    }
11212}
11213
11214#[must_use = "FIDL methods require a response to be sent"]
11215#[derive(Debug)]
11216pub struct NodeGetBufferCollectionIdResponder {
11217    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11218    tx_id: u32,
11219}
11220
11221/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11222/// if the responder is dropped without sending a response, so that the client
11223/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11224impl std::ops::Drop for NodeGetBufferCollectionIdResponder {
11225    fn drop(&mut self) {
11226        self.control_handle.shutdown();
11227        // Safety: drops once, never accessed again
11228        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11229    }
11230}
11231
11232impl fdomain_client::fidl::Responder for NodeGetBufferCollectionIdResponder {
11233    type ControlHandle = NodeControlHandle;
11234
11235    fn control_handle(&self) -> &NodeControlHandle {
11236        &self.control_handle
11237    }
11238
11239    fn drop_without_shutdown(mut self) {
11240        // Safety: drops once, never accessed again due to mem::forget
11241        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11242        // Prevent Drop from running (which would shut down the channel)
11243        std::mem::forget(self);
11244    }
11245}
11246
11247impl NodeGetBufferCollectionIdResponder {
11248    /// Sends a response to the FIDL transaction.
11249    ///
11250    /// Sets the channel to shutdown if an error occurs.
11251    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
11252        let _result = self.send_raw(payload);
11253        if _result.is_err() {
11254            self.control_handle.shutdown();
11255        }
11256        self.drop_without_shutdown();
11257        _result
11258    }
11259
11260    /// Similar to "send" but does not shutdown the channel if an error occurs.
11261    pub fn send_no_shutdown_on_err(
11262        self,
11263        mut payload: &NodeGetBufferCollectionIdResponse,
11264    ) -> Result<(), fidl::Error> {
11265        let _result = self.send_raw(payload);
11266        self.drop_without_shutdown();
11267        _result
11268    }
11269
11270    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
11271        self.control_handle
11272            .inner
11273            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
11274                fidl::encoding::Flexible::new(payload),
11275                self.tx_id,
11276                0x77d19a494b78ba8c,
11277                fidl::encoding::DynamicFlags::FLEXIBLE,
11278            )
11279    }
11280}
11281
11282#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11283pub struct SecureMemMarker;
11284
11285impl fdomain_client::fidl::ProtocolMarker for SecureMemMarker {
11286    type Proxy = SecureMemProxy;
11287    type RequestStream = SecureMemRequestStream;
11288
11289    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
11290}
11291pub type SecureMemGetPhysicalSecureHeapsResult =
11292    Result<SecureMemGetPhysicalSecureHeapsResponse, Error>;
11293pub type SecureMemGetDynamicSecureHeapsResult =
11294    Result<SecureMemGetDynamicSecureHeapsResponse, Error>;
11295pub type SecureMemGetPhysicalSecureHeapPropertiesResult =
11296    Result<SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>;
11297pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), Error>;
11298pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), Error>;
11299pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), Error>;
11300pub type SecureMemZeroSubRangeResult = Result<(), Error>;
11301
11302pub trait SecureMemProxyInterface: Send + Sync {
11303    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
11304        + Send;
11305    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
11306    type GetDynamicSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetDynamicSecureHeapsResult, fidl::Error>>
11307        + Send;
11308    fn r#get_dynamic_secure_heaps(&self) -> Self::GetDynamicSecureHeapsResponseFut;
11309    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
11310            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
11311        > + Send;
11312    fn r#get_physical_secure_heap_properties(
11313        &self,
11314        payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11315    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
11316    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
11317        + Send;
11318    fn r#add_secure_heap_physical_range(
11319        &self,
11320        payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11321    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
11322    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
11323            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
11324        > + Send;
11325    fn r#delete_secure_heap_physical_range(
11326        &self,
11327        payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11328    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
11329    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
11330            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
11331        > + Send;
11332    fn r#modify_secure_heap_physical_range(
11333        &self,
11334        payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11335    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
11336    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
11337        + Send;
11338    fn r#zero_sub_range(
11339        &self,
11340        payload: &SecureMemZeroSubRangeRequest,
11341    ) -> Self::ZeroSubRangeResponseFut;
11342}
11343
11344#[derive(Debug, Clone)]
11345pub struct SecureMemProxy {
11346    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11347}
11348
11349impl fdomain_client::fidl::Proxy for SecureMemProxy {
11350    type Protocol = SecureMemMarker;
11351
11352    fn from_channel(inner: fdomain_client::Channel) -> Self {
11353        Self::new(inner)
11354    }
11355
11356    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11357        self.client.into_channel().map_err(|client| Self { client })
11358    }
11359
11360    fn as_channel(&self) -> &fdomain_client::Channel {
11361        self.client.as_channel()
11362    }
11363}
11364
11365impl SecureMemProxy {
11366    /// Create a new Proxy for fuchsia.sysmem2/SecureMem.
11367    pub fn new(channel: fdomain_client::Channel) -> Self {
11368        let protocol_name = <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11369        Self { client: fidl::client::Client::new(channel, protocol_name) }
11370    }
11371
11372    /// Get a Stream of events from the remote end of the protocol.
11373    ///
11374    /// # Panics
11375    ///
11376    /// Panics if the event stream was already taken.
11377    pub fn take_event_stream(&self) -> SecureMemEventStream {
11378        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
11379    }
11380
11381    /// Gets the physical address and length of any secure heap whose physical
11382    /// range is configured via the TEE.
11383    ///
11384    /// Presently, these will be fixed physical addresses and lengths, with the
11385    /// location plumbed via the TEE.
11386    ///
11387    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
11388    /// when there isn't any special heap-specific per-VMO setup or teardown
11389    /// required.
11390    ///
11391    /// The physical range must be secured/protected by the TEE before the
11392    /// securemem driver responds to this request with success.
11393    ///
11394    /// Sysmem should only call this once.  Returning zero heaps is not a
11395    /// failure.
11396    ///
11397    /// Errors:
11398    ///  * PROTOCOL_DEVIATION - called more than once.
11399    ///  * UNSPECIFIED - generic internal error (such as in communication
11400    ///    with TEE which doesn't generate zx_status_t errors).
11401    ///  * other errors are allowed; any other errors should be treated the same
11402    ///    as UNSPECIFIED.
11403    pub fn r#get_physical_secure_heaps(
11404        &self,
11405    ) -> fidl::client::QueryResponseFut<
11406        SecureMemGetPhysicalSecureHeapsResult,
11407        fdomain_client::fidl::FDomainResourceDialect,
11408    > {
11409        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
11410    }
11411
11412    /// Gets information about any secure heaps whose physical pages are not
11413    /// configured by the TEE, but by sysmem.
11414    ///
11415    /// Sysmem should only call this once. Returning zero heaps is not a
11416    /// failure.
11417    ///
11418    /// Errors:
11419    ///  * PROTOCOL_DEVIATION - called more than once.
11420    ///  * UNSPECIFIED - generic internal error (such as in communication
11421    ///    with TEE which doesn't generate zx_status_t errors).
11422    ///  * other errors are allowed; any other errors should be treated the same
11423    ///    as UNSPECIFIED.
11424    pub fn r#get_dynamic_secure_heaps(
11425        &self,
11426    ) -> fidl::client::QueryResponseFut<
11427        SecureMemGetDynamicSecureHeapsResult,
11428        fdomain_client::fidl::FDomainResourceDialect,
11429    > {
11430        SecureMemProxyInterface::r#get_dynamic_secure_heaps(self)
11431    }
11432
11433    /// This request from sysmem to the securemem driver gets the properties of
11434    /// a protected/secure heap.
11435    ///
11436    /// This only handles heaps with a single contiguous physical extent.
11437    ///
11438    /// The heap's entire physical range is indicated in case this request needs
11439    /// some physical space to auto-detect how many ranges are REE-usable.  Any
11440    /// temporary HW protection ranges will be deleted before this request
11441    /// completes.
11442    ///
11443    /// Errors:
11444    ///  * UNSPECIFIED - generic internal error (such as in communication
11445    ///    with TEE which doesn't generate zx_status_t errors).
11446    ///  * other errors are allowed; any other errors should be treated the same
11447    ///    as UNSPECIFIED.
11448    pub fn r#get_physical_secure_heap_properties(
11449        &self,
11450        mut payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11451    ) -> fidl::client::QueryResponseFut<
11452        SecureMemGetPhysicalSecureHeapPropertiesResult,
11453        fdomain_client::fidl::FDomainResourceDialect,
11454    > {
11455        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, payload)
11456    }
11457
11458    /// This request from sysmem to the securemem driver conveys a physical
11459    /// range to add, for a heap whose physical range(s) are set up via
11460    /// sysmem.
11461    ///
11462    /// Only sysmem can call this because only sysmem is handed the client end
11463    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11464    /// securemem driver is the server end of this protocol.
11465    ///
11466    /// The securemem driver must configure all the covered offsets as protected
11467    /// before responding to this message with success.
11468    ///
11469    /// On failure, the securemem driver must ensure the protected range was not
11470    /// created.
11471    ///
11472    /// Sysmem must only call this up to once if dynamic_protection_ranges
11473    /// false.
11474    ///
11475    /// If dynamic_protection_ranges is true, sysmem can call this multiple
11476    /// times as long as the current number of ranges never exceeds
11477    /// max_protected_range_count.
11478    ///
11479    /// The caller must not attempt to add a range that matches an
11480    /// already-existing range.  Added ranges can overlap each other as long as
11481    /// no two ranges match exactly.
11482    ///
11483    /// Errors:
11484    ///   * PROTOCOL_DEVIATION - called more than once when
11485    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
11486    ///     heap count to exceed max_protected_range_count. Unexpected heap, or
11487    ///     range that doesn't conform to protected_range_granularity. See log.
11488    ///   * UNSPECIFIED - generic internal error (such as in communication
11489    ///     with TEE which doesn't generate zx_status_t errors).
11490    ///   * other errors are possible, such as from communication failures or
11491    ///     server propagation of failures.
11492    pub fn r#add_secure_heap_physical_range(
11493        &self,
11494        mut payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11495    ) -> fidl::client::QueryResponseFut<
11496        SecureMemAddSecureHeapPhysicalRangeResult,
11497        fdomain_client::fidl::FDomainResourceDialect,
11498    > {
11499        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, payload)
11500    }
11501
11502    /// This request from sysmem to the securemem driver conveys a physical
11503    /// range to delete, for a heap whose physical range(s) are set up via
11504    /// sysmem.
11505    ///
11506    /// Only sysmem can call this because only sysmem is handed the client end
11507    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11508    /// securemem driver is the server end of this protocol.
11509    ///
11510    /// The securemem driver must configure all the covered offsets as not
11511    /// protected before responding to this message with success.
11512    ///
11513    /// On failure, the securemem driver must ensure the protected range was not
11514    /// deleted.
11515    ///
11516    /// Sysmem must not call this if dynamic_protection_ranges false.
11517    ///
11518    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11519    /// on various ranges that exist at the time of the call.
11520    ///
11521    /// If any portion of the range being deleted is not also covered by another
11522    /// protected range, then any ongoing DMA to any part of the entire range
11523    /// may be interrupted / may fail, potentially in a way that's disruptive to
11524    /// the entire system (bus lockup or similar, depending on device details).
11525    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
11526    /// any portion of the range being deleted, unless the caller has other
11527    /// active ranges covering every block of the range being deleted.  Ongoing
11528    /// DMA to/from blocks outside the range being deleted is never impacted by
11529    /// the deletion.
11530    ///
11531    /// Errors:
11532    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11533    ///     Unexpected heap, or range that doesn't conform to
11534    ///     protected_range_granularity.
11535    ///   * UNSPECIFIED - generic internal error (such as in communication
11536    ///     with TEE which doesn't generate zx_status_t errors).
11537    ///   * NOT_FOUND - the specified range is not found.
11538    ///   * other errors are possible, such as from communication failures or
11539    ///     server propagation of failures.
11540    pub fn r#delete_secure_heap_physical_range(
11541        &self,
11542        mut payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11543    ) -> fidl::client::QueryResponseFut<
11544        SecureMemDeleteSecureHeapPhysicalRangeResult,
11545        fdomain_client::fidl::FDomainResourceDialect,
11546    > {
11547        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, payload)
11548    }
11549
11550    /// This request from sysmem to the securemem driver conveys a physical
11551    /// range to modify and its new base and length, for a heap whose physical
11552    /// range(s) are set up via sysmem.
11553    ///
11554    /// Only sysmem can call this because only sysmem is handed the client end
11555    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11556    /// securemem driver is the server end of this protocol.
11557    ///
11558    /// The securemem driver must configure the range to cover only the new
11559    /// offsets before responding to this message with success.
11560    ///
11561    /// On failure, the securemem driver must ensure the range was not changed.
11562    ///
11563    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
11564    /// must not call this if !is_mod_protected_range_available.
11565    ///
11566    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11567    /// on various ranges that exist at the time of the call.
11568    ///
11569    /// The range must only be modified at one end or the other, but not both.
11570    /// If the range is getting shorter, and the un-covered blocks are not
11571    /// covered by other active ranges, any ongoing DMA to the entire range
11572    /// that's geting shorter may fail in a way that disrupts the entire system
11573    /// (bus lockup or similar), so the caller must ensure that no DMA is
11574    /// ongoing to any portion of a range that is getting shorter, unless the
11575    /// blocks being un-covered by the modification to this range are all
11576    /// covered by other active ranges, in which case no disruption to ongoing
11577    /// DMA will occur.
11578    ///
11579    /// If a range is modified to become <= zero length, the range is deleted.
11580    ///
11581    /// Errors:
11582    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11583    ///     Unexpected heap, or old_range or new_range that doesn't conform to
11584    ///     protected_range_granularity, or old_range and new_range differ in
11585    ///     both begin and end (disallowed).
11586    ///   * UNSPECIFIED - generic internal error (such as in communication
11587    ///     with TEE which doesn't generate zx_status_t errors).
11588    ///   * NOT_FOUND - the specified range is not found.
11589    ///   * other errors are possible, such as from communication failures or
11590    ///     server propagation of failures.
11591    pub fn r#modify_secure_heap_physical_range(
11592        &self,
11593        mut payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11594    ) -> fidl::client::QueryResponseFut<
11595        SecureMemModifySecureHeapPhysicalRangeResult,
11596        fdomain_client::fidl::FDomainResourceDialect,
11597    > {
11598        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, payload)
11599    }
11600
11601    /// Zero a sub-range of a currently-existing physical range added via
11602    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11603    /// exactly one physical range, and must not overlap with any other
11604    /// physical range.
11605    ///
11606    /// is_covering_range_explicit - When true, the covering range must be one
11607    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11608    ///     possibly modified since.  When false, the covering range must not
11609    ///     be one of the ranges explicitly created via
11610    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11611    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11612    ///     covering range is typically the entire physical range (or a range
11613    ///     which covers even more) of a heap configured by the TEE and whose
11614    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11615    ///
11616    /// Ongoing DMA is not disrupted by this request.
11617    ///
11618    /// Errors:
11619    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11620    ///     Unexpected heap.
11621    ///   * UNSPECIFIED - generic internal error (such as in communication
11622    ///     with TEE which doesn't generate zx_status_t errors).
11623    ///   * other errors are possible, such as from communication failures or
11624    ///     server propagation of failures.
11625    pub fn r#zero_sub_range(
11626        &self,
11627        mut payload: &SecureMemZeroSubRangeRequest,
11628    ) -> fidl::client::QueryResponseFut<
11629        SecureMemZeroSubRangeResult,
11630        fdomain_client::fidl::FDomainResourceDialect,
11631    > {
11632        SecureMemProxyInterface::r#zero_sub_range(self, payload)
11633    }
11634}
11635
11636impl SecureMemProxyInterface for SecureMemProxy {
11637    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11638        SecureMemGetPhysicalSecureHeapsResult,
11639        fdomain_client::fidl::FDomainResourceDialect,
11640    >;
11641    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
11642        fn _decode(
11643            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11644        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
11645            let _response = fidl::client::decode_transaction_body::<
11646                fidl::encoding::FlexibleResultType<SecureMemGetPhysicalSecureHeapsResponse, Error>,
11647                fdomain_client::fidl::FDomainResourceDialect,
11648                0x38716300592073e3,
11649            >(_buf?)?
11650            .into_result_fdomain::<SecureMemMarker>("get_physical_secure_heaps")?;
11651            Ok(_response.map(|x| x))
11652        }
11653        self.client.send_query_and_decode::<
11654            fidl::encoding::EmptyPayload,
11655            SecureMemGetPhysicalSecureHeapsResult,
11656        >(
11657            (),
11658            0x38716300592073e3,
11659            fidl::encoding::DynamicFlags::FLEXIBLE,
11660            _decode,
11661        )
11662    }
11663
11664    type GetDynamicSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11665        SecureMemGetDynamicSecureHeapsResult,
11666        fdomain_client::fidl::FDomainResourceDialect,
11667    >;
11668    fn r#get_dynamic_secure_heaps(&self) -> Self::GetDynamicSecureHeapsResponseFut {
11669        fn _decode(
11670            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11671        ) -> Result<SecureMemGetDynamicSecureHeapsResult, fidl::Error> {
11672            let _response = fidl::client::decode_transaction_body::<
11673                fidl::encoding::FlexibleResultType<SecureMemGetDynamicSecureHeapsResponse, Error>,
11674                fdomain_client::fidl::FDomainResourceDialect,
11675                0x1190847f99952834,
11676            >(_buf?)?
11677            .into_result_fdomain::<SecureMemMarker>("get_dynamic_secure_heaps")?;
11678            Ok(_response.map(|x| x))
11679        }
11680        self.client.send_query_and_decode::<
11681            fidl::encoding::EmptyPayload,
11682            SecureMemGetDynamicSecureHeapsResult,
11683        >(
11684            (),
11685            0x1190847f99952834,
11686            fidl::encoding::DynamicFlags::FLEXIBLE,
11687            _decode,
11688        )
11689    }
11690
11691    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
11692        SecureMemGetPhysicalSecureHeapPropertiesResult,
11693        fdomain_client::fidl::FDomainResourceDialect,
11694    >;
11695    fn r#get_physical_secure_heap_properties(
11696        &self,
11697        mut payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11698    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
11699        fn _decode(
11700            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11701        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
11702            let _response = fidl::client::decode_transaction_body::<
11703                fidl::encoding::FlexibleResultType<
11704                    SecureMemGetPhysicalSecureHeapPropertiesResponse,
11705                    Error,
11706                >,
11707                fdomain_client::fidl::FDomainResourceDialect,
11708                0xc6f06889009c7bc,
11709            >(_buf?)?
11710            .into_result_fdomain::<SecureMemMarker>("get_physical_secure_heap_properties")?;
11711            Ok(_response.map(|x| x))
11712        }
11713        self.client.send_query_and_decode::<
11714            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11715            SecureMemGetPhysicalSecureHeapPropertiesResult,
11716        >(
11717            payload,
11718            0xc6f06889009c7bc,
11719            fidl::encoding::DynamicFlags::FLEXIBLE,
11720            _decode,
11721        )
11722    }
11723
11724    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11725        SecureMemAddSecureHeapPhysicalRangeResult,
11726        fdomain_client::fidl::FDomainResourceDialect,
11727    >;
11728    fn r#add_secure_heap_physical_range(
11729        &self,
11730        mut payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11731    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
11732        fn _decode(
11733            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11734        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
11735            let _response = fidl::client::decode_transaction_body::<
11736                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11737                fdomain_client::fidl::FDomainResourceDialect,
11738                0x35f695b9b6c7217a,
11739            >(_buf?)?
11740            .into_result_fdomain::<SecureMemMarker>("add_secure_heap_physical_range")?;
11741            Ok(_response.map(|x| x))
11742        }
11743        self.client.send_query_and_decode::<
11744            SecureMemAddSecureHeapPhysicalRangeRequest,
11745            SecureMemAddSecureHeapPhysicalRangeResult,
11746        >(
11747            payload,
11748            0x35f695b9b6c7217a,
11749            fidl::encoding::DynamicFlags::FLEXIBLE,
11750            _decode,
11751        )
11752    }
11753
11754    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11755        SecureMemDeleteSecureHeapPhysicalRangeResult,
11756        fdomain_client::fidl::FDomainResourceDialect,
11757    >;
11758    fn r#delete_secure_heap_physical_range(
11759        &self,
11760        mut payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11761    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
11762        fn _decode(
11763            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11764        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
11765            let _response = fidl::client::decode_transaction_body::<
11766                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11767                fdomain_client::fidl::FDomainResourceDialect,
11768                0xeaa58c650264c9e,
11769            >(_buf?)?
11770            .into_result_fdomain::<SecureMemMarker>("delete_secure_heap_physical_range")?;
11771            Ok(_response.map(|x| x))
11772        }
11773        self.client.send_query_and_decode::<
11774            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11775            SecureMemDeleteSecureHeapPhysicalRangeResult,
11776        >(
11777            payload,
11778            0xeaa58c650264c9e,
11779            fidl::encoding::DynamicFlags::FLEXIBLE,
11780            _decode,
11781        )
11782    }
11783
11784    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11785        SecureMemModifySecureHeapPhysicalRangeResult,
11786        fdomain_client::fidl::FDomainResourceDialect,
11787    >;
11788    fn r#modify_secure_heap_physical_range(
11789        &self,
11790        mut payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11791    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
11792        fn _decode(
11793            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11794        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
11795            let _response = fidl::client::decode_transaction_body::<
11796                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11797                fdomain_client::fidl::FDomainResourceDialect,
11798                0x60b7448aa1187734,
11799            >(_buf?)?
11800            .into_result_fdomain::<SecureMemMarker>("modify_secure_heap_physical_range")?;
11801            Ok(_response.map(|x| x))
11802        }
11803        self.client.send_query_and_decode::<
11804            SecureMemModifySecureHeapPhysicalRangeRequest,
11805            SecureMemModifySecureHeapPhysicalRangeResult,
11806        >(
11807            payload,
11808            0x60b7448aa1187734,
11809            fidl::encoding::DynamicFlags::FLEXIBLE,
11810            _decode,
11811        )
11812    }
11813
11814    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
11815        SecureMemZeroSubRangeResult,
11816        fdomain_client::fidl::FDomainResourceDialect,
11817    >;
11818    fn r#zero_sub_range(
11819        &self,
11820        mut payload: &SecureMemZeroSubRangeRequest,
11821    ) -> Self::ZeroSubRangeResponseFut {
11822        fn _decode(
11823            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11824        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
11825            let _response = fidl::client::decode_transaction_body::<
11826                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11827                fdomain_client::fidl::FDomainResourceDialect,
11828                0x5b25b7901a385ce5,
11829            >(_buf?)?
11830            .into_result_fdomain::<SecureMemMarker>("zero_sub_range")?;
11831            Ok(_response.map(|x| x))
11832        }
11833        self.client
11834            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
11835                payload,
11836                0x5b25b7901a385ce5,
11837                fidl::encoding::DynamicFlags::FLEXIBLE,
11838                _decode,
11839            )
11840    }
11841}
11842
11843pub struct SecureMemEventStream {
11844    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
11845}
11846
11847impl std::marker::Unpin for SecureMemEventStream {}
11848
11849impl futures::stream::FusedStream for SecureMemEventStream {
11850    fn is_terminated(&self) -> bool {
11851        self.event_receiver.is_terminated()
11852    }
11853}
11854
11855impl futures::Stream for SecureMemEventStream {
11856    type Item = Result<SecureMemEvent, fidl::Error>;
11857
11858    fn poll_next(
11859        mut self: std::pin::Pin<&mut Self>,
11860        cx: &mut std::task::Context<'_>,
11861    ) -> std::task::Poll<Option<Self::Item>> {
11862        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11863            &mut self.event_receiver,
11864            cx
11865        )?) {
11866            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
11867            None => std::task::Poll::Ready(None),
11868        }
11869    }
11870}
11871
11872#[derive(Debug)]
11873pub enum SecureMemEvent {
11874    #[non_exhaustive]
11875    _UnknownEvent {
11876        /// Ordinal of the event that was sent.
11877        ordinal: u64,
11878    },
11879}
11880
11881impl SecureMemEvent {
11882    /// Decodes a message buffer as a [`SecureMemEvent`].
11883    fn decode(
11884        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11885    ) -> Result<SecureMemEvent, fidl::Error> {
11886        let (bytes, _handles) = buf.split_mut();
11887        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11888        debug_assert_eq!(tx_header.tx_id, 0);
11889        match tx_header.ordinal {
11890            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
11891                Ok(SecureMemEvent::_UnknownEvent { ordinal: tx_header.ordinal })
11892            }
11893            _ => Err(fidl::Error::UnknownOrdinal {
11894                ordinal: tx_header.ordinal,
11895                protocol_name:
11896                    <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
11897            }),
11898        }
11899    }
11900}
11901
11902/// A Stream of incoming requests for fuchsia.sysmem2/SecureMem.
11903pub struct SecureMemRequestStream {
11904    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11905    is_terminated: bool,
11906}
11907
11908impl std::marker::Unpin for SecureMemRequestStream {}
11909
11910impl futures::stream::FusedStream for SecureMemRequestStream {
11911    fn is_terminated(&self) -> bool {
11912        self.is_terminated
11913    }
11914}
11915
11916impl fdomain_client::fidl::RequestStream for SecureMemRequestStream {
11917    type Protocol = SecureMemMarker;
11918    type ControlHandle = SecureMemControlHandle;
11919
11920    fn from_channel(channel: fdomain_client::Channel) -> Self {
11921        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11922    }
11923
11924    fn control_handle(&self) -> Self::ControlHandle {
11925        SecureMemControlHandle { inner: self.inner.clone() }
11926    }
11927
11928    fn into_inner(
11929        self,
11930    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
11931    {
11932        (self.inner, self.is_terminated)
11933    }
11934
11935    fn from_inner(
11936        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11937        is_terminated: bool,
11938    ) -> Self {
11939        Self { inner, is_terminated }
11940    }
11941}
11942
11943impl futures::Stream for SecureMemRequestStream {
11944    type Item = Result<SecureMemRequest, fidl::Error>;
11945
11946    fn poll_next(
11947        mut self: std::pin::Pin<&mut Self>,
11948        cx: &mut std::task::Context<'_>,
11949    ) -> std::task::Poll<Option<Self::Item>> {
11950        let this = &mut *self;
11951        if this.inner.check_shutdown(cx) {
11952            this.is_terminated = true;
11953            return std::task::Poll::Ready(None);
11954        }
11955        if this.is_terminated {
11956            panic!("polled SecureMemRequestStream after completion");
11957        }
11958        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
11959            |bytes, handles| {
11960                match this.inner.channel().read_etc(cx, bytes, handles) {
11961                    std::task::Poll::Ready(Ok(())) => {}
11962                    std::task::Poll::Pending => return std::task::Poll::Pending,
11963                    std::task::Poll::Ready(Err(None)) => {
11964                        this.is_terminated = true;
11965                        return std::task::Poll::Ready(None);
11966                    }
11967                    std::task::Poll::Ready(Err(Some(e))) => {
11968                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11969                            e.into(),
11970                        ))));
11971                    }
11972                }
11973
11974                // A message has been received from the channel
11975                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11976
11977                std::task::Poll::Ready(Some(match header.ordinal {
11978                    0x38716300592073e3 => {
11979                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11980                        let mut req = fidl::new_empty!(
11981                            fidl::encoding::EmptyPayload,
11982                            fdomain_client::fidl::FDomainResourceDialect
11983                        );
11984                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
11985                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
11986                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
11987                            responder: SecureMemGetPhysicalSecureHeapsResponder {
11988                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11989                                tx_id: header.tx_id,
11990                            },
11991                        })
11992                    }
11993                    0x1190847f99952834 => {
11994                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11995                        let mut req = fidl::new_empty!(
11996                            fidl::encoding::EmptyPayload,
11997                            fdomain_client::fidl::FDomainResourceDialect
11998                        );
11999                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12000                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12001                        Ok(SecureMemRequest::GetDynamicSecureHeaps {
12002                            responder: SecureMemGetDynamicSecureHeapsResponder {
12003                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12004                                tx_id: header.tx_id,
12005                            },
12006                        })
12007                    }
12008                    0xc6f06889009c7bc => {
12009                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12010                        let mut req = fidl::new_empty!(
12011                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
12012                            fdomain_client::fidl::FDomainResourceDialect
12013                        );
12014                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
12015                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12016                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
12017                            payload: req,
12018                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
12019                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12020                                tx_id: header.tx_id,
12021                            },
12022                        })
12023                    }
12024                    0x35f695b9b6c7217a => {
12025                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12026                        let mut req = fidl::new_empty!(
12027                            SecureMemAddSecureHeapPhysicalRangeRequest,
12028                            fdomain_client::fidl::FDomainResourceDialect
12029                        );
12030                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12031                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12032                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
12033                            payload: req,
12034                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
12035                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12036                                tx_id: header.tx_id,
12037                            },
12038                        })
12039                    }
12040                    0xeaa58c650264c9e => {
12041                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12042                        let mut req = fidl::new_empty!(
12043                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
12044                            fdomain_client::fidl::FDomainResourceDialect
12045                        );
12046                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12047                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12048                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
12049                            payload: req,
12050                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
12051                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12052                                tx_id: header.tx_id,
12053                            },
12054                        })
12055                    }
12056                    0x60b7448aa1187734 => {
12057                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12058                        let mut req = fidl::new_empty!(
12059                            SecureMemModifySecureHeapPhysicalRangeRequest,
12060                            fdomain_client::fidl::FDomainResourceDialect
12061                        );
12062                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12063                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12064                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
12065                            payload: req,
12066                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
12067                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12068                                tx_id: header.tx_id,
12069                            },
12070                        })
12071                    }
12072                    0x5b25b7901a385ce5 => {
12073                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12074                        let mut req = fidl::new_empty!(
12075                            SecureMemZeroSubRangeRequest,
12076                            fdomain_client::fidl::FDomainResourceDialect
12077                        );
12078                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12079                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12080                        Ok(SecureMemRequest::ZeroSubRange {
12081                            payload: req,
12082                            responder: SecureMemZeroSubRangeResponder {
12083                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12084                                tx_id: header.tx_id,
12085                            },
12086                        })
12087                    }
12088                    _ if header.tx_id == 0
12089                        && header
12090                            .dynamic_flags()
12091                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
12092                    {
12093                        Ok(SecureMemRequest::_UnknownMethod {
12094                            ordinal: header.ordinal,
12095                            control_handle: SecureMemControlHandle { inner: this.inner.clone() },
12096                            method_type: fidl::MethodType::OneWay,
12097                        })
12098                    }
12099                    _ if header
12100                        .dynamic_flags()
12101                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
12102                    {
12103                        this.inner.send_framework_err(
12104                            fidl::encoding::FrameworkErr::UnknownMethod,
12105                            header.tx_id,
12106                            header.ordinal,
12107                            header.dynamic_flags(),
12108                            (bytes, handles),
12109                        )?;
12110                        Ok(SecureMemRequest::_UnknownMethod {
12111                            ordinal: header.ordinal,
12112                            control_handle: SecureMemControlHandle { inner: this.inner.clone() },
12113                            method_type: fidl::MethodType::TwoWay,
12114                        })
12115                    }
12116                    _ => Err(fidl::Error::UnknownOrdinal {
12117                        ordinal: header.ordinal,
12118                        protocol_name:
12119                            <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12120                    }),
12121                }))
12122            },
12123        )
12124    }
12125}
12126
12127/// SecureMem
12128///
12129/// The client is sysmem.  The server is securemem driver.
12130///
12131/// TEE - Trusted Execution Environment.
12132///
12133/// REE - Rich Execution Environment.
12134///
12135/// Enables sysmem to call the securemem driver to get any secure heaps
12136/// configured via the TEE (or via the securemem driver), and set any physical
12137/// secure heaps configured via sysmem.
12138///
12139/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
12140/// it starts quite early during boot and can successfully reserve contiguous
12141/// physical memory.  Presently, fixed-location secure heaps are configured via
12142/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
12143/// protocol intentionally doesn't care which heaps are dynamically-allocated
12144/// and which are fixed-location.
12145#[derive(Debug)]
12146pub enum SecureMemRequest {
12147    /// Gets the physical address and length of any secure heap whose physical
12148    /// range is configured via the TEE.
12149    ///
12150    /// Presently, these will be fixed physical addresses and lengths, with the
12151    /// location plumbed via the TEE.
12152    ///
12153    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
12154    /// when there isn't any special heap-specific per-VMO setup or teardown
12155    /// required.
12156    ///
12157    /// The physical range must be secured/protected by the TEE before the
12158    /// securemem driver responds to this request with success.
12159    ///
12160    /// Sysmem should only call this once.  Returning zero heaps is not a
12161    /// failure.
12162    ///
12163    /// Errors:
12164    ///  * PROTOCOL_DEVIATION - called more than once.
12165    ///  * UNSPECIFIED - generic internal error (such as in communication
12166    ///    with TEE which doesn't generate zx_status_t errors).
12167    ///  * other errors are allowed; any other errors should be treated the same
12168    ///    as UNSPECIFIED.
12169    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
12170    /// Gets information about any secure heaps whose physical pages are not
12171    /// configured by the TEE, but by sysmem.
12172    ///
12173    /// Sysmem should only call this once. Returning zero heaps is not a
12174    /// failure.
12175    ///
12176    /// Errors:
12177    ///  * PROTOCOL_DEVIATION - called more than once.
12178    ///  * UNSPECIFIED - generic internal error (such as in communication
12179    ///    with TEE which doesn't generate zx_status_t errors).
12180    ///  * other errors are allowed; any other errors should be treated the same
12181    ///    as UNSPECIFIED.
12182    GetDynamicSecureHeaps { responder: SecureMemGetDynamicSecureHeapsResponder },
12183    /// This request from sysmem to the securemem driver gets the properties of
12184    /// a protected/secure heap.
12185    ///
12186    /// This only handles heaps with a single contiguous physical extent.
12187    ///
12188    /// The heap's entire physical range is indicated in case this request needs
12189    /// some physical space to auto-detect how many ranges are REE-usable.  Any
12190    /// temporary HW protection ranges will be deleted before this request
12191    /// completes.
12192    ///
12193    /// Errors:
12194    ///  * UNSPECIFIED - generic internal error (such as in communication
12195    ///    with TEE which doesn't generate zx_status_t errors).
12196    ///  * other errors are allowed; any other errors should be treated the same
12197    ///    as UNSPECIFIED.
12198    GetPhysicalSecureHeapProperties {
12199        payload: SecureMemGetPhysicalSecureHeapPropertiesRequest,
12200        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
12201    },
12202    /// This request from sysmem to the securemem driver conveys a physical
12203    /// range to add, for a heap whose physical range(s) are set up via
12204    /// sysmem.
12205    ///
12206    /// Only sysmem can call this because only sysmem is handed the client end
12207    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12208    /// securemem driver is the server end of this protocol.
12209    ///
12210    /// The securemem driver must configure all the covered offsets as protected
12211    /// before responding to this message with success.
12212    ///
12213    /// On failure, the securemem driver must ensure the protected range was not
12214    /// created.
12215    ///
12216    /// Sysmem must only call this up to once if dynamic_protection_ranges
12217    /// false.
12218    ///
12219    /// If dynamic_protection_ranges is true, sysmem can call this multiple
12220    /// times as long as the current number of ranges never exceeds
12221    /// max_protected_range_count.
12222    ///
12223    /// The caller must not attempt to add a range that matches an
12224    /// already-existing range.  Added ranges can overlap each other as long as
12225    /// no two ranges match exactly.
12226    ///
12227    /// Errors:
12228    ///   * PROTOCOL_DEVIATION - called more than once when
12229    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
12230    ///     heap count to exceed max_protected_range_count. Unexpected heap, or
12231    ///     range that doesn't conform to protected_range_granularity. See log.
12232    ///   * UNSPECIFIED - generic internal error (such as in communication
12233    ///     with TEE which doesn't generate zx_status_t errors).
12234    ///   * other errors are possible, such as from communication failures or
12235    ///     server propagation of failures.
12236    AddSecureHeapPhysicalRange {
12237        payload: SecureMemAddSecureHeapPhysicalRangeRequest,
12238        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
12239    },
12240    /// This request from sysmem to the securemem driver conveys a physical
12241    /// range to delete, for a heap whose physical range(s) are set up via
12242    /// sysmem.
12243    ///
12244    /// Only sysmem can call this because only sysmem is handed the client end
12245    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12246    /// securemem driver is the server end of this protocol.
12247    ///
12248    /// The securemem driver must configure all the covered offsets as not
12249    /// protected before responding to this message with success.
12250    ///
12251    /// On failure, the securemem driver must ensure the protected range was not
12252    /// deleted.
12253    ///
12254    /// Sysmem must not call this if dynamic_protection_ranges false.
12255    ///
12256    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
12257    /// on various ranges that exist at the time of the call.
12258    ///
12259    /// If any portion of the range being deleted is not also covered by another
12260    /// protected range, then any ongoing DMA to any part of the entire range
12261    /// may be interrupted / may fail, potentially in a way that's disruptive to
12262    /// the entire system (bus lockup or similar, depending on device details).
12263    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
12264    /// any portion of the range being deleted, unless the caller has other
12265    /// active ranges covering every block of the range being deleted.  Ongoing
12266    /// DMA to/from blocks outside the range being deleted is never impacted by
12267    /// the deletion.
12268    ///
12269    /// Errors:
12270    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12271    ///     Unexpected heap, or range that doesn't conform to
12272    ///     protected_range_granularity.
12273    ///   * UNSPECIFIED - generic internal error (such as in communication
12274    ///     with TEE which doesn't generate zx_status_t errors).
12275    ///   * NOT_FOUND - the specified range is not found.
12276    ///   * other errors are possible, such as from communication failures or
12277    ///     server propagation of failures.
12278    DeleteSecureHeapPhysicalRange {
12279        payload: SecureMemDeleteSecureHeapPhysicalRangeRequest,
12280        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
12281    },
12282    /// This request from sysmem to the securemem driver conveys a physical
12283    /// range to modify and its new base and length, for a heap whose physical
12284    /// range(s) are set up via sysmem.
12285    ///
12286    /// Only sysmem can call this because only sysmem is handed the client end
12287    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12288    /// securemem driver is the server end of this protocol.
12289    ///
12290    /// The securemem driver must configure the range to cover only the new
12291    /// offsets before responding to this message with success.
12292    ///
12293    /// On failure, the securemem driver must ensure the range was not changed.
12294    ///
12295    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
12296    /// must not call this if !is_mod_protected_range_available.
12297    ///
12298    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
12299    /// on various ranges that exist at the time of the call.
12300    ///
12301    /// The range must only be modified at one end or the other, but not both.
12302    /// If the range is getting shorter, and the un-covered blocks are not
12303    /// covered by other active ranges, any ongoing DMA to the entire range
12304    /// that's geting shorter may fail in a way that disrupts the entire system
12305    /// (bus lockup or similar), so the caller must ensure that no DMA is
12306    /// ongoing to any portion of a range that is getting shorter, unless the
12307    /// blocks being un-covered by the modification to this range are all
12308    /// covered by other active ranges, in which case no disruption to ongoing
12309    /// DMA will occur.
12310    ///
12311    /// If a range is modified to become <= zero length, the range is deleted.
12312    ///
12313    /// Errors:
12314    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12315    ///     Unexpected heap, or old_range or new_range that doesn't conform to
12316    ///     protected_range_granularity, or old_range and new_range differ in
12317    ///     both begin and end (disallowed).
12318    ///   * UNSPECIFIED - generic internal error (such as in communication
12319    ///     with TEE which doesn't generate zx_status_t errors).
12320    ///   * NOT_FOUND - the specified range is not found.
12321    ///   * other errors are possible, such as from communication failures or
12322    ///     server propagation of failures.
12323    ModifySecureHeapPhysicalRange {
12324        payload: SecureMemModifySecureHeapPhysicalRangeRequest,
12325        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
12326    },
12327    /// Zero a sub-range of a currently-existing physical range added via
12328    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
12329    /// exactly one physical range, and must not overlap with any other
12330    /// physical range.
12331    ///
12332    /// is_covering_range_explicit - When true, the covering range must be one
12333    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
12334    ///     possibly modified since.  When false, the covering range must not
12335    ///     be one of the ranges explicitly created via
12336    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
12337    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
12338    ///     covering range is typically the entire physical range (or a range
12339    ///     which covers even more) of a heap configured by the TEE and whose
12340    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
12341    ///
12342    /// Ongoing DMA is not disrupted by this request.
12343    ///
12344    /// Errors:
12345    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12346    ///     Unexpected heap.
12347    ///   * UNSPECIFIED - generic internal error (such as in communication
12348    ///     with TEE which doesn't generate zx_status_t errors).
12349    ///   * other errors are possible, such as from communication failures or
12350    ///     server propagation of failures.
12351    ZeroSubRange {
12352        payload: SecureMemZeroSubRangeRequest,
12353        responder: SecureMemZeroSubRangeResponder,
12354    },
12355    /// An interaction was received which does not match any known method.
12356    #[non_exhaustive]
12357    _UnknownMethod {
12358        /// Ordinal of the method that was called.
12359        ordinal: u64,
12360        control_handle: SecureMemControlHandle,
12361        method_type: fidl::MethodType,
12362    },
12363}
12364
12365impl SecureMemRequest {
12366    #[allow(irrefutable_let_patterns)]
12367    pub fn into_get_physical_secure_heaps(
12368        self,
12369    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
12370        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
12371            Some((responder))
12372        } else {
12373            None
12374        }
12375    }
12376
12377    #[allow(irrefutable_let_patterns)]
12378    pub fn into_get_dynamic_secure_heaps(
12379        self,
12380    ) -> Option<(SecureMemGetDynamicSecureHeapsResponder)> {
12381        if let SecureMemRequest::GetDynamicSecureHeaps { responder } = self {
12382            Some((responder))
12383        } else {
12384            None
12385        }
12386    }
12387
12388    #[allow(irrefutable_let_patterns)]
12389    pub fn into_get_physical_secure_heap_properties(
12390        self,
12391    ) -> Option<(
12392        SecureMemGetPhysicalSecureHeapPropertiesRequest,
12393        SecureMemGetPhysicalSecureHeapPropertiesResponder,
12394    )> {
12395        if let SecureMemRequest::GetPhysicalSecureHeapProperties { payload, responder } = self {
12396            Some((payload, responder))
12397        } else {
12398            None
12399        }
12400    }
12401
12402    #[allow(irrefutable_let_patterns)]
12403    pub fn into_add_secure_heap_physical_range(
12404        self,
12405    ) -> Option<(
12406        SecureMemAddSecureHeapPhysicalRangeRequest,
12407        SecureMemAddSecureHeapPhysicalRangeResponder,
12408    )> {
12409        if let SecureMemRequest::AddSecureHeapPhysicalRange { payload, responder } = self {
12410            Some((payload, responder))
12411        } else {
12412            None
12413        }
12414    }
12415
12416    #[allow(irrefutable_let_patterns)]
12417    pub fn into_delete_secure_heap_physical_range(
12418        self,
12419    ) -> Option<(
12420        SecureMemDeleteSecureHeapPhysicalRangeRequest,
12421        SecureMemDeleteSecureHeapPhysicalRangeResponder,
12422    )> {
12423        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { payload, responder } = self {
12424            Some((payload, responder))
12425        } else {
12426            None
12427        }
12428    }
12429
12430    #[allow(irrefutable_let_patterns)]
12431    pub fn into_modify_secure_heap_physical_range(
12432        self,
12433    ) -> Option<(
12434        SecureMemModifySecureHeapPhysicalRangeRequest,
12435        SecureMemModifySecureHeapPhysicalRangeResponder,
12436    )> {
12437        if let SecureMemRequest::ModifySecureHeapPhysicalRange { payload, responder } = self {
12438            Some((payload, responder))
12439        } else {
12440            None
12441        }
12442    }
12443
12444    #[allow(irrefutable_let_patterns)]
12445    pub fn into_zero_sub_range(
12446        self,
12447    ) -> Option<(SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResponder)> {
12448        if let SecureMemRequest::ZeroSubRange { payload, responder } = self {
12449            Some((payload, responder))
12450        } else {
12451            None
12452        }
12453    }
12454
12455    /// Name of the method defined in FIDL
12456    pub fn method_name(&self) -> &'static str {
12457        match *self {
12458            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
12459            SecureMemRequest::GetDynamicSecureHeaps { .. } => "get_dynamic_secure_heaps",
12460            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
12461                "get_physical_secure_heap_properties"
12462            }
12463            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
12464            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
12465                "delete_secure_heap_physical_range"
12466            }
12467            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
12468                "modify_secure_heap_physical_range"
12469            }
12470            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
12471            SecureMemRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
12472                "unknown one-way method"
12473            }
12474            SecureMemRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
12475                "unknown two-way method"
12476            }
12477        }
12478    }
12479}
12480
12481#[derive(Debug, Clone)]
12482pub struct SecureMemControlHandle {
12483    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12484}
12485
12486impl fdomain_client::fidl::ControlHandle for SecureMemControlHandle {
12487    fn shutdown(&self) {
12488        self.inner.shutdown()
12489    }
12490
12491    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12492        self.inner.shutdown_with_epitaph(status)
12493    }
12494
12495    fn is_closed(&self) -> bool {
12496        self.inner.channel().is_closed()
12497    }
12498    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
12499        self.inner.channel().on_closed()
12500    }
12501}
12502
12503impl SecureMemControlHandle {}
12504
12505#[must_use = "FIDL methods require a response to be sent"]
12506#[derive(Debug)]
12507pub struct SecureMemGetPhysicalSecureHeapsResponder {
12508    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12509    tx_id: u32,
12510}
12511
12512/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12513/// if the responder is dropped without sending a response, so that the client
12514/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12515impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
12516    fn drop(&mut self) {
12517        self.control_handle.shutdown();
12518        // Safety: drops once, never accessed again
12519        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12520    }
12521}
12522
12523impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapsResponder {
12524    type ControlHandle = SecureMemControlHandle;
12525
12526    fn control_handle(&self) -> &SecureMemControlHandle {
12527        &self.control_handle
12528    }
12529
12530    fn drop_without_shutdown(mut self) {
12531        // Safety: drops once, never accessed again due to mem::forget
12532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12533        // Prevent Drop from running (which would shut down the channel)
12534        std::mem::forget(self);
12535    }
12536}
12537
12538impl SecureMemGetPhysicalSecureHeapsResponder {
12539    /// Sends a response to the FIDL transaction.
12540    ///
12541    /// Sets the channel to shutdown if an error occurs.
12542    pub fn send(
12543        self,
12544        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12545    ) -> Result<(), fidl::Error> {
12546        let _result = self.send_raw(result);
12547        if _result.is_err() {
12548            self.control_handle.shutdown();
12549        }
12550        self.drop_without_shutdown();
12551        _result
12552    }
12553
12554    /// Similar to "send" but does not shutdown the channel if an error occurs.
12555    pub fn send_no_shutdown_on_err(
12556        self,
12557        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12558    ) -> Result<(), fidl::Error> {
12559        let _result = self.send_raw(result);
12560        self.drop_without_shutdown();
12561        _result
12562    }
12563
12564    fn send_raw(
12565        &self,
12566        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12567    ) -> Result<(), fidl::Error> {
12568        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12569            SecureMemGetPhysicalSecureHeapsResponse,
12570            Error,
12571        >>(
12572            fidl::encoding::FlexibleResult::new(result),
12573            self.tx_id,
12574            0x38716300592073e3,
12575            fidl::encoding::DynamicFlags::FLEXIBLE,
12576        )
12577    }
12578}
12579
12580#[must_use = "FIDL methods require a response to be sent"]
12581#[derive(Debug)]
12582pub struct SecureMemGetDynamicSecureHeapsResponder {
12583    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12584    tx_id: u32,
12585}
12586
12587/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12588/// if the responder is dropped without sending a response, so that the client
12589/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12590impl std::ops::Drop for SecureMemGetDynamicSecureHeapsResponder {
12591    fn drop(&mut self) {
12592        self.control_handle.shutdown();
12593        // Safety: drops once, never accessed again
12594        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12595    }
12596}
12597
12598impl fdomain_client::fidl::Responder for SecureMemGetDynamicSecureHeapsResponder {
12599    type ControlHandle = SecureMemControlHandle;
12600
12601    fn control_handle(&self) -> &SecureMemControlHandle {
12602        &self.control_handle
12603    }
12604
12605    fn drop_without_shutdown(mut self) {
12606        // Safety: drops once, never accessed again due to mem::forget
12607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12608        // Prevent Drop from running (which would shut down the channel)
12609        std::mem::forget(self);
12610    }
12611}
12612
12613impl SecureMemGetDynamicSecureHeapsResponder {
12614    /// Sends a response to the FIDL transaction.
12615    ///
12616    /// Sets the channel to shutdown if an error occurs.
12617    pub fn send(
12618        self,
12619        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12620    ) -> Result<(), fidl::Error> {
12621        let _result = self.send_raw(result);
12622        if _result.is_err() {
12623            self.control_handle.shutdown();
12624        }
12625        self.drop_without_shutdown();
12626        _result
12627    }
12628
12629    /// Similar to "send" but does not shutdown the channel if an error occurs.
12630    pub fn send_no_shutdown_on_err(
12631        self,
12632        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12633    ) -> Result<(), fidl::Error> {
12634        let _result = self.send_raw(result);
12635        self.drop_without_shutdown();
12636        _result
12637    }
12638
12639    fn send_raw(
12640        &self,
12641        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12642    ) -> Result<(), fidl::Error> {
12643        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12644            SecureMemGetDynamicSecureHeapsResponse,
12645            Error,
12646        >>(
12647            fidl::encoding::FlexibleResult::new(result),
12648            self.tx_id,
12649            0x1190847f99952834,
12650            fidl::encoding::DynamicFlags::FLEXIBLE,
12651        )
12652    }
12653}
12654
12655#[must_use = "FIDL methods require a response to be sent"]
12656#[derive(Debug)]
12657pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
12658    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12659    tx_id: u32,
12660}
12661
12662/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12663/// if the responder is dropped without sending a response, so that the client
12664/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12665impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
12666    fn drop(&mut self) {
12667        self.control_handle.shutdown();
12668        // Safety: drops once, never accessed again
12669        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12670    }
12671}
12672
12673impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
12674    type ControlHandle = SecureMemControlHandle;
12675
12676    fn control_handle(&self) -> &SecureMemControlHandle {
12677        &self.control_handle
12678    }
12679
12680    fn drop_without_shutdown(mut self) {
12681        // Safety: drops once, never accessed again due to mem::forget
12682        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12683        // Prevent Drop from running (which would shut down the channel)
12684        std::mem::forget(self);
12685    }
12686}
12687
12688impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
12689    /// Sends a response to the FIDL transaction.
12690    ///
12691    /// Sets the channel to shutdown if an error occurs.
12692    pub fn send(
12693        self,
12694        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12695    ) -> Result<(), fidl::Error> {
12696        let _result = self.send_raw(result);
12697        if _result.is_err() {
12698            self.control_handle.shutdown();
12699        }
12700        self.drop_without_shutdown();
12701        _result
12702    }
12703
12704    /// Similar to "send" but does not shutdown the channel if an error occurs.
12705    pub fn send_no_shutdown_on_err(
12706        self,
12707        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12708    ) -> Result<(), fidl::Error> {
12709        let _result = self.send_raw(result);
12710        self.drop_without_shutdown();
12711        _result
12712    }
12713
12714    fn send_raw(
12715        &self,
12716        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12717    ) -> Result<(), fidl::Error> {
12718        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12719            SecureMemGetPhysicalSecureHeapPropertiesResponse,
12720            Error,
12721        >>(
12722            fidl::encoding::FlexibleResult::new(result),
12723            self.tx_id,
12724            0xc6f06889009c7bc,
12725            fidl::encoding::DynamicFlags::FLEXIBLE,
12726        )
12727    }
12728}
12729
12730#[must_use = "FIDL methods require a response to be sent"]
12731#[derive(Debug)]
12732pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
12733    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12734    tx_id: u32,
12735}
12736
12737/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12738/// if the responder is dropped without sending a response, so that the client
12739/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12740impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
12741    fn drop(&mut self) {
12742        self.control_handle.shutdown();
12743        // Safety: drops once, never accessed again
12744        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12745    }
12746}
12747
12748impl fdomain_client::fidl::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
12749    type ControlHandle = SecureMemControlHandle;
12750
12751    fn control_handle(&self) -> &SecureMemControlHandle {
12752        &self.control_handle
12753    }
12754
12755    fn drop_without_shutdown(mut self) {
12756        // Safety: drops once, never accessed again due to mem::forget
12757        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12758        // Prevent Drop from running (which would shut down the channel)
12759        std::mem::forget(self);
12760    }
12761}
12762
12763impl SecureMemAddSecureHeapPhysicalRangeResponder {
12764    /// Sends a response to the FIDL transaction.
12765    ///
12766    /// Sets the channel to shutdown if an error occurs.
12767    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12768        let _result = self.send_raw(result);
12769        if _result.is_err() {
12770            self.control_handle.shutdown();
12771        }
12772        self.drop_without_shutdown();
12773        _result
12774    }
12775
12776    /// Similar to "send" but does not shutdown the channel if an error occurs.
12777    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12778        let _result = self.send_raw(result);
12779        self.drop_without_shutdown();
12780        _result
12781    }
12782
12783    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12784        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12785            fidl::encoding::EmptyStruct,
12786            Error,
12787        >>(
12788            fidl::encoding::FlexibleResult::new(result),
12789            self.tx_id,
12790            0x35f695b9b6c7217a,
12791            fidl::encoding::DynamicFlags::FLEXIBLE,
12792        )
12793    }
12794}
12795
12796#[must_use = "FIDL methods require a response to be sent"]
12797#[derive(Debug)]
12798pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
12799    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12800    tx_id: u32,
12801}
12802
12803/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12804/// if the responder is dropped without sending a response, so that the client
12805/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12806impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
12807    fn drop(&mut self) {
12808        self.control_handle.shutdown();
12809        // Safety: drops once, never accessed again
12810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12811    }
12812}
12813
12814impl fdomain_client::fidl::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
12815    type ControlHandle = SecureMemControlHandle;
12816
12817    fn control_handle(&self) -> &SecureMemControlHandle {
12818        &self.control_handle
12819    }
12820
12821    fn drop_without_shutdown(mut self) {
12822        // Safety: drops once, never accessed again due to mem::forget
12823        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12824        // Prevent Drop from running (which would shut down the channel)
12825        std::mem::forget(self);
12826    }
12827}
12828
12829impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
12830    /// Sends a response to the FIDL transaction.
12831    ///
12832    /// Sets the channel to shutdown if an error occurs.
12833    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12834        let _result = self.send_raw(result);
12835        if _result.is_err() {
12836            self.control_handle.shutdown();
12837        }
12838        self.drop_without_shutdown();
12839        _result
12840    }
12841
12842    /// Similar to "send" but does not shutdown the channel if an error occurs.
12843    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12844        let _result = self.send_raw(result);
12845        self.drop_without_shutdown();
12846        _result
12847    }
12848
12849    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12850        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12851            fidl::encoding::EmptyStruct,
12852            Error,
12853        >>(
12854            fidl::encoding::FlexibleResult::new(result),
12855            self.tx_id,
12856            0xeaa58c650264c9e,
12857            fidl::encoding::DynamicFlags::FLEXIBLE,
12858        )
12859    }
12860}
12861
12862#[must_use = "FIDL methods require a response to be sent"]
12863#[derive(Debug)]
12864pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
12865    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12866    tx_id: u32,
12867}
12868
12869/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12870/// if the responder is dropped without sending a response, so that the client
12871/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12872impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
12873    fn drop(&mut self) {
12874        self.control_handle.shutdown();
12875        // Safety: drops once, never accessed again
12876        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12877    }
12878}
12879
12880impl fdomain_client::fidl::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
12881    type ControlHandle = SecureMemControlHandle;
12882
12883    fn control_handle(&self) -> &SecureMemControlHandle {
12884        &self.control_handle
12885    }
12886
12887    fn drop_without_shutdown(mut self) {
12888        // Safety: drops once, never accessed again due to mem::forget
12889        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12890        // Prevent Drop from running (which would shut down the channel)
12891        std::mem::forget(self);
12892    }
12893}
12894
12895impl SecureMemModifySecureHeapPhysicalRangeResponder {
12896    /// Sends a response to the FIDL transaction.
12897    ///
12898    /// Sets the channel to shutdown if an error occurs.
12899    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12900        let _result = self.send_raw(result);
12901        if _result.is_err() {
12902            self.control_handle.shutdown();
12903        }
12904        self.drop_without_shutdown();
12905        _result
12906    }
12907
12908    /// Similar to "send" but does not shutdown the channel if an error occurs.
12909    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12910        let _result = self.send_raw(result);
12911        self.drop_without_shutdown();
12912        _result
12913    }
12914
12915    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12916        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12917            fidl::encoding::EmptyStruct,
12918            Error,
12919        >>(
12920            fidl::encoding::FlexibleResult::new(result),
12921            self.tx_id,
12922            0x60b7448aa1187734,
12923            fidl::encoding::DynamicFlags::FLEXIBLE,
12924        )
12925    }
12926}
12927
12928#[must_use = "FIDL methods require a response to be sent"]
12929#[derive(Debug)]
12930pub struct SecureMemZeroSubRangeResponder {
12931    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12932    tx_id: u32,
12933}
12934
12935/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12936/// if the responder is dropped without sending a response, so that the client
12937/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12938impl std::ops::Drop for SecureMemZeroSubRangeResponder {
12939    fn drop(&mut self) {
12940        self.control_handle.shutdown();
12941        // Safety: drops once, never accessed again
12942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12943    }
12944}
12945
12946impl fdomain_client::fidl::Responder for SecureMemZeroSubRangeResponder {
12947    type ControlHandle = SecureMemControlHandle;
12948
12949    fn control_handle(&self) -> &SecureMemControlHandle {
12950        &self.control_handle
12951    }
12952
12953    fn drop_without_shutdown(mut self) {
12954        // Safety: drops once, never accessed again due to mem::forget
12955        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12956        // Prevent Drop from running (which would shut down the channel)
12957        std::mem::forget(self);
12958    }
12959}
12960
12961impl SecureMemZeroSubRangeResponder {
12962    /// Sends a response to the FIDL transaction.
12963    ///
12964    /// Sets the channel to shutdown if an error occurs.
12965    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12966        let _result = self.send_raw(result);
12967        if _result.is_err() {
12968            self.control_handle.shutdown();
12969        }
12970        self.drop_without_shutdown();
12971        _result
12972    }
12973
12974    /// Similar to "send" but does not shutdown the channel if an error occurs.
12975    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12976        let _result = self.send_raw(result);
12977        self.drop_without_shutdown();
12978        _result
12979    }
12980
12981    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12982        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12983            fidl::encoding::EmptyStruct,
12984            Error,
12985        >>(
12986            fidl::encoding::FlexibleResult::new(result),
12987            self.tx_id,
12988            0x5b25b7901a385ce5,
12989            fidl::encoding::DynamicFlags::FLEXIBLE,
12990        )
12991    }
12992}
12993
12994mod internal {
12995    use super::*;
12996
12997    impl AllocatorAllocateNonSharedCollectionRequest {
12998        #[inline(always)]
12999        fn max_ordinal_present(&self) -> u64 {
13000            if let Some(_) = self.collection_request {
13001                return 1;
13002            }
13003            0
13004        }
13005    }
13006
13007    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
13008        type Borrowed<'a> = &'a mut Self;
13009        fn take_or_borrow<'a>(
13010            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13011        ) -> Self::Borrowed<'a> {
13012            value
13013        }
13014    }
13015
13016    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
13017        type Owned = Self;
13018
13019        #[inline(always)]
13020        fn inline_align(_context: fidl::encoding::Context) -> usize {
13021            8
13022        }
13023
13024        #[inline(always)]
13025        fn inline_size(_context: fidl::encoding::Context) -> usize {
13026            16
13027        }
13028    }
13029
13030    unsafe impl
13031        fidl::encoding::Encode<
13032            AllocatorAllocateNonSharedCollectionRequest,
13033            fdomain_client::fidl::FDomainResourceDialect,
13034        > for &mut AllocatorAllocateNonSharedCollectionRequest
13035    {
13036        unsafe fn encode(
13037            self,
13038            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13039            offset: usize,
13040            mut depth: fidl::encoding::Depth,
13041        ) -> fidl::Result<()> {
13042            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
13043            // Vector header
13044            let max_ordinal: u64 = self.max_ordinal_present();
13045            encoder.write_num(max_ordinal, offset);
13046            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13047            // Calling encoder.out_of_line_offset(0) is not allowed.
13048            if max_ordinal == 0 {
13049                return Ok(());
13050            }
13051            depth.increment()?;
13052            let envelope_size = 8;
13053            let bytes_len = max_ordinal as usize * envelope_size;
13054            #[allow(unused_variables)]
13055            let offset = encoder.out_of_line_offset(bytes_len);
13056            let mut _prev_end_offset: usize = 0;
13057            if 1 > max_ordinal {
13058                return Ok(());
13059            }
13060
13061            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13062            // are envelope_size bytes.
13063            let cur_offset: usize = (1 - 1) * envelope_size;
13064
13065            // Zero reserved fields.
13066            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13067
13068            // Safety:
13069            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13070            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13071            //   envelope_size bytes, there is always sufficient room.
13072            fidl::encoding::encode_in_envelope_optional::<
13073                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
13074                fdomain_client::fidl::FDomainResourceDialect,
13075            >(
13076                self.collection_request.as_mut().map(
13077                    <fidl::encoding::Endpoint<
13078                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13079                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13080                ),
13081                encoder,
13082                offset + cur_offset,
13083                depth,
13084            )?;
13085
13086            _prev_end_offset = cur_offset + envelope_size;
13087
13088            Ok(())
13089        }
13090    }
13091
13092    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13093        for AllocatorAllocateNonSharedCollectionRequest
13094    {
13095        #[inline(always)]
13096        fn new_empty() -> Self {
13097            Self::default()
13098        }
13099
13100        unsafe fn decode(
13101            &mut self,
13102            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13103            offset: usize,
13104            mut depth: fidl::encoding::Depth,
13105        ) -> fidl::Result<()> {
13106            decoder.debug_check_bounds::<Self>(offset);
13107            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13108                None => return Err(fidl::Error::NotNullable),
13109                Some(len) => len,
13110            };
13111            // Calling decoder.out_of_line_offset(0) is not allowed.
13112            if len == 0 {
13113                return Ok(());
13114            };
13115            depth.increment()?;
13116            let envelope_size = 8;
13117            let bytes_len = len * envelope_size;
13118            let offset = decoder.out_of_line_offset(bytes_len)?;
13119            // Decode the envelope for each type.
13120            let mut _next_ordinal_to_read = 0;
13121            let mut next_offset = offset;
13122            let end_offset = offset + bytes_len;
13123            _next_ordinal_to_read += 1;
13124            if next_offset >= end_offset {
13125                return Ok(());
13126            }
13127
13128            // Decode unknown envelopes for gaps in ordinals.
13129            while _next_ordinal_to_read < 1 {
13130                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13131                _next_ordinal_to_read += 1;
13132                next_offset += envelope_size;
13133            }
13134
13135            let next_out_of_line = decoder.next_out_of_line();
13136            let handles_before = decoder.remaining_handles();
13137            if let Some((inlined, num_bytes, num_handles)) =
13138                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13139            {
13140                let member_inline_size = <fidl::encoding::Endpoint<
13141                    fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13142                > as fidl::encoding::TypeMarker>::inline_size(
13143                    decoder.context
13144                );
13145                if inlined != (member_inline_size <= 4) {
13146                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13147                }
13148                let inner_offset;
13149                let mut inner_depth = depth.clone();
13150                if inlined {
13151                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13152                    inner_offset = next_offset;
13153                } else {
13154                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13155                    inner_depth.increment()?;
13156                }
13157                let val_ref = self.collection_request.get_or_insert_with(|| {
13158                    fidl::new_empty!(
13159                        fidl::encoding::Endpoint<
13160                            fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13161                        >,
13162                        fdomain_client::fidl::FDomainResourceDialect
13163                    )
13164                });
13165                fidl::decode!(
13166                    fidl::encoding::Endpoint<
13167                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13168                    >,
13169                    fdomain_client::fidl::FDomainResourceDialect,
13170                    val_ref,
13171                    decoder,
13172                    inner_offset,
13173                    inner_depth
13174                )?;
13175                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13176                {
13177                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13178                }
13179                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13180                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13181                }
13182            }
13183
13184            next_offset += envelope_size;
13185
13186            // Decode the remaining unknown envelopes.
13187            while next_offset < end_offset {
13188                _next_ordinal_to_read += 1;
13189                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13190                next_offset += envelope_size;
13191            }
13192
13193            Ok(())
13194        }
13195    }
13196
13197    impl AllocatorAllocateSharedCollectionRequest {
13198        #[inline(always)]
13199        fn max_ordinal_present(&self) -> u64 {
13200            if let Some(_) = self.token_request {
13201                return 1;
13202            }
13203            0
13204        }
13205    }
13206
13207    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
13208        type Borrowed<'a> = &'a mut Self;
13209        fn take_or_borrow<'a>(
13210            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13211        ) -> Self::Borrowed<'a> {
13212            value
13213        }
13214    }
13215
13216    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
13217        type Owned = Self;
13218
13219        #[inline(always)]
13220        fn inline_align(_context: fidl::encoding::Context) -> usize {
13221            8
13222        }
13223
13224        #[inline(always)]
13225        fn inline_size(_context: fidl::encoding::Context) -> usize {
13226            16
13227        }
13228    }
13229
13230    unsafe impl
13231        fidl::encoding::Encode<
13232            AllocatorAllocateSharedCollectionRequest,
13233            fdomain_client::fidl::FDomainResourceDialect,
13234        > for &mut AllocatorAllocateSharedCollectionRequest
13235    {
13236        unsafe fn encode(
13237            self,
13238            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13239            offset: usize,
13240            mut depth: fidl::encoding::Depth,
13241        ) -> fidl::Result<()> {
13242            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
13243            // Vector header
13244            let max_ordinal: u64 = self.max_ordinal_present();
13245            encoder.write_num(max_ordinal, offset);
13246            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13247            // Calling encoder.out_of_line_offset(0) is not allowed.
13248            if max_ordinal == 0 {
13249                return Ok(());
13250            }
13251            depth.increment()?;
13252            let envelope_size = 8;
13253            let bytes_len = max_ordinal as usize * envelope_size;
13254            #[allow(unused_variables)]
13255            let offset = encoder.out_of_line_offset(bytes_len);
13256            let mut _prev_end_offset: usize = 0;
13257            if 1 > max_ordinal {
13258                return Ok(());
13259            }
13260
13261            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13262            // are envelope_size bytes.
13263            let cur_offset: usize = (1 - 1) * envelope_size;
13264
13265            // Zero reserved fields.
13266            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13267
13268            // Safety:
13269            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13270            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13271            //   envelope_size bytes, there is always sufficient room.
13272            fidl::encoding::encode_in_envelope_optional::<
13273                fidl::encoding::Endpoint<
13274                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13275                >,
13276                fdomain_client::fidl::FDomainResourceDialect,
13277            >(
13278                self.token_request.as_mut().map(
13279                    <fidl::encoding::Endpoint<
13280                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13281                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13282                ),
13283                encoder,
13284                offset + cur_offset,
13285                depth,
13286            )?;
13287
13288            _prev_end_offset = cur_offset + envelope_size;
13289
13290            Ok(())
13291        }
13292    }
13293
13294    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13295        for AllocatorAllocateSharedCollectionRequest
13296    {
13297        #[inline(always)]
13298        fn new_empty() -> Self {
13299            Self::default()
13300        }
13301
13302        unsafe fn decode(
13303            &mut self,
13304            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13305            offset: usize,
13306            mut depth: fidl::encoding::Depth,
13307        ) -> fidl::Result<()> {
13308            decoder.debug_check_bounds::<Self>(offset);
13309            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13310                None => return Err(fidl::Error::NotNullable),
13311                Some(len) => len,
13312            };
13313            // Calling decoder.out_of_line_offset(0) is not allowed.
13314            if len == 0 {
13315                return Ok(());
13316            };
13317            depth.increment()?;
13318            let envelope_size = 8;
13319            let bytes_len = len * envelope_size;
13320            let offset = decoder.out_of_line_offset(bytes_len)?;
13321            // Decode the envelope for each type.
13322            let mut _next_ordinal_to_read = 0;
13323            let mut next_offset = offset;
13324            let end_offset = offset + bytes_len;
13325            _next_ordinal_to_read += 1;
13326            if next_offset >= end_offset {
13327                return Ok(());
13328            }
13329
13330            // Decode unknown envelopes for gaps in ordinals.
13331            while _next_ordinal_to_read < 1 {
13332                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13333                _next_ordinal_to_read += 1;
13334                next_offset += envelope_size;
13335            }
13336
13337            let next_out_of_line = decoder.next_out_of_line();
13338            let handles_before = decoder.remaining_handles();
13339            if let Some((inlined, num_bytes, num_handles)) =
13340                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13341            {
13342                let member_inline_size = <fidl::encoding::Endpoint<
13343                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13344                > as fidl::encoding::TypeMarker>::inline_size(
13345                    decoder.context
13346                );
13347                if inlined != (member_inline_size <= 4) {
13348                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13349                }
13350                let inner_offset;
13351                let mut inner_depth = depth.clone();
13352                if inlined {
13353                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13354                    inner_offset = next_offset;
13355                } else {
13356                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13357                    inner_depth.increment()?;
13358                }
13359                let val_ref = self.token_request.get_or_insert_with(|| {
13360                    fidl::new_empty!(
13361                        fidl::encoding::Endpoint<
13362                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13363                        >,
13364                        fdomain_client::fidl::FDomainResourceDialect
13365                    )
13366                });
13367                fidl::decode!(
13368                    fidl::encoding::Endpoint<
13369                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13370                    >,
13371                    fdomain_client::fidl::FDomainResourceDialect,
13372                    val_ref,
13373                    decoder,
13374                    inner_offset,
13375                    inner_depth
13376                )?;
13377                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13378                {
13379                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13380                }
13381                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13382                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13383                }
13384            }
13385
13386            next_offset += envelope_size;
13387
13388            // Decode the remaining unknown envelopes.
13389            while next_offset < end_offset {
13390                _next_ordinal_to_read += 1;
13391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13392                next_offset += envelope_size;
13393            }
13394
13395            Ok(())
13396        }
13397    }
13398
13399    impl AllocatorBindSharedCollectionRequest {
13400        #[inline(always)]
13401        fn max_ordinal_present(&self) -> u64 {
13402            if let Some(_) = self.buffer_collection_request {
13403                return 2;
13404            }
13405            if let Some(_) = self.token {
13406                return 1;
13407            }
13408            0
13409        }
13410    }
13411
13412    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
13413        type Borrowed<'a> = &'a mut Self;
13414        fn take_or_borrow<'a>(
13415            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13416        ) -> Self::Borrowed<'a> {
13417            value
13418        }
13419    }
13420
13421    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
13422        type Owned = Self;
13423
13424        #[inline(always)]
13425        fn inline_align(_context: fidl::encoding::Context) -> usize {
13426            8
13427        }
13428
13429        #[inline(always)]
13430        fn inline_size(_context: fidl::encoding::Context) -> usize {
13431            16
13432        }
13433    }
13434
13435    unsafe impl
13436        fidl::encoding::Encode<
13437            AllocatorBindSharedCollectionRequest,
13438            fdomain_client::fidl::FDomainResourceDialect,
13439        > for &mut AllocatorBindSharedCollectionRequest
13440    {
13441        unsafe fn encode(
13442            self,
13443            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13444            offset: usize,
13445            mut depth: fidl::encoding::Depth,
13446        ) -> fidl::Result<()> {
13447            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
13448            // Vector header
13449            let max_ordinal: u64 = self.max_ordinal_present();
13450            encoder.write_num(max_ordinal, offset);
13451            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13452            // Calling encoder.out_of_line_offset(0) is not allowed.
13453            if max_ordinal == 0 {
13454                return Ok(());
13455            }
13456            depth.increment()?;
13457            let envelope_size = 8;
13458            let bytes_len = max_ordinal as usize * envelope_size;
13459            #[allow(unused_variables)]
13460            let offset = encoder.out_of_line_offset(bytes_len);
13461            let mut _prev_end_offset: usize = 0;
13462            if 1 > max_ordinal {
13463                return Ok(());
13464            }
13465
13466            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13467            // are envelope_size bytes.
13468            let cur_offset: usize = (1 - 1) * envelope_size;
13469
13470            // Zero reserved fields.
13471            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13472
13473            // Safety:
13474            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13475            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13476            //   envelope_size bytes, there is always sufficient room.
13477            fidl::encoding::encode_in_envelope_optional::<
13478                fidl::encoding::Endpoint<
13479                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13480                >,
13481                fdomain_client::fidl::FDomainResourceDialect,
13482            >(
13483                self.token.as_mut().map(
13484                    <fidl::encoding::Endpoint<
13485                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13486                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13487                ),
13488                encoder,
13489                offset + cur_offset,
13490                depth,
13491            )?;
13492
13493            _prev_end_offset = cur_offset + envelope_size;
13494            if 2 > max_ordinal {
13495                return Ok(());
13496            }
13497
13498            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13499            // are envelope_size bytes.
13500            let cur_offset: usize = (2 - 1) * envelope_size;
13501
13502            // Zero reserved fields.
13503            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13504
13505            // Safety:
13506            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13507            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13508            //   envelope_size bytes, there is always sufficient room.
13509            fidl::encoding::encode_in_envelope_optional::<
13510                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
13511                fdomain_client::fidl::FDomainResourceDialect,
13512            >(
13513                self.buffer_collection_request.as_mut().map(
13514                    <fidl::encoding::Endpoint<
13515                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13516                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13517                ),
13518                encoder,
13519                offset + cur_offset,
13520                depth,
13521            )?;
13522
13523            _prev_end_offset = cur_offset + envelope_size;
13524
13525            Ok(())
13526        }
13527    }
13528
13529    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13530        for AllocatorBindSharedCollectionRequest
13531    {
13532        #[inline(always)]
13533        fn new_empty() -> Self {
13534            Self::default()
13535        }
13536
13537        unsafe fn decode(
13538            &mut self,
13539            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13540            offset: usize,
13541            mut depth: fidl::encoding::Depth,
13542        ) -> fidl::Result<()> {
13543            decoder.debug_check_bounds::<Self>(offset);
13544            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13545                None => return Err(fidl::Error::NotNullable),
13546                Some(len) => len,
13547            };
13548            // Calling decoder.out_of_line_offset(0) is not allowed.
13549            if len == 0 {
13550                return Ok(());
13551            };
13552            depth.increment()?;
13553            let envelope_size = 8;
13554            let bytes_len = len * envelope_size;
13555            let offset = decoder.out_of_line_offset(bytes_len)?;
13556            // Decode the envelope for each type.
13557            let mut _next_ordinal_to_read = 0;
13558            let mut next_offset = offset;
13559            let end_offset = offset + bytes_len;
13560            _next_ordinal_to_read += 1;
13561            if next_offset >= end_offset {
13562                return Ok(());
13563            }
13564
13565            // Decode unknown envelopes for gaps in ordinals.
13566            while _next_ordinal_to_read < 1 {
13567                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13568                _next_ordinal_to_read += 1;
13569                next_offset += envelope_size;
13570            }
13571
13572            let next_out_of_line = decoder.next_out_of_line();
13573            let handles_before = decoder.remaining_handles();
13574            if let Some((inlined, num_bytes, num_handles)) =
13575                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13576            {
13577                let member_inline_size = <fidl::encoding::Endpoint<
13578                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13579                > as fidl::encoding::TypeMarker>::inline_size(
13580                    decoder.context
13581                );
13582                if inlined != (member_inline_size <= 4) {
13583                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13584                }
13585                let inner_offset;
13586                let mut inner_depth = depth.clone();
13587                if inlined {
13588                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13589                    inner_offset = next_offset;
13590                } else {
13591                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13592                    inner_depth.increment()?;
13593                }
13594                let val_ref = self.token.get_or_insert_with(|| {
13595                    fidl::new_empty!(
13596                        fidl::encoding::Endpoint<
13597                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13598                        >,
13599                        fdomain_client::fidl::FDomainResourceDialect
13600                    )
13601                });
13602                fidl::decode!(
13603                    fidl::encoding::Endpoint<
13604                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13605                    >,
13606                    fdomain_client::fidl::FDomainResourceDialect,
13607                    val_ref,
13608                    decoder,
13609                    inner_offset,
13610                    inner_depth
13611                )?;
13612                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13613                {
13614                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13615                }
13616                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13617                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13618                }
13619            }
13620
13621            next_offset += envelope_size;
13622            _next_ordinal_to_read += 1;
13623            if next_offset >= end_offset {
13624                return Ok(());
13625            }
13626
13627            // Decode unknown envelopes for gaps in ordinals.
13628            while _next_ordinal_to_read < 2 {
13629                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13630                _next_ordinal_to_read += 1;
13631                next_offset += envelope_size;
13632            }
13633
13634            let next_out_of_line = decoder.next_out_of_line();
13635            let handles_before = decoder.remaining_handles();
13636            if let Some((inlined, num_bytes, num_handles)) =
13637                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13638            {
13639                let member_inline_size = <fidl::encoding::Endpoint<
13640                    fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13641                > as fidl::encoding::TypeMarker>::inline_size(
13642                    decoder.context
13643                );
13644                if inlined != (member_inline_size <= 4) {
13645                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13646                }
13647                let inner_offset;
13648                let mut inner_depth = depth.clone();
13649                if inlined {
13650                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13651                    inner_offset = next_offset;
13652                } else {
13653                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13654                    inner_depth.increment()?;
13655                }
13656                let val_ref = self.buffer_collection_request.get_or_insert_with(|| {
13657                    fidl::new_empty!(
13658                        fidl::encoding::Endpoint<
13659                            fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13660                        >,
13661                        fdomain_client::fidl::FDomainResourceDialect
13662                    )
13663                });
13664                fidl::decode!(
13665                    fidl::encoding::Endpoint<
13666                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13667                    >,
13668                    fdomain_client::fidl::FDomainResourceDialect,
13669                    val_ref,
13670                    decoder,
13671                    inner_offset,
13672                    inner_depth
13673                )?;
13674                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13675                {
13676                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13677                }
13678                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13679                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13680                }
13681            }
13682
13683            next_offset += envelope_size;
13684
13685            // Decode the remaining unknown envelopes.
13686            while next_offset < end_offset {
13687                _next_ordinal_to_read += 1;
13688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13689                next_offset += envelope_size;
13690            }
13691
13692            Ok(())
13693        }
13694    }
13695
13696    impl AllocatorGetVmoInfoRequest {
13697        #[inline(always)]
13698        fn max_ordinal_present(&self) -> u64 {
13699            if let Some(_) = self.vmo {
13700                return 1;
13701            }
13702            0
13703        }
13704    }
13705
13706    impl fidl::encoding::ResourceTypeMarker for AllocatorGetVmoInfoRequest {
13707        type Borrowed<'a> = &'a mut Self;
13708        fn take_or_borrow<'a>(
13709            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13710        ) -> Self::Borrowed<'a> {
13711            value
13712        }
13713    }
13714
13715    unsafe impl fidl::encoding::TypeMarker for AllocatorGetVmoInfoRequest {
13716        type Owned = Self;
13717
13718        #[inline(always)]
13719        fn inline_align(_context: fidl::encoding::Context) -> usize {
13720            8
13721        }
13722
13723        #[inline(always)]
13724        fn inline_size(_context: fidl::encoding::Context) -> usize {
13725            16
13726        }
13727    }
13728
13729    unsafe impl
13730        fidl::encoding::Encode<
13731            AllocatorGetVmoInfoRequest,
13732            fdomain_client::fidl::FDomainResourceDialect,
13733        > for &mut AllocatorGetVmoInfoRequest
13734    {
13735        unsafe fn encode(
13736            self,
13737            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13738            offset: usize,
13739            mut depth: fidl::encoding::Depth,
13740        ) -> fidl::Result<()> {
13741            encoder.debug_check_bounds::<AllocatorGetVmoInfoRequest>(offset);
13742            // Vector header
13743            let max_ordinal: u64 = self.max_ordinal_present();
13744            encoder.write_num(max_ordinal, offset);
13745            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13746            // Calling encoder.out_of_line_offset(0) is not allowed.
13747            if max_ordinal == 0 {
13748                return Ok(());
13749            }
13750            depth.increment()?;
13751            let envelope_size = 8;
13752            let bytes_len = max_ordinal as usize * envelope_size;
13753            #[allow(unused_variables)]
13754            let offset = encoder.out_of_line_offset(bytes_len);
13755            let mut _prev_end_offset: usize = 0;
13756            if 1 > max_ordinal {
13757                return Ok(());
13758            }
13759
13760            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13761            // are envelope_size bytes.
13762            let cur_offset: usize = (1 - 1) * envelope_size;
13763
13764            // Zero reserved fields.
13765            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13766
13767            // Safety:
13768            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13769            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13770            //   envelope_size bytes, there is always sufficient room.
13771            fidl::encoding::encode_in_envelope_optional::<
13772                fidl::encoding::HandleType<
13773                    fdomain_client::Vmo,
13774                    { fidl::ObjectType::VMO.into_raw() },
13775                    2147483648,
13776                >,
13777                fdomain_client::fidl::FDomainResourceDialect,
13778            >(
13779                self.vmo.as_mut().map(
13780                    <fidl::encoding::HandleType<
13781                        fdomain_client::Vmo,
13782                        { fidl::ObjectType::VMO.into_raw() },
13783                        2147483648,
13784                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13785                ),
13786                encoder,
13787                offset + cur_offset,
13788                depth,
13789            )?;
13790
13791            _prev_end_offset = cur_offset + envelope_size;
13792
13793            Ok(())
13794        }
13795    }
13796
13797    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13798        for AllocatorGetVmoInfoRequest
13799    {
13800        #[inline(always)]
13801        fn new_empty() -> Self {
13802            Self::default()
13803        }
13804
13805        unsafe fn decode(
13806            &mut self,
13807            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13808            offset: usize,
13809            mut depth: fidl::encoding::Depth,
13810        ) -> fidl::Result<()> {
13811            decoder.debug_check_bounds::<Self>(offset);
13812            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13813                None => return Err(fidl::Error::NotNullable),
13814                Some(len) => len,
13815            };
13816            // Calling decoder.out_of_line_offset(0) is not allowed.
13817            if len == 0 {
13818                return Ok(());
13819            };
13820            depth.increment()?;
13821            let envelope_size = 8;
13822            let bytes_len = len * envelope_size;
13823            let offset = decoder.out_of_line_offset(bytes_len)?;
13824            // Decode the envelope for each type.
13825            let mut _next_ordinal_to_read = 0;
13826            let mut next_offset = offset;
13827            let end_offset = offset + bytes_len;
13828            _next_ordinal_to_read += 1;
13829            if next_offset >= end_offset {
13830                return Ok(());
13831            }
13832
13833            // Decode unknown envelopes for gaps in ordinals.
13834            while _next_ordinal_to_read < 1 {
13835                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13836                _next_ordinal_to_read += 1;
13837                next_offset += envelope_size;
13838            }
13839
13840            let next_out_of_line = decoder.next_out_of_line();
13841            let handles_before = decoder.remaining_handles();
13842            if let Some((inlined, num_bytes, num_handles)) =
13843                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13844            {
13845                let member_inline_size = <fidl::encoding::HandleType<
13846                    fdomain_client::Vmo,
13847                    { fidl::ObjectType::VMO.into_raw() },
13848                    2147483648,
13849                > as fidl::encoding::TypeMarker>::inline_size(
13850                    decoder.context
13851                );
13852                if inlined != (member_inline_size <= 4) {
13853                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13854                }
13855                let inner_offset;
13856                let mut inner_depth = depth.clone();
13857                if inlined {
13858                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13859                    inner_offset = next_offset;
13860                } else {
13861                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13862                    inner_depth.increment()?;
13863                }
13864                let val_ref =
13865                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
13866                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
13867                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13868                {
13869                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13870                }
13871                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13872                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13873                }
13874            }
13875
13876            next_offset += envelope_size;
13877
13878            // Decode the remaining unknown envelopes.
13879            while next_offset < end_offset {
13880                _next_ordinal_to_read += 1;
13881                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13882                next_offset += envelope_size;
13883            }
13884
13885            Ok(())
13886        }
13887    }
13888
13889    impl AllocatorGetVmoInfoResponse {
13890        #[inline(always)]
13891        fn max_ordinal_present(&self) -> u64 {
13892            if let Some(_) = self.close_weak_asap {
13893                return 3;
13894            }
13895            if let Some(_) = self.buffer_index {
13896                return 2;
13897            }
13898            if let Some(_) = self.buffer_collection_id {
13899                return 1;
13900            }
13901            0
13902        }
13903    }
13904
13905    impl fidl::encoding::ResourceTypeMarker for AllocatorGetVmoInfoResponse {
13906        type Borrowed<'a> = &'a mut Self;
13907        fn take_or_borrow<'a>(
13908            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13909        ) -> Self::Borrowed<'a> {
13910            value
13911        }
13912    }
13913
13914    unsafe impl fidl::encoding::TypeMarker for AllocatorGetVmoInfoResponse {
13915        type Owned = Self;
13916
13917        #[inline(always)]
13918        fn inline_align(_context: fidl::encoding::Context) -> usize {
13919            8
13920        }
13921
13922        #[inline(always)]
13923        fn inline_size(_context: fidl::encoding::Context) -> usize {
13924            16
13925        }
13926    }
13927
13928    unsafe impl
13929        fidl::encoding::Encode<
13930            AllocatorGetVmoInfoResponse,
13931            fdomain_client::fidl::FDomainResourceDialect,
13932        > for &mut AllocatorGetVmoInfoResponse
13933    {
13934        unsafe fn encode(
13935            self,
13936            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13937            offset: usize,
13938            mut depth: fidl::encoding::Depth,
13939        ) -> fidl::Result<()> {
13940            encoder.debug_check_bounds::<AllocatorGetVmoInfoResponse>(offset);
13941            // Vector header
13942            let max_ordinal: u64 = self.max_ordinal_present();
13943            encoder.write_num(max_ordinal, offset);
13944            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13945            // Calling encoder.out_of_line_offset(0) is not allowed.
13946            if max_ordinal == 0 {
13947                return Ok(());
13948            }
13949            depth.increment()?;
13950            let envelope_size = 8;
13951            let bytes_len = max_ordinal as usize * envelope_size;
13952            #[allow(unused_variables)]
13953            let offset = encoder.out_of_line_offset(bytes_len);
13954            let mut _prev_end_offset: usize = 0;
13955            if 1 > max_ordinal {
13956                return Ok(());
13957            }
13958
13959            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13960            // are envelope_size bytes.
13961            let cur_offset: usize = (1 - 1) * envelope_size;
13962
13963            // Zero reserved fields.
13964            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13965
13966            // Safety:
13967            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13968            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13969            //   envelope_size bytes, there is always sufficient room.
13970            fidl::encoding::encode_in_envelope_optional::<
13971                u64,
13972                fdomain_client::fidl::FDomainResourceDialect,
13973            >(
13974                self.buffer_collection_id
13975                    .as_ref()
13976                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
13977                encoder,
13978                offset + cur_offset,
13979                depth,
13980            )?;
13981
13982            _prev_end_offset = cur_offset + envelope_size;
13983            if 2 > max_ordinal {
13984                return Ok(());
13985            }
13986
13987            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13988            // are envelope_size bytes.
13989            let cur_offset: usize = (2 - 1) * envelope_size;
13990
13991            // Zero reserved fields.
13992            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13993
13994            // Safety:
13995            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13996            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13997            //   envelope_size bytes, there is always sufficient room.
13998            fidl::encoding::encode_in_envelope_optional::<
13999                u64,
14000                fdomain_client::fidl::FDomainResourceDialect,
14001            >(
14002                self.buffer_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
14003                encoder,
14004                offset + cur_offset,
14005                depth,
14006            )?;
14007
14008            _prev_end_offset = cur_offset + envelope_size;
14009            if 3 > max_ordinal {
14010                return Ok(());
14011            }
14012
14013            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14014            // are envelope_size bytes.
14015            let cur_offset: usize = (3 - 1) * envelope_size;
14016
14017            // Zero reserved fields.
14018            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14019
14020            // Safety:
14021            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14022            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14023            //   envelope_size bytes, there is always sufficient room.
14024            fidl::encoding::encode_in_envelope_optional::<
14025                fidl::encoding::HandleType<
14026                    fdomain_client::EventPair,
14027                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14028                    2147483648,
14029                >,
14030                fdomain_client::fidl::FDomainResourceDialect,
14031            >(
14032                self.close_weak_asap.as_mut().map(
14033                    <fidl::encoding::HandleType<
14034                        fdomain_client::EventPair,
14035                        { fidl::ObjectType::EVENTPAIR.into_raw() },
14036                        2147483648,
14037                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14038                ),
14039                encoder,
14040                offset + cur_offset,
14041                depth,
14042            )?;
14043
14044            _prev_end_offset = cur_offset + envelope_size;
14045
14046            Ok(())
14047        }
14048    }
14049
14050    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14051        for AllocatorGetVmoInfoResponse
14052    {
14053        #[inline(always)]
14054        fn new_empty() -> Self {
14055            Self::default()
14056        }
14057
14058        unsafe fn decode(
14059            &mut self,
14060            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14061            offset: usize,
14062            mut depth: fidl::encoding::Depth,
14063        ) -> fidl::Result<()> {
14064            decoder.debug_check_bounds::<Self>(offset);
14065            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14066                None => return Err(fidl::Error::NotNullable),
14067                Some(len) => len,
14068            };
14069            // Calling decoder.out_of_line_offset(0) is not allowed.
14070            if len == 0 {
14071                return Ok(());
14072            };
14073            depth.increment()?;
14074            let envelope_size = 8;
14075            let bytes_len = len * envelope_size;
14076            let offset = decoder.out_of_line_offset(bytes_len)?;
14077            // Decode the envelope for each type.
14078            let mut _next_ordinal_to_read = 0;
14079            let mut next_offset = offset;
14080            let end_offset = offset + bytes_len;
14081            _next_ordinal_to_read += 1;
14082            if next_offset >= end_offset {
14083                return Ok(());
14084            }
14085
14086            // Decode unknown envelopes for gaps in ordinals.
14087            while _next_ordinal_to_read < 1 {
14088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14089                _next_ordinal_to_read += 1;
14090                next_offset += envelope_size;
14091            }
14092
14093            let next_out_of_line = decoder.next_out_of_line();
14094            let handles_before = decoder.remaining_handles();
14095            if let Some((inlined, num_bytes, num_handles)) =
14096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14097            {
14098                let member_inline_size =
14099                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14100                if inlined != (member_inline_size <= 4) {
14101                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14102                }
14103                let inner_offset;
14104                let mut inner_depth = depth.clone();
14105                if inlined {
14106                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14107                    inner_offset = next_offset;
14108                } else {
14109                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14110                    inner_depth.increment()?;
14111                }
14112                let val_ref = self.buffer_collection_id.get_or_insert_with(|| {
14113                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
14114                });
14115                fidl::decode!(
14116                    u64,
14117                    fdomain_client::fidl::FDomainResourceDialect,
14118                    val_ref,
14119                    decoder,
14120                    inner_offset,
14121                    inner_depth
14122                )?;
14123                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14124                {
14125                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14126                }
14127                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14128                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14129                }
14130            }
14131
14132            next_offset += envelope_size;
14133            _next_ordinal_to_read += 1;
14134            if next_offset >= end_offset {
14135                return Ok(());
14136            }
14137
14138            // Decode unknown envelopes for gaps in ordinals.
14139            while _next_ordinal_to_read < 2 {
14140                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14141                _next_ordinal_to_read += 1;
14142                next_offset += envelope_size;
14143            }
14144
14145            let next_out_of_line = decoder.next_out_of_line();
14146            let handles_before = decoder.remaining_handles();
14147            if let Some((inlined, num_bytes, num_handles)) =
14148                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14149            {
14150                let member_inline_size =
14151                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14152                if inlined != (member_inline_size <= 4) {
14153                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14154                }
14155                let inner_offset;
14156                let mut inner_depth = depth.clone();
14157                if inlined {
14158                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14159                    inner_offset = next_offset;
14160                } else {
14161                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14162                    inner_depth.increment()?;
14163                }
14164                let val_ref = self.buffer_index.get_or_insert_with(|| {
14165                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
14166                });
14167                fidl::decode!(
14168                    u64,
14169                    fdomain_client::fidl::FDomainResourceDialect,
14170                    val_ref,
14171                    decoder,
14172                    inner_offset,
14173                    inner_depth
14174                )?;
14175                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14176                {
14177                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14178                }
14179                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14180                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14181                }
14182            }
14183
14184            next_offset += envelope_size;
14185            _next_ordinal_to_read += 1;
14186            if next_offset >= end_offset {
14187                return Ok(());
14188            }
14189
14190            // Decode unknown envelopes for gaps in ordinals.
14191            while _next_ordinal_to_read < 3 {
14192                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14193                _next_ordinal_to_read += 1;
14194                next_offset += envelope_size;
14195            }
14196
14197            let next_out_of_line = decoder.next_out_of_line();
14198            let handles_before = decoder.remaining_handles();
14199            if let Some((inlined, num_bytes, num_handles)) =
14200                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14201            {
14202                let member_inline_size = <fidl::encoding::HandleType<
14203                    fdomain_client::EventPair,
14204                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14205                    2147483648,
14206                > as fidl::encoding::TypeMarker>::inline_size(
14207                    decoder.context
14208                );
14209                if inlined != (member_inline_size <= 4) {
14210                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14211                }
14212                let inner_offset;
14213                let mut inner_depth = depth.clone();
14214                if inlined {
14215                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14216                    inner_offset = next_offset;
14217                } else {
14218                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14219                    inner_depth.increment()?;
14220                }
14221                let val_ref =
14222                self.close_weak_asap.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
14223                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
14224                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14225                {
14226                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14227                }
14228                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14229                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14230                }
14231            }
14232
14233            next_offset += envelope_size;
14234
14235            // Decode the remaining unknown envelopes.
14236            while next_offset < end_offset {
14237                _next_ordinal_to_read += 1;
14238                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14239                next_offset += envelope_size;
14240            }
14241
14242            Ok(())
14243        }
14244    }
14245
14246    impl BufferCollectionAttachLifetimeTrackingRequest {
14247        #[inline(always)]
14248        fn max_ordinal_present(&self) -> u64 {
14249            if let Some(_) = self.buffers_remaining {
14250                return 2;
14251            }
14252            if let Some(_) = self.server_end {
14253                return 1;
14254            }
14255            0
14256        }
14257    }
14258
14259    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
14260        type Borrowed<'a> = &'a mut Self;
14261        fn take_or_borrow<'a>(
14262            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14263        ) -> Self::Borrowed<'a> {
14264            value
14265        }
14266    }
14267
14268    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
14269        type Owned = Self;
14270
14271        #[inline(always)]
14272        fn inline_align(_context: fidl::encoding::Context) -> usize {
14273            8
14274        }
14275
14276        #[inline(always)]
14277        fn inline_size(_context: fidl::encoding::Context) -> usize {
14278            16
14279        }
14280    }
14281
14282    unsafe impl
14283        fidl::encoding::Encode<
14284            BufferCollectionAttachLifetimeTrackingRequest,
14285            fdomain_client::fidl::FDomainResourceDialect,
14286        > for &mut BufferCollectionAttachLifetimeTrackingRequest
14287    {
14288        unsafe fn encode(
14289            self,
14290            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14291            offset: usize,
14292            mut depth: fidl::encoding::Depth,
14293        ) -> fidl::Result<()> {
14294            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
14295            // Vector header
14296            let max_ordinal: u64 = self.max_ordinal_present();
14297            encoder.write_num(max_ordinal, offset);
14298            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14299            // Calling encoder.out_of_line_offset(0) is not allowed.
14300            if max_ordinal == 0 {
14301                return Ok(());
14302            }
14303            depth.increment()?;
14304            let envelope_size = 8;
14305            let bytes_len = max_ordinal as usize * envelope_size;
14306            #[allow(unused_variables)]
14307            let offset = encoder.out_of_line_offset(bytes_len);
14308            let mut _prev_end_offset: usize = 0;
14309            if 1 > max_ordinal {
14310                return Ok(());
14311            }
14312
14313            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14314            // are envelope_size bytes.
14315            let cur_offset: usize = (1 - 1) * envelope_size;
14316
14317            // Zero reserved fields.
14318            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14319
14320            // Safety:
14321            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14322            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14323            //   envelope_size bytes, there is always sufficient room.
14324            fidl::encoding::encode_in_envelope_optional::<
14325                fidl::encoding::HandleType<
14326                    fdomain_client::EventPair,
14327                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14328                    2147483648,
14329                >,
14330                fdomain_client::fidl::FDomainResourceDialect,
14331            >(
14332                self.server_end.as_mut().map(
14333                    <fidl::encoding::HandleType<
14334                        fdomain_client::EventPair,
14335                        { fidl::ObjectType::EVENTPAIR.into_raw() },
14336                        2147483648,
14337                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14338                ),
14339                encoder,
14340                offset + cur_offset,
14341                depth,
14342            )?;
14343
14344            _prev_end_offset = cur_offset + envelope_size;
14345            if 2 > max_ordinal {
14346                return Ok(());
14347            }
14348
14349            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14350            // are envelope_size bytes.
14351            let cur_offset: usize = (2 - 1) * envelope_size;
14352
14353            // Zero reserved fields.
14354            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14355
14356            // Safety:
14357            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14358            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14359            //   envelope_size bytes, there is always sufficient room.
14360            fidl::encoding::encode_in_envelope_optional::<
14361                u32,
14362                fdomain_client::fidl::FDomainResourceDialect,
14363            >(
14364                self.buffers_remaining
14365                    .as_ref()
14366                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
14367                encoder,
14368                offset + cur_offset,
14369                depth,
14370            )?;
14371
14372            _prev_end_offset = cur_offset + envelope_size;
14373
14374            Ok(())
14375        }
14376    }
14377
14378    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14379        for BufferCollectionAttachLifetimeTrackingRequest
14380    {
14381        #[inline(always)]
14382        fn new_empty() -> Self {
14383            Self::default()
14384        }
14385
14386        unsafe fn decode(
14387            &mut self,
14388            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14389            offset: usize,
14390            mut depth: fidl::encoding::Depth,
14391        ) -> fidl::Result<()> {
14392            decoder.debug_check_bounds::<Self>(offset);
14393            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14394                None => return Err(fidl::Error::NotNullable),
14395                Some(len) => len,
14396            };
14397            // Calling decoder.out_of_line_offset(0) is not allowed.
14398            if len == 0 {
14399                return Ok(());
14400            };
14401            depth.increment()?;
14402            let envelope_size = 8;
14403            let bytes_len = len * envelope_size;
14404            let offset = decoder.out_of_line_offset(bytes_len)?;
14405            // Decode the envelope for each type.
14406            let mut _next_ordinal_to_read = 0;
14407            let mut next_offset = offset;
14408            let end_offset = offset + bytes_len;
14409            _next_ordinal_to_read += 1;
14410            if next_offset >= end_offset {
14411                return Ok(());
14412            }
14413
14414            // Decode unknown envelopes for gaps in ordinals.
14415            while _next_ordinal_to_read < 1 {
14416                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14417                _next_ordinal_to_read += 1;
14418                next_offset += envelope_size;
14419            }
14420
14421            let next_out_of_line = decoder.next_out_of_line();
14422            let handles_before = decoder.remaining_handles();
14423            if let Some((inlined, num_bytes, num_handles)) =
14424                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14425            {
14426                let member_inline_size = <fidl::encoding::HandleType<
14427                    fdomain_client::EventPair,
14428                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14429                    2147483648,
14430                > as fidl::encoding::TypeMarker>::inline_size(
14431                    decoder.context
14432                );
14433                if inlined != (member_inline_size <= 4) {
14434                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14435                }
14436                let inner_offset;
14437                let mut inner_depth = depth.clone();
14438                if inlined {
14439                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14440                    inner_offset = next_offset;
14441                } else {
14442                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14443                    inner_depth.increment()?;
14444                }
14445                let val_ref =
14446                self.server_end.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
14447                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
14448                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14449                {
14450                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14451                }
14452                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14453                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14454                }
14455            }
14456
14457            next_offset += envelope_size;
14458            _next_ordinal_to_read += 1;
14459            if next_offset >= end_offset {
14460                return Ok(());
14461            }
14462
14463            // Decode unknown envelopes for gaps in ordinals.
14464            while _next_ordinal_to_read < 2 {
14465                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14466                _next_ordinal_to_read += 1;
14467                next_offset += envelope_size;
14468            }
14469
14470            let next_out_of_line = decoder.next_out_of_line();
14471            let handles_before = decoder.remaining_handles();
14472            if let Some((inlined, num_bytes, num_handles)) =
14473                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14474            {
14475                let member_inline_size =
14476                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14477                if inlined != (member_inline_size <= 4) {
14478                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14479                }
14480                let inner_offset;
14481                let mut inner_depth = depth.clone();
14482                if inlined {
14483                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14484                    inner_offset = next_offset;
14485                } else {
14486                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14487                    inner_depth.increment()?;
14488                }
14489                let val_ref = self.buffers_remaining.get_or_insert_with(|| {
14490                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
14491                });
14492                fidl::decode!(
14493                    u32,
14494                    fdomain_client::fidl::FDomainResourceDialect,
14495                    val_ref,
14496                    decoder,
14497                    inner_offset,
14498                    inner_depth
14499                )?;
14500                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14501                {
14502                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14503                }
14504                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14505                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14506                }
14507            }
14508
14509            next_offset += envelope_size;
14510
14511            // Decode the remaining unknown envelopes.
14512            while next_offset < end_offset {
14513                _next_ordinal_to_read += 1;
14514                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14515                next_offset += envelope_size;
14516            }
14517
14518            Ok(())
14519        }
14520    }
14521
14522    impl BufferCollectionAttachTokenRequest {
14523        #[inline(always)]
14524        fn max_ordinal_present(&self) -> u64 {
14525            if let Some(_) = self.token_request {
14526                return 2;
14527            }
14528            if let Some(_) = self.rights_attenuation_mask {
14529                return 1;
14530            }
14531            0
14532        }
14533    }
14534
14535    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
14536        type Borrowed<'a> = &'a mut Self;
14537        fn take_or_borrow<'a>(
14538            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14539        ) -> Self::Borrowed<'a> {
14540            value
14541        }
14542    }
14543
14544    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
14545        type Owned = Self;
14546
14547        #[inline(always)]
14548        fn inline_align(_context: fidl::encoding::Context) -> usize {
14549            8
14550        }
14551
14552        #[inline(always)]
14553        fn inline_size(_context: fidl::encoding::Context) -> usize {
14554            16
14555        }
14556    }
14557
14558    unsafe impl
14559        fidl::encoding::Encode<
14560            BufferCollectionAttachTokenRequest,
14561            fdomain_client::fidl::FDomainResourceDialect,
14562        > for &mut BufferCollectionAttachTokenRequest
14563    {
14564        unsafe fn encode(
14565            self,
14566            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14567            offset: usize,
14568            mut depth: fidl::encoding::Depth,
14569        ) -> fidl::Result<()> {
14570            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
14571            // Vector header
14572            let max_ordinal: u64 = self.max_ordinal_present();
14573            encoder.write_num(max_ordinal, offset);
14574            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14575            // Calling encoder.out_of_line_offset(0) is not allowed.
14576            if max_ordinal == 0 {
14577                return Ok(());
14578            }
14579            depth.increment()?;
14580            let envelope_size = 8;
14581            let bytes_len = max_ordinal as usize * envelope_size;
14582            #[allow(unused_variables)]
14583            let offset = encoder.out_of_line_offset(bytes_len);
14584            let mut _prev_end_offset: usize = 0;
14585            if 1 > max_ordinal {
14586                return Ok(());
14587            }
14588
14589            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14590            // are envelope_size bytes.
14591            let cur_offset: usize = (1 - 1) * envelope_size;
14592
14593            // Zero reserved fields.
14594            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14595
14596            // Safety:
14597            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14598            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14599            //   envelope_size bytes, there is always sufficient room.
14600            fidl::encoding::encode_in_envelope_optional::<
14601                fidl::Rights,
14602                fdomain_client::fidl::FDomainResourceDialect,
14603            >(
14604                self.rights_attenuation_mask
14605                    .as_ref()
14606                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
14607                encoder,
14608                offset + cur_offset,
14609                depth,
14610            )?;
14611
14612            _prev_end_offset = cur_offset + envelope_size;
14613            if 2 > max_ordinal {
14614                return Ok(());
14615            }
14616
14617            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14618            // are envelope_size bytes.
14619            let cur_offset: usize = (2 - 1) * envelope_size;
14620
14621            // Zero reserved fields.
14622            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14623
14624            // Safety:
14625            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14626            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14627            //   envelope_size bytes, there is always sufficient room.
14628            fidl::encoding::encode_in_envelope_optional::<
14629                fidl::encoding::Endpoint<
14630                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
14631                >,
14632                fdomain_client::fidl::FDomainResourceDialect,
14633            >(
14634                self.token_request.as_mut().map(
14635                    <fidl::encoding::Endpoint<
14636                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
14637                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14638                ),
14639                encoder,
14640                offset + cur_offset,
14641                depth,
14642            )?;
14643
14644            _prev_end_offset = cur_offset + envelope_size;
14645
14646            Ok(())
14647        }
14648    }
14649
14650    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14651        for BufferCollectionAttachTokenRequest
14652    {
14653        #[inline(always)]
14654        fn new_empty() -> Self {
14655            Self::default()
14656        }
14657
14658        unsafe fn decode(
14659            &mut self,
14660            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14661            offset: usize,
14662            mut depth: fidl::encoding::Depth,
14663        ) -> fidl::Result<()> {
14664            decoder.debug_check_bounds::<Self>(offset);
14665            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14666                None => return Err(fidl::Error::NotNullable),
14667                Some(len) => len,
14668            };
14669            // Calling decoder.out_of_line_offset(0) is not allowed.
14670            if len == 0 {
14671                return Ok(());
14672            };
14673            depth.increment()?;
14674            let envelope_size = 8;
14675            let bytes_len = len * envelope_size;
14676            let offset = decoder.out_of_line_offset(bytes_len)?;
14677            // Decode the envelope for each type.
14678            let mut _next_ordinal_to_read = 0;
14679            let mut next_offset = offset;
14680            let end_offset = offset + bytes_len;
14681            _next_ordinal_to_read += 1;
14682            if next_offset >= end_offset {
14683                return Ok(());
14684            }
14685
14686            // Decode unknown envelopes for gaps in ordinals.
14687            while _next_ordinal_to_read < 1 {
14688                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14689                _next_ordinal_to_read += 1;
14690                next_offset += envelope_size;
14691            }
14692
14693            let next_out_of_line = decoder.next_out_of_line();
14694            let handles_before = decoder.remaining_handles();
14695            if let Some((inlined, num_bytes, num_handles)) =
14696                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14697            {
14698                let member_inline_size =
14699                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14700                if inlined != (member_inline_size <= 4) {
14701                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14702                }
14703                let inner_offset;
14704                let mut inner_depth = depth.clone();
14705                if inlined {
14706                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14707                    inner_offset = next_offset;
14708                } else {
14709                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14710                    inner_depth.increment()?;
14711                }
14712                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
14713                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
14714                });
14715                fidl::decode!(
14716                    fidl::Rights,
14717                    fdomain_client::fidl::FDomainResourceDialect,
14718                    val_ref,
14719                    decoder,
14720                    inner_offset,
14721                    inner_depth
14722                )?;
14723                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14724                {
14725                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14726                }
14727                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14728                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14729                }
14730            }
14731
14732            next_offset += envelope_size;
14733            _next_ordinal_to_read += 1;
14734            if next_offset >= end_offset {
14735                return Ok(());
14736            }
14737
14738            // Decode unknown envelopes for gaps in ordinals.
14739            while _next_ordinal_to_read < 2 {
14740                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14741                _next_ordinal_to_read += 1;
14742                next_offset += envelope_size;
14743            }
14744
14745            let next_out_of_line = decoder.next_out_of_line();
14746            let handles_before = decoder.remaining_handles();
14747            if let Some((inlined, num_bytes, num_handles)) =
14748                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14749            {
14750                let member_inline_size = <fidl::encoding::Endpoint<
14751                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
14752                > as fidl::encoding::TypeMarker>::inline_size(
14753                    decoder.context
14754                );
14755                if inlined != (member_inline_size <= 4) {
14756                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14757                }
14758                let inner_offset;
14759                let mut inner_depth = depth.clone();
14760                if inlined {
14761                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14762                    inner_offset = next_offset;
14763                } else {
14764                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14765                    inner_depth.increment()?;
14766                }
14767                let val_ref = self.token_request.get_or_insert_with(|| {
14768                    fidl::new_empty!(
14769                        fidl::encoding::Endpoint<
14770                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
14771                        >,
14772                        fdomain_client::fidl::FDomainResourceDialect
14773                    )
14774                });
14775                fidl::decode!(
14776                    fidl::encoding::Endpoint<
14777                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
14778                    >,
14779                    fdomain_client::fidl::FDomainResourceDialect,
14780                    val_ref,
14781                    decoder,
14782                    inner_offset,
14783                    inner_depth
14784                )?;
14785                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14786                {
14787                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14788                }
14789                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14790                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14791                }
14792            }
14793
14794            next_offset += envelope_size;
14795
14796            // Decode the remaining unknown envelopes.
14797            while next_offset < end_offset {
14798                _next_ordinal_to_read += 1;
14799                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14800                next_offset += envelope_size;
14801            }
14802
14803            Ok(())
14804        }
14805    }
14806
14807    impl BufferCollectionInfo {
14808        #[inline(always)]
14809        fn max_ordinal_present(&self) -> u64 {
14810            if let Some(_) = self.buffer_collection_id {
14811                return 3;
14812            }
14813            if let Some(_) = self.buffers {
14814                return 2;
14815            }
14816            if let Some(_) = self.settings {
14817                return 1;
14818            }
14819            0
14820        }
14821    }
14822
14823    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
14824        type Borrowed<'a> = &'a mut Self;
14825        fn take_or_borrow<'a>(
14826            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14827        ) -> Self::Borrowed<'a> {
14828            value
14829        }
14830    }
14831
14832    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
14833        type Owned = Self;
14834
14835        #[inline(always)]
14836        fn inline_align(_context: fidl::encoding::Context) -> usize {
14837            8
14838        }
14839
14840        #[inline(always)]
14841        fn inline_size(_context: fidl::encoding::Context) -> usize {
14842            16
14843        }
14844    }
14845
14846    unsafe impl
14847        fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
14848        for &mut BufferCollectionInfo
14849    {
14850        unsafe fn encode(
14851            self,
14852            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14853            offset: usize,
14854            mut depth: fidl::encoding::Depth,
14855        ) -> fidl::Result<()> {
14856            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
14857            // Vector header
14858            let max_ordinal: u64 = self.max_ordinal_present();
14859            encoder.write_num(max_ordinal, offset);
14860            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14861            // Calling encoder.out_of_line_offset(0) is not allowed.
14862            if max_ordinal == 0 {
14863                return Ok(());
14864            }
14865            depth.increment()?;
14866            let envelope_size = 8;
14867            let bytes_len = max_ordinal as usize * envelope_size;
14868            #[allow(unused_variables)]
14869            let offset = encoder.out_of_line_offset(bytes_len);
14870            let mut _prev_end_offset: usize = 0;
14871            if 1 > max_ordinal {
14872                return Ok(());
14873            }
14874
14875            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14876            // are envelope_size bytes.
14877            let cur_offset: usize = (1 - 1) * envelope_size;
14878
14879            // Zero reserved fields.
14880            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14881
14882            // Safety:
14883            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14884            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14885            //   envelope_size bytes, there is always sufficient room.
14886            fidl::encoding::encode_in_envelope_optional::<
14887                SingleBufferSettings,
14888                fdomain_client::fidl::FDomainResourceDialect,
14889            >(
14890                self.settings
14891                    .as_ref()
14892                    .map(<SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow),
14893                encoder,
14894                offset + cur_offset,
14895                depth,
14896            )?;
14897
14898            _prev_end_offset = cur_offset + envelope_size;
14899            if 2 > max_ordinal {
14900                return Ok(());
14901            }
14902
14903            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14904            // are envelope_size bytes.
14905            let cur_offset: usize = (2 - 1) * envelope_size;
14906
14907            // Zero reserved fields.
14908            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14909
14910            // Safety:
14911            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14912            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14913            //   envelope_size bytes, there is always sufficient room.
14914            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect>(
14915            self.buffers.as_mut().map(<fidl::encoding::Vector<VmoBuffer, 128> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
14916            encoder, offset + cur_offset, depth
14917        )?;
14918
14919            _prev_end_offset = cur_offset + envelope_size;
14920            if 3 > max_ordinal {
14921                return Ok(());
14922            }
14923
14924            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14925            // are envelope_size bytes.
14926            let cur_offset: usize = (3 - 1) * envelope_size;
14927
14928            // Zero reserved fields.
14929            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14930
14931            // Safety:
14932            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14933            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14934            //   envelope_size bytes, there is always sufficient room.
14935            fidl::encoding::encode_in_envelope_optional::<
14936                u64,
14937                fdomain_client::fidl::FDomainResourceDialect,
14938            >(
14939                self.buffer_collection_id
14940                    .as_ref()
14941                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
14942                encoder,
14943                offset + cur_offset,
14944                depth,
14945            )?;
14946
14947            _prev_end_offset = cur_offset + envelope_size;
14948
14949            Ok(())
14950        }
14951    }
14952
14953    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14954        for BufferCollectionInfo
14955    {
14956        #[inline(always)]
14957        fn new_empty() -> Self {
14958            Self::default()
14959        }
14960
14961        unsafe fn decode(
14962            &mut self,
14963            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14964            offset: usize,
14965            mut depth: fidl::encoding::Depth,
14966        ) -> fidl::Result<()> {
14967            decoder.debug_check_bounds::<Self>(offset);
14968            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14969                None => return Err(fidl::Error::NotNullable),
14970                Some(len) => len,
14971            };
14972            // Calling decoder.out_of_line_offset(0) is not allowed.
14973            if len == 0 {
14974                return Ok(());
14975            };
14976            depth.increment()?;
14977            let envelope_size = 8;
14978            let bytes_len = len * envelope_size;
14979            let offset = decoder.out_of_line_offset(bytes_len)?;
14980            // Decode the envelope for each type.
14981            let mut _next_ordinal_to_read = 0;
14982            let mut next_offset = offset;
14983            let end_offset = offset + bytes_len;
14984            _next_ordinal_to_read += 1;
14985            if next_offset >= end_offset {
14986                return Ok(());
14987            }
14988
14989            // Decode unknown envelopes for gaps in ordinals.
14990            while _next_ordinal_to_read < 1 {
14991                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14992                _next_ordinal_to_read += 1;
14993                next_offset += envelope_size;
14994            }
14995
14996            let next_out_of_line = decoder.next_out_of_line();
14997            let handles_before = decoder.remaining_handles();
14998            if let Some((inlined, num_bytes, num_handles)) =
14999                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15000            {
15001                let member_inline_size =
15002                    <SingleBufferSettings as fidl::encoding::TypeMarker>::inline_size(
15003                        decoder.context,
15004                    );
15005                if inlined != (member_inline_size <= 4) {
15006                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15007                }
15008                let inner_offset;
15009                let mut inner_depth = depth.clone();
15010                if inlined {
15011                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15012                    inner_offset = next_offset;
15013                } else {
15014                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15015                    inner_depth.increment()?;
15016                }
15017                let val_ref = self.settings.get_or_insert_with(|| {
15018                    fidl::new_empty!(
15019                        SingleBufferSettings,
15020                        fdomain_client::fidl::FDomainResourceDialect
15021                    )
15022                });
15023                fidl::decode!(
15024                    SingleBufferSettings,
15025                    fdomain_client::fidl::FDomainResourceDialect,
15026                    val_ref,
15027                    decoder,
15028                    inner_offset,
15029                    inner_depth
15030                )?;
15031                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15032                {
15033                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15034                }
15035                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15036                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15037                }
15038            }
15039
15040            next_offset += envelope_size;
15041            _next_ordinal_to_read += 1;
15042            if next_offset >= end_offset {
15043                return Ok(());
15044            }
15045
15046            // Decode unknown envelopes for gaps in ordinals.
15047            while _next_ordinal_to_read < 2 {
15048                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15049                _next_ordinal_to_read += 1;
15050                next_offset += envelope_size;
15051            }
15052
15053            let next_out_of_line = decoder.next_out_of_line();
15054            let handles_before = decoder.remaining_handles();
15055            if let Some((inlined, num_bytes, num_handles)) =
15056                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15057            {
15058                let member_inline_size = <fidl::encoding::Vector<VmoBuffer, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15059                if inlined != (member_inline_size <= 4) {
15060                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15061                }
15062                let inner_offset;
15063                let mut inner_depth = depth.clone();
15064                if inlined {
15065                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15066                    inner_offset = next_offset;
15067                } else {
15068                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15069                    inner_depth.increment()?;
15070                }
15071                let val_ref =
15072                self.buffers.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect));
15073                fidl::decode!(fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
15074                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15075                {
15076                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15077                }
15078                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15079                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15080                }
15081            }
15082
15083            next_offset += envelope_size;
15084            _next_ordinal_to_read += 1;
15085            if next_offset >= end_offset {
15086                return Ok(());
15087            }
15088
15089            // Decode unknown envelopes for gaps in ordinals.
15090            while _next_ordinal_to_read < 3 {
15091                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15092                _next_ordinal_to_read += 1;
15093                next_offset += envelope_size;
15094            }
15095
15096            let next_out_of_line = decoder.next_out_of_line();
15097            let handles_before = decoder.remaining_handles();
15098            if let Some((inlined, num_bytes, num_handles)) =
15099                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15100            {
15101                let member_inline_size =
15102                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15103                if inlined != (member_inline_size <= 4) {
15104                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15105                }
15106                let inner_offset;
15107                let mut inner_depth = depth.clone();
15108                if inlined {
15109                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15110                    inner_offset = next_offset;
15111                } else {
15112                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15113                    inner_depth.increment()?;
15114                }
15115                let val_ref = self.buffer_collection_id.get_or_insert_with(|| {
15116                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
15117                });
15118                fidl::decode!(
15119                    u64,
15120                    fdomain_client::fidl::FDomainResourceDialect,
15121                    val_ref,
15122                    decoder,
15123                    inner_offset,
15124                    inner_depth
15125                )?;
15126                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15127                {
15128                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15129                }
15130                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15131                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15132                }
15133            }
15134
15135            next_offset += envelope_size;
15136
15137            // Decode the remaining unknown envelopes.
15138            while next_offset < end_offset {
15139                _next_ordinal_to_read += 1;
15140                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15141                next_offset += envelope_size;
15142            }
15143
15144            Ok(())
15145        }
15146    }
15147
15148    impl BufferCollectionSetConstraintsRequest {
15149        #[inline(always)]
15150        fn max_ordinal_present(&self) -> u64 {
15151            if let Some(_) = self.constraints {
15152                return 1;
15153            }
15154            0
15155        }
15156    }
15157
15158    impl fidl::encoding::ResourceTypeMarker for BufferCollectionSetConstraintsRequest {
15159        type Borrowed<'a> = &'a mut Self;
15160        fn take_or_borrow<'a>(
15161            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15162        ) -> Self::Borrowed<'a> {
15163            value
15164        }
15165    }
15166
15167    unsafe impl fidl::encoding::TypeMarker for BufferCollectionSetConstraintsRequest {
15168        type Owned = Self;
15169
15170        #[inline(always)]
15171        fn inline_align(_context: fidl::encoding::Context) -> usize {
15172            8
15173        }
15174
15175        #[inline(always)]
15176        fn inline_size(_context: fidl::encoding::Context) -> usize {
15177            16
15178        }
15179    }
15180
15181    unsafe impl
15182        fidl::encoding::Encode<
15183            BufferCollectionSetConstraintsRequest,
15184            fdomain_client::fidl::FDomainResourceDialect,
15185        > for &mut BufferCollectionSetConstraintsRequest
15186    {
15187        unsafe fn encode(
15188            self,
15189            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15190            offset: usize,
15191            mut depth: fidl::encoding::Depth,
15192        ) -> fidl::Result<()> {
15193            encoder.debug_check_bounds::<BufferCollectionSetConstraintsRequest>(offset);
15194            // Vector header
15195            let max_ordinal: u64 = self.max_ordinal_present();
15196            encoder.write_num(max_ordinal, offset);
15197            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15198            // Calling encoder.out_of_line_offset(0) is not allowed.
15199            if max_ordinal == 0 {
15200                return Ok(());
15201            }
15202            depth.increment()?;
15203            let envelope_size = 8;
15204            let bytes_len = max_ordinal as usize * envelope_size;
15205            #[allow(unused_variables)]
15206            let offset = encoder.out_of_line_offset(bytes_len);
15207            let mut _prev_end_offset: usize = 0;
15208            if 1 > max_ordinal {
15209                return Ok(());
15210            }
15211
15212            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15213            // are envelope_size bytes.
15214            let cur_offset: usize = (1 - 1) * envelope_size;
15215
15216            // Zero reserved fields.
15217            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15218
15219            // Safety:
15220            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15221            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15222            //   envelope_size bytes, there is always sufficient room.
15223            fidl::encoding::encode_in_envelope_optional::<
15224                BufferCollectionConstraints,
15225                fdomain_client::fidl::FDomainResourceDialect,
15226            >(
15227                self.constraints
15228                    .as_ref()
15229                    .map(<BufferCollectionConstraints as fidl::encoding::ValueTypeMarker>::borrow),
15230                encoder,
15231                offset + cur_offset,
15232                depth,
15233            )?;
15234
15235            _prev_end_offset = cur_offset + envelope_size;
15236
15237            Ok(())
15238        }
15239    }
15240
15241    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15242        for BufferCollectionSetConstraintsRequest
15243    {
15244        #[inline(always)]
15245        fn new_empty() -> Self {
15246            Self::default()
15247        }
15248
15249        unsafe fn decode(
15250            &mut self,
15251            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15252            offset: usize,
15253            mut depth: fidl::encoding::Depth,
15254        ) -> fidl::Result<()> {
15255            decoder.debug_check_bounds::<Self>(offset);
15256            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15257                None => return Err(fidl::Error::NotNullable),
15258                Some(len) => len,
15259            };
15260            // Calling decoder.out_of_line_offset(0) is not allowed.
15261            if len == 0 {
15262                return Ok(());
15263            };
15264            depth.increment()?;
15265            let envelope_size = 8;
15266            let bytes_len = len * envelope_size;
15267            let offset = decoder.out_of_line_offset(bytes_len)?;
15268            // Decode the envelope for each type.
15269            let mut _next_ordinal_to_read = 0;
15270            let mut next_offset = offset;
15271            let end_offset = offset + bytes_len;
15272            _next_ordinal_to_read += 1;
15273            if next_offset >= end_offset {
15274                return Ok(());
15275            }
15276
15277            // Decode unknown envelopes for gaps in ordinals.
15278            while _next_ordinal_to_read < 1 {
15279                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15280                _next_ordinal_to_read += 1;
15281                next_offset += envelope_size;
15282            }
15283
15284            let next_out_of_line = decoder.next_out_of_line();
15285            let handles_before = decoder.remaining_handles();
15286            if let Some((inlined, num_bytes, num_handles)) =
15287                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15288            {
15289                let member_inline_size =
15290                    <BufferCollectionConstraints as fidl::encoding::TypeMarker>::inline_size(
15291                        decoder.context,
15292                    );
15293                if inlined != (member_inline_size <= 4) {
15294                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15295                }
15296                let inner_offset;
15297                let mut inner_depth = depth.clone();
15298                if inlined {
15299                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15300                    inner_offset = next_offset;
15301                } else {
15302                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15303                    inner_depth.increment()?;
15304                }
15305                let val_ref = self.constraints.get_or_insert_with(|| {
15306                    fidl::new_empty!(
15307                        BufferCollectionConstraints,
15308                        fdomain_client::fidl::FDomainResourceDialect
15309                    )
15310                });
15311                fidl::decode!(
15312                    BufferCollectionConstraints,
15313                    fdomain_client::fidl::FDomainResourceDialect,
15314                    val_ref,
15315                    decoder,
15316                    inner_offset,
15317                    inner_depth
15318                )?;
15319                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15320                {
15321                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15322                }
15323                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15324                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15325                }
15326            }
15327
15328            next_offset += envelope_size;
15329
15330            // Decode the remaining unknown envelopes.
15331            while next_offset < end_offset {
15332                _next_ordinal_to_read += 1;
15333                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15334                next_offset += envelope_size;
15335            }
15336
15337            Ok(())
15338        }
15339    }
15340
15341    impl BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
15342        #[inline(always)]
15343        fn max_ordinal_present(&self) -> u64 {
15344            if let Some(_) = self.group_request {
15345                return 1;
15346            }
15347            0
15348        }
15349    }
15350
15351    impl fidl::encoding::ResourceTypeMarker
15352        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
15353    {
15354        type Borrowed<'a> = &'a mut Self;
15355        fn take_or_borrow<'a>(
15356            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15357        ) -> Self::Borrowed<'a> {
15358            value
15359        }
15360    }
15361
15362    unsafe impl fidl::encoding::TypeMarker
15363        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
15364    {
15365        type Owned = Self;
15366
15367        #[inline(always)]
15368        fn inline_align(_context: fidl::encoding::Context) -> usize {
15369            8
15370        }
15371
15372        #[inline(always)]
15373        fn inline_size(_context: fidl::encoding::Context) -> usize {
15374            16
15375        }
15376    }
15377
15378    unsafe impl
15379        fidl::encoding::Encode<
15380            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
15381            fdomain_client::fidl::FDomainResourceDialect,
15382        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
15383    {
15384        unsafe fn encode(
15385            self,
15386            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15387            offset: usize,
15388            mut depth: fidl::encoding::Depth,
15389        ) -> fidl::Result<()> {
15390            encoder
15391                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
15392                    offset,
15393                );
15394            // Vector header
15395            let max_ordinal: u64 = self.max_ordinal_present();
15396            encoder.write_num(max_ordinal, offset);
15397            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15398            // Calling encoder.out_of_line_offset(0) is not allowed.
15399            if max_ordinal == 0 {
15400                return Ok(());
15401            }
15402            depth.increment()?;
15403            let envelope_size = 8;
15404            let bytes_len = max_ordinal as usize * envelope_size;
15405            #[allow(unused_variables)]
15406            let offset = encoder.out_of_line_offset(bytes_len);
15407            let mut _prev_end_offset: usize = 0;
15408            if 1 > max_ordinal {
15409                return Ok(());
15410            }
15411
15412            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15413            // are envelope_size bytes.
15414            let cur_offset: usize = (1 - 1) * envelope_size;
15415
15416            // Zero reserved fields.
15417            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15418
15419            // Safety:
15420            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15421            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15422            //   envelope_size bytes, there is always sufficient room.
15423            fidl::encoding::encode_in_envelope_optional::<
15424                fidl::encoding::Endpoint<
15425                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
15426                >,
15427                fdomain_client::fidl::FDomainResourceDialect,
15428            >(
15429                self.group_request.as_mut().map(
15430                    <fidl::encoding::Endpoint<
15431                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
15432                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15433                ),
15434                encoder,
15435                offset + cur_offset,
15436                depth,
15437            )?;
15438
15439            _prev_end_offset = cur_offset + envelope_size;
15440
15441            Ok(())
15442        }
15443    }
15444
15445    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15446        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
15447    {
15448        #[inline(always)]
15449        fn new_empty() -> Self {
15450            Self::default()
15451        }
15452
15453        unsafe fn decode(
15454            &mut self,
15455            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15456            offset: usize,
15457            mut depth: fidl::encoding::Depth,
15458        ) -> fidl::Result<()> {
15459            decoder.debug_check_bounds::<Self>(offset);
15460            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15461                None => return Err(fidl::Error::NotNullable),
15462                Some(len) => len,
15463            };
15464            // Calling decoder.out_of_line_offset(0) is not allowed.
15465            if len == 0 {
15466                return Ok(());
15467            };
15468            depth.increment()?;
15469            let envelope_size = 8;
15470            let bytes_len = len * envelope_size;
15471            let offset = decoder.out_of_line_offset(bytes_len)?;
15472            // Decode the envelope for each type.
15473            let mut _next_ordinal_to_read = 0;
15474            let mut next_offset = offset;
15475            let end_offset = offset + bytes_len;
15476            _next_ordinal_to_read += 1;
15477            if next_offset >= end_offset {
15478                return Ok(());
15479            }
15480
15481            // Decode unknown envelopes for gaps in ordinals.
15482            while _next_ordinal_to_read < 1 {
15483                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15484                _next_ordinal_to_read += 1;
15485                next_offset += envelope_size;
15486            }
15487
15488            let next_out_of_line = decoder.next_out_of_line();
15489            let handles_before = decoder.remaining_handles();
15490            if let Some((inlined, num_bytes, num_handles)) =
15491                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15492            {
15493                let member_inline_size = <fidl::encoding::Endpoint<
15494                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
15495                > as fidl::encoding::TypeMarker>::inline_size(
15496                    decoder.context
15497                );
15498                if inlined != (member_inline_size <= 4) {
15499                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15500                }
15501                let inner_offset;
15502                let mut inner_depth = depth.clone();
15503                if inlined {
15504                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15505                    inner_offset = next_offset;
15506                } else {
15507                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15508                    inner_depth.increment()?;
15509                }
15510                let val_ref = self.group_request.get_or_insert_with(|| {
15511                    fidl::new_empty!(
15512                        fidl::encoding::Endpoint<
15513                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
15514                        >,
15515                        fdomain_client::fidl::FDomainResourceDialect
15516                    )
15517                });
15518                fidl::decode!(
15519                    fidl::encoding::Endpoint<
15520                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
15521                    >,
15522                    fdomain_client::fidl::FDomainResourceDialect,
15523                    val_ref,
15524                    decoder,
15525                    inner_offset,
15526                    inner_depth
15527                )?;
15528                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15529                {
15530                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15531                }
15532                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15533                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15534                }
15535            }
15536
15537            next_offset += envelope_size;
15538
15539            // Decode the remaining unknown envelopes.
15540            while next_offset < end_offset {
15541                _next_ordinal_to_read += 1;
15542                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15543                next_offset += envelope_size;
15544            }
15545
15546            Ok(())
15547        }
15548    }
15549
15550    impl BufferCollectionTokenDuplicateRequest {
15551        #[inline(always)]
15552        fn max_ordinal_present(&self) -> u64 {
15553            if let Some(_) = self.token_request {
15554                return 2;
15555            }
15556            if let Some(_) = self.rights_attenuation_mask {
15557                return 1;
15558            }
15559            0
15560        }
15561    }
15562
15563    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
15564        type Borrowed<'a> = &'a mut Self;
15565        fn take_or_borrow<'a>(
15566            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15567        ) -> Self::Borrowed<'a> {
15568            value
15569        }
15570    }
15571
15572    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
15573        type Owned = Self;
15574
15575        #[inline(always)]
15576        fn inline_align(_context: fidl::encoding::Context) -> usize {
15577            8
15578        }
15579
15580        #[inline(always)]
15581        fn inline_size(_context: fidl::encoding::Context) -> usize {
15582            16
15583        }
15584    }
15585
15586    unsafe impl
15587        fidl::encoding::Encode<
15588            BufferCollectionTokenDuplicateRequest,
15589            fdomain_client::fidl::FDomainResourceDialect,
15590        > for &mut BufferCollectionTokenDuplicateRequest
15591    {
15592        unsafe fn encode(
15593            self,
15594            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15595            offset: usize,
15596            mut depth: fidl::encoding::Depth,
15597        ) -> fidl::Result<()> {
15598            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
15599            // Vector header
15600            let max_ordinal: u64 = self.max_ordinal_present();
15601            encoder.write_num(max_ordinal, offset);
15602            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15603            // Calling encoder.out_of_line_offset(0) is not allowed.
15604            if max_ordinal == 0 {
15605                return Ok(());
15606            }
15607            depth.increment()?;
15608            let envelope_size = 8;
15609            let bytes_len = max_ordinal as usize * envelope_size;
15610            #[allow(unused_variables)]
15611            let offset = encoder.out_of_line_offset(bytes_len);
15612            let mut _prev_end_offset: usize = 0;
15613            if 1 > max_ordinal {
15614                return Ok(());
15615            }
15616
15617            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15618            // are envelope_size bytes.
15619            let cur_offset: usize = (1 - 1) * envelope_size;
15620
15621            // Zero reserved fields.
15622            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15623
15624            // Safety:
15625            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15626            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15627            //   envelope_size bytes, there is always sufficient room.
15628            fidl::encoding::encode_in_envelope_optional::<
15629                fidl::Rights,
15630                fdomain_client::fidl::FDomainResourceDialect,
15631            >(
15632                self.rights_attenuation_mask
15633                    .as_ref()
15634                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
15635                encoder,
15636                offset + cur_offset,
15637                depth,
15638            )?;
15639
15640            _prev_end_offset = cur_offset + envelope_size;
15641            if 2 > max_ordinal {
15642                return Ok(());
15643            }
15644
15645            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15646            // are envelope_size bytes.
15647            let cur_offset: usize = (2 - 1) * envelope_size;
15648
15649            // Zero reserved fields.
15650            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15651
15652            // Safety:
15653            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15654            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15655            //   envelope_size bytes, there is always sufficient room.
15656            fidl::encoding::encode_in_envelope_optional::<
15657                fidl::encoding::Endpoint<
15658                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15659                >,
15660                fdomain_client::fidl::FDomainResourceDialect,
15661            >(
15662                self.token_request.as_mut().map(
15663                    <fidl::encoding::Endpoint<
15664                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15665                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15666                ),
15667                encoder,
15668                offset + cur_offset,
15669                depth,
15670            )?;
15671
15672            _prev_end_offset = cur_offset + envelope_size;
15673
15674            Ok(())
15675        }
15676    }
15677
15678    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15679        for BufferCollectionTokenDuplicateRequest
15680    {
15681        #[inline(always)]
15682        fn new_empty() -> Self {
15683            Self::default()
15684        }
15685
15686        unsafe fn decode(
15687            &mut self,
15688            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15689            offset: usize,
15690            mut depth: fidl::encoding::Depth,
15691        ) -> fidl::Result<()> {
15692            decoder.debug_check_bounds::<Self>(offset);
15693            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15694                None => return Err(fidl::Error::NotNullable),
15695                Some(len) => len,
15696            };
15697            // Calling decoder.out_of_line_offset(0) is not allowed.
15698            if len == 0 {
15699                return Ok(());
15700            };
15701            depth.increment()?;
15702            let envelope_size = 8;
15703            let bytes_len = len * envelope_size;
15704            let offset = decoder.out_of_line_offset(bytes_len)?;
15705            // Decode the envelope for each type.
15706            let mut _next_ordinal_to_read = 0;
15707            let mut next_offset = offset;
15708            let end_offset = offset + bytes_len;
15709            _next_ordinal_to_read += 1;
15710            if next_offset >= end_offset {
15711                return Ok(());
15712            }
15713
15714            // Decode unknown envelopes for gaps in ordinals.
15715            while _next_ordinal_to_read < 1 {
15716                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15717                _next_ordinal_to_read += 1;
15718                next_offset += envelope_size;
15719            }
15720
15721            let next_out_of_line = decoder.next_out_of_line();
15722            let handles_before = decoder.remaining_handles();
15723            if let Some((inlined, num_bytes, num_handles)) =
15724                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15725            {
15726                let member_inline_size =
15727                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15728                if inlined != (member_inline_size <= 4) {
15729                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15730                }
15731                let inner_offset;
15732                let mut inner_depth = depth.clone();
15733                if inlined {
15734                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15735                    inner_offset = next_offset;
15736                } else {
15737                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15738                    inner_depth.increment()?;
15739                }
15740                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
15741                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
15742                });
15743                fidl::decode!(
15744                    fidl::Rights,
15745                    fdomain_client::fidl::FDomainResourceDialect,
15746                    val_ref,
15747                    decoder,
15748                    inner_offset,
15749                    inner_depth
15750                )?;
15751                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15752                {
15753                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15754                }
15755                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15756                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15757                }
15758            }
15759
15760            next_offset += envelope_size;
15761            _next_ordinal_to_read += 1;
15762            if next_offset >= end_offset {
15763                return Ok(());
15764            }
15765
15766            // Decode unknown envelopes for gaps in ordinals.
15767            while _next_ordinal_to_read < 2 {
15768                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15769                _next_ordinal_to_read += 1;
15770                next_offset += envelope_size;
15771            }
15772
15773            let next_out_of_line = decoder.next_out_of_line();
15774            let handles_before = decoder.remaining_handles();
15775            if let Some((inlined, num_bytes, num_handles)) =
15776                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15777            {
15778                let member_inline_size = <fidl::encoding::Endpoint<
15779                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15780                > as fidl::encoding::TypeMarker>::inline_size(
15781                    decoder.context
15782                );
15783                if inlined != (member_inline_size <= 4) {
15784                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15785                }
15786                let inner_offset;
15787                let mut inner_depth = depth.clone();
15788                if inlined {
15789                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15790                    inner_offset = next_offset;
15791                } else {
15792                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15793                    inner_depth.increment()?;
15794                }
15795                let val_ref = self.token_request.get_or_insert_with(|| {
15796                    fidl::new_empty!(
15797                        fidl::encoding::Endpoint<
15798                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15799                        >,
15800                        fdomain_client::fidl::FDomainResourceDialect
15801                    )
15802                });
15803                fidl::decode!(
15804                    fidl::encoding::Endpoint<
15805                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15806                    >,
15807                    fdomain_client::fidl::FDomainResourceDialect,
15808                    val_ref,
15809                    decoder,
15810                    inner_offset,
15811                    inner_depth
15812                )?;
15813                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15814                {
15815                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15816                }
15817                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15818                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15819                }
15820            }
15821
15822            next_offset += envelope_size;
15823
15824            // Decode the remaining unknown envelopes.
15825            while next_offset < end_offset {
15826                _next_ordinal_to_read += 1;
15827                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15828                next_offset += envelope_size;
15829            }
15830
15831            Ok(())
15832        }
15833    }
15834
15835    impl BufferCollectionTokenGroupCreateChildRequest {
15836        #[inline(always)]
15837        fn max_ordinal_present(&self) -> u64 {
15838            if let Some(_) = self.rights_attenuation_mask {
15839                return 2;
15840            }
15841            if let Some(_) = self.token_request {
15842                return 1;
15843            }
15844            0
15845        }
15846    }
15847
15848    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
15849        type Borrowed<'a> = &'a mut Self;
15850        fn take_or_borrow<'a>(
15851            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15852        ) -> Self::Borrowed<'a> {
15853            value
15854        }
15855    }
15856
15857    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
15858        type Owned = Self;
15859
15860        #[inline(always)]
15861        fn inline_align(_context: fidl::encoding::Context) -> usize {
15862            8
15863        }
15864
15865        #[inline(always)]
15866        fn inline_size(_context: fidl::encoding::Context) -> usize {
15867            16
15868        }
15869    }
15870
15871    unsafe impl
15872        fidl::encoding::Encode<
15873            BufferCollectionTokenGroupCreateChildRequest,
15874            fdomain_client::fidl::FDomainResourceDialect,
15875        > for &mut BufferCollectionTokenGroupCreateChildRequest
15876    {
15877        unsafe fn encode(
15878            self,
15879            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15880            offset: usize,
15881            mut depth: fidl::encoding::Depth,
15882        ) -> fidl::Result<()> {
15883            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
15884            // Vector header
15885            let max_ordinal: u64 = self.max_ordinal_present();
15886            encoder.write_num(max_ordinal, offset);
15887            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15888            // Calling encoder.out_of_line_offset(0) is not allowed.
15889            if max_ordinal == 0 {
15890                return Ok(());
15891            }
15892            depth.increment()?;
15893            let envelope_size = 8;
15894            let bytes_len = max_ordinal as usize * envelope_size;
15895            #[allow(unused_variables)]
15896            let offset = encoder.out_of_line_offset(bytes_len);
15897            let mut _prev_end_offset: usize = 0;
15898            if 1 > max_ordinal {
15899                return Ok(());
15900            }
15901
15902            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15903            // are envelope_size bytes.
15904            let cur_offset: usize = (1 - 1) * envelope_size;
15905
15906            // Zero reserved fields.
15907            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15908
15909            // Safety:
15910            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15911            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15912            //   envelope_size bytes, there is always sufficient room.
15913            fidl::encoding::encode_in_envelope_optional::<
15914                fidl::encoding::Endpoint<
15915                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15916                >,
15917                fdomain_client::fidl::FDomainResourceDialect,
15918            >(
15919                self.token_request.as_mut().map(
15920                    <fidl::encoding::Endpoint<
15921                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15922                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15923                ),
15924                encoder,
15925                offset + cur_offset,
15926                depth,
15927            )?;
15928
15929            _prev_end_offset = cur_offset + envelope_size;
15930            if 2 > max_ordinal {
15931                return Ok(());
15932            }
15933
15934            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15935            // are envelope_size bytes.
15936            let cur_offset: usize = (2 - 1) * envelope_size;
15937
15938            // Zero reserved fields.
15939            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15940
15941            // Safety:
15942            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15943            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15944            //   envelope_size bytes, there is always sufficient room.
15945            fidl::encoding::encode_in_envelope_optional::<
15946                fidl::Rights,
15947                fdomain_client::fidl::FDomainResourceDialect,
15948            >(
15949                self.rights_attenuation_mask
15950                    .as_ref()
15951                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
15952                encoder,
15953                offset + cur_offset,
15954                depth,
15955            )?;
15956
15957            _prev_end_offset = cur_offset + envelope_size;
15958
15959            Ok(())
15960        }
15961    }
15962
15963    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15964        for BufferCollectionTokenGroupCreateChildRequest
15965    {
15966        #[inline(always)]
15967        fn new_empty() -> Self {
15968            Self::default()
15969        }
15970
15971        unsafe fn decode(
15972            &mut self,
15973            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15974            offset: usize,
15975            mut depth: fidl::encoding::Depth,
15976        ) -> fidl::Result<()> {
15977            decoder.debug_check_bounds::<Self>(offset);
15978            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15979                None => return Err(fidl::Error::NotNullable),
15980                Some(len) => len,
15981            };
15982            // Calling decoder.out_of_line_offset(0) is not allowed.
15983            if len == 0 {
15984                return Ok(());
15985            };
15986            depth.increment()?;
15987            let envelope_size = 8;
15988            let bytes_len = len * envelope_size;
15989            let offset = decoder.out_of_line_offset(bytes_len)?;
15990            // Decode the envelope for each type.
15991            let mut _next_ordinal_to_read = 0;
15992            let mut next_offset = offset;
15993            let end_offset = offset + bytes_len;
15994            _next_ordinal_to_read += 1;
15995            if next_offset >= end_offset {
15996                return Ok(());
15997            }
15998
15999            // Decode unknown envelopes for gaps in ordinals.
16000            while _next_ordinal_to_read < 1 {
16001                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16002                _next_ordinal_to_read += 1;
16003                next_offset += envelope_size;
16004            }
16005
16006            let next_out_of_line = decoder.next_out_of_line();
16007            let handles_before = decoder.remaining_handles();
16008            if let Some((inlined, num_bytes, num_handles)) =
16009                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16010            {
16011                let member_inline_size = <fidl::encoding::Endpoint<
16012                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16013                > as fidl::encoding::TypeMarker>::inline_size(
16014                    decoder.context
16015                );
16016                if inlined != (member_inline_size <= 4) {
16017                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16018                }
16019                let inner_offset;
16020                let mut inner_depth = depth.clone();
16021                if inlined {
16022                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16023                    inner_offset = next_offset;
16024                } else {
16025                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16026                    inner_depth.increment()?;
16027                }
16028                let val_ref = self.token_request.get_or_insert_with(|| {
16029                    fidl::new_empty!(
16030                        fidl::encoding::Endpoint<
16031                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16032                        >,
16033                        fdomain_client::fidl::FDomainResourceDialect
16034                    )
16035                });
16036                fidl::decode!(
16037                    fidl::encoding::Endpoint<
16038                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16039                    >,
16040                    fdomain_client::fidl::FDomainResourceDialect,
16041                    val_ref,
16042                    decoder,
16043                    inner_offset,
16044                    inner_depth
16045                )?;
16046                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16047                {
16048                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16049                }
16050                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16051                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16052                }
16053            }
16054
16055            next_offset += envelope_size;
16056            _next_ordinal_to_read += 1;
16057            if next_offset >= end_offset {
16058                return Ok(());
16059            }
16060
16061            // Decode unknown envelopes for gaps in ordinals.
16062            while _next_ordinal_to_read < 2 {
16063                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16064                _next_ordinal_to_read += 1;
16065                next_offset += envelope_size;
16066            }
16067
16068            let next_out_of_line = decoder.next_out_of_line();
16069            let handles_before = decoder.remaining_handles();
16070            if let Some((inlined, num_bytes, num_handles)) =
16071                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16072            {
16073                let member_inline_size =
16074                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16075                if inlined != (member_inline_size <= 4) {
16076                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16077                }
16078                let inner_offset;
16079                let mut inner_depth = depth.clone();
16080                if inlined {
16081                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16082                    inner_offset = next_offset;
16083                } else {
16084                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16085                    inner_depth.increment()?;
16086                }
16087                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
16088                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
16089                });
16090                fidl::decode!(
16091                    fidl::Rights,
16092                    fdomain_client::fidl::FDomainResourceDialect,
16093                    val_ref,
16094                    decoder,
16095                    inner_offset,
16096                    inner_depth
16097                )?;
16098                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16099                {
16100                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16101                }
16102                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16103                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16104                }
16105            }
16106
16107            next_offset += envelope_size;
16108
16109            // Decode the remaining unknown envelopes.
16110            while next_offset < end_offset {
16111                _next_ordinal_to_read += 1;
16112                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16113                next_offset += envelope_size;
16114            }
16115
16116            Ok(())
16117        }
16118    }
16119
16120    impl BufferCollectionTokenGroupCreateChildrenSyncResponse {
16121        #[inline(always)]
16122        fn max_ordinal_present(&self) -> u64 {
16123            if let Some(_) = self.tokens {
16124                return 1;
16125            }
16126            0
16127        }
16128    }
16129
16130    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
16131        type Borrowed<'a> = &'a mut Self;
16132        fn take_or_borrow<'a>(
16133            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16134        ) -> Self::Borrowed<'a> {
16135            value
16136        }
16137    }
16138
16139    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
16140        type Owned = Self;
16141
16142        #[inline(always)]
16143        fn inline_align(_context: fidl::encoding::Context) -> usize {
16144            8
16145        }
16146
16147        #[inline(always)]
16148        fn inline_size(_context: fidl::encoding::Context) -> usize {
16149            16
16150        }
16151    }
16152
16153    unsafe impl
16154        fidl::encoding::Encode<
16155            BufferCollectionTokenGroupCreateChildrenSyncResponse,
16156            fdomain_client::fidl::FDomainResourceDialect,
16157        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
16158    {
16159        unsafe fn encode(
16160            self,
16161            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16162            offset: usize,
16163            mut depth: fidl::encoding::Depth,
16164        ) -> fidl::Result<()> {
16165            encoder
16166                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
16167            // Vector header
16168            let max_ordinal: u64 = self.max_ordinal_present();
16169            encoder.write_num(max_ordinal, offset);
16170            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16171            // Calling encoder.out_of_line_offset(0) is not allowed.
16172            if max_ordinal == 0 {
16173                return Ok(());
16174            }
16175            depth.increment()?;
16176            let envelope_size = 8;
16177            let bytes_len = max_ordinal as usize * envelope_size;
16178            #[allow(unused_variables)]
16179            let offset = encoder.out_of_line_offset(bytes_len);
16180            let mut _prev_end_offset: usize = 0;
16181            if 1 > max_ordinal {
16182                return Ok(());
16183            }
16184
16185            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16186            // are envelope_size bytes.
16187            let cur_offset: usize = (1 - 1) * envelope_size;
16188
16189            // Zero reserved fields.
16190            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16191
16192            // Safety:
16193            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16194            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16195            //   envelope_size bytes, there is always sufficient room.
16196            fidl::encoding::encode_in_envelope_optional::<
16197                fidl::encoding::Vector<
16198                    fidl::encoding::Endpoint<
16199                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16200                    >,
16201                    64,
16202                >,
16203                fdomain_client::fidl::FDomainResourceDialect,
16204            >(
16205                self.tokens.as_mut().map(
16206                    <fidl::encoding::Vector<
16207                        fidl::encoding::Endpoint<
16208                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16209                        >,
16210                        64,
16211                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16212                ),
16213                encoder,
16214                offset + cur_offset,
16215                depth,
16216            )?;
16217
16218            _prev_end_offset = cur_offset + envelope_size;
16219
16220            Ok(())
16221        }
16222    }
16223
16224    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16225        for BufferCollectionTokenGroupCreateChildrenSyncResponse
16226    {
16227        #[inline(always)]
16228        fn new_empty() -> Self {
16229            Self::default()
16230        }
16231
16232        unsafe fn decode(
16233            &mut self,
16234            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16235            offset: usize,
16236            mut depth: fidl::encoding::Depth,
16237        ) -> fidl::Result<()> {
16238            decoder.debug_check_bounds::<Self>(offset);
16239            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16240                None => return Err(fidl::Error::NotNullable),
16241                Some(len) => len,
16242            };
16243            // Calling decoder.out_of_line_offset(0) is not allowed.
16244            if len == 0 {
16245                return Ok(());
16246            };
16247            depth.increment()?;
16248            let envelope_size = 8;
16249            let bytes_len = len * envelope_size;
16250            let offset = decoder.out_of_line_offset(bytes_len)?;
16251            // Decode the envelope for each type.
16252            let mut _next_ordinal_to_read = 0;
16253            let mut next_offset = offset;
16254            let end_offset = offset + bytes_len;
16255            _next_ordinal_to_read += 1;
16256            if next_offset >= end_offset {
16257                return Ok(());
16258            }
16259
16260            // Decode unknown envelopes for gaps in ordinals.
16261            while _next_ordinal_to_read < 1 {
16262                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16263                _next_ordinal_to_read += 1;
16264                next_offset += envelope_size;
16265            }
16266
16267            let next_out_of_line = decoder.next_out_of_line();
16268            let handles_before = decoder.remaining_handles();
16269            if let Some((inlined, num_bytes, num_handles)) =
16270                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16271            {
16272                let member_inline_size = <fidl::encoding::Vector<
16273                    fidl::encoding::Endpoint<
16274                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16275                    >,
16276                    64,
16277                > as fidl::encoding::TypeMarker>::inline_size(
16278                    decoder.context
16279                );
16280                if inlined != (member_inline_size <= 4) {
16281                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16282                }
16283                let inner_offset;
16284                let mut inner_depth = depth.clone();
16285                if inlined {
16286                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16287                    inner_offset = next_offset;
16288                } else {
16289                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16290                    inner_depth.increment()?;
16291                }
16292                let val_ref = self.tokens.get_or_insert_with(|| {
16293                    fidl::new_empty!(
16294                        fidl::encoding::Vector<
16295                            fidl::encoding::Endpoint<
16296                                fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16297                            >,
16298                            64,
16299                        >,
16300                        fdomain_client::fidl::FDomainResourceDialect
16301                    )
16302                });
16303                fidl::decode!(
16304                    fidl::encoding::Vector<
16305                        fidl::encoding::Endpoint<
16306                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16307                        >,
16308                        64,
16309                    >,
16310                    fdomain_client::fidl::FDomainResourceDialect,
16311                    val_ref,
16312                    decoder,
16313                    inner_offset,
16314                    inner_depth
16315                )?;
16316                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16317                {
16318                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16319                }
16320                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16321                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16322                }
16323            }
16324
16325            next_offset += envelope_size;
16326
16327            // Decode the remaining unknown envelopes.
16328            while next_offset < end_offset {
16329                _next_ordinal_to_read += 1;
16330                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16331                next_offset += envelope_size;
16332            }
16333
16334            Ok(())
16335        }
16336    }
16337
16338    impl BufferCollectionTokenDuplicateSyncResponse {
16339        #[inline(always)]
16340        fn max_ordinal_present(&self) -> u64 {
16341            if let Some(_) = self.tokens {
16342                return 1;
16343            }
16344            0
16345        }
16346    }
16347
16348    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
16349        type Borrowed<'a> = &'a mut Self;
16350        fn take_or_borrow<'a>(
16351            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16352        ) -> Self::Borrowed<'a> {
16353            value
16354        }
16355    }
16356
16357    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
16358        type Owned = Self;
16359
16360        #[inline(always)]
16361        fn inline_align(_context: fidl::encoding::Context) -> usize {
16362            8
16363        }
16364
16365        #[inline(always)]
16366        fn inline_size(_context: fidl::encoding::Context) -> usize {
16367            16
16368        }
16369    }
16370
16371    unsafe impl
16372        fidl::encoding::Encode<
16373            BufferCollectionTokenDuplicateSyncResponse,
16374            fdomain_client::fidl::FDomainResourceDialect,
16375        > for &mut BufferCollectionTokenDuplicateSyncResponse
16376    {
16377        unsafe fn encode(
16378            self,
16379            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16380            offset: usize,
16381            mut depth: fidl::encoding::Depth,
16382        ) -> fidl::Result<()> {
16383            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
16384            // Vector header
16385            let max_ordinal: u64 = self.max_ordinal_present();
16386            encoder.write_num(max_ordinal, offset);
16387            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16388            // Calling encoder.out_of_line_offset(0) is not allowed.
16389            if max_ordinal == 0 {
16390                return Ok(());
16391            }
16392            depth.increment()?;
16393            let envelope_size = 8;
16394            let bytes_len = max_ordinal as usize * envelope_size;
16395            #[allow(unused_variables)]
16396            let offset = encoder.out_of_line_offset(bytes_len);
16397            let mut _prev_end_offset: usize = 0;
16398            if 1 > max_ordinal {
16399                return Ok(());
16400            }
16401
16402            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16403            // are envelope_size bytes.
16404            let cur_offset: usize = (1 - 1) * envelope_size;
16405
16406            // Zero reserved fields.
16407            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16408
16409            // Safety:
16410            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16411            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16412            //   envelope_size bytes, there is always sufficient room.
16413            fidl::encoding::encode_in_envelope_optional::<
16414                fidl::encoding::Vector<
16415                    fidl::encoding::Endpoint<
16416                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16417                    >,
16418                    64,
16419                >,
16420                fdomain_client::fidl::FDomainResourceDialect,
16421            >(
16422                self.tokens.as_mut().map(
16423                    <fidl::encoding::Vector<
16424                        fidl::encoding::Endpoint<
16425                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16426                        >,
16427                        64,
16428                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16429                ),
16430                encoder,
16431                offset + cur_offset,
16432                depth,
16433            )?;
16434
16435            _prev_end_offset = cur_offset + envelope_size;
16436
16437            Ok(())
16438        }
16439    }
16440
16441    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16442        for BufferCollectionTokenDuplicateSyncResponse
16443    {
16444        #[inline(always)]
16445        fn new_empty() -> Self {
16446            Self::default()
16447        }
16448
16449        unsafe fn decode(
16450            &mut self,
16451            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16452            offset: usize,
16453            mut depth: fidl::encoding::Depth,
16454        ) -> fidl::Result<()> {
16455            decoder.debug_check_bounds::<Self>(offset);
16456            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16457                None => return Err(fidl::Error::NotNullable),
16458                Some(len) => len,
16459            };
16460            // Calling decoder.out_of_line_offset(0) is not allowed.
16461            if len == 0 {
16462                return Ok(());
16463            };
16464            depth.increment()?;
16465            let envelope_size = 8;
16466            let bytes_len = len * envelope_size;
16467            let offset = decoder.out_of_line_offset(bytes_len)?;
16468            // Decode the envelope for each type.
16469            let mut _next_ordinal_to_read = 0;
16470            let mut next_offset = offset;
16471            let end_offset = offset + bytes_len;
16472            _next_ordinal_to_read += 1;
16473            if next_offset >= end_offset {
16474                return Ok(());
16475            }
16476
16477            // Decode unknown envelopes for gaps in ordinals.
16478            while _next_ordinal_to_read < 1 {
16479                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16480                _next_ordinal_to_read += 1;
16481                next_offset += envelope_size;
16482            }
16483
16484            let next_out_of_line = decoder.next_out_of_line();
16485            let handles_before = decoder.remaining_handles();
16486            if let Some((inlined, num_bytes, num_handles)) =
16487                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16488            {
16489                let member_inline_size = <fidl::encoding::Vector<
16490                    fidl::encoding::Endpoint<
16491                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16492                    >,
16493                    64,
16494                > as fidl::encoding::TypeMarker>::inline_size(
16495                    decoder.context
16496                );
16497                if inlined != (member_inline_size <= 4) {
16498                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16499                }
16500                let inner_offset;
16501                let mut inner_depth = depth.clone();
16502                if inlined {
16503                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16504                    inner_offset = next_offset;
16505                } else {
16506                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16507                    inner_depth.increment()?;
16508                }
16509                let val_ref = self.tokens.get_or_insert_with(|| {
16510                    fidl::new_empty!(
16511                        fidl::encoding::Vector<
16512                            fidl::encoding::Endpoint<
16513                                fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16514                            >,
16515                            64,
16516                        >,
16517                        fdomain_client::fidl::FDomainResourceDialect
16518                    )
16519                });
16520                fidl::decode!(
16521                    fidl::encoding::Vector<
16522                        fidl::encoding::Endpoint<
16523                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
16524                        >,
16525                        64,
16526                    >,
16527                    fdomain_client::fidl::FDomainResourceDialect,
16528                    val_ref,
16529                    decoder,
16530                    inner_offset,
16531                    inner_depth
16532                )?;
16533                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16534                {
16535                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16536                }
16537                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16538                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16539                }
16540            }
16541
16542            next_offset += envelope_size;
16543
16544            // Decode the remaining unknown envelopes.
16545            while next_offset < end_offset {
16546                _next_ordinal_to_read += 1;
16547                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16548                next_offset += envelope_size;
16549            }
16550
16551            Ok(())
16552        }
16553    }
16554
16555    impl BufferCollectionWaitForAllBuffersAllocatedResponse {
16556        #[inline(always)]
16557        fn max_ordinal_present(&self) -> u64 {
16558            if let Some(_) = self.buffer_collection_info {
16559                return 1;
16560            }
16561            0
16562        }
16563    }
16564
16565    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForAllBuffersAllocatedResponse {
16566        type Borrowed<'a> = &'a mut Self;
16567        fn take_or_borrow<'a>(
16568            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16569        ) -> Self::Borrowed<'a> {
16570            value
16571        }
16572    }
16573
16574    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForAllBuffersAllocatedResponse {
16575        type Owned = Self;
16576
16577        #[inline(always)]
16578        fn inline_align(_context: fidl::encoding::Context) -> usize {
16579            8
16580        }
16581
16582        #[inline(always)]
16583        fn inline_size(_context: fidl::encoding::Context) -> usize {
16584            16
16585        }
16586    }
16587
16588    unsafe impl
16589        fidl::encoding::Encode<
16590            BufferCollectionWaitForAllBuffersAllocatedResponse,
16591            fdomain_client::fidl::FDomainResourceDialect,
16592        > for &mut BufferCollectionWaitForAllBuffersAllocatedResponse
16593    {
16594        unsafe fn encode(
16595            self,
16596            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16597            offset: usize,
16598            mut depth: fidl::encoding::Depth,
16599        ) -> fidl::Result<()> {
16600            encoder
16601                .debug_check_bounds::<BufferCollectionWaitForAllBuffersAllocatedResponse>(offset);
16602            // Vector header
16603            let max_ordinal: u64 = self.max_ordinal_present();
16604            encoder.write_num(max_ordinal, offset);
16605            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16606            // Calling encoder.out_of_line_offset(0) is not allowed.
16607            if max_ordinal == 0 {
16608                return Ok(());
16609            }
16610            depth.increment()?;
16611            let envelope_size = 8;
16612            let bytes_len = max_ordinal as usize * envelope_size;
16613            #[allow(unused_variables)]
16614            let offset = encoder.out_of_line_offset(bytes_len);
16615            let mut _prev_end_offset: usize = 0;
16616            if 1 > max_ordinal {
16617                return Ok(());
16618            }
16619
16620            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16621            // are envelope_size bytes.
16622            let cur_offset: usize = (1 - 1) * envelope_size;
16623
16624            // Zero reserved fields.
16625            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16626
16627            // Safety:
16628            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16629            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16630            //   envelope_size bytes, there is always sufficient room.
16631            fidl::encoding::encode_in_envelope_optional::<
16632                BufferCollectionInfo,
16633                fdomain_client::fidl::FDomainResourceDialect,
16634            >(
16635                self.buffer_collection_info.as_mut().map(
16636                    <BufferCollectionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16637                ),
16638                encoder,
16639                offset + cur_offset,
16640                depth,
16641            )?;
16642
16643            _prev_end_offset = cur_offset + envelope_size;
16644
16645            Ok(())
16646        }
16647    }
16648
16649    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16650        for BufferCollectionWaitForAllBuffersAllocatedResponse
16651    {
16652        #[inline(always)]
16653        fn new_empty() -> Self {
16654            Self::default()
16655        }
16656
16657        unsafe fn decode(
16658            &mut self,
16659            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16660            offset: usize,
16661            mut depth: fidl::encoding::Depth,
16662        ) -> fidl::Result<()> {
16663            decoder.debug_check_bounds::<Self>(offset);
16664            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16665                None => return Err(fidl::Error::NotNullable),
16666                Some(len) => len,
16667            };
16668            // Calling decoder.out_of_line_offset(0) is not allowed.
16669            if len == 0 {
16670                return Ok(());
16671            };
16672            depth.increment()?;
16673            let envelope_size = 8;
16674            let bytes_len = len * envelope_size;
16675            let offset = decoder.out_of_line_offset(bytes_len)?;
16676            // Decode the envelope for each type.
16677            let mut _next_ordinal_to_read = 0;
16678            let mut next_offset = offset;
16679            let end_offset = offset + bytes_len;
16680            _next_ordinal_to_read += 1;
16681            if next_offset >= end_offset {
16682                return Ok(());
16683            }
16684
16685            // Decode unknown envelopes for gaps in ordinals.
16686            while _next_ordinal_to_read < 1 {
16687                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16688                _next_ordinal_to_read += 1;
16689                next_offset += envelope_size;
16690            }
16691
16692            let next_out_of_line = decoder.next_out_of_line();
16693            let handles_before = decoder.remaining_handles();
16694            if let Some((inlined, num_bytes, num_handles)) =
16695                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16696            {
16697                let member_inline_size =
16698                    <BufferCollectionInfo as fidl::encoding::TypeMarker>::inline_size(
16699                        decoder.context,
16700                    );
16701                if inlined != (member_inline_size <= 4) {
16702                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16703                }
16704                let inner_offset;
16705                let mut inner_depth = depth.clone();
16706                if inlined {
16707                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16708                    inner_offset = next_offset;
16709                } else {
16710                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16711                    inner_depth.increment()?;
16712                }
16713                let val_ref = self.buffer_collection_info.get_or_insert_with(|| {
16714                    fidl::new_empty!(
16715                        BufferCollectionInfo,
16716                        fdomain_client::fidl::FDomainResourceDialect
16717                    )
16718                });
16719                fidl::decode!(
16720                    BufferCollectionInfo,
16721                    fdomain_client::fidl::FDomainResourceDialect,
16722                    val_ref,
16723                    decoder,
16724                    inner_offset,
16725                    inner_depth
16726                )?;
16727                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16728                {
16729                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16730                }
16731                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16732                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16733                }
16734            }
16735
16736            next_offset += envelope_size;
16737
16738            // Decode the remaining unknown envelopes.
16739            while next_offset < end_offset {
16740                _next_ordinal_to_read += 1;
16741                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16742                next_offset += envelope_size;
16743            }
16744
16745            Ok(())
16746        }
16747    }
16748
16749    impl NodeAttachNodeTrackingRequest {
16750        #[inline(always)]
16751        fn max_ordinal_present(&self) -> u64 {
16752            if let Some(_) = self.server_end {
16753                return 1;
16754            }
16755            0
16756        }
16757    }
16758
16759    impl fidl::encoding::ResourceTypeMarker for NodeAttachNodeTrackingRequest {
16760        type Borrowed<'a> = &'a mut Self;
16761        fn take_or_borrow<'a>(
16762            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16763        ) -> Self::Borrowed<'a> {
16764            value
16765        }
16766    }
16767
16768    unsafe impl fidl::encoding::TypeMarker for NodeAttachNodeTrackingRequest {
16769        type Owned = Self;
16770
16771        #[inline(always)]
16772        fn inline_align(_context: fidl::encoding::Context) -> usize {
16773            8
16774        }
16775
16776        #[inline(always)]
16777        fn inline_size(_context: fidl::encoding::Context) -> usize {
16778            16
16779        }
16780    }
16781
16782    unsafe impl
16783        fidl::encoding::Encode<
16784            NodeAttachNodeTrackingRequest,
16785            fdomain_client::fidl::FDomainResourceDialect,
16786        > for &mut NodeAttachNodeTrackingRequest
16787    {
16788        unsafe fn encode(
16789            self,
16790            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16791            offset: usize,
16792            mut depth: fidl::encoding::Depth,
16793        ) -> fidl::Result<()> {
16794            encoder.debug_check_bounds::<NodeAttachNodeTrackingRequest>(offset);
16795            // Vector header
16796            let max_ordinal: u64 = self.max_ordinal_present();
16797            encoder.write_num(max_ordinal, offset);
16798            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16799            // Calling encoder.out_of_line_offset(0) is not allowed.
16800            if max_ordinal == 0 {
16801                return Ok(());
16802            }
16803            depth.increment()?;
16804            let envelope_size = 8;
16805            let bytes_len = max_ordinal as usize * envelope_size;
16806            #[allow(unused_variables)]
16807            let offset = encoder.out_of_line_offset(bytes_len);
16808            let mut _prev_end_offset: usize = 0;
16809            if 1 > max_ordinal {
16810                return Ok(());
16811            }
16812
16813            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16814            // are envelope_size bytes.
16815            let cur_offset: usize = (1 - 1) * envelope_size;
16816
16817            // Zero reserved fields.
16818            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16819
16820            // Safety:
16821            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16822            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16823            //   envelope_size bytes, there is always sufficient room.
16824            fidl::encoding::encode_in_envelope_optional::<
16825                fidl::encoding::HandleType<
16826                    fdomain_client::EventPair,
16827                    { fidl::ObjectType::EVENTPAIR.into_raw() },
16828                    2147483648,
16829                >,
16830                fdomain_client::fidl::FDomainResourceDialect,
16831            >(
16832                self.server_end.as_mut().map(
16833                    <fidl::encoding::HandleType<
16834                        fdomain_client::EventPair,
16835                        { fidl::ObjectType::EVENTPAIR.into_raw() },
16836                        2147483648,
16837                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16838                ),
16839                encoder,
16840                offset + cur_offset,
16841                depth,
16842            )?;
16843
16844            _prev_end_offset = cur_offset + envelope_size;
16845
16846            Ok(())
16847        }
16848    }
16849
16850    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16851        for NodeAttachNodeTrackingRequest
16852    {
16853        #[inline(always)]
16854        fn new_empty() -> Self {
16855            Self::default()
16856        }
16857
16858        unsafe fn decode(
16859            &mut self,
16860            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16861            offset: usize,
16862            mut depth: fidl::encoding::Depth,
16863        ) -> fidl::Result<()> {
16864            decoder.debug_check_bounds::<Self>(offset);
16865            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16866                None => return Err(fidl::Error::NotNullable),
16867                Some(len) => len,
16868            };
16869            // Calling decoder.out_of_line_offset(0) is not allowed.
16870            if len == 0 {
16871                return Ok(());
16872            };
16873            depth.increment()?;
16874            let envelope_size = 8;
16875            let bytes_len = len * envelope_size;
16876            let offset = decoder.out_of_line_offset(bytes_len)?;
16877            // Decode the envelope for each type.
16878            let mut _next_ordinal_to_read = 0;
16879            let mut next_offset = offset;
16880            let end_offset = offset + bytes_len;
16881            _next_ordinal_to_read += 1;
16882            if next_offset >= end_offset {
16883                return Ok(());
16884            }
16885
16886            // Decode unknown envelopes for gaps in ordinals.
16887            while _next_ordinal_to_read < 1 {
16888                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16889                _next_ordinal_to_read += 1;
16890                next_offset += envelope_size;
16891            }
16892
16893            let next_out_of_line = decoder.next_out_of_line();
16894            let handles_before = decoder.remaining_handles();
16895            if let Some((inlined, num_bytes, num_handles)) =
16896                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16897            {
16898                let member_inline_size = <fidl::encoding::HandleType<
16899                    fdomain_client::EventPair,
16900                    { fidl::ObjectType::EVENTPAIR.into_raw() },
16901                    2147483648,
16902                > as fidl::encoding::TypeMarker>::inline_size(
16903                    decoder.context
16904                );
16905                if inlined != (member_inline_size <= 4) {
16906                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16907                }
16908                let inner_offset;
16909                let mut inner_depth = depth.clone();
16910                if inlined {
16911                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16912                    inner_offset = next_offset;
16913                } else {
16914                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16915                    inner_depth.increment()?;
16916                }
16917                let val_ref =
16918                self.server_end.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
16919                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
16920                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16921                {
16922                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16923                }
16924                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16925                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16926                }
16927            }
16928
16929            next_offset += envelope_size;
16930
16931            // Decode the remaining unknown envelopes.
16932            while next_offset < end_offset {
16933                _next_ordinal_to_read += 1;
16934                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16935                next_offset += envelope_size;
16936            }
16937
16938            Ok(())
16939        }
16940    }
16941
16942    impl NodeIsAlternateForRequest {
16943        #[inline(always)]
16944        fn max_ordinal_present(&self) -> u64 {
16945            if let Some(_) = self.node_ref {
16946                return 1;
16947            }
16948            0
16949        }
16950    }
16951
16952    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
16953        type Borrowed<'a> = &'a mut Self;
16954        fn take_or_borrow<'a>(
16955            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16956        ) -> Self::Borrowed<'a> {
16957            value
16958        }
16959    }
16960
16961    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
16962        type Owned = Self;
16963
16964        #[inline(always)]
16965        fn inline_align(_context: fidl::encoding::Context) -> usize {
16966            8
16967        }
16968
16969        #[inline(always)]
16970        fn inline_size(_context: fidl::encoding::Context) -> usize {
16971            16
16972        }
16973    }
16974
16975    unsafe impl
16976        fidl::encoding::Encode<
16977            NodeIsAlternateForRequest,
16978            fdomain_client::fidl::FDomainResourceDialect,
16979        > for &mut NodeIsAlternateForRequest
16980    {
16981        unsafe fn encode(
16982            self,
16983            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16984            offset: usize,
16985            mut depth: fidl::encoding::Depth,
16986        ) -> fidl::Result<()> {
16987            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
16988            // Vector header
16989            let max_ordinal: u64 = self.max_ordinal_present();
16990            encoder.write_num(max_ordinal, offset);
16991            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16992            // Calling encoder.out_of_line_offset(0) is not allowed.
16993            if max_ordinal == 0 {
16994                return Ok(());
16995            }
16996            depth.increment()?;
16997            let envelope_size = 8;
16998            let bytes_len = max_ordinal as usize * envelope_size;
16999            #[allow(unused_variables)]
17000            let offset = encoder.out_of_line_offset(bytes_len);
17001            let mut _prev_end_offset: usize = 0;
17002            if 1 > max_ordinal {
17003                return Ok(());
17004            }
17005
17006            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17007            // are envelope_size bytes.
17008            let cur_offset: usize = (1 - 1) * envelope_size;
17009
17010            // Zero reserved fields.
17011            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17012
17013            // Safety:
17014            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17015            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17016            //   envelope_size bytes, there is always sufficient room.
17017            fidl::encoding::encode_in_envelope_optional::<
17018                fidl::encoding::HandleType<
17019                    fdomain_client::Event,
17020                    { fidl::ObjectType::EVENT.into_raw() },
17021                    2147483648,
17022                >,
17023                fdomain_client::fidl::FDomainResourceDialect,
17024            >(
17025                self.node_ref.as_mut().map(
17026                    <fidl::encoding::HandleType<
17027                        fdomain_client::Event,
17028                        { fidl::ObjectType::EVENT.into_raw() },
17029                        2147483648,
17030                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17031                ),
17032                encoder,
17033                offset + cur_offset,
17034                depth,
17035            )?;
17036
17037            _prev_end_offset = cur_offset + envelope_size;
17038
17039            Ok(())
17040        }
17041    }
17042
17043    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17044        for NodeIsAlternateForRequest
17045    {
17046        #[inline(always)]
17047        fn new_empty() -> Self {
17048            Self::default()
17049        }
17050
17051        unsafe fn decode(
17052            &mut self,
17053            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17054            offset: usize,
17055            mut depth: fidl::encoding::Depth,
17056        ) -> fidl::Result<()> {
17057            decoder.debug_check_bounds::<Self>(offset);
17058            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17059                None => return Err(fidl::Error::NotNullable),
17060                Some(len) => len,
17061            };
17062            // Calling decoder.out_of_line_offset(0) is not allowed.
17063            if len == 0 {
17064                return Ok(());
17065            };
17066            depth.increment()?;
17067            let envelope_size = 8;
17068            let bytes_len = len * envelope_size;
17069            let offset = decoder.out_of_line_offset(bytes_len)?;
17070            // Decode the envelope for each type.
17071            let mut _next_ordinal_to_read = 0;
17072            let mut next_offset = offset;
17073            let end_offset = offset + bytes_len;
17074            _next_ordinal_to_read += 1;
17075            if next_offset >= end_offset {
17076                return Ok(());
17077            }
17078
17079            // Decode unknown envelopes for gaps in ordinals.
17080            while _next_ordinal_to_read < 1 {
17081                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17082                _next_ordinal_to_read += 1;
17083                next_offset += envelope_size;
17084            }
17085
17086            let next_out_of_line = decoder.next_out_of_line();
17087            let handles_before = decoder.remaining_handles();
17088            if let Some((inlined, num_bytes, num_handles)) =
17089                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17090            {
17091                let member_inline_size = <fidl::encoding::HandleType<
17092                    fdomain_client::Event,
17093                    { fidl::ObjectType::EVENT.into_raw() },
17094                    2147483648,
17095                > as fidl::encoding::TypeMarker>::inline_size(
17096                    decoder.context
17097                );
17098                if inlined != (member_inline_size <= 4) {
17099                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17100                }
17101                let inner_offset;
17102                let mut inner_depth = depth.clone();
17103                if inlined {
17104                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17105                    inner_offset = next_offset;
17106                } else {
17107                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17108                    inner_depth.increment()?;
17109                }
17110                let val_ref =
17111                self.node_ref.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
17112                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
17113                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17114                {
17115                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17116                }
17117                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17118                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17119                }
17120            }
17121
17122            next_offset += envelope_size;
17123
17124            // Decode the remaining unknown envelopes.
17125            while next_offset < end_offset {
17126                _next_ordinal_to_read += 1;
17127                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17128                next_offset += envelope_size;
17129            }
17130
17131            Ok(())
17132        }
17133    }
17134
17135    impl NodeSetWeakOkRequest {
17136        #[inline(always)]
17137        fn max_ordinal_present(&self) -> u64 {
17138            if let Some(_) = self.for_child_nodes_also {
17139                return 1;
17140            }
17141            0
17142        }
17143    }
17144
17145    impl fidl::encoding::ResourceTypeMarker for NodeSetWeakOkRequest {
17146        type Borrowed<'a> = &'a mut Self;
17147        fn take_or_borrow<'a>(
17148            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17149        ) -> Self::Borrowed<'a> {
17150            value
17151        }
17152    }
17153
17154    unsafe impl fidl::encoding::TypeMarker for NodeSetWeakOkRequest {
17155        type Owned = Self;
17156
17157        #[inline(always)]
17158        fn inline_align(_context: fidl::encoding::Context) -> usize {
17159            8
17160        }
17161
17162        #[inline(always)]
17163        fn inline_size(_context: fidl::encoding::Context) -> usize {
17164            16
17165        }
17166    }
17167
17168    unsafe impl
17169        fidl::encoding::Encode<NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect>
17170        for &mut NodeSetWeakOkRequest
17171    {
17172        unsafe fn encode(
17173            self,
17174            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17175            offset: usize,
17176            mut depth: fidl::encoding::Depth,
17177        ) -> fidl::Result<()> {
17178            encoder.debug_check_bounds::<NodeSetWeakOkRequest>(offset);
17179            // Vector header
17180            let max_ordinal: u64 = self.max_ordinal_present();
17181            encoder.write_num(max_ordinal, offset);
17182            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17183            // Calling encoder.out_of_line_offset(0) is not allowed.
17184            if max_ordinal == 0 {
17185                return Ok(());
17186            }
17187            depth.increment()?;
17188            let envelope_size = 8;
17189            let bytes_len = max_ordinal as usize * envelope_size;
17190            #[allow(unused_variables)]
17191            let offset = encoder.out_of_line_offset(bytes_len);
17192            let mut _prev_end_offset: usize = 0;
17193            if 1 > max_ordinal {
17194                return Ok(());
17195            }
17196
17197            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17198            // are envelope_size bytes.
17199            let cur_offset: usize = (1 - 1) * envelope_size;
17200
17201            // Zero reserved fields.
17202            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17203
17204            // Safety:
17205            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17206            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17207            //   envelope_size bytes, there is always sufficient room.
17208            fidl::encoding::encode_in_envelope_optional::<
17209                bool,
17210                fdomain_client::fidl::FDomainResourceDialect,
17211            >(
17212                self.for_child_nodes_also
17213                    .as_ref()
17214                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
17215                encoder,
17216                offset + cur_offset,
17217                depth,
17218            )?;
17219
17220            _prev_end_offset = cur_offset + envelope_size;
17221
17222            Ok(())
17223        }
17224    }
17225
17226    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17227        for NodeSetWeakOkRequest
17228    {
17229        #[inline(always)]
17230        fn new_empty() -> Self {
17231            Self::default()
17232        }
17233
17234        unsafe fn decode(
17235            &mut self,
17236            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17237            offset: usize,
17238            mut depth: fidl::encoding::Depth,
17239        ) -> fidl::Result<()> {
17240            decoder.debug_check_bounds::<Self>(offset);
17241            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17242                None => return Err(fidl::Error::NotNullable),
17243                Some(len) => len,
17244            };
17245            // Calling decoder.out_of_line_offset(0) is not allowed.
17246            if len == 0 {
17247                return Ok(());
17248            };
17249            depth.increment()?;
17250            let envelope_size = 8;
17251            let bytes_len = len * envelope_size;
17252            let offset = decoder.out_of_line_offset(bytes_len)?;
17253            // Decode the envelope for each type.
17254            let mut _next_ordinal_to_read = 0;
17255            let mut next_offset = offset;
17256            let end_offset = offset + bytes_len;
17257            _next_ordinal_to_read += 1;
17258            if next_offset >= end_offset {
17259                return Ok(());
17260            }
17261
17262            // Decode unknown envelopes for gaps in ordinals.
17263            while _next_ordinal_to_read < 1 {
17264                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17265                _next_ordinal_to_read += 1;
17266                next_offset += envelope_size;
17267            }
17268
17269            let next_out_of_line = decoder.next_out_of_line();
17270            let handles_before = decoder.remaining_handles();
17271            if let Some((inlined, num_bytes, num_handles)) =
17272                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17273            {
17274                let member_inline_size =
17275                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17276                if inlined != (member_inline_size <= 4) {
17277                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17278                }
17279                let inner_offset;
17280                let mut inner_depth = depth.clone();
17281                if inlined {
17282                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17283                    inner_offset = next_offset;
17284                } else {
17285                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17286                    inner_depth.increment()?;
17287                }
17288                let val_ref = self.for_child_nodes_also.get_or_insert_with(|| {
17289                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
17290                });
17291                fidl::decode!(
17292                    bool,
17293                    fdomain_client::fidl::FDomainResourceDialect,
17294                    val_ref,
17295                    decoder,
17296                    inner_offset,
17297                    inner_depth
17298                )?;
17299                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17300                {
17301                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17302                }
17303                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17304                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17305                }
17306            }
17307
17308            next_offset += envelope_size;
17309
17310            // Decode the remaining unknown envelopes.
17311            while next_offset < end_offset {
17312                _next_ordinal_to_read += 1;
17313                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17314                next_offset += envelope_size;
17315            }
17316
17317            Ok(())
17318        }
17319    }
17320
17321    impl NodeGetNodeRefResponse {
17322        #[inline(always)]
17323        fn max_ordinal_present(&self) -> u64 {
17324            if let Some(_) = self.node_ref {
17325                return 1;
17326            }
17327            0
17328        }
17329    }
17330
17331    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
17332        type Borrowed<'a> = &'a mut Self;
17333        fn take_or_borrow<'a>(
17334            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17335        ) -> Self::Borrowed<'a> {
17336            value
17337        }
17338    }
17339
17340    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
17341        type Owned = Self;
17342
17343        #[inline(always)]
17344        fn inline_align(_context: fidl::encoding::Context) -> usize {
17345            8
17346        }
17347
17348        #[inline(always)]
17349        fn inline_size(_context: fidl::encoding::Context) -> usize {
17350            16
17351        }
17352    }
17353
17354    unsafe impl
17355        fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
17356        for &mut NodeGetNodeRefResponse
17357    {
17358        unsafe fn encode(
17359            self,
17360            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17361            offset: usize,
17362            mut depth: fidl::encoding::Depth,
17363        ) -> fidl::Result<()> {
17364            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
17365            // Vector header
17366            let max_ordinal: u64 = self.max_ordinal_present();
17367            encoder.write_num(max_ordinal, offset);
17368            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17369            // Calling encoder.out_of_line_offset(0) is not allowed.
17370            if max_ordinal == 0 {
17371                return Ok(());
17372            }
17373            depth.increment()?;
17374            let envelope_size = 8;
17375            let bytes_len = max_ordinal as usize * envelope_size;
17376            #[allow(unused_variables)]
17377            let offset = encoder.out_of_line_offset(bytes_len);
17378            let mut _prev_end_offset: usize = 0;
17379            if 1 > max_ordinal {
17380                return Ok(());
17381            }
17382
17383            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17384            // are envelope_size bytes.
17385            let cur_offset: usize = (1 - 1) * envelope_size;
17386
17387            // Zero reserved fields.
17388            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17389
17390            // Safety:
17391            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17392            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17393            //   envelope_size bytes, there is always sufficient room.
17394            fidl::encoding::encode_in_envelope_optional::<
17395                fidl::encoding::HandleType<
17396                    fdomain_client::Event,
17397                    { fidl::ObjectType::EVENT.into_raw() },
17398                    2147483648,
17399                >,
17400                fdomain_client::fidl::FDomainResourceDialect,
17401            >(
17402                self.node_ref.as_mut().map(
17403                    <fidl::encoding::HandleType<
17404                        fdomain_client::Event,
17405                        { fidl::ObjectType::EVENT.into_raw() },
17406                        2147483648,
17407                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17408                ),
17409                encoder,
17410                offset + cur_offset,
17411                depth,
17412            )?;
17413
17414            _prev_end_offset = cur_offset + envelope_size;
17415
17416            Ok(())
17417        }
17418    }
17419
17420    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17421        for NodeGetNodeRefResponse
17422    {
17423        #[inline(always)]
17424        fn new_empty() -> Self {
17425            Self::default()
17426        }
17427
17428        unsafe fn decode(
17429            &mut self,
17430            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17431            offset: usize,
17432            mut depth: fidl::encoding::Depth,
17433        ) -> fidl::Result<()> {
17434            decoder.debug_check_bounds::<Self>(offset);
17435            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17436                None => return Err(fidl::Error::NotNullable),
17437                Some(len) => len,
17438            };
17439            // Calling decoder.out_of_line_offset(0) is not allowed.
17440            if len == 0 {
17441                return Ok(());
17442            };
17443            depth.increment()?;
17444            let envelope_size = 8;
17445            let bytes_len = len * envelope_size;
17446            let offset = decoder.out_of_line_offset(bytes_len)?;
17447            // Decode the envelope for each type.
17448            let mut _next_ordinal_to_read = 0;
17449            let mut next_offset = offset;
17450            let end_offset = offset + bytes_len;
17451            _next_ordinal_to_read += 1;
17452            if next_offset >= end_offset {
17453                return Ok(());
17454            }
17455
17456            // Decode unknown envelopes for gaps in ordinals.
17457            while _next_ordinal_to_read < 1 {
17458                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17459                _next_ordinal_to_read += 1;
17460                next_offset += envelope_size;
17461            }
17462
17463            let next_out_of_line = decoder.next_out_of_line();
17464            let handles_before = decoder.remaining_handles();
17465            if let Some((inlined, num_bytes, num_handles)) =
17466                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17467            {
17468                let member_inline_size = <fidl::encoding::HandleType<
17469                    fdomain_client::Event,
17470                    { fidl::ObjectType::EVENT.into_raw() },
17471                    2147483648,
17472                > as fidl::encoding::TypeMarker>::inline_size(
17473                    decoder.context
17474                );
17475                if inlined != (member_inline_size <= 4) {
17476                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17477                }
17478                let inner_offset;
17479                let mut inner_depth = depth.clone();
17480                if inlined {
17481                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17482                    inner_offset = next_offset;
17483                } else {
17484                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17485                    inner_depth.increment()?;
17486                }
17487                let val_ref =
17488                self.node_ref.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
17489                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
17490                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17491                {
17492                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17493                }
17494                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17495                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17496                }
17497            }
17498
17499            next_offset += envelope_size;
17500
17501            // Decode the remaining unknown envelopes.
17502            while next_offset < end_offset {
17503                _next_ordinal_to_read += 1;
17504                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17505                next_offset += envelope_size;
17506            }
17507
17508            Ok(())
17509        }
17510    }
17511
17512    impl VmoBuffer {
17513        #[inline(always)]
17514        fn max_ordinal_present(&self) -> u64 {
17515            if let Some(_) = self.close_weak_asap {
17516                return 3;
17517            }
17518            if let Some(_) = self.vmo_usable_start {
17519                return 2;
17520            }
17521            if let Some(_) = self.vmo {
17522                return 1;
17523            }
17524            0
17525        }
17526    }
17527
17528    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
17529        type Borrowed<'a> = &'a mut Self;
17530        fn take_or_borrow<'a>(
17531            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17532        ) -> Self::Borrowed<'a> {
17533            value
17534        }
17535    }
17536
17537    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
17538        type Owned = Self;
17539
17540        #[inline(always)]
17541        fn inline_align(_context: fidl::encoding::Context) -> usize {
17542            8
17543        }
17544
17545        #[inline(always)]
17546        fn inline_size(_context: fidl::encoding::Context) -> usize {
17547            16
17548        }
17549    }
17550
17551    unsafe impl fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>
17552        for &mut VmoBuffer
17553    {
17554        unsafe fn encode(
17555            self,
17556            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17557            offset: usize,
17558            mut depth: fidl::encoding::Depth,
17559        ) -> fidl::Result<()> {
17560            encoder.debug_check_bounds::<VmoBuffer>(offset);
17561            // Vector header
17562            let max_ordinal: u64 = self.max_ordinal_present();
17563            encoder.write_num(max_ordinal, offset);
17564            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17565            // Calling encoder.out_of_line_offset(0) is not allowed.
17566            if max_ordinal == 0 {
17567                return Ok(());
17568            }
17569            depth.increment()?;
17570            let envelope_size = 8;
17571            let bytes_len = max_ordinal as usize * envelope_size;
17572            #[allow(unused_variables)]
17573            let offset = encoder.out_of_line_offset(bytes_len);
17574            let mut _prev_end_offset: usize = 0;
17575            if 1 > max_ordinal {
17576                return Ok(());
17577            }
17578
17579            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17580            // are envelope_size bytes.
17581            let cur_offset: usize = (1 - 1) * envelope_size;
17582
17583            // Zero reserved fields.
17584            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17585
17586            // Safety:
17587            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17588            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17589            //   envelope_size bytes, there is always sufficient room.
17590            fidl::encoding::encode_in_envelope_optional::<
17591                fidl::encoding::HandleType<
17592                    fdomain_client::Vmo,
17593                    { fidl::ObjectType::VMO.into_raw() },
17594                    2147483648,
17595                >,
17596                fdomain_client::fidl::FDomainResourceDialect,
17597            >(
17598                self.vmo.as_mut().map(
17599                    <fidl::encoding::HandleType<
17600                        fdomain_client::Vmo,
17601                        { fidl::ObjectType::VMO.into_raw() },
17602                        2147483648,
17603                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17604                ),
17605                encoder,
17606                offset + cur_offset,
17607                depth,
17608            )?;
17609
17610            _prev_end_offset = cur_offset + envelope_size;
17611            if 2 > max_ordinal {
17612                return Ok(());
17613            }
17614
17615            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17616            // are envelope_size bytes.
17617            let cur_offset: usize = (2 - 1) * envelope_size;
17618
17619            // Zero reserved fields.
17620            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17621
17622            // Safety:
17623            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17624            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17625            //   envelope_size bytes, there is always sufficient room.
17626            fidl::encoding::encode_in_envelope_optional::<
17627                u64,
17628                fdomain_client::fidl::FDomainResourceDialect,
17629            >(
17630                self.vmo_usable_start
17631                    .as_ref()
17632                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
17633                encoder,
17634                offset + cur_offset,
17635                depth,
17636            )?;
17637
17638            _prev_end_offset = cur_offset + envelope_size;
17639            if 3 > max_ordinal {
17640                return Ok(());
17641            }
17642
17643            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17644            // are envelope_size bytes.
17645            let cur_offset: usize = (3 - 1) * envelope_size;
17646
17647            // Zero reserved fields.
17648            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17649
17650            // Safety:
17651            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17652            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17653            //   envelope_size bytes, there is always sufficient room.
17654            fidl::encoding::encode_in_envelope_optional::<
17655                fidl::encoding::HandleType<
17656                    fdomain_client::EventPair,
17657                    { fidl::ObjectType::EVENTPAIR.into_raw() },
17658                    2147483648,
17659                >,
17660                fdomain_client::fidl::FDomainResourceDialect,
17661            >(
17662                self.close_weak_asap.as_mut().map(
17663                    <fidl::encoding::HandleType<
17664                        fdomain_client::EventPair,
17665                        { fidl::ObjectType::EVENTPAIR.into_raw() },
17666                        2147483648,
17667                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17668                ),
17669                encoder,
17670                offset + cur_offset,
17671                depth,
17672            )?;
17673
17674            _prev_end_offset = cur_offset + envelope_size;
17675
17676            Ok(())
17677        }
17678    }
17679
17680    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {
17681        #[inline(always)]
17682        fn new_empty() -> Self {
17683            Self::default()
17684        }
17685
17686        unsafe fn decode(
17687            &mut self,
17688            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17689            offset: usize,
17690            mut depth: fidl::encoding::Depth,
17691        ) -> fidl::Result<()> {
17692            decoder.debug_check_bounds::<Self>(offset);
17693            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17694                None => return Err(fidl::Error::NotNullable),
17695                Some(len) => len,
17696            };
17697            // Calling decoder.out_of_line_offset(0) is not allowed.
17698            if len == 0 {
17699                return Ok(());
17700            };
17701            depth.increment()?;
17702            let envelope_size = 8;
17703            let bytes_len = len * envelope_size;
17704            let offset = decoder.out_of_line_offset(bytes_len)?;
17705            // Decode the envelope for each type.
17706            let mut _next_ordinal_to_read = 0;
17707            let mut next_offset = offset;
17708            let end_offset = offset + bytes_len;
17709            _next_ordinal_to_read += 1;
17710            if next_offset >= end_offset {
17711                return Ok(());
17712            }
17713
17714            // Decode unknown envelopes for gaps in ordinals.
17715            while _next_ordinal_to_read < 1 {
17716                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17717                _next_ordinal_to_read += 1;
17718                next_offset += envelope_size;
17719            }
17720
17721            let next_out_of_line = decoder.next_out_of_line();
17722            let handles_before = decoder.remaining_handles();
17723            if let Some((inlined, num_bytes, num_handles)) =
17724                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17725            {
17726                let member_inline_size = <fidl::encoding::HandleType<
17727                    fdomain_client::Vmo,
17728                    { fidl::ObjectType::VMO.into_raw() },
17729                    2147483648,
17730                > as fidl::encoding::TypeMarker>::inline_size(
17731                    decoder.context
17732                );
17733                if inlined != (member_inline_size <= 4) {
17734                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17735                }
17736                let inner_offset;
17737                let mut inner_depth = depth.clone();
17738                if inlined {
17739                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17740                    inner_offset = next_offset;
17741                } else {
17742                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17743                    inner_depth.increment()?;
17744                }
17745                let val_ref =
17746                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
17747                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
17748                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17749                {
17750                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17751                }
17752                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17753                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17754                }
17755            }
17756
17757            next_offset += envelope_size;
17758            _next_ordinal_to_read += 1;
17759            if next_offset >= end_offset {
17760                return Ok(());
17761            }
17762
17763            // Decode unknown envelopes for gaps in ordinals.
17764            while _next_ordinal_to_read < 2 {
17765                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17766                _next_ordinal_to_read += 1;
17767                next_offset += envelope_size;
17768            }
17769
17770            let next_out_of_line = decoder.next_out_of_line();
17771            let handles_before = decoder.remaining_handles();
17772            if let Some((inlined, num_bytes, num_handles)) =
17773                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17774            {
17775                let member_inline_size =
17776                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17777                if inlined != (member_inline_size <= 4) {
17778                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17779                }
17780                let inner_offset;
17781                let mut inner_depth = depth.clone();
17782                if inlined {
17783                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17784                    inner_offset = next_offset;
17785                } else {
17786                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17787                    inner_depth.increment()?;
17788                }
17789                let val_ref = self.vmo_usable_start.get_or_insert_with(|| {
17790                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
17791                });
17792                fidl::decode!(
17793                    u64,
17794                    fdomain_client::fidl::FDomainResourceDialect,
17795                    val_ref,
17796                    decoder,
17797                    inner_offset,
17798                    inner_depth
17799                )?;
17800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17801                {
17802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17803                }
17804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17806                }
17807            }
17808
17809            next_offset += envelope_size;
17810            _next_ordinal_to_read += 1;
17811            if next_offset >= end_offset {
17812                return Ok(());
17813            }
17814
17815            // Decode unknown envelopes for gaps in ordinals.
17816            while _next_ordinal_to_read < 3 {
17817                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17818                _next_ordinal_to_read += 1;
17819                next_offset += envelope_size;
17820            }
17821
17822            let next_out_of_line = decoder.next_out_of_line();
17823            let handles_before = decoder.remaining_handles();
17824            if let Some((inlined, num_bytes, num_handles)) =
17825                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17826            {
17827                let member_inline_size = <fidl::encoding::HandleType<
17828                    fdomain_client::EventPair,
17829                    { fidl::ObjectType::EVENTPAIR.into_raw() },
17830                    2147483648,
17831                > as fidl::encoding::TypeMarker>::inline_size(
17832                    decoder.context
17833                );
17834                if inlined != (member_inline_size <= 4) {
17835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17836                }
17837                let inner_offset;
17838                let mut inner_depth = depth.clone();
17839                if inlined {
17840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17841                    inner_offset = next_offset;
17842                } else {
17843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17844                    inner_depth.increment()?;
17845                }
17846                let val_ref =
17847                self.close_weak_asap.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
17848                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
17849                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17850                {
17851                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17852                }
17853                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17854                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17855                }
17856            }
17857
17858            next_offset += envelope_size;
17859
17860            // Decode the remaining unknown envelopes.
17861            while next_offset < end_offset {
17862                _next_ordinal_to_read += 1;
17863                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17864                next_offset += envelope_size;
17865            }
17866
17867            Ok(())
17868        }
17869    }
17870}