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    ///
56    /// The GetVmoInfo call will fail with `NOT_FOUND` if this VMO isn't a
57    /// sysmem-provided VMO. Children of sysmem-provided VMOs don't count as
58    /// sysmem-provided VMOs.
59    ///
60    /// Assuming this is a sysmem-provided VMO, the handle can be a sysmem
61    /// strong VMO handle or a sysmem weak VMO handle.
62    ///
63    /// If this field is sysmem weak VMO handle, `close_weak_asap` will be
64    /// set in the response (not the only reason for close_weak_asap to be
65    /// set).
66    ///
67    /// This field is required.
68    pub vmo: Option<fdomain_client::Vmo>,
69    /// Iff set to true, a successful response will have weak_vmo set to a
70    /// sysmem weak VMO handle for the buffer, regardless of whether the vmo
71    /// handle in the request was weak or not.
72    ///
73    /// Also, when `weak_vmo` is set in the response, `close_weak_asap` will
74    /// also be set in the response, whether `vmo` was sysmem strong or
75    /// sysmem weak (not the only reason for close_weak_asap to be set).
76    ///
77    /// If set to true and `vmo` is a weak vmo and there aren't any
78    /// remaining strong vmo handles for the logical buffer (and the sysmem
79    /// server has had a chance to notice that), the request will fail with
80    /// `Error.NO_MORE_STRONG_VMO_HANDLES`.
81    ///
82    /// This field is optional. The default is false.
83    pub need_weak: Option<bool>,
84    /// Iff set to true, a successful response will have
85    /// single_buffer_settings set to the SingleBufferSettings for the
86    /// buffer's buffer collection.
87    ///
88    /// The fields in SingleBufferSettings can be thought of as similar in
89    /// nature to the information available from zx_object_get_info with
90    /// topic ZX_INFO_VMO, which doesn't require any rights on the VMO
91    /// handle to succeed. This information can be needed by the caller to
92    /// know how to correctly handle / use the VMO. Similarly, this call
93    /// doesn't require any particular rights in order to get
94    /// single_buffer_settings - just ZX_RIGHT_TRANSFER for the client's
95    /// message to send successfully, and of course the `vmo` field must be
96    /// a handle to a sysmem-provided VMO.
97    ///
98    /// Clients should avoid manually checking whether
99    /// `single_buffer_settings` is consistent with the client's
100    /// BufferCollectionConstraints (or at least, shouldn't only rely on
101    /// that checking in the client). To have sysmem check, see
102    /// `constraints_to_check`.
103    ///
104    /// This field is optional. The default is false.
105    pub need_single_buffer_settings: Option<bool>,
106    /// Iff set, `constraints_ok` will be set in the response indicating
107    /// whether the sent constraints are compatible with the parent buffer
108    /// collection as allocated.
109    ///
110    /// Buffer counts are not checked for consistency, as there's no way for
111    /// sysmem to know whether the passed-in `vmo` was originally handed out
112    /// to the same logical participant that's now checking the vmo against
113    /// its constraints, and we also want to avoid adding things that might
114    /// lock sysmem into a static number of buffers per collection.
115    ///
116    /// This can be thought of as checking `constraints_to_check` against
117    /// the `single_buffer_settings` (if that is/were requested), but sysmem
118    /// is free to check against additional info as well (such as a
119    /// hypothetical future sysmem3's buffer collection info, or modified
120    /// semantics for sysmem2 fields that this client hasn't opted into, or
121    /// similar). In other words, clients should let sysmem do this check,
122    /// regardless of whether the client also does some checking of its own.
123    ///
124    /// This field is optional. If un-set, no constraints checking occurs.
125    pub constraints_to_check: Option<BufferCollectionConstraints>,
126    /// If set, `vmo_settings_match` will be set to indicate whether the
127    /// parent collection of `vmo` and `vmo_settings_to_check` have the same
128    /// SingleBufferSettings. This will be true if both are the same VMO,
129    /// will be true if both VMOs are from the same collection, and can also
130    /// be true if two VMOs from different collections have the same
131    /// SingleBufferSettings.
132    pub vmo_settings_to_check: Option<fdomain_client::Vmo>,
133    /// When vmo_settings_to_check is set to a VMO and
134    /// vmo_settings_to_check_ignore_size is set to true, the buffer size
135    /// is ignored when comparing the two buffer's settings. This can be
136    /// useful to set when checking video decoder input buffers.
137    pub vmo_settings_to_check_ignore_size: Option<bool>,
138    #[doc(hidden)]
139    pub __source_breaking: fidl::marker::SourceBreaking,
140}
141
142impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for AllocatorGetVmoInfoRequest {}
143
144#[derive(Debug, Default, PartialEq)]
145pub struct AllocatorGetVmoInfoResponse {
146    /// The buffer_collection_id and buffer_index together uniquely identify
147    /// a buffer per boot.
148    pub buffer_collection_id: Option<u64>,
149    /// The buffer_collection_id and buffer_index together uniquely identify
150    /// a buffer per boot.
151    ///
152    /// This buffer_index is in the same space as specified/implied by
153    /// `BufferCollectionInfo` from collection allocation.
154    ///
155    /// Clients that don't have direct control over the provenance of `vmo`
156    /// should assume that buffer_index could be any uint64. Such clients
157    /// may wish to check the buffer_collection_id against client-known
158    /// buffer collections before looking at buffer_index, and/or ensure
159    /// that looking up a client-known buffer by buffer_collection_id and
160    /// buffer_index doesn't rely on buffer_index(s) being packed near 0, at
161    /// least until a client-known buffer is found that the client knows
162    /// will have buffer_index packed near 0.
163    pub buffer_index: Option<u64>,
164    /// If vmo was a sysmem weak VMO handle or need_weak was set to true (or
165    /// both), this field will be set. Later when ZX_EVENTPAIR_PEER_CLOSED
166    /// is signalled on this eventpair endpoint, all weak VMO handles to
167    /// this buffer should be closed asap (all strong VMO handles were
168    /// already closed by this point). In some cases, a client may be able
169    /// to rely on a different participant to notice and inform the client,
170    /// so this field being set is potentially ignore-able by some clients.
171    ///
172    /// Client authors should ensure that when the buffer's close_weak_asap
173    /// server_end closes, the client will close all handles to the buffer
174    /// as soon as possible. This can be achieved directly or indirectly.
175    /// Client authors should not assume that this is achieved indirectly.
176    pub close_weak_asap: Option<fdomain_client::EventPair>,
177    /// Iff `need_weak` was set to true, this field is set to a sysmem weak
178    /// VMO handle to the same sysmem buffer (assuming no Error). The koid
179    /// may be different than the koid of the `vmo` in the request,
180    /// regardless of whether `vmo` in the request was a strong or weak VMO
181    /// handle. The `weak_vmo` will have no more rights than the `vmo`
182    /// handle had. In most cases, the client should also retain
183    /// `close_weak_asap` and notice when ZX_EVENTPAIR_PEER_CLOSED is
184    /// signalled and close the `weak_vmo` (and any handles to child VMOs)
185    /// ASAP.
186    pub weak_vmo: Option<fdomain_client::Vmo>,
187    /// Iff `need_single_buffer_settings` is set, this field will be set to
188    /// the SingleBufferSettings of the vmo's collection. See also
189    /// `[fuchsia.sysmem2/Allocator.GetVmoInfo]`
190    /// `need_single_buffer_settings`.
191    pub single_buffer_settings: Option<SingleBufferSettings>,
192    /// Iff `constraints_to_check` was set, this field will be set. If true,
193    /// the vmo conforms to `constraints_to_check`. If false, the vmo does
194    /// not conform to `constraints_to_check`.
195    pub constraints_ok: Option<bool>,
196    /// Iff `vmo_settings_to_check` was set, this field will be set. If
197    /// true, `vmo` and `vmo_settings_to_check` have the same
198    /// SingleBufferSettings. If false, `vmo` and `vmo_settings_to_check`
199    /// have different SingleBufferSettings. The reason for not matching may
200    /// not be visible to the client if SingleBufferSettings has a new field
201    /// or similar.
202    pub vmo_settings_match: Option<bool>,
203    #[doc(hidden)]
204    pub __source_breaking: fidl::marker::SourceBreaking,
205}
206
207impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
208    for AllocatorGetVmoInfoResponse
209{
210}
211
212#[derive(Debug, Default, PartialEq)]
213pub struct BufferCollectionAttachLifetimeTrackingRequest {
214    pub server_end: Option<fdomain_client::EventPair>,
215    pub buffers_remaining: Option<u32>,
216    #[doc(hidden)]
217    pub __source_breaking: fidl::marker::SourceBreaking,
218}
219
220impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
221    for BufferCollectionAttachLifetimeTrackingRequest
222{
223}
224
225#[derive(Debug, Default, PartialEq)]
226pub struct BufferCollectionAttachTokenRequest {
227    pub rights_attenuation_mask: Option<fidl::Rights>,
228    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
229    #[doc(hidden)]
230    pub __source_breaking: fidl::marker::SourceBreaking,
231}
232
233impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
234    for BufferCollectionAttachTokenRequest
235{
236}
237
238/// Information about a buffer collection and its buffers.
239///
240/// When adding fields to this table, see also
241/// fuchsia.sysmem2/Allocator.GetVmoInfo, redacted_buffer_collection_info, and
242/// RedactBufferCollectionInfo. Consider whether a client with only
243/// ZX_RIGHT_TRANSFER right on a sysmem vmo handle, calling GetVmoInfo, should
244/// be given the information in the new field, or whether it should be un-set
245/// during redaction. GetVmoInfo is analogous to zx_object_get_info with topic
246/// ZX_INFO_VMO, which doesn't require the VMO handle to have any rights - just
247/// needs to be a handle to a VMO. Fields that are necessary to correctly use a
248/// single sysmem VMO in isolation are generally ok (but still think about it
249/// field by field). Fields that are not necessary to correctly use a single
250/// sysmem VMO in isolation should probably be redacted for GetVmoInfo
251/// redacted_buffer_collection_info.
252#[derive(Debug, Default, PartialEq)]
253pub struct BufferCollectionInfo {
254    /// These settings apply to all the buffers in the initial buffer
255    /// allocation.
256    ///
257    /// This field will always be set by sysmem.
258    pub settings: Option<SingleBufferSettings>,
259    /// VMO handles (and vmo_usable_start offset) for each buffer in the
260    /// collection.
261    ///
262    /// The size of this vector is the buffer_count (buffer_count is not sent
263    /// separately).
264    ///
265    /// All buffer VMO handles have identical size and access rights.  The size
266    /// is in settings.buffer_settings.size_bytes.
267    ///
268    /// The VMO access rights are determined based on the usages which the
269    /// client specified when allocating the buffer collection.  For example, a
270    /// client which expressed a read-only usage will receive VMOs without write
271    /// rights.  In addition, the rights can be attenuated by the parameter to
272    /// BufferCollectionToken.Duplicate() calls.
273    ///
274    /// This field will always have VmoBuffer(s) in it, even if the participant
275    /// specifies usage whieh does not require VMO handles.  This permits such a
276    /// participant to know the vmo_usable_start values, in case that's of any
277    /// use to the participant.
278    ///
279    /// This field will always be set by sysmem, even if the participant doesn't
280    /// specify any buffer usage (but the [`fuchsia.sysmem2/VmoBuffer.vmo`]
281    /// sub-field within this field won't be set in that case).
282    ///
283    /// In the response from `[fuchsia.sysmem2/Allocator.GetVmoInfo]`, in the
284    /// redacted_buffer_collection_info, this field is un-set.
285    pub buffers: Option<Vec<VmoBuffer>>,
286    /// This number is unique among all logical buffer collections per boot.
287    ///
288    /// This ID number will be the same for all BufferCollectionToken(s),
289    /// BufferCollection(s), and BufferCollectionTokenGroup(s) associated with
290    /// the same logical buffer collection (derived from the same root token
291    /// created with fuchsia.sysmem2.Allocator.CreateSharedCollection, or with
292    /// CreateNonSharedCollection).
293    ///
294    /// The same ID can be retrieved from a BufferCollectionToken,
295    /// BufferCollection, or BufferCollectionTokenGroup using
296    /// GetBufferCollectionId (at the cost of a round-trip to sysmem and back).
297    ///
298    /// This field will always be set by sysmem.
299    pub buffer_collection_id: Option<u64>,
300    #[doc(hidden)]
301    pub __source_breaking: fidl::marker::SourceBreaking,
302}
303
304impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for BufferCollectionInfo {}
305
306#[derive(Debug, Default, PartialEq)]
307pub struct BufferCollectionSetConstraintsRequest {
308    /// These are the constraints on the buffer collection imposed by the
309    /// sending client/participant.  The `constraints` field is not required
310    /// to be set. If not set, the client is not setting any actual
311    /// constraints, but is indicating that the client has no constraints to
312    /// set. A client that doesn't set the `constraints` field won't receive
313    /// any VMO handles, but can still find out how many buffers were
314    /// allocated and can still refer to buffers by their `buffer_index`.
315    pub constraints: Option<BufferCollectionConstraints>,
316    /// This field should only be set if a client must force the new buffer
317    /// collection to have exactly identical SingleBufferSettings as a
318    /// previously-allocated collection, else the allocation must fail.
319    ///
320    /// Setting this field nails down all the constraints except the buffer
321    /// count, so clients shouldn't expect this to work unless the overall
322    /// set of participants on this logical buffer collection is the same as
323    /// for the previous allocation (though this isn't strictly required to
324    /// be true). Even then, if any participant indicates different
325    /// constraints than for this VMO's collection, the allocation is fairly
326    /// likely to fail. For these reasons, clients will want to avoid
327    /// setting this field unless it's really needed.
328    ///
329    /// The `must_match_vmo` handle must be a handle to a sysmem-provided
330    /// VMO, else the logical buffer collection will fail. To check whether
331    /// a VMO handle refers to a sysmem-provided VMO before setting this
332    /// field (if not already known), see
333    /// `[fuchsia.sysmem2/Allocator.GetVmoInfo]`.
334    ///
335    /// This still ensures that constraints of other participants are
336    /// satisfied as well, else the allocation will fail.
337    ///
338    /// This field is a VMO rather than SingleBufferSettings so that adding
339    /// a new field to SingleBufferSettings remains compatible with this
340    /// mechanism without needing to update/rebuild all clients using this
341    /// mechanism to copy the new field.
342    ///
343    /// This field is a VMO rather than a "handle to a SingleBufferSettings"
344    /// (or similar) to avoid this field causing allocation failure when
345    /// there are zero actual still-existing buffers to match (in which case
346    /// not setting this field is better than letting an already-gone buffer
347    /// dictate the settings for new buffers).
348    ///
349    /// Clients should avoid keeping a buffer alive just to use it with this
350    /// field; instead drop the old buffer when appropriate, and allocate
351    /// new buffer(s) like it's the first allocation after boot again.
352    ///
353    /// See also `[fuchsia.sysmem2/BufferCollection.AttachToken]` which is a
354    /// substantially different mechanism, but might be a workable
355    /// alternative to setting this feild in a few (but not all) situations
356    /// that would otherwise need to set this field.
357    ///
358    /// In most cases the constraints field should specify all the necessary
359    /// constraints known to the client, and this field should not be set.
360    pub must_match_vmo: Option<fdomain_client::Vmo>,
361    #[doc(hidden)]
362    pub __source_breaking: fidl::marker::SourceBreaking,
363}
364
365impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
366    for BufferCollectionSetConstraintsRequest
367{
368}
369
370#[derive(Debug, Default, PartialEq)]
371pub struct BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
372    pub group_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>>,
373    #[doc(hidden)]
374    pub __source_breaking: fidl::marker::SourceBreaking,
375}
376
377impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
378    for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
379{
380}
381
382#[derive(Debug, Default, PartialEq)]
383pub struct BufferCollectionTokenDuplicateRequest {
384    pub rights_attenuation_mask: Option<fidl::Rights>,
385    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
386    #[doc(hidden)]
387    pub __source_breaking: fidl::marker::SourceBreaking,
388}
389
390impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
391    for BufferCollectionTokenDuplicateRequest
392{
393}
394
395#[derive(Debug, Default, PartialEq)]
396pub struct BufferCollectionTokenGroupCreateChildRequest {
397    /// Must be set.
398    pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
399    /// If not set, the default is `ZX_RIGHT_SAME_RIGHTS`.
400    pub rights_attenuation_mask: Option<fidl::Rights>,
401    #[doc(hidden)]
402    pub __source_breaking: fidl::marker::SourceBreaking,
403}
404
405impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
406    for BufferCollectionTokenGroupCreateChildRequest
407{
408}
409
410#[derive(Debug, Default, PartialEq)]
411pub struct BufferCollectionTokenGroupCreateChildrenSyncResponse {
412    pub tokens: Option<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>>,
413    #[doc(hidden)]
414    pub __source_breaking: fidl::marker::SourceBreaking,
415}
416
417impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
418    for BufferCollectionTokenGroupCreateChildrenSyncResponse
419{
420}
421
422#[derive(Debug, Default, PartialEq)]
423pub struct BufferCollectionTokenDuplicateSyncResponse {
424    pub tokens: Option<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>>,
425    #[doc(hidden)]
426    pub __source_breaking: fidl::marker::SourceBreaking,
427}
428
429impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
430    for BufferCollectionTokenDuplicateSyncResponse
431{
432}
433
434#[derive(Debug, Default, PartialEq)]
435pub struct BufferCollectionWaitForAllBuffersAllocatedResponse {
436    pub buffer_collection_info: Option<BufferCollectionInfo>,
437    #[doc(hidden)]
438    pub __source_breaking: fidl::marker::SourceBreaking,
439}
440
441impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
442    for BufferCollectionWaitForAllBuffersAllocatedResponse
443{
444}
445
446#[derive(Debug, Default, PartialEq)]
447pub struct NodeAttachNodeTrackingRequest {
448    /// This field must be set. This evenpair end will be closed after the
449    /// `Node` is closed or failed and the node's buffer counts are no
450    /// longer in effect in the logical buffer collection.
451    pub server_end: Option<fdomain_client::EventPair>,
452    #[doc(hidden)]
453    pub __source_breaking: fidl::marker::SourceBreaking,
454}
455
456impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
457    for NodeAttachNodeTrackingRequest
458{
459}
460
461#[derive(Debug, Default, PartialEq)]
462pub struct NodeIsAlternateForRequest {
463    pub node_ref: Option<fdomain_client::Event>,
464    #[doc(hidden)]
465    pub __source_breaking: fidl::marker::SourceBreaking,
466}
467
468impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeIsAlternateForRequest {}
469
470#[derive(Debug, Default, PartialEq)]
471pub struct NodeSetWeakOkRequest {
472    pub for_child_nodes_also: Option<bool>,
473    #[doc(hidden)]
474    pub __source_breaking: fidl::marker::SourceBreaking,
475}
476
477impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeSetWeakOkRequest {}
478
479#[derive(Debug, Default, PartialEq)]
480pub struct NodeGetNodeRefResponse {
481    pub node_ref: Option<fdomain_client::Event>,
482    #[doc(hidden)]
483    pub __source_breaking: fidl::marker::SourceBreaking,
484}
485
486impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeGetNodeRefResponse {}
487
488#[derive(Debug, Default, PartialEq)]
489pub struct VmoBuffer {
490    /// `vmo` can be un-set if a participant has only
491    /// [`fuchsia.sysmem2/BufferUsage.none`] set to `NONE_USAGE` (explicitly or
492    /// implicitly by [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
493    /// without `constraints` set).
494    pub vmo: Option<fdomain_client::Vmo>,
495    /// Offset within the VMO of the first usable byte. Must be < the VMO's size
496    /// in bytes, and leave sufficient room for BufferMemorySettings.size_bytes
497    /// before the end of the VMO.
498    ///
499    /// Currently sysmem will always set this field to 0, and in future, sysmem
500    /// won't set this field to a non-zero value unless all participants have
501    /// explicitly indicated support for non-zero vmo_usable_start (this
502    /// mechanism does not exist as of this comment). A participant that hasn't
503    /// explicitly indicated support for non-zero vmo_usable_start (all current
504    /// clients) should implicitly assume this field is set to 0 without
505    /// actually checking this field.
506    pub vmo_usable_start: Option<u64>,
507    /// This field is set iff `vmo` is a sysmem weak VMO handle.
508    ///
509    /// If the client sent `SetWeakOk`, the client must keep `close_weak_asap`
510    /// around for as long as `vmo`, and must notice `ZX_EVENTPAIR_PEER_CLOSED`.
511    /// If that signal occurs, the client must close `vmo` asap.
512    ///
513    /// If the `vmo` is a sysmem weak VMO handle but the client didn't send
514    /// `SetWeakOk`, this means that a holder of a parent node sent `SetWeakOk`
515    /// with `for_child_nodes_also` true, and the owner of that parent node is
516    /// responsible for paying attention to `close_weak_asap` and informing
517    /// child token participants to close handles. In this case the participant
518    /// that never sent `SetWeakOk` is allowed to retain and/or pay attention to
519    /// `close_weak_asap` (to close the handle faster, or for other reasons such
520    /// as diagnosing overall buffer cleanup timing), but is not required to
521    /// retain or pay attention to `close_weak_asap`.
522    ///
523    /// If sysmem closing the sysmem end of `close_weak_asap` does not result in
524    /// quick closure of all sysmem weak VMO handles to the buffer, that's
525    /// considered a VMO leak, and in that case sysmem will eventually complain
526    /// loudly via syslog (currently 5s later).
527    pub close_weak_asap: Option<fdomain_client::EventPair>,
528    #[doc(hidden)]
529    pub __source_breaking: fidl::marker::SourceBreaking,
530}
531
532impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {}
533
534#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
535pub struct AllocatorMarker;
536
537impl fdomain_client::fidl::ProtocolMarker for AllocatorMarker {
538    type Proxy = AllocatorProxy;
539    type RequestStream = AllocatorRequestStream;
540
541    const DEBUG_NAME: &'static str = "fuchsia.sysmem2.Allocator";
542}
543impl fdomain_client::fidl::DiscoverableProtocolMarker for AllocatorMarker {}
544pub type AllocatorGetVmoInfoResult = Result<AllocatorGetVmoInfoResponse, Error>;
545
546pub trait AllocatorProxyInterface: Send + Sync {
547    fn r#allocate_non_shared_collection(
548        &self,
549        payload: AllocatorAllocateNonSharedCollectionRequest,
550    ) -> Result<(), fidl::Error>;
551    fn r#allocate_shared_collection(
552        &self,
553        payload: AllocatorAllocateSharedCollectionRequest,
554    ) -> Result<(), fidl::Error>;
555    fn r#bind_shared_collection(
556        &self,
557        payload: AllocatorBindSharedCollectionRequest,
558    ) -> Result<(), fidl::Error>;
559    type ValidateBufferCollectionTokenResponseFut: std::future::Future<
560            Output = Result<AllocatorValidateBufferCollectionTokenResponse, fidl::Error>,
561        > + Send;
562    fn r#validate_buffer_collection_token(
563        &self,
564        payload: &AllocatorValidateBufferCollectionTokenRequest,
565    ) -> Self::ValidateBufferCollectionTokenResponseFut;
566    fn r#set_debug_client_info(
567        &self,
568        payload: &AllocatorSetDebugClientInfoRequest,
569    ) -> Result<(), fidl::Error>;
570    type GetVmoInfoResponseFut: std::future::Future<Output = Result<AllocatorGetVmoInfoResult, fidl::Error>>
571        + Send;
572    fn r#get_vmo_info(&self, payload: AllocatorGetVmoInfoRequest) -> Self::GetVmoInfoResponseFut;
573}
574
575#[derive(Debug, Clone)]
576pub struct AllocatorProxy {
577    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
578}
579
580impl fdomain_client::fidl::Proxy for AllocatorProxy {
581    type Protocol = AllocatorMarker;
582
583    fn from_channel(inner: fdomain_client::Channel) -> Self {
584        Self::new(inner)
585    }
586
587    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
588        self.client.into_channel().map_err(|client| Self { client })
589    }
590
591    fn as_channel(&self) -> &fdomain_client::Channel {
592        self.client.as_channel()
593    }
594}
595
596impl AllocatorProxy {
597    /// Create a new Proxy for fuchsia.sysmem2/Allocator.
598    pub fn new(channel: fdomain_client::Channel) -> Self {
599        let protocol_name = <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
600        Self { client: fidl::client::Client::new(channel, protocol_name) }
601    }
602
603    /// Get a Stream of events from the remote end of the protocol.
604    ///
605    /// # Panics
606    ///
607    /// Panics if the event stream was already taken.
608    pub fn take_event_stream(&self) -> AllocatorEventStream {
609        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
610    }
611
612    /// Allocates a buffer collection on behalf of a single client (aka
613    /// initiator) who is also the only participant (from the point of view of
614    /// sysmem).
615    ///
616    /// This call exists mainly for temp/testing purposes.  This call skips the
617    /// [`fuchsia.sysmem2/BufferCollectionToken`] stage, so there's no way to
618    /// allow another participant to specify its constraints.
619    ///
620    /// Real clients are encouraged to use
621    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] instead, and to
622    /// let relevant participants directly convey their own constraints to
623    /// sysmem by sending `BufferCollectionToken`s to those participants.
624    ///
625    /// + request `collection_request` The server end of the
626    ///   [`fuchsia.sysmem2/BufferCollection`].
627    pub fn r#allocate_non_shared_collection(
628        &self,
629        mut payload: AllocatorAllocateNonSharedCollectionRequest,
630    ) -> Result<(), fidl::Error> {
631        AllocatorProxyInterface::r#allocate_non_shared_collection(self, payload)
632    }
633
634    /// Creates a root [`fuchsia.sysmem2/BufferCollectionToken`].
635    ///
636    /// The `BufferCollectionToken` can be "duplicated" for distribution to
637    /// participants by using
638    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`]. Each
639    /// `BufferCollectionToken` can be converted into a
640    /// [`fuchsia.sysmem2.BufferCollection`] using
641    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`].
642    ///
643    /// Buffer constraints can be set via
644    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
645    ///
646    /// Success/failure to populate the buffer collection with buffers can be
647    /// determined from
648    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
649    ///
650    /// Closing the client end of a `BufferCollectionToken` or
651    /// `BufferCollection` (without `Release` first) will fail all client ends
652    /// in the same failure domain, which by default is all client ends of the
653    /// buffer collection. See
654    /// [`fuchsia.sysmem2/BufferCollection.SetDispensable`] and
655    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`] for ways to create
656    /// separate failure domains within a buffer collection.
657    pub fn r#allocate_shared_collection(
658        &self,
659        mut payload: AllocatorAllocateSharedCollectionRequest,
660    ) -> Result<(), fidl::Error> {
661        AllocatorProxyInterface::r#allocate_shared_collection(self, payload)
662    }
663
664    /// Convert a [`fuchsia.sysmem2/BufferCollectionToken`] into a
665    /// [`fuchsia.sysmem2/BufferCollection`].
666    ///
667    /// At the time of sending this message, the buffer collection hasn't yet
668    /// been populated with buffers - the participant must first also send
669    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] via the
670    /// `BufferCollection` client end.
671    ///
672    /// All `BufferCollectionToken`(s) duplicated from a root
673    /// `BufferCollectionToken` (created via `AllocateSharedCollection`) must be
674    /// "turned in" via `BindSharedCollection` (or `Release`ed), and all
675    /// existing `BufferCollection` client ends must have sent `SetConstraints`
676    /// before the logical BufferCollection will be populated with buffers (or
677    /// will fail if the overall set of constraints can't be satisfied).
678    ///
679    /// + request `token` The client endpoint of a channel whose server end was
680    ///   sent to sysmem using
681    ///   [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] or whose server
682    ///   end was sent to sysmem using
683    ///   [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`].  The token is
684    ///   being "turned in" in exchange for a
685    ///   [`fuchsia.sysmem2/BufferCollection`].
686    /// + request `buffer_collection_request` The server end of a
687    ///   [`fuchsia.sysmem2/BufferCollection`] channel.  The sender retains the
688    ///   client end. The `BufferCollection` channel is a single participant's
689    ///   connection to the logical buffer collection. Typically there will be
690    ///   other participants with their own `BufferCollection` channel to the
691    ///   logical buffer collection.
692    pub fn r#bind_shared_collection(
693        &self,
694        mut payload: AllocatorBindSharedCollectionRequest,
695    ) -> Result<(), fidl::Error> {
696        AllocatorProxyInterface::r#bind_shared_collection(self, payload)
697    }
698
699    /// Checks whether a [`fuchsia.sysmem2/BufferCollectionToken`] is known to
700    /// the sysmem server.
701    ///
702    /// With this call, the client can determine whether an incoming token is a
703    /// real sysmem token that is known to the sysmem server, without any risk
704    /// of getting stuck waiting forever on a potentially fake token to complete
705    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or
706    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] (or any other two-way
707    /// FIDL message). In cases where the client trusts the source of the token
708    /// to provide a real token, this call is not typically needed outside of
709    /// debugging.
710    ///
711    /// If the validate fails sometimes but succeeds other times, the source of
712    /// the token may itself not be calling
713    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] or
714    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after creating/duplicating the
715    /// token but before sending the token to the current client. It may be more
716    /// convenient for the source to use
717    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] to duplicate
718    /// token(s), since that call has the sync step built in. Or, the buffer
719    /// collection may be failing before this call is processed by the sysmem
720    /// server, as buffer collection failure cleans up sysmem's tracking of
721    /// associated tokens.
722    ///
723    /// This call has no effect on any token.
724    ///
725    /// + request `token_server_koid` The koid of the server end of a channel
726    ///   that might be a BufferCollectionToken channel.  This can be obtained
727    ///   via `zx_object_get_info` `ZX_INFO_HANDLE_BASIC` `related_koid`.
728    /// - response `is_known` true means sysmem knew of the token at the time
729    ///   sysmem processed the request, but doesn't guarantee that the token is
730    ///   still valid by the time the client receives the reply. What it does
731    ///   guarantee is that the token at least was a real token, so a two-way
732    ///   call to the token won't stall forever (will fail or succeed fairly
733    ///   quickly, not stall). This can already be known implicitly if the
734    ///   source of the token can be trusted to provide a real token. A false
735    ///   value means the token wasn't known to sysmem at the time sysmem
736    ///   processed this call, but the token may have previously been valid, or
737    ///   may yet become valid. Or if the sender of the token isn't trusted to
738    ///   provide a real token, the token may be fake. It's the responsibility
739    ///   of the sender to sync with sysmem to ensure that previously
740    ///   created/duplicated token(s) are known to sysmem, before sending the
741    ///   token(s) to other participants.
742    pub fn r#validate_buffer_collection_token(
743        &self,
744        mut payload: &AllocatorValidateBufferCollectionTokenRequest,
745    ) -> fidl::client::QueryResponseFut<
746        AllocatorValidateBufferCollectionTokenResponse,
747        fdomain_client::fidl::FDomainResourceDialect,
748    > {
749        AllocatorProxyInterface::r#validate_buffer_collection_token(self, payload)
750    }
751
752    /// Set information about the current client that can be used by sysmem to
753    /// help diagnose leaking memory and allocation stalls waiting for a
754    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
755    ///
756    /// This sets the debug client info on all [`fuchsia.sysmem2/Node`](s)
757    /// subsequently created by this this [`fuchsia.sysmem2/Allocator`]
758    /// including any [`fuchsia.sysmem2/BufferCollection`](s) created via
759    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] (in the absence of
760    /// any prior call to [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`],
761    /// these `BufferCollection`(s) have the same initial debug client info as
762    /// the token turned in to create the `BufferCollection`).
763    ///
764    /// This info can be subsequently overridden on a per-`Node` basis by
765    /// sending [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
766    ///
767    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
768    /// `Allocator` is the most efficient way to ensure that all
769    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
770    /// set, and is also more efficient than separately sending the same debug
771    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
772    /// created [`fuchsia.sysmem2/Node`].
773    ///
774    /// + request `name` This can be an arbitrary string, but the current
775    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
776    /// + request `id` This can be an arbitrary id, but the current process ID
777    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
778    pub fn r#set_debug_client_info(
779        &self,
780        mut payload: &AllocatorSetDebugClientInfoRequest,
781    ) -> Result<(), fidl::Error> {
782        AllocatorProxyInterface::r#set_debug_client_info(self, payload)
783    }
784
785    /// Given a handle to a sysmem-provided VMO, this returns additional info
786    /// about the corresponding sysmem logical buffer.
787    ///
788    /// Most callers will duplicate a VMO handle first and send the duplicate to
789    /// this call.
790    ///
791    /// If the client has created a child VMO of a sysmem-provided VMO, that
792    /// child VMO isn't considered a "sysmem VMO" for purposes of this call.
793    ///
794    /// + request `vmo` A handle to a sysmem-provided VMO (or see errors).
795    /// + request `need_weak` Iff set to true, the response will have weak_vmo
796    ///   set to a weak VMO for the buffer, regardless of whether `vmo` in the
797    ///   request was weak or strong.
798    /// - response `buffer_collection_id` The buffer collection ID, which is
799    ///   unique per logical buffer collection per boot.
800    /// - response `buffer_index` The buffer index of the buffer within the
801    ///   buffer collection. This is the same as the index of the buffer within
802    ///   [`fuchsia.sysmem2/BufferCollectionInfo.buffers`]. The `buffer_index`
803    ///   is the same for all sysmem-delivered VMOs corresponding to the same
804    ///   logical buffer, even if the VMO koids differ. The `buffer_index` is
805    ///   only unique across buffers of a buffer collection. For a given buffer,
806    ///   the combination of `buffer_collection_id` and `buffer_index` is unique
807    ///   per boot.
808    /// - response `close_weak_asap` Iff `vmo` is a handle to a weak sysmem VMO
809    ///   OR need_weak is set to true, the `close_weak_asap` field will be set
810    ///   in the response. This handle will signal `ZX_EVENTPAIR_PEER_CLOSED`
811    ///   when all weak VMO handles to the buffer should be closed as soon as
812    ///   possible. This is signalled shortly after all strong sysmem VMOs to
813    ///   the buffer are closed (including any held indirectly via strong
814    ///   `BufferCollectionToken` or strong `BufferCollection`). Failure to
815    ///   close all weak sysmem VMO handles to the buffer quickly upon
816    ///   `ZX_EVENTPAIR_PEER_CLOSED` is considered a VMO leak caused by the
817    ///   client still holding a weak sysmem VMO handle and results in loud
818    ///   complaints to the log by sysmem (after a delay). The buffers of a
819    ///   collection can be freed independently of each other. The
820    ///   `ZX_EVENTPAIR_PEER_CLOSED` may already be signalled before the
821    ///   response arrives at the client. A client that isn't prepared to
822    ///   directly handle weak sysmem VMOs and waiting on close_weak_asap, on
823    ///   seeing this field set in response to a request that had need_weak
824    ///   un-set, typically should ignore the fact that the vmo handle was a
825    ///   weak vmo handle; typically another participant that's also a client of
826    ///   this participant via some other protocol has taken responsibility for
827    ///   ensuring that this participant will close all handles to the buffer,
828    ///   typically by shutting down this participant's context holding a vmo
829    ///   handle in some other way. That said, it is not harmful for both
830    ///   participants to directly handle close_weak_asap, even if one
831    ///   participant can take responsibility for handling close_weak_asap. See
832    ///   also `[fuchsia.sysmem2/Node.SetWeakOk]` for_child_nodes_also.
833    /// - response `weak_vmo` This field is set in the response iff the request
834    ///   had `need_weak` set to true. When set, this is a weak VMO handle to
835    ///   the same buffer as `vmo` in the request, but may not have the same
836    ///   koid as `vmo` had (this applies regardless of whether `vmo` was strong
837    ///   or weak).
838    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` - the vmo isn't a sysmem
839    ///   VMO. Both strong and weak sysmem VMOs can be passed to this call, and
840    ///   the VMO handle passed in to this call itself keeps the VMO's info
841    ///   alive for purposes of responding to this call. Because of this,
842    ///   ZX_ERR_NOT_FOUND errors are unambiguous (even if there are no other
843    ///   handles to the VMO when calling; even if other handles are closed
844    ///   before the GetVmoInfo response arrives at the client).
845    /// * error `[fuchsia.sysmem2/Error.UNSPECIFIED]` The request failed for an
846    ///   unspecified reason. See the log for more info.
847    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The vmo field
848    ///   wasn't set, or there was some other problem with the request field(s).
849    ///   See the log.
850    pub fn r#get_vmo_info(
851        &self,
852        mut payload: AllocatorGetVmoInfoRequest,
853    ) -> fidl::client::QueryResponseFut<
854        AllocatorGetVmoInfoResult,
855        fdomain_client::fidl::FDomainResourceDialect,
856    > {
857        AllocatorProxyInterface::r#get_vmo_info(self, payload)
858    }
859}
860
861impl AllocatorProxyInterface for AllocatorProxy {
862    fn r#allocate_non_shared_collection(
863        &self,
864        mut payload: AllocatorAllocateNonSharedCollectionRequest,
865    ) -> Result<(), fidl::Error> {
866        self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
867            &mut payload,
868            0x5ca681f025a80e44,
869            fidl::encoding::DynamicFlags::FLEXIBLE,
870        )
871    }
872
873    fn r#allocate_shared_collection(
874        &self,
875        mut payload: AllocatorAllocateSharedCollectionRequest,
876    ) -> Result<(), fidl::Error> {
877        self.client.send::<AllocatorAllocateSharedCollectionRequest>(
878            &mut payload,
879            0x11a19ff51f0b49c1,
880            fidl::encoding::DynamicFlags::FLEXIBLE,
881        )
882    }
883
884    fn r#bind_shared_collection(
885        &self,
886        mut payload: AllocatorBindSharedCollectionRequest,
887    ) -> Result<(), fidl::Error> {
888        self.client.send::<AllocatorBindSharedCollectionRequest>(
889            &mut payload,
890            0x550916b0dc1d5b4e,
891            fidl::encoding::DynamicFlags::FLEXIBLE,
892        )
893    }
894
895    type ValidateBufferCollectionTokenResponseFut = fidl::client::QueryResponseFut<
896        AllocatorValidateBufferCollectionTokenResponse,
897        fdomain_client::fidl::FDomainResourceDialect,
898    >;
899    fn r#validate_buffer_collection_token(
900        &self,
901        mut payload: &AllocatorValidateBufferCollectionTokenRequest,
902    ) -> Self::ValidateBufferCollectionTokenResponseFut {
903        fn _decode(
904            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
905        ) -> Result<AllocatorValidateBufferCollectionTokenResponse, fidl::Error> {
906            let _response = fidl::client::decode_transaction_body::<
907                fidl::encoding::FlexibleType<AllocatorValidateBufferCollectionTokenResponse>,
908                fdomain_client::fidl::FDomainResourceDialect,
909                0x4c5ee91b02a7e68d,
910            >(_buf?)?
911            .into_result_fdomain::<AllocatorMarker>("validate_buffer_collection_token")?;
912            Ok(_response)
913        }
914        self.client.send_query_and_decode::<
915            AllocatorValidateBufferCollectionTokenRequest,
916            AllocatorValidateBufferCollectionTokenResponse,
917        >(
918            payload,
919            0x4c5ee91b02a7e68d,
920            fidl::encoding::DynamicFlags::FLEXIBLE,
921            _decode,
922        )
923    }
924
925    fn r#set_debug_client_info(
926        &self,
927        mut payload: &AllocatorSetDebugClientInfoRequest,
928    ) -> Result<(), fidl::Error> {
929        self.client.send::<AllocatorSetDebugClientInfoRequest>(
930            payload,
931            0x6f68f19a3f509c4d,
932            fidl::encoding::DynamicFlags::FLEXIBLE,
933        )
934    }
935
936    type GetVmoInfoResponseFut = fidl::client::QueryResponseFut<
937        AllocatorGetVmoInfoResult,
938        fdomain_client::fidl::FDomainResourceDialect,
939    >;
940    fn r#get_vmo_info(
941        &self,
942        mut payload: AllocatorGetVmoInfoRequest,
943    ) -> Self::GetVmoInfoResponseFut {
944        fn _decode(
945            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
946        ) -> Result<AllocatorGetVmoInfoResult, fidl::Error> {
947            let _response = fidl::client::decode_transaction_body::<
948                fidl::encoding::FlexibleResultType<AllocatorGetVmoInfoResponse, Error>,
949                fdomain_client::fidl::FDomainResourceDialect,
950                0x21a881120aa0ddf9,
951            >(_buf?)?
952            .into_result_fdomain::<AllocatorMarker>("get_vmo_info")?;
953            Ok(_response.map(|x| x))
954        }
955        self.client.send_query_and_decode::<AllocatorGetVmoInfoRequest, AllocatorGetVmoInfoResult>(
956            &mut payload,
957            0x21a881120aa0ddf9,
958            fidl::encoding::DynamicFlags::FLEXIBLE,
959            _decode,
960        )
961    }
962}
963
964pub struct AllocatorEventStream {
965    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
966}
967
968impl std::marker::Unpin for AllocatorEventStream {}
969
970impl futures::stream::FusedStream for AllocatorEventStream {
971    fn is_terminated(&self) -> bool {
972        self.event_receiver.is_terminated()
973    }
974}
975
976impl futures::Stream for AllocatorEventStream {
977    type Item = Result<AllocatorEvent, fidl::Error>;
978
979    fn poll_next(
980        mut self: std::pin::Pin<&mut Self>,
981        cx: &mut std::task::Context<'_>,
982    ) -> std::task::Poll<Option<Self::Item>> {
983        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
984            &mut self.event_receiver,
985            cx
986        )?) {
987            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
988            None => std::task::Poll::Ready(None),
989        }
990    }
991}
992
993#[derive(Debug)]
994pub enum AllocatorEvent {
995    #[non_exhaustive]
996    _UnknownEvent {
997        /// Ordinal of the event that was sent.
998        ordinal: u64,
999    },
1000}
1001
1002impl AllocatorEvent {
1003    /// Decodes a message buffer as a [`AllocatorEvent`].
1004    fn decode(
1005        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1006    ) -> Result<AllocatorEvent, fidl::Error> {
1007        let (bytes, _handles) = buf.split_mut();
1008        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1009        debug_assert_eq!(tx_header.tx_id, 0);
1010        match tx_header.ordinal {
1011            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1012                Ok(AllocatorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1013            }
1014            _ => Err(fidl::Error::UnknownOrdinal {
1015                ordinal: tx_header.ordinal,
1016                protocol_name:
1017                    <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1018            }),
1019        }
1020    }
1021}
1022
1023/// A Stream of incoming requests for fuchsia.sysmem2/Allocator.
1024pub struct AllocatorRequestStream {
1025    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1026    is_terminated: bool,
1027}
1028
1029impl std::marker::Unpin for AllocatorRequestStream {}
1030
1031impl futures::stream::FusedStream for AllocatorRequestStream {
1032    fn is_terminated(&self) -> bool {
1033        self.is_terminated
1034    }
1035}
1036
1037impl fdomain_client::fidl::RequestStream for AllocatorRequestStream {
1038    type Protocol = AllocatorMarker;
1039    type ControlHandle = AllocatorControlHandle;
1040
1041    fn from_channel(channel: fdomain_client::Channel) -> Self {
1042        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1043    }
1044
1045    fn control_handle(&self) -> Self::ControlHandle {
1046        AllocatorControlHandle { inner: self.inner.clone() }
1047    }
1048
1049    fn into_inner(
1050        self,
1051    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1052    {
1053        (self.inner, self.is_terminated)
1054    }
1055
1056    fn from_inner(
1057        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1058        is_terminated: bool,
1059    ) -> Self {
1060        Self { inner, is_terminated }
1061    }
1062}
1063
1064impl futures::Stream for AllocatorRequestStream {
1065    type Item = Result<AllocatorRequest, fidl::Error>;
1066
1067    fn poll_next(
1068        mut self: std::pin::Pin<&mut Self>,
1069        cx: &mut std::task::Context<'_>,
1070    ) -> std::task::Poll<Option<Self::Item>> {
1071        let this = &mut *self;
1072        if this.inner.check_shutdown(cx) {
1073            this.is_terminated = true;
1074            return std::task::Poll::Ready(None);
1075        }
1076        if this.is_terminated {
1077            panic!("polled AllocatorRequestStream after completion");
1078        }
1079        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1080            |bytes, handles| {
1081                match this.inner.channel().read_etc(cx, bytes, handles) {
1082                    std::task::Poll::Ready(Ok(())) => {}
1083                    std::task::Poll::Pending => return std::task::Poll::Pending,
1084                    std::task::Poll::Ready(Err(None)) => {
1085                        this.is_terminated = true;
1086                        return std::task::Poll::Ready(None);
1087                    }
1088                    std::task::Poll::Ready(Err(Some(e))) => {
1089                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1090                            e.into(),
1091                        ))));
1092                    }
1093                }
1094
1095                // A message has been received from the channel
1096                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1097
1098                std::task::Poll::Ready(Some(match header.ordinal {
1099                    0x5ca681f025a80e44 => {
1100                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1101                        let mut req = fidl::new_empty!(
1102                            AllocatorAllocateNonSharedCollectionRequest,
1103                            fdomain_client::fidl::FDomainResourceDialect
1104                        );
1105                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
1106                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1107                        Ok(AllocatorRequest::AllocateNonSharedCollection {
1108                            payload: req,
1109                            control_handle,
1110                        })
1111                    }
1112                    0x11a19ff51f0b49c1 => {
1113                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1114                        let mut req = fidl::new_empty!(
1115                            AllocatorAllocateSharedCollectionRequest,
1116                            fdomain_client::fidl::FDomainResourceDialect
1117                        );
1118                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
1119                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1120                        Ok(AllocatorRequest::AllocateSharedCollection {
1121                            payload: req,
1122                            control_handle,
1123                        })
1124                    }
1125                    0x550916b0dc1d5b4e => {
1126                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1127                        let mut req = fidl::new_empty!(
1128                            AllocatorBindSharedCollectionRequest,
1129                            fdomain_client::fidl::FDomainResourceDialect
1130                        );
1131                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
1132                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1133                        Ok(AllocatorRequest::BindSharedCollection { payload: req, control_handle })
1134                    }
1135                    0x4c5ee91b02a7e68d => {
1136                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1137                        let mut req = fidl::new_empty!(
1138                            AllocatorValidateBufferCollectionTokenRequest,
1139                            fdomain_client::fidl::FDomainResourceDialect
1140                        );
1141                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
1142                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1143                        Ok(AllocatorRequest::ValidateBufferCollectionToken {
1144                            payload: req,
1145                            responder: AllocatorValidateBufferCollectionTokenResponder {
1146                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1147                                tx_id: header.tx_id,
1148                            },
1149                        })
1150                    }
1151                    0x6f68f19a3f509c4d => {
1152                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1153                        let mut req = fidl::new_empty!(
1154                            AllocatorSetDebugClientInfoRequest,
1155                            fdomain_client::fidl::FDomainResourceDialect
1156                        );
1157                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
1158                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1159                        Ok(AllocatorRequest::SetDebugClientInfo { payload: req, control_handle })
1160                    }
1161                    0x21a881120aa0ddf9 => {
1162                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1163                        let mut req = fidl::new_empty!(
1164                            AllocatorGetVmoInfoRequest,
1165                            fdomain_client::fidl::FDomainResourceDialect
1166                        );
1167                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorGetVmoInfoRequest>(&header, _body_bytes, handles, &mut req)?;
1168                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
1169                        Ok(AllocatorRequest::GetVmoInfo {
1170                            payload: req,
1171                            responder: AllocatorGetVmoInfoResponder {
1172                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1173                                tx_id: header.tx_id,
1174                            },
1175                        })
1176                    }
1177                    _ if header.tx_id == 0
1178                        && header
1179                            .dynamic_flags()
1180                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1181                    {
1182                        Ok(AllocatorRequest::_UnknownMethod {
1183                            ordinal: header.ordinal,
1184                            control_handle: AllocatorControlHandle { inner: this.inner.clone() },
1185                            method_type: fidl::MethodType::OneWay,
1186                        })
1187                    }
1188                    _ if header
1189                        .dynamic_flags()
1190                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1191                    {
1192                        this.inner.send_framework_err(
1193                            fidl::encoding::FrameworkErr::UnknownMethod,
1194                            header.tx_id,
1195                            header.ordinal,
1196                            header.dynamic_flags(),
1197                            (bytes, handles),
1198                        )?;
1199                        Ok(AllocatorRequest::_UnknownMethod {
1200                            ordinal: header.ordinal,
1201                            control_handle: AllocatorControlHandle { inner: this.inner.clone() },
1202                            method_type: fidl::MethodType::TwoWay,
1203                        })
1204                    }
1205                    _ => Err(fidl::Error::UnknownOrdinal {
1206                        ordinal: header.ordinal,
1207                        protocol_name:
1208                            <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1209                    }),
1210                }))
1211            },
1212        )
1213    }
1214}
1215
1216/// Allocates system memory buffers.
1217///
1218/// Epitaphs are not used in this protocol.
1219#[derive(Debug)]
1220pub enum AllocatorRequest {
1221    /// Allocates a buffer collection on behalf of a single client (aka
1222    /// initiator) who is also the only participant (from the point of view of
1223    /// sysmem).
1224    ///
1225    /// This call exists mainly for temp/testing purposes.  This call skips the
1226    /// [`fuchsia.sysmem2/BufferCollectionToken`] stage, so there's no way to
1227    /// allow another participant to specify its constraints.
1228    ///
1229    /// Real clients are encouraged to use
1230    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] instead, and to
1231    /// let relevant participants directly convey their own constraints to
1232    /// sysmem by sending `BufferCollectionToken`s to those participants.
1233    ///
1234    /// + request `collection_request` The server end of the
1235    ///   [`fuchsia.sysmem2/BufferCollection`].
1236    AllocateNonSharedCollection {
1237        payload: AllocatorAllocateNonSharedCollectionRequest,
1238        control_handle: AllocatorControlHandle,
1239    },
1240    /// Creates a root [`fuchsia.sysmem2/BufferCollectionToken`].
1241    ///
1242    /// The `BufferCollectionToken` can be "duplicated" for distribution to
1243    /// participants by using
1244    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`]. Each
1245    /// `BufferCollectionToken` can be converted into a
1246    /// [`fuchsia.sysmem2.BufferCollection`] using
1247    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`].
1248    ///
1249    /// Buffer constraints can be set via
1250    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1251    ///
1252    /// Success/failure to populate the buffer collection with buffers can be
1253    /// determined from
1254    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
1255    ///
1256    /// Closing the client end of a `BufferCollectionToken` or
1257    /// `BufferCollection` (without `Release` first) will fail all client ends
1258    /// in the same failure domain, which by default is all client ends of the
1259    /// buffer collection. See
1260    /// [`fuchsia.sysmem2/BufferCollection.SetDispensable`] and
1261    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`] for ways to create
1262    /// separate failure domains within a buffer collection.
1263    AllocateSharedCollection {
1264        payload: AllocatorAllocateSharedCollectionRequest,
1265        control_handle: AllocatorControlHandle,
1266    },
1267    /// Convert a [`fuchsia.sysmem2/BufferCollectionToken`] into a
1268    /// [`fuchsia.sysmem2/BufferCollection`].
1269    ///
1270    /// At the time of sending this message, the buffer collection hasn't yet
1271    /// been populated with buffers - the participant must first also send
1272    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] via the
1273    /// `BufferCollection` client end.
1274    ///
1275    /// All `BufferCollectionToken`(s) duplicated from a root
1276    /// `BufferCollectionToken` (created via `AllocateSharedCollection`) must be
1277    /// "turned in" via `BindSharedCollection` (or `Release`ed), and all
1278    /// existing `BufferCollection` client ends must have sent `SetConstraints`
1279    /// before the logical BufferCollection will be populated with buffers (or
1280    /// will fail if the overall set of constraints can't be satisfied).
1281    ///
1282    /// + request `token` The client endpoint of a channel whose server end was
1283    ///   sent to sysmem using
1284    ///   [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`] or whose server
1285    ///   end was sent to sysmem using
1286    ///   [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`].  The token is
1287    ///   being "turned in" in exchange for a
1288    ///   [`fuchsia.sysmem2/BufferCollection`].
1289    /// + request `buffer_collection_request` The server end of a
1290    ///   [`fuchsia.sysmem2/BufferCollection`] channel.  The sender retains the
1291    ///   client end. The `BufferCollection` channel is a single participant's
1292    ///   connection to the logical buffer collection. Typically there will be
1293    ///   other participants with their own `BufferCollection` channel to the
1294    ///   logical buffer collection.
1295    BindSharedCollection {
1296        payload: AllocatorBindSharedCollectionRequest,
1297        control_handle: AllocatorControlHandle,
1298    },
1299    /// Checks whether a [`fuchsia.sysmem2/BufferCollectionToken`] is known to
1300    /// the sysmem server.
1301    ///
1302    /// With this call, the client can determine whether an incoming token is a
1303    /// real sysmem token that is known to the sysmem server, without any risk
1304    /// of getting stuck waiting forever on a potentially fake token to complete
1305    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or
1306    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] (or any other two-way
1307    /// FIDL message). In cases where the client trusts the source of the token
1308    /// to provide a real token, this call is not typically needed outside of
1309    /// debugging.
1310    ///
1311    /// If the validate fails sometimes but succeeds other times, the source of
1312    /// the token may itself not be calling
1313    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] or
1314    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after creating/duplicating the
1315    /// token but before sending the token to the current client. It may be more
1316    /// convenient for the source to use
1317    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] to duplicate
1318    /// token(s), since that call has the sync step built in. Or, the buffer
1319    /// collection may be failing before this call is processed by the sysmem
1320    /// server, as buffer collection failure cleans up sysmem's tracking of
1321    /// associated tokens.
1322    ///
1323    /// This call has no effect on any token.
1324    ///
1325    /// + request `token_server_koid` The koid of the server end of a channel
1326    ///   that might be a BufferCollectionToken channel.  This can be obtained
1327    ///   via `zx_object_get_info` `ZX_INFO_HANDLE_BASIC` `related_koid`.
1328    /// - response `is_known` true means sysmem knew of the token at the time
1329    ///   sysmem processed the request, but doesn't guarantee that the token is
1330    ///   still valid by the time the client receives the reply. What it does
1331    ///   guarantee is that the token at least was a real token, so a two-way
1332    ///   call to the token won't stall forever (will fail or succeed fairly
1333    ///   quickly, not stall). This can already be known implicitly if the
1334    ///   source of the token can be trusted to provide a real token. A false
1335    ///   value means the token wasn't known to sysmem at the time sysmem
1336    ///   processed this call, but the token may have previously been valid, or
1337    ///   may yet become valid. Or if the sender of the token isn't trusted to
1338    ///   provide a real token, the token may be fake. It's the responsibility
1339    ///   of the sender to sync with sysmem to ensure that previously
1340    ///   created/duplicated token(s) are known to sysmem, before sending the
1341    ///   token(s) to other participants.
1342    ValidateBufferCollectionToken {
1343        payload: AllocatorValidateBufferCollectionTokenRequest,
1344        responder: AllocatorValidateBufferCollectionTokenResponder,
1345    },
1346    /// Set information about the current client that can be used by sysmem to
1347    /// help diagnose leaking memory and allocation stalls waiting for a
1348    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1349    ///
1350    /// This sets the debug client info on all [`fuchsia.sysmem2/Node`](s)
1351    /// subsequently created by this this [`fuchsia.sysmem2/Allocator`]
1352    /// including any [`fuchsia.sysmem2/BufferCollection`](s) created via
1353    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] (in the absence of
1354    /// any prior call to [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`],
1355    /// these `BufferCollection`(s) have the same initial debug client info as
1356    /// the token turned in to create the `BufferCollection`).
1357    ///
1358    /// This info can be subsequently overridden on a per-`Node` basis by
1359    /// sending [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
1360    ///
1361    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
1362    /// `Allocator` is the most efficient way to ensure that all
1363    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
1364    /// set, and is also more efficient than separately sending the same debug
1365    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
1366    /// created [`fuchsia.sysmem2/Node`].
1367    ///
1368    /// + request `name` This can be an arbitrary string, but the current
1369    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
1370    /// + request `id` This can be an arbitrary id, but the current process ID
1371    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
1372    SetDebugClientInfo {
1373        payload: AllocatorSetDebugClientInfoRequest,
1374        control_handle: AllocatorControlHandle,
1375    },
1376    /// Given a handle to a sysmem-provided VMO, this returns additional info
1377    /// about the corresponding sysmem logical buffer.
1378    ///
1379    /// Most callers will duplicate a VMO handle first and send the duplicate to
1380    /// this call.
1381    ///
1382    /// If the client has created a child VMO of a sysmem-provided VMO, that
1383    /// child VMO isn't considered a "sysmem VMO" for purposes of this call.
1384    ///
1385    /// + request `vmo` A handle to a sysmem-provided VMO (or see errors).
1386    /// + request `need_weak` Iff set to true, the response will have weak_vmo
1387    ///   set to a weak VMO for the buffer, regardless of whether `vmo` in the
1388    ///   request was weak or strong.
1389    /// - response `buffer_collection_id` The buffer collection ID, which is
1390    ///   unique per logical buffer collection per boot.
1391    /// - response `buffer_index` The buffer index of the buffer within the
1392    ///   buffer collection. This is the same as the index of the buffer within
1393    ///   [`fuchsia.sysmem2/BufferCollectionInfo.buffers`]. The `buffer_index`
1394    ///   is the same for all sysmem-delivered VMOs corresponding to the same
1395    ///   logical buffer, even if the VMO koids differ. The `buffer_index` is
1396    ///   only unique across buffers of a buffer collection. For a given buffer,
1397    ///   the combination of `buffer_collection_id` and `buffer_index` is unique
1398    ///   per boot.
1399    /// - response `close_weak_asap` Iff `vmo` is a handle to a weak sysmem VMO
1400    ///   OR need_weak is set to true, the `close_weak_asap` field will be set
1401    ///   in the response. This handle will signal `ZX_EVENTPAIR_PEER_CLOSED`
1402    ///   when all weak VMO handles to the buffer should be closed as soon as
1403    ///   possible. This is signalled shortly after all strong sysmem VMOs to
1404    ///   the buffer are closed (including any held indirectly via strong
1405    ///   `BufferCollectionToken` or strong `BufferCollection`). Failure to
1406    ///   close all weak sysmem VMO handles to the buffer quickly upon
1407    ///   `ZX_EVENTPAIR_PEER_CLOSED` is considered a VMO leak caused by the
1408    ///   client still holding a weak sysmem VMO handle and results in loud
1409    ///   complaints to the log by sysmem (after a delay). The buffers of a
1410    ///   collection can be freed independently of each other. The
1411    ///   `ZX_EVENTPAIR_PEER_CLOSED` may already be signalled before the
1412    ///   response arrives at the client. A client that isn't prepared to
1413    ///   directly handle weak sysmem VMOs and waiting on close_weak_asap, on
1414    ///   seeing this field set in response to a request that had need_weak
1415    ///   un-set, typically should ignore the fact that the vmo handle was a
1416    ///   weak vmo handle; typically another participant that's also a client of
1417    ///   this participant via some other protocol has taken responsibility for
1418    ///   ensuring that this participant will close all handles to the buffer,
1419    ///   typically by shutting down this participant's context holding a vmo
1420    ///   handle in some other way. That said, it is not harmful for both
1421    ///   participants to directly handle close_weak_asap, even if one
1422    ///   participant can take responsibility for handling close_weak_asap. See
1423    ///   also `[fuchsia.sysmem2/Node.SetWeakOk]` for_child_nodes_also.
1424    /// - response `weak_vmo` This field is set in the response iff the request
1425    ///   had `need_weak` set to true. When set, this is a weak VMO handle to
1426    ///   the same buffer as `vmo` in the request, but may not have the same
1427    ///   koid as `vmo` had (this applies regardless of whether `vmo` was strong
1428    ///   or weak).
1429    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` - the vmo isn't a sysmem
1430    ///   VMO. Both strong and weak sysmem VMOs can be passed to this call, and
1431    ///   the VMO handle passed in to this call itself keeps the VMO's info
1432    ///   alive for purposes of responding to this call. Because of this,
1433    ///   ZX_ERR_NOT_FOUND errors are unambiguous (even if there are no other
1434    ///   handles to the VMO when calling; even if other handles are closed
1435    ///   before the GetVmoInfo response arrives at the client).
1436    /// * error `[fuchsia.sysmem2/Error.UNSPECIFIED]` The request failed for an
1437    ///   unspecified reason. See the log for more info.
1438    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The vmo field
1439    ///   wasn't set, or there was some other problem with the request field(s).
1440    ///   See the log.
1441    GetVmoInfo { payload: AllocatorGetVmoInfoRequest, responder: AllocatorGetVmoInfoResponder },
1442    /// An interaction was received which does not match any known method.
1443    #[non_exhaustive]
1444    _UnknownMethod {
1445        /// Ordinal of the method that was called.
1446        ordinal: u64,
1447        control_handle: AllocatorControlHandle,
1448        method_type: fidl::MethodType,
1449    },
1450}
1451
1452impl AllocatorRequest {
1453    #[allow(irrefutable_let_patterns)]
1454    pub fn into_allocate_non_shared_collection(
1455        self,
1456    ) -> Option<(AllocatorAllocateNonSharedCollectionRequest, AllocatorControlHandle)> {
1457        if let AllocatorRequest::AllocateNonSharedCollection { payload, control_handle } = self {
1458            Some((payload, control_handle))
1459        } else {
1460            None
1461        }
1462    }
1463
1464    #[allow(irrefutable_let_patterns)]
1465    pub fn into_allocate_shared_collection(
1466        self,
1467    ) -> Option<(AllocatorAllocateSharedCollectionRequest, AllocatorControlHandle)> {
1468        if let AllocatorRequest::AllocateSharedCollection { payload, control_handle } = self {
1469            Some((payload, control_handle))
1470        } else {
1471            None
1472        }
1473    }
1474
1475    #[allow(irrefutable_let_patterns)]
1476    pub fn into_bind_shared_collection(
1477        self,
1478    ) -> Option<(AllocatorBindSharedCollectionRequest, AllocatorControlHandle)> {
1479        if let AllocatorRequest::BindSharedCollection { payload, control_handle } = self {
1480            Some((payload, control_handle))
1481        } else {
1482            None
1483        }
1484    }
1485
1486    #[allow(irrefutable_let_patterns)]
1487    pub fn into_validate_buffer_collection_token(
1488        self,
1489    ) -> Option<(
1490        AllocatorValidateBufferCollectionTokenRequest,
1491        AllocatorValidateBufferCollectionTokenResponder,
1492    )> {
1493        if let AllocatorRequest::ValidateBufferCollectionToken { payload, responder } = self {
1494            Some((payload, responder))
1495        } else {
1496            None
1497        }
1498    }
1499
1500    #[allow(irrefutable_let_patterns)]
1501    pub fn into_set_debug_client_info(
1502        self,
1503    ) -> Option<(AllocatorSetDebugClientInfoRequest, AllocatorControlHandle)> {
1504        if let AllocatorRequest::SetDebugClientInfo { payload, control_handle } = self {
1505            Some((payload, control_handle))
1506        } else {
1507            None
1508        }
1509    }
1510
1511    #[allow(irrefutable_let_patterns)]
1512    pub fn into_get_vmo_info(
1513        self,
1514    ) -> Option<(AllocatorGetVmoInfoRequest, AllocatorGetVmoInfoResponder)> {
1515        if let AllocatorRequest::GetVmoInfo { payload, responder } = self {
1516            Some((payload, responder))
1517        } else {
1518            None
1519        }
1520    }
1521
1522    /// Name of the method defined in FIDL
1523    pub fn method_name(&self) -> &'static str {
1524        match *self {
1525            AllocatorRequest::AllocateNonSharedCollection { .. } => {
1526                "allocate_non_shared_collection"
1527            }
1528            AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1529            AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1530            AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1531                "validate_buffer_collection_token"
1532            }
1533            AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1534            AllocatorRequest::GetVmoInfo { .. } => "get_vmo_info",
1535            AllocatorRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1536                "unknown one-way method"
1537            }
1538            AllocatorRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1539                "unknown two-way method"
1540            }
1541        }
1542    }
1543}
1544
1545#[derive(Debug, Clone)]
1546pub struct AllocatorControlHandle {
1547    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1548}
1549
1550impl fdomain_client::fidl::ControlHandle for AllocatorControlHandle {
1551    fn shutdown(&self) {
1552        self.inner.shutdown()
1553    }
1554
1555    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1556        self.inner.shutdown_with_epitaph(status)
1557    }
1558
1559    fn is_closed(&self) -> bool {
1560        self.inner.channel().is_closed()
1561    }
1562    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1563        self.inner.channel().on_closed()
1564    }
1565}
1566
1567impl AllocatorControlHandle {}
1568
1569#[must_use = "FIDL methods require a response to be sent"]
1570#[derive(Debug)]
1571pub struct AllocatorValidateBufferCollectionTokenResponder {
1572    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1573    tx_id: u32,
1574}
1575
1576/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1577/// if the responder is dropped without sending a response, so that the client
1578/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1579impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1580    fn drop(&mut self) {
1581        self.control_handle.shutdown();
1582        // Safety: drops once, never accessed again
1583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1584    }
1585}
1586
1587impl fdomain_client::fidl::Responder for AllocatorValidateBufferCollectionTokenResponder {
1588    type ControlHandle = AllocatorControlHandle;
1589
1590    fn control_handle(&self) -> &AllocatorControlHandle {
1591        &self.control_handle
1592    }
1593
1594    fn drop_without_shutdown(mut self) {
1595        // Safety: drops once, never accessed again due to mem::forget
1596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1597        // Prevent Drop from running (which would shut down the channel)
1598        std::mem::forget(self);
1599    }
1600}
1601
1602impl AllocatorValidateBufferCollectionTokenResponder {
1603    /// Sends a response to the FIDL transaction.
1604    ///
1605    /// Sets the channel to shutdown if an error occurs.
1606    pub fn send(
1607        self,
1608        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1609    ) -> Result<(), fidl::Error> {
1610        let _result = self.send_raw(payload);
1611        if _result.is_err() {
1612            self.control_handle.shutdown();
1613        }
1614        self.drop_without_shutdown();
1615        _result
1616    }
1617
1618    /// Similar to "send" but does not shutdown the channel if an error occurs.
1619    pub fn send_no_shutdown_on_err(
1620        self,
1621        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1622    ) -> Result<(), fidl::Error> {
1623        let _result = self.send_raw(payload);
1624        self.drop_without_shutdown();
1625        _result
1626    }
1627
1628    fn send_raw(
1629        &self,
1630        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1631    ) -> Result<(), fidl::Error> {
1632        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1633            AllocatorValidateBufferCollectionTokenResponse,
1634        >>(
1635            fidl::encoding::Flexible::new(payload),
1636            self.tx_id,
1637            0x4c5ee91b02a7e68d,
1638            fidl::encoding::DynamicFlags::FLEXIBLE,
1639        )
1640    }
1641}
1642
1643#[must_use = "FIDL methods require a response to be sent"]
1644#[derive(Debug)]
1645pub struct AllocatorGetVmoInfoResponder {
1646    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1647    tx_id: u32,
1648}
1649
1650/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1651/// if the responder is dropped without sending a response, so that the client
1652/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1653impl std::ops::Drop for AllocatorGetVmoInfoResponder {
1654    fn drop(&mut self) {
1655        self.control_handle.shutdown();
1656        // Safety: drops once, never accessed again
1657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1658    }
1659}
1660
1661impl fdomain_client::fidl::Responder for AllocatorGetVmoInfoResponder {
1662    type ControlHandle = AllocatorControlHandle;
1663
1664    fn control_handle(&self) -> &AllocatorControlHandle {
1665        &self.control_handle
1666    }
1667
1668    fn drop_without_shutdown(mut self) {
1669        // Safety: drops once, never accessed again due to mem::forget
1670        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1671        // Prevent Drop from running (which would shut down the channel)
1672        std::mem::forget(self);
1673    }
1674}
1675
1676impl AllocatorGetVmoInfoResponder {
1677    /// Sends a response to the FIDL transaction.
1678    ///
1679    /// Sets the channel to shutdown if an error occurs.
1680    pub fn send(
1681        self,
1682        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1683    ) -> Result<(), fidl::Error> {
1684        let _result = self.send_raw(result);
1685        if _result.is_err() {
1686            self.control_handle.shutdown();
1687        }
1688        self.drop_without_shutdown();
1689        _result
1690    }
1691
1692    /// Similar to "send" but does not shutdown the channel if an error occurs.
1693    pub fn send_no_shutdown_on_err(
1694        self,
1695        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1696    ) -> Result<(), fidl::Error> {
1697        let _result = self.send_raw(result);
1698        self.drop_without_shutdown();
1699        _result
1700    }
1701
1702    fn send_raw(
1703        &self,
1704        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1705    ) -> Result<(), fidl::Error> {
1706        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1707            AllocatorGetVmoInfoResponse,
1708            Error,
1709        >>(
1710            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1711            self.tx_id,
1712            0x21a881120aa0ddf9,
1713            fidl::encoding::DynamicFlags::FLEXIBLE,
1714        )
1715    }
1716}
1717
1718#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1719pub struct BufferCollectionMarker;
1720
1721impl fdomain_client::fidl::ProtocolMarker for BufferCollectionMarker {
1722    type Proxy = BufferCollectionProxy;
1723    type RequestStream = BufferCollectionRequestStream;
1724
1725    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1726}
1727pub type BufferCollectionWaitForAllBuffersAllocatedResult =
1728    Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>;
1729pub type BufferCollectionCheckAllBuffersAllocatedResult = Result<(), Error>;
1730
1731pub trait BufferCollectionProxyInterface: Send + Sync {
1732    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1733    fn r#sync(&self) -> Self::SyncResponseFut;
1734    fn r#release(&self) -> Result<(), fidl::Error>;
1735    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
1736    fn r#set_debug_client_info(
1737        &self,
1738        payload: &NodeSetDebugClientInfoRequest,
1739    ) -> Result<(), fidl::Error>;
1740    fn r#set_debug_timeout_log_deadline(
1741        &self,
1742        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
1743    ) -> Result<(), fidl::Error>;
1744    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1745    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
1746        + Send;
1747    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1748    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1749        + Send;
1750    fn r#is_alternate_for(
1751        &self,
1752        payload: NodeIsAlternateForRequest,
1753    ) -> Self::IsAlternateForResponseFut;
1754    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
1755        + Send;
1756    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
1757    fn r#set_weak(&self) -> Result<(), fidl::Error>;
1758    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
1759    fn r#attach_node_tracking(
1760        &self,
1761        payload: NodeAttachNodeTrackingRequest,
1762    ) -> Result<(), fidl::Error>;
1763    fn r#set_constraints(
1764        &self,
1765        payload: BufferCollectionSetConstraintsRequest,
1766    ) -> Result<(), fidl::Error>;
1767    type WaitForAllBuffersAllocatedResponseFut: std::future::Future<
1768            Output = Result<BufferCollectionWaitForAllBuffersAllocatedResult, fidl::Error>,
1769        > + Send;
1770    fn r#wait_for_all_buffers_allocated(&self) -> Self::WaitForAllBuffersAllocatedResponseFut;
1771    type CheckAllBuffersAllocatedResponseFut: std::future::Future<
1772            Output = Result<BufferCollectionCheckAllBuffersAllocatedResult, fidl::Error>,
1773        > + Send;
1774    fn r#check_all_buffers_allocated(&self) -> Self::CheckAllBuffersAllocatedResponseFut;
1775    fn r#attach_token(
1776        &self,
1777        payload: BufferCollectionAttachTokenRequest,
1778    ) -> Result<(), fidl::Error>;
1779    fn r#attach_lifetime_tracking(
1780        &self,
1781        payload: BufferCollectionAttachLifetimeTrackingRequest,
1782    ) -> Result<(), fidl::Error>;
1783}
1784
1785#[derive(Debug, Clone)]
1786pub struct BufferCollectionProxy {
1787    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1788}
1789
1790impl fdomain_client::fidl::Proxy for BufferCollectionProxy {
1791    type Protocol = BufferCollectionMarker;
1792
1793    fn from_channel(inner: fdomain_client::Channel) -> Self {
1794        Self::new(inner)
1795    }
1796
1797    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1798        self.client.into_channel().map_err(|client| Self { client })
1799    }
1800
1801    fn as_channel(&self) -> &fdomain_client::Channel {
1802        self.client.as_channel()
1803    }
1804}
1805
1806impl BufferCollectionProxy {
1807    /// Create a new Proxy for fuchsia.sysmem2/BufferCollection.
1808    pub fn new(channel: fdomain_client::Channel) -> Self {
1809        let protocol_name =
1810            <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1811        Self { client: fidl::client::Client::new(channel, protocol_name) }
1812    }
1813
1814    /// Get a Stream of events from the remote end of the protocol.
1815    ///
1816    /// # Panics
1817    ///
1818    /// Panics if the event stream was already taken.
1819    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
1820        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
1821    }
1822
1823    /// Ensure that previous messages have been received server side. This is
1824    /// particularly useful after previous messages that created new tokens,
1825    /// because a token must be known to the sysmem server before sending the
1826    /// token to another participant.
1827    ///
1828    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
1829    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
1830    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
1831    /// to mitigate the possibility of a hostile/fake
1832    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
1833    /// Another way is to pass the token to
1834    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
1835    /// the token as part of exchanging it for a
1836    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
1837    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
1838    /// of stalling.
1839    ///
1840    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
1841    /// and then starting and completing a `Sync`, it's then safe to send the
1842    /// `BufferCollectionToken` client ends to other participants knowing the
1843    /// server will recognize the tokens when they're sent by the other
1844    /// participants to sysmem in a
1845    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
1846    /// efficient way to create tokens while avoiding unnecessary round trips.
1847    ///
1848    /// Other options include waiting for each
1849    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
1850    /// individually (using separate call to `Sync` after each), or calling
1851    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
1852    /// converted to a `BufferCollection` via
1853    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
1854    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
1855    /// the sync step and can create multiple tokens at once.
1856    pub fn r#sync(
1857        &self,
1858    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1859        BufferCollectionProxyInterface::r#sync(self)
1860    }
1861
1862    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
1863    ///
1864    /// Normally a participant will convert a `BufferCollectionToken` into a
1865    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
1866    /// `Release` via the token (and then close the channel immediately or
1867    /// shortly later in response to server closing the server end), which
1868    /// avoids causing buffer collection failure. Without a prior `Release`,
1869    /// closing the `BufferCollectionToken` client end will cause buffer
1870    /// collection failure.
1871    ///
1872    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
1873    ///
1874    /// By default the server handles unexpected closure of a
1875    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
1876    /// first) by failing the buffer collection. Partly this is to expedite
1877    /// closing VMO handles to reclaim memory when any participant fails. If a
1878    /// participant would like to cleanly close a `BufferCollection` without
1879    /// causing buffer collection failure, the participant can send `Release`
1880    /// before closing the `BufferCollection` client end. The `Release` can
1881    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
1882    /// buffer collection won't require constraints from this node in order to
1883    /// allocate. If after `SetConstraints`, the constraints are retained and
1884    /// aggregated, despite the lack of `BufferCollection` connection at the
1885    /// time of constraints aggregation.
1886    ///
1887    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
1888    ///
1889    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
1890    /// end (without `Release` first) will trigger failure of the buffer
1891    /// collection. To close a `BufferCollectionTokenGroup` channel without
1892    /// failing the buffer collection, ensure that AllChildrenPresent() has been
1893    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
1894    /// client end.
1895    ///
1896    /// If `Release` occurs before
1897    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
1898    /// buffer collection will fail (triggered by reception of `Release` without
1899    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
1900    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
1901    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
1902    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
1903    /// close requires `AllChildrenPresent` (if not already sent), then
1904    /// `Release`, then close client end.
1905    ///
1906    /// If `Release` occurs after `AllChildrenPresent`, the children and all
1907    /// their constraints remain intact (just as they would if the
1908    /// `BufferCollectionTokenGroup` channel had remained open), and the client
1909    /// end close doesn't trigger buffer collection failure.
1910    ///
1911    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
1912    ///
1913    /// For brevity, the per-channel-protocol paragraphs above ignore the
1914    /// separate failure domain created by
1915    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
1916    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
1917    /// unexpectedly closes (without `Release` first) and that client end is
1918    /// under a failure domain, instead of failing the whole buffer collection,
1919    /// the failure domain is failed, but the buffer collection itself is
1920    /// isolated from failure of the failure domain. Such failure domains can be
1921    /// nested, in which case only the inner-most failure domain in which the
1922    /// `Node` resides fails.
1923    pub fn r#release(&self) -> Result<(), fidl::Error> {
1924        BufferCollectionProxyInterface::r#release(self)
1925    }
1926
1927    /// Set a name for VMOs in this buffer collection.
1928    ///
1929    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
1930    /// will be truncated to fit. The name of the vmo will be suffixed with the
1931    /// buffer index within the collection (if the suffix fits within
1932    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
1933    /// listed in the inspect data.
1934    ///
1935    /// The name only affects VMOs allocated after the name is set; this call
1936    /// does not rename existing VMOs. If multiple clients set different names
1937    /// then the larger priority value will win. Setting a new name with the
1938    /// same priority as a prior name doesn't change the name.
1939    ///
1940    /// All table fields are currently required.
1941    ///
1942    /// + request `priority` The name is only set if this is the first `SetName`
1943    ///   or if `priority` is greater than any previous `priority` value in
1944    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
1945    /// + request `name` The name for VMOs created under this buffer collection.
1946    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
1947        BufferCollectionProxyInterface::r#set_name(self, payload)
1948    }
1949
1950    /// Set information about the current client that can be used by sysmem to
1951    /// help diagnose leaking memory and allocation stalls waiting for a
1952    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1953    ///
1954    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
1955    /// `Node`(s) derived from this `Node`, unless overriden by
1956    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
1957    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
1958    ///
1959    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
1960    /// `Allocator` is the most efficient way to ensure that all
1961    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
1962    /// set, and is also more efficient than separately sending the same debug
1963    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
1964    /// created [`fuchsia.sysmem2/Node`].
1965    ///
1966    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
1967    /// indicate which client is closing their channel first, leading to subtree
1968    /// failure (which can be normal if the purpose of the subtree is over, but
1969    /// if happening earlier than expected, the client-channel-specific name can
1970    /// help diagnose where the failure is first coming from, from sysmem's
1971    /// point of view).
1972    ///
1973    /// All table fields are currently required.
1974    ///
1975    /// + request `name` This can be an arbitrary string, but the current
1976    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
1977    /// + request `id` This can be an arbitrary id, but the current process ID
1978    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
1979    pub fn r#set_debug_client_info(
1980        &self,
1981        mut payload: &NodeSetDebugClientInfoRequest,
1982    ) -> Result<(), fidl::Error> {
1983        BufferCollectionProxyInterface::r#set_debug_client_info(self, payload)
1984    }
1985
1986    /// Sysmem logs a warning if sysmem hasn't seen
1987    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
1988    /// within 5 seconds after creation of a new collection.
1989    ///
1990    /// Clients can call this method to change when the log is printed. If
1991    /// multiple client set the deadline, it's unspecified which deadline will
1992    /// take effect.
1993    ///
1994    /// In most cases the default works well.
1995    ///
1996    /// All table fields are currently required.
1997    ///
1998    /// + request `deadline` The time at which sysmem will start trying to log
1999    ///   the warning, unless all constraints are with sysmem by then.
2000    pub fn r#set_debug_timeout_log_deadline(
2001        &self,
2002        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
2003    ) -> Result<(), fidl::Error> {
2004        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
2005    }
2006
2007    /// This enables verbose logging for the buffer collection.
2008    ///
2009    /// Verbose logging includes constraints set via
2010    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
2011    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
2012    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
2013    /// the tree of `Node`(s).
2014    ///
2015    /// Normally sysmem prints only a single line complaint when aggregation
2016    /// fails, with just the specific detailed reason that aggregation failed,
2017    /// with little surrounding context.  While this is often enough to diagnose
2018    /// a problem if only a small change was made and everything was working
2019    /// before the small change, it's often not particularly helpful for getting
2020    /// a new buffer collection to work for the first time.  Especially with
2021    /// more complex trees of nodes, involving things like
2022    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
2023    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
2024    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
2025    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
2026    /// looks like and why it's failing a logical allocation, or why a tree or
2027    /// subtree is failing sooner than expected.
2028    ///
2029    /// The intent of the extra logging is to be acceptable from a performance
2030    /// point of view, under the assumption that verbose logging is only enabled
2031    /// on a low number of buffer collections. If we're not tracking down a bug,
2032    /// we shouldn't send this message.
2033    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2034        BufferCollectionProxyInterface::r#set_verbose_logging(self)
2035    }
2036
2037    /// This gets a handle that can be used as a parameter to
2038    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
2039    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
2040    /// client obtained this handle from this `Node`.
2041    ///
2042    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
2043    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
2044    /// despite the two calls typically being on different channels.
2045    ///
2046    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
2047    ///
2048    /// All table fields are currently required.
2049    ///
2050    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
2051    ///   different `Node` channel, to prove that the client obtained the handle
2052    ///   from this `Node`.
2053    pub fn r#get_node_ref(
2054        &self,
2055    ) -> fidl::client::QueryResponseFut<
2056        NodeGetNodeRefResponse,
2057        fdomain_client::fidl::FDomainResourceDialect,
2058    > {
2059        BufferCollectionProxyInterface::r#get_node_ref(self)
2060    }
2061
2062    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
2063    /// rooted at a different child token of a common parent
2064    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
2065    /// passed-in `node_ref`.
2066    ///
2067    /// This call is for assisting with admission control de-duplication, and
2068    /// with debugging.
2069    ///
2070    /// The `node_ref` must be obtained using
2071    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
2072    ///
2073    /// The `node_ref` can be a duplicated handle; it's not necessary to call
2074    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
2075    ///
2076    /// If a calling token may not actually be a valid token at all due to a
2077    /// potentially hostile/untrusted provider of the token, call
2078    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
2079    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
2080    /// never responds due to a calling token not being a real token (not really
2081    /// talking to sysmem).  Another option is to call
2082    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
2083    /// which also validates the token along with converting it to a
2084    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
2085    ///
2086    /// All table fields are currently required.
2087    ///
2088    /// - response `is_alternate`
2089    ///   - true: The first parent node in common between the calling node and
2090    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
2091    ///     that the calling `Node` and the `node_ref` `Node` will not have both
2092    ///     their constraints apply - rather sysmem will choose one or the other
2093    ///     of the constraints - never both.  This is because only one child of
2094    ///     a `BufferCollectionTokenGroup` is selected during logical
2095    ///     allocation, with only that one child's subtree contributing to
2096    ///     constraints aggregation.
2097    ///   - false: The first parent node in common between the calling `Node`
2098    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
2099    ///     Currently, this means the first parent node in common is a
2100    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
2101    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
2102    ///     `Node` may have both their constraints apply during constraints
2103    ///     aggregation of the logical allocation, if both `Node`(s) are
2104    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
2105    ///     this case, there is no `BufferCollectionTokenGroup` that will
2106    ///     directly prevent the two `Node`(s) from both being selected and
2107    ///     their constraints both aggregated, but even when false, one or both
2108    ///     `Node`(s) may still be eliminated from consideration if one or both
2109    ///     `Node`(s) has a direct or indirect parent
2110    ///     `BufferCollectionTokenGroup` which selects a child subtree other
2111    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
2112    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
2113    ///   associated with the same buffer collection as the calling `Node`.
2114    ///   Another reason for this error is if the `node_ref` is an
2115    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
2116    ///   a real `node_ref` obtained from `GetNodeRef`.
2117    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
2118    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
2119    ///   the needed rights expected on a real `node_ref`.
2120    /// * No other failing status codes are returned by this call.  However,
2121    ///   sysmem may add additional codes in future, so the client should have
2122    ///   sensible default handling for any failing status code.
2123    pub fn r#is_alternate_for(
2124        &self,
2125        mut payload: NodeIsAlternateForRequest,
2126    ) -> fidl::client::QueryResponseFut<
2127        NodeIsAlternateForResult,
2128        fdomain_client::fidl::FDomainResourceDialect,
2129    > {
2130        BufferCollectionProxyInterface::r#is_alternate_for(self, payload)
2131    }
2132
2133    /// Get the buffer collection ID. This ID is also available from
2134    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
2135    /// within the collection).
2136    ///
2137    /// This call is mainly useful in situations where we can't convey a
2138    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
2139    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
2140    /// handle, which can be joined back up with a `BufferCollection` client end
2141    /// that was created via a different path. Prefer to convey a
2142    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
2143    ///
2144    /// Trusting a `buffer_collection_id` value from a source other than sysmem
2145    /// is analogous to trusting a koid value from a source other than zircon.
2146    /// Both should be avoided unless really necessary, and both require
2147    /// caution. In some situations it may be reasonable to refer to a
2148    /// pre-established `BufferCollection` by `buffer_collection_id` via a
2149    /// protocol for efficiency reasons, but an incoming value purporting to be
2150    /// a `buffer_collection_id` is not sufficient alone to justify granting the
2151    /// sender of the `buffer_collection_id` any capability. The sender must
2152    /// first prove to a receiver that the sender has/had a VMO or has/had a
2153    /// `BufferCollectionToken` to the same collection by sending a handle that
2154    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
2155    /// `buffer_collection_id` value. The receiver should take care to avoid
2156    /// assuming that a sender had a `BufferCollectionToken` in cases where the
2157    /// sender has only proven that the sender had a VMO.
2158    ///
2159    /// - response `buffer_collection_id` This ID is unique per buffer
2160    ///   collection per boot. Each buffer is uniquely identified by the
2161    ///   `buffer_collection_id` and `buffer_index` together.
2162    pub fn r#get_buffer_collection_id(
2163        &self,
2164    ) -> fidl::client::QueryResponseFut<
2165        NodeGetBufferCollectionIdResponse,
2166        fdomain_client::fidl::FDomainResourceDialect,
2167    > {
2168        BufferCollectionProxyInterface::r#get_buffer_collection_id(self)
2169    }
2170
2171    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
2172    /// created after this message to weak, which means that a client's `Node`
2173    /// client end (or a child created after this message) is not alone
2174    /// sufficient to keep allocated VMOs alive.
2175    ///
2176    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
2177    /// `close_weak_asap`.
2178    ///
2179    /// This message is only permitted before the `Node` becomes ready for
2180    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
2181    ///   * `BufferCollectionToken`: any time
2182    ///   * `BufferCollection`: before `SetConstraints`
2183    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
2184    ///
2185    /// Currently, no conversion from strong `Node` to weak `Node` after ready
2186    /// for allocation is provided, but a client can simulate that by creating
2187    /// an additional `Node` before allocation and setting that additional
2188    /// `Node` to weak, and then potentially at some point later sending
2189    /// `Release` and closing the client end of the client's strong `Node`, but
2190    /// keeping the client's weak `Node`.
2191    ///
2192    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
2193    /// collection failure (all `Node` client end(s) will see
2194    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
2195    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
2196    /// this situation until all `Node`(s) are ready for allocation. For initial
2197    /// allocation to succeed, at least one strong `Node` is required to exist
2198    /// at allocation time, but after that client receives VMO handles, that
2199    /// client can `BufferCollection.Release` and close the client end without
2200    /// causing this type of failure.
2201    ///
2202    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
2203    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
2204    /// separately as appropriate.
2205    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
2206        BufferCollectionProxyInterface::r#set_weak(self)
2207    }
2208
2209    /// This indicates to sysmem that the client is prepared to pay attention to
2210    /// `close_weak_asap`.
2211    ///
2212    /// If sent, this message must be before
2213    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
2214    ///
2215    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
2216    /// send this message before `WaitForAllBuffersAllocated`, or a parent
2217    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
2218    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
2219    /// trigger buffer collection failure.
2220    ///
2221    /// This message is necessary because weak sysmem VMOs have not always been
2222    /// a thing, so older clients are not aware of the need to pay attention to
2223    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
2224    /// sysmem weak VMO handles asap. By having this message and requiring
2225    /// participants to indicate their acceptance of this aspect of the overall
2226    /// protocol, we avoid situations where an older client is delivered a weak
2227    /// VMO without any way for sysmem to get that VMO to close quickly later
2228    /// (and on a per-buffer basis).
2229    ///
2230    /// A participant that doesn't handle `close_weak_asap` and also doesn't
2231    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
2232    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
2233    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
2234    /// same participant has a child/delegate which does retrieve VMOs, that
2235    /// child/delegate will need to send `SetWeakOk` before
2236    /// `WaitForAllBuffersAllocated`.
2237    ///
2238    /// + request `for_child_nodes_also` If present and true, this means direct
2239    ///   child nodes of this node created after this message plus all
2240    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
2241    ///   those nodes. Any child node of this node that was created before this
2242    ///   message is not included. This setting is "sticky" in the sense that a
2243    ///   subsequent `SetWeakOk` without this bool set to true does not reset
2244    ///   the server-side bool. If this creates a problem for a participant, a
2245    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
2246    ///   tokens instead, as appropriate. A participant should only set
2247    ///   `for_child_nodes_also` true if the participant can really promise to
2248    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
2249    ///   weak VMO handles held by participants holding the corresponding child
2250    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
2251    ///   which are using sysmem(1) can be weak, despite the clients of those
2252    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
2253    ///   direct way to find out about `close_weak_asap`. This only applies to
2254    ///   descendents of this `Node` which are using sysmem(1), not to this
2255    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
2256    ///   token, which will fail allocation unless an ancestor of this `Node`
2257    ///   specified `for_child_nodes_also` true.
2258    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
2259        BufferCollectionProxyInterface::r#set_weak_ok(self, payload)
2260    }
2261
2262    /// The server_end will be closed after this `Node` and any child nodes have
2263    /// have released their buffer counts, making those counts available for
2264    /// reservation by a different `Node` via
2265    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
2266    ///
2267    /// The `Node` buffer counts may not be released until the entire tree of
2268    /// `Node`(s) is closed or failed, because
2269    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
2270    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
2271    /// `Node` buffer counts remain reserved until the orphaned node is later
2272    /// cleaned up.
2273    ///
2274    /// If the `Node` exceeds a fairly large number of attached eventpair server
2275    /// ends, a log message will indicate this and the `Node` (and the
2276    /// appropriate) sub-tree will fail.
2277    ///
2278    /// The `server_end` will remain open when
2279    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
2280    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
2281    /// [`fuchsia.sysmem2/BufferCollection`].
2282    ///
2283    /// This message can also be used with a
2284    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
2285    pub fn r#attach_node_tracking(
2286        &self,
2287        mut payload: NodeAttachNodeTrackingRequest,
2288    ) -> Result<(), fidl::Error> {
2289        BufferCollectionProxyInterface::r#attach_node_tracking(self, payload)
2290    }
2291
2292    /// Provide [`fuchsia.sysmem2/BufferCollectionConstraints`] to the buffer
2293    /// collection.
2294    ///
2295    /// A participant may only call
2296    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] up to once per
2297    /// [`fuchsia.sysmem2/BufferCollection`].
2298    ///
2299    /// For buffer allocation to be attempted, all holders of a
2300    /// `BufferCollection` client end need to call `SetConstraints` before
2301    /// sysmem will attempt to allocate buffers.
2302    pub fn r#set_constraints(
2303        &self,
2304        mut payload: BufferCollectionSetConstraintsRequest,
2305    ) -> Result<(), fidl::Error> {
2306        BufferCollectionProxyInterface::r#set_constraints(self, payload)
2307    }
2308
2309    /// Wait until all buffers are allocated.
2310    ///
2311    /// This FIDL call completes when buffers have been allocated, or completes
2312    /// with some failure detail if allocation has been attempted but failed.
2313    ///
2314    /// The following must occur before buffers will be allocated:
2315    ///   * All [`fuchsia.sysmem2/BufferCollectionToken`](s) of the buffer
2316    ///     collection must be turned in via `BindSharedCollection` to get a
2317    ///     [`fuchsia.sysmem2/BufferCollection`] (for brevity, this is assuming
2318    ///     [`fuchsia.sysmem2/BufferCollection.AttachToken`] isn't being used),
2319    ///     or have had [`fuchsia.sysmem2/BufferCollectionToken.Release`] sent
2320    ///     to them.
2321    ///   * All [`fuchsia.sysmem2/BufferCollection`](s) of the buffer collection
2322    ///     must have had [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
2323    ///     sent to them, or had [`fuchsia.sysmem2/BufferCollection.Release`]
2324    ///     sent to them.
2325    ///
2326    /// - result `buffer_collection_info` The VMO handles and other related
2327    ///   info.
2328    /// * error `[fuchsia.sysmem2/Error.NO_MEMORY]` The request is valid but
2329    ///   cannot be fulfilled due to resource exhaustion.
2330    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION`] The request is
2331    ///   malformed.
2332    /// * error `[fuchsia.sysmem2/Error.CONSTRAINTS_INTERSECTION_EMPTY`] The
2333    ///   request is valid but cannot be satisfied, perhaps due to hardware
2334    ///   limitations. This can happen if participants have incompatible
2335    ///   constraints (empty intersection, roughly speaking). See the log for
2336    ///   more info. In cases where a participant could potentially be treated
2337    ///   as optional, see [`BufferCollectionTokenGroup`]. When using
2338    ///   [`fuchsia.sysmem2/BufferCollection.AttachToken`], this will be the
2339    ///   error code if there aren't enough buffers in the pre-existing
2340    ///   collection to satisfy the constraints set on the attached token and
2341    ///   any sub-tree of tokens derived from the attached token.
2342    pub fn r#wait_for_all_buffers_allocated(
2343        &self,
2344    ) -> fidl::client::QueryResponseFut<
2345        BufferCollectionWaitForAllBuffersAllocatedResult,
2346        fdomain_client::fidl::FDomainResourceDialect,
2347    > {
2348        BufferCollectionProxyInterface::r#wait_for_all_buffers_allocated(self)
2349    }
2350
2351    /// Checks whether all the buffers have been allocated, in a polling
2352    /// fashion.
2353    ///
2354    /// * If the buffer collection has been allocated, returns success.
2355    /// * If the buffer collection failed allocation, returns the same
2356    ///   [`fuchsia.sysmem2/Error`] as
2357    ///   [`fuchsia.sysmem2/BufferCollection/WaitForAllBuffersAllocated`] would
2358    ///   return.
2359    /// * error [`fuchsia.sysmem2/Error.PENDING`] The buffer collection hasn't
2360    ///   attempted allocation yet. This means that WaitForAllBuffersAllocated
2361    ///   would not respond quickly.
2362    pub fn r#check_all_buffers_allocated(
2363        &self,
2364    ) -> fidl::client::QueryResponseFut<
2365        BufferCollectionCheckAllBuffersAllocatedResult,
2366        fdomain_client::fidl::FDomainResourceDialect,
2367    > {
2368        BufferCollectionProxyInterface::r#check_all_buffers_allocated(self)
2369    }
2370
2371    /// Create a new token to add a new participant to an existing logical
2372    /// buffer collection, if the existing collection's buffer counts,
2373    /// constraints, and participants allow.
2374    ///
2375    /// This can be useful in replacing a failed participant, and/or in
2376    /// adding/re-adding a participant after buffers have already been
2377    /// allocated.
2378    ///
2379    /// When [`fuchsia.sysmem2/BufferCollection.AttachToken`] is used, the sub
2380    /// tree rooted at the attached [`fuchsia.sysmem2/BufferCollectionToken`]
2381    /// goes through the normal procedure of setting constraints or closing
2382    /// [`fuchsia.sysmem2/Node`](s), and then appearing to allocate buffers from
2383    /// clients' point of view, despite the possibility that all the buffers
2384    /// were actually allocated previously. This process is called "logical
2385    /// allocation". Most instances of "allocation" in docs for other messages
2386    /// can also be read as "allocation or logical allocation" while remaining
2387    /// valid, but we just say "allocation" in most places for brevity/clarity
2388    /// of explanation, with the details of "logical allocation" left for the
2389    /// docs here on `AttachToken`.
2390    ///
2391    /// Failure of an attached `Node` does not propagate to the parent of the
2392    /// attached `Node`. More generally, failure of a child `Node` is blocked
2393    /// from reaching its parent `Node` if the child is attached, or if the
2394    /// child is dispensable and the failure occurred after logical allocation
2395    /// (see [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`]).
2396    ///
2397    /// A participant may in some scenarios choose to initially use a
2398    /// dispensable token for a given instance of a delegate participant, and
2399    /// then later if the first instance of that delegate participant fails, a
2400    /// new second instance of that delegate participant my be given a token
2401    /// created with `AttachToken`.
2402    ///
2403    /// From the point of view of the [`fuchsia.sysmem2/BufferCollectionToken`]
2404    /// client end, the token acts like any other token. The client can
2405    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] the token as needed,
2406    /// and can send the token to a different process/participant. The
2407    /// `BufferCollectionToken` `Node` should be converted to a
2408    /// `BufferCollection` `Node` as normal by sending
2409    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or can be closed
2410    /// without causing subtree failure by sending
2411    /// [`fuchsia.sysmem2/BufferCollectionToken.Release`]. Assuming the former,
2412    /// the [`fuchsia.sysmem2/BufferCollection.SetConstraints`] message or
2413    /// [`fuchsia.sysmem2/BufferCollection.Release`] message should be sent to
2414    /// the `BufferCollection`.
2415    ///
2416    /// Within the subtree, a success result from
2417    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] means
2418    /// the subtree participants' constraints were satisfiable using the
2419    /// already-existing buffer collection, the already-established
2420    /// [`fuchsia.sysmem2/BufferCollectionInfo`] including image format
2421    /// constraints, and the already-existing other participants (already added
2422    /// via successful logical allocation) and their specified buffer counts in
2423    /// their constraints. A failure result means the new participants'
2424    /// constraints cannot be satisfied using the existing buffer collection and
2425    /// its already-added participants. Creating a new collection instead may
2426    /// allow all participants' constraints to be satisfied, assuming
2427    /// `SetDispensable` is used in place of `AttachToken`, or a normal token is
2428    /// used.
2429    ///
2430    /// A token created with `AttachToken` performs constraints aggregation with
2431    /// all constraints currently in effect on the buffer collection, plus the
2432    /// attached token under consideration plus child tokens under the attached
2433    /// token which are not themselves an attached token or under such a token.
2434    /// Further subtrees under this subtree are considered for logical
2435    /// allocation only after this subtree has completed logical allocation.
2436    ///
2437    /// Assignment of existing buffers to participants'
2438    /// [`fuchsia.sysmem2/BufferCollectionConstraints.min_buffer_count_for_camping`]
2439    /// etc is first-come first-served, but a child can't logically allocate
2440    /// before all its parents have sent `SetConstraints`.
2441    ///
2442    /// See also [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`], which
2443    /// in contrast to `AttachToken`, has the created token `Node` + child
2444    /// `Node`(s) (in the created subtree but not in any subtree under this
2445    /// subtree) participate in constraints aggregation along with its parent
2446    /// during the parent's allocation or logical allocation.
2447    ///
2448    /// Similar to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], the
2449    /// newly created token needs to be [`fuchsia.sysmem2/Node.Sync`]ed to
2450    /// sysmem before the new token can be passed to `BindSharedCollection`. The
2451    /// `Sync` of the new token can be accomplished with
2452    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after converting the created
2453    /// `BufferCollectionToken` to a `BufferCollection`. Alternately,
2454    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on the new token also
2455    /// works. Or using [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`]
2456    /// works. As usual, a `BufferCollectionToken.Sync` can be started after any
2457    /// `BufferCollectionToken.Duplicate` messages have been sent via the newly
2458    /// created token, to also sync those additional tokens to sysmem using a
2459    /// single round-trip.
2460    ///
2461    /// All table fields are currently required.
2462    ///
2463    /// + request `rights_attentuation_mask` This allows attenuating the VMO
2464    ///   rights of the subtree. These values for `rights_attenuation_mask`
2465    ///   result in no attenuation (note that 0 is not on this list):
2466    ///   + ZX_RIGHT_SAME_RIGHTS (preferred)
2467    ///   + 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2468    /// + request `token_request` The server end of the `BufferCollectionToken`
2469    ///   channel. The client retains the client end.
2470    pub fn r#attach_token(
2471        &self,
2472        mut payload: BufferCollectionAttachTokenRequest,
2473    ) -> Result<(), fidl::Error> {
2474        BufferCollectionProxyInterface::r#attach_token(self, payload)
2475    }
2476
2477    /// Set up an eventpair to be signalled (`ZX_EVENTPAIR_PEER_CLOSED`) when
2478    /// buffers have been allocated and only the specified number of buffers (or
2479    /// fewer) remain in the buffer collection.
2480    ///
2481    /// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] allows a
2482    /// client to wait until an old buffer collection is fully or mostly
2483    /// deallocated before attempting allocation of a new buffer collection. The
2484    /// eventpair is only signalled when the buffers of this collection have
2485    /// been fully deallocated (not just un-referenced by clients, but all the
2486    /// memory consumed by those buffers has been fully reclaimed/recycled), or
2487    /// when allocation or logical allocation fails for the tree or subtree
2488    /// including this [`fuchsia.sysmem2/BufferCollection`].
2489    ///
2490    /// The eventpair won't be signalled until allocation or logical allocation
2491    /// has completed; until then, the collection's current buffer count is
2492    /// ignored.
2493    ///
2494    /// If logical allocation fails for an attached subtree (using
2495    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]), the server end of the
2496    /// eventpair will close during that failure regardless of the number of
2497    /// buffers potenitally allocated in the overall buffer collection. This is
2498    /// for logical allocation consistency with normal allocation.
2499    ///
2500    /// The lifetime signalled by this event includes asynchronous cleanup of
2501    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2502    /// holders of VMO handles to the buffers have closed those VMO handles.
2503    /// Therefore, clients should take care not to become blocked forever
2504    /// waiting for `ZX_EVENTPAIR_PEER_CLOSED` to be signalled if any of the
2505    /// participants using the logical buffer collection (including the waiter
2506    /// itself) are less trusted, less reliable, or potentially blocked by the
2507    /// wait itself. Waiting asynchronously is recommended. Setting a deadline
2508    /// for the client wait may be prudent, depending on details of how the
2509    /// collection and/or its VMOs are used or shared. Failure to allocate a
2510    /// new/replacement buffer collection is better than getting stuck forever.
2511    ///
2512    /// The sysmem server itself intentionally does not perform any waiting on
2513    /// already-failed collections' VMOs to finish cleaning up before attempting
2514    /// a new allocation, and the sysmem server intentionally doesn't retry
2515    /// allocation if a new allocation fails due to out of memory, even if that
2516    /// failure is potentially due to continued existence of an old collection's
2517    /// VMOs. This `AttachLifetimeTracking` message is how an initiator can
2518    /// mitigate too much overlap of old VMO lifetimes with new VMO lifetimes,
2519    /// as long as the waiting client is careful to not create a deadlock.
2520    ///
2521    /// Continued existence of old collections that are still cleaning up is not
2522    /// the only reason that a new allocation may fail due to insufficient
2523    /// memory, even if the new allocation is allocating physically contiguous
2524    /// buffers. Overall system memory pressure can also be the cause of failure
2525    /// to allocate a new collection. See also
2526    /// [`fuchsia.memorypressure/Provider`].
2527    ///
2528    /// `AttachLifetimeTracking` is meant to be compatible with other protocols
2529    /// with a similar `AttachLifetimeTracking` message; duplicates of the same
2530    /// `eventpair` handle (server end) can be sent via more than one
2531    /// `AttachLifetimeTracking` message to different protocols, and the
2532    /// `ZX_EVENTPAIR_PEER_CLOSED` will be signalled for the client end when all
2533    /// the conditions are met (all holders of duplicates have closed their
2534    /// server end handle(s)). Also, thanks to how eventpair endponts work, the
2535    /// client end can (also) be duplicated without preventing the
2536    /// `ZX_EVENTPAIR_PEER_CLOSED` signal.
2537    ///
2538    /// The server intentionally doesn't "trust" any signals set on the
2539    /// `server_end`. This mechanism intentionally uses only
2540    /// `ZX_EVENTPAIR_PEER_CLOSED` set on the client end, which can't be set
2541    /// "early", and is only set when all handles to the server end eventpair
2542    /// are closed. No meaning is associated with any of the other signals, and
2543    /// clients should ignore any other signal bits on either end of the
2544    /// `eventpair`.
2545    ///
2546    /// The `server_end` may lack `ZX_RIGHT_SIGNAL` or `ZX_RIGHT_SIGNAL_PEER`,
2547    /// but must have `ZX_RIGHT_DUPLICATE` (and must have `ZX_RIGHT_TRANSFER` to
2548    /// transfer without causing `BufferCollection` channel failure).
2549    ///
2550    /// All table fields are currently required.
2551    ///
2552    /// + request `server_end` This eventpair handle will be closed by the
2553    ///   sysmem server when buffers have been allocated initially and the
2554    ///   number of buffers is then less than or equal to `buffers_remaining`.
2555    /// + request `buffers_remaining` Wait for all but `buffers_remaining` (or
2556    ///   fewer) buffers to be fully deallocated. A number greater than zero can
2557    ///   be useful in situations where a known number of buffers are
2558    ///   intentionally not closed so that the data can continue to be used,
2559    ///   such as for keeping the last available video frame displayed in the UI
2560    ///   even if the video stream was using protected output buffers. It's
2561    ///   outside the scope of the `BufferCollection` interface (at least for
2562    ///   now) to determine how many buffers may be held without closing, but
2563    ///   it'll typically be in the range 0-2.
2564    pub fn r#attach_lifetime_tracking(
2565        &self,
2566        mut payload: BufferCollectionAttachLifetimeTrackingRequest,
2567    ) -> Result<(), fidl::Error> {
2568        BufferCollectionProxyInterface::r#attach_lifetime_tracking(self, payload)
2569    }
2570}
2571
2572impl BufferCollectionProxyInterface for BufferCollectionProxy {
2573    type SyncResponseFut =
2574        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2575    fn r#sync(&self) -> Self::SyncResponseFut {
2576        fn _decode(
2577            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2578        ) -> Result<(), fidl::Error> {
2579            let _response = fidl::client::decode_transaction_body::<
2580                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2581                fdomain_client::fidl::FDomainResourceDialect,
2582                0x11ac2555cf575b54,
2583            >(_buf?)?
2584            .into_result_fdomain::<BufferCollectionMarker>("sync")?;
2585            Ok(_response)
2586        }
2587        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2588            (),
2589            0x11ac2555cf575b54,
2590            fidl::encoding::DynamicFlags::FLEXIBLE,
2591            _decode,
2592        )
2593    }
2594
2595    fn r#release(&self) -> Result<(), fidl::Error> {
2596        self.client.send::<fidl::encoding::EmptyPayload>(
2597            (),
2598            0x6a5cae7d6d6e04c6,
2599            fidl::encoding::DynamicFlags::FLEXIBLE,
2600        )
2601    }
2602
2603    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
2604        self.client.send::<NodeSetNameRequest>(
2605            payload,
2606            0xb41f1624f48c1e9,
2607            fidl::encoding::DynamicFlags::FLEXIBLE,
2608        )
2609    }
2610
2611    fn r#set_debug_client_info(
2612        &self,
2613        mut payload: &NodeSetDebugClientInfoRequest,
2614    ) -> Result<(), fidl::Error> {
2615        self.client.send::<NodeSetDebugClientInfoRequest>(
2616            payload,
2617            0x5cde8914608d99b1,
2618            fidl::encoding::DynamicFlags::FLEXIBLE,
2619        )
2620    }
2621
2622    fn r#set_debug_timeout_log_deadline(
2623        &self,
2624        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
2625    ) -> Result<(), fidl::Error> {
2626        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
2627            payload,
2628            0x716b0af13d5c0806,
2629            fidl::encoding::DynamicFlags::FLEXIBLE,
2630        )
2631    }
2632
2633    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2634        self.client.send::<fidl::encoding::EmptyPayload>(
2635            (),
2636            0x5209c77415b4dfad,
2637            fidl::encoding::DynamicFlags::FLEXIBLE,
2638        )
2639    }
2640
2641    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
2642        NodeGetNodeRefResponse,
2643        fdomain_client::fidl::FDomainResourceDialect,
2644    >;
2645    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
2646        fn _decode(
2647            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2648        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
2649            let _response = fidl::client::decode_transaction_body::<
2650                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
2651                fdomain_client::fidl::FDomainResourceDialect,
2652                0x5b3d0e51614df053,
2653            >(_buf?)?
2654            .into_result_fdomain::<BufferCollectionMarker>("get_node_ref")?;
2655            Ok(_response)
2656        }
2657        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
2658            (),
2659            0x5b3d0e51614df053,
2660            fidl::encoding::DynamicFlags::FLEXIBLE,
2661            _decode,
2662        )
2663    }
2664
2665    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
2666        NodeIsAlternateForResult,
2667        fdomain_client::fidl::FDomainResourceDialect,
2668    >;
2669    fn r#is_alternate_for(
2670        &self,
2671        mut payload: NodeIsAlternateForRequest,
2672    ) -> Self::IsAlternateForResponseFut {
2673        fn _decode(
2674            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2675        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
2676            let _response = fidl::client::decode_transaction_body::<
2677                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
2678                fdomain_client::fidl::FDomainResourceDialect,
2679                0x3a58e00157e0825,
2680            >(_buf?)?
2681            .into_result_fdomain::<BufferCollectionMarker>("is_alternate_for")?;
2682            Ok(_response.map(|x| x))
2683        }
2684        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
2685            &mut payload,
2686            0x3a58e00157e0825,
2687            fidl::encoding::DynamicFlags::FLEXIBLE,
2688            _decode,
2689        )
2690    }
2691
2692    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
2693        NodeGetBufferCollectionIdResponse,
2694        fdomain_client::fidl::FDomainResourceDialect,
2695    >;
2696    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
2697        fn _decode(
2698            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2699        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
2700            let _response = fidl::client::decode_transaction_body::<
2701                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
2702                fdomain_client::fidl::FDomainResourceDialect,
2703                0x77d19a494b78ba8c,
2704            >(_buf?)?
2705            .into_result_fdomain::<BufferCollectionMarker>("get_buffer_collection_id")?;
2706            Ok(_response)
2707        }
2708        self.client.send_query_and_decode::<
2709            fidl::encoding::EmptyPayload,
2710            NodeGetBufferCollectionIdResponse,
2711        >(
2712            (),
2713            0x77d19a494b78ba8c,
2714            fidl::encoding::DynamicFlags::FLEXIBLE,
2715            _decode,
2716        )
2717    }
2718
2719    fn r#set_weak(&self) -> Result<(), fidl::Error> {
2720        self.client.send::<fidl::encoding::EmptyPayload>(
2721            (),
2722            0x22dd3ea514eeffe1,
2723            fidl::encoding::DynamicFlags::FLEXIBLE,
2724        )
2725    }
2726
2727    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
2728        self.client.send::<NodeSetWeakOkRequest>(
2729            &mut payload,
2730            0x38a44fc4d7724be9,
2731            fidl::encoding::DynamicFlags::FLEXIBLE,
2732        )
2733    }
2734
2735    fn r#attach_node_tracking(
2736        &self,
2737        mut payload: NodeAttachNodeTrackingRequest,
2738    ) -> Result<(), fidl::Error> {
2739        self.client.send::<NodeAttachNodeTrackingRequest>(
2740            &mut payload,
2741            0x3f22f2a293d3cdac,
2742            fidl::encoding::DynamicFlags::FLEXIBLE,
2743        )
2744    }
2745
2746    fn r#set_constraints(
2747        &self,
2748        mut payload: BufferCollectionSetConstraintsRequest,
2749    ) -> Result<(), fidl::Error> {
2750        self.client.send::<BufferCollectionSetConstraintsRequest>(
2751            &mut payload,
2752            0x1fde0f19d650197b,
2753            fidl::encoding::DynamicFlags::FLEXIBLE,
2754        )
2755    }
2756
2757    type WaitForAllBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2758        BufferCollectionWaitForAllBuffersAllocatedResult,
2759        fdomain_client::fidl::FDomainResourceDialect,
2760    >;
2761    fn r#wait_for_all_buffers_allocated(&self) -> Self::WaitForAllBuffersAllocatedResponseFut {
2762        fn _decode(
2763            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2764        ) -> Result<BufferCollectionWaitForAllBuffersAllocatedResult, fidl::Error> {
2765            let _response = fidl::client::decode_transaction_body::<
2766                fidl::encoding::FlexibleResultType<
2767                    BufferCollectionWaitForAllBuffersAllocatedResponse,
2768                    Error,
2769                >,
2770                fdomain_client::fidl::FDomainResourceDialect,
2771                0x62300344b61404e,
2772            >(_buf?)?
2773            .into_result_fdomain::<BufferCollectionMarker>("wait_for_all_buffers_allocated")?;
2774            Ok(_response.map(|x| x))
2775        }
2776        self.client.send_query_and_decode::<
2777            fidl::encoding::EmptyPayload,
2778            BufferCollectionWaitForAllBuffersAllocatedResult,
2779        >(
2780            (),
2781            0x62300344b61404e,
2782            fidl::encoding::DynamicFlags::FLEXIBLE,
2783            _decode,
2784        )
2785    }
2786
2787    type CheckAllBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2788        BufferCollectionCheckAllBuffersAllocatedResult,
2789        fdomain_client::fidl::FDomainResourceDialect,
2790    >;
2791    fn r#check_all_buffers_allocated(&self) -> Self::CheckAllBuffersAllocatedResponseFut {
2792        fn _decode(
2793            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2794        ) -> Result<BufferCollectionCheckAllBuffersAllocatedResult, fidl::Error> {
2795            let _response = fidl::client::decode_transaction_body::<
2796                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2797                fdomain_client::fidl::FDomainResourceDialect,
2798                0x35a5fe77ce939c10,
2799            >(_buf?)?
2800            .into_result_fdomain::<BufferCollectionMarker>("check_all_buffers_allocated")?;
2801            Ok(_response.map(|x| x))
2802        }
2803        self.client.send_query_and_decode::<
2804            fidl::encoding::EmptyPayload,
2805            BufferCollectionCheckAllBuffersAllocatedResult,
2806        >(
2807            (),
2808            0x35a5fe77ce939c10,
2809            fidl::encoding::DynamicFlags::FLEXIBLE,
2810            _decode,
2811        )
2812    }
2813
2814    fn r#attach_token(
2815        &self,
2816        mut payload: BufferCollectionAttachTokenRequest,
2817    ) -> Result<(), fidl::Error> {
2818        self.client.send::<BufferCollectionAttachTokenRequest>(
2819            &mut payload,
2820            0x46ac7d0008492982,
2821            fidl::encoding::DynamicFlags::FLEXIBLE,
2822        )
2823    }
2824
2825    fn r#attach_lifetime_tracking(
2826        &self,
2827        mut payload: BufferCollectionAttachLifetimeTrackingRequest,
2828    ) -> Result<(), fidl::Error> {
2829        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2830            &mut payload,
2831            0x3ecb510113116dcf,
2832            fidl::encoding::DynamicFlags::FLEXIBLE,
2833        )
2834    }
2835}
2836
2837pub struct BufferCollectionEventStream {
2838    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2839}
2840
2841impl std::marker::Unpin for BufferCollectionEventStream {}
2842
2843impl futures::stream::FusedStream for BufferCollectionEventStream {
2844    fn is_terminated(&self) -> bool {
2845        self.event_receiver.is_terminated()
2846    }
2847}
2848
2849impl futures::Stream for BufferCollectionEventStream {
2850    type Item = Result<BufferCollectionEvent, fidl::Error>;
2851
2852    fn poll_next(
2853        mut self: std::pin::Pin<&mut Self>,
2854        cx: &mut std::task::Context<'_>,
2855    ) -> std::task::Poll<Option<Self::Item>> {
2856        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2857            &mut self.event_receiver,
2858            cx
2859        )?) {
2860            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
2861            None => std::task::Poll::Ready(None),
2862        }
2863    }
2864}
2865
2866#[derive(Debug)]
2867pub enum BufferCollectionEvent {
2868    #[non_exhaustive]
2869    _UnknownEvent {
2870        /// Ordinal of the event that was sent.
2871        ordinal: u64,
2872    },
2873}
2874
2875impl BufferCollectionEvent {
2876    /// Decodes a message buffer as a [`BufferCollectionEvent`].
2877    fn decode(
2878        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2879    ) -> Result<BufferCollectionEvent, fidl::Error> {
2880        let (bytes, _handles) = buf.split_mut();
2881        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2882        debug_assert_eq!(tx_header.tx_id, 0);
2883        match tx_header.ordinal {
2884            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2885                Ok(BufferCollectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2886            }
2887            _ => Err(fidl::Error::UnknownOrdinal {
2888                ordinal: tx_header.ordinal,
2889                protocol_name:
2890                    <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2891            }),
2892        }
2893    }
2894}
2895
2896/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollection.
2897pub struct BufferCollectionRequestStream {
2898    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2899    is_terminated: bool,
2900}
2901
2902impl std::marker::Unpin for BufferCollectionRequestStream {}
2903
2904impl futures::stream::FusedStream for BufferCollectionRequestStream {
2905    fn is_terminated(&self) -> bool {
2906        self.is_terminated
2907    }
2908}
2909
2910impl fdomain_client::fidl::RequestStream for BufferCollectionRequestStream {
2911    type Protocol = BufferCollectionMarker;
2912    type ControlHandle = BufferCollectionControlHandle;
2913
2914    fn from_channel(channel: fdomain_client::Channel) -> Self {
2915        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2916    }
2917
2918    fn control_handle(&self) -> Self::ControlHandle {
2919        BufferCollectionControlHandle { inner: self.inner.clone() }
2920    }
2921
2922    fn into_inner(
2923        self,
2924    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2925    {
2926        (self.inner, self.is_terminated)
2927    }
2928
2929    fn from_inner(
2930        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2931        is_terminated: bool,
2932    ) -> Self {
2933        Self { inner, is_terminated }
2934    }
2935}
2936
2937impl futures::Stream for BufferCollectionRequestStream {
2938    type Item = Result<BufferCollectionRequest, fidl::Error>;
2939
2940    fn poll_next(
2941        mut self: std::pin::Pin<&mut Self>,
2942        cx: &mut std::task::Context<'_>,
2943    ) -> std::task::Poll<Option<Self::Item>> {
2944        let this = &mut *self;
2945        if this.inner.check_shutdown(cx) {
2946            this.is_terminated = true;
2947            return std::task::Poll::Ready(None);
2948        }
2949        if this.is_terminated {
2950            panic!("polled BufferCollectionRequestStream after completion");
2951        }
2952        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2953            |bytes, handles| {
2954                match this.inner.channel().read_etc(cx, bytes, handles) {
2955                    std::task::Poll::Ready(Ok(())) => {}
2956                    std::task::Poll::Pending => return std::task::Poll::Pending,
2957                    std::task::Poll::Ready(Err(None)) => {
2958                        this.is_terminated = true;
2959                        return std::task::Poll::Ready(None);
2960                    }
2961                    std::task::Poll::Ready(Err(Some(e))) => {
2962                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2963                            e.into(),
2964                        ))));
2965                    }
2966                }
2967
2968                // A message has been received from the channel
2969                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2970
2971                std::task::Poll::Ready(Some(match header.ordinal {
2972                0x11ac2555cf575b54 => {
2973                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2974                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2975                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2976                    let control_handle = BufferCollectionControlHandle {
2977                        inner: this.inner.clone(),
2978                    };
2979                    Ok(BufferCollectionRequest::Sync {
2980                        responder: BufferCollectionSyncResponder {
2981                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2982                            tx_id: header.tx_id,
2983                        },
2984                    })
2985                }
2986                0x6a5cae7d6d6e04c6 => {
2987                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2988                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2989                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2990                    let control_handle = BufferCollectionControlHandle {
2991                        inner: this.inner.clone(),
2992                    };
2993                    Ok(BufferCollectionRequest::Release {
2994                        control_handle,
2995                    })
2996                }
2997                0xb41f1624f48c1e9 => {
2998                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2999                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
3000                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
3001                    let control_handle = BufferCollectionControlHandle {
3002                        inner: this.inner.clone(),
3003                    };
3004                    Ok(BufferCollectionRequest::SetName {payload: req,
3005                        control_handle,
3006                    })
3007                }
3008                0x5cde8914608d99b1 => {
3009                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3010                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
3011                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
3012                    let control_handle = BufferCollectionControlHandle {
3013                        inner: this.inner.clone(),
3014                    };
3015                    Ok(BufferCollectionRequest::SetDebugClientInfo {payload: req,
3016                        control_handle,
3017                    })
3018                }
3019                0x716b0af13d5c0806 => {
3020                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3021                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
3022                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
3023                    let control_handle = BufferCollectionControlHandle {
3024                        inner: this.inner.clone(),
3025                    };
3026                    Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {payload: req,
3027                        control_handle,
3028                    })
3029                }
3030                0x5209c77415b4dfad => {
3031                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3032                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3033                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3034                    let control_handle = BufferCollectionControlHandle {
3035                        inner: this.inner.clone(),
3036                    };
3037                    Ok(BufferCollectionRequest::SetVerboseLogging {
3038                        control_handle,
3039                    })
3040                }
3041                0x5b3d0e51614df053 => {
3042                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3043                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3044                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3045                    let control_handle = BufferCollectionControlHandle {
3046                        inner: this.inner.clone(),
3047                    };
3048                    Ok(BufferCollectionRequest::GetNodeRef {
3049                        responder: BufferCollectionGetNodeRefResponder {
3050                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3051                            tx_id: header.tx_id,
3052                        },
3053                    })
3054                }
3055                0x3a58e00157e0825 => {
3056                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3057                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
3058                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
3059                    let control_handle = BufferCollectionControlHandle {
3060                        inner: this.inner.clone(),
3061                    };
3062                    Ok(BufferCollectionRequest::IsAlternateFor {payload: req,
3063                        responder: BufferCollectionIsAlternateForResponder {
3064                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3065                            tx_id: header.tx_id,
3066                        },
3067                    })
3068                }
3069                0x77d19a494b78ba8c => {
3070                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3071                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3072                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3073                    let control_handle = BufferCollectionControlHandle {
3074                        inner: this.inner.clone(),
3075                    };
3076                    Ok(BufferCollectionRequest::GetBufferCollectionId {
3077                        responder: BufferCollectionGetBufferCollectionIdResponder {
3078                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3079                            tx_id: header.tx_id,
3080                        },
3081                    })
3082                }
3083                0x22dd3ea514eeffe1 => {
3084                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3085                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3086                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3087                    let control_handle = BufferCollectionControlHandle {
3088                        inner: this.inner.clone(),
3089                    };
3090                    Ok(BufferCollectionRequest::SetWeak {
3091                        control_handle,
3092                    })
3093                }
3094                0x38a44fc4d7724be9 => {
3095                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3096                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
3097                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
3098                    let control_handle = BufferCollectionControlHandle {
3099                        inner: this.inner.clone(),
3100                    };
3101                    Ok(BufferCollectionRequest::SetWeakOk {payload: req,
3102                        control_handle,
3103                    })
3104                }
3105                0x3f22f2a293d3cdac => {
3106                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3107                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
3108                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3109                    let control_handle = BufferCollectionControlHandle {
3110                        inner: this.inner.clone(),
3111                    };
3112                    Ok(BufferCollectionRequest::AttachNodeTracking {payload: req,
3113                        control_handle,
3114                    })
3115                }
3116                0x1fde0f19d650197b => {
3117                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3118                    let mut req = fidl::new_empty!(BufferCollectionSetConstraintsRequest, fdomain_client::fidl::FDomainResourceDialect);
3119                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
3120                    let control_handle = BufferCollectionControlHandle {
3121                        inner: this.inner.clone(),
3122                    };
3123                    Ok(BufferCollectionRequest::SetConstraints {payload: req,
3124                        control_handle,
3125                    })
3126                }
3127                0x62300344b61404e => {
3128                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3129                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3130                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3131                    let control_handle = BufferCollectionControlHandle {
3132                        inner: this.inner.clone(),
3133                    };
3134                    Ok(BufferCollectionRequest::WaitForAllBuffersAllocated {
3135                        responder: BufferCollectionWaitForAllBuffersAllocatedResponder {
3136                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3137                            tx_id: header.tx_id,
3138                        },
3139                    })
3140                }
3141                0x35a5fe77ce939c10 => {
3142                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3143                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3144                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3145                    let control_handle = BufferCollectionControlHandle {
3146                        inner: this.inner.clone(),
3147                    };
3148                    Ok(BufferCollectionRequest::CheckAllBuffersAllocated {
3149                        responder: BufferCollectionCheckAllBuffersAllocatedResponder {
3150                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3151                            tx_id: header.tx_id,
3152                        },
3153                    })
3154                }
3155                0x46ac7d0008492982 => {
3156                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3157                    let mut req = fidl::new_empty!(BufferCollectionAttachTokenRequest, fdomain_client::fidl::FDomainResourceDialect);
3158                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
3159                    let control_handle = BufferCollectionControlHandle {
3160                        inner: this.inner.clone(),
3161                    };
3162                    Ok(BufferCollectionRequest::AttachToken {payload: req,
3163                        control_handle,
3164                    })
3165                }
3166                0x3ecb510113116dcf => {
3167                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3168                    let mut req = fidl::new_empty!(BufferCollectionAttachLifetimeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
3169                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3170                    let control_handle = BufferCollectionControlHandle {
3171                        inner: this.inner.clone(),
3172                    };
3173                    Ok(BufferCollectionRequest::AttachLifetimeTracking {payload: req,
3174                        control_handle,
3175                    })
3176                }
3177                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3178                    Ok(BufferCollectionRequest::_UnknownMethod {
3179                        ordinal: header.ordinal,
3180                        control_handle: BufferCollectionControlHandle { inner: this.inner.clone() },
3181                        method_type: fidl::MethodType::OneWay,
3182                    })
3183                }
3184                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3185                    this.inner.send_framework_err(
3186                        fidl::encoding::FrameworkErr::UnknownMethod,
3187                        header.tx_id,
3188                        header.ordinal,
3189                        header.dynamic_flags(),
3190                        (bytes, handles),
3191                    )?;
3192                    Ok(BufferCollectionRequest::_UnknownMethod {
3193                        ordinal: header.ordinal,
3194                        control_handle: BufferCollectionControlHandle { inner: this.inner.clone() },
3195                        method_type: fidl::MethodType::TwoWay,
3196                    })
3197                }
3198                _ => Err(fidl::Error::UnknownOrdinal {
3199                    ordinal: header.ordinal,
3200                    protocol_name: <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3201                }),
3202            }))
3203            },
3204        )
3205    }
3206}
3207
3208/// [`fuchsia.sysmem2/BufferCollection`] is a connection directly from a
3209/// participant to sysmem re. a buffer collection; often the buffer collection
3210/// is shared with other participants which have their own `BufferCollection`
3211/// client end(s) associated with the same buffer collection.  In other words,
3212/// an instance of the `BufferCollection` interface is a view of a buffer
3213/// collection, not the buffer collection itself.
3214///
3215/// The `BufferCollection` connection exists to facilitate async indication of
3216/// when the buffer collection has been populated with buffers.
3217///
3218/// Also, the channel's closure by the sysmem server is an indication to the
3219/// client that the client should close all VMO handles that were obtained from
3220/// the `BufferCollection` ASAP.
3221///
3222/// Some buffer collections can use enough memory that it can be worth avoiding
3223/// allocation overlap (in time) using
3224/// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] so that the
3225/// initiator can tell when enough buffers of the buffer collection have been
3226/// fully deallocated prior to the initiator allocating a new buffer collection.
3227///
3228/// Epitaphs are not used in this protocol.
3229#[derive(Debug)]
3230pub enum BufferCollectionRequest {
3231    /// Ensure that previous messages have been received server side. This is
3232    /// particularly useful after previous messages that created new tokens,
3233    /// because a token must be known to the sysmem server before sending the
3234    /// token to another participant.
3235    ///
3236    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
3237    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
3238    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
3239    /// to mitigate the possibility of a hostile/fake
3240    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
3241    /// Another way is to pass the token to
3242    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
3243    /// the token as part of exchanging it for a
3244    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
3245    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
3246    /// of stalling.
3247    ///
3248    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
3249    /// and then starting and completing a `Sync`, it's then safe to send the
3250    /// `BufferCollectionToken` client ends to other participants knowing the
3251    /// server will recognize the tokens when they're sent by the other
3252    /// participants to sysmem in a
3253    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
3254    /// efficient way to create tokens while avoiding unnecessary round trips.
3255    ///
3256    /// Other options include waiting for each
3257    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
3258    /// individually (using separate call to `Sync` after each), or calling
3259    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
3260    /// converted to a `BufferCollection` via
3261    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
3262    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
3263    /// the sync step and can create multiple tokens at once.
3264    Sync { responder: BufferCollectionSyncResponder },
3265    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
3266    ///
3267    /// Normally a participant will convert a `BufferCollectionToken` into a
3268    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
3269    /// `Release` via the token (and then close the channel immediately or
3270    /// shortly later in response to server closing the server end), which
3271    /// avoids causing buffer collection failure. Without a prior `Release`,
3272    /// closing the `BufferCollectionToken` client end will cause buffer
3273    /// collection failure.
3274    ///
3275    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
3276    ///
3277    /// By default the server handles unexpected closure of a
3278    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
3279    /// first) by failing the buffer collection. Partly this is to expedite
3280    /// closing VMO handles to reclaim memory when any participant fails. If a
3281    /// participant would like to cleanly close a `BufferCollection` without
3282    /// causing buffer collection failure, the participant can send `Release`
3283    /// before closing the `BufferCollection` client end. The `Release` can
3284    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
3285    /// buffer collection won't require constraints from this node in order to
3286    /// allocate. If after `SetConstraints`, the constraints are retained and
3287    /// aggregated, despite the lack of `BufferCollection` connection at the
3288    /// time of constraints aggregation.
3289    ///
3290    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
3291    ///
3292    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
3293    /// end (without `Release` first) will trigger failure of the buffer
3294    /// collection. To close a `BufferCollectionTokenGroup` channel without
3295    /// failing the buffer collection, ensure that AllChildrenPresent() has been
3296    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
3297    /// client end.
3298    ///
3299    /// If `Release` occurs before
3300    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
3301    /// buffer collection will fail (triggered by reception of `Release` without
3302    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
3303    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
3304    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
3305    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
3306    /// close requires `AllChildrenPresent` (if not already sent), then
3307    /// `Release`, then close client end.
3308    ///
3309    /// If `Release` occurs after `AllChildrenPresent`, the children and all
3310    /// their constraints remain intact (just as they would if the
3311    /// `BufferCollectionTokenGroup` channel had remained open), and the client
3312    /// end close doesn't trigger buffer collection failure.
3313    ///
3314    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
3315    ///
3316    /// For brevity, the per-channel-protocol paragraphs above ignore the
3317    /// separate failure domain created by
3318    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
3319    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
3320    /// unexpectedly closes (without `Release` first) and that client end is
3321    /// under a failure domain, instead of failing the whole buffer collection,
3322    /// the failure domain is failed, but the buffer collection itself is
3323    /// isolated from failure of the failure domain. Such failure domains can be
3324    /// nested, in which case only the inner-most failure domain in which the
3325    /// `Node` resides fails.
3326    Release { control_handle: BufferCollectionControlHandle },
3327    /// Set a name for VMOs in this buffer collection.
3328    ///
3329    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
3330    /// will be truncated to fit. The name of the vmo will be suffixed with the
3331    /// buffer index within the collection (if the suffix fits within
3332    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
3333    /// listed in the inspect data.
3334    ///
3335    /// The name only affects VMOs allocated after the name is set; this call
3336    /// does not rename existing VMOs. If multiple clients set different names
3337    /// then the larger priority value will win. Setting a new name with the
3338    /// same priority as a prior name doesn't change the name.
3339    ///
3340    /// All table fields are currently required.
3341    ///
3342    /// + request `priority` The name is only set if this is the first `SetName`
3343    ///   or if `priority` is greater than any previous `priority` value in
3344    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
3345    /// + request `name` The name for VMOs created under this buffer collection.
3346    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionControlHandle },
3347    /// Set information about the current client that can be used by sysmem to
3348    /// help diagnose leaking memory and allocation stalls waiting for a
3349    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
3350    ///
3351    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
3352    /// `Node`(s) derived from this `Node`, unless overriden by
3353    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
3354    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
3355    ///
3356    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
3357    /// `Allocator` is the most efficient way to ensure that all
3358    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
3359    /// set, and is also more efficient than separately sending the same debug
3360    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
3361    /// created [`fuchsia.sysmem2/Node`].
3362    ///
3363    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
3364    /// indicate which client is closing their channel first, leading to subtree
3365    /// failure (which can be normal if the purpose of the subtree is over, but
3366    /// if happening earlier than expected, the client-channel-specific name can
3367    /// help diagnose where the failure is first coming from, from sysmem's
3368    /// point of view).
3369    ///
3370    /// All table fields are currently required.
3371    ///
3372    /// + request `name` This can be an arbitrary string, but the current
3373    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
3374    /// + request `id` This can be an arbitrary id, but the current process ID
3375    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
3376    SetDebugClientInfo {
3377        payload: NodeSetDebugClientInfoRequest,
3378        control_handle: BufferCollectionControlHandle,
3379    },
3380    /// Sysmem logs a warning if sysmem hasn't seen
3381    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
3382    /// within 5 seconds after creation of a new collection.
3383    ///
3384    /// Clients can call this method to change when the log is printed. If
3385    /// multiple client set the deadline, it's unspecified which deadline will
3386    /// take effect.
3387    ///
3388    /// In most cases the default works well.
3389    ///
3390    /// All table fields are currently required.
3391    ///
3392    /// + request `deadline` The time at which sysmem will start trying to log
3393    ///   the warning, unless all constraints are with sysmem by then.
3394    SetDebugTimeoutLogDeadline {
3395        payload: NodeSetDebugTimeoutLogDeadlineRequest,
3396        control_handle: BufferCollectionControlHandle,
3397    },
3398    /// This enables verbose logging for the buffer collection.
3399    ///
3400    /// Verbose logging includes constraints set via
3401    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
3402    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
3403    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
3404    /// the tree of `Node`(s).
3405    ///
3406    /// Normally sysmem prints only a single line complaint when aggregation
3407    /// fails, with just the specific detailed reason that aggregation failed,
3408    /// with little surrounding context.  While this is often enough to diagnose
3409    /// a problem if only a small change was made and everything was working
3410    /// before the small change, it's often not particularly helpful for getting
3411    /// a new buffer collection to work for the first time.  Especially with
3412    /// more complex trees of nodes, involving things like
3413    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
3414    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
3415    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
3416    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
3417    /// looks like and why it's failing a logical allocation, or why a tree or
3418    /// subtree is failing sooner than expected.
3419    ///
3420    /// The intent of the extra logging is to be acceptable from a performance
3421    /// point of view, under the assumption that verbose logging is only enabled
3422    /// on a low number of buffer collections. If we're not tracking down a bug,
3423    /// we shouldn't send this message.
3424    SetVerboseLogging { control_handle: BufferCollectionControlHandle },
3425    /// This gets a handle that can be used as a parameter to
3426    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
3427    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
3428    /// client obtained this handle from this `Node`.
3429    ///
3430    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
3431    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
3432    /// despite the two calls typically being on different channels.
3433    ///
3434    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
3435    ///
3436    /// All table fields are currently required.
3437    ///
3438    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
3439    ///   different `Node` channel, to prove that the client obtained the handle
3440    ///   from this `Node`.
3441    GetNodeRef { responder: BufferCollectionGetNodeRefResponder },
3442    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
3443    /// rooted at a different child token of a common parent
3444    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
3445    /// passed-in `node_ref`.
3446    ///
3447    /// This call is for assisting with admission control de-duplication, and
3448    /// with debugging.
3449    ///
3450    /// The `node_ref` must be obtained using
3451    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
3452    ///
3453    /// The `node_ref` can be a duplicated handle; it's not necessary to call
3454    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
3455    ///
3456    /// If a calling token may not actually be a valid token at all due to a
3457    /// potentially hostile/untrusted provider of the token, call
3458    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
3459    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
3460    /// never responds due to a calling token not being a real token (not really
3461    /// talking to sysmem).  Another option is to call
3462    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
3463    /// which also validates the token along with converting it to a
3464    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
3465    ///
3466    /// All table fields are currently required.
3467    ///
3468    /// - response `is_alternate`
3469    ///   - true: The first parent node in common between the calling node and
3470    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
3471    ///     that the calling `Node` and the `node_ref` `Node` will not have both
3472    ///     their constraints apply - rather sysmem will choose one or the other
3473    ///     of the constraints - never both.  This is because only one child of
3474    ///     a `BufferCollectionTokenGroup` is selected during logical
3475    ///     allocation, with only that one child's subtree contributing to
3476    ///     constraints aggregation.
3477    ///   - false: The first parent node in common between the calling `Node`
3478    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
3479    ///     Currently, this means the first parent node in common is a
3480    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
3481    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
3482    ///     `Node` may have both their constraints apply during constraints
3483    ///     aggregation of the logical allocation, if both `Node`(s) are
3484    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
3485    ///     this case, there is no `BufferCollectionTokenGroup` that will
3486    ///     directly prevent the two `Node`(s) from both being selected and
3487    ///     their constraints both aggregated, but even when false, one or both
3488    ///     `Node`(s) may still be eliminated from consideration if one or both
3489    ///     `Node`(s) has a direct or indirect parent
3490    ///     `BufferCollectionTokenGroup` which selects a child subtree other
3491    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
3492    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
3493    ///   associated with the same buffer collection as the calling `Node`.
3494    ///   Another reason for this error is if the `node_ref` is an
3495    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
3496    ///   a real `node_ref` obtained from `GetNodeRef`.
3497    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
3498    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
3499    ///   the needed rights expected on a real `node_ref`.
3500    /// * No other failing status codes are returned by this call.  However,
3501    ///   sysmem may add additional codes in future, so the client should have
3502    ///   sensible default handling for any failing status code.
3503    IsAlternateFor {
3504        payload: NodeIsAlternateForRequest,
3505        responder: BufferCollectionIsAlternateForResponder,
3506    },
3507    /// Get the buffer collection ID. This ID is also available from
3508    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
3509    /// within the collection).
3510    ///
3511    /// This call is mainly useful in situations where we can't convey a
3512    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
3513    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
3514    /// handle, which can be joined back up with a `BufferCollection` client end
3515    /// that was created via a different path. Prefer to convey a
3516    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
3517    ///
3518    /// Trusting a `buffer_collection_id` value from a source other than sysmem
3519    /// is analogous to trusting a koid value from a source other than zircon.
3520    /// Both should be avoided unless really necessary, and both require
3521    /// caution. In some situations it may be reasonable to refer to a
3522    /// pre-established `BufferCollection` by `buffer_collection_id` via a
3523    /// protocol for efficiency reasons, but an incoming value purporting to be
3524    /// a `buffer_collection_id` is not sufficient alone to justify granting the
3525    /// sender of the `buffer_collection_id` any capability. The sender must
3526    /// first prove to a receiver that the sender has/had a VMO or has/had a
3527    /// `BufferCollectionToken` to the same collection by sending a handle that
3528    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
3529    /// `buffer_collection_id` value. The receiver should take care to avoid
3530    /// assuming that a sender had a `BufferCollectionToken` in cases where the
3531    /// sender has only proven that the sender had a VMO.
3532    ///
3533    /// - response `buffer_collection_id` This ID is unique per buffer
3534    ///   collection per boot. Each buffer is uniquely identified by the
3535    ///   `buffer_collection_id` and `buffer_index` together.
3536    GetBufferCollectionId { responder: BufferCollectionGetBufferCollectionIdResponder },
3537    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
3538    /// created after this message to weak, which means that a client's `Node`
3539    /// client end (or a child created after this message) is not alone
3540    /// sufficient to keep allocated VMOs alive.
3541    ///
3542    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
3543    /// `close_weak_asap`.
3544    ///
3545    /// This message is only permitted before the `Node` becomes ready for
3546    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
3547    ///   * `BufferCollectionToken`: any time
3548    ///   * `BufferCollection`: before `SetConstraints`
3549    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
3550    ///
3551    /// Currently, no conversion from strong `Node` to weak `Node` after ready
3552    /// for allocation is provided, but a client can simulate that by creating
3553    /// an additional `Node` before allocation and setting that additional
3554    /// `Node` to weak, and then potentially at some point later sending
3555    /// `Release` and closing the client end of the client's strong `Node`, but
3556    /// keeping the client's weak `Node`.
3557    ///
3558    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
3559    /// collection failure (all `Node` client end(s) will see
3560    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
3561    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
3562    /// this situation until all `Node`(s) are ready for allocation. For initial
3563    /// allocation to succeed, at least one strong `Node` is required to exist
3564    /// at allocation time, but after that client receives VMO handles, that
3565    /// client can `BufferCollection.Release` and close the client end without
3566    /// causing this type of failure.
3567    ///
3568    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
3569    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
3570    /// separately as appropriate.
3571    SetWeak { control_handle: BufferCollectionControlHandle },
3572    /// This indicates to sysmem that the client is prepared to pay attention to
3573    /// `close_weak_asap`.
3574    ///
3575    /// If sent, this message must be before
3576    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
3577    ///
3578    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
3579    /// send this message before `WaitForAllBuffersAllocated`, or a parent
3580    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
3581    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
3582    /// trigger buffer collection failure.
3583    ///
3584    /// This message is necessary because weak sysmem VMOs have not always been
3585    /// a thing, so older clients are not aware of the need to pay attention to
3586    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
3587    /// sysmem weak VMO handles asap. By having this message and requiring
3588    /// participants to indicate their acceptance of this aspect of the overall
3589    /// protocol, we avoid situations where an older client is delivered a weak
3590    /// VMO without any way for sysmem to get that VMO to close quickly later
3591    /// (and on a per-buffer basis).
3592    ///
3593    /// A participant that doesn't handle `close_weak_asap` and also doesn't
3594    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
3595    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
3596    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
3597    /// same participant has a child/delegate which does retrieve VMOs, that
3598    /// child/delegate will need to send `SetWeakOk` before
3599    /// `WaitForAllBuffersAllocated`.
3600    ///
3601    /// + request `for_child_nodes_also` If present and true, this means direct
3602    ///   child nodes of this node created after this message plus all
3603    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
3604    ///   those nodes. Any child node of this node that was created before this
3605    ///   message is not included. This setting is "sticky" in the sense that a
3606    ///   subsequent `SetWeakOk` without this bool set to true does not reset
3607    ///   the server-side bool. If this creates a problem for a participant, a
3608    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
3609    ///   tokens instead, as appropriate. A participant should only set
3610    ///   `for_child_nodes_also` true if the participant can really promise to
3611    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
3612    ///   weak VMO handles held by participants holding the corresponding child
3613    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
3614    ///   which are using sysmem(1) can be weak, despite the clients of those
3615    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
3616    ///   direct way to find out about `close_weak_asap`. This only applies to
3617    ///   descendents of this `Node` which are using sysmem(1), not to this
3618    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
3619    ///   token, which will fail allocation unless an ancestor of this `Node`
3620    ///   specified `for_child_nodes_also` true.
3621    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: BufferCollectionControlHandle },
3622    /// The server_end will be closed after this `Node` and any child nodes have
3623    /// have released their buffer counts, making those counts available for
3624    /// reservation by a different `Node` via
3625    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
3626    ///
3627    /// The `Node` buffer counts may not be released until the entire tree of
3628    /// `Node`(s) is closed or failed, because
3629    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
3630    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
3631    /// `Node` buffer counts remain reserved until the orphaned node is later
3632    /// cleaned up.
3633    ///
3634    /// If the `Node` exceeds a fairly large number of attached eventpair server
3635    /// ends, a log message will indicate this and the `Node` (and the
3636    /// appropriate) sub-tree will fail.
3637    ///
3638    /// The `server_end` will remain open when
3639    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
3640    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
3641    /// [`fuchsia.sysmem2/BufferCollection`].
3642    ///
3643    /// This message can also be used with a
3644    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
3645    AttachNodeTracking {
3646        payload: NodeAttachNodeTrackingRequest,
3647        control_handle: BufferCollectionControlHandle,
3648    },
3649    /// Provide [`fuchsia.sysmem2/BufferCollectionConstraints`] to the buffer
3650    /// collection.
3651    ///
3652    /// A participant may only call
3653    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] up to once per
3654    /// [`fuchsia.sysmem2/BufferCollection`].
3655    ///
3656    /// For buffer allocation to be attempted, all holders of a
3657    /// `BufferCollection` client end need to call `SetConstraints` before
3658    /// sysmem will attempt to allocate buffers.
3659    SetConstraints {
3660        payload: BufferCollectionSetConstraintsRequest,
3661        control_handle: BufferCollectionControlHandle,
3662    },
3663    /// Wait until all buffers are allocated.
3664    ///
3665    /// This FIDL call completes when buffers have been allocated, or completes
3666    /// with some failure detail if allocation has been attempted but failed.
3667    ///
3668    /// The following must occur before buffers will be allocated:
3669    ///   * All [`fuchsia.sysmem2/BufferCollectionToken`](s) of the buffer
3670    ///     collection must be turned in via `BindSharedCollection` to get a
3671    ///     [`fuchsia.sysmem2/BufferCollection`] (for brevity, this is assuming
3672    ///     [`fuchsia.sysmem2/BufferCollection.AttachToken`] isn't being used),
3673    ///     or have had [`fuchsia.sysmem2/BufferCollectionToken.Release`] sent
3674    ///     to them.
3675    ///   * All [`fuchsia.sysmem2/BufferCollection`](s) of the buffer collection
3676    ///     must have had [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
3677    ///     sent to them, or had [`fuchsia.sysmem2/BufferCollection.Release`]
3678    ///     sent to them.
3679    ///
3680    /// - result `buffer_collection_info` The VMO handles and other related
3681    ///   info.
3682    /// * error `[fuchsia.sysmem2/Error.NO_MEMORY]` The request is valid but
3683    ///   cannot be fulfilled due to resource exhaustion.
3684    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION`] The request is
3685    ///   malformed.
3686    /// * error `[fuchsia.sysmem2/Error.CONSTRAINTS_INTERSECTION_EMPTY`] The
3687    ///   request is valid but cannot be satisfied, perhaps due to hardware
3688    ///   limitations. This can happen if participants have incompatible
3689    ///   constraints (empty intersection, roughly speaking). See the log for
3690    ///   more info. In cases where a participant could potentially be treated
3691    ///   as optional, see [`BufferCollectionTokenGroup`]. When using
3692    ///   [`fuchsia.sysmem2/BufferCollection.AttachToken`], this will be the
3693    ///   error code if there aren't enough buffers in the pre-existing
3694    ///   collection to satisfy the constraints set on the attached token and
3695    ///   any sub-tree of tokens derived from the attached token.
3696    WaitForAllBuffersAllocated { responder: BufferCollectionWaitForAllBuffersAllocatedResponder },
3697    /// Checks whether all the buffers have been allocated, in a polling
3698    /// fashion.
3699    ///
3700    /// * If the buffer collection has been allocated, returns success.
3701    /// * If the buffer collection failed allocation, returns the same
3702    ///   [`fuchsia.sysmem2/Error`] as
3703    ///   [`fuchsia.sysmem2/BufferCollection/WaitForAllBuffersAllocated`] would
3704    ///   return.
3705    /// * error [`fuchsia.sysmem2/Error.PENDING`] The buffer collection hasn't
3706    ///   attempted allocation yet. This means that WaitForAllBuffersAllocated
3707    ///   would not respond quickly.
3708    CheckAllBuffersAllocated { responder: BufferCollectionCheckAllBuffersAllocatedResponder },
3709    /// Create a new token to add a new participant to an existing logical
3710    /// buffer collection, if the existing collection's buffer counts,
3711    /// constraints, and participants allow.
3712    ///
3713    /// This can be useful in replacing a failed participant, and/or in
3714    /// adding/re-adding a participant after buffers have already been
3715    /// allocated.
3716    ///
3717    /// When [`fuchsia.sysmem2/BufferCollection.AttachToken`] is used, the sub
3718    /// tree rooted at the attached [`fuchsia.sysmem2/BufferCollectionToken`]
3719    /// goes through the normal procedure of setting constraints or closing
3720    /// [`fuchsia.sysmem2/Node`](s), and then appearing to allocate buffers from
3721    /// clients' point of view, despite the possibility that all the buffers
3722    /// were actually allocated previously. This process is called "logical
3723    /// allocation". Most instances of "allocation" in docs for other messages
3724    /// can also be read as "allocation or logical allocation" while remaining
3725    /// valid, but we just say "allocation" in most places for brevity/clarity
3726    /// of explanation, with the details of "logical allocation" left for the
3727    /// docs here on `AttachToken`.
3728    ///
3729    /// Failure of an attached `Node` does not propagate to the parent of the
3730    /// attached `Node`. More generally, failure of a child `Node` is blocked
3731    /// from reaching its parent `Node` if the child is attached, or if the
3732    /// child is dispensable and the failure occurred after logical allocation
3733    /// (see [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`]).
3734    ///
3735    /// A participant may in some scenarios choose to initially use a
3736    /// dispensable token for a given instance of a delegate participant, and
3737    /// then later if the first instance of that delegate participant fails, a
3738    /// new second instance of that delegate participant my be given a token
3739    /// created with `AttachToken`.
3740    ///
3741    /// From the point of view of the [`fuchsia.sysmem2/BufferCollectionToken`]
3742    /// client end, the token acts like any other token. The client can
3743    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] the token as needed,
3744    /// and can send the token to a different process/participant. The
3745    /// `BufferCollectionToken` `Node` should be converted to a
3746    /// `BufferCollection` `Node` as normal by sending
3747    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or can be closed
3748    /// without causing subtree failure by sending
3749    /// [`fuchsia.sysmem2/BufferCollectionToken.Release`]. Assuming the former,
3750    /// the [`fuchsia.sysmem2/BufferCollection.SetConstraints`] message or
3751    /// [`fuchsia.sysmem2/BufferCollection.Release`] message should be sent to
3752    /// the `BufferCollection`.
3753    ///
3754    /// Within the subtree, a success result from
3755    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] means
3756    /// the subtree participants' constraints were satisfiable using the
3757    /// already-existing buffer collection, the already-established
3758    /// [`fuchsia.sysmem2/BufferCollectionInfo`] including image format
3759    /// constraints, and the already-existing other participants (already added
3760    /// via successful logical allocation) and their specified buffer counts in
3761    /// their constraints. A failure result means the new participants'
3762    /// constraints cannot be satisfied using the existing buffer collection and
3763    /// its already-added participants. Creating a new collection instead may
3764    /// allow all participants' constraints to be satisfied, assuming
3765    /// `SetDispensable` is used in place of `AttachToken`, or a normal token is
3766    /// used.
3767    ///
3768    /// A token created with `AttachToken` performs constraints aggregation with
3769    /// all constraints currently in effect on the buffer collection, plus the
3770    /// attached token under consideration plus child tokens under the attached
3771    /// token which are not themselves an attached token or under such a token.
3772    /// Further subtrees under this subtree are considered for logical
3773    /// allocation only after this subtree has completed logical allocation.
3774    ///
3775    /// Assignment of existing buffers to participants'
3776    /// [`fuchsia.sysmem2/BufferCollectionConstraints.min_buffer_count_for_camping`]
3777    /// etc is first-come first-served, but a child can't logically allocate
3778    /// before all its parents have sent `SetConstraints`.
3779    ///
3780    /// See also [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`], which
3781    /// in contrast to `AttachToken`, has the created token `Node` + child
3782    /// `Node`(s) (in the created subtree but not in any subtree under this
3783    /// subtree) participate in constraints aggregation along with its parent
3784    /// during the parent's allocation or logical allocation.
3785    ///
3786    /// Similar to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], the
3787    /// newly created token needs to be [`fuchsia.sysmem2/Node.Sync`]ed to
3788    /// sysmem before the new token can be passed to `BindSharedCollection`. The
3789    /// `Sync` of the new token can be accomplished with
3790    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after converting the created
3791    /// `BufferCollectionToken` to a `BufferCollection`. Alternately,
3792    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on the new token also
3793    /// works. Or using [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`]
3794    /// works. As usual, a `BufferCollectionToken.Sync` can be started after any
3795    /// `BufferCollectionToken.Duplicate` messages have been sent via the newly
3796    /// created token, to also sync those additional tokens to sysmem using a
3797    /// single round-trip.
3798    ///
3799    /// All table fields are currently required.
3800    ///
3801    /// + request `rights_attentuation_mask` This allows attenuating the VMO
3802    ///   rights of the subtree. These values for `rights_attenuation_mask`
3803    ///   result in no attenuation (note that 0 is not on this list):
3804    ///   + ZX_RIGHT_SAME_RIGHTS (preferred)
3805    ///   + 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3806    /// + request `token_request` The server end of the `BufferCollectionToken`
3807    ///   channel. The client retains the client end.
3808    AttachToken {
3809        payload: BufferCollectionAttachTokenRequest,
3810        control_handle: BufferCollectionControlHandle,
3811    },
3812    /// Set up an eventpair to be signalled (`ZX_EVENTPAIR_PEER_CLOSED`) when
3813    /// buffers have been allocated and only the specified number of buffers (or
3814    /// fewer) remain in the buffer collection.
3815    ///
3816    /// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] allows a
3817    /// client to wait until an old buffer collection is fully or mostly
3818    /// deallocated before attempting allocation of a new buffer collection. The
3819    /// eventpair is only signalled when the buffers of this collection have
3820    /// been fully deallocated (not just un-referenced by clients, but all the
3821    /// memory consumed by those buffers has been fully reclaimed/recycled), or
3822    /// when allocation or logical allocation fails for the tree or subtree
3823    /// including this [`fuchsia.sysmem2/BufferCollection`].
3824    ///
3825    /// The eventpair won't be signalled until allocation or logical allocation
3826    /// has completed; until then, the collection's current buffer count is
3827    /// ignored.
3828    ///
3829    /// If logical allocation fails for an attached subtree (using
3830    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]), the server end of the
3831    /// eventpair will close during that failure regardless of the number of
3832    /// buffers potenitally allocated in the overall buffer collection. This is
3833    /// for logical allocation consistency with normal allocation.
3834    ///
3835    /// The lifetime signalled by this event includes asynchronous cleanup of
3836    /// allocated buffers, and this asynchronous cleanup cannot occur until all
3837    /// holders of VMO handles to the buffers have closed those VMO handles.
3838    /// Therefore, clients should take care not to become blocked forever
3839    /// waiting for `ZX_EVENTPAIR_PEER_CLOSED` to be signalled if any of the
3840    /// participants using the logical buffer collection (including the waiter
3841    /// itself) are less trusted, less reliable, or potentially blocked by the
3842    /// wait itself. Waiting asynchronously is recommended. Setting a deadline
3843    /// for the client wait may be prudent, depending on details of how the
3844    /// collection and/or its VMOs are used or shared. Failure to allocate a
3845    /// new/replacement buffer collection is better than getting stuck forever.
3846    ///
3847    /// The sysmem server itself intentionally does not perform any waiting on
3848    /// already-failed collections' VMOs to finish cleaning up before attempting
3849    /// a new allocation, and the sysmem server intentionally doesn't retry
3850    /// allocation if a new allocation fails due to out of memory, even if that
3851    /// failure is potentially due to continued existence of an old collection's
3852    /// VMOs. This `AttachLifetimeTracking` message is how an initiator can
3853    /// mitigate too much overlap of old VMO lifetimes with new VMO lifetimes,
3854    /// as long as the waiting client is careful to not create a deadlock.
3855    ///
3856    /// Continued existence of old collections that are still cleaning up is not
3857    /// the only reason that a new allocation may fail due to insufficient
3858    /// memory, even if the new allocation is allocating physically contiguous
3859    /// buffers. Overall system memory pressure can also be the cause of failure
3860    /// to allocate a new collection. See also
3861    /// [`fuchsia.memorypressure/Provider`].
3862    ///
3863    /// `AttachLifetimeTracking` is meant to be compatible with other protocols
3864    /// with a similar `AttachLifetimeTracking` message; duplicates of the same
3865    /// `eventpair` handle (server end) can be sent via more than one
3866    /// `AttachLifetimeTracking` message to different protocols, and the
3867    /// `ZX_EVENTPAIR_PEER_CLOSED` will be signalled for the client end when all
3868    /// the conditions are met (all holders of duplicates have closed their
3869    /// server end handle(s)). Also, thanks to how eventpair endponts work, the
3870    /// client end can (also) be duplicated without preventing the
3871    /// `ZX_EVENTPAIR_PEER_CLOSED` signal.
3872    ///
3873    /// The server intentionally doesn't "trust" any signals set on the
3874    /// `server_end`. This mechanism intentionally uses only
3875    /// `ZX_EVENTPAIR_PEER_CLOSED` set on the client end, which can't be set
3876    /// "early", and is only set when all handles to the server end eventpair
3877    /// are closed. No meaning is associated with any of the other signals, and
3878    /// clients should ignore any other signal bits on either end of the
3879    /// `eventpair`.
3880    ///
3881    /// The `server_end` may lack `ZX_RIGHT_SIGNAL` or `ZX_RIGHT_SIGNAL_PEER`,
3882    /// but must have `ZX_RIGHT_DUPLICATE` (and must have `ZX_RIGHT_TRANSFER` to
3883    /// transfer without causing `BufferCollection` channel failure).
3884    ///
3885    /// All table fields are currently required.
3886    ///
3887    /// + request `server_end` This eventpair handle will be closed by the
3888    ///   sysmem server when buffers have been allocated initially and the
3889    ///   number of buffers is then less than or equal to `buffers_remaining`.
3890    /// + request `buffers_remaining` Wait for all but `buffers_remaining` (or
3891    ///   fewer) buffers to be fully deallocated. A number greater than zero can
3892    ///   be useful in situations where a known number of buffers are
3893    ///   intentionally not closed so that the data can continue to be used,
3894    ///   such as for keeping the last available video frame displayed in the UI
3895    ///   even if the video stream was using protected output buffers. It's
3896    ///   outside the scope of the `BufferCollection` interface (at least for
3897    ///   now) to determine how many buffers may be held without closing, but
3898    ///   it'll typically be in the range 0-2.
3899    AttachLifetimeTracking {
3900        payload: BufferCollectionAttachLifetimeTrackingRequest,
3901        control_handle: BufferCollectionControlHandle,
3902    },
3903    /// An interaction was received which does not match any known method.
3904    #[non_exhaustive]
3905    _UnknownMethod {
3906        /// Ordinal of the method that was called.
3907        ordinal: u64,
3908        control_handle: BufferCollectionControlHandle,
3909        method_type: fidl::MethodType,
3910    },
3911}
3912
3913impl BufferCollectionRequest {
3914    #[allow(irrefutable_let_patterns)]
3915    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
3916        if let BufferCollectionRequest::Sync { responder } = self {
3917            Some((responder))
3918        } else {
3919            None
3920        }
3921    }
3922
3923    #[allow(irrefutable_let_patterns)]
3924    pub fn into_release(self) -> Option<(BufferCollectionControlHandle)> {
3925        if let BufferCollectionRequest::Release { control_handle } = self {
3926            Some((control_handle))
3927        } else {
3928            None
3929        }
3930    }
3931
3932    #[allow(irrefutable_let_patterns)]
3933    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, BufferCollectionControlHandle)> {
3934        if let BufferCollectionRequest::SetName { payload, control_handle } = self {
3935            Some((payload, control_handle))
3936        } else {
3937            None
3938        }
3939    }
3940
3941    #[allow(irrefutable_let_patterns)]
3942    pub fn into_set_debug_client_info(
3943        self,
3944    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionControlHandle)> {
3945        if let BufferCollectionRequest::SetDebugClientInfo { payload, control_handle } = self {
3946            Some((payload, control_handle))
3947        } else {
3948            None
3949        }
3950    }
3951
3952    #[allow(irrefutable_let_patterns)]
3953    pub fn into_set_debug_timeout_log_deadline(
3954        self,
3955    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionControlHandle)> {
3956        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { payload, control_handle } =
3957            self
3958        {
3959            Some((payload, control_handle))
3960        } else {
3961            None
3962        }
3963    }
3964
3965    #[allow(irrefutable_let_patterns)]
3966    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
3967        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
3968            Some((control_handle))
3969        } else {
3970            None
3971        }
3972    }
3973
3974    #[allow(irrefutable_let_patterns)]
3975    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
3976        if let BufferCollectionRequest::GetNodeRef { responder } = self {
3977            Some((responder))
3978        } else {
3979            None
3980        }
3981    }
3982
3983    #[allow(irrefutable_let_patterns)]
3984    pub fn into_is_alternate_for(
3985        self,
3986    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionIsAlternateForResponder)> {
3987        if let BufferCollectionRequest::IsAlternateFor { payload, responder } = self {
3988            Some((payload, responder))
3989        } else {
3990            None
3991        }
3992    }
3993
3994    #[allow(irrefutable_let_patterns)]
3995    pub fn into_get_buffer_collection_id(
3996        self,
3997    ) -> Option<(BufferCollectionGetBufferCollectionIdResponder)> {
3998        if let BufferCollectionRequest::GetBufferCollectionId { responder } = self {
3999            Some((responder))
4000        } else {
4001            None
4002        }
4003    }
4004
4005    #[allow(irrefutable_let_patterns)]
4006    pub fn into_set_weak(self) -> Option<(BufferCollectionControlHandle)> {
4007        if let BufferCollectionRequest::SetWeak { control_handle } = self {
4008            Some((control_handle))
4009        } else {
4010            None
4011        }
4012    }
4013
4014    #[allow(irrefutable_let_patterns)]
4015    pub fn into_set_weak_ok(self) -> Option<(NodeSetWeakOkRequest, BufferCollectionControlHandle)> {
4016        if let BufferCollectionRequest::SetWeakOk { payload, control_handle } = self {
4017            Some((payload, control_handle))
4018        } else {
4019            None
4020        }
4021    }
4022
4023    #[allow(irrefutable_let_patterns)]
4024    pub fn into_attach_node_tracking(
4025        self,
4026    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionControlHandle)> {
4027        if let BufferCollectionRequest::AttachNodeTracking { payload, control_handle } = self {
4028            Some((payload, control_handle))
4029        } else {
4030            None
4031        }
4032    }
4033
4034    #[allow(irrefutable_let_patterns)]
4035    pub fn into_set_constraints(
4036        self,
4037    ) -> Option<(BufferCollectionSetConstraintsRequest, BufferCollectionControlHandle)> {
4038        if let BufferCollectionRequest::SetConstraints { payload, control_handle } = self {
4039            Some((payload, control_handle))
4040        } else {
4041            None
4042        }
4043    }
4044
4045    #[allow(irrefutable_let_patterns)]
4046    pub fn into_wait_for_all_buffers_allocated(
4047        self,
4048    ) -> Option<(BufferCollectionWaitForAllBuffersAllocatedResponder)> {
4049        if let BufferCollectionRequest::WaitForAllBuffersAllocated { responder } = self {
4050            Some((responder))
4051        } else {
4052            None
4053        }
4054    }
4055
4056    #[allow(irrefutable_let_patterns)]
4057    pub fn into_check_all_buffers_allocated(
4058        self,
4059    ) -> Option<(BufferCollectionCheckAllBuffersAllocatedResponder)> {
4060        if let BufferCollectionRequest::CheckAllBuffersAllocated { responder } = self {
4061            Some((responder))
4062        } else {
4063            None
4064        }
4065    }
4066
4067    #[allow(irrefutable_let_patterns)]
4068    pub fn into_attach_token(
4069        self,
4070    ) -> Option<(BufferCollectionAttachTokenRequest, BufferCollectionControlHandle)> {
4071        if let BufferCollectionRequest::AttachToken { payload, control_handle } = self {
4072            Some((payload, control_handle))
4073        } else {
4074            None
4075        }
4076    }
4077
4078    #[allow(irrefutable_let_patterns)]
4079    pub fn into_attach_lifetime_tracking(
4080        self,
4081    ) -> Option<(BufferCollectionAttachLifetimeTrackingRequest, BufferCollectionControlHandle)>
4082    {
4083        if let BufferCollectionRequest::AttachLifetimeTracking { payload, control_handle } = self {
4084            Some((payload, control_handle))
4085        } else {
4086            None
4087        }
4088    }
4089
4090    /// Name of the method defined in FIDL
4091    pub fn method_name(&self) -> &'static str {
4092        match *self {
4093            BufferCollectionRequest::Sync { .. } => "sync",
4094            BufferCollectionRequest::Release { .. } => "release",
4095            BufferCollectionRequest::SetName { .. } => "set_name",
4096            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
4097            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
4098                "set_debug_timeout_log_deadline"
4099            }
4100            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
4101            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
4102            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
4103            BufferCollectionRequest::GetBufferCollectionId { .. } => "get_buffer_collection_id",
4104            BufferCollectionRequest::SetWeak { .. } => "set_weak",
4105            BufferCollectionRequest::SetWeakOk { .. } => "set_weak_ok",
4106            BufferCollectionRequest::AttachNodeTracking { .. } => "attach_node_tracking",
4107            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
4108            BufferCollectionRequest::WaitForAllBuffersAllocated { .. } => {
4109                "wait_for_all_buffers_allocated"
4110            }
4111            BufferCollectionRequest::CheckAllBuffersAllocated { .. } => {
4112                "check_all_buffers_allocated"
4113            }
4114            BufferCollectionRequest::AttachToken { .. } => "attach_token",
4115            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
4116            BufferCollectionRequest::_UnknownMethod {
4117                method_type: fidl::MethodType::OneWay,
4118                ..
4119            } => "unknown one-way method",
4120            BufferCollectionRequest::_UnknownMethod {
4121                method_type: fidl::MethodType::TwoWay,
4122                ..
4123            } => "unknown two-way method",
4124        }
4125    }
4126}
4127
4128#[derive(Debug, Clone)]
4129pub struct BufferCollectionControlHandle {
4130    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4131}
4132
4133impl fdomain_client::fidl::ControlHandle for BufferCollectionControlHandle {
4134    fn shutdown(&self) {
4135        self.inner.shutdown()
4136    }
4137
4138    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4139        self.inner.shutdown_with_epitaph(status)
4140    }
4141
4142    fn is_closed(&self) -> bool {
4143        self.inner.channel().is_closed()
4144    }
4145    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4146        self.inner.channel().on_closed()
4147    }
4148}
4149
4150impl BufferCollectionControlHandle {}
4151
4152#[must_use = "FIDL methods require a response to be sent"]
4153#[derive(Debug)]
4154pub struct BufferCollectionSyncResponder {
4155    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4156    tx_id: u32,
4157}
4158
4159/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4160/// if the responder is dropped without sending a response, so that the client
4161/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4162impl std::ops::Drop for BufferCollectionSyncResponder {
4163    fn drop(&mut self) {
4164        self.control_handle.shutdown();
4165        // Safety: drops once, never accessed again
4166        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4167    }
4168}
4169
4170impl fdomain_client::fidl::Responder for BufferCollectionSyncResponder {
4171    type ControlHandle = BufferCollectionControlHandle;
4172
4173    fn control_handle(&self) -> &BufferCollectionControlHandle {
4174        &self.control_handle
4175    }
4176
4177    fn drop_without_shutdown(mut self) {
4178        // Safety: drops once, never accessed again due to mem::forget
4179        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4180        // Prevent Drop from running (which would shut down the channel)
4181        std::mem::forget(self);
4182    }
4183}
4184
4185impl BufferCollectionSyncResponder {
4186    /// Sends a response to the FIDL transaction.
4187    ///
4188    /// Sets the channel to shutdown if an error occurs.
4189    pub fn send(self) -> Result<(), fidl::Error> {
4190        let _result = self.send_raw();
4191        if _result.is_err() {
4192            self.control_handle.shutdown();
4193        }
4194        self.drop_without_shutdown();
4195        _result
4196    }
4197
4198    /// Similar to "send" but does not shutdown the channel if an error occurs.
4199    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4200        let _result = self.send_raw();
4201        self.drop_without_shutdown();
4202        _result
4203    }
4204
4205    fn send_raw(&self) -> Result<(), fidl::Error> {
4206        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4207            fidl::encoding::Flexible::new(()),
4208            self.tx_id,
4209            0x11ac2555cf575b54,
4210            fidl::encoding::DynamicFlags::FLEXIBLE,
4211        )
4212    }
4213}
4214
4215#[must_use = "FIDL methods require a response to be sent"]
4216#[derive(Debug)]
4217pub struct BufferCollectionGetNodeRefResponder {
4218    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4219    tx_id: u32,
4220}
4221
4222/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4223/// if the responder is dropped without sending a response, so that the client
4224/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4225impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
4226    fn drop(&mut self) {
4227        self.control_handle.shutdown();
4228        // Safety: drops once, never accessed again
4229        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4230    }
4231}
4232
4233impl fdomain_client::fidl::Responder for BufferCollectionGetNodeRefResponder {
4234    type ControlHandle = BufferCollectionControlHandle;
4235
4236    fn control_handle(&self) -> &BufferCollectionControlHandle {
4237        &self.control_handle
4238    }
4239
4240    fn drop_without_shutdown(mut self) {
4241        // Safety: drops once, never accessed again due to mem::forget
4242        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4243        // Prevent Drop from running (which would shut down the channel)
4244        std::mem::forget(self);
4245    }
4246}
4247
4248impl BufferCollectionGetNodeRefResponder {
4249    /// Sends a response to the FIDL transaction.
4250    ///
4251    /// Sets the channel to shutdown if an error occurs.
4252    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
4253        let _result = self.send_raw(payload);
4254        if _result.is_err() {
4255            self.control_handle.shutdown();
4256        }
4257        self.drop_without_shutdown();
4258        _result
4259    }
4260
4261    /// Similar to "send" but does not shutdown the channel if an error occurs.
4262    pub fn send_no_shutdown_on_err(
4263        self,
4264        mut payload: NodeGetNodeRefResponse,
4265    ) -> Result<(), fidl::Error> {
4266        let _result = self.send_raw(payload);
4267        self.drop_without_shutdown();
4268        _result
4269    }
4270
4271    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
4272        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
4273            fidl::encoding::Flexible::new(&mut payload),
4274            self.tx_id,
4275            0x5b3d0e51614df053,
4276            fidl::encoding::DynamicFlags::FLEXIBLE,
4277        )
4278    }
4279}
4280
4281#[must_use = "FIDL methods require a response to be sent"]
4282#[derive(Debug)]
4283pub struct BufferCollectionIsAlternateForResponder {
4284    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4285    tx_id: u32,
4286}
4287
4288/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4289/// if the responder is dropped without sending a response, so that the client
4290/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4291impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
4292    fn drop(&mut self) {
4293        self.control_handle.shutdown();
4294        // Safety: drops once, never accessed again
4295        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4296    }
4297}
4298
4299impl fdomain_client::fidl::Responder for BufferCollectionIsAlternateForResponder {
4300    type ControlHandle = BufferCollectionControlHandle;
4301
4302    fn control_handle(&self) -> &BufferCollectionControlHandle {
4303        &self.control_handle
4304    }
4305
4306    fn drop_without_shutdown(mut self) {
4307        // Safety: drops once, never accessed again due to mem::forget
4308        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4309        // Prevent Drop from running (which would shut down the channel)
4310        std::mem::forget(self);
4311    }
4312}
4313
4314impl BufferCollectionIsAlternateForResponder {
4315    /// Sends a response to the FIDL transaction.
4316    ///
4317    /// Sets the channel to shutdown if an error occurs.
4318    pub fn send(
4319        self,
4320        mut result: Result<&NodeIsAlternateForResponse, Error>,
4321    ) -> Result<(), fidl::Error> {
4322        let _result = self.send_raw(result);
4323        if _result.is_err() {
4324            self.control_handle.shutdown();
4325        }
4326        self.drop_without_shutdown();
4327        _result
4328    }
4329
4330    /// Similar to "send" but does not shutdown the channel if an error occurs.
4331    pub fn send_no_shutdown_on_err(
4332        self,
4333        mut result: Result<&NodeIsAlternateForResponse, Error>,
4334    ) -> Result<(), fidl::Error> {
4335        let _result = self.send_raw(result);
4336        self.drop_without_shutdown();
4337        _result
4338    }
4339
4340    fn send_raw(
4341        &self,
4342        mut result: Result<&NodeIsAlternateForResponse, Error>,
4343    ) -> Result<(), fidl::Error> {
4344        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4345            NodeIsAlternateForResponse,
4346            Error,
4347        >>(
4348            fidl::encoding::FlexibleResult::new(result),
4349            self.tx_id,
4350            0x3a58e00157e0825,
4351            fidl::encoding::DynamicFlags::FLEXIBLE,
4352        )
4353    }
4354}
4355
4356#[must_use = "FIDL methods require a response to be sent"]
4357#[derive(Debug)]
4358pub struct BufferCollectionGetBufferCollectionIdResponder {
4359    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4360    tx_id: u32,
4361}
4362
4363/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4364/// if the responder is dropped without sending a response, so that the client
4365/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4366impl std::ops::Drop for BufferCollectionGetBufferCollectionIdResponder {
4367    fn drop(&mut self) {
4368        self.control_handle.shutdown();
4369        // Safety: drops once, never accessed again
4370        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4371    }
4372}
4373
4374impl fdomain_client::fidl::Responder for BufferCollectionGetBufferCollectionIdResponder {
4375    type ControlHandle = BufferCollectionControlHandle;
4376
4377    fn control_handle(&self) -> &BufferCollectionControlHandle {
4378        &self.control_handle
4379    }
4380
4381    fn drop_without_shutdown(mut self) {
4382        // Safety: drops once, never accessed again due to mem::forget
4383        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4384        // Prevent Drop from running (which would shut down the channel)
4385        std::mem::forget(self);
4386    }
4387}
4388
4389impl BufferCollectionGetBufferCollectionIdResponder {
4390    /// Sends a response to the FIDL transaction.
4391    ///
4392    /// Sets the channel to shutdown if an error occurs.
4393    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
4394        let _result = self.send_raw(payload);
4395        if _result.is_err() {
4396            self.control_handle.shutdown();
4397        }
4398        self.drop_without_shutdown();
4399        _result
4400    }
4401
4402    /// Similar to "send" but does not shutdown the channel if an error occurs.
4403    pub fn send_no_shutdown_on_err(
4404        self,
4405        mut payload: &NodeGetBufferCollectionIdResponse,
4406    ) -> Result<(), fidl::Error> {
4407        let _result = self.send_raw(payload);
4408        self.drop_without_shutdown();
4409        _result
4410    }
4411
4412    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
4413        self.control_handle
4414            .inner
4415            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
4416                fidl::encoding::Flexible::new(payload),
4417                self.tx_id,
4418                0x77d19a494b78ba8c,
4419                fidl::encoding::DynamicFlags::FLEXIBLE,
4420            )
4421    }
4422}
4423
4424#[must_use = "FIDL methods require a response to be sent"]
4425#[derive(Debug)]
4426pub struct BufferCollectionWaitForAllBuffersAllocatedResponder {
4427    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4428    tx_id: u32,
4429}
4430
4431/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4432/// if the responder is dropped without sending a response, so that the client
4433/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4434impl std::ops::Drop for BufferCollectionWaitForAllBuffersAllocatedResponder {
4435    fn drop(&mut self) {
4436        self.control_handle.shutdown();
4437        // Safety: drops once, never accessed again
4438        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4439    }
4440}
4441
4442impl fdomain_client::fidl::Responder for BufferCollectionWaitForAllBuffersAllocatedResponder {
4443    type ControlHandle = BufferCollectionControlHandle;
4444
4445    fn control_handle(&self) -> &BufferCollectionControlHandle {
4446        &self.control_handle
4447    }
4448
4449    fn drop_without_shutdown(mut self) {
4450        // Safety: drops once, never accessed again due to mem::forget
4451        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4452        // Prevent Drop from running (which would shut down the channel)
4453        std::mem::forget(self);
4454    }
4455}
4456
4457impl BufferCollectionWaitForAllBuffersAllocatedResponder {
4458    /// Sends a response to the FIDL transaction.
4459    ///
4460    /// Sets the channel to shutdown if an error occurs.
4461    pub fn send(
4462        self,
4463        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4464    ) -> Result<(), fidl::Error> {
4465        let _result = self.send_raw(result);
4466        if _result.is_err() {
4467            self.control_handle.shutdown();
4468        }
4469        self.drop_without_shutdown();
4470        _result
4471    }
4472
4473    /// Similar to "send" but does not shutdown the channel if an error occurs.
4474    pub fn send_no_shutdown_on_err(
4475        self,
4476        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4477    ) -> Result<(), fidl::Error> {
4478        let _result = self.send_raw(result);
4479        self.drop_without_shutdown();
4480        _result
4481    }
4482
4483    fn send_raw(
4484        &self,
4485        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4486    ) -> Result<(), fidl::Error> {
4487        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4488            BufferCollectionWaitForAllBuffersAllocatedResponse,
4489            Error,
4490        >>(
4491            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4492            self.tx_id,
4493            0x62300344b61404e,
4494            fidl::encoding::DynamicFlags::FLEXIBLE,
4495        )
4496    }
4497}
4498
4499#[must_use = "FIDL methods require a response to be sent"]
4500#[derive(Debug)]
4501pub struct BufferCollectionCheckAllBuffersAllocatedResponder {
4502    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4503    tx_id: u32,
4504}
4505
4506/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4507/// if the responder is dropped without sending a response, so that the client
4508/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4509impl std::ops::Drop for BufferCollectionCheckAllBuffersAllocatedResponder {
4510    fn drop(&mut self) {
4511        self.control_handle.shutdown();
4512        // Safety: drops once, never accessed again
4513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4514    }
4515}
4516
4517impl fdomain_client::fidl::Responder for BufferCollectionCheckAllBuffersAllocatedResponder {
4518    type ControlHandle = BufferCollectionControlHandle;
4519
4520    fn control_handle(&self) -> &BufferCollectionControlHandle {
4521        &self.control_handle
4522    }
4523
4524    fn drop_without_shutdown(mut self) {
4525        // Safety: drops once, never accessed again due to mem::forget
4526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4527        // Prevent Drop from running (which would shut down the channel)
4528        std::mem::forget(self);
4529    }
4530}
4531
4532impl BufferCollectionCheckAllBuffersAllocatedResponder {
4533    /// Sends a response to the FIDL transaction.
4534    ///
4535    /// Sets the channel to shutdown if an error occurs.
4536    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4537        let _result = self.send_raw(result);
4538        if _result.is_err() {
4539            self.control_handle.shutdown();
4540        }
4541        self.drop_without_shutdown();
4542        _result
4543    }
4544
4545    /// Similar to "send" but does not shutdown the channel if an error occurs.
4546    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4547        let _result = self.send_raw(result);
4548        self.drop_without_shutdown();
4549        _result
4550    }
4551
4552    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4553        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4554            fidl::encoding::EmptyStruct,
4555            Error,
4556        >>(
4557            fidl::encoding::FlexibleResult::new(result),
4558            self.tx_id,
4559            0x35a5fe77ce939c10,
4560            fidl::encoding::DynamicFlags::FLEXIBLE,
4561        )
4562    }
4563}
4564
4565#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4566pub struct BufferCollectionTokenMarker;
4567
4568impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenMarker {
4569    type Proxy = BufferCollectionTokenProxy;
4570    type RequestStream = BufferCollectionTokenRequestStream;
4571
4572    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
4573}
4574
4575pub trait BufferCollectionTokenProxyInterface: Send + Sync {
4576    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4577    fn r#sync(&self) -> Self::SyncResponseFut;
4578    fn r#release(&self) -> Result<(), fidl::Error>;
4579    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
4580    fn r#set_debug_client_info(
4581        &self,
4582        payload: &NodeSetDebugClientInfoRequest,
4583    ) -> Result<(), fidl::Error>;
4584    fn r#set_debug_timeout_log_deadline(
4585        &self,
4586        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
4587    ) -> Result<(), fidl::Error>;
4588    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
4589    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
4590        + Send;
4591    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
4592    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
4593        + Send;
4594    fn r#is_alternate_for(
4595        &self,
4596        payload: NodeIsAlternateForRequest,
4597    ) -> Self::IsAlternateForResponseFut;
4598    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
4599        + Send;
4600    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
4601    fn r#set_weak(&self) -> Result<(), fidl::Error>;
4602    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
4603    fn r#attach_node_tracking(
4604        &self,
4605        payload: NodeAttachNodeTrackingRequest,
4606    ) -> Result<(), fidl::Error>;
4607    type DuplicateSyncResponseFut: std::future::Future<
4608            Output = Result<BufferCollectionTokenDuplicateSyncResponse, fidl::Error>,
4609        > + Send;
4610    fn r#duplicate_sync(
4611        &self,
4612        payload: &BufferCollectionTokenDuplicateSyncRequest,
4613    ) -> Self::DuplicateSyncResponseFut;
4614    fn r#duplicate(
4615        &self,
4616        payload: BufferCollectionTokenDuplicateRequest,
4617    ) -> Result<(), fidl::Error>;
4618    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
4619    fn r#create_buffer_collection_token_group(
4620        &self,
4621        payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
4622    ) -> Result<(), fidl::Error>;
4623}
4624
4625#[derive(Debug, Clone)]
4626pub struct BufferCollectionTokenProxy {
4627    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4628}
4629
4630impl fdomain_client::fidl::Proxy for BufferCollectionTokenProxy {
4631    type Protocol = BufferCollectionTokenMarker;
4632
4633    fn from_channel(inner: fdomain_client::Channel) -> Self {
4634        Self::new(inner)
4635    }
4636
4637    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4638        self.client.into_channel().map_err(|client| Self { client })
4639    }
4640
4641    fn as_channel(&self) -> &fdomain_client::Channel {
4642        self.client.as_channel()
4643    }
4644}
4645
4646impl BufferCollectionTokenProxy {
4647    /// Create a new Proxy for fuchsia.sysmem2/BufferCollectionToken.
4648    pub fn new(channel: fdomain_client::Channel) -> Self {
4649        let protocol_name =
4650            <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4651        Self { client: fidl::client::Client::new(channel, protocol_name) }
4652    }
4653
4654    /// Get a Stream of events from the remote end of the protocol.
4655    ///
4656    /// # Panics
4657    ///
4658    /// Panics if the event stream was already taken.
4659    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
4660        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
4661    }
4662
4663    /// Ensure that previous messages have been received server side. This is
4664    /// particularly useful after previous messages that created new tokens,
4665    /// because a token must be known to the sysmem server before sending the
4666    /// token to another participant.
4667    ///
4668    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
4669    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
4670    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
4671    /// to mitigate the possibility of a hostile/fake
4672    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
4673    /// Another way is to pass the token to
4674    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
4675    /// the token as part of exchanging it for a
4676    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
4677    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
4678    /// of stalling.
4679    ///
4680    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
4681    /// and then starting and completing a `Sync`, it's then safe to send the
4682    /// `BufferCollectionToken` client ends to other participants knowing the
4683    /// server will recognize the tokens when they're sent by the other
4684    /// participants to sysmem in a
4685    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
4686    /// efficient way to create tokens while avoiding unnecessary round trips.
4687    ///
4688    /// Other options include waiting for each
4689    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
4690    /// individually (using separate call to `Sync` after each), or calling
4691    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
4692    /// converted to a `BufferCollection` via
4693    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
4694    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
4695    /// the sync step and can create multiple tokens at once.
4696    pub fn r#sync(
4697        &self,
4698    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
4699        BufferCollectionTokenProxyInterface::r#sync(self)
4700    }
4701
4702    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
4703    ///
4704    /// Normally a participant will convert a `BufferCollectionToken` into a
4705    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
4706    /// `Release` via the token (and then close the channel immediately or
4707    /// shortly later in response to server closing the server end), which
4708    /// avoids causing buffer collection failure. Without a prior `Release`,
4709    /// closing the `BufferCollectionToken` client end will cause buffer
4710    /// collection failure.
4711    ///
4712    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
4713    ///
4714    /// By default the server handles unexpected closure of a
4715    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
4716    /// first) by failing the buffer collection. Partly this is to expedite
4717    /// closing VMO handles to reclaim memory when any participant fails. If a
4718    /// participant would like to cleanly close a `BufferCollection` without
4719    /// causing buffer collection failure, the participant can send `Release`
4720    /// before closing the `BufferCollection` client end. The `Release` can
4721    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
4722    /// buffer collection won't require constraints from this node in order to
4723    /// allocate. If after `SetConstraints`, the constraints are retained and
4724    /// aggregated, despite the lack of `BufferCollection` connection at the
4725    /// time of constraints aggregation.
4726    ///
4727    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
4728    ///
4729    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
4730    /// end (without `Release` first) will trigger failure of the buffer
4731    /// collection. To close a `BufferCollectionTokenGroup` channel without
4732    /// failing the buffer collection, ensure that AllChildrenPresent() has been
4733    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
4734    /// client end.
4735    ///
4736    /// If `Release` occurs before
4737    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
4738    /// buffer collection will fail (triggered by reception of `Release` without
4739    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
4740    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
4741    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
4742    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
4743    /// close requires `AllChildrenPresent` (if not already sent), then
4744    /// `Release`, then close client end.
4745    ///
4746    /// If `Release` occurs after `AllChildrenPresent`, the children and all
4747    /// their constraints remain intact (just as they would if the
4748    /// `BufferCollectionTokenGroup` channel had remained open), and the client
4749    /// end close doesn't trigger buffer collection failure.
4750    ///
4751    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
4752    ///
4753    /// For brevity, the per-channel-protocol paragraphs above ignore the
4754    /// separate failure domain created by
4755    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
4756    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
4757    /// unexpectedly closes (without `Release` first) and that client end is
4758    /// under a failure domain, instead of failing the whole buffer collection,
4759    /// the failure domain is failed, but the buffer collection itself is
4760    /// isolated from failure of the failure domain. Such failure domains can be
4761    /// nested, in which case only the inner-most failure domain in which the
4762    /// `Node` resides fails.
4763    pub fn r#release(&self) -> Result<(), fidl::Error> {
4764        BufferCollectionTokenProxyInterface::r#release(self)
4765    }
4766
4767    /// Set a name for VMOs in this buffer collection.
4768    ///
4769    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
4770    /// will be truncated to fit. The name of the vmo will be suffixed with the
4771    /// buffer index within the collection (if the suffix fits within
4772    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
4773    /// listed in the inspect data.
4774    ///
4775    /// The name only affects VMOs allocated after the name is set; this call
4776    /// does not rename existing VMOs. If multiple clients set different names
4777    /// then the larger priority value will win. Setting a new name with the
4778    /// same priority as a prior name doesn't change the name.
4779    ///
4780    /// All table fields are currently required.
4781    ///
4782    /// + request `priority` The name is only set if this is the first `SetName`
4783    ///   or if `priority` is greater than any previous `priority` value in
4784    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
4785    /// + request `name` The name for VMOs created under this buffer collection.
4786    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
4787        BufferCollectionTokenProxyInterface::r#set_name(self, payload)
4788    }
4789
4790    /// Set information about the current client that can be used by sysmem to
4791    /// help diagnose leaking memory and allocation stalls waiting for a
4792    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
4793    ///
4794    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
4795    /// `Node`(s) derived from this `Node`, unless overriden by
4796    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
4797    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
4798    ///
4799    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
4800    /// `Allocator` is the most efficient way to ensure that all
4801    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
4802    /// set, and is also more efficient than separately sending the same debug
4803    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
4804    /// created [`fuchsia.sysmem2/Node`].
4805    ///
4806    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
4807    /// indicate which client is closing their channel first, leading to subtree
4808    /// failure (which can be normal if the purpose of the subtree is over, but
4809    /// if happening earlier than expected, the client-channel-specific name can
4810    /// help diagnose where the failure is first coming from, from sysmem's
4811    /// point of view).
4812    ///
4813    /// All table fields are currently required.
4814    ///
4815    /// + request `name` This can be an arbitrary string, but the current
4816    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
4817    /// + request `id` This can be an arbitrary id, but the current process ID
4818    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
4819    pub fn r#set_debug_client_info(
4820        &self,
4821        mut payload: &NodeSetDebugClientInfoRequest,
4822    ) -> Result<(), fidl::Error> {
4823        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, payload)
4824    }
4825
4826    /// Sysmem logs a warning if sysmem hasn't seen
4827    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
4828    /// within 5 seconds after creation of a new collection.
4829    ///
4830    /// Clients can call this method to change when the log is printed. If
4831    /// multiple client set the deadline, it's unspecified which deadline will
4832    /// take effect.
4833    ///
4834    /// In most cases the default works well.
4835    ///
4836    /// All table fields are currently required.
4837    ///
4838    /// + request `deadline` The time at which sysmem will start trying to log
4839    ///   the warning, unless all constraints are with sysmem by then.
4840    pub fn r#set_debug_timeout_log_deadline(
4841        &self,
4842        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
4843    ) -> Result<(), fidl::Error> {
4844        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
4845    }
4846
4847    /// This enables verbose logging for the buffer collection.
4848    ///
4849    /// Verbose logging includes constraints set via
4850    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
4851    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
4852    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
4853    /// the tree of `Node`(s).
4854    ///
4855    /// Normally sysmem prints only a single line complaint when aggregation
4856    /// fails, with just the specific detailed reason that aggregation failed,
4857    /// with little surrounding context.  While this is often enough to diagnose
4858    /// a problem if only a small change was made and everything was working
4859    /// before the small change, it's often not particularly helpful for getting
4860    /// a new buffer collection to work for the first time.  Especially with
4861    /// more complex trees of nodes, involving things like
4862    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
4863    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
4864    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
4865    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
4866    /// looks like and why it's failing a logical allocation, or why a tree or
4867    /// subtree is failing sooner than expected.
4868    ///
4869    /// The intent of the extra logging is to be acceptable from a performance
4870    /// point of view, under the assumption that verbose logging is only enabled
4871    /// on a low number of buffer collections. If we're not tracking down a bug,
4872    /// we shouldn't send this message.
4873    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4874        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
4875    }
4876
4877    /// This gets a handle that can be used as a parameter to
4878    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
4879    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
4880    /// client obtained this handle from this `Node`.
4881    ///
4882    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
4883    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
4884    /// despite the two calls typically being on different channels.
4885    ///
4886    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
4887    ///
4888    /// All table fields are currently required.
4889    ///
4890    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
4891    ///   different `Node` channel, to prove that the client obtained the handle
4892    ///   from this `Node`.
4893    pub fn r#get_node_ref(
4894        &self,
4895    ) -> fidl::client::QueryResponseFut<
4896        NodeGetNodeRefResponse,
4897        fdomain_client::fidl::FDomainResourceDialect,
4898    > {
4899        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
4900    }
4901
4902    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
4903    /// rooted at a different child token of a common parent
4904    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
4905    /// passed-in `node_ref`.
4906    ///
4907    /// This call is for assisting with admission control de-duplication, and
4908    /// with debugging.
4909    ///
4910    /// The `node_ref` must be obtained using
4911    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
4912    ///
4913    /// The `node_ref` can be a duplicated handle; it's not necessary to call
4914    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
4915    ///
4916    /// If a calling token may not actually be a valid token at all due to a
4917    /// potentially hostile/untrusted provider of the token, call
4918    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
4919    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
4920    /// never responds due to a calling token not being a real token (not really
4921    /// talking to sysmem).  Another option is to call
4922    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
4923    /// which also validates the token along with converting it to a
4924    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
4925    ///
4926    /// All table fields are currently required.
4927    ///
4928    /// - response `is_alternate`
4929    ///   - true: The first parent node in common between the calling node and
4930    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
4931    ///     that the calling `Node` and the `node_ref` `Node` will not have both
4932    ///     their constraints apply - rather sysmem will choose one or the other
4933    ///     of the constraints - never both.  This is because only one child of
4934    ///     a `BufferCollectionTokenGroup` is selected during logical
4935    ///     allocation, with only that one child's subtree contributing to
4936    ///     constraints aggregation.
4937    ///   - false: The first parent node in common between the calling `Node`
4938    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
4939    ///     Currently, this means the first parent node in common is a
4940    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
4941    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
4942    ///     `Node` may have both their constraints apply during constraints
4943    ///     aggregation of the logical allocation, if both `Node`(s) are
4944    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
4945    ///     this case, there is no `BufferCollectionTokenGroup` that will
4946    ///     directly prevent the two `Node`(s) from both being selected and
4947    ///     their constraints both aggregated, but even when false, one or both
4948    ///     `Node`(s) may still be eliminated from consideration if one or both
4949    ///     `Node`(s) has a direct or indirect parent
4950    ///     `BufferCollectionTokenGroup` which selects a child subtree other
4951    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
4952    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
4953    ///   associated with the same buffer collection as the calling `Node`.
4954    ///   Another reason for this error is if the `node_ref` is an
4955    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
4956    ///   a real `node_ref` obtained from `GetNodeRef`.
4957    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
4958    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
4959    ///   the needed rights expected on a real `node_ref`.
4960    /// * No other failing status codes are returned by this call.  However,
4961    ///   sysmem may add additional codes in future, so the client should have
4962    ///   sensible default handling for any failing status code.
4963    pub fn r#is_alternate_for(
4964        &self,
4965        mut payload: NodeIsAlternateForRequest,
4966    ) -> fidl::client::QueryResponseFut<
4967        NodeIsAlternateForResult,
4968        fdomain_client::fidl::FDomainResourceDialect,
4969    > {
4970        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, payload)
4971    }
4972
4973    /// Get the buffer collection ID. This ID is also available from
4974    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
4975    /// within the collection).
4976    ///
4977    /// This call is mainly useful in situations where we can't convey a
4978    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
4979    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
4980    /// handle, which can be joined back up with a `BufferCollection` client end
4981    /// that was created via a different path. Prefer to convey a
4982    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
4983    ///
4984    /// Trusting a `buffer_collection_id` value from a source other than sysmem
4985    /// is analogous to trusting a koid value from a source other than zircon.
4986    /// Both should be avoided unless really necessary, and both require
4987    /// caution. In some situations it may be reasonable to refer to a
4988    /// pre-established `BufferCollection` by `buffer_collection_id` via a
4989    /// protocol for efficiency reasons, but an incoming value purporting to be
4990    /// a `buffer_collection_id` is not sufficient alone to justify granting the
4991    /// sender of the `buffer_collection_id` any capability. The sender must
4992    /// first prove to a receiver that the sender has/had a VMO or has/had a
4993    /// `BufferCollectionToken` to the same collection by sending a handle that
4994    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
4995    /// `buffer_collection_id` value. The receiver should take care to avoid
4996    /// assuming that a sender had a `BufferCollectionToken` in cases where the
4997    /// sender has only proven that the sender had a VMO.
4998    ///
4999    /// - response `buffer_collection_id` This ID is unique per buffer
5000    ///   collection per boot. Each buffer is uniquely identified by the
5001    ///   `buffer_collection_id` and `buffer_index` together.
5002    pub fn r#get_buffer_collection_id(
5003        &self,
5004    ) -> fidl::client::QueryResponseFut<
5005        NodeGetBufferCollectionIdResponse,
5006        fdomain_client::fidl::FDomainResourceDialect,
5007    > {
5008        BufferCollectionTokenProxyInterface::r#get_buffer_collection_id(self)
5009    }
5010
5011    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
5012    /// created after this message to weak, which means that a client's `Node`
5013    /// client end (or a child created after this message) is not alone
5014    /// sufficient to keep allocated VMOs alive.
5015    ///
5016    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
5017    /// `close_weak_asap`.
5018    ///
5019    /// This message is only permitted before the `Node` becomes ready for
5020    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
5021    ///   * `BufferCollectionToken`: any time
5022    ///   * `BufferCollection`: before `SetConstraints`
5023    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
5024    ///
5025    /// Currently, no conversion from strong `Node` to weak `Node` after ready
5026    /// for allocation is provided, but a client can simulate that by creating
5027    /// an additional `Node` before allocation and setting that additional
5028    /// `Node` to weak, and then potentially at some point later sending
5029    /// `Release` and closing the client end of the client's strong `Node`, but
5030    /// keeping the client's weak `Node`.
5031    ///
5032    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
5033    /// collection failure (all `Node` client end(s) will see
5034    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
5035    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
5036    /// this situation until all `Node`(s) are ready for allocation. For initial
5037    /// allocation to succeed, at least one strong `Node` is required to exist
5038    /// at allocation time, but after that client receives VMO handles, that
5039    /// client can `BufferCollection.Release` and close the client end without
5040    /// causing this type of failure.
5041    ///
5042    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
5043    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
5044    /// separately as appropriate.
5045    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
5046        BufferCollectionTokenProxyInterface::r#set_weak(self)
5047    }
5048
5049    /// This indicates to sysmem that the client is prepared to pay attention to
5050    /// `close_weak_asap`.
5051    ///
5052    /// If sent, this message must be before
5053    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
5054    ///
5055    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
5056    /// send this message before `WaitForAllBuffersAllocated`, or a parent
5057    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
5058    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
5059    /// trigger buffer collection failure.
5060    ///
5061    /// This message is necessary because weak sysmem VMOs have not always been
5062    /// a thing, so older clients are not aware of the need to pay attention to
5063    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
5064    /// sysmem weak VMO handles asap. By having this message and requiring
5065    /// participants to indicate their acceptance of this aspect of the overall
5066    /// protocol, we avoid situations where an older client is delivered a weak
5067    /// VMO without any way for sysmem to get that VMO to close quickly later
5068    /// (and on a per-buffer basis).
5069    ///
5070    /// A participant that doesn't handle `close_weak_asap` and also doesn't
5071    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
5072    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
5073    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
5074    /// same participant has a child/delegate which does retrieve VMOs, that
5075    /// child/delegate will need to send `SetWeakOk` before
5076    /// `WaitForAllBuffersAllocated`.
5077    ///
5078    /// + request `for_child_nodes_also` If present and true, this means direct
5079    ///   child nodes of this node created after this message plus all
5080    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
5081    ///   those nodes. Any child node of this node that was created before this
5082    ///   message is not included. This setting is "sticky" in the sense that a
5083    ///   subsequent `SetWeakOk` without this bool set to true does not reset
5084    ///   the server-side bool. If this creates a problem for a participant, a
5085    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
5086    ///   tokens instead, as appropriate. A participant should only set
5087    ///   `for_child_nodes_also` true if the participant can really promise to
5088    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
5089    ///   weak VMO handles held by participants holding the corresponding child
5090    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
5091    ///   which are using sysmem(1) can be weak, despite the clients of those
5092    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
5093    ///   direct way to find out about `close_weak_asap`. This only applies to
5094    ///   descendents of this `Node` which are using sysmem(1), not to this
5095    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
5096    ///   token, which will fail allocation unless an ancestor of this `Node`
5097    ///   specified `for_child_nodes_also` true.
5098    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
5099        BufferCollectionTokenProxyInterface::r#set_weak_ok(self, payload)
5100    }
5101
5102    /// The server_end will be closed after this `Node` and any child nodes have
5103    /// have released their buffer counts, making those counts available for
5104    /// reservation by a different `Node` via
5105    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
5106    ///
5107    /// The `Node` buffer counts may not be released until the entire tree of
5108    /// `Node`(s) is closed or failed, because
5109    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
5110    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
5111    /// `Node` buffer counts remain reserved until the orphaned node is later
5112    /// cleaned up.
5113    ///
5114    /// If the `Node` exceeds a fairly large number of attached eventpair server
5115    /// ends, a log message will indicate this and the `Node` (and the
5116    /// appropriate) sub-tree will fail.
5117    ///
5118    /// The `server_end` will remain open when
5119    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
5120    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
5121    /// [`fuchsia.sysmem2/BufferCollection`].
5122    ///
5123    /// This message can also be used with a
5124    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
5125    pub fn r#attach_node_tracking(
5126        &self,
5127        mut payload: NodeAttachNodeTrackingRequest,
5128    ) -> Result<(), fidl::Error> {
5129        BufferCollectionTokenProxyInterface::r#attach_node_tracking(self, payload)
5130    }
5131
5132    /// Create additional [`fuchsia.sysmem2/BufferCollectionToken`](s) from this
5133    /// one, referring to the same buffer collection.
5134    ///
5135    /// The created tokens are children of this token in the
5136    /// [`fuchsia.sysmem2/Node`] heirarchy.
5137    ///
5138    /// This method can be used to add more participants, by transferring the
5139    /// newly created tokens to additional participants.
5140    ///
5141    /// A new token will be returned for each entry in the
5142    /// `rights_attenuation_masks` array.
5143    ///
5144    /// If the called token may not actually be a valid token due to a
5145    /// potentially hostile/untrusted provider of the token, consider using
5146    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
5147    /// instead of potentially getting stuck indefinitely if
5148    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] never responds
5149    /// due to the calling token not being a real token.
5150    ///
5151    /// In contrast to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], no
5152    /// separate [`fuchsia.sysmem2/Node.Sync`] is needed after calling this
5153    /// method, because the sync step is included in this call, at the cost of a
5154    /// round trip during this call.
5155    ///
5156    /// All tokens must be turned in to sysmem via
5157    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
5158    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
5159    /// successfully allocate buffers (or to logically allocate buffers in the
5160    /// case of subtrees involving
5161    /// [`fuchsia.sysmem2/BufferCollectionToken.AttachToken`]).
5162    ///
5163    /// All table fields are currently required.
5164    ///
5165    /// + request `rights_attenuation_mask` In each entry of
5166    ///   `rights_attenuation_masks`, rights bits that are zero will be absent
5167    ///   in the buffer VMO rights obtainable via the corresponding returned
5168    ///   token. This allows an initiator or intermediary participant to
5169    ///   attenuate the rights available to a participant. This does not allow a
5170    ///   participant to gain rights that the participant doesn't already have.
5171    ///   The value `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no
5172    ///   attenuation should be applied.
5173    /// - response `tokens` The client ends of each newly created token.
5174    pub fn r#duplicate_sync(
5175        &self,
5176        mut payload: &BufferCollectionTokenDuplicateSyncRequest,
5177    ) -> fidl::client::QueryResponseFut<
5178        BufferCollectionTokenDuplicateSyncResponse,
5179        fdomain_client::fidl::FDomainResourceDialect,
5180    > {
5181        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, payload)
5182    }
5183
5184    /// Create an additional [`fuchsia.sysmem2/BufferCollectionToken`] from this
5185    /// one, referring to the same buffer collection.
5186    ///
5187    /// The created token is a child of this token in the
5188    /// [`fuchsia.sysmem2/Node`] heirarchy.
5189    ///
5190    /// This method can be used to add a participant, by transferring the newly
5191    /// created token to another participant.
5192    ///
5193    /// This one-way message can be used instead of the two-way
5194    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] FIDL call in
5195    /// performance sensitive cases where it would be undesireable to wait for
5196    /// sysmem to respond to
5197    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or when the
5198    /// client code isn't structured to make it easy to duplicate all the needed
5199    /// tokens at once.
5200    ///
5201    /// After sending one or more `Duplicate` messages, and before sending the
5202    /// newly created child tokens to other participants (or to other
5203    /// [`fuchsia.sysmem2/Allocator`] channels), the client must send a
5204    /// [`fuchsia.sysmem2/Node.Sync`] and wait for the `Sync` response. The
5205    /// `Sync` call can be made on the token, or on the `BufferCollection`
5206    /// obtained by passing this token to `BindSharedCollection`.  Either will
5207    /// ensure that the server knows about the tokens created via `Duplicate`
5208    /// before the other participant sends the token to the server via separate
5209    /// `Allocator` channel.
5210    ///
5211    /// All tokens must be turned in via
5212    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
5213    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
5214    /// successfully allocate buffers.
5215    ///
5216    /// All table fields are currently required.
5217    ///
5218    /// + request `rights_attenuation_mask` The rights bits that are zero in
5219    ///   this mask will be absent in the buffer VMO rights obtainable via the
5220    ///   client end of `token_request`. This allows an initiator or
5221    ///   intermediary participant to attenuate the rights available to a
5222    ///   delegate participant. This does not allow a participant to gain rights
5223    ///   that the participant doesn't already have. The value
5224    ///   `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no attenuation
5225    ///   should be applied.
5226    ///   + These values for rights_attenuation_mask result in no attenuation:
5227    ///     + `ZX_RIGHT_SAME_RIGHTS` (preferred)
5228    ///     + 0xFFFFFFFF (this is reasonable when an attenuation mask is
5229    ///       computed)
5230    ///     + 0 (deprecated - do not use 0 - an ERROR will go to the log)
5231    /// + request `token_request` is the server end of a `BufferCollectionToken`
5232    ///   channel. The client end of this channel acts as another participant in
5233    ///   the shared buffer collection.
5234    pub fn r#duplicate(
5235        &self,
5236        mut payload: BufferCollectionTokenDuplicateRequest,
5237    ) -> Result<(), fidl::Error> {
5238        BufferCollectionTokenProxyInterface::r#duplicate(self, payload)
5239    }
5240
5241    /// Set this [`fuchsia.sysmem2/BufferCollectionToken`] to dispensable.
5242    ///
5243    /// When the `BufferCollectionToken` is converted to a
5244    /// [`fuchsia.sysmem2/BufferCollection`], the dispensable status applies to
5245    /// the `BufferCollection` also.
5246    ///
5247    /// Normally, if a client closes a [`fuchsia.sysmem2/BufferCollection`]
5248    /// client end without having sent
5249    /// [`fuchsia.sysmem2/BufferCollection.Release`] first, the
5250    /// `BufferCollection` [`fuchisa.sysmem2/Node`] will fail, which also
5251    /// propagates failure to the parent [`fuchsia.sysmem2/Node`] and so on up
5252    /// to the root `Node`, which fails the whole buffer collection. In
5253    /// contrast, a dispensable `Node` can fail after buffers are allocated
5254    /// without causing failure of its parent in the [`fuchsia.sysmem2/Node`]
5255    /// heirarchy.
5256    ///
5257    /// The dispensable `Node` participates in constraints aggregation along
5258    /// with its parent before buffer allocation. If the dispensable `Node`
5259    /// fails before buffers are allocated, the failure propagates to the
5260    /// dispensable `Node`'s parent.
5261    ///
5262    /// After buffers are allocated, failure of the dispensable `Node` (or any
5263    /// child of the dispensable `Node`) does not propagate to the dispensable
5264    /// `Node`'s parent. Failure does propagate from a normal child of a
5265    /// dispensable `Node` to the dispensable `Node`.  Failure of a child is
5266    /// blocked from reaching its parent if the child is attached using
5267    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or if the child is
5268    /// dispensable and the failure occurred after allocation.
5269    ///
5270    /// A dispensable `Node` can be used in cases where a participant needs to
5271    /// provide constraints, but after buffers are allocated, the participant
5272    /// can fail without causing buffer collection failure from the parent
5273    /// `Node`'s point of view.
5274    ///
5275    /// In contrast, `BufferCollection.AttachToken` can be used to create a
5276    /// `BufferCollectionToken` which does not participate in constraints
5277    /// aggregation with its parent `Node`, and whose failure at any time does
5278    /// not propagate to its parent `Node`, and whose potential delay providing
5279    /// constraints does not prevent the parent `Node` from completing its
5280    /// buffer allocation.
5281    ///
5282    /// An initiator (creator of the root `Node` using
5283    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`]) may in some
5284    /// scenarios choose to initially use a dispensable `Node` for a first
5285    /// instance of a participant, and then later if the first instance of that
5286    /// participant fails, a new second instance of that participant my be given
5287    /// a `BufferCollectionToken` created with `AttachToken`.
5288    ///
5289    /// Normally a client will `SetDispensable` on a `BufferCollectionToken`
5290    /// shortly before sending the dispensable `BufferCollectionToken` to a
5291    /// delegate participant. Because `SetDispensable` prevents propagation of
5292    /// child `Node` failure to parent `Node`(s), if the client was relying on
5293    /// noticing child failure via failure of the parent `Node` retained by the
5294    /// client, the client may instead need to notice failure via other means.
5295    /// If other means aren't available/convenient, the client can instead
5296    /// retain the dispensable `Node` and create a child `Node` under that to
5297    /// send to the delegate participant, retaining this `Node` in order to
5298    /// notice failure of the subtree rooted at this `Node` via this `Node`'s
5299    /// ZX_CHANNEL_PEER_CLOSED signal, and take whatever action is appropriate
5300    /// (e.g. starting a new instance of the delegate participant and handing it
5301    /// a `BufferCollectionToken` created using
5302    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or propagate failure
5303    /// and clean up in a client-specific way).
5304    ///
5305    /// While it is possible (and potentially useful) to `SetDispensable` on a
5306    /// direct child of a `BufferCollectionTokenGroup` `Node`, it isn't possible
5307    /// to later replace a failed dispensable `Node` that was a direct child of
5308    /// a `BufferCollectionTokenGroup` with a new token using `AttachToken`
5309    /// (since there's no `AttachToken` on a group). Instead, to enable
5310    /// `AttachToken` replacement in this case, create an additional
5311    /// non-dispensable token that's a direct child of the group and make the
5312    /// existing dispensable token a child of the additional token.  This way,
5313    /// the additional token that is a direct child of the group has
5314    /// `BufferCollection.AttachToken` which can be used to replace the failed
5315    /// dispensable token.
5316    ///
5317    /// `SetDispensable` on an already-dispensable token is idempotent.
5318    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5319        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
5320    }
5321
5322    /// Create a logical OR among a set of tokens, called a
5323    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
5324    ///
5325    /// Most sysmem clients and many participants don't need to care about this
5326    /// message or about `BufferCollectionTokenGroup`(s). However, in some cases
5327    /// a participant wants to attempt to include one set of delegate
5328    /// participants, but if constraints don't combine successfully that way,
5329    /// fall back to a different (possibly overlapping) set of delegate
5330    /// participants, and/or fall back to a less demanding strategy (in terms of
5331    /// how strict the [`fuchisa.sysmem2/BufferCollectionConstraints`] are,
5332    /// across all involved delegate participants). In such cases, a
5333    /// `BufferCollectionTokenGroup` is useful.
5334    ///
5335    /// A `BufferCollectionTokenGroup` is used to create a 1 of N OR among N
5336    /// child [`fuchsia.sysmem2/BufferCollectionToken`](s).  The child tokens
5337    /// which are not selected during aggregation will fail (close), which a
5338    /// potential participant should notice when their `BufferCollection`
5339    /// channel client endpoint sees PEER_CLOSED, allowing the participant to
5340    /// clean up the speculative usage that didn't end up happening (this is
5341    /// simimlar to a normal `BufferCollection` server end closing on failure to
5342    /// allocate a logical buffer collection or later async failure of a buffer
5343    /// collection).
5344    ///
5345    /// See comments on protocol `BufferCollectionTokenGroup`.
5346    ///
5347    /// Any `rights_attenuation_mask` or `AttachToken`/`SetDispensable` to be
5348    /// applied to the whole group can be achieved with a
5349    /// `BufferCollectionToken` for this purpose as a direct parent of the
5350    /// `BufferCollectionTokenGroup`.
5351    ///
5352    /// All table fields are currently required.
5353    ///
5354    /// + request `group_request` The server end of a
5355    ///   `BufferCollectionTokenGroup` channel to be served by sysmem.
5356    pub fn r#create_buffer_collection_token_group(
5357        &self,
5358        mut payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
5359    ) -> Result<(), fidl::Error> {
5360        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(self, payload)
5361    }
5362}
5363
5364impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
5365    type SyncResponseFut =
5366        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
5367    fn r#sync(&self) -> Self::SyncResponseFut {
5368        fn _decode(
5369            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5370        ) -> Result<(), fidl::Error> {
5371            let _response = fidl::client::decode_transaction_body::<
5372                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5373                fdomain_client::fidl::FDomainResourceDialect,
5374                0x11ac2555cf575b54,
5375            >(_buf?)?
5376            .into_result_fdomain::<BufferCollectionTokenMarker>("sync")?;
5377            Ok(_response)
5378        }
5379        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5380            (),
5381            0x11ac2555cf575b54,
5382            fidl::encoding::DynamicFlags::FLEXIBLE,
5383            _decode,
5384        )
5385    }
5386
5387    fn r#release(&self) -> Result<(), fidl::Error> {
5388        self.client.send::<fidl::encoding::EmptyPayload>(
5389            (),
5390            0x6a5cae7d6d6e04c6,
5391            fidl::encoding::DynamicFlags::FLEXIBLE,
5392        )
5393    }
5394
5395    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
5396        self.client.send::<NodeSetNameRequest>(
5397            payload,
5398            0xb41f1624f48c1e9,
5399            fidl::encoding::DynamicFlags::FLEXIBLE,
5400        )
5401    }
5402
5403    fn r#set_debug_client_info(
5404        &self,
5405        mut payload: &NodeSetDebugClientInfoRequest,
5406    ) -> Result<(), fidl::Error> {
5407        self.client.send::<NodeSetDebugClientInfoRequest>(
5408            payload,
5409            0x5cde8914608d99b1,
5410            fidl::encoding::DynamicFlags::FLEXIBLE,
5411        )
5412    }
5413
5414    fn r#set_debug_timeout_log_deadline(
5415        &self,
5416        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
5417    ) -> Result<(), fidl::Error> {
5418        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5419            payload,
5420            0x716b0af13d5c0806,
5421            fidl::encoding::DynamicFlags::FLEXIBLE,
5422        )
5423    }
5424
5425    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5426        self.client.send::<fidl::encoding::EmptyPayload>(
5427            (),
5428            0x5209c77415b4dfad,
5429            fidl::encoding::DynamicFlags::FLEXIBLE,
5430        )
5431    }
5432
5433    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
5434        NodeGetNodeRefResponse,
5435        fdomain_client::fidl::FDomainResourceDialect,
5436    >;
5437    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5438        fn _decode(
5439            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5440        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
5441            let _response = fidl::client::decode_transaction_body::<
5442                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
5443                fdomain_client::fidl::FDomainResourceDialect,
5444                0x5b3d0e51614df053,
5445            >(_buf?)?
5446            .into_result_fdomain::<BufferCollectionTokenMarker>("get_node_ref")?;
5447            Ok(_response)
5448        }
5449        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
5450            (),
5451            0x5b3d0e51614df053,
5452            fidl::encoding::DynamicFlags::FLEXIBLE,
5453            _decode,
5454        )
5455    }
5456
5457    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5458        NodeIsAlternateForResult,
5459        fdomain_client::fidl::FDomainResourceDialect,
5460    >;
5461    fn r#is_alternate_for(
5462        &self,
5463        mut payload: NodeIsAlternateForRequest,
5464    ) -> Self::IsAlternateForResponseFut {
5465        fn _decode(
5466            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5467        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5468            let _response = fidl::client::decode_transaction_body::<
5469                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
5470                fdomain_client::fidl::FDomainResourceDialect,
5471                0x3a58e00157e0825,
5472            >(_buf?)?
5473            .into_result_fdomain::<BufferCollectionTokenMarker>("is_alternate_for")?;
5474            Ok(_response.map(|x| x))
5475        }
5476        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5477            &mut payload,
5478            0x3a58e00157e0825,
5479            fidl::encoding::DynamicFlags::FLEXIBLE,
5480            _decode,
5481        )
5482    }
5483
5484    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
5485        NodeGetBufferCollectionIdResponse,
5486        fdomain_client::fidl::FDomainResourceDialect,
5487    >;
5488    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
5489        fn _decode(
5490            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5491        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
5492            let _response = fidl::client::decode_transaction_body::<
5493                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
5494                fdomain_client::fidl::FDomainResourceDialect,
5495                0x77d19a494b78ba8c,
5496            >(_buf?)?
5497            .into_result_fdomain::<BufferCollectionTokenMarker>("get_buffer_collection_id")?;
5498            Ok(_response)
5499        }
5500        self.client.send_query_and_decode::<
5501            fidl::encoding::EmptyPayload,
5502            NodeGetBufferCollectionIdResponse,
5503        >(
5504            (),
5505            0x77d19a494b78ba8c,
5506            fidl::encoding::DynamicFlags::FLEXIBLE,
5507            _decode,
5508        )
5509    }
5510
5511    fn r#set_weak(&self) -> Result<(), fidl::Error> {
5512        self.client.send::<fidl::encoding::EmptyPayload>(
5513            (),
5514            0x22dd3ea514eeffe1,
5515            fidl::encoding::DynamicFlags::FLEXIBLE,
5516        )
5517    }
5518
5519    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
5520        self.client.send::<NodeSetWeakOkRequest>(
5521            &mut payload,
5522            0x38a44fc4d7724be9,
5523            fidl::encoding::DynamicFlags::FLEXIBLE,
5524        )
5525    }
5526
5527    fn r#attach_node_tracking(
5528        &self,
5529        mut payload: NodeAttachNodeTrackingRequest,
5530    ) -> Result<(), fidl::Error> {
5531        self.client.send::<NodeAttachNodeTrackingRequest>(
5532            &mut payload,
5533            0x3f22f2a293d3cdac,
5534            fidl::encoding::DynamicFlags::FLEXIBLE,
5535        )
5536    }
5537
5538    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
5539        BufferCollectionTokenDuplicateSyncResponse,
5540        fdomain_client::fidl::FDomainResourceDialect,
5541    >;
5542    fn r#duplicate_sync(
5543        &self,
5544        mut payload: &BufferCollectionTokenDuplicateSyncRequest,
5545    ) -> Self::DuplicateSyncResponseFut {
5546        fn _decode(
5547            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5548        ) -> Result<BufferCollectionTokenDuplicateSyncResponse, fidl::Error> {
5549            let _response = fidl::client::decode_transaction_body::<
5550                fidl::encoding::FlexibleType<BufferCollectionTokenDuplicateSyncResponse>,
5551                fdomain_client::fidl::FDomainResourceDialect,
5552                0x1c1af9919d1ca45c,
5553            >(_buf?)?
5554            .into_result_fdomain::<BufferCollectionTokenMarker>("duplicate_sync")?;
5555            Ok(_response)
5556        }
5557        self.client.send_query_and_decode::<
5558            BufferCollectionTokenDuplicateSyncRequest,
5559            BufferCollectionTokenDuplicateSyncResponse,
5560        >(
5561            payload,
5562            0x1c1af9919d1ca45c,
5563            fidl::encoding::DynamicFlags::FLEXIBLE,
5564            _decode,
5565        )
5566    }
5567
5568    fn r#duplicate(
5569        &self,
5570        mut payload: BufferCollectionTokenDuplicateRequest,
5571    ) -> Result<(), fidl::Error> {
5572        self.client.send::<BufferCollectionTokenDuplicateRequest>(
5573            &mut payload,
5574            0x73e78f92ee7fb887,
5575            fidl::encoding::DynamicFlags::FLEXIBLE,
5576        )
5577    }
5578
5579    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5580        self.client.send::<fidl::encoding::EmptyPayload>(
5581            (),
5582            0x228acf979254df8b,
5583            fidl::encoding::DynamicFlags::FLEXIBLE,
5584        )
5585    }
5586
5587    fn r#create_buffer_collection_token_group(
5588        &self,
5589        mut payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
5590    ) -> Result<(), fidl::Error> {
5591        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
5592            &mut payload,
5593            0x30f8d48e77bd36f2,
5594            fidl::encoding::DynamicFlags::FLEXIBLE,
5595        )
5596    }
5597}
5598
5599pub struct BufferCollectionTokenEventStream {
5600    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5601}
5602
5603impl std::marker::Unpin for BufferCollectionTokenEventStream {}
5604
5605impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
5606    fn is_terminated(&self) -> bool {
5607        self.event_receiver.is_terminated()
5608    }
5609}
5610
5611impl futures::Stream for BufferCollectionTokenEventStream {
5612    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
5613
5614    fn poll_next(
5615        mut self: std::pin::Pin<&mut Self>,
5616        cx: &mut std::task::Context<'_>,
5617    ) -> std::task::Poll<Option<Self::Item>> {
5618        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5619            &mut self.event_receiver,
5620            cx
5621        )?) {
5622            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
5623            None => std::task::Poll::Ready(None),
5624        }
5625    }
5626}
5627
5628#[derive(Debug)]
5629pub enum BufferCollectionTokenEvent {
5630    #[non_exhaustive]
5631    _UnknownEvent {
5632        /// Ordinal of the event that was sent.
5633        ordinal: u64,
5634    },
5635}
5636
5637impl BufferCollectionTokenEvent {
5638    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
5639    fn decode(
5640        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5641    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
5642        let (bytes, _handles) = buf.split_mut();
5643        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5644        debug_assert_eq!(tx_header.tx_id, 0);
5645        match tx_header.ordinal {
5646            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5647                Ok(BufferCollectionTokenEvent::_UnknownEvent {
5648                    ordinal: tx_header.ordinal,
5649                })
5650            }
5651            _ => Err(fidl::Error::UnknownOrdinal {
5652                ordinal: tx_header.ordinal,
5653                protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5654            })
5655        }
5656    }
5657}
5658
5659/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollectionToken.
5660pub struct BufferCollectionTokenRequestStream {
5661    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5662    is_terminated: bool,
5663}
5664
5665impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
5666
5667impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
5668    fn is_terminated(&self) -> bool {
5669        self.is_terminated
5670    }
5671}
5672
5673impl fdomain_client::fidl::RequestStream for BufferCollectionTokenRequestStream {
5674    type Protocol = BufferCollectionTokenMarker;
5675    type ControlHandle = BufferCollectionTokenControlHandle;
5676
5677    fn from_channel(channel: fdomain_client::Channel) -> Self {
5678        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5679    }
5680
5681    fn control_handle(&self) -> Self::ControlHandle {
5682        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
5683    }
5684
5685    fn into_inner(
5686        self,
5687    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
5688    {
5689        (self.inner, self.is_terminated)
5690    }
5691
5692    fn from_inner(
5693        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5694        is_terminated: bool,
5695    ) -> Self {
5696        Self { inner, is_terminated }
5697    }
5698}
5699
5700impl futures::Stream for BufferCollectionTokenRequestStream {
5701    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
5702
5703    fn poll_next(
5704        mut self: std::pin::Pin<&mut Self>,
5705        cx: &mut std::task::Context<'_>,
5706    ) -> std::task::Poll<Option<Self::Item>> {
5707        let this = &mut *self;
5708        if this.inner.check_shutdown(cx) {
5709            this.is_terminated = true;
5710            return std::task::Poll::Ready(None);
5711        }
5712        if this.is_terminated {
5713            panic!("polled BufferCollectionTokenRequestStream after completion");
5714        }
5715        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5716            |bytes, handles| {
5717                match this.inner.channel().read_etc(cx, bytes, handles) {
5718                    std::task::Poll::Ready(Ok(())) => {}
5719                    std::task::Poll::Pending => return std::task::Poll::Pending,
5720                    std::task::Poll::Ready(Err(None)) => {
5721                        this.is_terminated = true;
5722                        return std::task::Poll::Ready(None);
5723                    }
5724                    std::task::Poll::Ready(Err(Some(e))) => {
5725                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5726                            e.into(),
5727                        ))));
5728                    }
5729                }
5730
5731                // A message has been received from the channel
5732                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5733
5734                std::task::Poll::Ready(Some(match header.ordinal {
5735                0x11ac2555cf575b54 => {
5736                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5737                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5738                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5739                    let control_handle = BufferCollectionTokenControlHandle {
5740                        inner: this.inner.clone(),
5741                    };
5742                    Ok(BufferCollectionTokenRequest::Sync {
5743                        responder: BufferCollectionTokenSyncResponder {
5744                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5745                            tx_id: header.tx_id,
5746                        },
5747                    })
5748                }
5749                0x6a5cae7d6d6e04c6 => {
5750                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5751                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5752                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5753                    let control_handle = BufferCollectionTokenControlHandle {
5754                        inner: this.inner.clone(),
5755                    };
5756                    Ok(BufferCollectionTokenRequest::Release {
5757                        control_handle,
5758                    })
5759                }
5760                0xb41f1624f48c1e9 => {
5761                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5762                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
5763                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5764                    let control_handle = BufferCollectionTokenControlHandle {
5765                        inner: this.inner.clone(),
5766                    };
5767                    Ok(BufferCollectionTokenRequest::SetName {payload: req,
5768                        control_handle,
5769                    })
5770                }
5771                0x5cde8914608d99b1 => {
5772                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5773                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
5774                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5775                    let control_handle = BufferCollectionTokenControlHandle {
5776                        inner: this.inner.clone(),
5777                    };
5778                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {payload: req,
5779                        control_handle,
5780                    })
5781                }
5782                0x716b0af13d5c0806 => {
5783                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5784                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
5785                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5786                    let control_handle = BufferCollectionTokenControlHandle {
5787                        inner: this.inner.clone(),
5788                    };
5789                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {payload: req,
5790                        control_handle,
5791                    })
5792                }
5793                0x5209c77415b4dfad => {
5794                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5795                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5796                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5797                    let control_handle = BufferCollectionTokenControlHandle {
5798                        inner: this.inner.clone(),
5799                    };
5800                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
5801                        control_handle,
5802                    })
5803                }
5804                0x5b3d0e51614df053 => {
5805                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5806                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5807                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5808                    let control_handle = BufferCollectionTokenControlHandle {
5809                        inner: this.inner.clone(),
5810                    };
5811                    Ok(BufferCollectionTokenRequest::GetNodeRef {
5812                        responder: BufferCollectionTokenGetNodeRefResponder {
5813                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5814                            tx_id: header.tx_id,
5815                        },
5816                    })
5817                }
5818                0x3a58e00157e0825 => {
5819                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5820                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
5821                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5822                    let control_handle = BufferCollectionTokenControlHandle {
5823                        inner: this.inner.clone(),
5824                    };
5825                    Ok(BufferCollectionTokenRequest::IsAlternateFor {payload: req,
5826                        responder: BufferCollectionTokenIsAlternateForResponder {
5827                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5828                            tx_id: header.tx_id,
5829                        },
5830                    })
5831                }
5832                0x77d19a494b78ba8c => {
5833                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5834                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5835                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5836                    let control_handle = BufferCollectionTokenControlHandle {
5837                        inner: this.inner.clone(),
5838                    };
5839                    Ok(BufferCollectionTokenRequest::GetBufferCollectionId {
5840                        responder: BufferCollectionTokenGetBufferCollectionIdResponder {
5841                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5842                            tx_id: header.tx_id,
5843                        },
5844                    })
5845                }
5846                0x22dd3ea514eeffe1 => {
5847                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5848                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5849                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5850                    let control_handle = BufferCollectionTokenControlHandle {
5851                        inner: this.inner.clone(),
5852                    };
5853                    Ok(BufferCollectionTokenRequest::SetWeak {
5854                        control_handle,
5855                    })
5856                }
5857                0x38a44fc4d7724be9 => {
5858                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5859                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
5860                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
5861                    let control_handle = BufferCollectionTokenControlHandle {
5862                        inner: this.inner.clone(),
5863                    };
5864                    Ok(BufferCollectionTokenRequest::SetWeakOk {payload: req,
5865                        control_handle,
5866                    })
5867                }
5868                0x3f22f2a293d3cdac => {
5869                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5870                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
5871                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
5872                    let control_handle = BufferCollectionTokenControlHandle {
5873                        inner: this.inner.clone(),
5874                    };
5875                    Ok(BufferCollectionTokenRequest::AttachNodeTracking {payload: req,
5876                        control_handle,
5877                    })
5878                }
5879                0x1c1af9919d1ca45c => {
5880                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5881                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
5882                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5883                    let control_handle = BufferCollectionTokenControlHandle {
5884                        inner: this.inner.clone(),
5885                    };
5886                    Ok(BufferCollectionTokenRequest::DuplicateSync {payload: req,
5887                        responder: BufferCollectionTokenDuplicateSyncResponder {
5888                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5889                            tx_id: header.tx_id,
5890                        },
5891                    })
5892                }
5893                0x73e78f92ee7fb887 => {
5894                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5895                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fdomain_client::fidl::FDomainResourceDialect);
5896                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
5897                    let control_handle = BufferCollectionTokenControlHandle {
5898                        inner: this.inner.clone(),
5899                    };
5900                    Ok(BufferCollectionTokenRequest::Duplicate {payload: req,
5901                        control_handle,
5902                    })
5903                }
5904                0x228acf979254df8b => {
5905                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5906                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5907                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5908                    let control_handle = BufferCollectionTokenControlHandle {
5909                        inner: this.inner.clone(),
5910                    };
5911                    Ok(BufferCollectionTokenRequest::SetDispensable {
5912                        control_handle,
5913                    })
5914                }
5915                0x30f8d48e77bd36f2 => {
5916                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5917                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fdomain_client::fidl::FDomainResourceDialect);
5918                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
5919                    let control_handle = BufferCollectionTokenControlHandle {
5920                        inner: this.inner.clone(),
5921                    };
5922                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {payload: req,
5923                        control_handle,
5924                    })
5925                }
5926                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5927                    Ok(BufferCollectionTokenRequest::_UnknownMethod {
5928                        ordinal: header.ordinal,
5929                        control_handle: BufferCollectionTokenControlHandle { inner: this.inner.clone() },
5930                        method_type: fidl::MethodType::OneWay,
5931                    })
5932                }
5933                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5934                    this.inner.send_framework_err(
5935                        fidl::encoding::FrameworkErr::UnknownMethod,
5936                        header.tx_id,
5937                        header.ordinal,
5938                        header.dynamic_flags(),
5939                        (bytes, handles),
5940                    )?;
5941                    Ok(BufferCollectionTokenRequest::_UnknownMethod {
5942                        ordinal: header.ordinal,
5943                        control_handle: BufferCollectionTokenControlHandle { inner: this.inner.clone() },
5944                        method_type: fidl::MethodType::TwoWay,
5945                    })
5946                }
5947                _ => Err(fidl::Error::UnknownOrdinal {
5948                    ordinal: header.ordinal,
5949                    protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5950                }),
5951            }))
5952            },
5953        )
5954    }
5955}
5956
5957/// A [`fuchsia.sysmem2/BufferCollectionToken`] is not a buffer collection, but
5958/// rather is a way to identify a specific potential shared buffer collection,
5959/// and a way to distribute that potential shared buffer collection to
5960/// additional participants prior to the buffer collection allocating any
5961/// buffers.
5962///
5963/// Epitaphs are not used in this protocol.
5964///
5965/// We use a channel for the `BufferCollectionToken` instead of a single
5966/// `eventpair` (pair) because this way we can detect error conditions like a
5967/// participant failing mid-create.
5968#[derive(Debug)]
5969pub enum BufferCollectionTokenRequest {
5970    /// Ensure that previous messages have been received server side. This is
5971    /// particularly useful after previous messages that created new tokens,
5972    /// because a token must be known to the sysmem server before sending the
5973    /// token to another participant.
5974    ///
5975    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
5976    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
5977    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
5978    /// to mitigate the possibility of a hostile/fake
5979    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
5980    /// Another way is to pass the token to
5981    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
5982    /// the token as part of exchanging it for a
5983    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
5984    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
5985    /// of stalling.
5986    ///
5987    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
5988    /// and then starting and completing a `Sync`, it's then safe to send the
5989    /// `BufferCollectionToken` client ends to other participants knowing the
5990    /// server will recognize the tokens when they're sent by the other
5991    /// participants to sysmem in a
5992    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
5993    /// efficient way to create tokens while avoiding unnecessary round trips.
5994    ///
5995    /// Other options include waiting for each
5996    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
5997    /// individually (using separate call to `Sync` after each), or calling
5998    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
5999    /// converted to a `BufferCollection` via
6000    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
6001    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
6002    /// the sync step and can create multiple tokens at once.
6003    Sync { responder: BufferCollectionTokenSyncResponder },
6004    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
6005    ///
6006    /// Normally a participant will convert a `BufferCollectionToken` into a
6007    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
6008    /// `Release` via the token (and then close the channel immediately or
6009    /// shortly later in response to server closing the server end), which
6010    /// avoids causing buffer collection failure. Without a prior `Release`,
6011    /// closing the `BufferCollectionToken` client end will cause buffer
6012    /// collection failure.
6013    ///
6014    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
6015    ///
6016    /// By default the server handles unexpected closure of a
6017    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
6018    /// first) by failing the buffer collection. Partly this is to expedite
6019    /// closing VMO handles to reclaim memory when any participant fails. If a
6020    /// participant would like to cleanly close a `BufferCollection` without
6021    /// causing buffer collection failure, the participant can send `Release`
6022    /// before closing the `BufferCollection` client end. The `Release` can
6023    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
6024    /// buffer collection won't require constraints from this node in order to
6025    /// allocate. If after `SetConstraints`, the constraints are retained and
6026    /// aggregated, despite the lack of `BufferCollection` connection at the
6027    /// time of constraints aggregation.
6028    ///
6029    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
6030    ///
6031    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
6032    /// end (without `Release` first) will trigger failure of the buffer
6033    /// collection. To close a `BufferCollectionTokenGroup` channel without
6034    /// failing the buffer collection, ensure that AllChildrenPresent() has been
6035    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
6036    /// client end.
6037    ///
6038    /// If `Release` occurs before
6039    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
6040    /// buffer collection will fail (triggered by reception of `Release` without
6041    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
6042    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
6043    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
6044    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
6045    /// close requires `AllChildrenPresent` (if not already sent), then
6046    /// `Release`, then close client end.
6047    ///
6048    /// If `Release` occurs after `AllChildrenPresent`, the children and all
6049    /// their constraints remain intact (just as they would if the
6050    /// `BufferCollectionTokenGroup` channel had remained open), and the client
6051    /// end close doesn't trigger buffer collection failure.
6052    ///
6053    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
6054    ///
6055    /// For brevity, the per-channel-protocol paragraphs above ignore the
6056    /// separate failure domain created by
6057    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
6058    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
6059    /// unexpectedly closes (without `Release` first) and that client end is
6060    /// under a failure domain, instead of failing the whole buffer collection,
6061    /// the failure domain is failed, but the buffer collection itself is
6062    /// isolated from failure of the failure domain. Such failure domains can be
6063    /// nested, in which case only the inner-most failure domain in which the
6064    /// `Node` resides fails.
6065    Release { control_handle: BufferCollectionTokenControlHandle },
6066    /// Set a name for VMOs in this buffer collection.
6067    ///
6068    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
6069    /// will be truncated to fit. The name of the vmo will be suffixed with the
6070    /// buffer index within the collection (if the suffix fits within
6071    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
6072    /// listed in the inspect data.
6073    ///
6074    /// The name only affects VMOs allocated after the name is set; this call
6075    /// does not rename existing VMOs. If multiple clients set different names
6076    /// then the larger priority value will win. Setting a new name with the
6077    /// same priority as a prior name doesn't change the name.
6078    ///
6079    /// All table fields are currently required.
6080    ///
6081    /// + request `priority` The name is only set if this is the first `SetName`
6082    ///   or if `priority` is greater than any previous `priority` value in
6083    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
6084    /// + request `name` The name for VMOs created under this buffer collection.
6085    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionTokenControlHandle },
6086    /// Set information about the current client that can be used by sysmem to
6087    /// help diagnose leaking memory and allocation stalls waiting for a
6088    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
6089    ///
6090    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
6091    /// `Node`(s) derived from this `Node`, unless overriden by
6092    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
6093    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
6094    ///
6095    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
6096    /// `Allocator` is the most efficient way to ensure that all
6097    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
6098    /// set, and is also more efficient than separately sending the same debug
6099    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
6100    /// created [`fuchsia.sysmem2/Node`].
6101    ///
6102    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
6103    /// indicate which client is closing their channel first, leading to subtree
6104    /// failure (which can be normal if the purpose of the subtree is over, but
6105    /// if happening earlier than expected, the client-channel-specific name can
6106    /// help diagnose where the failure is first coming from, from sysmem's
6107    /// point of view).
6108    ///
6109    /// All table fields are currently required.
6110    ///
6111    /// + request `name` This can be an arbitrary string, but the current
6112    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
6113    /// + request `id` This can be an arbitrary id, but the current process ID
6114    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
6115    SetDebugClientInfo {
6116        payload: NodeSetDebugClientInfoRequest,
6117        control_handle: BufferCollectionTokenControlHandle,
6118    },
6119    /// Sysmem logs a warning if sysmem hasn't seen
6120    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
6121    /// within 5 seconds after creation of a new collection.
6122    ///
6123    /// Clients can call this method to change when the log is printed. If
6124    /// multiple client set the deadline, it's unspecified which deadline will
6125    /// take effect.
6126    ///
6127    /// In most cases the default works well.
6128    ///
6129    /// All table fields are currently required.
6130    ///
6131    /// + request `deadline` The time at which sysmem will start trying to log
6132    ///   the warning, unless all constraints are with sysmem by then.
6133    SetDebugTimeoutLogDeadline {
6134        payload: NodeSetDebugTimeoutLogDeadlineRequest,
6135        control_handle: BufferCollectionTokenControlHandle,
6136    },
6137    /// This enables verbose logging for the buffer collection.
6138    ///
6139    /// Verbose logging includes constraints set via
6140    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
6141    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
6142    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
6143    /// the tree of `Node`(s).
6144    ///
6145    /// Normally sysmem prints only a single line complaint when aggregation
6146    /// fails, with just the specific detailed reason that aggregation failed,
6147    /// with little surrounding context.  While this is often enough to diagnose
6148    /// a problem if only a small change was made and everything was working
6149    /// before the small change, it's often not particularly helpful for getting
6150    /// a new buffer collection to work for the first time.  Especially with
6151    /// more complex trees of nodes, involving things like
6152    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
6153    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
6154    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
6155    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
6156    /// looks like and why it's failing a logical allocation, or why a tree or
6157    /// subtree is failing sooner than expected.
6158    ///
6159    /// The intent of the extra logging is to be acceptable from a performance
6160    /// point of view, under the assumption that verbose logging is only enabled
6161    /// on a low number of buffer collections. If we're not tracking down a bug,
6162    /// we shouldn't send this message.
6163    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
6164    /// This gets a handle that can be used as a parameter to
6165    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
6166    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
6167    /// client obtained this handle from this `Node`.
6168    ///
6169    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
6170    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
6171    /// despite the two calls typically being on different channels.
6172    ///
6173    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
6174    ///
6175    /// All table fields are currently required.
6176    ///
6177    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
6178    ///   different `Node` channel, to prove that the client obtained the handle
6179    ///   from this `Node`.
6180    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
6181    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
6182    /// rooted at a different child token of a common parent
6183    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
6184    /// passed-in `node_ref`.
6185    ///
6186    /// This call is for assisting with admission control de-duplication, and
6187    /// with debugging.
6188    ///
6189    /// The `node_ref` must be obtained using
6190    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
6191    ///
6192    /// The `node_ref` can be a duplicated handle; it's not necessary to call
6193    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
6194    ///
6195    /// If a calling token may not actually be a valid token at all due to a
6196    /// potentially hostile/untrusted provider of the token, call
6197    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
6198    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
6199    /// never responds due to a calling token not being a real token (not really
6200    /// talking to sysmem).  Another option is to call
6201    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
6202    /// which also validates the token along with converting it to a
6203    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
6204    ///
6205    /// All table fields are currently required.
6206    ///
6207    /// - response `is_alternate`
6208    ///   - true: The first parent node in common between the calling node and
6209    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
6210    ///     that the calling `Node` and the `node_ref` `Node` will not have both
6211    ///     their constraints apply - rather sysmem will choose one or the other
6212    ///     of the constraints - never both.  This is because only one child of
6213    ///     a `BufferCollectionTokenGroup` is selected during logical
6214    ///     allocation, with only that one child's subtree contributing to
6215    ///     constraints aggregation.
6216    ///   - false: The first parent node in common between the calling `Node`
6217    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
6218    ///     Currently, this means the first parent node in common is a
6219    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
6220    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
6221    ///     `Node` may have both their constraints apply during constraints
6222    ///     aggregation of the logical allocation, if both `Node`(s) are
6223    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
6224    ///     this case, there is no `BufferCollectionTokenGroup` that will
6225    ///     directly prevent the two `Node`(s) from both being selected and
6226    ///     their constraints both aggregated, but even when false, one or both
6227    ///     `Node`(s) may still be eliminated from consideration if one or both
6228    ///     `Node`(s) has a direct or indirect parent
6229    ///     `BufferCollectionTokenGroup` which selects a child subtree other
6230    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
6231    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
6232    ///   associated with the same buffer collection as the calling `Node`.
6233    ///   Another reason for this error is if the `node_ref` is an
6234    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
6235    ///   a real `node_ref` obtained from `GetNodeRef`.
6236    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
6237    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
6238    ///   the needed rights expected on a real `node_ref`.
6239    /// * No other failing status codes are returned by this call.  However,
6240    ///   sysmem may add additional codes in future, so the client should have
6241    ///   sensible default handling for any failing status code.
6242    IsAlternateFor {
6243        payload: NodeIsAlternateForRequest,
6244        responder: BufferCollectionTokenIsAlternateForResponder,
6245    },
6246    /// Get the buffer collection ID. This ID is also available from
6247    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
6248    /// within the collection).
6249    ///
6250    /// This call is mainly useful in situations where we can't convey a
6251    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
6252    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
6253    /// handle, which can be joined back up with a `BufferCollection` client end
6254    /// that was created via a different path. Prefer to convey a
6255    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
6256    ///
6257    /// Trusting a `buffer_collection_id` value from a source other than sysmem
6258    /// is analogous to trusting a koid value from a source other than zircon.
6259    /// Both should be avoided unless really necessary, and both require
6260    /// caution. In some situations it may be reasonable to refer to a
6261    /// pre-established `BufferCollection` by `buffer_collection_id` via a
6262    /// protocol for efficiency reasons, but an incoming value purporting to be
6263    /// a `buffer_collection_id` is not sufficient alone to justify granting the
6264    /// sender of the `buffer_collection_id` any capability. The sender must
6265    /// first prove to a receiver that the sender has/had a VMO or has/had a
6266    /// `BufferCollectionToken` to the same collection by sending a handle that
6267    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
6268    /// `buffer_collection_id` value. The receiver should take care to avoid
6269    /// assuming that a sender had a `BufferCollectionToken` in cases where the
6270    /// sender has only proven that the sender had a VMO.
6271    ///
6272    /// - response `buffer_collection_id` This ID is unique per buffer
6273    ///   collection per boot. Each buffer is uniquely identified by the
6274    ///   `buffer_collection_id` and `buffer_index` together.
6275    GetBufferCollectionId { responder: BufferCollectionTokenGetBufferCollectionIdResponder },
6276    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
6277    /// created after this message to weak, which means that a client's `Node`
6278    /// client end (or a child created after this message) is not alone
6279    /// sufficient to keep allocated VMOs alive.
6280    ///
6281    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
6282    /// `close_weak_asap`.
6283    ///
6284    /// This message is only permitted before the `Node` becomes ready for
6285    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
6286    ///   * `BufferCollectionToken`: any time
6287    ///   * `BufferCollection`: before `SetConstraints`
6288    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
6289    ///
6290    /// Currently, no conversion from strong `Node` to weak `Node` after ready
6291    /// for allocation is provided, but a client can simulate that by creating
6292    /// an additional `Node` before allocation and setting that additional
6293    /// `Node` to weak, and then potentially at some point later sending
6294    /// `Release` and closing the client end of the client's strong `Node`, but
6295    /// keeping the client's weak `Node`.
6296    ///
6297    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
6298    /// collection failure (all `Node` client end(s) will see
6299    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
6300    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
6301    /// this situation until all `Node`(s) are ready for allocation. For initial
6302    /// allocation to succeed, at least one strong `Node` is required to exist
6303    /// at allocation time, but after that client receives VMO handles, that
6304    /// client can `BufferCollection.Release` and close the client end without
6305    /// causing this type of failure.
6306    ///
6307    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
6308    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
6309    /// separately as appropriate.
6310    SetWeak { control_handle: BufferCollectionTokenControlHandle },
6311    /// This indicates to sysmem that the client is prepared to pay attention to
6312    /// `close_weak_asap`.
6313    ///
6314    /// If sent, this message must be before
6315    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
6316    ///
6317    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
6318    /// send this message before `WaitForAllBuffersAllocated`, or a parent
6319    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
6320    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
6321    /// trigger buffer collection failure.
6322    ///
6323    /// This message is necessary because weak sysmem VMOs have not always been
6324    /// a thing, so older clients are not aware of the need to pay attention to
6325    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
6326    /// sysmem weak VMO handles asap. By having this message and requiring
6327    /// participants to indicate their acceptance of this aspect of the overall
6328    /// protocol, we avoid situations where an older client is delivered a weak
6329    /// VMO without any way for sysmem to get that VMO to close quickly later
6330    /// (and on a per-buffer basis).
6331    ///
6332    /// A participant that doesn't handle `close_weak_asap` and also doesn't
6333    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
6334    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
6335    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
6336    /// same participant has a child/delegate which does retrieve VMOs, that
6337    /// child/delegate will need to send `SetWeakOk` before
6338    /// `WaitForAllBuffersAllocated`.
6339    ///
6340    /// + request `for_child_nodes_also` If present and true, this means direct
6341    ///   child nodes of this node created after this message plus all
6342    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
6343    ///   those nodes. Any child node of this node that was created before this
6344    ///   message is not included. This setting is "sticky" in the sense that a
6345    ///   subsequent `SetWeakOk` without this bool set to true does not reset
6346    ///   the server-side bool. If this creates a problem for a participant, a
6347    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
6348    ///   tokens instead, as appropriate. A participant should only set
6349    ///   `for_child_nodes_also` true if the participant can really promise to
6350    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
6351    ///   weak VMO handles held by participants holding the corresponding child
6352    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
6353    ///   which are using sysmem(1) can be weak, despite the clients of those
6354    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
6355    ///   direct way to find out about `close_weak_asap`. This only applies to
6356    ///   descendents of this `Node` which are using sysmem(1), not to this
6357    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
6358    ///   token, which will fail allocation unless an ancestor of this `Node`
6359    ///   specified `for_child_nodes_also` true.
6360    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: BufferCollectionTokenControlHandle },
6361    /// The server_end will be closed after this `Node` and any child nodes have
6362    /// have released their buffer counts, making those counts available for
6363    /// reservation by a different `Node` via
6364    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
6365    ///
6366    /// The `Node` buffer counts may not be released until the entire tree of
6367    /// `Node`(s) is closed or failed, because
6368    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
6369    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
6370    /// `Node` buffer counts remain reserved until the orphaned node is later
6371    /// cleaned up.
6372    ///
6373    /// If the `Node` exceeds a fairly large number of attached eventpair server
6374    /// ends, a log message will indicate this and the `Node` (and the
6375    /// appropriate) sub-tree will fail.
6376    ///
6377    /// The `server_end` will remain open when
6378    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
6379    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
6380    /// [`fuchsia.sysmem2/BufferCollection`].
6381    ///
6382    /// This message can also be used with a
6383    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
6384    AttachNodeTracking {
6385        payload: NodeAttachNodeTrackingRequest,
6386        control_handle: BufferCollectionTokenControlHandle,
6387    },
6388    /// Create additional [`fuchsia.sysmem2/BufferCollectionToken`](s) from this
6389    /// one, referring to the same buffer collection.
6390    ///
6391    /// The created tokens are children of this token in the
6392    /// [`fuchsia.sysmem2/Node`] heirarchy.
6393    ///
6394    /// This method can be used to add more participants, by transferring the
6395    /// newly created tokens to additional participants.
6396    ///
6397    /// A new token will be returned for each entry in the
6398    /// `rights_attenuation_masks` array.
6399    ///
6400    /// If the called token may not actually be a valid token due to a
6401    /// potentially hostile/untrusted provider of the token, consider using
6402    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
6403    /// instead of potentially getting stuck indefinitely if
6404    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] never responds
6405    /// due to the calling token not being a real token.
6406    ///
6407    /// In contrast to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], no
6408    /// separate [`fuchsia.sysmem2/Node.Sync`] is needed after calling this
6409    /// method, because the sync step is included in this call, at the cost of a
6410    /// round trip during this call.
6411    ///
6412    /// All tokens must be turned in to sysmem via
6413    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
6414    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
6415    /// successfully allocate buffers (or to logically allocate buffers in the
6416    /// case of subtrees involving
6417    /// [`fuchsia.sysmem2/BufferCollectionToken.AttachToken`]).
6418    ///
6419    /// All table fields are currently required.
6420    ///
6421    /// + request `rights_attenuation_mask` In each entry of
6422    ///   `rights_attenuation_masks`, rights bits that are zero will be absent
6423    ///   in the buffer VMO rights obtainable via the corresponding returned
6424    ///   token. This allows an initiator or intermediary participant to
6425    ///   attenuate the rights available to a participant. This does not allow a
6426    ///   participant to gain rights that the participant doesn't already have.
6427    ///   The value `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no
6428    ///   attenuation should be applied.
6429    /// - response `tokens` The client ends of each newly created token.
6430    DuplicateSync {
6431        payload: BufferCollectionTokenDuplicateSyncRequest,
6432        responder: BufferCollectionTokenDuplicateSyncResponder,
6433    },
6434    /// Create an additional [`fuchsia.sysmem2/BufferCollectionToken`] from this
6435    /// one, referring to the same buffer collection.
6436    ///
6437    /// The created token is a child of this token in the
6438    /// [`fuchsia.sysmem2/Node`] heirarchy.
6439    ///
6440    /// This method can be used to add a participant, by transferring the newly
6441    /// created token to another participant.
6442    ///
6443    /// This one-way message can be used instead of the two-way
6444    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] FIDL call in
6445    /// performance sensitive cases where it would be undesireable to wait for
6446    /// sysmem to respond to
6447    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or when the
6448    /// client code isn't structured to make it easy to duplicate all the needed
6449    /// tokens at once.
6450    ///
6451    /// After sending one or more `Duplicate` messages, and before sending the
6452    /// newly created child tokens to other participants (or to other
6453    /// [`fuchsia.sysmem2/Allocator`] channels), the client must send a
6454    /// [`fuchsia.sysmem2/Node.Sync`] and wait for the `Sync` response. The
6455    /// `Sync` call can be made on the token, or on the `BufferCollection`
6456    /// obtained by passing this token to `BindSharedCollection`.  Either will
6457    /// ensure that the server knows about the tokens created via `Duplicate`
6458    /// before the other participant sends the token to the server via separate
6459    /// `Allocator` channel.
6460    ///
6461    /// All tokens must be turned in via
6462    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
6463    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
6464    /// successfully allocate buffers.
6465    ///
6466    /// All table fields are currently required.
6467    ///
6468    /// + request `rights_attenuation_mask` The rights bits that are zero in
6469    ///   this mask will be absent in the buffer VMO rights obtainable via the
6470    ///   client end of `token_request`. This allows an initiator or
6471    ///   intermediary participant to attenuate the rights available to a
6472    ///   delegate participant. This does not allow a participant to gain rights
6473    ///   that the participant doesn't already have. The value
6474    ///   `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no attenuation
6475    ///   should be applied.
6476    ///   + These values for rights_attenuation_mask result in no attenuation:
6477    ///     + `ZX_RIGHT_SAME_RIGHTS` (preferred)
6478    ///     + 0xFFFFFFFF (this is reasonable when an attenuation mask is
6479    ///       computed)
6480    ///     + 0 (deprecated - do not use 0 - an ERROR will go to the log)
6481    /// + request `token_request` is the server end of a `BufferCollectionToken`
6482    ///   channel. The client end of this channel acts as another participant in
6483    ///   the shared buffer collection.
6484    Duplicate {
6485        payload: BufferCollectionTokenDuplicateRequest,
6486        control_handle: BufferCollectionTokenControlHandle,
6487    },
6488    /// Set this [`fuchsia.sysmem2/BufferCollectionToken`] to dispensable.
6489    ///
6490    /// When the `BufferCollectionToken` is converted to a
6491    /// [`fuchsia.sysmem2/BufferCollection`], the dispensable status applies to
6492    /// the `BufferCollection` also.
6493    ///
6494    /// Normally, if a client closes a [`fuchsia.sysmem2/BufferCollection`]
6495    /// client end without having sent
6496    /// [`fuchsia.sysmem2/BufferCollection.Release`] first, the
6497    /// `BufferCollection` [`fuchisa.sysmem2/Node`] will fail, which also
6498    /// propagates failure to the parent [`fuchsia.sysmem2/Node`] and so on up
6499    /// to the root `Node`, which fails the whole buffer collection. In
6500    /// contrast, a dispensable `Node` can fail after buffers are allocated
6501    /// without causing failure of its parent in the [`fuchsia.sysmem2/Node`]
6502    /// heirarchy.
6503    ///
6504    /// The dispensable `Node` participates in constraints aggregation along
6505    /// with its parent before buffer allocation. If the dispensable `Node`
6506    /// fails before buffers are allocated, the failure propagates to the
6507    /// dispensable `Node`'s parent.
6508    ///
6509    /// After buffers are allocated, failure of the dispensable `Node` (or any
6510    /// child of the dispensable `Node`) does not propagate to the dispensable
6511    /// `Node`'s parent. Failure does propagate from a normal child of a
6512    /// dispensable `Node` to the dispensable `Node`.  Failure of a child is
6513    /// blocked from reaching its parent if the child is attached using
6514    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or if the child is
6515    /// dispensable and the failure occurred after allocation.
6516    ///
6517    /// A dispensable `Node` can be used in cases where a participant needs to
6518    /// provide constraints, but after buffers are allocated, the participant
6519    /// can fail without causing buffer collection failure from the parent
6520    /// `Node`'s point of view.
6521    ///
6522    /// In contrast, `BufferCollection.AttachToken` can be used to create a
6523    /// `BufferCollectionToken` which does not participate in constraints
6524    /// aggregation with its parent `Node`, and whose failure at any time does
6525    /// not propagate to its parent `Node`, and whose potential delay providing
6526    /// constraints does not prevent the parent `Node` from completing its
6527    /// buffer allocation.
6528    ///
6529    /// An initiator (creator of the root `Node` using
6530    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`]) may in some
6531    /// scenarios choose to initially use a dispensable `Node` for a first
6532    /// instance of a participant, and then later if the first instance of that
6533    /// participant fails, a new second instance of that participant my be given
6534    /// a `BufferCollectionToken` created with `AttachToken`.
6535    ///
6536    /// Normally a client will `SetDispensable` on a `BufferCollectionToken`
6537    /// shortly before sending the dispensable `BufferCollectionToken` to a
6538    /// delegate participant. Because `SetDispensable` prevents propagation of
6539    /// child `Node` failure to parent `Node`(s), if the client was relying on
6540    /// noticing child failure via failure of the parent `Node` retained by the
6541    /// client, the client may instead need to notice failure via other means.
6542    /// If other means aren't available/convenient, the client can instead
6543    /// retain the dispensable `Node` and create a child `Node` under that to
6544    /// send to the delegate participant, retaining this `Node` in order to
6545    /// notice failure of the subtree rooted at this `Node` via this `Node`'s
6546    /// ZX_CHANNEL_PEER_CLOSED signal, and take whatever action is appropriate
6547    /// (e.g. starting a new instance of the delegate participant and handing it
6548    /// a `BufferCollectionToken` created using
6549    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or propagate failure
6550    /// and clean up in a client-specific way).
6551    ///
6552    /// While it is possible (and potentially useful) to `SetDispensable` on a
6553    /// direct child of a `BufferCollectionTokenGroup` `Node`, it isn't possible
6554    /// to later replace a failed dispensable `Node` that was a direct child of
6555    /// a `BufferCollectionTokenGroup` with a new token using `AttachToken`
6556    /// (since there's no `AttachToken` on a group). Instead, to enable
6557    /// `AttachToken` replacement in this case, create an additional
6558    /// non-dispensable token that's a direct child of the group and make the
6559    /// existing dispensable token a child of the additional token.  This way,
6560    /// the additional token that is a direct child of the group has
6561    /// `BufferCollection.AttachToken` which can be used to replace the failed
6562    /// dispensable token.
6563    ///
6564    /// `SetDispensable` on an already-dispensable token is idempotent.
6565    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
6566    /// Create a logical OR among a set of tokens, called a
6567    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
6568    ///
6569    /// Most sysmem clients and many participants don't need to care about this
6570    /// message or about `BufferCollectionTokenGroup`(s). However, in some cases
6571    /// a participant wants to attempt to include one set of delegate
6572    /// participants, but if constraints don't combine successfully that way,
6573    /// fall back to a different (possibly overlapping) set of delegate
6574    /// participants, and/or fall back to a less demanding strategy (in terms of
6575    /// how strict the [`fuchisa.sysmem2/BufferCollectionConstraints`] are,
6576    /// across all involved delegate participants). In such cases, a
6577    /// `BufferCollectionTokenGroup` is useful.
6578    ///
6579    /// A `BufferCollectionTokenGroup` is used to create a 1 of N OR among N
6580    /// child [`fuchsia.sysmem2/BufferCollectionToken`](s).  The child tokens
6581    /// which are not selected during aggregation will fail (close), which a
6582    /// potential participant should notice when their `BufferCollection`
6583    /// channel client endpoint sees PEER_CLOSED, allowing the participant to
6584    /// clean up the speculative usage that didn't end up happening (this is
6585    /// simimlar to a normal `BufferCollection` server end closing on failure to
6586    /// allocate a logical buffer collection or later async failure of a buffer
6587    /// collection).
6588    ///
6589    /// See comments on protocol `BufferCollectionTokenGroup`.
6590    ///
6591    /// Any `rights_attenuation_mask` or `AttachToken`/`SetDispensable` to be
6592    /// applied to the whole group can be achieved with a
6593    /// `BufferCollectionToken` for this purpose as a direct parent of the
6594    /// `BufferCollectionTokenGroup`.
6595    ///
6596    /// All table fields are currently required.
6597    ///
6598    /// + request `group_request` The server end of a
6599    ///   `BufferCollectionTokenGroup` channel to be served by sysmem.
6600    CreateBufferCollectionTokenGroup {
6601        payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
6602        control_handle: BufferCollectionTokenControlHandle,
6603    },
6604    /// An interaction was received which does not match any known method.
6605    #[non_exhaustive]
6606    _UnknownMethod {
6607        /// Ordinal of the method that was called.
6608        ordinal: u64,
6609        control_handle: BufferCollectionTokenControlHandle,
6610        method_type: fidl::MethodType,
6611    },
6612}
6613
6614impl BufferCollectionTokenRequest {
6615    #[allow(irrefutable_let_patterns)]
6616    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
6617        if let BufferCollectionTokenRequest::Sync { responder } = self {
6618            Some((responder))
6619        } else {
6620            None
6621        }
6622    }
6623
6624    #[allow(irrefutable_let_patterns)]
6625    pub fn into_release(self) -> Option<(BufferCollectionTokenControlHandle)> {
6626        if let BufferCollectionTokenRequest::Release { control_handle } = self {
6627            Some((control_handle))
6628        } else {
6629            None
6630        }
6631    }
6632
6633    #[allow(irrefutable_let_patterns)]
6634    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, BufferCollectionTokenControlHandle)> {
6635        if let BufferCollectionTokenRequest::SetName { payload, control_handle } = self {
6636            Some((payload, control_handle))
6637        } else {
6638            None
6639        }
6640    }
6641
6642    #[allow(irrefutable_let_patterns)]
6643    pub fn into_set_debug_client_info(
6644        self,
6645    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionTokenControlHandle)> {
6646        if let BufferCollectionTokenRequest::SetDebugClientInfo { payload, control_handle } = self {
6647            Some((payload, control_handle))
6648        } else {
6649            None
6650        }
6651    }
6652
6653    #[allow(irrefutable_let_patterns)]
6654    pub fn into_set_debug_timeout_log_deadline(
6655        self,
6656    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionTokenControlHandle)> {
6657        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
6658            payload,
6659            control_handle,
6660        } = self
6661        {
6662            Some((payload, control_handle))
6663        } else {
6664            None
6665        }
6666    }
6667
6668    #[allow(irrefutable_let_patterns)]
6669    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
6670        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
6671            Some((control_handle))
6672        } else {
6673            None
6674        }
6675    }
6676
6677    #[allow(irrefutable_let_patterns)]
6678    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
6679        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
6680            Some((responder))
6681        } else {
6682            None
6683        }
6684    }
6685
6686    #[allow(irrefutable_let_patterns)]
6687    pub fn into_is_alternate_for(
6688        self,
6689    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionTokenIsAlternateForResponder)> {
6690        if let BufferCollectionTokenRequest::IsAlternateFor { payload, responder } = self {
6691            Some((payload, responder))
6692        } else {
6693            None
6694        }
6695    }
6696
6697    #[allow(irrefutable_let_patterns)]
6698    pub fn into_get_buffer_collection_id(
6699        self,
6700    ) -> Option<(BufferCollectionTokenGetBufferCollectionIdResponder)> {
6701        if let BufferCollectionTokenRequest::GetBufferCollectionId { responder } = self {
6702            Some((responder))
6703        } else {
6704            None
6705        }
6706    }
6707
6708    #[allow(irrefutable_let_patterns)]
6709    pub fn into_set_weak(self) -> Option<(BufferCollectionTokenControlHandle)> {
6710        if let BufferCollectionTokenRequest::SetWeak { control_handle } = self {
6711            Some((control_handle))
6712        } else {
6713            None
6714        }
6715    }
6716
6717    #[allow(irrefutable_let_patterns)]
6718    pub fn into_set_weak_ok(
6719        self,
6720    ) -> Option<(NodeSetWeakOkRequest, BufferCollectionTokenControlHandle)> {
6721        if let BufferCollectionTokenRequest::SetWeakOk { payload, control_handle } = self {
6722            Some((payload, control_handle))
6723        } else {
6724            None
6725        }
6726    }
6727
6728    #[allow(irrefutable_let_patterns)]
6729    pub fn into_attach_node_tracking(
6730        self,
6731    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionTokenControlHandle)> {
6732        if let BufferCollectionTokenRequest::AttachNodeTracking { payload, control_handle } = self {
6733            Some((payload, control_handle))
6734        } else {
6735            None
6736        }
6737    }
6738
6739    #[allow(irrefutable_let_patterns)]
6740    pub fn into_duplicate_sync(
6741        self,
6742    ) -> Option<(
6743        BufferCollectionTokenDuplicateSyncRequest,
6744        BufferCollectionTokenDuplicateSyncResponder,
6745    )> {
6746        if let BufferCollectionTokenRequest::DuplicateSync { payload, responder } = self {
6747            Some((payload, responder))
6748        } else {
6749            None
6750        }
6751    }
6752
6753    #[allow(irrefutable_let_patterns)]
6754    pub fn into_duplicate(
6755        self,
6756    ) -> Option<(BufferCollectionTokenDuplicateRequest, BufferCollectionTokenControlHandle)> {
6757        if let BufferCollectionTokenRequest::Duplicate { payload, control_handle } = self {
6758            Some((payload, control_handle))
6759        } else {
6760            None
6761        }
6762    }
6763
6764    #[allow(irrefutable_let_patterns)]
6765    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
6766        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
6767            Some((control_handle))
6768        } else {
6769            None
6770        }
6771    }
6772
6773    #[allow(irrefutable_let_patterns)]
6774    pub fn into_create_buffer_collection_token_group(
6775        self,
6776    ) -> Option<(
6777        BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
6778        BufferCollectionTokenControlHandle,
6779    )> {
6780        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
6781            payload,
6782            control_handle,
6783        } = self
6784        {
6785            Some((payload, control_handle))
6786        } else {
6787            None
6788        }
6789    }
6790
6791    /// Name of the method defined in FIDL
6792    pub fn method_name(&self) -> &'static str {
6793        match *self {
6794            BufferCollectionTokenRequest::Sync { .. } => "sync",
6795            BufferCollectionTokenRequest::Release { .. } => "release",
6796            BufferCollectionTokenRequest::SetName { .. } => "set_name",
6797            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6798            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
6799                "set_debug_timeout_log_deadline"
6800            }
6801            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6802            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
6803            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
6804            BufferCollectionTokenRequest::GetBufferCollectionId { .. } => {
6805                "get_buffer_collection_id"
6806            }
6807            BufferCollectionTokenRequest::SetWeak { .. } => "set_weak",
6808            BufferCollectionTokenRequest::SetWeakOk { .. } => "set_weak_ok",
6809            BufferCollectionTokenRequest::AttachNodeTracking { .. } => "attach_node_tracking",
6810            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
6811            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
6812            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
6813            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
6814                "create_buffer_collection_token_group"
6815            }
6816            BufferCollectionTokenRequest::_UnknownMethod {
6817                method_type: fidl::MethodType::OneWay,
6818                ..
6819            } => "unknown one-way method",
6820            BufferCollectionTokenRequest::_UnknownMethod {
6821                method_type: fidl::MethodType::TwoWay,
6822                ..
6823            } => "unknown two-way method",
6824        }
6825    }
6826}
6827
6828#[derive(Debug, Clone)]
6829pub struct BufferCollectionTokenControlHandle {
6830    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6831}
6832
6833impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenControlHandle {
6834    fn shutdown(&self) {
6835        self.inner.shutdown()
6836    }
6837
6838    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6839        self.inner.shutdown_with_epitaph(status)
6840    }
6841
6842    fn is_closed(&self) -> bool {
6843        self.inner.channel().is_closed()
6844    }
6845    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6846        self.inner.channel().on_closed()
6847    }
6848}
6849
6850impl BufferCollectionTokenControlHandle {}
6851
6852#[must_use = "FIDL methods require a response to be sent"]
6853#[derive(Debug)]
6854pub struct BufferCollectionTokenSyncResponder {
6855    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6856    tx_id: u32,
6857}
6858
6859/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6860/// if the responder is dropped without sending a response, so that the client
6861/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6862impl std::ops::Drop for BufferCollectionTokenSyncResponder {
6863    fn drop(&mut self) {
6864        self.control_handle.shutdown();
6865        // Safety: drops once, never accessed again
6866        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6867    }
6868}
6869
6870impl fdomain_client::fidl::Responder for BufferCollectionTokenSyncResponder {
6871    type ControlHandle = BufferCollectionTokenControlHandle;
6872
6873    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6874        &self.control_handle
6875    }
6876
6877    fn drop_without_shutdown(mut self) {
6878        // Safety: drops once, never accessed again due to mem::forget
6879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6880        // Prevent Drop from running (which would shut down the channel)
6881        std::mem::forget(self);
6882    }
6883}
6884
6885impl BufferCollectionTokenSyncResponder {
6886    /// Sends a response to the FIDL transaction.
6887    ///
6888    /// Sets the channel to shutdown if an error occurs.
6889    pub fn send(self) -> Result<(), fidl::Error> {
6890        let _result = self.send_raw();
6891        if _result.is_err() {
6892            self.control_handle.shutdown();
6893        }
6894        self.drop_without_shutdown();
6895        _result
6896    }
6897
6898    /// Similar to "send" but does not shutdown the channel if an error occurs.
6899    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6900        let _result = self.send_raw();
6901        self.drop_without_shutdown();
6902        _result
6903    }
6904
6905    fn send_raw(&self) -> Result<(), fidl::Error> {
6906        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
6907            fidl::encoding::Flexible::new(()),
6908            self.tx_id,
6909            0x11ac2555cf575b54,
6910            fidl::encoding::DynamicFlags::FLEXIBLE,
6911        )
6912    }
6913}
6914
6915#[must_use = "FIDL methods require a response to be sent"]
6916#[derive(Debug)]
6917pub struct BufferCollectionTokenGetNodeRefResponder {
6918    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6919    tx_id: u32,
6920}
6921
6922/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6923/// if the responder is dropped without sending a response, so that the client
6924/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6925impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
6926    fn drop(&mut self) {
6927        self.control_handle.shutdown();
6928        // Safety: drops once, never accessed again
6929        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6930    }
6931}
6932
6933impl fdomain_client::fidl::Responder for BufferCollectionTokenGetNodeRefResponder {
6934    type ControlHandle = BufferCollectionTokenControlHandle;
6935
6936    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6937        &self.control_handle
6938    }
6939
6940    fn drop_without_shutdown(mut self) {
6941        // Safety: drops once, never accessed again due to mem::forget
6942        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6943        // Prevent Drop from running (which would shut down the channel)
6944        std::mem::forget(self);
6945    }
6946}
6947
6948impl BufferCollectionTokenGetNodeRefResponder {
6949    /// Sends a response to the FIDL transaction.
6950    ///
6951    /// Sets the channel to shutdown if an error occurs.
6952    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
6953        let _result = self.send_raw(payload);
6954        if _result.is_err() {
6955            self.control_handle.shutdown();
6956        }
6957        self.drop_without_shutdown();
6958        _result
6959    }
6960
6961    /// Similar to "send" but does not shutdown the channel if an error occurs.
6962    pub fn send_no_shutdown_on_err(
6963        self,
6964        mut payload: NodeGetNodeRefResponse,
6965    ) -> Result<(), fidl::Error> {
6966        let _result = self.send_raw(payload);
6967        self.drop_without_shutdown();
6968        _result
6969    }
6970
6971    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
6972        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
6973            fidl::encoding::Flexible::new(&mut payload),
6974            self.tx_id,
6975            0x5b3d0e51614df053,
6976            fidl::encoding::DynamicFlags::FLEXIBLE,
6977        )
6978    }
6979}
6980
6981#[must_use = "FIDL methods require a response to be sent"]
6982#[derive(Debug)]
6983pub struct BufferCollectionTokenIsAlternateForResponder {
6984    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6985    tx_id: u32,
6986}
6987
6988/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6989/// if the responder is dropped without sending a response, so that the client
6990/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6991impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
6992    fn drop(&mut self) {
6993        self.control_handle.shutdown();
6994        // Safety: drops once, never accessed again
6995        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6996    }
6997}
6998
6999impl fdomain_client::fidl::Responder for BufferCollectionTokenIsAlternateForResponder {
7000    type ControlHandle = BufferCollectionTokenControlHandle;
7001
7002    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
7003        &self.control_handle
7004    }
7005
7006    fn drop_without_shutdown(mut self) {
7007        // Safety: drops once, never accessed again due to mem::forget
7008        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7009        // Prevent Drop from running (which would shut down the channel)
7010        std::mem::forget(self);
7011    }
7012}
7013
7014impl BufferCollectionTokenIsAlternateForResponder {
7015    /// Sends a response to the FIDL transaction.
7016    ///
7017    /// Sets the channel to shutdown if an error occurs.
7018    pub fn send(
7019        self,
7020        mut result: Result<&NodeIsAlternateForResponse, Error>,
7021    ) -> Result<(), fidl::Error> {
7022        let _result = self.send_raw(result);
7023        if _result.is_err() {
7024            self.control_handle.shutdown();
7025        }
7026        self.drop_without_shutdown();
7027        _result
7028    }
7029
7030    /// Similar to "send" but does not shutdown the channel if an error occurs.
7031    pub fn send_no_shutdown_on_err(
7032        self,
7033        mut result: Result<&NodeIsAlternateForResponse, Error>,
7034    ) -> Result<(), fidl::Error> {
7035        let _result = self.send_raw(result);
7036        self.drop_without_shutdown();
7037        _result
7038    }
7039
7040    fn send_raw(
7041        &self,
7042        mut result: Result<&NodeIsAlternateForResponse, Error>,
7043    ) -> Result<(), fidl::Error> {
7044        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7045            NodeIsAlternateForResponse,
7046            Error,
7047        >>(
7048            fidl::encoding::FlexibleResult::new(result),
7049            self.tx_id,
7050            0x3a58e00157e0825,
7051            fidl::encoding::DynamicFlags::FLEXIBLE,
7052        )
7053    }
7054}
7055
7056#[must_use = "FIDL methods require a response to be sent"]
7057#[derive(Debug)]
7058pub struct BufferCollectionTokenGetBufferCollectionIdResponder {
7059    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
7060    tx_id: u32,
7061}
7062
7063/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
7064/// if the responder is dropped without sending a response, so that the client
7065/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7066impl std::ops::Drop for BufferCollectionTokenGetBufferCollectionIdResponder {
7067    fn drop(&mut self) {
7068        self.control_handle.shutdown();
7069        // Safety: drops once, never accessed again
7070        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7071    }
7072}
7073
7074impl fdomain_client::fidl::Responder for BufferCollectionTokenGetBufferCollectionIdResponder {
7075    type ControlHandle = BufferCollectionTokenControlHandle;
7076
7077    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
7078        &self.control_handle
7079    }
7080
7081    fn drop_without_shutdown(mut self) {
7082        // Safety: drops once, never accessed again due to mem::forget
7083        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7084        // Prevent Drop from running (which would shut down the channel)
7085        std::mem::forget(self);
7086    }
7087}
7088
7089impl BufferCollectionTokenGetBufferCollectionIdResponder {
7090    /// Sends a response to the FIDL transaction.
7091    ///
7092    /// Sets the channel to shutdown if an error occurs.
7093    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
7094        let _result = self.send_raw(payload);
7095        if _result.is_err() {
7096            self.control_handle.shutdown();
7097        }
7098        self.drop_without_shutdown();
7099        _result
7100    }
7101
7102    /// Similar to "send" but does not shutdown the channel if an error occurs.
7103    pub fn send_no_shutdown_on_err(
7104        self,
7105        mut payload: &NodeGetBufferCollectionIdResponse,
7106    ) -> Result<(), fidl::Error> {
7107        let _result = self.send_raw(payload);
7108        self.drop_without_shutdown();
7109        _result
7110    }
7111
7112    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
7113        self.control_handle
7114            .inner
7115            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
7116                fidl::encoding::Flexible::new(payload),
7117                self.tx_id,
7118                0x77d19a494b78ba8c,
7119                fidl::encoding::DynamicFlags::FLEXIBLE,
7120            )
7121    }
7122}
7123
7124#[must_use = "FIDL methods require a response to be sent"]
7125#[derive(Debug)]
7126pub struct BufferCollectionTokenDuplicateSyncResponder {
7127    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
7128    tx_id: u32,
7129}
7130
7131/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
7132/// if the responder is dropped without sending a response, so that the client
7133/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7134impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
7135    fn drop(&mut self) {
7136        self.control_handle.shutdown();
7137        // Safety: drops once, never accessed again
7138        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7139    }
7140}
7141
7142impl fdomain_client::fidl::Responder for BufferCollectionTokenDuplicateSyncResponder {
7143    type ControlHandle = BufferCollectionTokenControlHandle;
7144
7145    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
7146        &self.control_handle
7147    }
7148
7149    fn drop_without_shutdown(mut self) {
7150        // Safety: drops once, never accessed again due to mem::forget
7151        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7152        // Prevent Drop from running (which would shut down the channel)
7153        std::mem::forget(self);
7154    }
7155}
7156
7157impl BufferCollectionTokenDuplicateSyncResponder {
7158    /// Sends a response to the FIDL transaction.
7159    ///
7160    /// Sets the channel to shutdown if an error occurs.
7161    pub fn send(
7162        self,
7163        mut payload: BufferCollectionTokenDuplicateSyncResponse,
7164    ) -> Result<(), fidl::Error> {
7165        let _result = self.send_raw(payload);
7166        if _result.is_err() {
7167            self.control_handle.shutdown();
7168        }
7169        self.drop_without_shutdown();
7170        _result
7171    }
7172
7173    /// Similar to "send" but does not shutdown the channel if an error occurs.
7174    pub fn send_no_shutdown_on_err(
7175        self,
7176        mut payload: BufferCollectionTokenDuplicateSyncResponse,
7177    ) -> Result<(), fidl::Error> {
7178        let _result = self.send_raw(payload);
7179        self.drop_without_shutdown();
7180        _result
7181    }
7182
7183    fn send_raw(
7184        &self,
7185        mut payload: BufferCollectionTokenDuplicateSyncResponse,
7186    ) -> Result<(), fidl::Error> {
7187        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
7188            BufferCollectionTokenDuplicateSyncResponse,
7189        >>(
7190            fidl::encoding::Flexible::new(&mut payload),
7191            self.tx_id,
7192            0x1c1af9919d1ca45c,
7193            fidl::encoding::DynamicFlags::FLEXIBLE,
7194        )
7195    }
7196}
7197
7198#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7199pub struct BufferCollectionTokenGroupMarker;
7200
7201impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenGroupMarker {
7202    type Proxy = BufferCollectionTokenGroupProxy;
7203    type RequestStream = BufferCollectionTokenGroupRequestStream;
7204
7205    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
7206}
7207
7208pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
7209    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7210    fn r#sync(&self) -> Self::SyncResponseFut;
7211    fn r#release(&self) -> Result<(), fidl::Error>;
7212    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
7213    fn r#set_debug_client_info(
7214        &self,
7215        payload: &NodeSetDebugClientInfoRequest,
7216    ) -> Result<(), fidl::Error>;
7217    fn r#set_debug_timeout_log_deadline(
7218        &self,
7219        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7220    ) -> Result<(), fidl::Error>;
7221    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
7222    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
7223        + Send;
7224    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
7225    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
7226        + Send;
7227    fn r#is_alternate_for(
7228        &self,
7229        payload: NodeIsAlternateForRequest,
7230    ) -> Self::IsAlternateForResponseFut;
7231    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
7232        + Send;
7233    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
7234    fn r#set_weak(&self) -> Result<(), fidl::Error>;
7235    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
7236    fn r#attach_node_tracking(
7237        &self,
7238        payload: NodeAttachNodeTrackingRequest,
7239    ) -> Result<(), fidl::Error>;
7240    fn r#create_child(
7241        &self,
7242        payload: BufferCollectionTokenGroupCreateChildRequest,
7243    ) -> Result<(), fidl::Error>;
7244    type CreateChildrenSyncResponseFut: std::future::Future<
7245            Output = Result<BufferCollectionTokenGroupCreateChildrenSyncResponse, fidl::Error>,
7246        > + Send;
7247    fn r#create_children_sync(
7248        &self,
7249        payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7250    ) -> Self::CreateChildrenSyncResponseFut;
7251    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
7252}
7253
7254#[derive(Debug, Clone)]
7255pub struct BufferCollectionTokenGroupProxy {
7256    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
7257}
7258
7259impl fdomain_client::fidl::Proxy for BufferCollectionTokenGroupProxy {
7260    type Protocol = BufferCollectionTokenGroupMarker;
7261
7262    fn from_channel(inner: fdomain_client::Channel) -> Self {
7263        Self::new(inner)
7264    }
7265
7266    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
7267        self.client.into_channel().map_err(|client| Self { client })
7268    }
7269
7270    fn as_channel(&self) -> &fdomain_client::Channel {
7271        self.client.as_channel()
7272    }
7273}
7274
7275impl BufferCollectionTokenGroupProxy {
7276    /// Create a new Proxy for fuchsia.sysmem2/BufferCollectionTokenGroup.
7277    pub fn new(channel: fdomain_client::Channel) -> Self {
7278        let protocol_name =
7279            <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
7280        Self { client: fidl::client::Client::new(channel, protocol_name) }
7281    }
7282
7283    /// Get a Stream of events from the remote end of the protocol.
7284    ///
7285    /// # Panics
7286    ///
7287    /// Panics if the event stream was already taken.
7288    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
7289        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
7290    }
7291
7292    /// Ensure that previous messages have been received server side. This is
7293    /// particularly useful after previous messages that created new tokens,
7294    /// because a token must be known to the sysmem server before sending the
7295    /// token to another participant.
7296    ///
7297    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
7298    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
7299    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
7300    /// to mitigate the possibility of a hostile/fake
7301    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
7302    /// Another way is to pass the token to
7303    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
7304    /// the token as part of exchanging it for a
7305    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
7306    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
7307    /// of stalling.
7308    ///
7309    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
7310    /// and then starting and completing a `Sync`, it's then safe to send the
7311    /// `BufferCollectionToken` client ends to other participants knowing the
7312    /// server will recognize the tokens when they're sent by the other
7313    /// participants to sysmem in a
7314    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
7315    /// efficient way to create tokens while avoiding unnecessary round trips.
7316    ///
7317    /// Other options include waiting for each
7318    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
7319    /// individually (using separate call to `Sync` after each), or calling
7320    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
7321    /// converted to a `BufferCollection` via
7322    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
7323    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
7324    /// the sync step and can create multiple tokens at once.
7325    pub fn r#sync(
7326        &self,
7327    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
7328        BufferCollectionTokenGroupProxyInterface::r#sync(self)
7329    }
7330
7331    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
7332    ///
7333    /// Normally a participant will convert a `BufferCollectionToken` into a
7334    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
7335    /// `Release` via the token (and then close the channel immediately or
7336    /// shortly later in response to server closing the server end), which
7337    /// avoids causing buffer collection failure. Without a prior `Release`,
7338    /// closing the `BufferCollectionToken` client end will cause buffer
7339    /// collection failure.
7340    ///
7341    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
7342    ///
7343    /// By default the server handles unexpected closure of a
7344    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
7345    /// first) by failing the buffer collection. Partly this is to expedite
7346    /// closing VMO handles to reclaim memory when any participant fails. If a
7347    /// participant would like to cleanly close a `BufferCollection` without
7348    /// causing buffer collection failure, the participant can send `Release`
7349    /// before closing the `BufferCollection` client end. The `Release` can
7350    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
7351    /// buffer collection won't require constraints from this node in order to
7352    /// allocate. If after `SetConstraints`, the constraints are retained and
7353    /// aggregated, despite the lack of `BufferCollection` connection at the
7354    /// time of constraints aggregation.
7355    ///
7356    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
7357    ///
7358    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
7359    /// end (without `Release` first) will trigger failure of the buffer
7360    /// collection. To close a `BufferCollectionTokenGroup` channel without
7361    /// failing the buffer collection, ensure that AllChildrenPresent() has been
7362    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
7363    /// client end.
7364    ///
7365    /// If `Release` occurs before
7366    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
7367    /// buffer collection will fail (triggered by reception of `Release` without
7368    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
7369    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
7370    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
7371    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
7372    /// close requires `AllChildrenPresent` (if not already sent), then
7373    /// `Release`, then close client end.
7374    ///
7375    /// If `Release` occurs after `AllChildrenPresent`, the children and all
7376    /// their constraints remain intact (just as they would if the
7377    /// `BufferCollectionTokenGroup` channel had remained open), and the client
7378    /// end close doesn't trigger buffer collection failure.
7379    ///
7380    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
7381    ///
7382    /// For brevity, the per-channel-protocol paragraphs above ignore the
7383    /// separate failure domain created by
7384    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
7385    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
7386    /// unexpectedly closes (without `Release` first) and that client end is
7387    /// under a failure domain, instead of failing the whole buffer collection,
7388    /// the failure domain is failed, but the buffer collection itself is
7389    /// isolated from failure of the failure domain. Such failure domains can be
7390    /// nested, in which case only the inner-most failure domain in which the
7391    /// `Node` resides fails.
7392    pub fn r#release(&self) -> Result<(), fidl::Error> {
7393        BufferCollectionTokenGroupProxyInterface::r#release(self)
7394    }
7395
7396    /// Set a name for VMOs in this buffer collection.
7397    ///
7398    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
7399    /// will be truncated to fit. The name of the vmo will be suffixed with the
7400    /// buffer index within the collection (if the suffix fits within
7401    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
7402    /// listed in the inspect data.
7403    ///
7404    /// The name only affects VMOs allocated after the name is set; this call
7405    /// does not rename existing VMOs. If multiple clients set different names
7406    /// then the larger priority value will win. Setting a new name with the
7407    /// same priority as a prior name doesn't change the name.
7408    ///
7409    /// All table fields are currently required.
7410    ///
7411    /// + request `priority` The name is only set if this is the first `SetName`
7412    ///   or if `priority` is greater than any previous `priority` value in
7413    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
7414    /// + request `name` The name for VMOs created under this buffer collection.
7415    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
7416        BufferCollectionTokenGroupProxyInterface::r#set_name(self, payload)
7417    }
7418
7419    /// Set information about the current client that can be used by sysmem to
7420    /// help diagnose leaking memory and allocation stalls waiting for a
7421    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
7422    ///
7423    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
7424    /// `Node`(s) derived from this `Node`, unless overriden by
7425    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
7426    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
7427    ///
7428    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
7429    /// `Allocator` is the most efficient way to ensure that all
7430    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
7431    /// set, and is also more efficient than separately sending the same debug
7432    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
7433    /// created [`fuchsia.sysmem2/Node`].
7434    ///
7435    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
7436    /// indicate which client is closing their channel first, leading to subtree
7437    /// failure (which can be normal if the purpose of the subtree is over, but
7438    /// if happening earlier than expected, the client-channel-specific name can
7439    /// help diagnose where the failure is first coming from, from sysmem's
7440    /// point of view).
7441    ///
7442    /// All table fields are currently required.
7443    ///
7444    /// + request `name` This can be an arbitrary string, but the current
7445    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
7446    /// + request `id` This can be an arbitrary id, but the current process ID
7447    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
7448    pub fn r#set_debug_client_info(
7449        &self,
7450        mut payload: &NodeSetDebugClientInfoRequest,
7451    ) -> Result<(), fidl::Error> {
7452        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, payload)
7453    }
7454
7455    /// Sysmem logs a warning if sysmem hasn't seen
7456    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
7457    /// within 5 seconds after creation of a new collection.
7458    ///
7459    /// Clients can call this method to change when the log is printed. If
7460    /// multiple client set the deadline, it's unspecified which deadline will
7461    /// take effect.
7462    ///
7463    /// In most cases the default works well.
7464    ///
7465    /// All table fields are currently required.
7466    ///
7467    /// + request `deadline` The time at which sysmem will start trying to log
7468    ///   the warning, unless all constraints are with sysmem by then.
7469    pub fn r#set_debug_timeout_log_deadline(
7470        &self,
7471        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7472    ) -> Result<(), fidl::Error> {
7473        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
7474    }
7475
7476    /// This enables verbose logging for the buffer collection.
7477    ///
7478    /// Verbose logging includes constraints set via
7479    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
7480    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
7481    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
7482    /// the tree of `Node`(s).
7483    ///
7484    /// Normally sysmem prints only a single line complaint when aggregation
7485    /// fails, with just the specific detailed reason that aggregation failed,
7486    /// with little surrounding context.  While this is often enough to diagnose
7487    /// a problem if only a small change was made and everything was working
7488    /// before the small change, it's often not particularly helpful for getting
7489    /// a new buffer collection to work for the first time.  Especially with
7490    /// more complex trees of nodes, involving things like
7491    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
7492    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
7493    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
7494    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
7495    /// looks like and why it's failing a logical allocation, or why a tree or
7496    /// subtree is failing sooner than expected.
7497    ///
7498    /// The intent of the extra logging is to be acceptable from a performance
7499    /// point of view, under the assumption that verbose logging is only enabled
7500    /// on a low number of buffer collections. If we're not tracking down a bug,
7501    /// we shouldn't send this message.
7502    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7503        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
7504    }
7505
7506    /// This gets a handle that can be used as a parameter to
7507    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
7508    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
7509    /// client obtained this handle from this `Node`.
7510    ///
7511    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
7512    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
7513    /// despite the two calls typically being on different channels.
7514    ///
7515    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
7516    ///
7517    /// All table fields are currently required.
7518    ///
7519    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
7520    ///   different `Node` channel, to prove that the client obtained the handle
7521    ///   from this `Node`.
7522    pub fn r#get_node_ref(
7523        &self,
7524    ) -> fidl::client::QueryResponseFut<
7525        NodeGetNodeRefResponse,
7526        fdomain_client::fidl::FDomainResourceDialect,
7527    > {
7528        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
7529    }
7530
7531    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
7532    /// rooted at a different child token of a common parent
7533    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
7534    /// passed-in `node_ref`.
7535    ///
7536    /// This call is for assisting with admission control de-duplication, and
7537    /// with debugging.
7538    ///
7539    /// The `node_ref` must be obtained using
7540    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
7541    ///
7542    /// The `node_ref` can be a duplicated handle; it's not necessary to call
7543    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
7544    ///
7545    /// If a calling token may not actually be a valid token at all due to a
7546    /// potentially hostile/untrusted provider of the token, call
7547    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
7548    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
7549    /// never responds due to a calling token not being a real token (not really
7550    /// talking to sysmem).  Another option is to call
7551    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
7552    /// which also validates the token along with converting it to a
7553    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
7554    ///
7555    /// All table fields are currently required.
7556    ///
7557    /// - response `is_alternate`
7558    ///   - true: The first parent node in common between the calling node and
7559    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
7560    ///     that the calling `Node` and the `node_ref` `Node` will not have both
7561    ///     their constraints apply - rather sysmem will choose one or the other
7562    ///     of the constraints - never both.  This is because only one child of
7563    ///     a `BufferCollectionTokenGroup` is selected during logical
7564    ///     allocation, with only that one child's subtree contributing to
7565    ///     constraints aggregation.
7566    ///   - false: The first parent node in common between the calling `Node`
7567    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
7568    ///     Currently, this means the first parent node in common is a
7569    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
7570    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
7571    ///     `Node` may have both their constraints apply during constraints
7572    ///     aggregation of the logical allocation, if both `Node`(s) are
7573    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
7574    ///     this case, there is no `BufferCollectionTokenGroup` that will
7575    ///     directly prevent the two `Node`(s) from both being selected and
7576    ///     their constraints both aggregated, but even when false, one or both
7577    ///     `Node`(s) may still be eliminated from consideration if one or both
7578    ///     `Node`(s) has a direct or indirect parent
7579    ///     `BufferCollectionTokenGroup` which selects a child subtree other
7580    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
7581    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
7582    ///   associated with the same buffer collection as the calling `Node`.
7583    ///   Another reason for this error is if the `node_ref` is an
7584    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
7585    ///   a real `node_ref` obtained from `GetNodeRef`.
7586    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
7587    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
7588    ///   the needed rights expected on a real `node_ref`.
7589    /// * No other failing status codes are returned by this call.  However,
7590    ///   sysmem may add additional codes in future, so the client should have
7591    ///   sensible default handling for any failing status code.
7592    pub fn r#is_alternate_for(
7593        &self,
7594        mut payload: NodeIsAlternateForRequest,
7595    ) -> fidl::client::QueryResponseFut<
7596        NodeIsAlternateForResult,
7597        fdomain_client::fidl::FDomainResourceDialect,
7598    > {
7599        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, payload)
7600    }
7601
7602    /// Get the buffer collection ID. This ID is also available from
7603    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
7604    /// within the collection).
7605    ///
7606    /// This call is mainly useful in situations where we can't convey a
7607    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
7608    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
7609    /// handle, which can be joined back up with a `BufferCollection` client end
7610    /// that was created via a different path. Prefer to convey a
7611    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
7612    ///
7613    /// Trusting a `buffer_collection_id` value from a source other than sysmem
7614    /// is analogous to trusting a koid value from a source other than zircon.
7615    /// Both should be avoided unless really necessary, and both require
7616    /// caution. In some situations it may be reasonable to refer to a
7617    /// pre-established `BufferCollection` by `buffer_collection_id` via a
7618    /// protocol for efficiency reasons, but an incoming value purporting to be
7619    /// a `buffer_collection_id` is not sufficient alone to justify granting the
7620    /// sender of the `buffer_collection_id` any capability. The sender must
7621    /// first prove to a receiver that the sender has/had a VMO or has/had a
7622    /// `BufferCollectionToken` to the same collection by sending a handle that
7623    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
7624    /// `buffer_collection_id` value. The receiver should take care to avoid
7625    /// assuming that a sender had a `BufferCollectionToken` in cases where the
7626    /// sender has only proven that the sender had a VMO.
7627    ///
7628    /// - response `buffer_collection_id` This ID is unique per buffer
7629    ///   collection per boot. Each buffer is uniquely identified by the
7630    ///   `buffer_collection_id` and `buffer_index` together.
7631    pub fn r#get_buffer_collection_id(
7632        &self,
7633    ) -> fidl::client::QueryResponseFut<
7634        NodeGetBufferCollectionIdResponse,
7635        fdomain_client::fidl::FDomainResourceDialect,
7636    > {
7637        BufferCollectionTokenGroupProxyInterface::r#get_buffer_collection_id(self)
7638    }
7639
7640    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
7641    /// created after this message to weak, which means that a client's `Node`
7642    /// client end (or a child created after this message) is not alone
7643    /// sufficient to keep allocated VMOs alive.
7644    ///
7645    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
7646    /// `close_weak_asap`.
7647    ///
7648    /// This message is only permitted before the `Node` becomes ready for
7649    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
7650    ///   * `BufferCollectionToken`: any time
7651    ///   * `BufferCollection`: before `SetConstraints`
7652    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
7653    ///
7654    /// Currently, no conversion from strong `Node` to weak `Node` after ready
7655    /// for allocation is provided, but a client can simulate that by creating
7656    /// an additional `Node` before allocation and setting that additional
7657    /// `Node` to weak, and then potentially at some point later sending
7658    /// `Release` and closing the client end of the client's strong `Node`, but
7659    /// keeping the client's weak `Node`.
7660    ///
7661    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
7662    /// collection failure (all `Node` client end(s) will see
7663    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
7664    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
7665    /// this situation until all `Node`(s) are ready for allocation. For initial
7666    /// allocation to succeed, at least one strong `Node` is required to exist
7667    /// at allocation time, but after that client receives VMO handles, that
7668    /// client can `BufferCollection.Release` and close the client end without
7669    /// causing this type of failure.
7670    ///
7671    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
7672    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
7673    /// separately as appropriate.
7674    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
7675        BufferCollectionTokenGroupProxyInterface::r#set_weak(self)
7676    }
7677
7678    /// This indicates to sysmem that the client is prepared to pay attention to
7679    /// `close_weak_asap`.
7680    ///
7681    /// If sent, this message must be before
7682    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
7683    ///
7684    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
7685    /// send this message before `WaitForAllBuffersAllocated`, or a parent
7686    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
7687    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
7688    /// trigger buffer collection failure.
7689    ///
7690    /// This message is necessary because weak sysmem VMOs have not always been
7691    /// a thing, so older clients are not aware of the need to pay attention to
7692    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
7693    /// sysmem weak VMO handles asap. By having this message and requiring
7694    /// participants to indicate their acceptance of this aspect of the overall
7695    /// protocol, we avoid situations where an older client is delivered a weak
7696    /// VMO without any way for sysmem to get that VMO to close quickly later
7697    /// (and on a per-buffer basis).
7698    ///
7699    /// A participant that doesn't handle `close_weak_asap` and also doesn't
7700    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
7701    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
7702    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
7703    /// same participant has a child/delegate which does retrieve VMOs, that
7704    /// child/delegate will need to send `SetWeakOk` before
7705    /// `WaitForAllBuffersAllocated`.
7706    ///
7707    /// + request `for_child_nodes_also` If present and true, this means direct
7708    ///   child nodes of this node created after this message plus all
7709    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
7710    ///   those nodes. Any child node of this node that was created before this
7711    ///   message is not included. This setting is "sticky" in the sense that a
7712    ///   subsequent `SetWeakOk` without this bool set to true does not reset
7713    ///   the server-side bool. If this creates a problem for a participant, a
7714    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
7715    ///   tokens instead, as appropriate. A participant should only set
7716    ///   `for_child_nodes_also` true if the participant can really promise to
7717    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
7718    ///   weak VMO handles held by participants holding the corresponding child
7719    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
7720    ///   which are using sysmem(1) can be weak, despite the clients of those
7721    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
7722    ///   direct way to find out about `close_weak_asap`. This only applies to
7723    ///   descendents of this `Node` which are using sysmem(1), not to this
7724    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
7725    ///   token, which will fail allocation unless an ancestor of this `Node`
7726    ///   specified `for_child_nodes_also` true.
7727    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
7728        BufferCollectionTokenGroupProxyInterface::r#set_weak_ok(self, payload)
7729    }
7730
7731    /// The server_end will be closed after this `Node` and any child nodes have
7732    /// have released their buffer counts, making those counts available for
7733    /// reservation by a different `Node` via
7734    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
7735    ///
7736    /// The `Node` buffer counts may not be released until the entire tree of
7737    /// `Node`(s) is closed or failed, because
7738    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
7739    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
7740    /// `Node` buffer counts remain reserved until the orphaned node is later
7741    /// cleaned up.
7742    ///
7743    /// If the `Node` exceeds a fairly large number of attached eventpair server
7744    /// ends, a log message will indicate this and the `Node` (and the
7745    /// appropriate) sub-tree will fail.
7746    ///
7747    /// The `server_end` will remain open when
7748    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
7749    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
7750    /// [`fuchsia.sysmem2/BufferCollection`].
7751    ///
7752    /// This message can also be used with a
7753    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
7754    pub fn r#attach_node_tracking(
7755        &self,
7756        mut payload: NodeAttachNodeTrackingRequest,
7757    ) -> Result<(), fidl::Error> {
7758        BufferCollectionTokenGroupProxyInterface::r#attach_node_tracking(self, payload)
7759    }
7760
7761    /// Create a child [`fuchsia.sysmem2/BufferCollectionToken`]. Only one child
7762    /// (including its children) will be selected during allocation (or logical
7763    /// allocation).
7764    ///
7765    /// Before passing the client end of this token to
7766    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], completion of
7767    /// [`fuchsia.sysmem2/Node.Sync`] after
7768    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] is required.
7769    /// Or the client can use
7770    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`] which
7771    /// essentially includes the `Sync`.
7772    ///
7773    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
7774    /// fail the group's subtree and close the connection.
7775    ///
7776    /// After all children have been created, send AllChildrenPresent.
7777    ///
7778    /// + request `token_request` The server end of the new token channel.
7779    /// + request `rights_attenuation_mask` If ZX_RIGHT_SAME_RIGHTS, the created
7780    ///   token allows the holder to get the same rights to buffers as the
7781    ///   parent token (of the group) had. When the value isn't
7782    ///   ZX_RIGHT_SAME_RIGHTS, the value is interpretted as a bitmask with 0
7783    ///   bits ensuring those rights are attentuated, so 0xFFFFFFFF is a synonym
7784    ///   for ZX_RIGHT_SAME_RIGHTS. The value 0 is not allowed and intentionally
7785    ///   causes subtree failure.
7786    pub fn r#create_child(
7787        &self,
7788        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7789    ) -> Result<(), fidl::Error> {
7790        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
7791    }
7792
7793    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7794    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`], no
7795    /// [`fuchsia.sysmem2/Node.Sync`] is required before passing the client end
7796    /// of a returned token to
7797    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`].
7798    ///
7799    /// The lower-index child tokens are higher priority (attempted sooner) than
7800    /// higher-index child tokens.
7801    ///
7802    /// As per all child tokens, successful aggregation will choose exactly one
7803    /// child among all created children (across all children created across
7804    /// potentially multiple calls to
7805    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] and
7806    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`]).
7807    ///
7808    /// The maximum permissible total number of children per group, and total
7809    /// number of nodes in an overall tree (from the root) are capped to limits
7810    /// which are not configurable via these protocols.
7811    ///
7812    /// Sending CreateChildrenSync after AllChildrenPresent is not permitted;
7813    /// this will fail the group's subtree and close the connection.
7814    ///
7815    /// After all children have been created, send AllChildrenPresent.
7816    ///
7817    /// + request `rights_attentuation_masks` The size of the
7818    ///   `rights_attentuation_masks` determines the number of created child
7819    ///   tokens. The value ZX_RIGHT_SAME_RIGHTS doesn't attenuate any rights.
7820    ///   The value 0xFFFFFFFF is a synonym for ZX_RIGHT_SAME_RIGHTS. For any
7821    ///   other value, each 0 bit in the mask attenuates that right.
7822    /// - response `tokens` The created child tokens.
7823    pub fn r#create_children_sync(
7824        &self,
7825        mut payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7826    ) -> fidl::client::QueryResponseFut<
7827        BufferCollectionTokenGroupCreateChildrenSyncResponse,
7828        fdomain_client::fidl::FDomainResourceDialect,
7829    > {
7830        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(self, payload)
7831    }
7832
7833    /// Indicate that no more children will be created.
7834    ///
7835    /// After creating all children, the client should send
7836    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent`] to
7837    /// inform sysmem that no more children will be created, so that sysmem can
7838    /// know when it's ok to start aggregating constraints.
7839    ///
7840    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
7841    /// fail the group's subtree and close the connection.
7842    ///
7843    /// If [`fuchsia.sysmem2/Node.Release`] is to be sent, it should be sent
7844    /// after `AllChildrenPresent`, else failure of the group's subtree will be
7845    /// triggered. This is intentionally not analogous to how `Release` without
7846    /// prior [`fuchsia.sysmem2/BufferCollection.SetConstraints`] doesn't cause
7847    /// subtree failure.
7848    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7849        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
7850    }
7851}
7852
7853impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
7854    type SyncResponseFut =
7855        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7856    fn r#sync(&self) -> Self::SyncResponseFut {
7857        fn _decode(
7858            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7859        ) -> Result<(), fidl::Error> {
7860            let _response = fidl::client::decode_transaction_body::<
7861                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
7862                fdomain_client::fidl::FDomainResourceDialect,
7863                0x11ac2555cf575b54,
7864            >(_buf?)?
7865            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("sync")?;
7866            Ok(_response)
7867        }
7868        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7869            (),
7870            0x11ac2555cf575b54,
7871            fidl::encoding::DynamicFlags::FLEXIBLE,
7872            _decode,
7873        )
7874    }
7875
7876    fn r#release(&self) -> Result<(), fidl::Error> {
7877        self.client.send::<fidl::encoding::EmptyPayload>(
7878            (),
7879            0x6a5cae7d6d6e04c6,
7880            fidl::encoding::DynamicFlags::FLEXIBLE,
7881        )
7882    }
7883
7884    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
7885        self.client.send::<NodeSetNameRequest>(
7886            payload,
7887            0xb41f1624f48c1e9,
7888            fidl::encoding::DynamicFlags::FLEXIBLE,
7889        )
7890    }
7891
7892    fn r#set_debug_client_info(
7893        &self,
7894        mut payload: &NodeSetDebugClientInfoRequest,
7895    ) -> Result<(), fidl::Error> {
7896        self.client.send::<NodeSetDebugClientInfoRequest>(
7897            payload,
7898            0x5cde8914608d99b1,
7899            fidl::encoding::DynamicFlags::FLEXIBLE,
7900        )
7901    }
7902
7903    fn r#set_debug_timeout_log_deadline(
7904        &self,
7905        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7906    ) -> Result<(), fidl::Error> {
7907        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7908            payload,
7909            0x716b0af13d5c0806,
7910            fidl::encoding::DynamicFlags::FLEXIBLE,
7911        )
7912    }
7913
7914    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7915        self.client.send::<fidl::encoding::EmptyPayload>(
7916            (),
7917            0x5209c77415b4dfad,
7918            fidl::encoding::DynamicFlags::FLEXIBLE,
7919        )
7920    }
7921
7922    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
7923        NodeGetNodeRefResponse,
7924        fdomain_client::fidl::FDomainResourceDialect,
7925    >;
7926    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7927        fn _decode(
7928            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7929        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
7930            let _response = fidl::client::decode_transaction_body::<
7931                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
7932                fdomain_client::fidl::FDomainResourceDialect,
7933                0x5b3d0e51614df053,
7934            >(_buf?)?
7935            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("get_node_ref")?;
7936            Ok(_response)
7937        }
7938        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
7939            (),
7940            0x5b3d0e51614df053,
7941            fidl::encoding::DynamicFlags::FLEXIBLE,
7942            _decode,
7943        )
7944    }
7945
7946    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7947        NodeIsAlternateForResult,
7948        fdomain_client::fidl::FDomainResourceDialect,
7949    >;
7950    fn r#is_alternate_for(
7951        &self,
7952        mut payload: NodeIsAlternateForRequest,
7953    ) -> Self::IsAlternateForResponseFut {
7954        fn _decode(
7955            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7956        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7957            let _response = fidl::client::decode_transaction_body::<
7958                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
7959                fdomain_client::fidl::FDomainResourceDialect,
7960                0x3a58e00157e0825,
7961            >(_buf?)?
7962            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("is_alternate_for")?;
7963            Ok(_response.map(|x| x))
7964        }
7965        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7966            &mut payload,
7967            0x3a58e00157e0825,
7968            fidl::encoding::DynamicFlags::FLEXIBLE,
7969            _decode,
7970        )
7971    }
7972
7973    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
7974        NodeGetBufferCollectionIdResponse,
7975        fdomain_client::fidl::FDomainResourceDialect,
7976    >;
7977    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
7978        fn _decode(
7979            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7980        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
7981            let _response = fidl::client::decode_transaction_body::<
7982                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
7983                fdomain_client::fidl::FDomainResourceDialect,
7984                0x77d19a494b78ba8c,
7985            >(_buf?)?
7986            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("get_buffer_collection_id")?;
7987            Ok(_response)
7988        }
7989        self.client.send_query_and_decode::<
7990            fidl::encoding::EmptyPayload,
7991            NodeGetBufferCollectionIdResponse,
7992        >(
7993            (),
7994            0x77d19a494b78ba8c,
7995            fidl::encoding::DynamicFlags::FLEXIBLE,
7996            _decode,
7997        )
7998    }
7999
8000    fn r#set_weak(&self) -> Result<(), fidl::Error> {
8001        self.client.send::<fidl::encoding::EmptyPayload>(
8002            (),
8003            0x22dd3ea514eeffe1,
8004            fidl::encoding::DynamicFlags::FLEXIBLE,
8005        )
8006    }
8007
8008    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
8009        self.client.send::<NodeSetWeakOkRequest>(
8010            &mut payload,
8011            0x38a44fc4d7724be9,
8012            fidl::encoding::DynamicFlags::FLEXIBLE,
8013        )
8014    }
8015
8016    fn r#attach_node_tracking(
8017        &self,
8018        mut payload: NodeAttachNodeTrackingRequest,
8019    ) -> Result<(), fidl::Error> {
8020        self.client.send::<NodeAttachNodeTrackingRequest>(
8021            &mut payload,
8022            0x3f22f2a293d3cdac,
8023            fidl::encoding::DynamicFlags::FLEXIBLE,
8024        )
8025    }
8026
8027    fn r#create_child(
8028        &self,
8029        mut payload: BufferCollectionTokenGroupCreateChildRequest,
8030    ) -> Result<(), fidl::Error> {
8031        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
8032            &mut payload,
8033            0x41a0075d419f30c5,
8034            fidl::encoding::DynamicFlags::FLEXIBLE,
8035        )
8036    }
8037
8038    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
8039        BufferCollectionTokenGroupCreateChildrenSyncResponse,
8040        fdomain_client::fidl::FDomainResourceDialect,
8041    >;
8042    fn r#create_children_sync(
8043        &self,
8044        mut payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
8045    ) -> Self::CreateChildrenSyncResponseFut {
8046        fn _decode(
8047            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8048        ) -> Result<BufferCollectionTokenGroupCreateChildrenSyncResponse, fidl::Error> {
8049            let _response = fidl::client::decode_transaction_body::<
8050                fidl::encoding::FlexibleType<BufferCollectionTokenGroupCreateChildrenSyncResponse>,
8051                fdomain_client::fidl::FDomainResourceDialect,
8052                0x15dea448c536070a,
8053            >(_buf?)?
8054            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("create_children_sync")?;
8055            Ok(_response)
8056        }
8057        self.client.send_query_and_decode::<
8058            BufferCollectionTokenGroupCreateChildrenSyncRequest,
8059            BufferCollectionTokenGroupCreateChildrenSyncResponse,
8060        >(
8061            payload,
8062            0x15dea448c536070a,
8063            fidl::encoding::DynamicFlags::FLEXIBLE,
8064            _decode,
8065        )
8066    }
8067
8068    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
8069        self.client.send::<fidl::encoding::EmptyPayload>(
8070            (),
8071            0x5c327e4a23391312,
8072            fidl::encoding::DynamicFlags::FLEXIBLE,
8073        )
8074    }
8075}
8076
8077pub struct BufferCollectionTokenGroupEventStream {
8078    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
8079}
8080
8081impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
8082
8083impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
8084    fn is_terminated(&self) -> bool {
8085        self.event_receiver.is_terminated()
8086    }
8087}
8088
8089impl futures::Stream for BufferCollectionTokenGroupEventStream {
8090    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
8091
8092    fn poll_next(
8093        mut self: std::pin::Pin<&mut Self>,
8094        cx: &mut std::task::Context<'_>,
8095    ) -> std::task::Poll<Option<Self::Item>> {
8096        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8097            &mut self.event_receiver,
8098            cx
8099        )?) {
8100            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
8101            None => std::task::Poll::Ready(None),
8102        }
8103    }
8104}
8105
8106#[derive(Debug)]
8107pub enum BufferCollectionTokenGroupEvent {
8108    #[non_exhaustive]
8109    _UnknownEvent {
8110        /// Ordinal of the event that was sent.
8111        ordinal: u64,
8112    },
8113}
8114
8115impl BufferCollectionTokenGroupEvent {
8116    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
8117    fn decode(
8118        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8119    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
8120        let (bytes, _handles) = buf.split_mut();
8121        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8122        debug_assert_eq!(tx_header.tx_id, 0);
8123        match tx_header.ordinal {
8124            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8125                Ok(BufferCollectionTokenGroupEvent::_UnknownEvent {
8126                    ordinal: tx_header.ordinal,
8127                })
8128            }
8129            _ => Err(fidl::Error::UnknownOrdinal {
8130                ordinal: tx_header.ordinal,
8131                protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8132            })
8133        }
8134    }
8135}
8136
8137/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollectionTokenGroup.
8138pub struct BufferCollectionTokenGroupRequestStream {
8139    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8140    is_terminated: bool,
8141}
8142
8143impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
8144
8145impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
8146    fn is_terminated(&self) -> bool {
8147        self.is_terminated
8148    }
8149}
8150
8151impl fdomain_client::fidl::RequestStream for BufferCollectionTokenGroupRequestStream {
8152    type Protocol = BufferCollectionTokenGroupMarker;
8153    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8154
8155    fn from_channel(channel: fdomain_client::Channel) -> Self {
8156        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8157    }
8158
8159    fn control_handle(&self) -> Self::ControlHandle {
8160        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
8161    }
8162
8163    fn into_inner(
8164        self,
8165    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
8166    {
8167        (self.inner, self.is_terminated)
8168    }
8169
8170    fn from_inner(
8171        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8172        is_terminated: bool,
8173    ) -> Self {
8174        Self { inner, is_terminated }
8175    }
8176}
8177
8178impl futures::Stream for BufferCollectionTokenGroupRequestStream {
8179    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
8180
8181    fn poll_next(
8182        mut self: std::pin::Pin<&mut Self>,
8183        cx: &mut std::task::Context<'_>,
8184    ) -> std::task::Poll<Option<Self::Item>> {
8185        let this = &mut *self;
8186        if this.inner.check_shutdown(cx) {
8187            this.is_terminated = true;
8188            return std::task::Poll::Ready(None);
8189        }
8190        if this.is_terminated {
8191            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
8192        }
8193        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
8194            |bytes, handles| {
8195                match this.inner.channel().read_etc(cx, bytes, handles) {
8196                    std::task::Poll::Ready(Ok(())) => {}
8197                    std::task::Poll::Pending => return std::task::Poll::Pending,
8198                    std::task::Poll::Ready(Err(None)) => {
8199                        this.is_terminated = true;
8200                        return std::task::Poll::Ready(None);
8201                    }
8202                    std::task::Poll::Ready(Err(Some(e))) => {
8203                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8204                            e.into(),
8205                        ))));
8206                    }
8207                }
8208
8209                // A message has been received from the channel
8210                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8211
8212                std::task::Poll::Ready(Some(match header.ordinal {
8213                0x11ac2555cf575b54 => {
8214                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8215                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8216                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8217                    let control_handle = BufferCollectionTokenGroupControlHandle {
8218                        inner: this.inner.clone(),
8219                    };
8220                    Ok(BufferCollectionTokenGroupRequest::Sync {
8221                        responder: BufferCollectionTokenGroupSyncResponder {
8222                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8223                            tx_id: header.tx_id,
8224                        },
8225                    })
8226                }
8227                0x6a5cae7d6d6e04c6 => {
8228                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8229                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8230                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8231                    let control_handle = BufferCollectionTokenGroupControlHandle {
8232                        inner: this.inner.clone(),
8233                    };
8234                    Ok(BufferCollectionTokenGroupRequest::Release {
8235                        control_handle,
8236                    })
8237                }
8238                0xb41f1624f48c1e9 => {
8239                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8240                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
8241                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
8242                    let control_handle = BufferCollectionTokenGroupControlHandle {
8243                        inner: this.inner.clone(),
8244                    };
8245                    Ok(BufferCollectionTokenGroupRequest::SetName {payload: req,
8246                        control_handle,
8247                    })
8248                }
8249                0x5cde8914608d99b1 => {
8250                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8251                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
8252                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
8253                    let control_handle = BufferCollectionTokenGroupControlHandle {
8254                        inner: this.inner.clone(),
8255                    };
8256                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {payload: req,
8257                        control_handle,
8258                    })
8259                }
8260                0x716b0af13d5c0806 => {
8261                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8262                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
8263                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
8264                    let control_handle = BufferCollectionTokenGroupControlHandle {
8265                        inner: this.inner.clone(),
8266                    };
8267                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {payload: req,
8268                        control_handle,
8269                    })
8270                }
8271                0x5209c77415b4dfad => {
8272                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8273                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8274                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8275                    let control_handle = BufferCollectionTokenGroupControlHandle {
8276                        inner: this.inner.clone(),
8277                    };
8278                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
8279                        control_handle,
8280                    })
8281                }
8282                0x5b3d0e51614df053 => {
8283                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8284                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8285                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8286                    let control_handle = BufferCollectionTokenGroupControlHandle {
8287                        inner: this.inner.clone(),
8288                    };
8289                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
8290                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
8291                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8292                            tx_id: header.tx_id,
8293                        },
8294                    })
8295                }
8296                0x3a58e00157e0825 => {
8297                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8298                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
8299                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
8300                    let control_handle = BufferCollectionTokenGroupControlHandle {
8301                        inner: this.inner.clone(),
8302                    };
8303                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {payload: req,
8304                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
8305                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8306                            tx_id: header.tx_id,
8307                        },
8308                    })
8309                }
8310                0x77d19a494b78ba8c => {
8311                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8312                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8313                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8314                    let control_handle = BufferCollectionTokenGroupControlHandle {
8315                        inner: this.inner.clone(),
8316                    };
8317                    Ok(BufferCollectionTokenGroupRequest::GetBufferCollectionId {
8318                        responder: BufferCollectionTokenGroupGetBufferCollectionIdResponder {
8319                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8320                            tx_id: header.tx_id,
8321                        },
8322                    })
8323                }
8324                0x22dd3ea514eeffe1 => {
8325                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8326                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8327                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8328                    let control_handle = BufferCollectionTokenGroupControlHandle {
8329                        inner: this.inner.clone(),
8330                    };
8331                    Ok(BufferCollectionTokenGroupRequest::SetWeak {
8332                        control_handle,
8333                    })
8334                }
8335                0x38a44fc4d7724be9 => {
8336                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8337                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
8338                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
8339                    let control_handle = BufferCollectionTokenGroupControlHandle {
8340                        inner: this.inner.clone(),
8341                    };
8342                    Ok(BufferCollectionTokenGroupRequest::SetWeakOk {payload: req,
8343                        control_handle,
8344                    })
8345                }
8346                0x3f22f2a293d3cdac => {
8347                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8348                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
8349                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
8350                    let control_handle = BufferCollectionTokenGroupControlHandle {
8351                        inner: this.inner.clone(),
8352                    };
8353                    Ok(BufferCollectionTokenGroupRequest::AttachNodeTracking {payload: req,
8354                        control_handle,
8355                    })
8356                }
8357                0x41a0075d419f30c5 => {
8358                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8359                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fdomain_client::fidl::FDomainResourceDialect);
8360                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
8361                    let control_handle = BufferCollectionTokenGroupControlHandle {
8362                        inner: this.inner.clone(),
8363                    };
8364                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
8365                        control_handle,
8366                    })
8367                }
8368                0x15dea448c536070a => {
8369                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8370                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
8371                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
8372                    let control_handle = BufferCollectionTokenGroupControlHandle {
8373                        inner: this.inner.clone(),
8374                    };
8375                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {payload: req,
8376                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
8377                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8378                            tx_id: header.tx_id,
8379                        },
8380                    })
8381                }
8382                0x5c327e4a23391312 => {
8383                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8384                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8385                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8386                    let control_handle = BufferCollectionTokenGroupControlHandle {
8387                        inner: this.inner.clone(),
8388                    };
8389                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
8390                        control_handle,
8391                    })
8392                }
8393                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8394                    Ok(BufferCollectionTokenGroupRequest::_UnknownMethod {
8395                        ordinal: header.ordinal,
8396                        control_handle: BufferCollectionTokenGroupControlHandle { inner: this.inner.clone() },
8397                        method_type: fidl::MethodType::OneWay,
8398                    })
8399                }
8400                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8401                    this.inner.send_framework_err(
8402                        fidl::encoding::FrameworkErr::UnknownMethod,
8403                        header.tx_id,
8404                        header.ordinal,
8405                        header.dynamic_flags(),
8406                        (bytes, handles),
8407                    )?;
8408                    Ok(BufferCollectionTokenGroupRequest::_UnknownMethod {
8409                        ordinal: header.ordinal,
8410                        control_handle: BufferCollectionTokenGroupControlHandle { inner: this.inner.clone() },
8411                        method_type: fidl::MethodType::TwoWay,
8412                    })
8413                }
8414                _ => Err(fidl::Error::UnknownOrdinal {
8415                    ordinal: header.ordinal,
8416                    protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8417                }),
8418            }))
8419            },
8420        )
8421    }
8422}
8423
8424/// The sysmem implementation is consistent with a logical / conceptual model of
8425/// allocation / logical allocation as follows:
8426///
8427/// As usual, a logical allocation considers either the root and all nodes with
8428/// connectivity to the root that don't transit a [`fuchsia.sysmem2/Node`]
8429/// created with [`fuchsia.sysmem2/BufferCollection.AttachToken`], or a subtree
8430/// rooted at an `AttachToken` `Node` and all `Node`(s) with connectivity to
8431/// that subtree that don't transit another `AttachToken`.  This is called the
8432/// logical allocation pruned subtree, or pruned subtree for short.
8433///
8434/// During constraints aggregation, each
8435/// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] will select a single child
8436/// `Node` among its direct children. The rest of the children will appear to
8437/// fail the logical allocation, while the selected child may succeed.
8438///
8439/// When more than one `BufferCollectionTokenGroup` exists in the overall
8440/// logical allocation pruned subtree, the relative priority between two groups
8441/// is equivalent to their ordering in a DFS pre-order iteration of the tree,
8442/// with parents higher priority than children, and left children higher
8443/// priority than right children.
8444///
8445/// When a particular child of a group is selected (whether provisionally during
8446/// a constraints aggregation attempt, or as a final selection), the
8447/// non-selection of other children of the group will "hide" any other groups
8448/// under those non-selected children.
8449///
8450/// Within a logical allocation, aggregation is attempted first by provisionally
8451/// selecting child 0 of the highest-priority group, and child 0 of the next
8452/// highest-priority group that isn't hidden by the provisional selections so
8453/// far, etc.
8454///
8455/// If that aggregation attempt fails, aggregation will be attempted with the
8456/// ordinal 0 child of all the same groups except the lowest priority non-hidden
8457/// group which will provisionally select its ordinal 1 child (and then child 2
8458/// and so on). If a new lowest-priority group is un-hidden as provisional
8459/// selections are updated, that newly un-hidden lowest-priority group has all
8460/// its children considered in order, before changing the provisional selection
8461/// in the former lowest-priority group. In terms of result, this is equivalent
8462/// to systematic enumeration of all possible combinations of choices in a
8463/// counting-like order updating the lowest-priority group the most often and
8464/// the highest-priority group the least often. Rather than actually attempting
8465/// aggregation with all the combinations, we can skip over combinations which
8466/// are redundant/equivalent due to hiding without any change to the result.
8467///
8468/// Attempted constraint aggregations of enumerated non-equivalent combinations
8469/// of choices continue in this manner until either (a) all aggregation attempts
8470/// fail in which case the overall logical allocation fails, or (b) until an
8471/// attempted aggregation succeeds, in which case buffer allocation (if needed;
8472/// if this is the pruned subtree rooted at the overall root `Node`) is
8473/// attempted once. If buffer allocation based on the first successful
8474/// constraints aggregation fails, the overall logical allocation fails (there
8475/// is no buffer allocation retry / re-attempt). If buffer allocation succeeds
8476/// (or is not needed due to being a pruned subtree that doesn't include the
8477/// root), the logical allocation succeeds.
8478///
8479/// If this prioritization scheme cannot reasonably work for your usage of
8480/// sysmem, please don't hesitate to contact sysmem folks to discuss potentially
8481/// adding a way to achieve what you need.
8482///
8483/// Please avoid creating a large number of `BufferCollectionTokenGroup`(s) per
8484/// logical allocation, especially with large number of children overall, and
8485/// especially in cases where aggregation may reasonably be expected to often
8486/// fail using ordinal 0 children and possibly with later children as well.
8487/// Sysmem mitigates potentially high time complexity of evaluating too many
8488/// child combinations/selections across too many groups by simply failing
8489/// logical allocation beyond a certain (fairly high, but not huge) max number
8490/// of considered group child combinations/selections. More advanced (and more
8491/// complicated) mitigation is not anticipated to be practically necessary or
8492/// worth the added complexity. Please contact sysmem folks if the max limit is
8493/// getting hit or if you anticipate it getting hit, to discuss potential
8494/// options.
8495///
8496/// Prefer to use multiple [`fuchsia.sysmem2/ImageFormatConstraints`] in a
8497/// single [`fuchsia.sysmem2/BufferCollectionConstraints`] when feasible (when a
8498/// participant just needs to express the ability to work with more than a
8499/// single [`fuchsia.images2/PixelFormat`], with sysmem choosing which
8500/// `PixelFormat` to use among those supported by all participants).
8501///
8502/// Similar to [`fuchsia.sysmem2/BufferCollectionToken`] and
8503/// [`fuchsia.sysmem2/BufferCollection`], closure of the
8504/// `BufferCollectionTokenGroup` channel without sending
8505/// [`fuchsia.sysmem2/Node.Release`] first will cause buffer collection failure
8506/// (or subtree failure if using
8507/// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
8508/// [`fuchsia.sysmem2/BufferCollection.AttachToken`] and the
8509/// `BufferCollectionTokenGroup` is part of a subtree under such a node that
8510/// doesn't propagate failure to its parent).
8511///
8512/// Epitaphs are not used in this protocol.
8513#[derive(Debug)]
8514pub enum BufferCollectionTokenGroupRequest {
8515    /// Ensure that previous messages have been received server side. This is
8516    /// particularly useful after previous messages that created new tokens,
8517    /// because a token must be known to the sysmem server before sending the
8518    /// token to another participant.
8519    ///
8520    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
8521    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
8522    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
8523    /// to mitigate the possibility of a hostile/fake
8524    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
8525    /// Another way is to pass the token to
8526    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
8527    /// the token as part of exchanging it for a
8528    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
8529    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
8530    /// of stalling.
8531    ///
8532    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
8533    /// and then starting and completing a `Sync`, it's then safe to send the
8534    /// `BufferCollectionToken` client ends to other participants knowing the
8535    /// server will recognize the tokens when they're sent by the other
8536    /// participants to sysmem in a
8537    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
8538    /// efficient way to create tokens while avoiding unnecessary round trips.
8539    ///
8540    /// Other options include waiting for each
8541    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
8542    /// individually (using separate call to `Sync` after each), or calling
8543    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
8544    /// converted to a `BufferCollection` via
8545    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
8546    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
8547    /// the sync step and can create multiple tokens at once.
8548    Sync { responder: BufferCollectionTokenGroupSyncResponder },
8549    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
8550    ///
8551    /// Normally a participant will convert a `BufferCollectionToken` into a
8552    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
8553    /// `Release` via the token (and then close the channel immediately or
8554    /// shortly later in response to server closing the server end), which
8555    /// avoids causing buffer collection failure. Without a prior `Release`,
8556    /// closing the `BufferCollectionToken` client end will cause buffer
8557    /// collection failure.
8558    ///
8559    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
8560    ///
8561    /// By default the server handles unexpected closure of a
8562    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
8563    /// first) by failing the buffer collection. Partly this is to expedite
8564    /// closing VMO handles to reclaim memory when any participant fails. If a
8565    /// participant would like to cleanly close a `BufferCollection` without
8566    /// causing buffer collection failure, the participant can send `Release`
8567    /// before closing the `BufferCollection` client end. The `Release` can
8568    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
8569    /// buffer collection won't require constraints from this node in order to
8570    /// allocate. If after `SetConstraints`, the constraints are retained and
8571    /// aggregated, despite the lack of `BufferCollection` connection at the
8572    /// time of constraints aggregation.
8573    ///
8574    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
8575    ///
8576    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
8577    /// end (without `Release` first) will trigger failure of the buffer
8578    /// collection. To close a `BufferCollectionTokenGroup` channel without
8579    /// failing the buffer collection, ensure that AllChildrenPresent() has been
8580    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
8581    /// client end.
8582    ///
8583    /// If `Release` occurs before
8584    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
8585    /// buffer collection will fail (triggered by reception of `Release` without
8586    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
8587    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
8588    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
8589    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
8590    /// close requires `AllChildrenPresent` (if not already sent), then
8591    /// `Release`, then close client end.
8592    ///
8593    /// If `Release` occurs after `AllChildrenPresent`, the children and all
8594    /// their constraints remain intact (just as they would if the
8595    /// `BufferCollectionTokenGroup` channel had remained open), and the client
8596    /// end close doesn't trigger buffer collection failure.
8597    ///
8598    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
8599    ///
8600    /// For brevity, the per-channel-protocol paragraphs above ignore the
8601    /// separate failure domain created by
8602    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
8603    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
8604    /// unexpectedly closes (without `Release` first) and that client end is
8605    /// under a failure domain, instead of failing the whole buffer collection,
8606    /// the failure domain is failed, but the buffer collection itself is
8607    /// isolated from failure of the failure domain. Such failure domains can be
8608    /// nested, in which case only the inner-most failure domain in which the
8609    /// `Node` resides fails.
8610    Release { control_handle: BufferCollectionTokenGroupControlHandle },
8611    /// Set a name for VMOs in this buffer collection.
8612    ///
8613    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
8614    /// will be truncated to fit. The name of the vmo will be suffixed with the
8615    /// buffer index within the collection (if the suffix fits within
8616    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
8617    /// listed in the inspect data.
8618    ///
8619    /// The name only affects VMOs allocated after the name is set; this call
8620    /// does not rename existing VMOs. If multiple clients set different names
8621    /// then the larger priority value will win. Setting a new name with the
8622    /// same priority as a prior name doesn't change the name.
8623    ///
8624    /// All table fields are currently required.
8625    ///
8626    /// + request `priority` The name is only set if this is the first `SetName`
8627    ///   or if `priority` is greater than any previous `priority` value in
8628    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
8629    /// + request `name` The name for VMOs created under this buffer collection.
8630    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionTokenGroupControlHandle },
8631    /// Set information about the current client that can be used by sysmem to
8632    /// help diagnose leaking memory and allocation stalls waiting for a
8633    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
8634    ///
8635    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
8636    /// `Node`(s) derived from this `Node`, unless overriden by
8637    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
8638    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
8639    ///
8640    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
8641    /// `Allocator` is the most efficient way to ensure that all
8642    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
8643    /// set, and is also more efficient than separately sending the same debug
8644    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
8645    /// created [`fuchsia.sysmem2/Node`].
8646    ///
8647    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
8648    /// indicate which client is closing their channel first, leading to subtree
8649    /// failure (which can be normal if the purpose of the subtree is over, but
8650    /// if happening earlier than expected, the client-channel-specific name can
8651    /// help diagnose where the failure is first coming from, from sysmem's
8652    /// point of view).
8653    ///
8654    /// All table fields are currently required.
8655    ///
8656    /// + request `name` This can be an arbitrary string, but the current
8657    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
8658    /// + request `id` This can be an arbitrary id, but the current process ID
8659    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
8660    SetDebugClientInfo {
8661        payload: NodeSetDebugClientInfoRequest,
8662        control_handle: BufferCollectionTokenGroupControlHandle,
8663    },
8664    /// Sysmem logs a warning if sysmem hasn't seen
8665    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
8666    /// within 5 seconds after creation of a new collection.
8667    ///
8668    /// Clients can call this method to change when the log is printed. If
8669    /// multiple client set the deadline, it's unspecified which deadline will
8670    /// take effect.
8671    ///
8672    /// In most cases the default works well.
8673    ///
8674    /// All table fields are currently required.
8675    ///
8676    /// + request `deadline` The time at which sysmem will start trying to log
8677    ///   the warning, unless all constraints are with sysmem by then.
8678    SetDebugTimeoutLogDeadline {
8679        payload: NodeSetDebugTimeoutLogDeadlineRequest,
8680        control_handle: BufferCollectionTokenGroupControlHandle,
8681    },
8682    /// This enables verbose logging for the buffer collection.
8683    ///
8684    /// Verbose logging includes constraints set via
8685    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
8686    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
8687    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
8688    /// the tree of `Node`(s).
8689    ///
8690    /// Normally sysmem prints only a single line complaint when aggregation
8691    /// fails, with just the specific detailed reason that aggregation failed,
8692    /// with little surrounding context.  While this is often enough to diagnose
8693    /// a problem if only a small change was made and everything was working
8694    /// before the small change, it's often not particularly helpful for getting
8695    /// a new buffer collection to work for the first time.  Especially with
8696    /// more complex trees of nodes, involving things like
8697    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
8698    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
8699    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
8700    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
8701    /// looks like and why it's failing a logical allocation, or why a tree or
8702    /// subtree is failing sooner than expected.
8703    ///
8704    /// The intent of the extra logging is to be acceptable from a performance
8705    /// point of view, under the assumption that verbose logging is only enabled
8706    /// on a low number of buffer collections. If we're not tracking down a bug,
8707    /// we shouldn't send this message.
8708    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
8709    /// This gets a handle that can be used as a parameter to
8710    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
8711    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
8712    /// client obtained this handle from this `Node`.
8713    ///
8714    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
8715    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
8716    /// despite the two calls typically being on different channels.
8717    ///
8718    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
8719    ///
8720    /// All table fields are currently required.
8721    ///
8722    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
8723    ///   different `Node` channel, to prove that the client obtained the handle
8724    ///   from this `Node`.
8725    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
8726    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
8727    /// rooted at a different child token of a common parent
8728    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
8729    /// passed-in `node_ref`.
8730    ///
8731    /// This call is for assisting with admission control de-duplication, and
8732    /// with debugging.
8733    ///
8734    /// The `node_ref` must be obtained using
8735    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
8736    ///
8737    /// The `node_ref` can be a duplicated handle; it's not necessary to call
8738    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
8739    ///
8740    /// If a calling token may not actually be a valid token at all due to a
8741    /// potentially hostile/untrusted provider of the token, call
8742    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
8743    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
8744    /// never responds due to a calling token not being a real token (not really
8745    /// talking to sysmem).  Another option is to call
8746    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
8747    /// which also validates the token along with converting it to a
8748    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
8749    ///
8750    /// All table fields are currently required.
8751    ///
8752    /// - response `is_alternate`
8753    ///   - true: The first parent node in common between the calling node and
8754    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
8755    ///     that the calling `Node` and the `node_ref` `Node` will not have both
8756    ///     their constraints apply - rather sysmem will choose one or the other
8757    ///     of the constraints - never both.  This is because only one child of
8758    ///     a `BufferCollectionTokenGroup` is selected during logical
8759    ///     allocation, with only that one child's subtree contributing to
8760    ///     constraints aggregation.
8761    ///   - false: The first parent node in common between the calling `Node`
8762    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
8763    ///     Currently, this means the first parent node in common is a
8764    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
8765    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
8766    ///     `Node` may have both their constraints apply during constraints
8767    ///     aggregation of the logical allocation, if both `Node`(s) are
8768    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
8769    ///     this case, there is no `BufferCollectionTokenGroup` that will
8770    ///     directly prevent the two `Node`(s) from both being selected and
8771    ///     their constraints both aggregated, but even when false, one or both
8772    ///     `Node`(s) may still be eliminated from consideration if one or both
8773    ///     `Node`(s) has a direct or indirect parent
8774    ///     `BufferCollectionTokenGroup` which selects a child subtree other
8775    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
8776    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
8777    ///   associated with the same buffer collection as the calling `Node`.
8778    ///   Another reason for this error is if the `node_ref` is an
8779    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
8780    ///   a real `node_ref` obtained from `GetNodeRef`.
8781    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
8782    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
8783    ///   the needed rights expected on a real `node_ref`.
8784    /// * No other failing status codes are returned by this call.  However,
8785    ///   sysmem may add additional codes in future, so the client should have
8786    ///   sensible default handling for any failing status code.
8787    IsAlternateFor {
8788        payload: NodeIsAlternateForRequest,
8789        responder: BufferCollectionTokenGroupIsAlternateForResponder,
8790    },
8791    /// Get the buffer collection ID. This ID is also available from
8792    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
8793    /// within the collection).
8794    ///
8795    /// This call is mainly useful in situations where we can't convey a
8796    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
8797    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
8798    /// handle, which can be joined back up with a `BufferCollection` client end
8799    /// that was created via a different path. Prefer to convey a
8800    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
8801    ///
8802    /// Trusting a `buffer_collection_id` value from a source other than sysmem
8803    /// is analogous to trusting a koid value from a source other than zircon.
8804    /// Both should be avoided unless really necessary, and both require
8805    /// caution. In some situations it may be reasonable to refer to a
8806    /// pre-established `BufferCollection` by `buffer_collection_id` via a
8807    /// protocol for efficiency reasons, but an incoming value purporting to be
8808    /// a `buffer_collection_id` is not sufficient alone to justify granting the
8809    /// sender of the `buffer_collection_id` any capability. The sender must
8810    /// first prove to a receiver that the sender has/had a VMO or has/had a
8811    /// `BufferCollectionToken` to the same collection by sending a handle that
8812    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
8813    /// `buffer_collection_id` value. The receiver should take care to avoid
8814    /// assuming that a sender had a `BufferCollectionToken` in cases where the
8815    /// sender has only proven that the sender had a VMO.
8816    ///
8817    /// - response `buffer_collection_id` This ID is unique per buffer
8818    ///   collection per boot. Each buffer is uniquely identified by the
8819    ///   `buffer_collection_id` and `buffer_index` together.
8820    GetBufferCollectionId { responder: BufferCollectionTokenGroupGetBufferCollectionIdResponder },
8821    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
8822    /// created after this message to weak, which means that a client's `Node`
8823    /// client end (or a child created after this message) is not alone
8824    /// sufficient to keep allocated VMOs alive.
8825    ///
8826    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
8827    /// `close_weak_asap`.
8828    ///
8829    /// This message is only permitted before the `Node` becomes ready for
8830    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
8831    ///   * `BufferCollectionToken`: any time
8832    ///   * `BufferCollection`: before `SetConstraints`
8833    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
8834    ///
8835    /// Currently, no conversion from strong `Node` to weak `Node` after ready
8836    /// for allocation is provided, but a client can simulate that by creating
8837    /// an additional `Node` before allocation and setting that additional
8838    /// `Node` to weak, and then potentially at some point later sending
8839    /// `Release` and closing the client end of the client's strong `Node`, but
8840    /// keeping the client's weak `Node`.
8841    ///
8842    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
8843    /// collection failure (all `Node` client end(s) will see
8844    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
8845    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
8846    /// this situation until all `Node`(s) are ready for allocation. For initial
8847    /// allocation to succeed, at least one strong `Node` is required to exist
8848    /// at allocation time, but after that client receives VMO handles, that
8849    /// client can `BufferCollection.Release` and close the client end without
8850    /// causing this type of failure.
8851    ///
8852    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
8853    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
8854    /// separately as appropriate.
8855    SetWeak { control_handle: BufferCollectionTokenGroupControlHandle },
8856    /// This indicates to sysmem that the client is prepared to pay attention to
8857    /// `close_weak_asap`.
8858    ///
8859    /// If sent, this message must be before
8860    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
8861    ///
8862    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
8863    /// send this message before `WaitForAllBuffersAllocated`, or a parent
8864    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
8865    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
8866    /// trigger buffer collection failure.
8867    ///
8868    /// This message is necessary because weak sysmem VMOs have not always been
8869    /// a thing, so older clients are not aware of the need to pay attention to
8870    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
8871    /// sysmem weak VMO handles asap. By having this message and requiring
8872    /// participants to indicate their acceptance of this aspect of the overall
8873    /// protocol, we avoid situations where an older client is delivered a weak
8874    /// VMO without any way for sysmem to get that VMO to close quickly later
8875    /// (and on a per-buffer basis).
8876    ///
8877    /// A participant that doesn't handle `close_weak_asap` and also doesn't
8878    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
8879    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
8880    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
8881    /// same participant has a child/delegate which does retrieve VMOs, that
8882    /// child/delegate will need to send `SetWeakOk` before
8883    /// `WaitForAllBuffersAllocated`.
8884    ///
8885    /// + request `for_child_nodes_also` If present and true, this means direct
8886    ///   child nodes of this node created after this message plus all
8887    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
8888    ///   those nodes. Any child node of this node that was created before this
8889    ///   message is not included. This setting is "sticky" in the sense that a
8890    ///   subsequent `SetWeakOk` without this bool set to true does not reset
8891    ///   the server-side bool. If this creates a problem for a participant, a
8892    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
8893    ///   tokens instead, as appropriate. A participant should only set
8894    ///   `for_child_nodes_also` true if the participant can really promise to
8895    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
8896    ///   weak VMO handles held by participants holding the corresponding child
8897    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
8898    ///   which are using sysmem(1) can be weak, despite the clients of those
8899    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
8900    ///   direct way to find out about `close_weak_asap`. This only applies to
8901    ///   descendents of this `Node` which are using sysmem(1), not to this
8902    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
8903    ///   token, which will fail allocation unless an ancestor of this `Node`
8904    ///   specified `for_child_nodes_also` true.
8905    SetWeakOk {
8906        payload: NodeSetWeakOkRequest,
8907        control_handle: BufferCollectionTokenGroupControlHandle,
8908    },
8909    /// The server_end will be closed after this `Node` and any child nodes have
8910    /// have released their buffer counts, making those counts available for
8911    /// reservation by a different `Node` via
8912    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
8913    ///
8914    /// The `Node` buffer counts may not be released until the entire tree of
8915    /// `Node`(s) is closed or failed, because
8916    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
8917    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
8918    /// `Node` buffer counts remain reserved until the orphaned node is later
8919    /// cleaned up.
8920    ///
8921    /// If the `Node` exceeds a fairly large number of attached eventpair server
8922    /// ends, a log message will indicate this and the `Node` (and the
8923    /// appropriate) sub-tree will fail.
8924    ///
8925    /// The `server_end` will remain open when
8926    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
8927    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
8928    /// [`fuchsia.sysmem2/BufferCollection`].
8929    ///
8930    /// This message can also be used with a
8931    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
8932    AttachNodeTracking {
8933        payload: NodeAttachNodeTrackingRequest,
8934        control_handle: BufferCollectionTokenGroupControlHandle,
8935    },
8936    /// Create a child [`fuchsia.sysmem2/BufferCollectionToken`]. Only one child
8937    /// (including its children) will be selected during allocation (or logical
8938    /// allocation).
8939    ///
8940    /// Before passing the client end of this token to
8941    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], completion of
8942    /// [`fuchsia.sysmem2/Node.Sync`] after
8943    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] is required.
8944    /// Or the client can use
8945    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`] which
8946    /// essentially includes the `Sync`.
8947    ///
8948    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
8949    /// fail the group's subtree and close the connection.
8950    ///
8951    /// After all children have been created, send AllChildrenPresent.
8952    ///
8953    /// + request `token_request` The server end of the new token channel.
8954    /// + request `rights_attenuation_mask` If ZX_RIGHT_SAME_RIGHTS, the created
8955    ///   token allows the holder to get the same rights to buffers as the
8956    ///   parent token (of the group) had. When the value isn't
8957    ///   ZX_RIGHT_SAME_RIGHTS, the value is interpretted as a bitmask with 0
8958    ///   bits ensuring those rights are attentuated, so 0xFFFFFFFF is a synonym
8959    ///   for ZX_RIGHT_SAME_RIGHTS. The value 0 is not allowed and intentionally
8960    ///   causes subtree failure.
8961    CreateChild {
8962        payload: BufferCollectionTokenGroupCreateChildRequest,
8963        control_handle: BufferCollectionTokenGroupControlHandle,
8964    },
8965    /// Create 1 or more child tokens at once, synchronously.  In contrast to
8966    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`], no
8967    /// [`fuchsia.sysmem2/Node.Sync`] is required before passing the client end
8968    /// of a returned token to
8969    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`].
8970    ///
8971    /// The lower-index child tokens are higher priority (attempted sooner) than
8972    /// higher-index child tokens.
8973    ///
8974    /// As per all child tokens, successful aggregation will choose exactly one
8975    /// child among all created children (across all children created across
8976    /// potentially multiple calls to
8977    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] and
8978    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`]).
8979    ///
8980    /// The maximum permissible total number of children per group, and total
8981    /// number of nodes in an overall tree (from the root) are capped to limits
8982    /// which are not configurable via these protocols.
8983    ///
8984    /// Sending CreateChildrenSync after AllChildrenPresent is not permitted;
8985    /// this will fail the group's subtree and close the connection.
8986    ///
8987    /// After all children have been created, send AllChildrenPresent.
8988    ///
8989    /// + request `rights_attentuation_masks` The size of the
8990    ///   `rights_attentuation_masks` determines the number of created child
8991    ///   tokens. The value ZX_RIGHT_SAME_RIGHTS doesn't attenuate any rights.
8992    ///   The value 0xFFFFFFFF is a synonym for ZX_RIGHT_SAME_RIGHTS. For any
8993    ///   other value, each 0 bit in the mask attenuates that right.
8994    /// - response `tokens` The created child tokens.
8995    CreateChildrenSync {
8996        payload: BufferCollectionTokenGroupCreateChildrenSyncRequest,
8997        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
8998    },
8999    /// Indicate that no more children will be created.
9000    ///
9001    /// After creating all children, the client should send
9002    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent`] to
9003    /// inform sysmem that no more children will be created, so that sysmem can
9004    /// know when it's ok to start aggregating constraints.
9005    ///
9006    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
9007    /// fail the group's subtree and close the connection.
9008    ///
9009    /// If [`fuchsia.sysmem2/Node.Release`] is to be sent, it should be sent
9010    /// after `AllChildrenPresent`, else failure of the group's subtree will be
9011    /// triggered. This is intentionally not analogous to how `Release` without
9012    /// prior [`fuchsia.sysmem2/BufferCollection.SetConstraints`] doesn't cause
9013    /// subtree failure.
9014    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
9015    /// An interaction was received which does not match any known method.
9016    #[non_exhaustive]
9017    _UnknownMethod {
9018        /// Ordinal of the method that was called.
9019        ordinal: u64,
9020        control_handle: BufferCollectionTokenGroupControlHandle,
9021        method_type: fidl::MethodType,
9022    },
9023}
9024
9025impl BufferCollectionTokenGroupRequest {
9026    #[allow(irrefutable_let_patterns)]
9027    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
9028        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
9029            Some((responder))
9030        } else {
9031            None
9032        }
9033    }
9034
9035    #[allow(irrefutable_let_patterns)]
9036    pub fn into_release(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9037        if let BufferCollectionTokenGroupRequest::Release { control_handle } = self {
9038            Some((control_handle))
9039        } else {
9040            None
9041        }
9042    }
9043
9044    #[allow(irrefutable_let_patterns)]
9045    pub fn into_set_name(
9046        self,
9047    ) -> Option<(NodeSetNameRequest, BufferCollectionTokenGroupControlHandle)> {
9048        if let BufferCollectionTokenGroupRequest::SetName { payload, control_handle } = self {
9049            Some((payload, control_handle))
9050        } else {
9051            None
9052        }
9053    }
9054
9055    #[allow(irrefutable_let_patterns)]
9056    pub fn into_set_debug_client_info(
9057        self,
9058    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionTokenGroupControlHandle)> {
9059        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { payload, control_handle } =
9060            self
9061        {
9062            Some((payload, control_handle))
9063        } else {
9064            None
9065        }
9066    }
9067
9068    #[allow(irrefutable_let_patterns)]
9069    pub fn into_set_debug_timeout_log_deadline(
9070        self,
9071    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionTokenGroupControlHandle)>
9072    {
9073        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
9074            payload,
9075            control_handle,
9076        } = self
9077        {
9078            Some((payload, control_handle))
9079        } else {
9080            None
9081        }
9082    }
9083
9084    #[allow(irrefutable_let_patterns)]
9085    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9086        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
9087            Some((control_handle))
9088        } else {
9089            None
9090        }
9091    }
9092
9093    #[allow(irrefutable_let_patterns)]
9094    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
9095        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
9096            Some((responder))
9097        } else {
9098            None
9099        }
9100    }
9101
9102    #[allow(irrefutable_let_patterns)]
9103    pub fn into_is_alternate_for(
9104        self,
9105    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionTokenGroupIsAlternateForResponder)>
9106    {
9107        if let BufferCollectionTokenGroupRequest::IsAlternateFor { payload, responder } = self {
9108            Some((payload, responder))
9109        } else {
9110            None
9111        }
9112    }
9113
9114    #[allow(irrefutable_let_patterns)]
9115    pub fn into_get_buffer_collection_id(
9116        self,
9117    ) -> Option<(BufferCollectionTokenGroupGetBufferCollectionIdResponder)> {
9118        if let BufferCollectionTokenGroupRequest::GetBufferCollectionId { responder } = self {
9119            Some((responder))
9120        } else {
9121            None
9122        }
9123    }
9124
9125    #[allow(irrefutable_let_patterns)]
9126    pub fn into_set_weak(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9127        if let BufferCollectionTokenGroupRequest::SetWeak { control_handle } = self {
9128            Some((control_handle))
9129        } else {
9130            None
9131        }
9132    }
9133
9134    #[allow(irrefutable_let_patterns)]
9135    pub fn into_set_weak_ok(
9136        self,
9137    ) -> Option<(NodeSetWeakOkRequest, BufferCollectionTokenGroupControlHandle)> {
9138        if let BufferCollectionTokenGroupRequest::SetWeakOk { payload, control_handle } = self {
9139            Some((payload, control_handle))
9140        } else {
9141            None
9142        }
9143    }
9144
9145    #[allow(irrefutable_let_patterns)]
9146    pub fn into_attach_node_tracking(
9147        self,
9148    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionTokenGroupControlHandle)> {
9149        if let BufferCollectionTokenGroupRequest::AttachNodeTracking { payload, control_handle } =
9150            self
9151        {
9152            Some((payload, control_handle))
9153        } else {
9154            None
9155        }
9156    }
9157
9158    #[allow(irrefutable_let_patterns)]
9159    pub fn into_create_child(
9160        self,
9161    ) -> Option<(
9162        BufferCollectionTokenGroupCreateChildRequest,
9163        BufferCollectionTokenGroupControlHandle,
9164    )> {
9165        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
9166            Some((payload, control_handle))
9167        } else {
9168            None
9169        }
9170    }
9171
9172    #[allow(irrefutable_let_patterns)]
9173    pub fn into_create_children_sync(
9174        self,
9175    ) -> Option<(
9176        BufferCollectionTokenGroupCreateChildrenSyncRequest,
9177        BufferCollectionTokenGroupCreateChildrenSyncResponder,
9178    )> {
9179        if let BufferCollectionTokenGroupRequest::CreateChildrenSync { payload, responder } = self {
9180            Some((payload, responder))
9181        } else {
9182            None
9183        }
9184    }
9185
9186    #[allow(irrefutable_let_patterns)]
9187    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9188        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
9189            Some((control_handle))
9190        } else {
9191            None
9192        }
9193    }
9194
9195    /// Name of the method defined in FIDL
9196    pub fn method_name(&self) -> &'static str {
9197        match *self {
9198            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
9199            BufferCollectionTokenGroupRequest::Release { .. } => "release",
9200            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
9201            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
9202            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
9203                "set_debug_timeout_log_deadline"
9204            }
9205            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
9206            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
9207            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
9208            BufferCollectionTokenGroupRequest::GetBufferCollectionId { .. } => {
9209                "get_buffer_collection_id"
9210            }
9211            BufferCollectionTokenGroupRequest::SetWeak { .. } => "set_weak",
9212            BufferCollectionTokenGroupRequest::SetWeakOk { .. } => "set_weak_ok",
9213            BufferCollectionTokenGroupRequest::AttachNodeTracking { .. } => "attach_node_tracking",
9214            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
9215            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
9216            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
9217            BufferCollectionTokenGroupRequest::_UnknownMethod {
9218                method_type: fidl::MethodType::OneWay,
9219                ..
9220            } => "unknown one-way method",
9221            BufferCollectionTokenGroupRequest::_UnknownMethod {
9222                method_type: fidl::MethodType::TwoWay,
9223                ..
9224            } => "unknown two-way method",
9225        }
9226    }
9227}
9228
9229#[derive(Debug, Clone)]
9230pub struct BufferCollectionTokenGroupControlHandle {
9231    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9232}
9233
9234impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenGroupControlHandle {
9235    fn shutdown(&self) {
9236        self.inner.shutdown()
9237    }
9238
9239    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
9240        self.inner.shutdown_with_epitaph(status)
9241    }
9242
9243    fn is_closed(&self) -> bool {
9244        self.inner.channel().is_closed()
9245    }
9246    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9247        self.inner.channel().on_closed()
9248    }
9249}
9250
9251impl BufferCollectionTokenGroupControlHandle {}
9252
9253#[must_use = "FIDL methods require a response to be sent"]
9254#[derive(Debug)]
9255pub struct BufferCollectionTokenGroupSyncResponder {
9256    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9257    tx_id: u32,
9258}
9259
9260/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9261/// if the responder is dropped without sending a response, so that the client
9262/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9263impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
9264    fn drop(&mut self) {
9265        self.control_handle.shutdown();
9266        // Safety: drops once, never accessed again
9267        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9268    }
9269}
9270
9271impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupSyncResponder {
9272    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9273
9274    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9275        &self.control_handle
9276    }
9277
9278    fn drop_without_shutdown(mut self) {
9279        // Safety: drops once, never accessed again due to mem::forget
9280        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9281        // Prevent Drop from running (which would shut down the channel)
9282        std::mem::forget(self);
9283    }
9284}
9285
9286impl BufferCollectionTokenGroupSyncResponder {
9287    /// Sends a response to the FIDL transaction.
9288    ///
9289    /// Sets the channel to shutdown if an error occurs.
9290    pub fn send(self) -> Result<(), fidl::Error> {
9291        let _result = self.send_raw();
9292        if _result.is_err() {
9293            self.control_handle.shutdown();
9294        }
9295        self.drop_without_shutdown();
9296        _result
9297    }
9298
9299    /// Similar to "send" but does not shutdown the channel if an error occurs.
9300    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9301        let _result = self.send_raw();
9302        self.drop_without_shutdown();
9303        _result
9304    }
9305
9306    fn send_raw(&self) -> Result<(), fidl::Error> {
9307        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
9308            fidl::encoding::Flexible::new(()),
9309            self.tx_id,
9310            0x11ac2555cf575b54,
9311            fidl::encoding::DynamicFlags::FLEXIBLE,
9312        )
9313    }
9314}
9315
9316#[must_use = "FIDL methods require a response to be sent"]
9317#[derive(Debug)]
9318pub struct BufferCollectionTokenGroupGetNodeRefResponder {
9319    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9320    tx_id: u32,
9321}
9322
9323/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9324/// if the responder is dropped without sending a response, so that the client
9325/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9326impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
9327    fn drop(&mut self) {
9328        self.control_handle.shutdown();
9329        // Safety: drops once, never accessed again
9330        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9331    }
9332}
9333
9334impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
9335    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9336
9337    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9338        &self.control_handle
9339    }
9340
9341    fn drop_without_shutdown(mut self) {
9342        // Safety: drops once, never accessed again due to mem::forget
9343        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9344        // Prevent Drop from running (which would shut down the channel)
9345        std::mem::forget(self);
9346    }
9347}
9348
9349impl BufferCollectionTokenGroupGetNodeRefResponder {
9350    /// Sends a response to the FIDL transaction.
9351    ///
9352    /// Sets the channel to shutdown if an error occurs.
9353    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
9354        let _result = self.send_raw(payload);
9355        if _result.is_err() {
9356            self.control_handle.shutdown();
9357        }
9358        self.drop_without_shutdown();
9359        _result
9360    }
9361
9362    /// Similar to "send" but does not shutdown the channel if an error occurs.
9363    pub fn send_no_shutdown_on_err(
9364        self,
9365        mut payload: NodeGetNodeRefResponse,
9366    ) -> Result<(), fidl::Error> {
9367        let _result = self.send_raw(payload);
9368        self.drop_without_shutdown();
9369        _result
9370    }
9371
9372    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
9373        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
9374            fidl::encoding::Flexible::new(&mut payload),
9375            self.tx_id,
9376            0x5b3d0e51614df053,
9377            fidl::encoding::DynamicFlags::FLEXIBLE,
9378        )
9379    }
9380}
9381
9382#[must_use = "FIDL methods require a response to be sent"]
9383#[derive(Debug)]
9384pub struct BufferCollectionTokenGroupIsAlternateForResponder {
9385    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9386    tx_id: u32,
9387}
9388
9389/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9390/// if the responder is dropped without sending a response, so that the client
9391/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9392impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
9393    fn drop(&mut self) {
9394        self.control_handle.shutdown();
9395        // Safety: drops once, never accessed again
9396        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9397    }
9398}
9399
9400impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
9401    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9402
9403    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9404        &self.control_handle
9405    }
9406
9407    fn drop_without_shutdown(mut self) {
9408        // Safety: drops once, never accessed again due to mem::forget
9409        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9410        // Prevent Drop from running (which would shut down the channel)
9411        std::mem::forget(self);
9412    }
9413}
9414
9415impl BufferCollectionTokenGroupIsAlternateForResponder {
9416    /// Sends a response to the FIDL transaction.
9417    ///
9418    /// Sets the channel to shutdown if an error occurs.
9419    pub fn send(
9420        self,
9421        mut result: Result<&NodeIsAlternateForResponse, Error>,
9422    ) -> Result<(), fidl::Error> {
9423        let _result = self.send_raw(result);
9424        if _result.is_err() {
9425            self.control_handle.shutdown();
9426        }
9427        self.drop_without_shutdown();
9428        _result
9429    }
9430
9431    /// Similar to "send" but does not shutdown the channel if an error occurs.
9432    pub fn send_no_shutdown_on_err(
9433        self,
9434        mut result: Result<&NodeIsAlternateForResponse, Error>,
9435    ) -> Result<(), fidl::Error> {
9436        let _result = self.send_raw(result);
9437        self.drop_without_shutdown();
9438        _result
9439    }
9440
9441    fn send_raw(
9442        &self,
9443        mut result: Result<&NodeIsAlternateForResponse, Error>,
9444    ) -> Result<(), fidl::Error> {
9445        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
9446            NodeIsAlternateForResponse,
9447            Error,
9448        >>(
9449            fidl::encoding::FlexibleResult::new(result),
9450            self.tx_id,
9451            0x3a58e00157e0825,
9452            fidl::encoding::DynamicFlags::FLEXIBLE,
9453        )
9454    }
9455}
9456
9457#[must_use = "FIDL methods require a response to be sent"]
9458#[derive(Debug)]
9459pub struct BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9460    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9461    tx_id: u32,
9462}
9463
9464/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9465/// if the responder is dropped without sending a response, so that the client
9466/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9467impl std::ops::Drop for BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9468    fn drop(&mut self) {
9469        self.control_handle.shutdown();
9470        // Safety: drops once, never accessed again
9471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9472    }
9473}
9474
9475impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9476    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9477
9478    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9479        &self.control_handle
9480    }
9481
9482    fn drop_without_shutdown(mut self) {
9483        // Safety: drops once, never accessed again due to mem::forget
9484        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9485        // Prevent Drop from running (which would shut down the channel)
9486        std::mem::forget(self);
9487    }
9488}
9489
9490impl BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9491    /// Sends a response to the FIDL transaction.
9492    ///
9493    /// Sets the channel to shutdown if an error occurs.
9494    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
9495        let _result = self.send_raw(payload);
9496        if _result.is_err() {
9497            self.control_handle.shutdown();
9498        }
9499        self.drop_without_shutdown();
9500        _result
9501    }
9502
9503    /// Similar to "send" but does not shutdown the channel if an error occurs.
9504    pub fn send_no_shutdown_on_err(
9505        self,
9506        mut payload: &NodeGetBufferCollectionIdResponse,
9507    ) -> Result<(), fidl::Error> {
9508        let _result = self.send_raw(payload);
9509        self.drop_without_shutdown();
9510        _result
9511    }
9512
9513    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
9514        self.control_handle
9515            .inner
9516            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
9517                fidl::encoding::Flexible::new(payload),
9518                self.tx_id,
9519                0x77d19a494b78ba8c,
9520                fidl::encoding::DynamicFlags::FLEXIBLE,
9521            )
9522    }
9523}
9524
9525#[must_use = "FIDL methods require a response to be sent"]
9526#[derive(Debug)]
9527pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
9528    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9529    tx_id: u32,
9530}
9531
9532/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9533/// if the responder is dropped without sending a response, so that the client
9534/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9535impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
9536    fn drop(&mut self) {
9537        self.control_handle.shutdown();
9538        // Safety: drops once, never accessed again
9539        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9540    }
9541}
9542
9543impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
9544    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9545
9546    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9547        &self.control_handle
9548    }
9549
9550    fn drop_without_shutdown(mut self) {
9551        // Safety: drops once, never accessed again due to mem::forget
9552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9553        // Prevent Drop from running (which would shut down the channel)
9554        std::mem::forget(self);
9555    }
9556}
9557
9558impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
9559    /// Sends a response to the FIDL transaction.
9560    ///
9561    /// Sets the channel to shutdown if an error occurs.
9562    pub fn send(
9563        self,
9564        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9565    ) -> Result<(), fidl::Error> {
9566        let _result = self.send_raw(payload);
9567        if _result.is_err() {
9568            self.control_handle.shutdown();
9569        }
9570        self.drop_without_shutdown();
9571        _result
9572    }
9573
9574    /// Similar to "send" but does not shutdown the channel if an error occurs.
9575    pub fn send_no_shutdown_on_err(
9576        self,
9577        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9578    ) -> Result<(), fidl::Error> {
9579        let _result = self.send_raw(payload);
9580        self.drop_without_shutdown();
9581        _result
9582    }
9583
9584    fn send_raw(
9585        &self,
9586        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9587    ) -> Result<(), fidl::Error> {
9588        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
9589            BufferCollectionTokenGroupCreateChildrenSyncResponse,
9590        >>(
9591            fidl::encoding::Flexible::new(&mut payload),
9592            self.tx_id,
9593            0x15dea448c536070a,
9594            fidl::encoding::DynamicFlags::FLEXIBLE,
9595        )
9596    }
9597}
9598
9599#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9600pub struct NodeMarker;
9601
9602impl fdomain_client::fidl::ProtocolMarker for NodeMarker {
9603    type Proxy = NodeProxy;
9604    type RequestStream = NodeRequestStream;
9605
9606    const DEBUG_NAME: &'static str = "(anonymous) Node";
9607}
9608pub type NodeIsAlternateForResult = Result<NodeIsAlternateForResponse, Error>;
9609
9610pub trait NodeProxyInterface: Send + Sync {
9611    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9612    fn r#sync(&self) -> Self::SyncResponseFut;
9613    fn r#release(&self) -> Result<(), fidl::Error>;
9614    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
9615    fn r#set_debug_client_info(
9616        &self,
9617        payload: &NodeSetDebugClientInfoRequest,
9618    ) -> Result<(), fidl::Error>;
9619    fn r#set_debug_timeout_log_deadline(
9620        &self,
9621        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9622    ) -> Result<(), fidl::Error>;
9623    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
9624    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
9625        + Send;
9626    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
9627    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
9628        + Send;
9629    fn r#is_alternate_for(
9630        &self,
9631        payload: NodeIsAlternateForRequest,
9632    ) -> Self::IsAlternateForResponseFut;
9633    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
9634        + Send;
9635    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
9636    fn r#set_weak(&self) -> Result<(), fidl::Error>;
9637    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
9638    fn r#attach_node_tracking(
9639        &self,
9640        payload: NodeAttachNodeTrackingRequest,
9641    ) -> Result<(), fidl::Error>;
9642}
9643
9644#[derive(Debug, Clone)]
9645pub struct NodeProxy {
9646    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9647}
9648
9649impl fdomain_client::fidl::Proxy for NodeProxy {
9650    type Protocol = NodeMarker;
9651
9652    fn from_channel(inner: fdomain_client::Channel) -> Self {
9653        Self::new(inner)
9654    }
9655
9656    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9657        self.client.into_channel().map_err(|client| Self { client })
9658    }
9659
9660    fn as_channel(&self) -> &fdomain_client::Channel {
9661        self.client.as_channel()
9662    }
9663}
9664
9665impl NodeProxy {
9666    /// Create a new Proxy for fuchsia.sysmem2/Node.
9667    pub fn new(channel: fdomain_client::Channel) -> Self {
9668        let protocol_name = <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9669        Self { client: fidl::client::Client::new(channel, protocol_name) }
9670    }
9671
9672    /// Get a Stream of events from the remote end of the protocol.
9673    ///
9674    /// # Panics
9675    ///
9676    /// Panics if the event stream was already taken.
9677    pub fn take_event_stream(&self) -> NodeEventStream {
9678        NodeEventStream { event_receiver: self.client.take_event_receiver() }
9679    }
9680
9681    /// Ensure that previous messages have been received server side. This is
9682    /// particularly useful after previous messages that created new tokens,
9683    /// because a token must be known to the sysmem server before sending the
9684    /// token to another participant.
9685    ///
9686    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
9687    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
9688    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
9689    /// to mitigate the possibility of a hostile/fake
9690    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
9691    /// Another way is to pass the token to
9692    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
9693    /// the token as part of exchanging it for a
9694    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
9695    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
9696    /// of stalling.
9697    ///
9698    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
9699    /// and then starting and completing a `Sync`, it's then safe to send the
9700    /// `BufferCollectionToken` client ends to other participants knowing the
9701    /// server will recognize the tokens when they're sent by the other
9702    /// participants to sysmem in a
9703    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
9704    /// efficient way to create tokens while avoiding unnecessary round trips.
9705    ///
9706    /// Other options include waiting for each
9707    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
9708    /// individually (using separate call to `Sync` after each), or calling
9709    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
9710    /// converted to a `BufferCollection` via
9711    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
9712    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
9713    /// the sync step and can create multiple tokens at once.
9714    pub fn r#sync(
9715        &self,
9716    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9717        NodeProxyInterface::r#sync(self)
9718    }
9719
9720    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
9721    ///
9722    /// Normally a participant will convert a `BufferCollectionToken` into a
9723    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
9724    /// `Release` via the token (and then close the channel immediately or
9725    /// shortly later in response to server closing the server end), which
9726    /// avoids causing buffer collection failure. Without a prior `Release`,
9727    /// closing the `BufferCollectionToken` client end will cause buffer
9728    /// collection failure.
9729    ///
9730    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
9731    ///
9732    /// By default the server handles unexpected closure of a
9733    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
9734    /// first) by failing the buffer collection. Partly this is to expedite
9735    /// closing VMO handles to reclaim memory when any participant fails. If a
9736    /// participant would like to cleanly close a `BufferCollection` without
9737    /// causing buffer collection failure, the participant can send `Release`
9738    /// before closing the `BufferCollection` client end. The `Release` can
9739    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
9740    /// buffer collection won't require constraints from this node in order to
9741    /// allocate. If after `SetConstraints`, the constraints are retained and
9742    /// aggregated, despite the lack of `BufferCollection` connection at the
9743    /// time of constraints aggregation.
9744    ///
9745    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
9746    ///
9747    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
9748    /// end (without `Release` first) will trigger failure of the buffer
9749    /// collection. To close a `BufferCollectionTokenGroup` channel without
9750    /// failing the buffer collection, ensure that AllChildrenPresent() has been
9751    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
9752    /// client end.
9753    ///
9754    /// If `Release` occurs before
9755    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
9756    /// buffer collection will fail (triggered by reception of `Release` without
9757    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
9758    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
9759    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
9760    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
9761    /// close requires `AllChildrenPresent` (if not already sent), then
9762    /// `Release`, then close client end.
9763    ///
9764    /// If `Release` occurs after `AllChildrenPresent`, the children and all
9765    /// their constraints remain intact (just as they would if the
9766    /// `BufferCollectionTokenGroup` channel had remained open), and the client
9767    /// end close doesn't trigger buffer collection failure.
9768    ///
9769    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
9770    ///
9771    /// For brevity, the per-channel-protocol paragraphs above ignore the
9772    /// separate failure domain created by
9773    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
9774    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
9775    /// unexpectedly closes (without `Release` first) and that client end is
9776    /// under a failure domain, instead of failing the whole buffer collection,
9777    /// the failure domain is failed, but the buffer collection itself is
9778    /// isolated from failure of the failure domain. Such failure domains can be
9779    /// nested, in which case only the inner-most failure domain in which the
9780    /// `Node` resides fails.
9781    pub fn r#release(&self) -> Result<(), fidl::Error> {
9782        NodeProxyInterface::r#release(self)
9783    }
9784
9785    /// Set a name for VMOs in this buffer collection.
9786    ///
9787    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
9788    /// will be truncated to fit. The name of the vmo will be suffixed with the
9789    /// buffer index within the collection (if the suffix fits within
9790    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
9791    /// listed in the inspect data.
9792    ///
9793    /// The name only affects VMOs allocated after the name is set; this call
9794    /// does not rename existing VMOs. If multiple clients set different names
9795    /// then the larger priority value will win. Setting a new name with the
9796    /// same priority as a prior name doesn't change the name.
9797    ///
9798    /// All table fields are currently required.
9799    ///
9800    /// + request `priority` The name is only set if this is the first `SetName`
9801    ///   or if `priority` is greater than any previous `priority` value in
9802    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
9803    /// + request `name` The name for VMOs created under this buffer collection.
9804    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
9805        NodeProxyInterface::r#set_name(self, payload)
9806    }
9807
9808    /// Set information about the current client that can be used by sysmem to
9809    /// help diagnose leaking memory and allocation stalls waiting for a
9810    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
9811    ///
9812    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
9813    /// `Node`(s) derived from this `Node`, unless overriden by
9814    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
9815    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
9816    ///
9817    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
9818    /// `Allocator` is the most efficient way to ensure that all
9819    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
9820    /// set, and is also more efficient than separately sending the same debug
9821    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
9822    /// created [`fuchsia.sysmem2/Node`].
9823    ///
9824    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
9825    /// indicate which client is closing their channel first, leading to subtree
9826    /// failure (which can be normal if the purpose of the subtree is over, but
9827    /// if happening earlier than expected, the client-channel-specific name can
9828    /// help diagnose where the failure is first coming from, from sysmem's
9829    /// point of view).
9830    ///
9831    /// All table fields are currently required.
9832    ///
9833    /// + request `name` This can be an arbitrary string, but the current
9834    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
9835    /// + request `id` This can be an arbitrary id, but the current process ID
9836    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
9837    pub fn r#set_debug_client_info(
9838        &self,
9839        mut payload: &NodeSetDebugClientInfoRequest,
9840    ) -> Result<(), fidl::Error> {
9841        NodeProxyInterface::r#set_debug_client_info(self, payload)
9842    }
9843
9844    /// Sysmem logs a warning if sysmem hasn't seen
9845    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
9846    /// within 5 seconds after creation of a new collection.
9847    ///
9848    /// Clients can call this method to change when the log is printed. If
9849    /// multiple client set the deadline, it's unspecified which deadline will
9850    /// take effect.
9851    ///
9852    /// In most cases the default works well.
9853    ///
9854    /// All table fields are currently required.
9855    ///
9856    /// + request `deadline` The time at which sysmem will start trying to log
9857    ///   the warning, unless all constraints are with sysmem by then.
9858    pub fn r#set_debug_timeout_log_deadline(
9859        &self,
9860        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9861    ) -> Result<(), fidl::Error> {
9862        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
9863    }
9864
9865    /// This enables verbose logging for the buffer collection.
9866    ///
9867    /// Verbose logging includes constraints set via
9868    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
9869    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
9870    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
9871    /// the tree of `Node`(s).
9872    ///
9873    /// Normally sysmem prints only a single line complaint when aggregation
9874    /// fails, with just the specific detailed reason that aggregation failed,
9875    /// with little surrounding context.  While this is often enough to diagnose
9876    /// a problem if only a small change was made and everything was working
9877    /// before the small change, it's often not particularly helpful for getting
9878    /// a new buffer collection to work for the first time.  Especially with
9879    /// more complex trees of nodes, involving things like
9880    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
9881    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
9882    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
9883    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
9884    /// looks like and why it's failing a logical allocation, or why a tree or
9885    /// subtree is failing sooner than expected.
9886    ///
9887    /// The intent of the extra logging is to be acceptable from a performance
9888    /// point of view, under the assumption that verbose logging is only enabled
9889    /// on a low number of buffer collections. If we're not tracking down a bug,
9890    /// we shouldn't send this message.
9891    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9892        NodeProxyInterface::r#set_verbose_logging(self)
9893    }
9894
9895    /// This gets a handle that can be used as a parameter to
9896    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
9897    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
9898    /// client obtained this handle from this `Node`.
9899    ///
9900    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
9901    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
9902    /// despite the two calls typically being on different channels.
9903    ///
9904    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
9905    ///
9906    /// All table fields are currently required.
9907    ///
9908    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
9909    ///   different `Node` channel, to prove that the client obtained the handle
9910    ///   from this `Node`.
9911    pub fn r#get_node_ref(
9912        &self,
9913    ) -> fidl::client::QueryResponseFut<
9914        NodeGetNodeRefResponse,
9915        fdomain_client::fidl::FDomainResourceDialect,
9916    > {
9917        NodeProxyInterface::r#get_node_ref(self)
9918    }
9919
9920    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
9921    /// rooted at a different child token of a common parent
9922    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
9923    /// passed-in `node_ref`.
9924    ///
9925    /// This call is for assisting with admission control de-duplication, and
9926    /// with debugging.
9927    ///
9928    /// The `node_ref` must be obtained using
9929    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
9930    ///
9931    /// The `node_ref` can be a duplicated handle; it's not necessary to call
9932    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
9933    ///
9934    /// If a calling token may not actually be a valid token at all due to a
9935    /// potentially hostile/untrusted provider of the token, call
9936    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
9937    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
9938    /// never responds due to a calling token not being a real token (not really
9939    /// talking to sysmem).  Another option is to call
9940    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
9941    /// which also validates the token along with converting it to a
9942    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
9943    ///
9944    /// All table fields are currently required.
9945    ///
9946    /// - response `is_alternate`
9947    ///   - true: The first parent node in common between the calling node and
9948    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
9949    ///     that the calling `Node` and the `node_ref` `Node` will not have both
9950    ///     their constraints apply - rather sysmem will choose one or the other
9951    ///     of the constraints - never both.  This is because only one child of
9952    ///     a `BufferCollectionTokenGroup` is selected during logical
9953    ///     allocation, with only that one child's subtree contributing to
9954    ///     constraints aggregation.
9955    ///   - false: The first parent node in common between the calling `Node`
9956    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
9957    ///     Currently, this means the first parent node in common is a
9958    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
9959    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
9960    ///     `Node` may have both their constraints apply during constraints
9961    ///     aggregation of the logical allocation, if both `Node`(s) are
9962    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
9963    ///     this case, there is no `BufferCollectionTokenGroup` that will
9964    ///     directly prevent the two `Node`(s) from both being selected and
9965    ///     their constraints both aggregated, but even when false, one or both
9966    ///     `Node`(s) may still be eliminated from consideration if one or both
9967    ///     `Node`(s) has a direct or indirect parent
9968    ///     `BufferCollectionTokenGroup` which selects a child subtree other
9969    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
9970    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
9971    ///   associated with the same buffer collection as the calling `Node`.
9972    ///   Another reason for this error is if the `node_ref` is an
9973    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
9974    ///   a real `node_ref` obtained from `GetNodeRef`.
9975    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
9976    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
9977    ///   the needed rights expected on a real `node_ref`.
9978    /// * No other failing status codes are returned by this call.  However,
9979    ///   sysmem may add additional codes in future, so the client should have
9980    ///   sensible default handling for any failing status code.
9981    pub fn r#is_alternate_for(
9982        &self,
9983        mut payload: NodeIsAlternateForRequest,
9984    ) -> fidl::client::QueryResponseFut<
9985        NodeIsAlternateForResult,
9986        fdomain_client::fidl::FDomainResourceDialect,
9987    > {
9988        NodeProxyInterface::r#is_alternate_for(self, payload)
9989    }
9990
9991    /// Get the buffer collection ID. This ID is also available from
9992    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
9993    /// within the collection).
9994    ///
9995    /// This call is mainly useful in situations where we can't convey a
9996    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
9997    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
9998    /// handle, which can be joined back up with a `BufferCollection` client end
9999    /// that was created via a different path. Prefer to convey a
10000    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
10001    ///
10002    /// Trusting a `buffer_collection_id` value from a source other than sysmem
10003    /// is analogous to trusting a koid value from a source other than zircon.
10004    /// Both should be avoided unless really necessary, and both require
10005    /// caution. In some situations it may be reasonable to refer to a
10006    /// pre-established `BufferCollection` by `buffer_collection_id` via a
10007    /// protocol for efficiency reasons, but an incoming value purporting to be
10008    /// a `buffer_collection_id` is not sufficient alone to justify granting the
10009    /// sender of the `buffer_collection_id` any capability. The sender must
10010    /// first prove to a receiver that the sender has/had a VMO or has/had a
10011    /// `BufferCollectionToken` to the same collection by sending a handle that
10012    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
10013    /// `buffer_collection_id` value. The receiver should take care to avoid
10014    /// assuming that a sender had a `BufferCollectionToken` in cases where the
10015    /// sender has only proven that the sender had a VMO.
10016    ///
10017    /// - response `buffer_collection_id` This ID is unique per buffer
10018    ///   collection per boot. Each buffer is uniquely identified by the
10019    ///   `buffer_collection_id` and `buffer_index` together.
10020    pub fn r#get_buffer_collection_id(
10021        &self,
10022    ) -> fidl::client::QueryResponseFut<
10023        NodeGetBufferCollectionIdResponse,
10024        fdomain_client::fidl::FDomainResourceDialect,
10025    > {
10026        NodeProxyInterface::r#get_buffer_collection_id(self)
10027    }
10028
10029    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
10030    /// created after this message to weak, which means that a client's `Node`
10031    /// client end (or a child created after this message) is not alone
10032    /// sufficient to keep allocated VMOs alive.
10033    ///
10034    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
10035    /// `close_weak_asap`.
10036    ///
10037    /// This message is only permitted before the `Node` becomes ready for
10038    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
10039    ///   * `BufferCollectionToken`: any time
10040    ///   * `BufferCollection`: before `SetConstraints`
10041    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
10042    ///
10043    /// Currently, no conversion from strong `Node` to weak `Node` after ready
10044    /// for allocation is provided, but a client can simulate that by creating
10045    /// an additional `Node` before allocation and setting that additional
10046    /// `Node` to weak, and then potentially at some point later sending
10047    /// `Release` and closing the client end of the client's strong `Node`, but
10048    /// keeping the client's weak `Node`.
10049    ///
10050    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
10051    /// collection failure (all `Node` client end(s) will see
10052    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
10053    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
10054    /// this situation until all `Node`(s) are ready for allocation. For initial
10055    /// allocation to succeed, at least one strong `Node` is required to exist
10056    /// at allocation time, but after that client receives VMO handles, that
10057    /// client can `BufferCollection.Release` and close the client end without
10058    /// causing this type of failure.
10059    ///
10060    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
10061    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
10062    /// separately as appropriate.
10063    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
10064        NodeProxyInterface::r#set_weak(self)
10065    }
10066
10067    /// This indicates to sysmem that the client is prepared to pay attention to
10068    /// `close_weak_asap`.
10069    ///
10070    /// If sent, this message must be before
10071    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
10072    ///
10073    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
10074    /// send this message before `WaitForAllBuffersAllocated`, or a parent
10075    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
10076    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
10077    /// trigger buffer collection failure.
10078    ///
10079    /// This message is necessary because weak sysmem VMOs have not always been
10080    /// a thing, so older clients are not aware of the need to pay attention to
10081    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
10082    /// sysmem weak VMO handles asap. By having this message and requiring
10083    /// participants to indicate their acceptance of this aspect of the overall
10084    /// protocol, we avoid situations where an older client is delivered a weak
10085    /// VMO without any way for sysmem to get that VMO to close quickly later
10086    /// (and on a per-buffer basis).
10087    ///
10088    /// A participant that doesn't handle `close_weak_asap` and also doesn't
10089    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
10090    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
10091    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
10092    /// same participant has a child/delegate which does retrieve VMOs, that
10093    /// child/delegate will need to send `SetWeakOk` before
10094    /// `WaitForAllBuffersAllocated`.
10095    ///
10096    /// + request `for_child_nodes_also` If present and true, this means direct
10097    ///   child nodes of this node created after this message plus all
10098    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
10099    ///   those nodes. Any child node of this node that was created before this
10100    ///   message is not included. This setting is "sticky" in the sense that a
10101    ///   subsequent `SetWeakOk` without this bool set to true does not reset
10102    ///   the server-side bool. If this creates a problem for a participant, a
10103    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
10104    ///   tokens instead, as appropriate. A participant should only set
10105    ///   `for_child_nodes_also` true if the participant can really promise to
10106    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
10107    ///   weak VMO handles held by participants holding the corresponding child
10108    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
10109    ///   which are using sysmem(1) can be weak, despite the clients of those
10110    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
10111    ///   direct way to find out about `close_weak_asap`. This only applies to
10112    ///   descendents of this `Node` which are using sysmem(1), not to this
10113    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
10114    ///   token, which will fail allocation unless an ancestor of this `Node`
10115    ///   specified `for_child_nodes_also` true.
10116    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
10117        NodeProxyInterface::r#set_weak_ok(self, payload)
10118    }
10119
10120    /// The server_end will be closed after this `Node` and any child nodes have
10121    /// have released their buffer counts, making those counts available for
10122    /// reservation by a different `Node` via
10123    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
10124    ///
10125    /// The `Node` buffer counts may not be released until the entire tree of
10126    /// `Node`(s) is closed or failed, because
10127    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
10128    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
10129    /// `Node` buffer counts remain reserved until the orphaned node is later
10130    /// cleaned up.
10131    ///
10132    /// If the `Node` exceeds a fairly large number of attached eventpair server
10133    /// ends, a log message will indicate this and the `Node` (and the
10134    /// appropriate) sub-tree will fail.
10135    ///
10136    /// The `server_end` will remain open when
10137    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
10138    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
10139    /// [`fuchsia.sysmem2/BufferCollection`].
10140    ///
10141    /// This message can also be used with a
10142    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
10143    pub fn r#attach_node_tracking(
10144        &self,
10145        mut payload: NodeAttachNodeTrackingRequest,
10146    ) -> Result<(), fidl::Error> {
10147        NodeProxyInterface::r#attach_node_tracking(self, payload)
10148    }
10149}
10150
10151impl NodeProxyInterface for NodeProxy {
10152    type SyncResponseFut =
10153        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10154    fn r#sync(&self) -> Self::SyncResponseFut {
10155        fn _decode(
10156            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10157        ) -> Result<(), fidl::Error> {
10158            let _response = fidl::client::decode_transaction_body::<
10159                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
10160                fdomain_client::fidl::FDomainResourceDialect,
10161                0x11ac2555cf575b54,
10162            >(_buf?)?
10163            .into_result_fdomain::<NodeMarker>("sync")?;
10164            Ok(_response)
10165        }
10166        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
10167            (),
10168            0x11ac2555cf575b54,
10169            fidl::encoding::DynamicFlags::FLEXIBLE,
10170            _decode,
10171        )
10172    }
10173
10174    fn r#release(&self) -> Result<(), fidl::Error> {
10175        self.client.send::<fidl::encoding::EmptyPayload>(
10176            (),
10177            0x6a5cae7d6d6e04c6,
10178            fidl::encoding::DynamicFlags::FLEXIBLE,
10179        )
10180    }
10181
10182    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
10183        self.client.send::<NodeSetNameRequest>(
10184            payload,
10185            0xb41f1624f48c1e9,
10186            fidl::encoding::DynamicFlags::FLEXIBLE,
10187        )
10188    }
10189
10190    fn r#set_debug_client_info(
10191        &self,
10192        mut payload: &NodeSetDebugClientInfoRequest,
10193    ) -> Result<(), fidl::Error> {
10194        self.client.send::<NodeSetDebugClientInfoRequest>(
10195            payload,
10196            0x5cde8914608d99b1,
10197            fidl::encoding::DynamicFlags::FLEXIBLE,
10198        )
10199    }
10200
10201    fn r#set_debug_timeout_log_deadline(
10202        &self,
10203        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
10204    ) -> Result<(), fidl::Error> {
10205        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
10206            payload,
10207            0x716b0af13d5c0806,
10208            fidl::encoding::DynamicFlags::FLEXIBLE,
10209        )
10210    }
10211
10212    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
10213        self.client.send::<fidl::encoding::EmptyPayload>(
10214            (),
10215            0x5209c77415b4dfad,
10216            fidl::encoding::DynamicFlags::FLEXIBLE,
10217        )
10218    }
10219
10220    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
10221        NodeGetNodeRefResponse,
10222        fdomain_client::fidl::FDomainResourceDialect,
10223    >;
10224    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
10225        fn _decode(
10226            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10227        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
10228            let _response = fidl::client::decode_transaction_body::<
10229                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
10230                fdomain_client::fidl::FDomainResourceDialect,
10231                0x5b3d0e51614df053,
10232            >(_buf?)?
10233            .into_result_fdomain::<NodeMarker>("get_node_ref")?;
10234            Ok(_response)
10235        }
10236        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
10237            (),
10238            0x5b3d0e51614df053,
10239            fidl::encoding::DynamicFlags::FLEXIBLE,
10240            _decode,
10241        )
10242    }
10243
10244    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
10245        NodeIsAlternateForResult,
10246        fdomain_client::fidl::FDomainResourceDialect,
10247    >;
10248    fn r#is_alternate_for(
10249        &self,
10250        mut payload: NodeIsAlternateForRequest,
10251    ) -> Self::IsAlternateForResponseFut {
10252        fn _decode(
10253            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10254        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
10255            let _response = fidl::client::decode_transaction_body::<
10256                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
10257                fdomain_client::fidl::FDomainResourceDialect,
10258                0x3a58e00157e0825,
10259            >(_buf?)?
10260            .into_result_fdomain::<NodeMarker>("is_alternate_for")?;
10261            Ok(_response.map(|x| x))
10262        }
10263        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
10264            &mut payload,
10265            0x3a58e00157e0825,
10266            fidl::encoding::DynamicFlags::FLEXIBLE,
10267            _decode,
10268        )
10269    }
10270
10271    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
10272        NodeGetBufferCollectionIdResponse,
10273        fdomain_client::fidl::FDomainResourceDialect,
10274    >;
10275    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
10276        fn _decode(
10277            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10278        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
10279            let _response = fidl::client::decode_transaction_body::<
10280                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
10281                fdomain_client::fidl::FDomainResourceDialect,
10282                0x77d19a494b78ba8c,
10283            >(_buf?)?
10284            .into_result_fdomain::<NodeMarker>("get_buffer_collection_id")?;
10285            Ok(_response)
10286        }
10287        self.client.send_query_and_decode::<
10288            fidl::encoding::EmptyPayload,
10289            NodeGetBufferCollectionIdResponse,
10290        >(
10291            (),
10292            0x77d19a494b78ba8c,
10293            fidl::encoding::DynamicFlags::FLEXIBLE,
10294            _decode,
10295        )
10296    }
10297
10298    fn r#set_weak(&self) -> Result<(), fidl::Error> {
10299        self.client.send::<fidl::encoding::EmptyPayload>(
10300            (),
10301            0x22dd3ea514eeffe1,
10302            fidl::encoding::DynamicFlags::FLEXIBLE,
10303        )
10304    }
10305
10306    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
10307        self.client.send::<NodeSetWeakOkRequest>(
10308            &mut payload,
10309            0x38a44fc4d7724be9,
10310            fidl::encoding::DynamicFlags::FLEXIBLE,
10311        )
10312    }
10313
10314    fn r#attach_node_tracking(
10315        &self,
10316        mut payload: NodeAttachNodeTrackingRequest,
10317    ) -> Result<(), fidl::Error> {
10318        self.client.send::<NodeAttachNodeTrackingRequest>(
10319            &mut payload,
10320            0x3f22f2a293d3cdac,
10321            fidl::encoding::DynamicFlags::FLEXIBLE,
10322        )
10323    }
10324}
10325
10326pub struct NodeEventStream {
10327    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10328}
10329
10330impl std::marker::Unpin for NodeEventStream {}
10331
10332impl futures::stream::FusedStream for NodeEventStream {
10333    fn is_terminated(&self) -> bool {
10334        self.event_receiver.is_terminated()
10335    }
10336}
10337
10338impl futures::Stream for NodeEventStream {
10339    type Item = Result<NodeEvent, fidl::Error>;
10340
10341    fn poll_next(
10342        mut self: std::pin::Pin<&mut Self>,
10343        cx: &mut std::task::Context<'_>,
10344    ) -> std::task::Poll<Option<Self::Item>> {
10345        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10346            &mut self.event_receiver,
10347            cx
10348        )?) {
10349            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
10350            None => std::task::Poll::Ready(None),
10351        }
10352    }
10353}
10354
10355#[derive(Debug)]
10356pub enum NodeEvent {
10357    #[non_exhaustive]
10358    _UnknownEvent {
10359        /// Ordinal of the event that was sent.
10360        ordinal: u64,
10361    },
10362}
10363
10364impl NodeEvent {
10365    /// Decodes a message buffer as a [`NodeEvent`].
10366    fn decode(
10367        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10368    ) -> Result<NodeEvent, fidl::Error> {
10369        let (bytes, _handles) = buf.split_mut();
10370        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10371        debug_assert_eq!(tx_header.tx_id, 0);
10372        match tx_header.ordinal {
10373            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
10374                Ok(NodeEvent::_UnknownEvent { ordinal: tx_header.ordinal })
10375            }
10376            _ => Err(fidl::Error::UnknownOrdinal {
10377                ordinal: tx_header.ordinal,
10378                protocol_name: <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10379            }),
10380        }
10381    }
10382}
10383
10384/// A Stream of incoming requests for fuchsia.sysmem2/Node.
10385pub struct NodeRequestStream {
10386    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10387    is_terminated: bool,
10388}
10389
10390impl std::marker::Unpin for NodeRequestStream {}
10391
10392impl futures::stream::FusedStream for NodeRequestStream {
10393    fn is_terminated(&self) -> bool {
10394        self.is_terminated
10395    }
10396}
10397
10398impl fdomain_client::fidl::RequestStream for NodeRequestStream {
10399    type Protocol = NodeMarker;
10400    type ControlHandle = NodeControlHandle;
10401
10402    fn from_channel(channel: fdomain_client::Channel) -> Self {
10403        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10404    }
10405
10406    fn control_handle(&self) -> Self::ControlHandle {
10407        NodeControlHandle { inner: self.inner.clone() }
10408    }
10409
10410    fn into_inner(
10411        self,
10412    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10413    {
10414        (self.inner, self.is_terminated)
10415    }
10416
10417    fn from_inner(
10418        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10419        is_terminated: bool,
10420    ) -> Self {
10421        Self { inner, is_terminated }
10422    }
10423}
10424
10425impl futures::Stream for NodeRequestStream {
10426    type Item = Result<NodeRequest, fidl::Error>;
10427
10428    fn poll_next(
10429        mut self: std::pin::Pin<&mut Self>,
10430        cx: &mut std::task::Context<'_>,
10431    ) -> std::task::Poll<Option<Self::Item>> {
10432        let this = &mut *self;
10433        if this.inner.check_shutdown(cx) {
10434            this.is_terminated = true;
10435            return std::task::Poll::Ready(None);
10436        }
10437        if this.is_terminated {
10438            panic!("polled NodeRequestStream after completion");
10439        }
10440        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10441            |bytes, handles| {
10442                match this.inner.channel().read_etc(cx, bytes, handles) {
10443                    std::task::Poll::Ready(Ok(())) => {}
10444                    std::task::Poll::Pending => return std::task::Poll::Pending,
10445                    std::task::Poll::Ready(Err(None)) => {
10446                        this.is_terminated = true;
10447                        return std::task::Poll::Ready(None);
10448                    }
10449                    std::task::Poll::Ready(Err(Some(e))) => {
10450                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10451                            e.into(),
10452                        ))));
10453                    }
10454                }
10455
10456                // A message has been received from the channel
10457                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10458
10459                std::task::Poll::Ready(Some(match header.ordinal {
10460                    0x11ac2555cf575b54 => {
10461                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10462                        let mut req = fidl::new_empty!(
10463                            fidl::encoding::EmptyPayload,
10464                            fdomain_client::fidl::FDomainResourceDialect
10465                        );
10466                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10467                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10468                        Ok(NodeRequest::Sync {
10469                            responder: NodeSyncResponder {
10470                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10471                                tx_id: header.tx_id,
10472                            },
10473                        })
10474                    }
10475                    0x6a5cae7d6d6e04c6 => {
10476                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10477                        let mut req = fidl::new_empty!(
10478                            fidl::encoding::EmptyPayload,
10479                            fdomain_client::fidl::FDomainResourceDialect
10480                        );
10481                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10482                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10483                        Ok(NodeRequest::Release { control_handle })
10484                    }
10485                    0xb41f1624f48c1e9 => {
10486                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10487                        let mut req = fidl::new_empty!(
10488                            NodeSetNameRequest,
10489                            fdomain_client::fidl::FDomainResourceDialect
10490                        );
10491                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
10492                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10493                        Ok(NodeRequest::SetName { payload: req, control_handle })
10494                    }
10495                    0x5cde8914608d99b1 => {
10496                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10497                        let mut req = fidl::new_empty!(
10498                            NodeSetDebugClientInfoRequest,
10499                            fdomain_client::fidl::FDomainResourceDialect
10500                        );
10501                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
10502                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10503                        Ok(NodeRequest::SetDebugClientInfo { payload: req, control_handle })
10504                    }
10505                    0x716b0af13d5c0806 => {
10506                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10507                        let mut req = fidl::new_empty!(
10508                            NodeSetDebugTimeoutLogDeadlineRequest,
10509                            fdomain_client::fidl::FDomainResourceDialect
10510                        );
10511                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
10512                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10513                        Ok(NodeRequest::SetDebugTimeoutLogDeadline { payload: req, control_handle })
10514                    }
10515                    0x5209c77415b4dfad => {
10516                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10517                        let mut req = fidl::new_empty!(
10518                            fidl::encoding::EmptyPayload,
10519                            fdomain_client::fidl::FDomainResourceDialect
10520                        );
10521                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10522                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10523                        Ok(NodeRequest::SetVerboseLogging { control_handle })
10524                    }
10525                    0x5b3d0e51614df053 => {
10526                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10527                        let mut req = fidl::new_empty!(
10528                            fidl::encoding::EmptyPayload,
10529                            fdomain_client::fidl::FDomainResourceDialect
10530                        );
10531                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10532                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10533                        Ok(NodeRequest::GetNodeRef {
10534                            responder: NodeGetNodeRefResponder {
10535                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10536                                tx_id: header.tx_id,
10537                            },
10538                        })
10539                    }
10540                    0x3a58e00157e0825 => {
10541                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10542                        let mut req = fidl::new_empty!(
10543                            NodeIsAlternateForRequest,
10544                            fdomain_client::fidl::FDomainResourceDialect
10545                        );
10546                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
10547                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10548                        Ok(NodeRequest::IsAlternateFor {
10549                            payload: req,
10550                            responder: NodeIsAlternateForResponder {
10551                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10552                                tx_id: header.tx_id,
10553                            },
10554                        })
10555                    }
10556                    0x77d19a494b78ba8c => {
10557                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10558                        let mut req = fidl::new_empty!(
10559                            fidl::encoding::EmptyPayload,
10560                            fdomain_client::fidl::FDomainResourceDialect
10561                        );
10562                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10563                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10564                        Ok(NodeRequest::GetBufferCollectionId {
10565                            responder: NodeGetBufferCollectionIdResponder {
10566                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10567                                tx_id: header.tx_id,
10568                            },
10569                        })
10570                    }
10571                    0x22dd3ea514eeffe1 => {
10572                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10573                        let mut req = fidl::new_empty!(
10574                            fidl::encoding::EmptyPayload,
10575                            fdomain_client::fidl::FDomainResourceDialect
10576                        );
10577                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10578                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10579                        Ok(NodeRequest::SetWeak { control_handle })
10580                    }
10581                    0x38a44fc4d7724be9 => {
10582                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10583                        let mut req = fidl::new_empty!(
10584                            NodeSetWeakOkRequest,
10585                            fdomain_client::fidl::FDomainResourceDialect
10586                        );
10587                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
10588                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10589                        Ok(NodeRequest::SetWeakOk { payload: req, control_handle })
10590                    }
10591                    0x3f22f2a293d3cdac => {
10592                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10593                        let mut req = fidl::new_empty!(
10594                            NodeAttachNodeTrackingRequest,
10595                            fdomain_client::fidl::FDomainResourceDialect
10596                        );
10597                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
10598                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10599                        Ok(NodeRequest::AttachNodeTracking { payload: req, control_handle })
10600                    }
10601                    _ if header.tx_id == 0
10602                        && header
10603                            .dynamic_flags()
10604                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
10605                    {
10606                        Ok(NodeRequest::_UnknownMethod {
10607                            ordinal: header.ordinal,
10608                            control_handle: NodeControlHandle { inner: this.inner.clone() },
10609                            method_type: fidl::MethodType::OneWay,
10610                        })
10611                    }
10612                    _ if header
10613                        .dynamic_flags()
10614                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
10615                    {
10616                        this.inner.send_framework_err(
10617                            fidl::encoding::FrameworkErr::UnknownMethod,
10618                            header.tx_id,
10619                            header.ordinal,
10620                            header.dynamic_flags(),
10621                            (bytes, handles),
10622                        )?;
10623                        Ok(NodeRequest::_UnknownMethod {
10624                            ordinal: header.ordinal,
10625                            control_handle: NodeControlHandle { inner: this.inner.clone() },
10626                            method_type: fidl::MethodType::TwoWay,
10627                        })
10628                    }
10629                    _ => Err(fidl::Error::UnknownOrdinal {
10630                        ordinal: header.ordinal,
10631                        protocol_name:
10632                            <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10633                    }),
10634                }))
10635            },
10636        )
10637    }
10638}
10639
10640/// This protocol is the parent protocol for all nodes in the tree established
10641/// by [`fuchsia.sysmem2/BufferCollectionToken`] creation and
10642/// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] creation, including
10643/// [`fuchsia.sysmem2/BufferCollectionToken`](s) which have since been converted
10644/// to a [`fuchsia.sysmem2/BufferCollection`] channel.
10645///
10646/// Epitaphs are not used in this protocol.
10647#[derive(Debug)]
10648pub enum NodeRequest {
10649    /// Ensure that previous messages have been received server side. This is
10650    /// particularly useful after previous messages that created new tokens,
10651    /// because a token must be known to the sysmem server before sending the
10652    /// token to another participant.
10653    ///
10654    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
10655    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
10656    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
10657    /// to mitigate the possibility of a hostile/fake
10658    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
10659    /// Another way is to pass the token to
10660    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
10661    /// the token as part of exchanging it for a
10662    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
10663    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
10664    /// of stalling.
10665    ///
10666    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
10667    /// and then starting and completing a `Sync`, it's then safe to send the
10668    /// `BufferCollectionToken` client ends to other participants knowing the
10669    /// server will recognize the tokens when they're sent by the other
10670    /// participants to sysmem in a
10671    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
10672    /// efficient way to create tokens while avoiding unnecessary round trips.
10673    ///
10674    /// Other options include waiting for each
10675    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
10676    /// individually (using separate call to `Sync` after each), or calling
10677    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
10678    /// converted to a `BufferCollection` via
10679    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
10680    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
10681    /// the sync step and can create multiple tokens at once.
10682    Sync { responder: NodeSyncResponder },
10683    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
10684    ///
10685    /// Normally a participant will convert a `BufferCollectionToken` into a
10686    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
10687    /// `Release` via the token (and then close the channel immediately or
10688    /// shortly later in response to server closing the server end), which
10689    /// avoids causing buffer collection failure. Without a prior `Release`,
10690    /// closing the `BufferCollectionToken` client end will cause buffer
10691    /// collection failure.
10692    ///
10693    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
10694    ///
10695    /// By default the server handles unexpected closure of a
10696    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
10697    /// first) by failing the buffer collection. Partly this is to expedite
10698    /// closing VMO handles to reclaim memory when any participant fails. If a
10699    /// participant would like to cleanly close a `BufferCollection` without
10700    /// causing buffer collection failure, the participant can send `Release`
10701    /// before closing the `BufferCollection` client end. The `Release` can
10702    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
10703    /// buffer collection won't require constraints from this node in order to
10704    /// allocate. If after `SetConstraints`, the constraints are retained and
10705    /// aggregated, despite the lack of `BufferCollection` connection at the
10706    /// time of constraints aggregation.
10707    ///
10708    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
10709    ///
10710    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
10711    /// end (without `Release` first) will trigger failure of the buffer
10712    /// collection. To close a `BufferCollectionTokenGroup` channel without
10713    /// failing the buffer collection, ensure that AllChildrenPresent() has been
10714    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
10715    /// client end.
10716    ///
10717    /// If `Release` occurs before
10718    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
10719    /// buffer collection will fail (triggered by reception of `Release` without
10720    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
10721    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
10722    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
10723    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
10724    /// close requires `AllChildrenPresent` (if not already sent), then
10725    /// `Release`, then close client end.
10726    ///
10727    /// If `Release` occurs after `AllChildrenPresent`, the children and all
10728    /// their constraints remain intact (just as they would if the
10729    /// `BufferCollectionTokenGroup` channel had remained open), and the client
10730    /// end close doesn't trigger buffer collection failure.
10731    ///
10732    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
10733    ///
10734    /// For brevity, the per-channel-protocol paragraphs above ignore the
10735    /// separate failure domain created by
10736    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
10737    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
10738    /// unexpectedly closes (without `Release` first) and that client end is
10739    /// under a failure domain, instead of failing the whole buffer collection,
10740    /// the failure domain is failed, but the buffer collection itself is
10741    /// isolated from failure of the failure domain. Such failure domains can be
10742    /// nested, in which case only the inner-most failure domain in which the
10743    /// `Node` resides fails.
10744    Release { control_handle: NodeControlHandle },
10745    /// Set a name for VMOs in this buffer collection.
10746    ///
10747    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
10748    /// will be truncated to fit. The name of the vmo will be suffixed with the
10749    /// buffer index within the collection (if the suffix fits within
10750    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
10751    /// listed in the inspect data.
10752    ///
10753    /// The name only affects VMOs allocated after the name is set; this call
10754    /// does not rename existing VMOs. If multiple clients set different names
10755    /// then the larger priority value will win. Setting a new name with the
10756    /// same priority as a prior name doesn't change the name.
10757    ///
10758    /// All table fields are currently required.
10759    ///
10760    /// + request `priority` The name is only set if this is the first `SetName`
10761    ///   or if `priority` is greater than any previous `priority` value in
10762    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
10763    /// + request `name` The name for VMOs created under this buffer collection.
10764    SetName { payload: NodeSetNameRequest, control_handle: NodeControlHandle },
10765    /// Set information about the current client that can be used by sysmem to
10766    /// help diagnose leaking memory and allocation stalls waiting for a
10767    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
10768    ///
10769    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
10770    /// `Node`(s) derived from this `Node`, unless overriden by
10771    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
10772    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
10773    ///
10774    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
10775    /// `Allocator` is the most efficient way to ensure that all
10776    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
10777    /// set, and is also more efficient than separately sending the same debug
10778    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
10779    /// created [`fuchsia.sysmem2/Node`].
10780    ///
10781    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
10782    /// indicate which client is closing their channel first, leading to subtree
10783    /// failure (which can be normal if the purpose of the subtree is over, but
10784    /// if happening earlier than expected, the client-channel-specific name can
10785    /// help diagnose where the failure is first coming from, from sysmem's
10786    /// point of view).
10787    ///
10788    /// All table fields are currently required.
10789    ///
10790    /// + request `name` This can be an arbitrary string, but the current
10791    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
10792    /// + request `id` This can be an arbitrary id, but the current process ID
10793    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
10794    SetDebugClientInfo { payload: NodeSetDebugClientInfoRequest, control_handle: NodeControlHandle },
10795    /// Sysmem logs a warning if sysmem hasn't seen
10796    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
10797    /// within 5 seconds after creation of a new collection.
10798    ///
10799    /// Clients can call this method to change when the log is printed. If
10800    /// multiple client set the deadline, it's unspecified which deadline will
10801    /// take effect.
10802    ///
10803    /// In most cases the default works well.
10804    ///
10805    /// All table fields are currently required.
10806    ///
10807    /// + request `deadline` The time at which sysmem will start trying to log
10808    ///   the warning, unless all constraints are with sysmem by then.
10809    SetDebugTimeoutLogDeadline {
10810        payload: NodeSetDebugTimeoutLogDeadlineRequest,
10811        control_handle: NodeControlHandle,
10812    },
10813    /// This enables verbose logging for the buffer collection.
10814    ///
10815    /// Verbose logging includes constraints set via
10816    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
10817    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
10818    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
10819    /// the tree of `Node`(s).
10820    ///
10821    /// Normally sysmem prints only a single line complaint when aggregation
10822    /// fails, with just the specific detailed reason that aggregation failed,
10823    /// with little surrounding context.  While this is often enough to diagnose
10824    /// a problem if only a small change was made and everything was working
10825    /// before the small change, it's often not particularly helpful for getting
10826    /// a new buffer collection to work for the first time.  Especially with
10827    /// more complex trees of nodes, involving things like
10828    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
10829    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
10830    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
10831    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
10832    /// looks like and why it's failing a logical allocation, or why a tree or
10833    /// subtree is failing sooner than expected.
10834    ///
10835    /// The intent of the extra logging is to be acceptable from a performance
10836    /// point of view, under the assumption that verbose logging is only enabled
10837    /// on a low number of buffer collections. If we're not tracking down a bug,
10838    /// we shouldn't send this message.
10839    SetVerboseLogging { control_handle: NodeControlHandle },
10840    /// This gets a handle that can be used as a parameter to
10841    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
10842    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
10843    /// client obtained this handle from this `Node`.
10844    ///
10845    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
10846    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
10847    /// despite the two calls typically being on different channels.
10848    ///
10849    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
10850    ///
10851    /// All table fields are currently required.
10852    ///
10853    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
10854    ///   different `Node` channel, to prove that the client obtained the handle
10855    ///   from this `Node`.
10856    GetNodeRef { responder: NodeGetNodeRefResponder },
10857    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
10858    /// rooted at a different child token of a common parent
10859    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
10860    /// passed-in `node_ref`.
10861    ///
10862    /// This call is for assisting with admission control de-duplication, and
10863    /// with debugging.
10864    ///
10865    /// The `node_ref` must be obtained using
10866    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
10867    ///
10868    /// The `node_ref` can be a duplicated handle; it's not necessary to call
10869    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
10870    ///
10871    /// If a calling token may not actually be a valid token at all due to a
10872    /// potentially hostile/untrusted provider of the token, call
10873    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
10874    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
10875    /// never responds due to a calling token not being a real token (not really
10876    /// talking to sysmem).  Another option is to call
10877    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
10878    /// which also validates the token along with converting it to a
10879    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
10880    ///
10881    /// All table fields are currently required.
10882    ///
10883    /// - response `is_alternate`
10884    ///   - true: The first parent node in common between the calling node and
10885    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
10886    ///     that the calling `Node` and the `node_ref` `Node` will not have both
10887    ///     their constraints apply - rather sysmem will choose one or the other
10888    ///     of the constraints - never both.  This is because only one child of
10889    ///     a `BufferCollectionTokenGroup` is selected during logical
10890    ///     allocation, with only that one child's subtree contributing to
10891    ///     constraints aggregation.
10892    ///   - false: The first parent node in common between the calling `Node`
10893    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
10894    ///     Currently, this means the first parent node in common is a
10895    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
10896    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
10897    ///     `Node` may have both their constraints apply during constraints
10898    ///     aggregation of the logical allocation, if both `Node`(s) are
10899    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
10900    ///     this case, there is no `BufferCollectionTokenGroup` that will
10901    ///     directly prevent the two `Node`(s) from both being selected and
10902    ///     their constraints both aggregated, but even when false, one or both
10903    ///     `Node`(s) may still be eliminated from consideration if one or both
10904    ///     `Node`(s) has a direct or indirect parent
10905    ///     `BufferCollectionTokenGroup` which selects a child subtree other
10906    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
10907    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
10908    ///   associated with the same buffer collection as the calling `Node`.
10909    ///   Another reason for this error is if the `node_ref` is an
10910    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
10911    ///   a real `node_ref` obtained from `GetNodeRef`.
10912    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
10913    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
10914    ///   the needed rights expected on a real `node_ref`.
10915    /// * No other failing status codes are returned by this call.  However,
10916    ///   sysmem may add additional codes in future, so the client should have
10917    ///   sensible default handling for any failing status code.
10918    IsAlternateFor { payload: NodeIsAlternateForRequest, responder: NodeIsAlternateForResponder },
10919    /// Get the buffer collection ID. This ID is also available from
10920    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
10921    /// within the collection).
10922    ///
10923    /// This call is mainly useful in situations where we can't convey a
10924    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
10925    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
10926    /// handle, which can be joined back up with a `BufferCollection` client end
10927    /// that was created via a different path. Prefer to convey a
10928    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
10929    ///
10930    /// Trusting a `buffer_collection_id` value from a source other than sysmem
10931    /// is analogous to trusting a koid value from a source other than zircon.
10932    /// Both should be avoided unless really necessary, and both require
10933    /// caution. In some situations it may be reasonable to refer to a
10934    /// pre-established `BufferCollection` by `buffer_collection_id` via a
10935    /// protocol for efficiency reasons, but an incoming value purporting to be
10936    /// a `buffer_collection_id` is not sufficient alone to justify granting the
10937    /// sender of the `buffer_collection_id` any capability. The sender must
10938    /// first prove to a receiver that the sender has/had a VMO or has/had a
10939    /// `BufferCollectionToken` to the same collection by sending a handle that
10940    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
10941    /// `buffer_collection_id` value. The receiver should take care to avoid
10942    /// assuming that a sender had a `BufferCollectionToken` in cases where the
10943    /// sender has only proven that the sender had a VMO.
10944    ///
10945    /// - response `buffer_collection_id` This ID is unique per buffer
10946    ///   collection per boot. Each buffer is uniquely identified by the
10947    ///   `buffer_collection_id` and `buffer_index` together.
10948    GetBufferCollectionId { responder: NodeGetBufferCollectionIdResponder },
10949    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
10950    /// created after this message to weak, which means that a client's `Node`
10951    /// client end (or a child created after this message) is not alone
10952    /// sufficient to keep allocated VMOs alive.
10953    ///
10954    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
10955    /// `close_weak_asap`.
10956    ///
10957    /// This message is only permitted before the `Node` becomes ready for
10958    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
10959    ///   * `BufferCollectionToken`: any time
10960    ///   * `BufferCollection`: before `SetConstraints`
10961    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
10962    ///
10963    /// Currently, no conversion from strong `Node` to weak `Node` after ready
10964    /// for allocation is provided, but a client can simulate that by creating
10965    /// an additional `Node` before allocation and setting that additional
10966    /// `Node` to weak, and then potentially at some point later sending
10967    /// `Release` and closing the client end of the client's strong `Node`, but
10968    /// keeping the client's weak `Node`.
10969    ///
10970    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
10971    /// collection failure (all `Node` client end(s) will see
10972    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
10973    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
10974    /// this situation until all `Node`(s) are ready for allocation. For initial
10975    /// allocation to succeed, at least one strong `Node` is required to exist
10976    /// at allocation time, but after that client receives VMO handles, that
10977    /// client can `BufferCollection.Release` and close the client end without
10978    /// causing this type of failure.
10979    ///
10980    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
10981    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
10982    /// separately as appropriate.
10983    SetWeak { control_handle: NodeControlHandle },
10984    /// This indicates to sysmem that the client is prepared to pay attention to
10985    /// `close_weak_asap`.
10986    ///
10987    /// If sent, this message must be before
10988    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
10989    ///
10990    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
10991    /// send this message before `WaitForAllBuffersAllocated`, or a parent
10992    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
10993    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
10994    /// trigger buffer collection failure.
10995    ///
10996    /// This message is necessary because weak sysmem VMOs have not always been
10997    /// a thing, so older clients are not aware of the need to pay attention to
10998    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
10999    /// sysmem weak VMO handles asap. By having this message and requiring
11000    /// participants to indicate their acceptance of this aspect of the overall
11001    /// protocol, we avoid situations where an older client is delivered a weak
11002    /// VMO without any way for sysmem to get that VMO to close quickly later
11003    /// (and on a per-buffer basis).
11004    ///
11005    /// A participant that doesn't handle `close_weak_asap` and also doesn't
11006    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
11007    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
11008    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
11009    /// same participant has a child/delegate which does retrieve VMOs, that
11010    /// child/delegate will need to send `SetWeakOk` before
11011    /// `WaitForAllBuffersAllocated`.
11012    ///
11013    /// + request `for_child_nodes_also` If present and true, this means direct
11014    ///   child nodes of this node created after this message plus all
11015    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
11016    ///   those nodes. Any child node of this node that was created before this
11017    ///   message is not included. This setting is "sticky" in the sense that a
11018    ///   subsequent `SetWeakOk` without this bool set to true does not reset
11019    ///   the server-side bool. If this creates a problem for a participant, a
11020    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
11021    ///   tokens instead, as appropriate. A participant should only set
11022    ///   `for_child_nodes_also` true if the participant can really promise to
11023    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
11024    ///   weak VMO handles held by participants holding the corresponding child
11025    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
11026    ///   which are using sysmem(1) can be weak, despite the clients of those
11027    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
11028    ///   direct way to find out about `close_weak_asap`. This only applies to
11029    ///   descendents of this `Node` which are using sysmem(1), not to this
11030    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
11031    ///   token, which will fail allocation unless an ancestor of this `Node`
11032    ///   specified `for_child_nodes_also` true.
11033    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: NodeControlHandle },
11034    /// The server_end will be closed after this `Node` and any child nodes have
11035    /// have released their buffer counts, making those counts available for
11036    /// reservation by a different `Node` via
11037    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
11038    ///
11039    /// The `Node` buffer counts may not be released until the entire tree of
11040    /// `Node`(s) is closed or failed, because
11041    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
11042    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
11043    /// `Node` buffer counts remain reserved until the orphaned node is later
11044    /// cleaned up.
11045    ///
11046    /// If the `Node` exceeds a fairly large number of attached eventpair server
11047    /// ends, a log message will indicate this and the `Node` (and the
11048    /// appropriate) sub-tree will fail.
11049    ///
11050    /// The `server_end` will remain open when
11051    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
11052    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
11053    /// [`fuchsia.sysmem2/BufferCollection`].
11054    ///
11055    /// This message can also be used with a
11056    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
11057    AttachNodeTracking { payload: NodeAttachNodeTrackingRequest, control_handle: NodeControlHandle },
11058    /// An interaction was received which does not match any known method.
11059    #[non_exhaustive]
11060    _UnknownMethod {
11061        /// Ordinal of the method that was called.
11062        ordinal: u64,
11063        control_handle: NodeControlHandle,
11064        method_type: fidl::MethodType,
11065    },
11066}
11067
11068impl NodeRequest {
11069    #[allow(irrefutable_let_patterns)]
11070    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
11071        if let NodeRequest::Sync { responder } = self { Some((responder)) } else { None }
11072    }
11073
11074    #[allow(irrefutable_let_patterns)]
11075    pub fn into_release(self) -> Option<(NodeControlHandle)> {
11076        if let NodeRequest::Release { control_handle } = self {
11077            Some((control_handle))
11078        } else {
11079            None
11080        }
11081    }
11082
11083    #[allow(irrefutable_let_patterns)]
11084    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, NodeControlHandle)> {
11085        if let NodeRequest::SetName { payload, control_handle } = self {
11086            Some((payload, control_handle))
11087        } else {
11088            None
11089        }
11090    }
11091
11092    #[allow(irrefutable_let_patterns)]
11093    pub fn into_set_debug_client_info(
11094        self,
11095    ) -> Option<(NodeSetDebugClientInfoRequest, NodeControlHandle)> {
11096        if let NodeRequest::SetDebugClientInfo { payload, control_handle } = self {
11097            Some((payload, control_handle))
11098        } else {
11099            None
11100        }
11101    }
11102
11103    #[allow(irrefutable_let_patterns)]
11104    pub fn into_set_debug_timeout_log_deadline(
11105        self,
11106    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, NodeControlHandle)> {
11107        if let NodeRequest::SetDebugTimeoutLogDeadline { payload, control_handle } = self {
11108            Some((payload, control_handle))
11109        } else {
11110            None
11111        }
11112    }
11113
11114    #[allow(irrefutable_let_patterns)]
11115    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
11116        if let NodeRequest::SetVerboseLogging { control_handle } = self {
11117            Some((control_handle))
11118        } else {
11119            None
11120        }
11121    }
11122
11123    #[allow(irrefutable_let_patterns)]
11124    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
11125        if let NodeRequest::GetNodeRef { responder } = self { Some((responder)) } else { None }
11126    }
11127
11128    #[allow(irrefutable_let_patterns)]
11129    pub fn into_is_alternate_for(
11130        self,
11131    ) -> Option<(NodeIsAlternateForRequest, NodeIsAlternateForResponder)> {
11132        if let NodeRequest::IsAlternateFor { payload, responder } = self {
11133            Some((payload, responder))
11134        } else {
11135            None
11136        }
11137    }
11138
11139    #[allow(irrefutable_let_patterns)]
11140    pub fn into_get_buffer_collection_id(self) -> Option<(NodeGetBufferCollectionIdResponder)> {
11141        if let NodeRequest::GetBufferCollectionId { responder } = self {
11142            Some((responder))
11143        } else {
11144            None
11145        }
11146    }
11147
11148    #[allow(irrefutable_let_patterns)]
11149    pub fn into_set_weak(self) -> Option<(NodeControlHandle)> {
11150        if let NodeRequest::SetWeak { control_handle } = self {
11151            Some((control_handle))
11152        } else {
11153            None
11154        }
11155    }
11156
11157    #[allow(irrefutable_let_patterns)]
11158    pub fn into_set_weak_ok(self) -> Option<(NodeSetWeakOkRequest, NodeControlHandle)> {
11159        if let NodeRequest::SetWeakOk { payload, control_handle } = self {
11160            Some((payload, control_handle))
11161        } else {
11162            None
11163        }
11164    }
11165
11166    #[allow(irrefutable_let_patterns)]
11167    pub fn into_attach_node_tracking(
11168        self,
11169    ) -> Option<(NodeAttachNodeTrackingRequest, NodeControlHandle)> {
11170        if let NodeRequest::AttachNodeTracking { payload, control_handle } = self {
11171            Some((payload, control_handle))
11172        } else {
11173            None
11174        }
11175    }
11176
11177    /// Name of the method defined in FIDL
11178    pub fn method_name(&self) -> &'static str {
11179        match *self {
11180            NodeRequest::Sync { .. } => "sync",
11181            NodeRequest::Release { .. } => "release",
11182            NodeRequest::SetName { .. } => "set_name",
11183            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
11184            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
11185            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
11186            NodeRequest::GetNodeRef { .. } => "get_node_ref",
11187            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
11188            NodeRequest::GetBufferCollectionId { .. } => "get_buffer_collection_id",
11189            NodeRequest::SetWeak { .. } => "set_weak",
11190            NodeRequest::SetWeakOk { .. } => "set_weak_ok",
11191            NodeRequest::AttachNodeTracking { .. } => "attach_node_tracking",
11192            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
11193                "unknown one-way method"
11194            }
11195            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
11196                "unknown two-way method"
11197            }
11198        }
11199    }
11200}
11201
11202#[derive(Debug, Clone)]
11203pub struct NodeControlHandle {
11204    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11205}
11206
11207impl fdomain_client::fidl::ControlHandle for NodeControlHandle {
11208    fn shutdown(&self) {
11209        self.inner.shutdown()
11210    }
11211
11212    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
11213        self.inner.shutdown_with_epitaph(status)
11214    }
11215
11216    fn is_closed(&self) -> bool {
11217        self.inner.channel().is_closed()
11218    }
11219    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
11220        self.inner.channel().on_closed()
11221    }
11222}
11223
11224impl NodeControlHandle {}
11225
11226#[must_use = "FIDL methods require a response to be sent"]
11227#[derive(Debug)]
11228pub struct NodeSyncResponder {
11229    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11230    tx_id: u32,
11231}
11232
11233/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11234/// if the responder is dropped without sending a response, so that the client
11235/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11236impl std::ops::Drop for NodeSyncResponder {
11237    fn drop(&mut self) {
11238        self.control_handle.shutdown();
11239        // Safety: drops once, never accessed again
11240        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11241    }
11242}
11243
11244impl fdomain_client::fidl::Responder for NodeSyncResponder {
11245    type ControlHandle = NodeControlHandle;
11246
11247    fn control_handle(&self) -> &NodeControlHandle {
11248        &self.control_handle
11249    }
11250
11251    fn drop_without_shutdown(mut self) {
11252        // Safety: drops once, never accessed again due to mem::forget
11253        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11254        // Prevent Drop from running (which would shut down the channel)
11255        std::mem::forget(self);
11256    }
11257}
11258
11259impl NodeSyncResponder {
11260    /// Sends a response to the FIDL transaction.
11261    ///
11262    /// Sets the channel to shutdown if an error occurs.
11263    pub fn send(self) -> Result<(), fidl::Error> {
11264        let _result = self.send_raw();
11265        if _result.is_err() {
11266            self.control_handle.shutdown();
11267        }
11268        self.drop_without_shutdown();
11269        _result
11270    }
11271
11272    /// Similar to "send" but does not shutdown the channel if an error occurs.
11273    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11274        let _result = self.send_raw();
11275        self.drop_without_shutdown();
11276        _result
11277    }
11278
11279    fn send_raw(&self) -> Result<(), fidl::Error> {
11280        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
11281            fidl::encoding::Flexible::new(()),
11282            self.tx_id,
11283            0x11ac2555cf575b54,
11284            fidl::encoding::DynamicFlags::FLEXIBLE,
11285        )
11286    }
11287}
11288
11289#[must_use = "FIDL methods require a response to be sent"]
11290#[derive(Debug)]
11291pub struct NodeGetNodeRefResponder {
11292    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11293    tx_id: u32,
11294}
11295
11296/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11297/// if the responder is dropped without sending a response, so that the client
11298/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11299impl std::ops::Drop for NodeGetNodeRefResponder {
11300    fn drop(&mut self) {
11301        self.control_handle.shutdown();
11302        // Safety: drops once, never accessed again
11303        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11304    }
11305}
11306
11307impl fdomain_client::fidl::Responder for NodeGetNodeRefResponder {
11308    type ControlHandle = NodeControlHandle;
11309
11310    fn control_handle(&self) -> &NodeControlHandle {
11311        &self.control_handle
11312    }
11313
11314    fn drop_without_shutdown(mut self) {
11315        // Safety: drops once, never accessed again due to mem::forget
11316        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11317        // Prevent Drop from running (which would shut down the channel)
11318        std::mem::forget(self);
11319    }
11320}
11321
11322impl NodeGetNodeRefResponder {
11323    /// Sends a response to the FIDL transaction.
11324    ///
11325    /// Sets the channel to shutdown if an error occurs.
11326    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
11327        let _result = self.send_raw(payload);
11328        if _result.is_err() {
11329            self.control_handle.shutdown();
11330        }
11331        self.drop_without_shutdown();
11332        _result
11333    }
11334
11335    /// Similar to "send" but does not shutdown the channel if an error occurs.
11336    pub fn send_no_shutdown_on_err(
11337        self,
11338        mut payload: NodeGetNodeRefResponse,
11339    ) -> Result<(), fidl::Error> {
11340        let _result = self.send_raw(payload);
11341        self.drop_without_shutdown();
11342        _result
11343    }
11344
11345    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
11346        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
11347            fidl::encoding::Flexible::new(&mut payload),
11348            self.tx_id,
11349            0x5b3d0e51614df053,
11350            fidl::encoding::DynamicFlags::FLEXIBLE,
11351        )
11352    }
11353}
11354
11355#[must_use = "FIDL methods require a response to be sent"]
11356#[derive(Debug)]
11357pub struct NodeIsAlternateForResponder {
11358    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11359    tx_id: u32,
11360}
11361
11362/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11363/// if the responder is dropped without sending a response, so that the client
11364/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11365impl std::ops::Drop for NodeIsAlternateForResponder {
11366    fn drop(&mut self) {
11367        self.control_handle.shutdown();
11368        // Safety: drops once, never accessed again
11369        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11370    }
11371}
11372
11373impl fdomain_client::fidl::Responder for NodeIsAlternateForResponder {
11374    type ControlHandle = NodeControlHandle;
11375
11376    fn control_handle(&self) -> &NodeControlHandle {
11377        &self.control_handle
11378    }
11379
11380    fn drop_without_shutdown(mut self) {
11381        // Safety: drops once, never accessed again due to mem::forget
11382        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11383        // Prevent Drop from running (which would shut down the channel)
11384        std::mem::forget(self);
11385    }
11386}
11387
11388impl NodeIsAlternateForResponder {
11389    /// Sends a response to the FIDL transaction.
11390    ///
11391    /// Sets the channel to shutdown if an error occurs.
11392    pub fn send(
11393        self,
11394        mut result: Result<&NodeIsAlternateForResponse, Error>,
11395    ) -> Result<(), fidl::Error> {
11396        let _result = self.send_raw(result);
11397        if _result.is_err() {
11398            self.control_handle.shutdown();
11399        }
11400        self.drop_without_shutdown();
11401        _result
11402    }
11403
11404    /// Similar to "send" but does not shutdown the channel if an error occurs.
11405    pub fn send_no_shutdown_on_err(
11406        self,
11407        mut result: Result<&NodeIsAlternateForResponse, Error>,
11408    ) -> Result<(), fidl::Error> {
11409        let _result = self.send_raw(result);
11410        self.drop_without_shutdown();
11411        _result
11412    }
11413
11414    fn send_raw(
11415        &self,
11416        mut result: Result<&NodeIsAlternateForResponse, Error>,
11417    ) -> Result<(), fidl::Error> {
11418        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
11419            NodeIsAlternateForResponse,
11420            Error,
11421        >>(
11422            fidl::encoding::FlexibleResult::new(result),
11423            self.tx_id,
11424            0x3a58e00157e0825,
11425            fidl::encoding::DynamicFlags::FLEXIBLE,
11426        )
11427    }
11428}
11429
11430#[must_use = "FIDL methods require a response to be sent"]
11431#[derive(Debug)]
11432pub struct NodeGetBufferCollectionIdResponder {
11433    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11434    tx_id: u32,
11435}
11436
11437/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11438/// if the responder is dropped without sending a response, so that the client
11439/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11440impl std::ops::Drop for NodeGetBufferCollectionIdResponder {
11441    fn drop(&mut self) {
11442        self.control_handle.shutdown();
11443        // Safety: drops once, never accessed again
11444        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11445    }
11446}
11447
11448impl fdomain_client::fidl::Responder for NodeGetBufferCollectionIdResponder {
11449    type ControlHandle = NodeControlHandle;
11450
11451    fn control_handle(&self) -> &NodeControlHandle {
11452        &self.control_handle
11453    }
11454
11455    fn drop_without_shutdown(mut self) {
11456        // Safety: drops once, never accessed again due to mem::forget
11457        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11458        // Prevent Drop from running (which would shut down the channel)
11459        std::mem::forget(self);
11460    }
11461}
11462
11463impl NodeGetBufferCollectionIdResponder {
11464    /// Sends a response to the FIDL transaction.
11465    ///
11466    /// Sets the channel to shutdown if an error occurs.
11467    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
11468        let _result = self.send_raw(payload);
11469        if _result.is_err() {
11470            self.control_handle.shutdown();
11471        }
11472        self.drop_without_shutdown();
11473        _result
11474    }
11475
11476    /// Similar to "send" but does not shutdown the channel if an error occurs.
11477    pub fn send_no_shutdown_on_err(
11478        self,
11479        mut payload: &NodeGetBufferCollectionIdResponse,
11480    ) -> Result<(), fidl::Error> {
11481        let _result = self.send_raw(payload);
11482        self.drop_without_shutdown();
11483        _result
11484    }
11485
11486    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
11487        self.control_handle
11488            .inner
11489            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
11490                fidl::encoding::Flexible::new(payload),
11491                self.tx_id,
11492                0x77d19a494b78ba8c,
11493                fidl::encoding::DynamicFlags::FLEXIBLE,
11494            )
11495    }
11496}
11497
11498#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11499pub struct SecureMemMarker;
11500
11501impl fdomain_client::fidl::ProtocolMarker for SecureMemMarker {
11502    type Proxy = SecureMemProxy;
11503    type RequestStream = SecureMemRequestStream;
11504
11505    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
11506}
11507pub type SecureMemGetPhysicalSecureHeapsResult =
11508    Result<SecureMemGetPhysicalSecureHeapsResponse, Error>;
11509pub type SecureMemGetDynamicSecureHeapsResult =
11510    Result<SecureMemGetDynamicSecureHeapsResponse, Error>;
11511pub type SecureMemGetPhysicalSecureHeapPropertiesResult =
11512    Result<SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>;
11513pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), Error>;
11514pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), Error>;
11515pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), Error>;
11516pub type SecureMemZeroSubRangeResult = Result<(), Error>;
11517
11518pub trait SecureMemProxyInterface: Send + Sync {
11519    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
11520        + Send;
11521    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
11522    type GetDynamicSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetDynamicSecureHeapsResult, fidl::Error>>
11523        + Send;
11524    fn r#get_dynamic_secure_heaps(&self) -> Self::GetDynamicSecureHeapsResponseFut;
11525    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
11526            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
11527        > + Send;
11528    fn r#get_physical_secure_heap_properties(
11529        &self,
11530        payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11531    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
11532    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
11533        + Send;
11534    fn r#add_secure_heap_physical_range(
11535        &self,
11536        payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11537    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
11538    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
11539            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
11540        > + Send;
11541    fn r#delete_secure_heap_physical_range(
11542        &self,
11543        payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11544    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
11545    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
11546            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
11547        > + Send;
11548    fn r#modify_secure_heap_physical_range(
11549        &self,
11550        payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11551    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
11552    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
11553        + Send;
11554    fn r#zero_sub_range(
11555        &self,
11556        payload: &SecureMemZeroSubRangeRequest,
11557    ) -> Self::ZeroSubRangeResponseFut;
11558}
11559
11560#[derive(Debug, Clone)]
11561pub struct SecureMemProxy {
11562    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11563}
11564
11565impl fdomain_client::fidl::Proxy for SecureMemProxy {
11566    type Protocol = SecureMemMarker;
11567
11568    fn from_channel(inner: fdomain_client::Channel) -> Self {
11569        Self::new(inner)
11570    }
11571
11572    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11573        self.client.into_channel().map_err(|client| Self { client })
11574    }
11575
11576    fn as_channel(&self) -> &fdomain_client::Channel {
11577        self.client.as_channel()
11578    }
11579}
11580
11581impl SecureMemProxy {
11582    /// Create a new Proxy for fuchsia.sysmem2/SecureMem.
11583    pub fn new(channel: fdomain_client::Channel) -> Self {
11584        let protocol_name = <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11585        Self { client: fidl::client::Client::new(channel, protocol_name) }
11586    }
11587
11588    /// Get a Stream of events from the remote end of the protocol.
11589    ///
11590    /// # Panics
11591    ///
11592    /// Panics if the event stream was already taken.
11593    pub fn take_event_stream(&self) -> SecureMemEventStream {
11594        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
11595    }
11596
11597    /// Gets the physical address and length of any secure heap whose physical
11598    /// range is configured via the TEE.
11599    ///
11600    /// Presently, these will be fixed physical addresses and lengths, with the
11601    /// location plumbed via the TEE.
11602    ///
11603    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
11604    /// when there isn't any special heap-specific per-VMO setup or teardown
11605    /// required.
11606    ///
11607    /// The physical range must be secured/protected by the TEE before the
11608    /// securemem driver responds to this request with success.
11609    ///
11610    /// Sysmem should only call this once.  Returning zero heaps is not a
11611    /// failure.
11612    ///
11613    /// Errors:
11614    ///  * PROTOCOL_DEVIATION - called more than once.
11615    ///  * UNSPECIFIED - generic internal error (such as in communication
11616    ///    with TEE which doesn't generate zx_status_t errors).
11617    ///  * other errors are allowed; any other errors should be treated the same
11618    ///    as UNSPECIFIED.
11619    pub fn r#get_physical_secure_heaps(
11620        &self,
11621    ) -> fidl::client::QueryResponseFut<
11622        SecureMemGetPhysicalSecureHeapsResult,
11623        fdomain_client::fidl::FDomainResourceDialect,
11624    > {
11625        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
11626    }
11627
11628    /// Gets information about any secure heaps whose physical pages are not
11629    /// configured by the TEE, but by sysmem.
11630    ///
11631    /// Sysmem should only call this once. Returning zero heaps is not a
11632    /// failure.
11633    ///
11634    /// Errors:
11635    ///  * PROTOCOL_DEVIATION - called more than once.
11636    ///  * UNSPECIFIED - generic internal error (such as in communication
11637    ///    with TEE which doesn't generate zx_status_t errors).
11638    ///  * other errors are allowed; any other errors should be treated the same
11639    ///    as UNSPECIFIED.
11640    pub fn r#get_dynamic_secure_heaps(
11641        &self,
11642    ) -> fidl::client::QueryResponseFut<
11643        SecureMemGetDynamicSecureHeapsResult,
11644        fdomain_client::fidl::FDomainResourceDialect,
11645    > {
11646        SecureMemProxyInterface::r#get_dynamic_secure_heaps(self)
11647    }
11648
11649    /// This request from sysmem to the securemem driver gets the properties of
11650    /// a protected/secure heap.
11651    ///
11652    /// This only handles heaps with a single contiguous physical extent.
11653    ///
11654    /// The heap's entire physical range is indicated in case this request needs
11655    /// some physical space to auto-detect how many ranges are REE-usable.  Any
11656    /// temporary HW protection ranges will be deleted before this request
11657    /// completes.
11658    ///
11659    /// Errors:
11660    ///  * UNSPECIFIED - generic internal error (such as in communication
11661    ///    with TEE which doesn't generate zx_status_t errors).
11662    ///  * other errors are allowed; any other errors should be treated the same
11663    ///    as UNSPECIFIED.
11664    pub fn r#get_physical_secure_heap_properties(
11665        &self,
11666        mut payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11667    ) -> fidl::client::QueryResponseFut<
11668        SecureMemGetPhysicalSecureHeapPropertiesResult,
11669        fdomain_client::fidl::FDomainResourceDialect,
11670    > {
11671        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, payload)
11672    }
11673
11674    /// This request from sysmem to the securemem driver conveys a physical
11675    /// range to add, for a heap whose physical range(s) are set up via
11676    /// sysmem.
11677    ///
11678    /// Only sysmem can call this because only sysmem is handed the client end
11679    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11680    /// securemem driver is the server end of this protocol.
11681    ///
11682    /// The securemem driver must configure all the covered offsets as protected
11683    /// before responding to this message with success.
11684    ///
11685    /// On failure, the securemem driver must ensure the protected range was not
11686    /// created.
11687    ///
11688    /// Sysmem must only call this up to once if dynamic_protection_ranges
11689    /// false.
11690    ///
11691    /// If dynamic_protection_ranges is true, sysmem can call this multiple
11692    /// times as long as the current number of ranges never exceeds
11693    /// max_protected_range_count.
11694    ///
11695    /// The caller must not attempt to add a range that matches an
11696    /// already-existing range.  Added ranges can overlap each other as long as
11697    /// no two ranges match exactly.
11698    ///
11699    /// Errors:
11700    ///   * PROTOCOL_DEVIATION - called more than once when
11701    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
11702    ///     heap count to exceed max_protected_range_count. Unexpected heap, or
11703    ///     range that doesn't conform to protected_range_granularity. See log.
11704    ///   * UNSPECIFIED - generic internal error (such as in communication
11705    ///     with TEE which doesn't generate zx_status_t errors).
11706    ///   * other errors are possible, such as from communication failures or
11707    ///     server propagation of failures.
11708    pub fn r#add_secure_heap_physical_range(
11709        &self,
11710        mut payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11711    ) -> fidl::client::QueryResponseFut<
11712        SecureMemAddSecureHeapPhysicalRangeResult,
11713        fdomain_client::fidl::FDomainResourceDialect,
11714    > {
11715        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, payload)
11716    }
11717
11718    /// This request from sysmem to the securemem driver conveys a physical
11719    /// range to delete, for a heap whose physical range(s) are set up via
11720    /// sysmem.
11721    ///
11722    /// Only sysmem can call this because only sysmem is handed the client end
11723    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11724    /// securemem driver is the server end of this protocol.
11725    ///
11726    /// The securemem driver must configure all the covered offsets as not
11727    /// protected before responding to this message with success.
11728    ///
11729    /// On failure, the securemem driver must ensure the protected range was not
11730    /// deleted.
11731    ///
11732    /// Sysmem must not call this if dynamic_protection_ranges false.
11733    ///
11734    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11735    /// on various ranges that exist at the time of the call.
11736    ///
11737    /// If any portion of the range being deleted is not also covered by another
11738    /// protected range, then any ongoing DMA to any part of the entire range
11739    /// may be interrupted / may fail, potentially in a way that's disruptive to
11740    /// the entire system (bus lockup or similar, depending on device details).
11741    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
11742    /// any portion of the range being deleted, unless the caller has other
11743    /// active ranges covering every block of the range being deleted.  Ongoing
11744    /// DMA to/from blocks outside the range being deleted is never impacted by
11745    /// the deletion.
11746    ///
11747    /// Errors:
11748    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11749    ///     Unexpected heap, or range that doesn't conform to
11750    ///     protected_range_granularity.
11751    ///   * UNSPECIFIED - generic internal error (such as in communication
11752    ///     with TEE which doesn't generate zx_status_t errors).
11753    ///   * NOT_FOUND - the specified range is not found.
11754    ///   * other errors are possible, such as from communication failures or
11755    ///     server propagation of failures.
11756    pub fn r#delete_secure_heap_physical_range(
11757        &self,
11758        mut payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11759    ) -> fidl::client::QueryResponseFut<
11760        SecureMemDeleteSecureHeapPhysicalRangeResult,
11761        fdomain_client::fidl::FDomainResourceDialect,
11762    > {
11763        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, payload)
11764    }
11765
11766    /// This request from sysmem to the securemem driver conveys a physical
11767    /// range to modify and its new base and length, for a heap whose physical
11768    /// range(s) are set up via sysmem.
11769    ///
11770    /// Only sysmem can call this because only sysmem is handed the client end
11771    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11772    /// securemem driver is the server end of this protocol.
11773    ///
11774    /// The securemem driver must configure the range to cover only the new
11775    /// offsets before responding to this message with success.
11776    ///
11777    /// On failure, the securemem driver must ensure the range was not changed.
11778    ///
11779    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
11780    /// must not call this if !is_mod_protected_range_available.
11781    ///
11782    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11783    /// on various ranges that exist at the time of the call.
11784    ///
11785    /// The range must only be modified at one end or the other, but not both.
11786    /// If the range is getting shorter, and the un-covered blocks are not
11787    /// covered by other active ranges, any ongoing DMA to the entire range
11788    /// that's geting shorter may fail in a way that disrupts the entire system
11789    /// (bus lockup or similar), so the caller must ensure that no DMA is
11790    /// ongoing to any portion of a range that is getting shorter, unless the
11791    /// blocks being un-covered by the modification to this range are all
11792    /// covered by other active ranges, in which case no disruption to ongoing
11793    /// DMA will occur.
11794    ///
11795    /// If a range is modified to become <= zero length, the range is deleted.
11796    ///
11797    /// Errors:
11798    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11799    ///     Unexpected heap, or old_range or new_range that doesn't conform to
11800    ///     protected_range_granularity, or old_range and new_range differ in
11801    ///     both begin and end (disallowed).
11802    ///   * UNSPECIFIED - generic internal error (such as in communication
11803    ///     with TEE which doesn't generate zx_status_t errors).
11804    ///   * NOT_FOUND - the specified range is not found.
11805    ///   * other errors are possible, such as from communication failures or
11806    ///     server propagation of failures.
11807    pub fn r#modify_secure_heap_physical_range(
11808        &self,
11809        mut payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11810    ) -> fidl::client::QueryResponseFut<
11811        SecureMemModifySecureHeapPhysicalRangeResult,
11812        fdomain_client::fidl::FDomainResourceDialect,
11813    > {
11814        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, payload)
11815    }
11816
11817    /// Zero a sub-range of a currently-existing physical range added via
11818    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11819    /// exactly one physical range, and must not overlap with any other
11820    /// physical range.
11821    ///
11822    /// is_covering_range_explicit - When true, the covering range must be one
11823    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11824    ///     possibly modified since.  When false, the covering range must not
11825    ///     be one of the ranges explicitly created via
11826    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11827    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11828    ///     covering range is typically the entire physical range (or a range
11829    ///     which covers even more) of a heap configured by the TEE and whose
11830    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11831    ///
11832    /// Ongoing DMA is not disrupted by this request.
11833    ///
11834    /// Errors:
11835    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11836    ///     Unexpected heap.
11837    ///   * UNSPECIFIED - generic internal error (such as in communication
11838    ///     with TEE which doesn't generate zx_status_t errors).
11839    ///   * other errors are possible, such as from communication failures or
11840    ///     server propagation of failures.
11841    pub fn r#zero_sub_range(
11842        &self,
11843        mut payload: &SecureMemZeroSubRangeRequest,
11844    ) -> fidl::client::QueryResponseFut<
11845        SecureMemZeroSubRangeResult,
11846        fdomain_client::fidl::FDomainResourceDialect,
11847    > {
11848        SecureMemProxyInterface::r#zero_sub_range(self, payload)
11849    }
11850}
11851
11852impl SecureMemProxyInterface for SecureMemProxy {
11853    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11854        SecureMemGetPhysicalSecureHeapsResult,
11855        fdomain_client::fidl::FDomainResourceDialect,
11856    >;
11857    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
11858        fn _decode(
11859            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11860        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
11861            let _response = fidl::client::decode_transaction_body::<
11862                fidl::encoding::FlexibleResultType<SecureMemGetPhysicalSecureHeapsResponse, Error>,
11863                fdomain_client::fidl::FDomainResourceDialect,
11864                0x38716300592073e3,
11865            >(_buf?)?
11866            .into_result_fdomain::<SecureMemMarker>("get_physical_secure_heaps")?;
11867            Ok(_response.map(|x| x))
11868        }
11869        self.client.send_query_and_decode::<
11870            fidl::encoding::EmptyPayload,
11871            SecureMemGetPhysicalSecureHeapsResult,
11872        >(
11873            (),
11874            0x38716300592073e3,
11875            fidl::encoding::DynamicFlags::FLEXIBLE,
11876            _decode,
11877        )
11878    }
11879
11880    type GetDynamicSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11881        SecureMemGetDynamicSecureHeapsResult,
11882        fdomain_client::fidl::FDomainResourceDialect,
11883    >;
11884    fn r#get_dynamic_secure_heaps(&self) -> Self::GetDynamicSecureHeapsResponseFut {
11885        fn _decode(
11886            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11887        ) -> Result<SecureMemGetDynamicSecureHeapsResult, fidl::Error> {
11888            let _response = fidl::client::decode_transaction_body::<
11889                fidl::encoding::FlexibleResultType<SecureMemGetDynamicSecureHeapsResponse, Error>,
11890                fdomain_client::fidl::FDomainResourceDialect,
11891                0x1190847f99952834,
11892            >(_buf?)?
11893            .into_result_fdomain::<SecureMemMarker>("get_dynamic_secure_heaps")?;
11894            Ok(_response.map(|x| x))
11895        }
11896        self.client.send_query_and_decode::<
11897            fidl::encoding::EmptyPayload,
11898            SecureMemGetDynamicSecureHeapsResult,
11899        >(
11900            (),
11901            0x1190847f99952834,
11902            fidl::encoding::DynamicFlags::FLEXIBLE,
11903            _decode,
11904        )
11905    }
11906
11907    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
11908        SecureMemGetPhysicalSecureHeapPropertiesResult,
11909        fdomain_client::fidl::FDomainResourceDialect,
11910    >;
11911    fn r#get_physical_secure_heap_properties(
11912        &self,
11913        mut payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11914    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
11915        fn _decode(
11916            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11917        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
11918            let _response = fidl::client::decode_transaction_body::<
11919                fidl::encoding::FlexibleResultType<
11920                    SecureMemGetPhysicalSecureHeapPropertiesResponse,
11921                    Error,
11922                >,
11923                fdomain_client::fidl::FDomainResourceDialect,
11924                0xc6f06889009c7bc,
11925            >(_buf?)?
11926            .into_result_fdomain::<SecureMemMarker>("get_physical_secure_heap_properties")?;
11927            Ok(_response.map(|x| x))
11928        }
11929        self.client.send_query_and_decode::<
11930            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11931            SecureMemGetPhysicalSecureHeapPropertiesResult,
11932        >(
11933            payload,
11934            0xc6f06889009c7bc,
11935            fidl::encoding::DynamicFlags::FLEXIBLE,
11936            _decode,
11937        )
11938    }
11939
11940    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11941        SecureMemAddSecureHeapPhysicalRangeResult,
11942        fdomain_client::fidl::FDomainResourceDialect,
11943    >;
11944    fn r#add_secure_heap_physical_range(
11945        &self,
11946        mut payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11947    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
11948        fn _decode(
11949            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11950        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
11951            let _response = fidl::client::decode_transaction_body::<
11952                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11953                fdomain_client::fidl::FDomainResourceDialect,
11954                0x35f695b9b6c7217a,
11955            >(_buf?)?
11956            .into_result_fdomain::<SecureMemMarker>("add_secure_heap_physical_range")?;
11957            Ok(_response.map(|x| x))
11958        }
11959        self.client.send_query_and_decode::<
11960            SecureMemAddSecureHeapPhysicalRangeRequest,
11961            SecureMemAddSecureHeapPhysicalRangeResult,
11962        >(
11963            payload,
11964            0x35f695b9b6c7217a,
11965            fidl::encoding::DynamicFlags::FLEXIBLE,
11966            _decode,
11967        )
11968    }
11969
11970    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11971        SecureMemDeleteSecureHeapPhysicalRangeResult,
11972        fdomain_client::fidl::FDomainResourceDialect,
11973    >;
11974    fn r#delete_secure_heap_physical_range(
11975        &self,
11976        mut payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11977    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
11978        fn _decode(
11979            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11980        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
11981            let _response = fidl::client::decode_transaction_body::<
11982                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11983                fdomain_client::fidl::FDomainResourceDialect,
11984                0xeaa58c650264c9e,
11985            >(_buf?)?
11986            .into_result_fdomain::<SecureMemMarker>("delete_secure_heap_physical_range")?;
11987            Ok(_response.map(|x| x))
11988        }
11989        self.client.send_query_and_decode::<
11990            SecureMemDeleteSecureHeapPhysicalRangeRequest,
11991            SecureMemDeleteSecureHeapPhysicalRangeResult,
11992        >(
11993            payload,
11994            0xeaa58c650264c9e,
11995            fidl::encoding::DynamicFlags::FLEXIBLE,
11996            _decode,
11997        )
11998    }
11999
12000    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
12001        SecureMemModifySecureHeapPhysicalRangeResult,
12002        fdomain_client::fidl::FDomainResourceDialect,
12003    >;
12004    fn r#modify_secure_heap_physical_range(
12005        &self,
12006        mut payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
12007    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
12008        fn _decode(
12009            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12010        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
12011            let _response = fidl::client::decode_transaction_body::<
12012                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
12013                fdomain_client::fidl::FDomainResourceDialect,
12014                0x60b7448aa1187734,
12015            >(_buf?)?
12016            .into_result_fdomain::<SecureMemMarker>("modify_secure_heap_physical_range")?;
12017            Ok(_response.map(|x| x))
12018        }
12019        self.client.send_query_and_decode::<
12020            SecureMemModifySecureHeapPhysicalRangeRequest,
12021            SecureMemModifySecureHeapPhysicalRangeResult,
12022        >(
12023            payload,
12024            0x60b7448aa1187734,
12025            fidl::encoding::DynamicFlags::FLEXIBLE,
12026            _decode,
12027        )
12028    }
12029
12030    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
12031        SecureMemZeroSubRangeResult,
12032        fdomain_client::fidl::FDomainResourceDialect,
12033    >;
12034    fn r#zero_sub_range(
12035        &self,
12036        mut payload: &SecureMemZeroSubRangeRequest,
12037    ) -> Self::ZeroSubRangeResponseFut {
12038        fn _decode(
12039            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12040        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
12041            let _response = fidl::client::decode_transaction_body::<
12042                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
12043                fdomain_client::fidl::FDomainResourceDialect,
12044                0x5b25b7901a385ce5,
12045            >(_buf?)?
12046            .into_result_fdomain::<SecureMemMarker>("zero_sub_range")?;
12047            Ok(_response.map(|x| x))
12048        }
12049        self.client
12050            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
12051                payload,
12052                0x5b25b7901a385ce5,
12053                fidl::encoding::DynamicFlags::FLEXIBLE,
12054                _decode,
12055            )
12056    }
12057}
12058
12059pub struct SecureMemEventStream {
12060    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
12061}
12062
12063impl std::marker::Unpin for SecureMemEventStream {}
12064
12065impl futures::stream::FusedStream for SecureMemEventStream {
12066    fn is_terminated(&self) -> bool {
12067        self.event_receiver.is_terminated()
12068    }
12069}
12070
12071impl futures::Stream for SecureMemEventStream {
12072    type Item = Result<SecureMemEvent, fidl::Error>;
12073
12074    fn poll_next(
12075        mut self: std::pin::Pin<&mut Self>,
12076        cx: &mut std::task::Context<'_>,
12077    ) -> std::task::Poll<Option<Self::Item>> {
12078        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12079            &mut self.event_receiver,
12080            cx
12081        )?) {
12082            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
12083            None => std::task::Poll::Ready(None),
12084        }
12085    }
12086}
12087
12088#[derive(Debug)]
12089pub enum SecureMemEvent {
12090    #[non_exhaustive]
12091    _UnknownEvent {
12092        /// Ordinal of the event that was sent.
12093        ordinal: u64,
12094    },
12095}
12096
12097impl SecureMemEvent {
12098    /// Decodes a message buffer as a [`SecureMemEvent`].
12099    fn decode(
12100        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12101    ) -> Result<SecureMemEvent, fidl::Error> {
12102        let (bytes, _handles) = buf.split_mut();
12103        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12104        debug_assert_eq!(tx_header.tx_id, 0);
12105        match tx_header.ordinal {
12106            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12107                Ok(SecureMemEvent::_UnknownEvent { ordinal: tx_header.ordinal })
12108            }
12109            _ => Err(fidl::Error::UnknownOrdinal {
12110                ordinal: tx_header.ordinal,
12111                protocol_name:
12112                    <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12113            }),
12114        }
12115    }
12116}
12117
12118/// A Stream of incoming requests for fuchsia.sysmem2/SecureMem.
12119pub struct SecureMemRequestStream {
12120    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12121    is_terminated: bool,
12122}
12123
12124impl std::marker::Unpin for SecureMemRequestStream {}
12125
12126impl futures::stream::FusedStream for SecureMemRequestStream {
12127    fn is_terminated(&self) -> bool {
12128        self.is_terminated
12129    }
12130}
12131
12132impl fdomain_client::fidl::RequestStream for SecureMemRequestStream {
12133    type Protocol = SecureMemMarker;
12134    type ControlHandle = SecureMemControlHandle;
12135
12136    fn from_channel(channel: fdomain_client::Channel) -> Self {
12137        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12138    }
12139
12140    fn control_handle(&self) -> Self::ControlHandle {
12141        SecureMemControlHandle { inner: self.inner.clone() }
12142    }
12143
12144    fn into_inner(
12145        self,
12146    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
12147    {
12148        (self.inner, self.is_terminated)
12149    }
12150
12151    fn from_inner(
12152        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12153        is_terminated: bool,
12154    ) -> Self {
12155        Self { inner, is_terminated }
12156    }
12157}
12158
12159impl futures::Stream for SecureMemRequestStream {
12160    type Item = Result<SecureMemRequest, fidl::Error>;
12161
12162    fn poll_next(
12163        mut self: std::pin::Pin<&mut Self>,
12164        cx: &mut std::task::Context<'_>,
12165    ) -> std::task::Poll<Option<Self::Item>> {
12166        let this = &mut *self;
12167        if this.inner.check_shutdown(cx) {
12168            this.is_terminated = true;
12169            return std::task::Poll::Ready(None);
12170        }
12171        if this.is_terminated {
12172            panic!("polled SecureMemRequestStream after completion");
12173        }
12174        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
12175            |bytes, handles| {
12176                match this.inner.channel().read_etc(cx, bytes, handles) {
12177                    std::task::Poll::Ready(Ok(())) => {}
12178                    std::task::Poll::Pending => return std::task::Poll::Pending,
12179                    std::task::Poll::Ready(Err(None)) => {
12180                        this.is_terminated = true;
12181                        return std::task::Poll::Ready(None);
12182                    }
12183                    std::task::Poll::Ready(Err(Some(e))) => {
12184                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12185                            e.into(),
12186                        ))));
12187                    }
12188                }
12189
12190                // A message has been received from the channel
12191                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12192
12193                std::task::Poll::Ready(Some(match header.ordinal {
12194                    0x38716300592073e3 => {
12195                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12196                        let mut req = fidl::new_empty!(
12197                            fidl::encoding::EmptyPayload,
12198                            fdomain_client::fidl::FDomainResourceDialect
12199                        );
12200                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12201                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12202                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
12203                            responder: SecureMemGetPhysicalSecureHeapsResponder {
12204                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12205                                tx_id: header.tx_id,
12206                            },
12207                        })
12208                    }
12209                    0x1190847f99952834 => {
12210                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12211                        let mut req = fidl::new_empty!(
12212                            fidl::encoding::EmptyPayload,
12213                            fdomain_client::fidl::FDomainResourceDialect
12214                        );
12215                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12216                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12217                        Ok(SecureMemRequest::GetDynamicSecureHeaps {
12218                            responder: SecureMemGetDynamicSecureHeapsResponder {
12219                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12220                                tx_id: header.tx_id,
12221                            },
12222                        })
12223                    }
12224                    0xc6f06889009c7bc => {
12225                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12226                        let mut req = fidl::new_empty!(
12227                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
12228                            fdomain_client::fidl::FDomainResourceDialect
12229                        );
12230                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
12231                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12232                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
12233                            payload: req,
12234                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
12235                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12236                                tx_id: header.tx_id,
12237                            },
12238                        })
12239                    }
12240                    0x35f695b9b6c7217a => {
12241                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12242                        let mut req = fidl::new_empty!(
12243                            SecureMemAddSecureHeapPhysicalRangeRequest,
12244                            fdomain_client::fidl::FDomainResourceDialect
12245                        );
12246                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12247                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12248                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
12249                            payload: req,
12250                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
12251                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12252                                tx_id: header.tx_id,
12253                            },
12254                        })
12255                    }
12256                    0xeaa58c650264c9e => {
12257                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12258                        let mut req = fidl::new_empty!(
12259                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
12260                            fdomain_client::fidl::FDomainResourceDialect
12261                        );
12262                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12263                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12264                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
12265                            payload: req,
12266                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
12267                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12268                                tx_id: header.tx_id,
12269                            },
12270                        })
12271                    }
12272                    0x60b7448aa1187734 => {
12273                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12274                        let mut req = fidl::new_empty!(
12275                            SecureMemModifySecureHeapPhysicalRangeRequest,
12276                            fdomain_client::fidl::FDomainResourceDialect
12277                        );
12278                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12279                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12280                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
12281                            payload: req,
12282                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
12283                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12284                                tx_id: header.tx_id,
12285                            },
12286                        })
12287                    }
12288                    0x5b25b7901a385ce5 => {
12289                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12290                        let mut req = fidl::new_empty!(
12291                            SecureMemZeroSubRangeRequest,
12292                            fdomain_client::fidl::FDomainResourceDialect
12293                        );
12294                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12295                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12296                        Ok(SecureMemRequest::ZeroSubRange {
12297                            payload: req,
12298                            responder: SecureMemZeroSubRangeResponder {
12299                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12300                                tx_id: header.tx_id,
12301                            },
12302                        })
12303                    }
12304                    _ if header.tx_id == 0
12305                        && header
12306                            .dynamic_flags()
12307                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
12308                    {
12309                        Ok(SecureMemRequest::_UnknownMethod {
12310                            ordinal: header.ordinal,
12311                            control_handle: SecureMemControlHandle { inner: this.inner.clone() },
12312                            method_type: fidl::MethodType::OneWay,
12313                        })
12314                    }
12315                    _ if header
12316                        .dynamic_flags()
12317                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
12318                    {
12319                        this.inner.send_framework_err(
12320                            fidl::encoding::FrameworkErr::UnknownMethod,
12321                            header.tx_id,
12322                            header.ordinal,
12323                            header.dynamic_flags(),
12324                            (bytes, handles),
12325                        )?;
12326                        Ok(SecureMemRequest::_UnknownMethod {
12327                            ordinal: header.ordinal,
12328                            control_handle: SecureMemControlHandle { inner: this.inner.clone() },
12329                            method_type: fidl::MethodType::TwoWay,
12330                        })
12331                    }
12332                    _ => Err(fidl::Error::UnknownOrdinal {
12333                        ordinal: header.ordinal,
12334                        protocol_name:
12335                            <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12336                    }),
12337                }))
12338            },
12339        )
12340    }
12341}
12342
12343/// SecureMem
12344///
12345/// The client is sysmem.  The server is securemem driver.
12346///
12347/// TEE - Trusted Execution Environment.
12348///
12349/// REE - Rich Execution Environment.
12350///
12351/// Enables sysmem to call the securemem driver to get any secure heaps
12352/// configured via the TEE (or via the securemem driver), and set any physical
12353/// secure heaps configured via sysmem.
12354///
12355/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
12356/// it starts quite early during boot and can successfully reserve contiguous
12357/// physical memory.  Presently, fixed-location secure heaps are configured via
12358/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
12359/// protocol intentionally doesn't care which heaps are dynamically-allocated
12360/// and which are fixed-location.
12361#[derive(Debug)]
12362pub enum SecureMemRequest {
12363    /// Gets the physical address and length of any secure heap whose physical
12364    /// range is configured via the TEE.
12365    ///
12366    /// Presently, these will be fixed physical addresses and lengths, with the
12367    /// location plumbed via the TEE.
12368    ///
12369    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
12370    /// when there isn't any special heap-specific per-VMO setup or teardown
12371    /// required.
12372    ///
12373    /// The physical range must be secured/protected by the TEE before the
12374    /// securemem driver responds to this request with success.
12375    ///
12376    /// Sysmem should only call this once.  Returning zero heaps is not a
12377    /// failure.
12378    ///
12379    /// Errors:
12380    ///  * PROTOCOL_DEVIATION - called more than once.
12381    ///  * UNSPECIFIED - generic internal error (such as in communication
12382    ///    with TEE which doesn't generate zx_status_t errors).
12383    ///  * other errors are allowed; any other errors should be treated the same
12384    ///    as UNSPECIFIED.
12385    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
12386    /// Gets information about any secure heaps whose physical pages are not
12387    /// configured by the TEE, but by sysmem.
12388    ///
12389    /// Sysmem should only call this once. Returning zero heaps is not a
12390    /// failure.
12391    ///
12392    /// Errors:
12393    ///  * PROTOCOL_DEVIATION - called more than once.
12394    ///  * UNSPECIFIED - generic internal error (such as in communication
12395    ///    with TEE which doesn't generate zx_status_t errors).
12396    ///  * other errors are allowed; any other errors should be treated the same
12397    ///    as UNSPECIFIED.
12398    GetDynamicSecureHeaps { responder: SecureMemGetDynamicSecureHeapsResponder },
12399    /// This request from sysmem to the securemem driver gets the properties of
12400    /// a protected/secure heap.
12401    ///
12402    /// This only handles heaps with a single contiguous physical extent.
12403    ///
12404    /// The heap's entire physical range is indicated in case this request needs
12405    /// some physical space to auto-detect how many ranges are REE-usable.  Any
12406    /// temporary HW protection ranges will be deleted before this request
12407    /// completes.
12408    ///
12409    /// Errors:
12410    ///  * UNSPECIFIED - generic internal error (such as in communication
12411    ///    with TEE which doesn't generate zx_status_t errors).
12412    ///  * other errors are allowed; any other errors should be treated the same
12413    ///    as UNSPECIFIED.
12414    GetPhysicalSecureHeapProperties {
12415        payload: SecureMemGetPhysicalSecureHeapPropertiesRequest,
12416        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
12417    },
12418    /// This request from sysmem to the securemem driver conveys a physical
12419    /// range to add, for a heap whose physical range(s) are set up via
12420    /// sysmem.
12421    ///
12422    /// Only sysmem can call this because only sysmem is handed the client end
12423    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12424    /// securemem driver is the server end of this protocol.
12425    ///
12426    /// The securemem driver must configure all the covered offsets as protected
12427    /// before responding to this message with success.
12428    ///
12429    /// On failure, the securemem driver must ensure the protected range was not
12430    /// created.
12431    ///
12432    /// Sysmem must only call this up to once if dynamic_protection_ranges
12433    /// false.
12434    ///
12435    /// If dynamic_protection_ranges is true, sysmem can call this multiple
12436    /// times as long as the current number of ranges never exceeds
12437    /// max_protected_range_count.
12438    ///
12439    /// The caller must not attempt to add a range that matches an
12440    /// already-existing range.  Added ranges can overlap each other as long as
12441    /// no two ranges match exactly.
12442    ///
12443    /// Errors:
12444    ///   * PROTOCOL_DEVIATION - called more than once when
12445    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
12446    ///     heap count to exceed max_protected_range_count. Unexpected heap, or
12447    ///     range that doesn't conform to protected_range_granularity. See log.
12448    ///   * UNSPECIFIED - generic internal error (such as in communication
12449    ///     with TEE which doesn't generate zx_status_t errors).
12450    ///   * other errors are possible, such as from communication failures or
12451    ///     server propagation of failures.
12452    AddSecureHeapPhysicalRange {
12453        payload: SecureMemAddSecureHeapPhysicalRangeRequest,
12454        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
12455    },
12456    /// This request from sysmem to the securemem driver conveys a physical
12457    /// range to delete, for a heap whose physical range(s) are set up via
12458    /// sysmem.
12459    ///
12460    /// Only sysmem can call this because only sysmem is handed the client end
12461    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12462    /// securemem driver is the server end of this protocol.
12463    ///
12464    /// The securemem driver must configure all the covered offsets as not
12465    /// protected before responding to this message with success.
12466    ///
12467    /// On failure, the securemem driver must ensure the protected range was not
12468    /// deleted.
12469    ///
12470    /// Sysmem must not call this if dynamic_protection_ranges false.
12471    ///
12472    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
12473    /// on various ranges that exist at the time of the call.
12474    ///
12475    /// If any portion of the range being deleted is not also covered by another
12476    /// protected range, then any ongoing DMA to any part of the entire range
12477    /// may be interrupted / may fail, potentially in a way that's disruptive to
12478    /// the entire system (bus lockup or similar, depending on device details).
12479    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
12480    /// any portion of the range being deleted, unless the caller has other
12481    /// active ranges covering every block of the range being deleted.  Ongoing
12482    /// DMA to/from blocks outside the range being deleted is never impacted by
12483    /// the deletion.
12484    ///
12485    /// Errors:
12486    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12487    ///     Unexpected heap, or range that doesn't conform to
12488    ///     protected_range_granularity.
12489    ///   * UNSPECIFIED - generic internal error (such as in communication
12490    ///     with TEE which doesn't generate zx_status_t errors).
12491    ///   * NOT_FOUND - the specified range is not found.
12492    ///   * other errors are possible, such as from communication failures or
12493    ///     server propagation of failures.
12494    DeleteSecureHeapPhysicalRange {
12495        payload: SecureMemDeleteSecureHeapPhysicalRangeRequest,
12496        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
12497    },
12498    /// This request from sysmem to the securemem driver conveys a physical
12499    /// range to modify and its new base and length, for a heap whose physical
12500    /// range(s) are set up via sysmem.
12501    ///
12502    /// Only sysmem can call this because only sysmem is handed the client end
12503    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12504    /// securemem driver is the server end of this protocol.
12505    ///
12506    /// The securemem driver must configure the range to cover only the new
12507    /// offsets before responding to this message with success.
12508    ///
12509    /// On failure, the securemem driver must ensure the range was not changed.
12510    ///
12511    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
12512    /// must not call this if !is_mod_protected_range_available.
12513    ///
12514    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
12515    /// on various ranges that exist at the time of the call.
12516    ///
12517    /// The range must only be modified at one end or the other, but not both.
12518    /// If the range is getting shorter, and the un-covered blocks are not
12519    /// covered by other active ranges, any ongoing DMA to the entire range
12520    /// that's geting shorter may fail in a way that disrupts the entire system
12521    /// (bus lockup or similar), so the caller must ensure that no DMA is
12522    /// ongoing to any portion of a range that is getting shorter, unless the
12523    /// blocks being un-covered by the modification to this range are all
12524    /// covered by other active ranges, in which case no disruption to ongoing
12525    /// DMA will occur.
12526    ///
12527    /// If a range is modified to become <= zero length, the range is deleted.
12528    ///
12529    /// Errors:
12530    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12531    ///     Unexpected heap, or old_range or new_range that doesn't conform to
12532    ///     protected_range_granularity, or old_range and new_range differ in
12533    ///     both begin and end (disallowed).
12534    ///   * UNSPECIFIED - generic internal error (such as in communication
12535    ///     with TEE which doesn't generate zx_status_t errors).
12536    ///   * NOT_FOUND - the specified range is not found.
12537    ///   * other errors are possible, such as from communication failures or
12538    ///     server propagation of failures.
12539    ModifySecureHeapPhysicalRange {
12540        payload: SecureMemModifySecureHeapPhysicalRangeRequest,
12541        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
12542    },
12543    /// Zero a sub-range of a currently-existing physical range added via
12544    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
12545    /// exactly one physical range, and must not overlap with any other
12546    /// physical range.
12547    ///
12548    /// is_covering_range_explicit - When true, the covering range must be one
12549    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
12550    ///     possibly modified since.  When false, the covering range must not
12551    ///     be one of the ranges explicitly created via
12552    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
12553    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
12554    ///     covering range is typically the entire physical range (or a range
12555    ///     which covers even more) of a heap configured by the TEE and whose
12556    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
12557    ///
12558    /// Ongoing DMA is not disrupted by this request.
12559    ///
12560    /// Errors:
12561    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12562    ///     Unexpected heap.
12563    ///   * UNSPECIFIED - generic internal error (such as in communication
12564    ///     with TEE which doesn't generate zx_status_t errors).
12565    ///   * other errors are possible, such as from communication failures or
12566    ///     server propagation of failures.
12567    ZeroSubRange {
12568        payload: SecureMemZeroSubRangeRequest,
12569        responder: SecureMemZeroSubRangeResponder,
12570    },
12571    /// An interaction was received which does not match any known method.
12572    #[non_exhaustive]
12573    _UnknownMethod {
12574        /// Ordinal of the method that was called.
12575        ordinal: u64,
12576        control_handle: SecureMemControlHandle,
12577        method_type: fidl::MethodType,
12578    },
12579}
12580
12581impl SecureMemRequest {
12582    #[allow(irrefutable_let_patterns)]
12583    pub fn into_get_physical_secure_heaps(
12584        self,
12585    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
12586        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
12587            Some((responder))
12588        } else {
12589            None
12590        }
12591    }
12592
12593    #[allow(irrefutable_let_patterns)]
12594    pub fn into_get_dynamic_secure_heaps(
12595        self,
12596    ) -> Option<(SecureMemGetDynamicSecureHeapsResponder)> {
12597        if let SecureMemRequest::GetDynamicSecureHeaps { responder } = self {
12598            Some((responder))
12599        } else {
12600            None
12601        }
12602    }
12603
12604    #[allow(irrefutable_let_patterns)]
12605    pub fn into_get_physical_secure_heap_properties(
12606        self,
12607    ) -> Option<(
12608        SecureMemGetPhysicalSecureHeapPropertiesRequest,
12609        SecureMemGetPhysicalSecureHeapPropertiesResponder,
12610    )> {
12611        if let SecureMemRequest::GetPhysicalSecureHeapProperties { payload, responder } = self {
12612            Some((payload, responder))
12613        } else {
12614            None
12615        }
12616    }
12617
12618    #[allow(irrefutable_let_patterns)]
12619    pub fn into_add_secure_heap_physical_range(
12620        self,
12621    ) -> Option<(
12622        SecureMemAddSecureHeapPhysicalRangeRequest,
12623        SecureMemAddSecureHeapPhysicalRangeResponder,
12624    )> {
12625        if let SecureMemRequest::AddSecureHeapPhysicalRange { payload, responder } = self {
12626            Some((payload, responder))
12627        } else {
12628            None
12629        }
12630    }
12631
12632    #[allow(irrefutable_let_patterns)]
12633    pub fn into_delete_secure_heap_physical_range(
12634        self,
12635    ) -> Option<(
12636        SecureMemDeleteSecureHeapPhysicalRangeRequest,
12637        SecureMemDeleteSecureHeapPhysicalRangeResponder,
12638    )> {
12639        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { payload, responder } = self {
12640            Some((payload, responder))
12641        } else {
12642            None
12643        }
12644    }
12645
12646    #[allow(irrefutable_let_patterns)]
12647    pub fn into_modify_secure_heap_physical_range(
12648        self,
12649    ) -> Option<(
12650        SecureMemModifySecureHeapPhysicalRangeRequest,
12651        SecureMemModifySecureHeapPhysicalRangeResponder,
12652    )> {
12653        if let SecureMemRequest::ModifySecureHeapPhysicalRange { payload, responder } = self {
12654            Some((payload, responder))
12655        } else {
12656            None
12657        }
12658    }
12659
12660    #[allow(irrefutable_let_patterns)]
12661    pub fn into_zero_sub_range(
12662        self,
12663    ) -> Option<(SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResponder)> {
12664        if let SecureMemRequest::ZeroSubRange { payload, responder } = self {
12665            Some((payload, responder))
12666        } else {
12667            None
12668        }
12669    }
12670
12671    /// Name of the method defined in FIDL
12672    pub fn method_name(&self) -> &'static str {
12673        match *self {
12674            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
12675            SecureMemRequest::GetDynamicSecureHeaps { .. } => "get_dynamic_secure_heaps",
12676            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
12677                "get_physical_secure_heap_properties"
12678            }
12679            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
12680            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
12681                "delete_secure_heap_physical_range"
12682            }
12683            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
12684                "modify_secure_heap_physical_range"
12685            }
12686            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
12687            SecureMemRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
12688                "unknown one-way method"
12689            }
12690            SecureMemRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
12691                "unknown two-way method"
12692            }
12693        }
12694    }
12695}
12696
12697#[derive(Debug, Clone)]
12698pub struct SecureMemControlHandle {
12699    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12700}
12701
12702impl fdomain_client::fidl::ControlHandle for SecureMemControlHandle {
12703    fn shutdown(&self) {
12704        self.inner.shutdown()
12705    }
12706
12707    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
12708        self.inner.shutdown_with_epitaph(status)
12709    }
12710
12711    fn is_closed(&self) -> bool {
12712        self.inner.channel().is_closed()
12713    }
12714    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
12715        self.inner.channel().on_closed()
12716    }
12717}
12718
12719impl SecureMemControlHandle {}
12720
12721#[must_use = "FIDL methods require a response to be sent"]
12722#[derive(Debug)]
12723pub struct SecureMemGetPhysicalSecureHeapsResponder {
12724    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12725    tx_id: u32,
12726}
12727
12728/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12729/// if the responder is dropped without sending a response, so that the client
12730/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12731impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
12732    fn drop(&mut self) {
12733        self.control_handle.shutdown();
12734        // Safety: drops once, never accessed again
12735        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12736    }
12737}
12738
12739impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapsResponder {
12740    type ControlHandle = SecureMemControlHandle;
12741
12742    fn control_handle(&self) -> &SecureMemControlHandle {
12743        &self.control_handle
12744    }
12745
12746    fn drop_without_shutdown(mut self) {
12747        // Safety: drops once, never accessed again due to mem::forget
12748        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12749        // Prevent Drop from running (which would shut down the channel)
12750        std::mem::forget(self);
12751    }
12752}
12753
12754impl SecureMemGetPhysicalSecureHeapsResponder {
12755    /// Sends a response to the FIDL transaction.
12756    ///
12757    /// Sets the channel to shutdown if an error occurs.
12758    pub fn send(
12759        self,
12760        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12761    ) -> Result<(), fidl::Error> {
12762        let _result = self.send_raw(result);
12763        if _result.is_err() {
12764            self.control_handle.shutdown();
12765        }
12766        self.drop_without_shutdown();
12767        _result
12768    }
12769
12770    /// Similar to "send" but does not shutdown the channel if an error occurs.
12771    pub fn send_no_shutdown_on_err(
12772        self,
12773        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12774    ) -> Result<(), fidl::Error> {
12775        let _result = self.send_raw(result);
12776        self.drop_without_shutdown();
12777        _result
12778    }
12779
12780    fn send_raw(
12781        &self,
12782        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12783    ) -> Result<(), fidl::Error> {
12784        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12785            SecureMemGetPhysicalSecureHeapsResponse,
12786            Error,
12787        >>(
12788            fidl::encoding::FlexibleResult::new(result),
12789            self.tx_id,
12790            0x38716300592073e3,
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 SecureMemGetDynamicSecureHeapsResponder {
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 SecureMemGetDynamicSecureHeapsResponder {
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 SecureMemGetDynamicSecureHeapsResponder {
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 SecureMemGetDynamicSecureHeapsResponder {
12830    /// Sends a response to the FIDL transaction.
12831    ///
12832    /// Sets the channel to shutdown if an error occurs.
12833    pub fn send(
12834        self,
12835        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12836    ) -> Result<(), fidl::Error> {
12837        let _result = self.send_raw(result);
12838        if _result.is_err() {
12839            self.control_handle.shutdown();
12840        }
12841        self.drop_without_shutdown();
12842        _result
12843    }
12844
12845    /// Similar to "send" but does not shutdown the channel if an error occurs.
12846    pub fn send_no_shutdown_on_err(
12847        self,
12848        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12849    ) -> Result<(), fidl::Error> {
12850        let _result = self.send_raw(result);
12851        self.drop_without_shutdown();
12852        _result
12853    }
12854
12855    fn send_raw(
12856        &self,
12857        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12858    ) -> Result<(), fidl::Error> {
12859        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12860            SecureMemGetDynamicSecureHeapsResponse,
12861            Error,
12862        >>(
12863            fidl::encoding::FlexibleResult::new(result),
12864            self.tx_id,
12865            0x1190847f99952834,
12866            fidl::encoding::DynamicFlags::FLEXIBLE,
12867        )
12868    }
12869}
12870
12871#[must_use = "FIDL methods require a response to be sent"]
12872#[derive(Debug)]
12873pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
12874    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12875    tx_id: u32,
12876}
12877
12878/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12879/// if the responder is dropped without sending a response, so that the client
12880/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12881impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
12882    fn drop(&mut self) {
12883        self.control_handle.shutdown();
12884        // Safety: drops once, never accessed again
12885        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12886    }
12887}
12888
12889impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
12890    type ControlHandle = SecureMemControlHandle;
12891
12892    fn control_handle(&self) -> &SecureMemControlHandle {
12893        &self.control_handle
12894    }
12895
12896    fn drop_without_shutdown(mut self) {
12897        // Safety: drops once, never accessed again due to mem::forget
12898        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12899        // Prevent Drop from running (which would shut down the channel)
12900        std::mem::forget(self);
12901    }
12902}
12903
12904impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
12905    /// Sends a response to the FIDL transaction.
12906    ///
12907    /// Sets the channel to shutdown if an error occurs.
12908    pub fn send(
12909        self,
12910        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12911    ) -> Result<(), fidl::Error> {
12912        let _result = self.send_raw(result);
12913        if _result.is_err() {
12914            self.control_handle.shutdown();
12915        }
12916        self.drop_without_shutdown();
12917        _result
12918    }
12919
12920    /// Similar to "send" but does not shutdown the channel if an error occurs.
12921    pub fn send_no_shutdown_on_err(
12922        self,
12923        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12924    ) -> Result<(), fidl::Error> {
12925        let _result = self.send_raw(result);
12926        self.drop_without_shutdown();
12927        _result
12928    }
12929
12930    fn send_raw(
12931        &self,
12932        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12933    ) -> Result<(), fidl::Error> {
12934        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12935            SecureMemGetPhysicalSecureHeapPropertiesResponse,
12936            Error,
12937        >>(
12938            fidl::encoding::FlexibleResult::new(result),
12939            self.tx_id,
12940            0xc6f06889009c7bc,
12941            fidl::encoding::DynamicFlags::FLEXIBLE,
12942        )
12943    }
12944}
12945
12946#[must_use = "FIDL methods require a response to be sent"]
12947#[derive(Debug)]
12948pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
12949    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12950    tx_id: u32,
12951}
12952
12953/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12954/// if the responder is dropped without sending a response, so that the client
12955/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12956impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
12957    fn drop(&mut self) {
12958        self.control_handle.shutdown();
12959        // Safety: drops once, never accessed again
12960        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12961    }
12962}
12963
12964impl fdomain_client::fidl::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
12965    type ControlHandle = SecureMemControlHandle;
12966
12967    fn control_handle(&self) -> &SecureMemControlHandle {
12968        &self.control_handle
12969    }
12970
12971    fn drop_without_shutdown(mut self) {
12972        // Safety: drops once, never accessed again due to mem::forget
12973        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12974        // Prevent Drop from running (which would shut down the channel)
12975        std::mem::forget(self);
12976    }
12977}
12978
12979impl SecureMemAddSecureHeapPhysicalRangeResponder {
12980    /// Sends a response to the FIDL transaction.
12981    ///
12982    /// Sets the channel to shutdown if an error occurs.
12983    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12984        let _result = self.send_raw(result);
12985        if _result.is_err() {
12986            self.control_handle.shutdown();
12987        }
12988        self.drop_without_shutdown();
12989        _result
12990    }
12991
12992    /// Similar to "send" but does not shutdown the channel if an error occurs.
12993    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
12994        let _result = self.send_raw(result);
12995        self.drop_without_shutdown();
12996        _result
12997    }
12998
12999    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13000        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13001            fidl::encoding::EmptyStruct,
13002            Error,
13003        >>(
13004            fidl::encoding::FlexibleResult::new(result),
13005            self.tx_id,
13006            0x35f695b9b6c7217a,
13007            fidl::encoding::DynamicFlags::FLEXIBLE,
13008        )
13009    }
13010}
13011
13012#[must_use = "FIDL methods require a response to be sent"]
13013#[derive(Debug)]
13014pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
13015    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
13016    tx_id: u32,
13017}
13018
13019/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
13020/// if the responder is dropped without sending a response, so that the client
13021/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13022impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
13023    fn drop(&mut self) {
13024        self.control_handle.shutdown();
13025        // Safety: drops once, never accessed again
13026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13027    }
13028}
13029
13030impl fdomain_client::fidl::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
13031    type ControlHandle = SecureMemControlHandle;
13032
13033    fn control_handle(&self) -> &SecureMemControlHandle {
13034        &self.control_handle
13035    }
13036
13037    fn drop_without_shutdown(mut self) {
13038        // Safety: drops once, never accessed again due to mem::forget
13039        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13040        // Prevent Drop from running (which would shut down the channel)
13041        std::mem::forget(self);
13042    }
13043}
13044
13045impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
13046    /// Sends a response to the FIDL transaction.
13047    ///
13048    /// Sets the channel to shutdown if an error occurs.
13049    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13050        let _result = self.send_raw(result);
13051        if _result.is_err() {
13052            self.control_handle.shutdown();
13053        }
13054        self.drop_without_shutdown();
13055        _result
13056    }
13057
13058    /// Similar to "send" but does not shutdown the channel if an error occurs.
13059    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13060        let _result = self.send_raw(result);
13061        self.drop_without_shutdown();
13062        _result
13063    }
13064
13065    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13066        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13067            fidl::encoding::EmptyStruct,
13068            Error,
13069        >>(
13070            fidl::encoding::FlexibleResult::new(result),
13071            self.tx_id,
13072            0xeaa58c650264c9e,
13073            fidl::encoding::DynamicFlags::FLEXIBLE,
13074        )
13075    }
13076}
13077
13078#[must_use = "FIDL methods require a response to be sent"]
13079#[derive(Debug)]
13080pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
13081    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
13082    tx_id: u32,
13083}
13084
13085/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
13086/// if the responder is dropped without sending a response, so that the client
13087/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13088impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
13089    fn drop(&mut self) {
13090        self.control_handle.shutdown();
13091        // Safety: drops once, never accessed again
13092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13093    }
13094}
13095
13096impl fdomain_client::fidl::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
13097    type ControlHandle = SecureMemControlHandle;
13098
13099    fn control_handle(&self) -> &SecureMemControlHandle {
13100        &self.control_handle
13101    }
13102
13103    fn drop_without_shutdown(mut self) {
13104        // Safety: drops once, never accessed again due to mem::forget
13105        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13106        // Prevent Drop from running (which would shut down the channel)
13107        std::mem::forget(self);
13108    }
13109}
13110
13111impl SecureMemModifySecureHeapPhysicalRangeResponder {
13112    /// Sends a response to the FIDL transaction.
13113    ///
13114    /// Sets the channel to shutdown if an error occurs.
13115    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13116        let _result = self.send_raw(result);
13117        if _result.is_err() {
13118            self.control_handle.shutdown();
13119        }
13120        self.drop_without_shutdown();
13121        _result
13122    }
13123
13124    /// Similar to "send" but does not shutdown the channel if an error occurs.
13125    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13126        let _result = self.send_raw(result);
13127        self.drop_without_shutdown();
13128        _result
13129    }
13130
13131    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13132        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13133            fidl::encoding::EmptyStruct,
13134            Error,
13135        >>(
13136            fidl::encoding::FlexibleResult::new(result),
13137            self.tx_id,
13138            0x60b7448aa1187734,
13139            fidl::encoding::DynamicFlags::FLEXIBLE,
13140        )
13141    }
13142}
13143
13144#[must_use = "FIDL methods require a response to be sent"]
13145#[derive(Debug)]
13146pub struct SecureMemZeroSubRangeResponder {
13147    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
13148    tx_id: u32,
13149}
13150
13151/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
13152/// if the responder is dropped without sending a response, so that the client
13153/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13154impl std::ops::Drop for SecureMemZeroSubRangeResponder {
13155    fn drop(&mut self) {
13156        self.control_handle.shutdown();
13157        // Safety: drops once, never accessed again
13158        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13159    }
13160}
13161
13162impl fdomain_client::fidl::Responder for SecureMemZeroSubRangeResponder {
13163    type ControlHandle = SecureMemControlHandle;
13164
13165    fn control_handle(&self) -> &SecureMemControlHandle {
13166        &self.control_handle
13167    }
13168
13169    fn drop_without_shutdown(mut self) {
13170        // Safety: drops once, never accessed again due to mem::forget
13171        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13172        // Prevent Drop from running (which would shut down the channel)
13173        std::mem::forget(self);
13174    }
13175}
13176
13177impl SecureMemZeroSubRangeResponder {
13178    /// Sends a response to the FIDL transaction.
13179    ///
13180    /// Sets the channel to shutdown if an error occurs.
13181    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13182        let _result = self.send_raw(result);
13183        if _result.is_err() {
13184            self.control_handle.shutdown();
13185        }
13186        self.drop_without_shutdown();
13187        _result
13188    }
13189
13190    /// Similar to "send" but does not shutdown the channel if an error occurs.
13191    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13192        let _result = self.send_raw(result);
13193        self.drop_without_shutdown();
13194        _result
13195    }
13196
13197    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13198        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13199            fidl::encoding::EmptyStruct,
13200            Error,
13201        >>(
13202            fidl::encoding::FlexibleResult::new(result),
13203            self.tx_id,
13204            0x5b25b7901a385ce5,
13205            fidl::encoding::DynamicFlags::FLEXIBLE,
13206        )
13207    }
13208}
13209
13210mod internal {
13211    use super::*;
13212
13213    impl AllocatorAllocateNonSharedCollectionRequest {
13214        #[inline(always)]
13215        fn max_ordinal_present(&self) -> u64 {
13216            if let Some(_) = self.collection_request {
13217                return 1;
13218            }
13219            0
13220        }
13221    }
13222
13223    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
13224        type Borrowed<'a> = &'a mut Self;
13225        fn take_or_borrow<'a>(
13226            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13227        ) -> Self::Borrowed<'a> {
13228            value
13229        }
13230    }
13231
13232    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
13233        type Owned = Self;
13234
13235        #[inline(always)]
13236        fn inline_align(_context: fidl::encoding::Context) -> usize {
13237            8
13238        }
13239
13240        #[inline(always)]
13241        fn inline_size(_context: fidl::encoding::Context) -> usize {
13242            16
13243        }
13244    }
13245
13246    unsafe impl
13247        fidl::encoding::Encode<
13248            AllocatorAllocateNonSharedCollectionRequest,
13249            fdomain_client::fidl::FDomainResourceDialect,
13250        > for &mut AllocatorAllocateNonSharedCollectionRequest
13251    {
13252        unsafe fn encode(
13253            self,
13254            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13255            offset: usize,
13256            mut depth: fidl::encoding::Depth,
13257        ) -> fidl::Result<()> {
13258            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
13259            // Vector header
13260            let max_ordinal: u64 = self.max_ordinal_present();
13261            encoder.write_num(max_ordinal, offset);
13262            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13263            // Calling encoder.out_of_line_offset(0) is not allowed.
13264            if max_ordinal == 0 {
13265                return Ok(());
13266            }
13267            depth.increment()?;
13268            let envelope_size = 8;
13269            let bytes_len = max_ordinal as usize * envelope_size;
13270            #[allow(unused_variables)]
13271            let offset = encoder.out_of_line_offset(bytes_len);
13272            let mut _prev_end_offset: usize = 0;
13273            if 1 > max_ordinal {
13274                return Ok(());
13275            }
13276
13277            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13278            // are envelope_size bytes.
13279            let cur_offset: usize = (1 - 1) * envelope_size;
13280
13281            // Zero reserved fields.
13282            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13283
13284            // Safety:
13285            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13286            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13287            //   envelope_size bytes, there is always sufficient room.
13288            fidl::encoding::encode_in_envelope_optional::<
13289                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
13290                fdomain_client::fidl::FDomainResourceDialect,
13291            >(
13292                self.collection_request.as_mut().map(
13293                    <fidl::encoding::Endpoint<
13294                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13295                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13296                ),
13297                encoder,
13298                offset + cur_offset,
13299                depth,
13300            )?;
13301
13302            _prev_end_offset = cur_offset + envelope_size;
13303
13304            Ok(())
13305        }
13306    }
13307
13308    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13309        for AllocatorAllocateNonSharedCollectionRequest
13310    {
13311        #[inline(always)]
13312        fn new_empty() -> Self {
13313            Self::default()
13314        }
13315
13316        unsafe fn decode(
13317            &mut self,
13318            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13319            offset: usize,
13320            mut depth: fidl::encoding::Depth,
13321        ) -> fidl::Result<()> {
13322            decoder.debug_check_bounds::<Self>(offset);
13323            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13324                None => return Err(fidl::Error::NotNullable),
13325                Some(len) => len,
13326            };
13327            // Calling decoder.out_of_line_offset(0) is not allowed.
13328            if len == 0 {
13329                return Ok(());
13330            };
13331            depth.increment()?;
13332            let envelope_size = 8;
13333            let bytes_len = len * envelope_size;
13334            let offset = decoder.out_of_line_offset(bytes_len)?;
13335            // Decode the envelope for each type.
13336            let mut _next_ordinal_to_read = 0;
13337            let mut next_offset = offset;
13338            let end_offset = offset + bytes_len;
13339            _next_ordinal_to_read += 1;
13340            if next_offset >= end_offset {
13341                return Ok(());
13342            }
13343
13344            // Decode unknown envelopes for gaps in ordinals.
13345            while _next_ordinal_to_read < 1 {
13346                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13347                _next_ordinal_to_read += 1;
13348                next_offset += envelope_size;
13349            }
13350
13351            let next_out_of_line = decoder.next_out_of_line();
13352            let handles_before = decoder.remaining_handles();
13353            if let Some((inlined, num_bytes, num_handles)) =
13354                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13355            {
13356                let member_inline_size = <fidl::encoding::Endpoint<
13357                    fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13358                > as fidl::encoding::TypeMarker>::inline_size(
13359                    decoder.context
13360                );
13361                if inlined != (member_inline_size <= 4) {
13362                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13363                }
13364                let inner_offset;
13365                let mut inner_depth = depth.clone();
13366                if inlined {
13367                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13368                    inner_offset = next_offset;
13369                } else {
13370                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13371                    inner_depth.increment()?;
13372                }
13373                let val_ref = self.collection_request.get_or_insert_with(|| {
13374                    fidl::new_empty!(
13375                        fidl::encoding::Endpoint<
13376                            fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13377                        >,
13378                        fdomain_client::fidl::FDomainResourceDialect
13379                    )
13380                });
13381                fidl::decode!(
13382                    fidl::encoding::Endpoint<
13383                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13384                    >,
13385                    fdomain_client::fidl::FDomainResourceDialect,
13386                    val_ref,
13387                    decoder,
13388                    inner_offset,
13389                    inner_depth
13390                )?;
13391                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13392                {
13393                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13394                }
13395                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13396                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13397                }
13398            }
13399
13400            next_offset += envelope_size;
13401
13402            // Decode the remaining unknown envelopes.
13403            while next_offset < end_offset {
13404                _next_ordinal_to_read += 1;
13405                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13406                next_offset += envelope_size;
13407            }
13408
13409            Ok(())
13410        }
13411    }
13412
13413    impl AllocatorAllocateSharedCollectionRequest {
13414        #[inline(always)]
13415        fn max_ordinal_present(&self) -> u64 {
13416            if let Some(_) = self.token_request {
13417                return 1;
13418            }
13419            0
13420        }
13421    }
13422
13423    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
13424        type Borrowed<'a> = &'a mut Self;
13425        fn take_or_borrow<'a>(
13426            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13427        ) -> Self::Borrowed<'a> {
13428            value
13429        }
13430    }
13431
13432    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
13433        type Owned = Self;
13434
13435        #[inline(always)]
13436        fn inline_align(_context: fidl::encoding::Context) -> usize {
13437            8
13438        }
13439
13440        #[inline(always)]
13441        fn inline_size(_context: fidl::encoding::Context) -> usize {
13442            16
13443        }
13444    }
13445
13446    unsafe impl
13447        fidl::encoding::Encode<
13448            AllocatorAllocateSharedCollectionRequest,
13449            fdomain_client::fidl::FDomainResourceDialect,
13450        > for &mut AllocatorAllocateSharedCollectionRequest
13451    {
13452        unsafe fn encode(
13453            self,
13454            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13455            offset: usize,
13456            mut depth: fidl::encoding::Depth,
13457        ) -> fidl::Result<()> {
13458            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
13459            // Vector header
13460            let max_ordinal: u64 = self.max_ordinal_present();
13461            encoder.write_num(max_ordinal, offset);
13462            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13463            // Calling encoder.out_of_line_offset(0) is not allowed.
13464            if max_ordinal == 0 {
13465                return Ok(());
13466            }
13467            depth.increment()?;
13468            let envelope_size = 8;
13469            let bytes_len = max_ordinal as usize * envelope_size;
13470            #[allow(unused_variables)]
13471            let offset = encoder.out_of_line_offset(bytes_len);
13472            let mut _prev_end_offset: usize = 0;
13473            if 1 > max_ordinal {
13474                return Ok(());
13475            }
13476
13477            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13478            // are envelope_size bytes.
13479            let cur_offset: usize = (1 - 1) * envelope_size;
13480
13481            // Zero reserved fields.
13482            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13483
13484            // Safety:
13485            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13486            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13487            //   envelope_size bytes, there is always sufficient room.
13488            fidl::encoding::encode_in_envelope_optional::<
13489                fidl::encoding::Endpoint<
13490                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13491                >,
13492                fdomain_client::fidl::FDomainResourceDialect,
13493            >(
13494                self.token_request.as_mut().map(
13495                    <fidl::encoding::Endpoint<
13496                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13497                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13498                ),
13499                encoder,
13500                offset + cur_offset,
13501                depth,
13502            )?;
13503
13504            _prev_end_offset = cur_offset + envelope_size;
13505
13506            Ok(())
13507        }
13508    }
13509
13510    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13511        for AllocatorAllocateSharedCollectionRequest
13512    {
13513        #[inline(always)]
13514        fn new_empty() -> Self {
13515            Self::default()
13516        }
13517
13518        unsafe fn decode(
13519            &mut self,
13520            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13521            offset: usize,
13522            mut depth: fidl::encoding::Depth,
13523        ) -> fidl::Result<()> {
13524            decoder.debug_check_bounds::<Self>(offset);
13525            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13526                None => return Err(fidl::Error::NotNullable),
13527                Some(len) => len,
13528            };
13529            // Calling decoder.out_of_line_offset(0) is not allowed.
13530            if len == 0 {
13531                return Ok(());
13532            };
13533            depth.increment()?;
13534            let envelope_size = 8;
13535            let bytes_len = len * envelope_size;
13536            let offset = decoder.out_of_line_offset(bytes_len)?;
13537            // Decode the envelope for each type.
13538            let mut _next_ordinal_to_read = 0;
13539            let mut next_offset = offset;
13540            let end_offset = offset + bytes_len;
13541            _next_ordinal_to_read += 1;
13542            if next_offset >= end_offset {
13543                return Ok(());
13544            }
13545
13546            // Decode unknown envelopes for gaps in ordinals.
13547            while _next_ordinal_to_read < 1 {
13548                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13549                _next_ordinal_to_read += 1;
13550                next_offset += envelope_size;
13551            }
13552
13553            let next_out_of_line = decoder.next_out_of_line();
13554            let handles_before = decoder.remaining_handles();
13555            if let Some((inlined, num_bytes, num_handles)) =
13556                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13557            {
13558                let member_inline_size = <fidl::encoding::Endpoint<
13559                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13560                > as fidl::encoding::TypeMarker>::inline_size(
13561                    decoder.context
13562                );
13563                if inlined != (member_inline_size <= 4) {
13564                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13565                }
13566                let inner_offset;
13567                let mut inner_depth = depth.clone();
13568                if inlined {
13569                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13570                    inner_offset = next_offset;
13571                } else {
13572                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13573                    inner_depth.increment()?;
13574                }
13575                let val_ref = self.token_request.get_or_insert_with(|| {
13576                    fidl::new_empty!(
13577                        fidl::encoding::Endpoint<
13578                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13579                        >,
13580                        fdomain_client::fidl::FDomainResourceDialect
13581                    )
13582                });
13583                fidl::decode!(
13584                    fidl::encoding::Endpoint<
13585                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13586                    >,
13587                    fdomain_client::fidl::FDomainResourceDialect,
13588                    val_ref,
13589                    decoder,
13590                    inner_offset,
13591                    inner_depth
13592                )?;
13593                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13594                {
13595                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13596                }
13597                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13598                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13599                }
13600            }
13601
13602            next_offset += envelope_size;
13603
13604            // Decode the remaining unknown envelopes.
13605            while next_offset < end_offset {
13606                _next_ordinal_to_read += 1;
13607                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13608                next_offset += envelope_size;
13609            }
13610
13611            Ok(())
13612        }
13613    }
13614
13615    impl AllocatorBindSharedCollectionRequest {
13616        #[inline(always)]
13617        fn max_ordinal_present(&self) -> u64 {
13618            if let Some(_) = self.buffer_collection_request {
13619                return 2;
13620            }
13621            if let Some(_) = self.token {
13622                return 1;
13623            }
13624            0
13625        }
13626    }
13627
13628    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
13629        type Borrowed<'a> = &'a mut Self;
13630        fn take_or_borrow<'a>(
13631            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13632        ) -> Self::Borrowed<'a> {
13633            value
13634        }
13635    }
13636
13637    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
13638        type Owned = Self;
13639
13640        #[inline(always)]
13641        fn inline_align(_context: fidl::encoding::Context) -> usize {
13642            8
13643        }
13644
13645        #[inline(always)]
13646        fn inline_size(_context: fidl::encoding::Context) -> usize {
13647            16
13648        }
13649    }
13650
13651    unsafe impl
13652        fidl::encoding::Encode<
13653            AllocatorBindSharedCollectionRequest,
13654            fdomain_client::fidl::FDomainResourceDialect,
13655        > for &mut AllocatorBindSharedCollectionRequest
13656    {
13657        unsafe fn encode(
13658            self,
13659            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13660            offset: usize,
13661            mut depth: fidl::encoding::Depth,
13662        ) -> fidl::Result<()> {
13663            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
13664            // Vector header
13665            let max_ordinal: u64 = self.max_ordinal_present();
13666            encoder.write_num(max_ordinal, offset);
13667            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13668            // Calling encoder.out_of_line_offset(0) is not allowed.
13669            if max_ordinal == 0 {
13670                return Ok(());
13671            }
13672            depth.increment()?;
13673            let envelope_size = 8;
13674            let bytes_len = max_ordinal as usize * envelope_size;
13675            #[allow(unused_variables)]
13676            let offset = encoder.out_of_line_offset(bytes_len);
13677            let mut _prev_end_offset: usize = 0;
13678            if 1 > max_ordinal {
13679                return Ok(());
13680            }
13681
13682            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13683            // are envelope_size bytes.
13684            let cur_offset: usize = (1 - 1) * envelope_size;
13685
13686            // Zero reserved fields.
13687            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13688
13689            // Safety:
13690            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13691            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13692            //   envelope_size bytes, there is always sufficient room.
13693            fidl::encoding::encode_in_envelope_optional::<
13694                fidl::encoding::Endpoint<
13695                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13696                >,
13697                fdomain_client::fidl::FDomainResourceDialect,
13698            >(
13699                self.token.as_mut().map(
13700                    <fidl::encoding::Endpoint<
13701                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13702                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13703                ),
13704                encoder,
13705                offset + cur_offset,
13706                depth,
13707            )?;
13708
13709            _prev_end_offset = cur_offset + envelope_size;
13710            if 2 > max_ordinal {
13711                return Ok(());
13712            }
13713
13714            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13715            // are envelope_size bytes.
13716            let cur_offset: usize = (2 - 1) * envelope_size;
13717
13718            // Zero reserved fields.
13719            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13720
13721            // Safety:
13722            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13723            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13724            //   envelope_size bytes, there is always sufficient room.
13725            fidl::encoding::encode_in_envelope_optional::<
13726                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
13727                fdomain_client::fidl::FDomainResourceDialect,
13728            >(
13729                self.buffer_collection_request.as_mut().map(
13730                    <fidl::encoding::Endpoint<
13731                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13732                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13733                ),
13734                encoder,
13735                offset + cur_offset,
13736                depth,
13737            )?;
13738
13739            _prev_end_offset = cur_offset + envelope_size;
13740
13741            Ok(())
13742        }
13743    }
13744
13745    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13746        for AllocatorBindSharedCollectionRequest
13747    {
13748        #[inline(always)]
13749        fn new_empty() -> Self {
13750            Self::default()
13751        }
13752
13753        unsafe fn decode(
13754            &mut self,
13755            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13756            offset: usize,
13757            mut depth: fidl::encoding::Depth,
13758        ) -> fidl::Result<()> {
13759            decoder.debug_check_bounds::<Self>(offset);
13760            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13761                None => return Err(fidl::Error::NotNullable),
13762                Some(len) => len,
13763            };
13764            // Calling decoder.out_of_line_offset(0) is not allowed.
13765            if len == 0 {
13766                return Ok(());
13767            };
13768            depth.increment()?;
13769            let envelope_size = 8;
13770            let bytes_len = len * envelope_size;
13771            let offset = decoder.out_of_line_offset(bytes_len)?;
13772            // Decode the envelope for each type.
13773            let mut _next_ordinal_to_read = 0;
13774            let mut next_offset = offset;
13775            let end_offset = offset + bytes_len;
13776            _next_ordinal_to_read += 1;
13777            if next_offset >= end_offset {
13778                return Ok(());
13779            }
13780
13781            // Decode unknown envelopes for gaps in ordinals.
13782            while _next_ordinal_to_read < 1 {
13783                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13784                _next_ordinal_to_read += 1;
13785                next_offset += envelope_size;
13786            }
13787
13788            let next_out_of_line = decoder.next_out_of_line();
13789            let handles_before = decoder.remaining_handles();
13790            if let Some((inlined, num_bytes, num_handles)) =
13791                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13792            {
13793                let member_inline_size = <fidl::encoding::Endpoint<
13794                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13795                > as fidl::encoding::TypeMarker>::inline_size(
13796                    decoder.context
13797                );
13798                if inlined != (member_inline_size <= 4) {
13799                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13800                }
13801                let inner_offset;
13802                let mut inner_depth = depth.clone();
13803                if inlined {
13804                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13805                    inner_offset = next_offset;
13806                } else {
13807                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13808                    inner_depth.increment()?;
13809                }
13810                let val_ref = self.token.get_or_insert_with(|| {
13811                    fidl::new_empty!(
13812                        fidl::encoding::Endpoint<
13813                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13814                        >,
13815                        fdomain_client::fidl::FDomainResourceDialect
13816                    )
13817                });
13818                fidl::decode!(
13819                    fidl::encoding::Endpoint<
13820                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13821                    >,
13822                    fdomain_client::fidl::FDomainResourceDialect,
13823                    val_ref,
13824                    decoder,
13825                    inner_offset,
13826                    inner_depth
13827                )?;
13828                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13829                {
13830                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13831                }
13832                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13833                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13834                }
13835            }
13836
13837            next_offset += envelope_size;
13838            _next_ordinal_to_read += 1;
13839            if next_offset >= end_offset {
13840                return Ok(());
13841            }
13842
13843            // Decode unknown envelopes for gaps in ordinals.
13844            while _next_ordinal_to_read < 2 {
13845                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13846                _next_ordinal_to_read += 1;
13847                next_offset += envelope_size;
13848            }
13849
13850            let next_out_of_line = decoder.next_out_of_line();
13851            let handles_before = decoder.remaining_handles();
13852            if let Some((inlined, num_bytes, num_handles)) =
13853                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13854            {
13855                let member_inline_size = <fidl::encoding::Endpoint<
13856                    fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13857                > as fidl::encoding::TypeMarker>::inline_size(
13858                    decoder.context
13859                );
13860                if inlined != (member_inline_size <= 4) {
13861                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13862                }
13863                let inner_offset;
13864                let mut inner_depth = depth.clone();
13865                if inlined {
13866                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13867                    inner_offset = next_offset;
13868                } else {
13869                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13870                    inner_depth.increment()?;
13871                }
13872                let val_ref = self.buffer_collection_request.get_or_insert_with(|| {
13873                    fidl::new_empty!(
13874                        fidl::encoding::Endpoint<
13875                            fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13876                        >,
13877                        fdomain_client::fidl::FDomainResourceDialect
13878                    )
13879                });
13880                fidl::decode!(
13881                    fidl::encoding::Endpoint<
13882                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13883                    >,
13884                    fdomain_client::fidl::FDomainResourceDialect,
13885                    val_ref,
13886                    decoder,
13887                    inner_offset,
13888                    inner_depth
13889                )?;
13890                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13891                {
13892                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13893                }
13894                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13895                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13896                }
13897            }
13898
13899            next_offset += envelope_size;
13900
13901            // Decode the remaining unknown envelopes.
13902            while next_offset < end_offset {
13903                _next_ordinal_to_read += 1;
13904                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13905                next_offset += envelope_size;
13906            }
13907
13908            Ok(())
13909        }
13910    }
13911
13912    impl AllocatorGetVmoInfoRequest {
13913        #[inline(always)]
13914        fn max_ordinal_present(&self) -> u64 {
13915            if let Some(_) = self.vmo_settings_to_check_ignore_size {
13916                return 6;
13917            }
13918            if let Some(_) = self.vmo_settings_to_check {
13919                return 5;
13920            }
13921            if let Some(_) = self.constraints_to_check {
13922                return 4;
13923            }
13924            if let Some(_) = self.need_single_buffer_settings {
13925                return 3;
13926            }
13927            if let Some(_) = self.need_weak {
13928                return 2;
13929            }
13930            if let Some(_) = self.vmo {
13931                return 1;
13932            }
13933            0
13934        }
13935    }
13936
13937    impl fidl::encoding::ResourceTypeMarker for AllocatorGetVmoInfoRequest {
13938        type Borrowed<'a> = &'a mut Self;
13939        fn take_or_borrow<'a>(
13940            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13941        ) -> Self::Borrowed<'a> {
13942            value
13943        }
13944    }
13945
13946    unsafe impl fidl::encoding::TypeMarker for AllocatorGetVmoInfoRequest {
13947        type Owned = Self;
13948
13949        #[inline(always)]
13950        fn inline_align(_context: fidl::encoding::Context) -> usize {
13951            8
13952        }
13953
13954        #[inline(always)]
13955        fn inline_size(_context: fidl::encoding::Context) -> usize {
13956            16
13957        }
13958    }
13959
13960    unsafe impl
13961        fidl::encoding::Encode<
13962            AllocatorGetVmoInfoRequest,
13963            fdomain_client::fidl::FDomainResourceDialect,
13964        > for &mut AllocatorGetVmoInfoRequest
13965    {
13966        unsafe fn encode(
13967            self,
13968            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13969            offset: usize,
13970            mut depth: fidl::encoding::Depth,
13971        ) -> fidl::Result<()> {
13972            encoder.debug_check_bounds::<AllocatorGetVmoInfoRequest>(offset);
13973            // Vector header
13974            let max_ordinal: u64 = self.max_ordinal_present();
13975            encoder.write_num(max_ordinal, offset);
13976            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13977            // Calling encoder.out_of_line_offset(0) is not allowed.
13978            if max_ordinal == 0 {
13979                return Ok(());
13980            }
13981            depth.increment()?;
13982            let envelope_size = 8;
13983            let bytes_len = max_ordinal as usize * envelope_size;
13984            #[allow(unused_variables)]
13985            let offset = encoder.out_of_line_offset(bytes_len);
13986            let mut _prev_end_offset: usize = 0;
13987            if 1 > max_ordinal {
13988                return Ok(());
13989            }
13990
13991            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13992            // are envelope_size bytes.
13993            let cur_offset: usize = (1 - 1) * envelope_size;
13994
13995            // Zero reserved fields.
13996            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13997
13998            // Safety:
13999            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14000            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14001            //   envelope_size bytes, there is always sufficient room.
14002            fidl::encoding::encode_in_envelope_optional::<
14003                fidl::encoding::HandleType<
14004                    fdomain_client::Vmo,
14005                    { fidl::ObjectType::VMO.into_raw() },
14006                    2147483648,
14007                >,
14008                fdomain_client::fidl::FDomainResourceDialect,
14009            >(
14010                self.vmo.as_mut().map(
14011                    <fidl::encoding::HandleType<
14012                        fdomain_client::Vmo,
14013                        { fidl::ObjectType::VMO.into_raw() },
14014                        2147483648,
14015                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14016                ),
14017                encoder,
14018                offset + cur_offset,
14019                depth,
14020            )?;
14021
14022            _prev_end_offset = cur_offset + envelope_size;
14023            if 2 > max_ordinal {
14024                return Ok(());
14025            }
14026
14027            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14028            // are envelope_size bytes.
14029            let cur_offset: usize = (2 - 1) * envelope_size;
14030
14031            // Zero reserved fields.
14032            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14033
14034            // Safety:
14035            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14036            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14037            //   envelope_size bytes, there is always sufficient room.
14038            fidl::encoding::encode_in_envelope_optional::<
14039                bool,
14040                fdomain_client::fidl::FDomainResourceDialect,
14041            >(
14042                self.need_weak.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14043                encoder,
14044                offset + cur_offset,
14045                depth,
14046            )?;
14047
14048            _prev_end_offset = cur_offset + envelope_size;
14049            if 3 > max_ordinal {
14050                return Ok(());
14051            }
14052
14053            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14054            // are envelope_size bytes.
14055            let cur_offset: usize = (3 - 1) * envelope_size;
14056
14057            // Zero reserved fields.
14058            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14059
14060            // Safety:
14061            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14062            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14063            //   envelope_size bytes, there is always sufficient room.
14064            fidl::encoding::encode_in_envelope_optional::<
14065                bool,
14066                fdomain_client::fidl::FDomainResourceDialect,
14067            >(
14068                self.need_single_buffer_settings
14069                    .as_ref()
14070                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14071                encoder,
14072                offset + cur_offset,
14073                depth,
14074            )?;
14075
14076            _prev_end_offset = cur_offset + envelope_size;
14077            if 4 > max_ordinal {
14078                return Ok(());
14079            }
14080
14081            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14082            // are envelope_size bytes.
14083            let cur_offset: usize = (4 - 1) * envelope_size;
14084
14085            // Zero reserved fields.
14086            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14087
14088            // Safety:
14089            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14090            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14091            //   envelope_size bytes, there is always sufficient room.
14092            fidl::encoding::encode_in_envelope_optional::<
14093                BufferCollectionConstraints,
14094                fdomain_client::fidl::FDomainResourceDialect,
14095            >(
14096                self.constraints_to_check
14097                    .as_ref()
14098                    .map(<BufferCollectionConstraints as fidl::encoding::ValueTypeMarker>::borrow),
14099                encoder,
14100                offset + cur_offset,
14101                depth,
14102            )?;
14103
14104            _prev_end_offset = cur_offset + envelope_size;
14105            if 5 > max_ordinal {
14106                return Ok(());
14107            }
14108
14109            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14110            // are envelope_size bytes.
14111            let cur_offset: usize = (5 - 1) * envelope_size;
14112
14113            // Zero reserved fields.
14114            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14115
14116            // Safety:
14117            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14118            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14119            //   envelope_size bytes, there is always sufficient room.
14120            fidl::encoding::encode_in_envelope_optional::<
14121                fidl::encoding::HandleType<
14122                    fdomain_client::Vmo,
14123                    { fidl::ObjectType::VMO.into_raw() },
14124                    2147483648,
14125                >,
14126                fdomain_client::fidl::FDomainResourceDialect,
14127            >(
14128                self.vmo_settings_to_check.as_mut().map(
14129                    <fidl::encoding::HandleType<
14130                        fdomain_client::Vmo,
14131                        { fidl::ObjectType::VMO.into_raw() },
14132                        2147483648,
14133                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14134                ),
14135                encoder,
14136                offset + cur_offset,
14137                depth,
14138            )?;
14139
14140            _prev_end_offset = cur_offset + envelope_size;
14141            if 6 > max_ordinal {
14142                return Ok(());
14143            }
14144
14145            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14146            // are envelope_size bytes.
14147            let cur_offset: usize = (6 - 1) * envelope_size;
14148
14149            // Zero reserved fields.
14150            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14151
14152            // Safety:
14153            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14154            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14155            //   envelope_size bytes, there is always sufficient room.
14156            fidl::encoding::encode_in_envelope_optional::<
14157                bool,
14158                fdomain_client::fidl::FDomainResourceDialect,
14159            >(
14160                self.vmo_settings_to_check_ignore_size
14161                    .as_ref()
14162                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14163                encoder,
14164                offset + cur_offset,
14165                depth,
14166            )?;
14167
14168            _prev_end_offset = cur_offset + envelope_size;
14169
14170            Ok(())
14171        }
14172    }
14173
14174    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14175        for AllocatorGetVmoInfoRequest
14176    {
14177        #[inline(always)]
14178        fn new_empty() -> Self {
14179            Self::default()
14180        }
14181
14182        unsafe fn decode(
14183            &mut self,
14184            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14185            offset: usize,
14186            mut depth: fidl::encoding::Depth,
14187        ) -> fidl::Result<()> {
14188            decoder.debug_check_bounds::<Self>(offset);
14189            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14190                None => return Err(fidl::Error::NotNullable),
14191                Some(len) => len,
14192            };
14193            // Calling decoder.out_of_line_offset(0) is not allowed.
14194            if len == 0 {
14195                return Ok(());
14196            };
14197            depth.increment()?;
14198            let envelope_size = 8;
14199            let bytes_len = len * envelope_size;
14200            let offset = decoder.out_of_line_offset(bytes_len)?;
14201            // Decode the envelope for each type.
14202            let mut _next_ordinal_to_read = 0;
14203            let mut next_offset = offset;
14204            let end_offset = offset + bytes_len;
14205            _next_ordinal_to_read += 1;
14206            if next_offset >= end_offset {
14207                return Ok(());
14208            }
14209
14210            // Decode unknown envelopes for gaps in ordinals.
14211            while _next_ordinal_to_read < 1 {
14212                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14213                _next_ordinal_to_read += 1;
14214                next_offset += envelope_size;
14215            }
14216
14217            let next_out_of_line = decoder.next_out_of_line();
14218            let handles_before = decoder.remaining_handles();
14219            if let Some((inlined, num_bytes, num_handles)) =
14220                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14221            {
14222                let member_inline_size = <fidl::encoding::HandleType<
14223                    fdomain_client::Vmo,
14224                    { fidl::ObjectType::VMO.into_raw() },
14225                    2147483648,
14226                > as fidl::encoding::TypeMarker>::inline_size(
14227                    decoder.context
14228                );
14229                if inlined != (member_inline_size <= 4) {
14230                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14231                }
14232                let inner_offset;
14233                let mut inner_depth = depth.clone();
14234                if inlined {
14235                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14236                    inner_offset = next_offset;
14237                } else {
14238                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14239                    inner_depth.increment()?;
14240                }
14241                let val_ref =
14242                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));
14243                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)?;
14244                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14245                {
14246                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14247                }
14248                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14249                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14250                }
14251            }
14252
14253            next_offset += envelope_size;
14254            _next_ordinal_to_read += 1;
14255            if next_offset >= end_offset {
14256                return Ok(());
14257            }
14258
14259            // Decode unknown envelopes for gaps in ordinals.
14260            while _next_ordinal_to_read < 2 {
14261                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14262                _next_ordinal_to_read += 1;
14263                next_offset += envelope_size;
14264            }
14265
14266            let next_out_of_line = decoder.next_out_of_line();
14267            let handles_before = decoder.remaining_handles();
14268            if let Some((inlined, num_bytes, num_handles)) =
14269                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14270            {
14271                let member_inline_size =
14272                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14273                if inlined != (member_inline_size <= 4) {
14274                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14275                }
14276                let inner_offset;
14277                let mut inner_depth = depth.clone();
14278                if inlined {
14279                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14280                    inner_offset = next_offset;
14281                } else {
14282                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14283                    inner_depth.increment()?;
14284                }
14285                let val_ref = self.need_weak.get_or_insert_with(|| {
14286                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
14287                });
14288                fidl::decode!(
14289                    bool,
14290                    fdomain_client::fidl::FDomainResourceDialect,
14291                    val_ref,
14292                    decoder,
14293                    inner_offset,
14294                    inner_depth
14295                )?;
14296                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14297                {
14298                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14299                }
14300                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14301                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14302                }
14303            }
14304
14305            next_offset += envelope_size;
14306            _next_ordinal_to_read += 1;
14307            if next_offset >= end_offset {
14308                return Ok(());
14309            }
14310
14311            // Decode unknown envelopes for gaps in ordinals.
14312            while _next_ordinal_to_read < 3 {
14313                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14314                _next_ordinal_to_read += 1;
14315                next_offset += envelope_size;
14316            }
14317
14318            let next_out_of_line = decoder.next_out_of_line();
14319            let handles_before = decoder.remaining_handles();
14320            if let Some((inlined, num_bytes, num_handles)) =
14321                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14322            {
14323                let member_inline_size =
14324                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14325                if inlined != (member_inline_size <= 4) {
14326                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14327                }
14328                let inner_offset;
14329                let mut inner_depth = depth.clone();
14330                if inlined {
14331                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14332                    inner_offset = next_offset;
14333                } else {
14334                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14335                    inner_depth.increment()?;
14336                }
14337                let val_ref = self.need_single_buffer_settings.get_or_insert_with(|| {
14338                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
14339                });
14340                fidl::decode!(
14341                    bool,
14342                    fdomain_client::fidl::FDomainResourceDialect,
14343                    val_ref,
14344                    decoder,
14345                    inner_offset,
14346                    inner_depth
14347                )?;
14348                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14349                {
14350                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14351                }
14352                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14353                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14354                }
14355            }
14356
14357            next_offset += envelope_size;
14358            _next_ordinal_to_read += 1;
14359            if next_offset >= end_offset {
14360                return Ok(());
14361            }
14362
14363            // Decode unknown envelopes for gaps in ordinals.
14364            while _next_ordinal_to_read < 4 {
14365                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14366                _next_ordinal_to_read += 1;
14367                next_offset += envelope_size;
14368            }
14369
14370            let next_out_of_line = decoder.next_out_of_line();
14371            let handles_before = decoder.remaining_handles();
14372            if let Some((inlined, num_bytes, num_handles)) =
14373                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14374            {
14375                let member_inline_size =
14376                    <BufferCollectionConstraints as fidl::encoding::TypeMarker>::inline_size(
14377                        decoder.context,
14378                    );
14379                if inlined != (member_inline_size <= 4) {
14380                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14381                }
14382                let inner_offset;
14383                let mut inner_depth = depth.clone();
14384                if inlined {
14385                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14386                    inner_offset = next_offset;
14387                } else {
14388                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14389                    inner_depth.increment()?;
14390                }
14391                let val_ref = self.constraints_to_check.get_or_insert_with(|| {
14392                    fidl::new_empty!(
14393                        BufferCollectionConstraints,
14394                        fdomain_client::fidl::FDomainResourceDialect
14395                    )
14396                });
14397                fidl::decode!(
14398                    BufferCollectionConstraints,
14399                    fdomain_client::fidl::FDomainResourceDialect,
14400                    val_ref,
14401                    decoder,
14402                    inner_offset,
14403                    inner_depth
14404                )?;
14405                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14406                {
14407                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14408                }
14409                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14410                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14411                }
14412            }
14413
14414            next_offset += envelope_size;
14415            _next_ordinal_to_read += 1;
14416            if next_offset >= end_offset {
14417                return Ok(());
14418            }
14419
14420            // Decode unknown envelopes for gaps in ordinals.
14421            while _next_ordinal_to_read < 5 {
14422                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14423                _next_ordinal_to_read += 1;
14424                next_offset += envelope_size;
14425            }
14426
14427            let next_out_of_line = decoder.next_out_of_line();
14428            let handles_before = decoder.remaining_handles();
14429            if let Some((inlined, num_bytes, num_handles)) =
14430                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14431            {
14432                let member_inline_size = <fidl::encoding::HandleType<
14433                    fdomain_client::Vmo,
14434                    { fidl::ObjectType::VMO.into_raw() },
14435                    2147483648,
14436                > as fidl::encoding::TypeMarker>::inline_size(
14437                    decoder.context
14438                );
14439                if inlined != (member_inline_size <= 4) {
14440                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14441                }
14442                let inner_offset;
14443                let mut inner_depth = depth.clone();
14444                if inlined {
14445                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14446                    inner_offset = next_offset;
14447                } else {
14448                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14449                    inner_depth.increment()?;
14450                }
14451                let val_ref =
14452                self.vmo_settings_to_check.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
14453                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)?;
14454                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14455                {
14456                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14457                }
14458                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14459                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14460                }
14461            }
14462
14463            next_offset += envelope_size;
14464            _next_ordinal_to_read += 1;
14465            if next_offset >= end_offset {
14466                return Ok(());
14467            }
14468
14469            // Decode unknown envelopes for gaps in ordinals.
14470            while _next_ordinal_to_read < 6 {
14471                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14472                _next_ordinal_to_read += 1;
14473                next_offset += envelope_size;
14474            }
14475
14476            let next_out_of_line = decoder.next_out_of_line();
14477            let handles_before = decoder.remaining_handles();
14478            if let Some((inlined, num_bytes, num_handles)) =
14479                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14480            {
14481                let member_inline_size =
14482                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14483                if inlined != (member_inline_size <= 4) {
14484                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14485                }
14486                let inner_offset;
14487                let mut inner_depth = depth.clone();
14488                if inlined {
14489                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14490                    inner_offset = next_offset;
14491                } else {
14492                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14493                    inner_depth.increment()?;
14494                }
14495                let val_ref = self.vmo_settings_to_check_ignore_size.get_or_insert_with(|| {
14496                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
14497                });
14498                fidl::decode!(
14499                    bool,
14500                    fdomain_client::fidl::FDomainResourceDialect,
14501                    val_ref,
14502                    decoder,
14503                    inner_offset,
14504                    inner_depth
14505                )?;
14506                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14507                {
14508                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14509                }
14510                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14511                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14512                }
14513            }
14514
14515            next_offset += envelope_size;
14516
14517            // Decode the remaining unknown envelopes.
14518            while next_offset < end_offset {
14519                _next_ordinal_to_read += 1;
14520                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14521                next_offset += envelope_size;
14522            }
14523
14524            Ok(())
14525        }
14526    }
14527
14528    impl AllocatorGetVmoInfoResponse {
14529        #[inline(always)]
14530        fn max_ordinal_present(&self) -> u64 {
14531            if let Some(_) = self.vmo_settings_match {
14532                return 7;
14533            }
14534            if let Some(_) = self.constraints_ok {
14535                return 6;
14536            }
14537            if let Some(_) = self.single_buffer_settings {
14538                return 5;
14539            }
14540            if let Some(_) = self.weak_vmo {
14541                return 4;
14542            }
14543            if let Some(_) = self.close_weak_asap {
14544                return 3;
14545            }
14546            if let Some(_) = self.buffer_index {
14547                return 2;
14548            }
14549            if let Some(_) = self.buffer_collection_id {
14550                return 1;
14551            }
14552            0
14553        }
14554    }
14555
14556    impl fidl::encoding::ResourceTypeMarker for AllocatorGetVmoInfoResponse {
14557        type Borrowed<'a> = &'a mut Self;
14558        fn take_or_borrow<'a>(
14559            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14560        ) -> Self::Borrowed<'a> {
14561            value
14562        }
14563    }
14564
14565    unsafe impl fidl::encoding::TypeMarker for AllocatorGetVmoInfoResponse {
14566        type Owned = Self;
14567
14568        #[inline(always)]
14569        fn inline_align(_context: fidl::encoding::Context) -> usize {
14570            8
14571        }
14572
14573        #[inline(always)]
14574        fn inline_size(_context: fidl::encoding::Context) -> usize {
14575            16
14576        }
14577    }
14578
14579    unsafe impl
14580        fidl::encoding::Encode<
14581            AllocatorGetVmoInfoResponse,
14582            fdomain_client::fidl::FDomainResourceDialect,
14583        > for &mut AllocatorGetVmoInfoResponse
14584    {
14585        unsafe fn encode(
14586            self,
14587            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14588            offset: usize,
14589            mut depth: fidl::encoding::Depth,
14590        ) -> fidl::Result<()> {
14591            encoder.debug_check_bounds::<AllocatorGetVmoInfoResponse>(offset);
14592            // Vector header
14593            let max_ordinal: u64 = self.max_ordinal_present();
14594            encoder.write_num(max_ordinal, offset);
14595            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14596            // Calling encoder.out_of_line_offset(0) is not allowed.
14597            if max_ordinal == 0 {
14598                return Ok(());
14599            }
14600            depth.increment()?;
14601            let envelope_size = 8;
14602            let bytes_len = max_ordinal as usize * envelope_size;
14603            #[allow(unused_variables)]
14604            let offset = encoder.out_of_line_offset(bytes_len);
14605            let mut _prev_end_offset: usize = 0;
14606            if 1 > max_ordinal {
14607                return Ok(());
14608            }
14609
14610            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14611            // are envelope_size bytes.
14612            let cur_offset: usize = (1 - 1) * envelope_size;
14613
14614            // Zero reserved fields.
14615            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14616
14617            // Safety:
14618            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14619            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14620            //   envelope_size bytes, there is always sufficient room.
14621            fidl::encoding::encode_in_envelope_optional::<
14622                u64,
14623                fdomain_client::fidl::FDomainResourceDialect,
14624            >(
14625                self.buffer_collection_id
14626                    .as_ref()
14627                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
14628                encoder,
14629                offset + cur_offset,
14630                depth,
14631            )?;
14632
14633            _prev_end_offset = cur_offset + envelope_size;
14634            if 2 > max_ordinal {
14635                return Ok(());
14636            }
14637
14638            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14639            // are envelope_size bytes.
14640            let cur_offset: usize = (2 - 1) * envelope_size;
14641
14642            // Zero reserved fields.
14643            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14644
14645            // Safety:
14646            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14647            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14648            //   envelope_size bytes, there is always sufficient room.
14649            fidl::encoding::encode_in_envelope_optional::<
14650                u64,
14651                fdomain_client::fidl::FDomainResourceDialect,
14652            >(
14653                self.buffer_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
14654                encoder,
14655                offset + cur_offset,
14656                depth,
14657            )?;
14658
14659            _prev_end_offset = cur_offset + envelope_size;
14660            if 3 > max_ordinal {
14661                return Ok(());
14662            }
14663
14664            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14665            // are envelope_size bytes.
14666            let cur_offset: usize = (3 - 1) * envelope_size;
14667
14668            // Zero reserved fields.
14669            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14670
14671            // Safety:
14672            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14673            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14674            //   envelope_size bytes, there is always sufficient room.
14675            fidl::encoding::encode_in_envelope_optional::<
14676                fidl::encoding::HandleType<
14677                    fdomain_client::EventPair,
14678                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14679                    2147483648,
14680                >,
14681                fdomain_client::fidl::FDomainResourceDialect,
14682            >(
14683                self.close_weak_asap.as_mut().map(
14684                    <fidl::encoding::HandleType<
14685                        fdomain_client::EventPair,
14686                        { fidl::ObjectType::EVENTPAIR.into_raw() },
14687                        2147483648,
14688                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14689                ),
14690                encoder,
14691                offset + cur_offset,
14692                depth,
14693            )?;
14694
14695            _prev_end_offset = cur_offset + envelope_size;
14696            if 4 > max_ordinal {
14697                return Ok(());
14698            }
14699
14700            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14701            // are envelope_size bytes.
14702            let cur_offset: usize = (4 - 1) * envelope_size;
14703
14704            // Zero reserved fields.
14705            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14706
14707            // Safety:
14708            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14709            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14710            //   envelope_size bytes, there is always sufficient room.
14711            fidl::encoding::encode_in_envelope_optional::<
14712                fidl::encoding::HandleType<
14713                    fdomain_client::Vmo,
14714                    { fidl::ObjectType::VMO.into_raw() },
14715                    2147483648,
14716                >,
14717                fdomain_client::fidl::FDomainResourceDialect,
14718            >(
14719                self.weak_vmo.as_mut().map(
14720                    <fidl::encoding::HandleType<
14721                        fdomain_client::Vmo,
14722                        { fidl::ObjectType::VMO.into_raw() },
14723                        2147483648,
14724                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14725                ),
14726                encoder,
14727                offset + cur_offset,
14728                depth,
14729            )?;
14730
14731            _prev_end_offset = cur_offset + envelope_size;
14732            if 5 > max_ordinal {
14733                return Ok(());
14734            }
14735
14736            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14737            // are envelope_size bytes.
14738            let cur_offset: usize = (5 - 1) * envelope_size;
14739
14740            // Zero reserved fields.
14741            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14742
14743            // Safety:
14744            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14745            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14746            //   envelope_size bytes, there is always sufficient room.
14747            fidl::encoding::encode_in_envelope_optional::<
14748                SingleBufferSettings,
14749                fdomain_client::fidl::FDomainResourceDialect,
14750            >(
14751                self.single_buffer_settings
14752                    .as_ref()
14753                    .map(<SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow),
14754                encoder,
14755                offset + cur_offset,
14756                depth,
14757            )?;
14758
14759            _prev_end_offset = cur_offset + envelope_size;
14760            if 6 > max_ordinal {
14761                return Ok(());
14762            }
14763
14764            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14765            // are envelope_size bytes.
14766            let cur_offset: usize = (6 - 1) * envelope_size;
14767
14768            // Zero reserved fields.
14769            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14770
14771            // Safety:
14772            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14773            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14774            //   envelope_size bytes, there is always sufficient room.
14775            fidl::encoding::encode_in_envelope_optional::<
14776                bool,
14777                fdomain_client::fidl::FDomainResourceDialect,
14778            >(
14779                self.constraints_ok.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14780                encoder,
14781                offset + cur_offset,
14782                depth,
14783            )?;
14784
14785            _prev_end_offset = cur_offset + envelope_size;
14786            if 7 > max_ordinal {
14787                return Ok(());
14788            }
14789
14790            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14791            // are envelope_size bytes.
14792            let cur_offset: usize = (7 - 1) * envelope_size;
14793
14794            // Zero reserved fields.
14795            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14796
14797            // Safety:
14798            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14799            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14800            //   envelope_size bytes, there is always sufficient room.
14801            fidl::encoding::encode_in_envelope_optional::<
14802                bool,
14803                fdomain_client::fidl::FDomainResourceDialect,
14804            >(
14805                self.vmo_settings_match
14806                    .as_ref()
14807                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14808                encoder,
14809                offset + cur_offset,
14810                depth,
14811            )?;
14812
14813            _prev_end_offset = cur_offset + envelope_size;
14814
14815            Ok(())
14816        }
14817    }
14818
14819    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14820        for AllocatorGetVmoInfoResponse
14821    {
14822        #[inline(always)]
14823        fn new_empty() -> Self {
14824            Self::default()
14825        }
14826
14827        unsafe fn decode(
14828            &mut self,
14829            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14830            offset: usize,
14831            mut depth: fidl::encoding::Depth,
14832        ) -> fidl::Result<()> {
14833            decoder.debug_check_bounds::<Self>(offset);
14834            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14835                None => return Err(fidl::Error::NotNullable),
14836                Some(len) => len,
14837            };
14838            // Calling decoder.out_of_line_offset(0) is not allowed.
14839            if len == 0 {
14840                return Ok(());
14841            };
14842            depth.increment()?;
14843            let envelope_size = 8;
14844            let bytes_len = len * envelope_size;
14845            let offset = decoder.out_of_line_offset(bytes_len)?;
14846            // Decode the envelope for each type.
14847            let mut _next_ordinal_to_read = 0;
14848            let mut next_offset = offset;
14849            let end_offset = offset + bytes_len;
14850            _next_ordinal_to_read += 1;
14851            if next_offset >= end_offset {
14852                return Ok(());
14853            }
14854
14855            // Decode unknown envelopes for gaps in ordinals.
14856            while _next_ordinal_to_read < 1 {
14857                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14858                _next_ordinal_to_read += 1;
14859                next_offset += envelope_size;
14860            }
14861
14862            let next_out_of_line = decoder.next_out_of_line();
14863            let handles_before = decoder.remaining_handles();
14864            if let Some((inlined, num_bytes, num_handles)) =
14865                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14866            {
14867                let member_inline_size =
14868                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14869                if inlined != (member_inline_size <= 4) {
14870                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14871                }
14872                let inner_offset;
14873                let mut inner_depth = depth.clone();
14874                if inlined {
14875                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14876                    inner_offset = next_offset;
14877                } else {
14878                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14879                    inner_depth.increment()?;
14880                }
14881                let val_ref = self.buffer_collection_id.get_or_insert_with(|| {
14882                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
14883                });
14884                fidl::decode!(
14885                    u64,
14886                    fdomain_client::fidl::FDomainResourceDialect,
14887                    val_ref,
14888                    decoder,
14889                    inner_offset,
14890                    inner_depth
14891                )?;
14892                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14893                {
14894                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14895                }
14896                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14897                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14898                }
14899            }
14900
14901            next_offset += envelope_size;
14902            _next_ordinal_to_read += 1;
14903            if next_offset >= end_offset {
14904                return Ok(());
14905            }
14906
14907            // Decode unknown envelopes for gaps in ordinals.
14908            while _next_ordinal_to_read < 2 {
14909                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14910                _next_ordinal_to_read += 1;
14911                next_offset += envelope_size;
14912            }
14913
14914            let next_out_of_line = decoder.next_out_of_line();
14915            let handles_before = decoder.remaining_handles();
14916            if let Some((inlined, num_bytes, num_handles)) =
14917                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14918            {
14919                let member_inline_size =
14920                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14921                if inlined != (member_inline_size <= 4) {
14922                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14923                }
14924                let inner_offset;
14925                let mut inner_depth = depth.clone();
14926                if inlined {
14927                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14928                    inner_offset = next_offset;
14929                } else {
14930                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14931                    inner_depth.increment()?;
14932                }
14933                let val_ref = self.buffer_index.get_or_insert_with(|| {
14934                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
14935                });
14936                fidl::decode!(
14937                    u64,
14938                    fdomain_client::fidl::FDomainResourceDialect,
14939                    val_ref,
14940                    decoder,
14941                    inner_offset,
14942                    inner_depth
14943                )?;
14944                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14945                {
14946                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14947                }
14948                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14949                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14950                }
14951            }
14952
14953            next_offset += envelope_size;
14954            _next_ordinal_to_read += 1;
14955            if next_offset >= end_offset {
14956                return Ok(());
14957            }
14958
14959            // Decode unknown envelopes for gaps in ordinals.
14960            while _next_ordinal_to_read < 3 {
14961                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14962                _next_ordinal_to_read += 1;
14963                next_offset += envelope_size;
14964            }
14965
14966            let next_out_of_line = decoder.next_out_of_line();
14967            let handles_before = decoder.remaining_handles();
14968            if let Some((inlined, num_bytes, num_handles)) =
14969                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14970            {
14971                let member_inline_size = <fidl::encoding::HandleType<
14972                    fdomain_client::EventPair,
14973                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14974                    2147483648,
14975                > as fidl::encoding::TypeMarker>::inline_size(
14976                    decoder.context
14977                );
14978                if inlined != (member_inline_size <= 4) {
14979                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14980                }
14981                let inner_offset;
14982                let mut inner_depth = depth.clone();
14983                if inlined {
14984                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14985                    inner_offset = next_offset;
14986                } else {
14987                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14988                    inner_depth.increment()?;
14989                }
14990                let val_ref =
14991                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));
14992                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)?;
14993                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14994                {
14995                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14996                }
14997                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14998                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14999                }
15000            }
15001
15002            next_offset += envelope_size;
15003            _next_ordinal_to_read += 1;
15004            if next_offset >= end_offset {
15005                return Ok(());
15006            }
15007
15008            // Decode unknown envelopes for gaps in ordinals.
15009            while _next_ordinal_to_read < 4 {
15010                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15011                _next_ordinal_to_read += 1;
15012                next_offset += envelope_size;
15013            }
15014
15015            let next_out_of_line = decoder.next_out_of_line();
15016            let handles_before = decoder.remaining_handles();
15017            if let Some((inlined, num_bytes, num_handles)) =
15018                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15019            {
15020                let member_inline_size = <fidl::encoding::HandleType<
15021                    fdomain_client::Vmo,
15022                    { fidl::ObjectType::VMO.into_raw() },
15023                    2147483648,
15024                > as fidl::encoding::TypeMarker>::inline_size(
15025                    decoder.context
15026                );
15027                if inlined != (member_inline_size <= 4) {
15028                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15029                }
15030                let inner_offset;
15031                let mut inner_depth = depth.clone();
15032                if inlined {
15033                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15034                    inner_offset = next_offset;
15035                } else {
15036                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15037                    inner_depth.increment()?;
15038                }
15039                let val_ref =
15040                self.weak_vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
15041                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)?;
15042                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15043                {
15044                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15045                }
15046                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15047                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15048                }
15049            }
15050
15051            next_offset += envelope_size;
15052            _next_ordinal_to_read += 1;
15053            if next_offset >= end_offset {
15054                return Ok(());
15055            }
15056
15057            // Decode unknown envelopes for gaps in ordinals.
15058            while _next_ordinal_to_read < 5 {
15059                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15060                _next_ordinal_to_read += 1;
15061                next_offset += envelope_size;
15062            }
15063
15064            let next_out_of_line = decoder.next_out_of_line();
15065            let handles_before = decoder.remaining_handles();
15066            if let Some((inlined, num_bytes, num_handles)) =
15067                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15068            {
15069                let member_inline_size =
15070                    <SingleBufferSettings as fidl::encoding::TypeMarker>::inline_size(
15071                        decoder.context,
15072                    );
15073                if inlined != (member_inline_size <= 4) {
15074                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15075                }
15076                let inner_offset;
15077                let mut inner_depth = depth.clone();
15078                if inlined {
15079                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15080                    inner_offset = next_offset;
15081                } else {
15082                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15083                    inner_depth.increment()?;
15084                }
15085                let val_ref = self.single_buffer_settings.get_or_insert_with(|| {
15086                    fidl::new_empty!(
15087                        SingleBufferSettings,
15088                        fdomain_client::fidl::FDomainResourceDialect
15089                    )
15090                });
15091                fidl::decode!(
15092                    SingleBufferSettings,
15093                    fdomain_client::fidl::FDomainResourceDialect,
15094                    val_ref,
15095                    decoder,
15096                    inner_offset,
15097                    inner_depth
15098                )?;
15099                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15100                {
15101                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15102                }
15103                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15104                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15105                }
15106            }
15107
15108            next_offset += envelope_size;
15109            _next_ordinal_to_read += 1;
15110            if next_offset >= end_offset {
15111                return Ok(());
15112            }
15113
15114            // Decode unknown envelopes for gaps in ordinals.
15115            while _next_ordinal_to_read < 6 {
15116                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15117                _next_ordinal_to_read += 1;
15118                next_offset += envelope_size;
15119            }
15120
15121            let next_out_of_line = decoder.next_out_of_line();
15122            let handles_before = decoder.remaining_handles();
15123            if let Some((inlined, num_bytes, num_handles)) =
15124                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15125            {
15126                let member_inline_size =
15127                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15128                if inlined != (member_inline_size <= 4) {
15129                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15130                }
15131                let inner_offset;
15132                let mut inner_depth = depth.clone();
15133                if inlined {
15134                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15135                    inner_offset = next_offset;
15136                } else {
15137                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15138                    inner_depth.increment()?;
15139                }
15140                let val_ref = self.constraints_ok.get_or_insert_with(|| {
15141                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
15142                });
15143                fidl::decode!(
15144                    bool,
15145                    fdomain_client::fidl::FDomainResourceDialect,
15146                    val_ref,
15147                    decoder,
15148                    inner_offset,
15149                    inner_depth
15150                )?;
15151                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15152                {
15153                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15154                }
15155                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15156                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15157                }
15158            }
15159
15160            next_offset += envelope_size;
15161            _next_ordinal_to_read += 1;
15162            if next_offset >= end_offset {
15163                return Ok(());
15164            }
15165
15166            // Decode unknown envelopes for gaps in ordinals.
15167            while _next_ordinal_to_read < 7 {
15168                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15169                _next_ordinal_to_read += 1;
15170                next_offset += envelope_size;
15171            }
15172
15173            let next_out_of_line = decoder.next_out_of_line();
15174            let handles_before = decoder.remaining_handles();
15175            if let Some((inlined, num_bytes, num_handles)) =
15176                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15177            {
15178                let member_inline_size =
15179                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15180                if inlined != (member_inline_size <= 4) {
15181                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15182                }
15183                let inner_offset;
15184                let mut inner_depth = depth.clone();
15185                if inlined {
15186                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15187                    inner_offset = next_offset;
15188                } else {
15189                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15190                    inner_depth.increment()?;
15191                }
15192                let val_ref = self.vmo_settings_match.get_or_insert_with(|| {
15193                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
15194                });
15195                fidl::decode!(
15196                    bool,
15197                    fdomain_client::fidl::FDomainResourceDialect,
15198                    val_ref,
15199                    decoder,
15200                    inner_offset,
15201                    inner_depth
15202                )?;
15203                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15204                {
15205                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15206                }
15207                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15208                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15209                }
15210            }
15211
15212            next_offset += envelope_size;
15213
15214            // Decode the remaining unknown envelopes.
15215            while next_offset < end_offset {
15216                _next_ordinal_to_read += 1;
15217                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15218                next_offset += envelope_size;
15219            }
15220
15221            Ok(())
15222        }
15223    }
15224
15225    impl BufferCollectionAttachLifetimeTrackingRequest {
15226        #[inline(always)]
15227        fn max_ordinal_present(&self) -> u64 {
15228            if let Some(_) = self.buffers_remaining {
15229                return 2;
15230            }
15231            if let Some(_) = self.server_end {
15232                return 1;
15233            }
15234            0
15235        }
15236    }
15237
15238    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
15239        type Borrowed<'a> = &'a mut Self;
15240        fn take_or_borrow<'a>(
15241            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15242        ) -> Self::Borrowed<'a> {
15243            value
15244        }
15245    }
15246
15247    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
15248        type Owned = Self;
15249
15250        #[inline(always)]
15251        fn inline_align(_context: fidl::encoding::Context) -> usize {
15252            8
15253        }
15254
15255        #[inline(always)]
15256        fn inline_size(_context: fidl::encoding::Context) -> usize {
15257            16
15258        }
15259    }
15260
15261    unsafe impl
15262        fidl::encoding::Encode<
15263            BufferCollectionAttachLifetimeTrackingRequest,
15264            fdomain_client::fidl::FDomainResourceDialect,
15265        > for &mut BufferCollectionAttachLifetimeTrackingRequest
15266    {
15267        unsafe fn encode(
15268            self,
15269            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15270            offset: usize,
15271            mut depth: fidl::encoding::Depth,
15272        ) -> fidl::Result<()> {
15273            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
15274            // Vector header
15275            let max_ordinal: u64 = self.max_ordinal_present();
15276            encoder.write_num(max_ordinal, offset);
15277            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15278            // Calling encoder.out_of_line_offset(0) is not allowed.
15279            if max_ordinal == 0 {
15280                return Ok(());
15281            }
15282            depth.increment()?;
15283            let envelope_size = 8;
15284            let bytes_len = max_ordinal as usize * envelope_size;
15285            #[allow(unused_variables)]
15286            let offset = encoder.out_of_line_offset(bytes_len);
15287            let mut _prev_end_offset: usize = 0;
15288            if 1 > max_ordinal {
15289                return Ok(());
15290            }
15291
15292            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15293            // are envelope_size bytes.
15294            let cur_offset: usize = (1 - 1) * envelope_size;
15295
15296            // Zero reserved fields.
15297            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15298
15299            // Safety:
15300            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15301            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15302            //   envelope_size bytes, there is always sufficient room.
15303            fidl::encoding::encode_in_envelope_optional::<
15304                fidl::encoding::HandleType<
15305                    fdomain_client::EventPair,
15306                    { fidl::ObjectType::EVENTPAIR.into_raw() },
15307                    2147483648,
15308                >,
15309                fdomain_client::fidl::FDomainResourceDialect,
15310            >(
15311                self.server_end.as_mut().map(
15312                    <fidl::encoding::HandleType<
15313                        fdomain_client::EventPair,
15314                        { fidl::ObjectType::EVENTPAIR.into_raw() },
15315                        2147483648,
15316                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15317                ),
15318                encoder,
15319                offset + cur_offset,
15320                depth,
15321            )?;
15322
15323            _prev_end_offset = cur_offset + envelope_size;
15324            if 2 > max_ordinal {
15325                return Ok(());
15326            }
15327
15328            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15329            // are envelope_size bytes.
15330            let cur_offset: usize = (2 - 1) * envelope_size;
15331
15332            // Zero reserved fields.
15333            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15334
15335            // Safety:
15336            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15337            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15338            //   envelope_size bytes, there is always sufficient room.
15339            fidl::encoding::encode_in_envelope_optional::<
15340                u32,
15341                fdomain_client::fidl::FDomainResourceDialect,
15342            >(
15343                self.buffers_remaining
15344                    .as_ref()
15345                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
15346                encoder,
15347                offset + cur_offset,
15348                depth,
15349            )?;
15350
15351            _prev_end_offset = cur_offset + envelope_size;
15352
15353            Ok(())
15354        }
15355    }
15356
15357    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15358        for BufferCollectionAttachLifetimeTrackingRequest
15359    {
15360        #[inline(always)]
15361        fn new_empty() -> Self {
15362            Self::default()
15363        }
15364
15365        unsafe fn decode(
15366            &mut self,
15367            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15368            offset: usize,
15369            mut depth: fidl::encoding::Depth,
15370        ) -> fidl::Result<()> {
15371            decoder.debug_check_bounds::<Self>(offset);
15372            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15373                None => return Err(fidl::Error::NotNullable),
15374                Some(len) => len,
15375            };
15376            // Calling decoder.out_of_line_offset(0) is not allowed.
15377            if len == 0 {
15378                return Ok(());
15379            };
15380            depth.increment()?;
15381            let envelope_size = 8;
15382            let bytes_len = len * envelope_size;
15383            let offset = decoder.out_of_line_offset(bytes_len)?;
15384            // Decode the envelope for each type.
15385            let mut _next_ordinal_to_read = 0;
15386            let mut next_offset = offset;
15387            let end_offset = offset + bytes_len;
15388            _next_ordinal_to_read += 1;
15389            if next_offset >= end_offset {
15390                return Ok(());
15391            }
15392
15393            // Decode unknown envelopes for gaps in ordinals.
15394            while _next_ordinal_to_read < 1 {
15395                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15396                _next_ordinal_to_read += 1;
15397                next_offset += envelope_size;
15398            }
15399
15400            let next_out_of_line = decoder.next_out_of_line();
15401            let handles_before = decoder.remaining_handles();
15402            if let Some((inlined, num_bytes, num_handles)) =
15403                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15404            {
15405                let member_inline_size = <fidl::encoding::HandleType<
15406                    fdomain_client::EventPair,
15407                    { fidl::ObjectType::EVENTPAIR.into_raw() },
15408                    2147483648,
15409                > as fidl::encoding::TypeMarker>::inline_size(
15410                    decoder.context
15411                );
15412                if inlined != (member_inline_size <= 4) {
15413                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15414                }
15415                let inner_offset;
15416                let mut inner_depth = depth.clone();
15417                if inlined {
15418                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15419                    inner_offset = next_offset;
15420                } else {
15421                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15422                    inner_depth.increment()?;
15423                }
15424                let val_ref =
15425                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));
15426                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)?;
15427                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15428                {
15429                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15430                }
15431                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15432                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15433                }
15434            }
15435
15436            next_offset += envelope_size;
15437            _next_ordinal_to_read += 1;
15438            if next_offset >= end_offset {
15439                return Ok(());
15440            }
15441
15442            // Decode unknown envelopes for gaps in ordinals.
15443            while _next_ordinal_to_read < 2 {
15444                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15445                _next_ordinal_to_read += 1;
15446                next_offset += envelope_size;
15447            }
15448
15449            let next_out_of_line = decoder.next_out_of_line();
15450            let handles_before = decoder.remaining_handles();
15451            if let Some((inlined, num_bytes, num_handles)) =
15452                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15453            {
15454                let member_inline_size =
15455                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15456                if inlined != (member_inline_size <= 4) {
15457                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15458                }
15459                let inner_offset;
15460                let mut inner_depth = depth.clone();
15461                if inlined {
15462                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15463                    inner_offset = next_offset;
15464                } else {
15465                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15466                    inner_depth.increment()?;
15467                }
15468                let val_ref = self.buffers_remaining.get_or_insert_with(|| {
15469                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
15470                });
15471                fidl::decode!(
15472                    u32,
15473                    fdomain_client::fidl::FDomainResourceDialect,
15474                    val_ref,
15475                    decoder,
15476                    inner_offset,
15477                    inner_depth
15478                )?;
15479                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15480                {
15481                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15482                }
15483                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15484                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15485                }
15486            }
15487
15488            next_offset += envelope_size;
15489
15490            // Decode the remaining unknown envelopes.
15491            while next_offset < end_offset {
15492                _next_ordinal_to_read += 1;
15493                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15494                next_offset += envelope_size;
15495            }
15496
15497            Ok(())
15498        }
15499    }
15500
15501    impl BufferCollectionAttachTokenRequest {
15502        #[inline(always)]
15503        fn max_ordinal_present(&self) -> u64 {
15504            if let Some(_) = self.token_request {
15505                return 2;
15506            }
15507            if let Some(_) = self.rights_attenuation_mask {
15508                return 1;
15509            }
15510            0
15511        }
15512    }
15513
15514    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
15515        type Borrowed<'a> = &'a mut Self;
15516        fn take_or_borrow<'a>(
15517            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15518        ) -> Self::Borrowed<'a> {
15519            value
15520        }
15521    }
15522
15523    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
15524        type Owned = Self;
15525
15526        #[inline(always)]
15527        fn inline_align(_context: fidl::encoding::Context) -> usize {
15528            8
15529        }
15530
15531        #[inline(always)]
15532        fn inline_size(_context: fidl::encoding::Context) -> usize {
15533            16
15534        }
15535    }
15536
15537    unsafe impl
15538        fidl::encoding::Encode<
15539            BufferCollectionAttachTokenRequest,
15540            fdomain_client::fidl::FDomainResourceDialect,
15541        > for &mut BufferCollectionAttachTokenRequest
15542    {
15543        unsafe fn encode(
15544            self,
15545            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15546            offset: usize,
15547            mut depth: fidl::encoding::Depth,
15548        ) -> fidl::Result<()> {
15549            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
15550            // Vector header
15551            let max_ordinal: u64 = self.max_ordinal_present();
15552            encoder.write_num(max_ordinal, offset);
15553            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15554            // Calling encoder.out_of_line_offset(0) is not allowed.
15555            if max_ordinal == 0 {
15556                return Ok(());
15557            }
15558            depth.increment()?;
15559            let envelope_size = 8;
15560            let bytes_len = max_ordinal as usize * envelope_size;
15561            #[allow(unused_variables)]
15562            let offset = encoder.out_of_line_offset(bytes_len);
15563            let mut _prev_end_offset: usize = 0;
15564            if 1 > max_ordinal {
15565                return Ok(());
15566            }
15567
15568            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15569            // are envelope_size bytes.
15570            let cur_offset: usize = (1 - 1) * envelope_size;
15571
15572            // Zero reserved fields.
15573            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15574
15575            // Safety:
15576            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15577            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15578            //   envelope_size bytes, there is always sufficient room.
15579            fidl::encoding::encode_in_envelope_optional::<
15580                fidl::Rights,
15581                fdomain_client::fidl::FDomainResourceDialect,
15582            >(
15583                self.rights_attenuation_mask
15584                    .as_ref()
15585                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
15586                encoder,
15587                offset + cur_offset,
15588                depth,
15589            )?;
15590
15591            _prev_end_offset = cur_offset + envelope_size;
15592            if 2 > max_ordinal {
15593                return Ok(());
15594            }
15595
15596            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15597            // are envelope_size bytes.
15598            let cur_offset: usize = (2 - 1) * envelope_size;
15599
15600            // Zero reserved fields.
15601            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15602
15603            // Safety:
15604            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15605            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15606            //   envelope_size bytes, there is always sufficient room.
15607            fidl::encoding::encode_in_envelope_optional::<
15608                fidl::encoding::Endpoint<
15609                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15610                >,
15611                fdomain_client::fidl::FDomainResourceDialect,
15612            >(
15613                self.token_request.as_mut().map(
15614                    <fidl::encoding::Endpoint<
15615                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15616                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15617                ),
15618                encoder,
15619                offset + cur_offset,
15620                depth,
15621            )?;
15622
15623            _prev_end_offset = cur_offset + envelope_size;
15624
15625            Ok(())
15626        }
15627    }
15628
15629    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15630        for BufferCollectionAttachTokenRequest
15631    {
15632        #[inline(always)]
15633        fn new_empty() -> Self {
15634            Self::default()
15635        }
15636
15637        unsafe fn decode(
15638            &mut self,
15639            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15640            offset: usize,
15641            mut depth: fidl::encoding::Depth,
15642        ) -> fidl::Result<()> {
15643            decoder.debug_check_bounds::<Self>(offset);
15644            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15645                None => return Err(fidl::Error::NotNullable),
15646                Some(len) => len,
15647            };
15648            // Calling decoder.out_of_line_offset(0) is not allowed.
15649            if len == 0 {
15650                return Ok(());
15651            };
15652            depth.increment()?;
15653            let envelope_size = 8;
15654            let bytes_len = len * envelope_size;
15655            let offset = decoder.out_of_line_offset(bytes_len)?;
15656            // Decode the envelope for each type.
15657            let mut _next_ordinal_to_read = 0;
15658            let mut next_offset = offset;
15659            let end_offset = offset + bytes_len;
15660            _next_ordinal_to_read += 1;
15661            if next_offset >= end_offset {
15662                return Ok(());
15663            }
15664
15665            // Decode unknown envelopes for gaps in ordinals.
15666            while _next_ordinal_to_read < 1 {
15667                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15668                _next_ordinal_to_read += 1;
15669                next_offset += envelope_size;
15670            }
15671
15672            let next_out_of_line = decoder.next_out_of_line();
15673            let handles_before = decoder.remaining_handles();
15674            if let Some((inlined, num_bytes, num_handles)) =
15675                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15676            {
15677                let member_inline_size =
15678                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15679                if inlined != (member_inline_size <= 4) {
15680                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15681                }
15682                let inner_offset;
15683                let mut inner_depth = depth.clone();
15684                if inlined {
15685                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15686                    inner_offset = next_offset;
15687                } else {
15688                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15689                    inner_depth.increment()?;
15690                }
15691                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
15692                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
15693                });
15694                fidl::decode!(
15695                    fidl::Rights,
15696                    fdomain_client::fidl::FDomainResourceDialect,
15697                    val_ref,
15698                    decoder,
15699                    inner_offset,
15700                    inner_depth
15701                )?;
15702                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15703                {
15704                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15705                }
15706                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15707                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15708                }
15709            }
15710
15711            next_offset += envelope_size;
15712            _next_ordinal_to_read += 1;
15713            if next_offset >= end_offset {
15714                return Ok(());
15715            }
15716
15717            // Decode unknown envelopes for gaps in ordinals.
15718            while _next_ordinal_to_read < 2 {
15719                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15720                _next_ordinal_to_read += 1;
15721                next_offset += envelope_size;
15722            }
15723
15724            let next_out_of_line = decoder.next_out_of_line();
15725            let handles_before = decoder.remaining_handles();
15726            if let Some((inlined, num_bytes, num_handles)) =
15727                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15728            {
15729                let member_inline_size = <fidl::encoding::Endpoint<
15730                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15731                > as fidl::encoding::TypeMarker>::inline_size(
15732                    decoder.context
15733                );
15734                if inlined != (member_inline_size <= 4) {
15735                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15736                }
15737                let inner_offset;
15738                let mut inner_depth = depth.clone();
15739                if inlined {
15740                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15741                    inner_offset = next_offset;
15742                } else {
15743                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15744                    inner_depth.increment()?;
15745                }
15746                let val_ref = self.token_request.get_or_insert_with(|| {
15747                    fidl::new_empty!(
15748                        fidl::encoding::Endpoint<
15749                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15750                        >,
15751                        fdomain_client::fidl::FDomainResourceDialect
15752                    )
15753                });
15754                fidl::decode!(
15755                    fidl::encoding::Endpoint<
15756                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15757                    >,
15758                    fdomain_client::fidl::FDomainResourceDialect,
15759                    val_ref,
15760                    decoder,
15761                    inner_offset,
15762                    inner_depth
15763                )?;
15764                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15765                {
15766                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15767                }
15768                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15769                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15770                }
15771            }
15772
15773            next_offset += envelope_size;
15774
15775            // Decode the remaining unknown envelopes.
15776            while next_offset < end_offset {
15777                _next_ordinal_to_read += 1;
15778                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15779                next_offset += envelope_size;
15780            }
15781
15782            Ok(())
15783        }
15784    }
15785
15786    impl BufferCollectionInfo {
15787        #[inline(always)]
15788        fn max_ordinal_present(&self) -> u64 {
15789            if let Some(_) = self.buffer_collection_id {
15790                return 3;
15791            }
15792            if let Some(_) = self.buffers {
15793                return 2;
15794            }
15795            if let Some(_) = self.settings {
15796                return 1;
15797            }
15798            0
15799        }
15800    }
15801
15802    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
15803        type Borrowed<'a> = &'a mut Self;
15804        fn take_or_borrow<'a>(
15805            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15806        ) -> Self::Borrowed<'a> {
15807            value
15808        }
15809    }
15810
15811    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
15812        type Owned = Self;
15813
15814        #[inline(always)]
15815        fn inline_align(_context: fidl::encoding::Context) -> usize {
15816            8
15817        }
15818
15819        #[inline(always)]
15820        fn inline_size(_context: fidl::encoding::Context) -> usize {
15821            16
15822        }
15823    }
15824
15825    unsafe impl
15826        fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
15827        for &mut BufferCollectionInfo
15828    {
15829        unsafe fn encode(
15830            self,
15831            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15832            offset: usize,
15833            mut depth: fidl::encoding::Depth,
15834        ) -> fidl::Result<()> {
15835            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
15836            // Vector header
15837            let max_ordinal: u64 = self.max_ordinal_present();
15838            encoder.write_num(max_ordinal, offset);
15839            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15840            // Calling encoder.out_of_line_offset(0) is not allowed.
15841            if max_ordinal == 0 {
15842                return Ok(());
15843            }
15844            depth.increment()?;
15845            let envelope_size = 8;
15846            let bytes_len = max_ordinal as usize * envelope_size;
15847            #[allow(unused_variables)]
15848            let offset = encoder.out_of_line_offset(bytes_len);
15849            let mut _prev_end_offset: usize = 0;
15850            if 1 > max_ordinal {
15851                return Ok(());
15852            }
15853
15854            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15855            // are envelope_size bytes.
15856            let cur_offset: usize = (1 - 1) * envelope_size;
15857
15858            // Zero reserved fields.
15859            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15860
15861            // Safety:
15862            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15863            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15864            //   envelope_size bytes, there is always sufficient room.
15865            fidl::encoding::encode_in_envelope_optional::<
15866                SingleBufferSettings,
15867                fdomain_client::fidl::FDomainResourceDialect,
15868            >(
15869                self.settings
15870                    .as_ref()
15871                    .map(<SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow),
15872                encoder,
15873                offset + cur_offset,
15874                depth,
15875            )?;
15876
15877            _prev_end_offset = cur_offset + envelope_size;
15878            if 2 > max_ordinal {
15879                return Ok(());
15880            }
15881
15882            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15883            // are envelope_size bytes.
15884            let cur_offset: usize = (2 - 1) * envelope_size;
15885
15886            // Zero reserved fields.
15887            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15888
15889            // Safety:
15890            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15891            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15892            //   envelope_size bytes, there is always sufficient room.
15893            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect>(
15894            self.buffers.as_mut().map(<fidl::encoding::Vector<VmoBuffer, 128> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
15895            encoder, offset + cur_offset, depth
15896        )?;
15897
15898            _prev_end_offset = cur_offset + envelope_size;
15899            if 3 > max_ordinal {
15900                return Ok(());
15901            }
15902
15903            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15904            // are envelope_size bytes.
15905            let cur_offset: usize = (3 - 1) * envelope_size;
15906
15907            // Zero reserved fields.
15908            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15909
15910            // Safety:
15911            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15912            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15913            //   envelope_size bytes, there is always sufficient room.
15914            fidl::encoding::encode_in_envelope_optional::<
15915                u64,
15916                fdomain_client::fidl::FDomainResourceDialect,
15917            >(
15918                self.buffer_collection_id
15919                    .as_ref()
15920                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
15921                encoder,
15922                offset + cur_offset,
15923                depth,
15924            )?;
15925
15926            _prev_end_offset = cur_offset + envelope_size;
15927
15928            Ok(())
15929        }
15930    }
15931
15932    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15933        for BufferCollectionInfo
15934    {
15935        #[inline(always)]
15936        fn new_empty() -> Self {
15937            Self::default()
15938        }
15939
15940        unsafe fn decode(
15941            &mut self,
15942            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15943            offset: usize,
15944            mut depth: fidl::encoding::Depth,
15945        ) -> fidl::Result<()> {
15946            decoder.debug_check_bounds::<Self>(offset);
15947            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15948                None => return Err(fidl::Error::NotNullable),
15949                Some(len) => len,
15950            };
15951            // Calling decoder.out_of_line_offset(0) is not allowed.
15952            if len == 0 {
15953                return Ok(());
15954            };
15955            depth.increment()?;
15956            let envelope_size = 8;
15957            let bytes_len = len * envelope_size;
15958            let offset = decoder.out_of_line_offset(bytes_len)?;
15959            // Decode the envelope for each type.
15960            let mut _next_ordinal_to_read = 0;
15961            let mut next_offset = offset;
15962            let end_offset = offset + bytes_len;
15963            _next_ordinal_to_read += 1;
15964            if next_offset >= end_offset {
15965                return Ok(());
15966            }
15967
15968            // Decode unknown envelopes for gaps in ordinals.
15969            while _next_ordinal_to_read < 1 {
15970                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15971                _next_ordinal_to_read += 1;
15972                next_offset += envelope_size;
15973            }
15974
15975            let next_out_of_line = decoder.next_out_of_line();
15976            let handles_before = decoder.remaining_handles();
15977            if let Some((inlined, num_bytes, num_handles)) =
15978                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15979            {
15980                let member_inline_size =
15981                    <SingleBufferSettings as fidl::encoding::TypeMarker>::inline_size(
15982                        decoder.context,
15983                    );
15984                if inlined != (member_inline_size <= 4) {
15985                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15986                }
15987                let inner_offset;
15988                let mut inner_depth = depth.clone();
15989                if inlined {
15990                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15991                    inner_offset = next_offset;
15992                } else {
15993                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15994                    inner_depth.increment()?;
15995                }
15996                let val_ref = self.settings.get_or_insert_with(|| {
15997                    fidl::new_empty!(
15998                        SingleBufferSettings,
15999                        fdomain_client::fidl::FDomainResourceDialect
16000                    )
16001                });
16002                fidl::decode!(
16003                    SingleBufferSettings,
16004                    fdomain_client::fidl::FDomainResourceDialect,
16005                    val_ref,
16006                    decoder,
16007                    inner_offset,
16008                    inner_depth
16009                )?;
16010                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16011                {
16012                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16013                }
16014                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16015                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16016                }
16017            }
16018
16019            next_offset += envelope_size;
16020            _next_ordinal_to_read += 1;
16021            if next_offset >= end_offset {
16022                return Ok(());
16023            }
16024
16025            // Decode unknown envelopes for gaps in ordinals.
16026            while _next_ordinal_to_read < 2 {
16027                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16028                _next_ordinal_to_read += 1;
16029                next_offset += envelope_size;
16030            }
16031
16032            let next_out_of_line = decoder.next_out_of_line();
16033            let handles_before = decoder.remaining_handles();
16034            if let Some((inlined, num_bytes, num_handles)) =
16035                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16036            {
16037                let member_inline_size = <fidl::encoding::Vector<VmoBuffer, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16038                if inlined != (member_inline_size <= 4) {
16039                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16040                }
16041                let inner_offset;
16042                let mut inner_depth = depth.clone();
16043                if inlined {
16044                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16045                    inner_offset = next_offset;
16046                } else {
16047                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16048                    inner_depth.increment()?;
16049                }
16050                let val_ref =
16051                self.buffers.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect));
16052                fidl::decode!(fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
16053                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16054                {
16055                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16056                }
16057                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16058                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16059                }
16060            }
16061
16062            next_offset += envelope_size;
16063            _next_ordinal_to_read += 1;
16064            if next_offset >= end_offset {
16065                return Ok(());
16066            }
16067
16068            // Decode unknown envelopes for gaps in ordinals.
16069            while _next_ordinal_to_read < 3 {
16070                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16071                _next_ordinal_to_read += 1;
16072                next_offset += envelope_size;
16073            }
16074
16075            let next_out_of_line = decoder.next_out_of_line();
16076            let handles_before = decoder.remaining_handles();
16077            if let Some((inlined, num_bytes, num_handles)) =
16078                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16079            {
16080                let member_inline_size =
16081                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16082                if inlined != (member_inline_size <= 4) {
16083                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16084                }
16085                let inner_offset;
16086                let mut inner_depth = depth.clone();
16087                if inlined {
16088                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16089                    inner_offset = next_offset;
16090                } else {
16091                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16092                    inner_depth.increment()?;
16093                }
16094                let val_ref = self.buffer_collection_id.get_or_insert_with(|| {
16095                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
16096                });
16097                fidl::decode!(
16098                    u64,
16099                    fdomain_client::fidl::FDomainResourceDialect,
16100                    val_ref,
16101                    decoder,
16102                    inner_offset,
16103                    inner_depth
16104                )?;
16105                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16106                {
16107                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16108                }
16109                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16110                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16111                }
16112            }
16113
16114            next_offset += envelope_size;
16115
16116            // Decode the remaining unknown envelopes.
16117            while next_offset < end_offset {
16118                _next_ordinal_to_read += 1;
16119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16120                next_offset += envelope_size;
16121            }
16122
16123            Ok(())
16124        }
16125    }
16126
16127    impl BufferCollectionSetConstraintsRequest {
16128        #[inline(always)]
16129        fn max_ordinal_present(&self) -> u64 {
16130            if let Some(_) = self.must_match_vmo {
16131                return 2;
16132            }
16133            if let Some(_) = self.constraints {
16134                return 1;
16135            }
16136            0
16137        }
16138    }
16139
16140    impl fidl::encoding::ResourceTypeMarker for BufferCollectionSetConstraintsRequest {
16141        type Borrowed<'a> = &'a mut Self;
16142        fn take_or_borrow<'a>(
16143            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16144        ) -> Self::Borrowed<'a> {
16145            value
16146        }
16147    }
16148
16149    unsafe impl fidl::encoding::TypeMarker for BufferCollectionSetConstraintsRequest {
16150        type Owned = Self;
16151
16152        #[inline(always)]
16153        fn inline_align(_context: fidl::encoding::Context) -> usize {
16154            8
16155        }
16156
16157        #[inline(always)]
16158        fn inline_size(_context: fidl::encoding::Context) -> usize {
16159            16
16160        }
16161    }
16162
16163    unsafe impl
16164        fidl::encoding::Encode<
16165            BufferCollectionSetConstraintsRequest,
16166            fdomain_client::fidl::FDomainResourceDialect,
16167        > for &mut BufferCollectionSetConstraintsRequest
16168    {
16169        unsafe fn encode(
16170            self,
16171            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16172            offset: usize,
16173            mut depth: fidl::encoding::Depth,
16174        ) -> fidl::Result<()> {
16175            encoder.debug_check_bounds::<BufferCollectionSetConstraintsRequest>(offset);
16176            // Vector header
16177            let max_ordinal: u64 = self.max_ordinal_present();
16178            encoder.write_num(max_ordinal, offset);
16179            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16180            // Calling encoder.out_of_line_offset(0) is not allowed.
16181            if max_ordinal == 0 {
16182                return Ok(());
16183            }
16184            depth.increment()?;
16185            let envelope_size = 8;
16186            let bytes_len = max_ordinal as usize * envelope_size;
16187            #[allow(unused_variables)]
16188            let offset = encoder.out_of_line_offset(bytes_len);
16189            let mut _prev_end_offset: usize = 0;
16190            if 1 > max_ordinal {
16191                return Ok(());
16192            }
16193
16194            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16195            // are envelope_size bytes.
16196            let cur_offset: usize = (1 - 1) * envelope_size;
16197
16198            // Zero reserved fields.
16199            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16200
16201            // Safety:
16202            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16203            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16204            //   envelope_size bytes, there is always sufficient room.
16205            fidl::encoding::encode_in_envelope_optional::<
16206                BufferCollectionConstraints,
16207                fdomain_client::fidl::FDomainResourceDialect,
16208            >(
16209                self.constraints
16210                    .as_ref()
16211                    .map(<BufferCollectionConstraints as fidl::encoding::ValueTypeMarker>::borrow),
16212                encoder,
16213                offset + cur_offset,
16214                depth,
16215            )?;
16216
16217            _prev_end_offset = cur_offset + envelope_size;
16218            if 2 > max_ordinal {
16219                return Ok(());
16220            }
16221
16222            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16223            // are envelope_size bytes.
16224            let cur_offset: usize = (2 - 1) * envelope_size;
16225
16226            // Zero reserved fields.
16227            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16228
16229            // Safety:
16230            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16231            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16232            //   envelope_size bytes, there is always sufficient room.
16233            fidl::encoding::encode_in_envelope_optional::<
16234                fidl::encoding::HandleType<
16235                    fdomain_client::Vmo,
16236                    { fidl::ObjectType::VMO.into_raw() },
16237                    2147483648,
16238                >,
16239                fdomain_client::fidl::FDomainResourceDialect,
16240            >(
16241                self.must_match_vmo.as_mut().map(
16242                    <fidl::encoding::HandleType<
16243                        fdomain_client::Vmo,
16244                        { fidl::ObjectType::VMO.into_raw() },
16245                        2147483648,
16246                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16247                ),
16248                encoder,
16249                offset + cur_offset,
16250                depth,
16251            )?;
16252
16253            _prev_end_offset = cur_offset + envelope_size;
16254
16255            Ok(())
16256        }
16257    }
16258
16259    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16260        for BufferCollectionSetConstraintsRequest
16261    {
16262        #[inline(always)]
16263        fn new_empty() -> Self {
16264            Self::default()
16265        }
16266
16267        unsafe fn decode(
16268            &mut self,
16269            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16270            offset: usize,
16271            mut depth: fidl::encoding::Depth,
16272        ) -> fidl::Result<()> {
16273            decoder.debug_check_bounds::<Self>(offset);
16274            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16275                None => return Err(fidl::Error::NotNullable),
16276                Some(len) => len,
16277            };
16278            // Calling decoder.out_of_line_offset(0) is not allowed.
16279            if len == 0 {
16280                return Ok(());
16281            };
16282            depth.increment()?;
16283            let envelope_size = 8;
16284            let bytes_len = len * envelope_size;
16285            let offset = decoder.out_of_line_offset(bytes_len)?;
16286            // Decode the envelope for each type.
16287            let mut _next_ordinal_to_read = 0;
16288            let mut next_offset = offset;
16289            let end_offset = offset + bytes_len;
16290            _next_ordinal_to_read += 1;
16291            if next_offset >= end_offset {
16292                return Ok(());
16293            }
16294
16295            // Decode unknown envelopes for gaps in ordinals.
16296            while _next_ordinal_to_read < 1 {
16297                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16298                _next_ordinal_to_read += 1;
16299                next_offset += envelope_size;
16300            }
16301
16302            let next_out_of_line = decoder.next_out_of_line();
16303            let handles_before = decoder.remaining_handles();
16304            if let Some((inlined, num_bytes, num_handles)) =
16305                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16306            {
16307                let member_inline_size =
16308                    <BufferCollectionConstraints as fidl::encoding::TypeMarker>::inline_size(
16309                        decoder.context,
16310                    );
16311                if inlined != (member_inline_size <= 4) {
16312                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16313                }
16314                let inner_offset;
16315                let mut inner_depth = depth.clone();
16316                if inlined {
16317                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16318                    inner_offset = next_offset;
16319                } else {
16320                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16321                    inner_depth.increment()?;
16322                }
16323                let val_ref = self.constraints.get_or_insert_with(|| {
16324                    fidl::new_empty!(
16325                        BufferCollectionConstraints,
16326                        fdomain_client::fidl::FDomainResourceDialect
16327                    )
16328                });
16329                fidl::decode!(
16330                    BufferCollectionConstraints,
16331                    fdomain_client::fidl::FDomainResourceDialect,
16332                    val_ref,
16333                    decoder,
16334                    inner_offset,
16335                    inner_depth
16336                )?;
16337                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16338                {
16339                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16340                }
16341                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16342                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16343                }
16344            }
16345
16346            next_offset += envelope_size;
16347            _next_ordinal_to_read += 1;
16348            if next_offset >= end_offset {
16349                return Ok(());
16350            }
16351
16352            // Decode unknown envelopes for gaps in ordinals.
16353            while _next_ordinal_to_read < 2 {
16354                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16355                _next_ordinal_to_read += 1;
16356                next_offset += envelope_size;
16357            }
16358
16359            let next_out_of_line = decoder.next_out_of_line();
16360            let handles_before = decoder.remaining_handles();
16361            if let Some((inlined, num_bytes, num_handles)) =
16362                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16363            {
16364                let member_inline_size = <fidl::encoding::HandleType<
16365                    fdomain_client::Vmo,
16366                    { fidl::ObjectType::VMO.into_raw() },
16367                    2147483648,
16368                > as fidl::encoding::TypeMarker>::inline_size(
16369                    decoder.context
16370                );
16371                if inlined != (member_inline_size <= 4) {
16372                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16373                }
16374                let inner_offset;
16375                let mut inner_depth = depth.clone();
16376                if inlined {
16377                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16378                    inner_offset = next_offset;
16379                } else {
16380                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16381                    inner_depth.increment()?;
16382                }
16383                let val_ref =
16384                self.must_match_vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
16385                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)?;
16386                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16387                {
16388                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16389                }
16390                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16391                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16392                }
16393            }
16394
16395            next_offset += envelope_size;
16396
16397            // Decode the remaining unknown envelopes.
16398            while next_offset < end_offset {
16399                _next_ordinal_to_read += 1;
16400                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16401                next_offset += envelope_size;
16402            }
16403
16404            Ok(())
16405        }
16406    }
16407
16408    impl BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
16409        #[inline(always)]
16410        fn max_ordinal_present(&self) -> u64 {
16411            if let Some(_) = self.group_request {
16412                return 1;
16413            }
16414            0
16415        }
16416    }
16417
16418    impl fidl::encoding::ResourceTypeMarker
16419        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16420    {
16421        type Borrowed<'a> = &'a mut Self;
16422        fn take_or_borrow<'a>(
16423            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16424        ) -> Self::Borrowed<'a> {
16425            value
16426        }
16427    }
16428
16429    unsafe impl fidl::encoding::TypeMarker
16430        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16431    {
16432        type Owned = Self;
16433
16434        #[inline(always)]
16435        fn inline_align(_context: fidl::encoding::Context) -> usize {
16436            8
16437        }
16438
16439        #[inline(always)]
16440        fn inline_size(_context: fidl::encoding::Context) -> usize {
16441            16
16442        }
16443    }
16444
16445    unsafe impl
16446        fidl::encoding::Encode<
16447            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
16448            fdomain_client::fidl::FDomainResourceDialect,
16449        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16450    {
16451        unsafe fn encode(
16452            self,
16453            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16454            offset: usize,
16455            mut depth: fidl::encoding::Depth,
16456        ) -> fidl::Result<()> {
16457            encoder
16458                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
16459                    offset,
16460                );
16461            // Vector header
16462            let max_ordinal: u64 = self.max_ordinal_present();
16463            encoder.write_num(max_ordinal, offset);
16464            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16465            // Calling encoder.out_of_line_offset(0) is not allowed.
16466            if max_ordinal == 0 {
16467                return Ok(());
16468            }
16469            depth.increment()?;
16470            let envelope_size = 8;
16471            let bytes_len = max_ordinal as usize * envelope_size;
16472            #[allow(unused_variables)]
16473            let offset = encoder.out_of_line_offset(bytes_len);
16474            let mut _prev_end_offset: usize = 0;
16475            if 1 > max_ordinal {
16476                return Ok(());
16477            }
16478
16479            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16480            // are envelope_size bytes.
16481            let cur_offset: usize = (1 - 1) * envelope_size;
16482
16483            // Zero reserved fields.
16484            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16485
16486            // Safety:
16487            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16488            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16489            //   envelope_size bytes, there is always sufficient room.
16490            fidl::encoding::encode_in_envelope_optional::<
16491                fidl::encoding::Endpoint<
16492                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16493                >,
16494                fdomain_client::fidl::FDomainResourceDialect,
16495            >(
16496                self.group_request.as_mut().map(
16497                    <fidl::encoding::Endpoint<
16498                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16499                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16500                ),
16501                encoder,
16502                offset + cur_offset,
16503                depth,
16504            )?;
16505
16506            _prev_end_offset = cur_offset + envelope_size;
16507
16508            Ok(())
16509        }
16510    }
16511
16512    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16513        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16514    {
16515        #[inline(always)]
16516        fn new_empty() -> Self {
16517            Self::default()
16518        }
16519
16520        unsafe fn decode(
16521            &mut self,
16522            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16523            offset: usize,
16524            mut depth: fidl::encoding::Depth,
16525        ) -> fidl::Result<()> {
16526            decoder.debug_check_bounds::<Self>(offset);
16527            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16528                None => return Err(fidl::Error::NotNullable),
16529                Some(len) => len,
16530            };
16531            // Calling decoder.out_of_line_offset(0) is not allowed.
16532            if len == 0 {
16533                return Ok(());
16534            };
16535            depth.increment()?;
16536            let envelope_size = 8;
16537            let bytes_len = len * envelope_size;
16538            let offset = decoder.out_of_line_offset(bytes_len)?;
16539            // Decode the envelope for each type.
16540            let mut _next_ordinal_to_read = 0;
16541            let mut next_offset = offset;
16542            let end_offset = offset + bytes_len;
16543            _next_ordinal_to_read += 1;
16544            if next_offset >= end_offset {
16545                return Ok(());
16546            }
16547
16548            // Decode unknown envelopes for gaps in ordinals.
16549            while _next_ordinal_to_read < 1 {
16550                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16551                _next_ordinal_to_read += 1;
16552                next_offset += envelope_size;
16553            }
16554
16555            let next_out_of_line = decoder.next_out_of_line();
16556            let handles_before = decoder.remaining_handles();
16557            if let Some((inlined, num_bytes, num_handles)) =
16558                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16559            {
16560                let member_inline_size = <fidl::encoding::Endpoint<
16561                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16562                > as fidl::encoding::TypeMarker>::inline_size(
16563                    decoder.context
16564                );
16565                if inlined != (member_inline_size <= 4) {
16566                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16567                }
16568                let inner_offset;
16569                let mut inner_depth = depth.clone();
16570                if inlined {
16571                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16572                    inner_offset = next_offset;
16573                } else {
16574                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16575                    inner_depth.increment()?;
16576                }
16577                let val_ref = self.group_request.get_or_insert_with(|| {
16578                    fidl::new_empty!(
16579                        fidl::encoding::Endpoint<
16580                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16581                        >,
16582                        fdomain_client::fidl::FDomainResourceDialect
16583                    )
16584                });
16585                fidl::decode!(
16586                    fidl::encoding::Endpoint<
16587                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16588                    >,
16589                    fdomain_client::fidl::FDomainResourceDialect,
16590                    val_ref,
16591                    decoder,
16592                    inner_offset,
16593                    inner_depth
16594                )?;
16595                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16596                {
16597                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16598                }
16599                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16600                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16601                }
16602            }
16603
16604            next_offset += envelope_size;
16605
16606            // Decode the remaining unknown envelopes.
16607            while next_offset < end_offset {
16608                _next_ordinal_to_read += 1;
16609                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16610                next_offset += envelope_size;
16611            }
16612
16613            Ok(())
16614        }
16615    }
16616
16617    impl BufferCollectionTokenDuplicateRequest {
16618        #[inline(always)]
16619        fn max_ordinal_present(&self) -> u64 {
16620            if let Some(_) = self.token_request {
16621                return 2;
16622            }
16623            if let Some(_) = self.rights_attenuation_mask {
16624                return 1;
16625            }
16626            0
16627        }
16628    }
16629
16630    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
16631        type Borrowed<'a> = &'a mut Self;
16632        fn take_or_borrow<'a>(
16633            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16634        ) -> Self::Borrowed<'a> {
16635            value
16636        }
16637    }
16638
16639    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
16640        type Owned = Self;
16641
16642        #[inline(always)]
16643        fn inline_align(_context: fidl::encoding::Context) -> usize {
16644            8
16645        }
16646
16647        #[inline(always)]
16648        fn inline_size(_context: fidl::encoding::Context) -> usize {
16649            16
16650        }
16651    }
16652
16653    unsafe impl
16654        fidl::encoding::Encode<
16655            BufferCollectionTokenDuplicateRequest,
16656            fdomain_client::fidl::FDomainResourceDialect,
16657        > for &mut BufferCollectionTokenDuplicateRequest
16658    {
16659        unsafe fn encode(
16660            self,
16661            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16662            offset: usize,
16663            mut depth: fidl::encoding::Depth,
16664        ) -> fidl::Result<()> {
16665            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
16666            // Vector header
16667            let max_ordinal: u64 = self.max_ordinal_present();
16668            encoder.write_num(max_ordinal, offset);
16669            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16670            // Calling encoder.out_of_line_offset(0) is not allowed.
16671            if max_ordinal == 0 {
16672                return Ok(());
16673            }
16674            depth.increment()?;
16675            let envelope_size = 8;
16676            let bytes_len = max_ordinal as usize * envelope_size;
16677            #[allow(unused_variables)]
16678            let offset = encoder.out_of_line_offset(bytes_len);
16679            let mut _prev_end_offset: usize = 0;
16680            if 1 > max_ordinal {
16681                return Ok(());
16682            }
16683
16684            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16685            // are envelope_size bytes.
16686            let cur_offset: usize = (1 - 1) * envelope_size;
16687
16688            // Zero reserved fields.
16689            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16690
16691            // Safety:
16692            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16693            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16694            //   envelope_size bytes, there is always sufficient room.
16695            fidl::encoding::encode_in_envelope_optional::<
16696                fidl::Rights,
16697                fdomain_client::fidl::FDomainResourceDialect,
16698            >(
16699                self.rights_attenuation_mask
16700                    .as_ref()
16701                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
16702                encoder,
16703                offset + cur_offset,
16704                depth,
16705            )?;
16706
16707            _prev_end_offset = cur_offset + envelope_size;
16708            if 2 > max_ordinal {
16709                return Ok(());
16710            }
16711
16712            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16713            // are envelope_size bytes.
16714            let cur_offset: usize = (2 - 1) * envelope_size;
16715
16716            // Zero reserved fields.
16717            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16718
16719            // Safety:
16720            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16721            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16722            //   envelope_size bytes, there is always sufficient room.
16723            fidl::encoding::encode_in_envelope_optional::<
16724                fidl::encoding::Endpoint<
16725                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16726                >,
16727                fdomain_client::fidl::FDomainResourceDialect,
16728            >(
16729                self.token_request.as_mut().map(
16730                    <fidl::encoding::Endpoint<
16731                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16732                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16733                ),
16734                encoder,
16735                offset + cur_offset,
16736                depth,
16737            )?;
16738
16739            _prev_end_offset = cur_offset + envelope_size;
16740
16741            Ok(())
16742        }
16743    }
16744
16745    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16746        for BufferCollectionTokenDuplicateRequest
16747    {
16748        #[inline(always)]
16749        fn new_empty() -> Self {
16750            Self::default()
16751        }
16752
16753        unsafe fn decode(
16754            &mut self,
16755            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16756            offset: usize,
16757            mut depth: fidl::encoding::Depth,
16758        ) -> fidl::Result<()> {
16759            decoder.debug_check_bounds::<Self>(offset);
16760            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16761                None => return Err(fidl::Error::NotNullable),
16762                Some(len) => len,
16763            };
16764            // Calling decoder.out_of_line_offset(0) is not allowed.
16765            if len == 0 {
16766                return Ok(());
16767            };
16768            depth.increment()?;
16769            let envelope_size = 8;
16770            let bytes_len = len * envelope_size;
16771            let offset = decoder.out_of_line_offset(bytes_len)?;
16772            // Decode the envelope for each type.
16773            let mut _next_ordinal_to_read = 0;
16774            let mut next_offset = offset;
16775            let end_offset = offset + bytes_len;
16776            _next_ordinal_to_read += 1;
16777            if next_offset >= end_offset {
16778                return Ok(());
16779            }
16780
16781            // Decode unknown envelopes for gaps in ordinals.
16782            while _next_ordinal_to_read < 1 {
16783                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16784                _next_ordinal_to_read += 1;
16785                next_offset += envelope_size;
16786            }
16787
16788            let next_out_of_line = decoder.next_out_of_line();
16789            let handles_before = decoder.remaining_handles();
16790            if let Some((inlined, num_bytes, num_handles)) =
16791                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16792            {
16793                let member_inline_size =
16794                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16795                if inlined != (member_inline_size <= 4) {
16796                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16797                }
16798                let inner_offset;
16799                let mut inner_depth = depth.clone();
16800                if inlined {
16801                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16802                    inner_offset = next_offset;
16803                } else {
16804                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16805                    inner_depth.increment()?;
16806                }
16807                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
16808                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
16809                });
16810                fidl::decode!(
16811                    fidl::Rights,
16812                    fdomain_client::fidl::FDomainResourceDialect,
16813                    val_ref,
16814                    decoder,
16815                    inner_offset,
16816                    inner_depth
16817                )?;
16818                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16819                {
16820                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16821                }
16822                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16823                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16824                }
16825            }
16826
16827            next_offset += envelope_size;
16828            _next_ordinal_to_read += 1;
16829            if next_offset >= end_offset {
16830                return Ok(());
16831            }
16832
16833            // Decode unknown envelopes for gaps in ordinals.
16834            while _next_ordinal_to_read < 2 {
16835                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16836                _next_ordinal_to_read += 1;
16837                next_offset += envelope_size;
16838            }
16839
16840            let next_out_of_line = decoder.next_out_of_line();
16841            let handles_before = decoder.remaining_handles();
16842            if let Some((inlined, num_bytes, num_handles)) =
16843                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16844            {
16845                let member_inline_size = <fidl::encoding::Endpoint<
16846                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16847                > as fidl::encoding::TypeMarker>::inline_size(
16848                    decoder.context
16849                );
16850                if inlined != (member_inline_size <= 4) {
16851                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16852                }
16853                let inner_offset;
16854                let mut inner_depth = depth.clone();
16855                if inlined {
16856                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16857                    inner_offset = next_offset;
16858                } else {
16859                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16860                    inner_depth.increment()?;
16861                }
16862                let val_ref = self.token_request.get_or_insert_with(|| {
16863                    fidl::new_empty!(
16864                        fidl::encoding::Endpoint<
16865                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16866                        >,
16867                        fdomain_client::fidl::FDomainResourceDialect
16868                    )
16869                });
16870                fidl::decode!(
16871                    fidl::encoding::Endpoint<
16872                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16873                    >,
16874                    fdomain_client::fidl::FDomainResourceDialect,
16875                    val_ref,
16876                    decoder,
16877                    inner_offset,
16878                    inner_depth
16879                )?;
16880                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16881                {
16882                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16883                }
16884                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16885                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16886                }
16887            }
16888
16889            next_offset += envelope_size;
16890
16891            // Decode the remaining unknown envelopes.
16892            while next_offset < end_offset {
16893                _next_ordinal_to_read += 1;
16894                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16895                next_offset += envelope_size;
16896            }
16897
16898            Ok(())
16899        }
16900    }
16901
16902    impl BufferCollectionTokenGroupCreateChildRequest {
16903        #[inline(always)]
16904        fn max_ordinal_present(&self) -> u64 {
16905            if let Some(_) = self.rights_attenuation_mask {
16906                return 2;
16907            }
16908            if let Some(_) = self.token_request {
16909                return 1;
16910            }
16911            0
16912        }
16913    }
16914
16915    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
16916        type Borrowed<'a> = &'a mut Self;
16917        fn take_or_borrow<'a>(
16918            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16919        ) -> Self::Borrowed<'a> {
16920            value
16921        }
16922    }
16923
16924    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
16925        type Owned = Self;
16926
16927        #[inline(always)]
16928        fn inline_align(_context: fidl::encoding::Context) -> usize {
16929            8
16930        }
16931
16932        #[inline(always)]
16933        fn inline_size(_context: fidl::encoding::Context) -> usize {
16934            16
16935        }
16936    }
16937
16938    unsafe impl
16939        fidl::encoding::Encode<
16940            BufferCollectionTokenGroupCreateChildRequest,
16941            fdomain_client::fidl::FDomainResourceDialect,
16942        > for &mut BufferCollectionTokenGroupCreateChildRequest
16943    {
16944        unsafe fn encode(
16945            self,
16946            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16947            offset: usize,
16948            mut depth: fidl::encoding::Depth,
16949        ) -> fidl::Result<()> {
16950            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
16951            // Vector header
16952            let max_ordinal: u64 = self.max_ordinal_present();
16953            encoder.write_num(max_ordinal, offset);
16954            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16955            // Calling encoder.out_of_line_offset(0) is not allowed.
16956            if max_ordinal == 0 {
16957                return Ok(());
16958            }
16959            depth.increment()?;
16960            let envelope_size = 8;
16961            let bytes_len = max_ordinal as usize * envelope_size;
16962            #[allow(unused_variables)]
16963            let offset = encoder.out_of_line_offset(bytes_len);
16964            let mut _prev_end_offset: usize = 0;
16965            if 1 > max_ordinal {
16966                return Ok(());
16967            }
16968
16969            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16970            // are envelope_size bytes.
16971            let cur_offset: usize = (1 - 1) * envelope_size;
16972
16973            // Zero reserved fields.
16974            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16975
16976            // Safety:
16977            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16978            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16979            //   envelope_size bytes, there is always sufficient room.
16980            fidl::encoding::encode_in_envelope_optional::<
16981                fidl::encoding::Endpoint<
16982                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16983                >,
16984                fdomain_client::fidl::FDomainResourceDialect,
16985            >(
16986                self.token_request.as_mut().map(
16987                    <fidl::encoding::Endpoint<
16988                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16989                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16990                ),
16991                encoder,
16992                offset + cur_offset,
16993                depth,
16994            )?;
16995
16996            _prev_end_offset = cur_offset + envelope_size;
16997            if 2 > max_ordinal {
16998                return Ok(());
16999            }
17000
17001            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17002            // are envelope_size bytes.
17003            let cur_offset: usize = (2 - 1) * envelope_size;
17004
17005            // Zero reserved fields.
17006            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17007
17008            // Safety:
17009            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17010            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17011            //   envelope_size bytes, there is always sufficient room.
17012            fidl::encoding::encode_in_envelope_optional::<
17013                fidl::Rights,
17014                fdomain_client::fidl::FDomainResourceDialect,
17015            >(
17016                self.rights_attenuation_mask
17017                    .as_ref()
17018                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
17019                encoder,
17020                offset + cur_offset,
17021                depth,
17022            )?;
17023
17024            _prev_end_offset = cur_offset + envelope_size;
17025
17026            Ok(())
17027        }
17028    }
17029
17030    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17031        for BufferCollectionTokenGroupCreateChildRequest
17032    {
17033        #[inline(always)]
17034        fn new_empty() -> Self {
17035            Self::default()
17036        }
17037
17038        unsafe fn decode(
17039            &mut self,
17040            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17041            offset: usize,
17042            mut depth: fidl::encoding::Depth,
17043        ) -> fidl::Result<()> {
17044            decoder.debug_check_bounds::<Self>(offset);
17045            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17046                None => return Err(fidl::Error::NotNullable),
17047                Some(len) => len,
17048            };
17049            // Calling decoder.out_of_line_offset(0) is not allowed.
17050            if len == 0 {
17051                return Ok(());
17052            };
17053            depth.increment()?;
17054            let envelope_size = 8;
17055            let bytes_len = len * envelope_size;
17056            let offset = decoder.out_of_line_offset(bytes_len)?;
17057            // Decode the envelope for each type.
17058            let mut _next_ordinal_to_read = 0;
17059            let mut next_offset = offset;
17060            let end_offset = offset + bytes_len;
17061            _next_ordinal_to_read += 1;
17062            if next_offset >= end_offset {
17063                return Ok(());
17064            }
17065
17066            // Decode unknown envelopes for gaps in ordinals.
17067            while _next_ordinal_to_read < 1 {
17068                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17069                _next_ordinal_to_read += 1;
17070                next_offset += envelope_size;
17071            }
17072
17073            let next_out_of_line = decoder.next_out_of_line();
17074            let handles_before = decoder.remaining_handles();
17075            if let Some((inlined, num_bytes, num_handles)) =
17076                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17077            {
17078                let member_inline_size = <fidl::encoding::Endpoint<
17079                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17080                > as fidl::encoding::TypeMarker>::inline_size(
17081                    decoder.context
17082                );
17083                if inlined != (member_inline_size <= 4) {
17084                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17085                }
17086                let inner_offset;
17087                let mut inner_depth = depth.clone();
17088                if inlined {
17089                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17090                    inner_offset = next_offset;
17091                } else {
17092                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17093                    inner_depth.increment()?;
17094                }
17095                let val_ref = self.token_request.get_or_insert_with(|| {
17096                    fidl::new_empty!(
17097                        fidl::encoding::Endpoint<
17098                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17099                        >,
17100                        fdomain_client::fidl::FDomainResourceDialect
17101                    )
17102                });
17103                fidl::decode!(
17104                    fidl::encoding::Endpoint<
17105                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17106                    >,
17107                    fdomain_client::fidl::FDomainResourceDialect,
17108                    val_ref,
17109                    decoder,
17110                    inner_offset,
17111                    inner_depth
17112                )?;
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            _next_ordinal_to_read += 1;
17124            if next_offset >= end_offset {
17125                return Ok(());
17126            }
17127
17128            // Decode unknown envelopes for gaps in ordinals.
17129            while _next_ordinal_to_read < 2 {
17130                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17131                _next_ordinal_to_read += 1;
17132                next_offset += envelope_size;
17133            }
17134
17135            let next_out_of_line = decoder.next_out_of_line();
17136            let handles_before = decoder.remaining_handles();
17137            if let Some((inlined, num_bytes, num_handles)) =
17138                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17139            {
17140                let member_inline_size =
17141                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17142                if inlined != (member_inline_size <= 4) {
17143                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17144                }
17145                let inner_offset;
17146                let mut inner_depth = depth.clone();
17147                if inlined {
17148                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17149                    inner_offset = next_offset;
17150                } else {
17151                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17152                    inner_depth.increment()?;
17153                }
17154                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
17155                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
17156                });
17157                fidl::decode!(
17158                    fidl::Rights,
17159                    fdomain_client::fidl::FDomainResourceDialect,
17160                    val_ref,
17161                    decoder,
17162                    inner_offset,
17163                    inner_depth
17164                )?;
17165                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17166                {
17167                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17168                }
17169                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17170                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17171                }
17172            }
17173
17174            next_offset += envelope_size;
17175
17176            // Decode the remaining unknown envelopes.
17177            while next_offset < end_offset {
17178                _next_ordinal_to_read += 1;
17179                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17180                next_offset += envelope_size;
17181            }
17182
17183            Ok(())
17184        }
17185    }
17186
17187    impl BufferCollectionTokenGroupCreateChildrenSyncResponse {
17188        #[inline(always)]
17189        fn max_ordinal_present(&self) -> u64 {
17190            if let Some(_) = self.tokens {
17191                return 1;
17192            }
17193            0
17194        }
17195    }
17196
17197    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
17198        type Borrowed<'a> = &'a mut Self;
17199        fn take_or_borrow<'a>(
17200            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17201        ) -> Self::Borrowed<'a> {
17202            value
17203        }
17204    }
17205
17206    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
17207        type Owned = Self;
17208
17209        #[inline(always)]
17210        fn inline_align(_context: fidl::encoding::Context) -> usize {
17211            8
17212        }
17213
17214        #[inline(always)]
17215        fn inline_size(_context: fidl::encoding::Context) -> usize {
17216            16
17217        }
17218    }
17219
17220    unsafe impl
17221        fidl::encoding::Encode<
17222            BufferCollectionTokenGroupCreateChildrenSyncResponse,
17223            fdomain_client::fidl::FDomainResourceDialect,
17224        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
17225    {
17226        unsafe fn encode(
17227            self,
17228            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17229            offset: usize,
17230            mut depth: fidl::encoding::Depth,
17231        ) -> fidl::Result<()> {
17232            encoder
17233                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
17234            // Vector header
17235            let max_ordinal: u64 = self.max_ordinal_present();
17236            encoder.write_num(max_ordinal, offset);
17237            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17238            // Calling encoder.out_of_line_offset(0) is not allowed.
17239            if max_ordinal == 0 {
17240                return Ok(());
17241            }
17242            depth.increment()?;
17243            let envelope_size = 8;
17244            let bytes_len = max_ordinal as usize * envelope_size;
17245            #[allow(unused_variables)]
17246            let offset = encoder.out_of_line_offset(bytes_len);
17247            let mut _prev_end_offset: usize = 0;
17248            if 1 > max_ordinal {
17249                return Ok(());
17250            }
17251
17252            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17253            // are envelope_size bytes.
17254            let cur_offset: usize = (1 - 1) * envelope_size;
17255
17256            // Zero reserved fields.
17257            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17258
17259            // Safety:
17260            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17261            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17262            //   envelope_size bytes, there is always sufficient room.
17263            fidl::encoding::encode_in_envelope_optional::<
17264                fidl::encoding::Vector<
17265                    fidl::encoding::Endpoint<
17266                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17267                    >,
17268                    64,
17269                >,
17270                fdomain_client::fidl::FDomainResourceDialect,
17271            >(
17272                self.tokens.as_mut().map(
17273                    <fidl::encoding::Vector<
17274                        fidl::encoding::Endpoint<
17275                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17276                        >,
17277                        64,
17278                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17279                ),
17280                encoder,
17281                offset + cur_offset,
17282                depth,
17283            )?;
17284
17285            _prev_end_offset = cur_offset + envelope_size;
17286
17287            Ok(())
17288        }
17289    }
17290
17291    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17292        for BufferCollectionTokenGroupCreateChildrenSyncResponse
17293    {
17294        #[inline(always)]
17295        fn new_empty() -> Self {
17296            Self::default()
17297        }
17298
17299        unsafe fn decode(
17300            &mut self,
17301            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17302            offset: usize,
17303            mut depth: fidl::encoding::Depth,
17304        ) -> fidl::Result<()> {
17305            decoder.debug_check_bounds::<Self>(offset);
17306            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17307                None => return Err(fidl::Error::NotNullable),
17308                Some(len) => len,
17309            };
17310            // Calling decoder.out_of_line_offset(0) is not allowed.
17311            if len == 0 {
17312                return Ok(());
17313            };
17314            depth.increment()?;
17315            let envelope_size = 8;
17316            let bytes_len = len * envelope_size;
17317            let offset = decoder.out_of_line_offset(bytes_len)?;
17318            // Decode the envelope for each type.
17319            let mut _next_ordinal_to_read = 0;
17320            let mut next_offset = offset;
17321            let end_offset = offset + bytes_len;
17322            _next_ordinal_to_read += 1;
17323            if next_offset >= end_offset {
17324                return Ok(());
17325            }
17326
17327            // Decode unknown envelopes for gaps in ordinals.
17328            while _next_ordinal_to_read < 1 {
17329                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17330                _next_ordinal_to_read += 1;
17331                next_offset += envelope_size;
17332            }
17333
17334            let next_out_of_line = decoder.next_out_of_line();
17335            let handles_before = decoder.remaining_handles();
17336            if let Some((inlined, num_bytes, num_handles)) =
17337                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17338            {
17339                let member_inline_size = <fidl::encoding::Vector<
17340                    fidl::encoding::Endpoint<
17341                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17342                    >,
17343                    64,
17344                > as fidl::encoding::TypeMarker>::inline_size(
17345                    decoder.context
17346                );
17347                if inlined != (member_inline_size <= 4) {
17348                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17349                }
17350                let inner_offset;
17351                let mut inner_depth = depth.clone();
17352                if inlined {
17353                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17354                    inner_offset = next_offset;
17355                } else {
17356                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17357                    inner_depth.increment()?;
17358                }
17359                let val_ref = self.tokens.get_or_insert_with(|| {
17360                    fidl::new_empty!(
17361                        fidl::encoding::Vector<
17362                            fidl::encoding::Endpoint<
17363                                fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17364                            >,
17365                            64,
17366                        >,
17367                        fdomain_client::fidl::FDomainResourceDialect
17368                    )
17369                });
17370                fidl::decode!(
17371                    fidl::encoding::Vector<
17372                        fidl::encoding::Endpoint<
17373                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17374                        >,
17375                        64,
17376                    >,
17377                    fdomain_client::fidl::FDomainResourceDialect,
17378                    val_ref,
17379                    decoder,
17380                    inner_offset,
17381                    inner_depth
17382                )?;
17383                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17384                {
17385                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17386                }
17387                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17388                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17389                }
17390            }
17391
17392            next_offset += envelope_size;
17393
17394            // Decode the remaining unknown envelopes.
17395            while next_offset < end_offset {
17396                _next_ordinal_to_read += 1;
17397                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17398                next_offset += envelope_size;
17399            }
17400
17401            Ok(())
17402        }
17403    }
17404
17405    impl BufferCollectionTokenDuplicateSyncResponse {
17406        #[inline(always)]
17407        fn max_ordinal_present(&self) -> u64 {
17408            if let Some(_) = self.tokens {
17409                return 1;
17410            }
17411            0
17412        }
17413    }
17414
17415    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
17416        type Borrowed<'a> = &'a mut Self;
17417        fn take_or_borrow<'a>(
17418            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17419        ) -> Self::Borrowed<'a> {
17420            value
17421        }
17422    }
17423
17424    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
17425        type Owned = Self;
17426
17427        #[inline(always)]
17428        fn inline_align(_context: fidl::encoding::Context) -> usize {
17429            8
17430        }
17431
17432        #[inline(always)]
17433        fn inline_size(_context: fidl::encoding::Context) -> usize {
17434            16
17435        }
17436    }
17437
17438    unsafe impl
17439        fidl::encoding::Encode<
17440            BufferCollectionTokenDuplicateSyncResponse,
17441            fdomain_client::fidl::FDomainResourceDialect,
17442        > for &mut BufferCollectionTokenDuplicateSyncResponse
17443    {
17444        unsafe fn encode(
17445            self,
17446            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17447            offset: usize,
17448            mut depth: fidl::encoding::Depth,
17449        ) -> fidl::Result<()> {
17450            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
17451            // Vector header
17452            let max_ordinal: u64 = self.max_ordinal_present();
17453            encoder.write_num(max_ordinal, offset);
17454            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17455            // Calling encoder.out_of_line_offset(0) is not allowed.
17456            if max_ordinal == 0 {
17457                return Ok(());
17458            }
17459            depth.increment()?;
17460            let envelope_size = 8;
17461            let bytes_len = max_ordinal as usize * envelope_size;
17462            #[allow(unused_variables)]
17463            let offset = encoder.out_of_line_offset(bytes_len);
17464            let mut _prev_end_offset: usize = 0;
17465            if 1 > max_ordinal {
17466                return Ok(());
17467            }
17468
17469            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17470            // are envelope_size bytes.
17471            let cur_offset: usize = (1 - 1) * envelope_size;
17472
17473            // Zero reserved fields.
17474            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17475
17476            // Safety:
17477            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17478            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17479            //   envelope_size bytes, there is always sufficient room.
17480            fidl::encoding::encode_in_envelope_optional::<
17481                fidl::encoding::Vector<
17482                    fidl::encoding::Endpoint<
17483                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17484                    >,
17485                    64,
17486                >,
17487                fdomain_client::fidl::FDomainResourceDialect,
17488            >(
17489                self.tokens.as_mut().map(
17490                    <fidl::encoding::Vector<
17491                        fidl::encoding::Endpoint<
17492                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17493                        >,
17494                        64,
17495                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17496                ),
17497                encoder,
17498                offset + cur_offset,
17499                depth,
17500            )?;
17501
17502            _prev_end_offset = cur_offset + envelope_size;
17503
17504            Ok(())
17505        }
17506    }
17507
17508    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17509        for BufferCollectionTokenDuplicateSyncResponse
17510    {
17511        #[inline(always)]
17512        fn new_empty() -> Self {
17513            Self::default()
17514        }
17515
17516        unsafe fn decode(
17517            &mut self,
17518            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17519            offset: usize,
17520            mut depth: fidl::encoding::Depth,
17521        ) -> fidl::Result<()> {
17522            decoder.debug_check_bounds::<Self>(offset);
17523            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17524                None => return Err(fidl::Error::NotNullable),
17525                Some(len) => len,
17526            };
17527            // Calling decoder.out_of_line_offset(0) is not allowed.
17528            if len == 0 {
17529                return Ok(());
17530            };
17531            depth.increment()?;
17532            let envelope_size = 8;
17533            let bytes_len = len * envelope_size;
17534            let offset = decoder.out_of_line_offset(bytes_len)?;
17535            // Decode the envelope for each type.
17536            let mut _next_ordinal_to_read = 0;
17537            let mut next_offset = offset;
17538            let end_offset = offset + bytes_len;
17539            _next_ordinal_to_read += 1;
17540            if next_offset >= end_offset {
17541                return Ok(());
17542            }
17543
17544            // Decode unknown envelopes for gaps in ordinals.
17545            while _next_ordinal_to_read < 1 {
17546                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17547                _next_ordinal_to_read += 1;
17548                next_offset += envelope_size;
17549            }
17550
17551            let next_out_of_line = decoder.next_out_of_line();
17552            let handles_before = decoder.remaining_handles();
17553            if let Some((inlined, num_bytes, num_handles)) =
17554                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17555            {
17556                let member_inline_size = <fidl::encoding::Vector<
17557                    fidl::encoding::Endpoint<
17558                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17559                    >,
17560                    64,
17561                > as fidl::encoding::TypeMarker>::inline_size(
17562                    decoder.context
17563                );
17564                if inlined != (member_inline_size <= 4) {
17565                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17566                }
17567                let inner_offset;
17568                let mut inner_depth = depth.clone();
17569                if inlined {
17570                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17571                    inner_offset = next_offset;
17572                } else {
17573                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17574                    inner_depth.increment()?;
17575                }
17576                let val_ref = self.tokens.get_or_insert_with(|| {
17577                    fidl::new_empty!(
17578                        fidl::encoding::Vector<
17579                            fidl::encoding::Endpoint<
17580                                fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17581                            >,
17582                            64,
17583                        >,
17584                        fdomain_client::fidl::FDomainResourceDialect
17585                    )
17586                });
17587                fidl::decode!(
17588                    fidl::encoding::Vector<
17589                        fidl::encoding::Endpoint<
17590                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17591                        >,
17592                        64,
17593                    >,
17594                    fdomain_client::fidl::FDomainResourceDialect,
17595                    val_ref,
17596                    decoder,
17597                    inner_offset,
17598                    inner_depth
17599                )?;
17600                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17601                {
17602                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17603                }
17604                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17605                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17606                }
17607            }
17608
17609            next_offset += envelope_size;
17610
17611            // Decode the remaining unknown envelopes.
17612            while next_offset < end_offset {
17613                _next_ordinal_to_read += 1;
17614                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17615                next_offset += envelope_size;
17616            }
17617
17618            Ok(())
17619        }
17620    }
17621
17622    impl BufferCollectionWaitForAllBuffersAllocatedResponse {
17623        #[inline(always)]
17624        fn max_ordinal_present(&self) -> u64 {
17625            if let Some(_) = self.buffer_collection_info {
17626                return 1;
17627            }
17628            0
17629        }
17630    }
17631
17632    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForAllBuffersAllocatedResponse {
17633        type Borrowed<'a> = &'a mut Self;
17634        fn take_or_borrow<'a>(
17635            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17636        ) -> Self::Borrowed<'a> {
17637            value
17638        }
17639    }
17640
17641    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForAllBuffersAllocatedResponse {
17642        type Owned = Self;
17643
17644        #[inline(always)]
17645        fn inline_align(_context: fidl::encoding::Context) -> usize {
17646            8
17647        }
17648
17649        #[inline(always)]
17650        fn inline_size(_context: fidl::encoding::Context) -> usize {
17651            16
17652        }
17653    }
17654
17655    unsafe impl
17656        fidl::encoding::Encode<
17657            BufferCollectionWaitForAllBuffersAllocatedResponse,
17658            fdomain_client::fidl::FDomainResourceDialect,
17659        > for &mut BufferCollectionWaitForAllBuffersAllocatedResponse
17660    {
17661        unsafe fn encode(
17662            self,
17663            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17664            offset: usize,
17665            mut depth: fidl::encoding::Depth,
17666        ) -> fidl::Result<()> {
17667            encoder
17668                .debug_check_bounds::<BufferCollectionWaitForAllBuffersAllocatedResponse>(offset);
17669            // Vector header
17670            let max_ordinal: u64 = self.max_ordinal_present();
17671            encoder.write_num(max_ordinal, offset);
17672            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17673            // Calling encoder.out_of_line_offset(0) is not allowed.
17674            if max_ordinal == 0 {
17675                return Ok(());
17676            }
17677            depth.increment()?;
17678            let envelope_size = 8;
17679            let bytes_len = max_ordinal as usize * envelope_size;
17680            #[allow(unused_variables)]
17681            let offset = encoder.out_of_line_offset(bytes_len);
17682            let mut _prev_end_offset: usize = 0;
17683            if 1 > max_ordinal {
17684                return Ok(());
17685            }
17686
17687            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17688            // are envelope_size bytes.
17689            let cur_offset: usize = (1 - 1) * envelope_size;
17690
17691            // Zero reserved fields.
17692            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17693
17694            // Safety:
17695            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17696            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17697            //   envelope_size bytes, there is always sufficient room.
17698            fidl::encoding::encode_in_envelope_optional::<
17699                BufferCollectionInfo,
17700                fdomain_client::fidl::FDomainResourceDialect,
17701            >(
17702                self.buffer_collection_info.as_mut().map(
17703                    <BufferCollectionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17704                ),
17705                encoder,
17706                offset + cur_offset,
17707                depth,
17708            )?;
17709
17710            _prev_end_offset = cur_offset + envelope_size;
17711
17712            Ok(())
17713        }
17714    }
17715
17716    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17717        for BufferCollectionWaitForAllBuffersAllocatedResponse
17718    {
17719        #[inline(always)]
17720        fn new_empty() -> Self {
17721            Self::default()
17722        }
17723
17724        unsafe fn decode(
17725            &mut self,
17726            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17727            offset: usize,
17728            mut depth: fidl::encoding::Depth,
17729        ) -> fidl::Result<()> {
17730            decoder.debug_check_bounds::<Self>(offset);
17731            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17732                None => return Err(fidl::Error::NotNullable),
17733                Some(len) => len,
17734            };
17735            // Calling decoder.out_of_line_offset(0) is not allowed.
17736            if len == 0 {
17737                return Ok(());
17738            };
17739            depth.increment()?;
17740            let envelope_size = 8;
17741            let bytes_len = len * envelope_size;
17742            let offset = decoder.out_of_line_offset(bytes_len)?;
17743            // Decode the envelope for each type.
17744            let mut _next_ordinal_to_read = 0;
17745            let mut next_offset = offset;
17746            let end_offset = offset + bytes_len;
17747            _next_ordinal_to_read += 1;
17748            if next_offset >= end_offset {
17749                return Ok(());
17750            }
17751
17752            // Decode unknown envelopes for gaps in ordinals.
17753            while _next_ordinal_to_read < 1 {
17754                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17755                _next_ordinal_to_read += 1;
17756                next_offset += envelope_size;
17757            }
17758
17759            let next_out_of_line = decoder.next_out_of_line();
17760            let handles_before = decoder.remaining_handles();
17761            if let Some((inlined, num_bytes, num_handles)) =
17762                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17763            {
17764                let member_inline_size =
17765                    <BufferCollectionInfo as fidl::encoding::TypeMarker>::inline_size(
17766                        decoder.context,
17767                    );
17768                if inlined != (member_inline_size <= 4) {
17769                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17770                }
17771                let inner_offset;
17772                let mut inner_depth = depth.clone();
17773                if inlined {
17774                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17775                    inner_offset = next_offset;
17776                } else {
17777                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17778                    inner_depth.increment()?;
17779                }
17780                let val_ref = self.buffer_collection_info.get_or_insert_with(|| {
17781                    fidl::new_empty!(
17782                        BufferCollectionInfo,
17783                        fdomain_client::fidl::FDomainResourceDialect
17784                    )
17785                });
17786                fidl::decode!(
17787                    BufferCollectionInfo,
17788                    fdomain_client::fidl::FDomainResourceDialect,
17789                    val_ref,
17790                    decoder,
17791                    inner_offset,
17792                    inner_depth
17793                )?;
17794                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17795                {
17796                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17797                }
17798                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17799                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17800                }
17801            }
17802
17803            next_offset += envelope_size;
17804
17805            // Decode the remaining unknown envelopes.
17806            while next_offset < end_offset {
17807                _next_ordinal_to_read += 1;
17808                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17809                next_offset += envelope_size;
17810            }
17811
17812            Ok(())
17813        }
17814    }
17815
17816    impl NodeAttachNodeTrackingRequest {
17817        #[inline(always)]
17818        fn max_ordinal_present(&self) -> u64 {
17819            if let Some(_) = self.server_end {
17820                return 1;
17821            }
17822            0
17823        }
17824    }
17825
17826    impl fidl::encoding::ResourceTypeMarker for NodeAttachNodeTrackingRequest {
17827        type Borrowed<'a> = &'a mut Self;
17828        fn take_or_borrow<'a>(
17829            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17830        ) -> Self::Borrowed<'a> {
17831            value
17832        }
17833    }
17834
17835    unsafe impl fidl::encoding::TypeMarker for NodeAttachNodeTrackingRequest {
17836        type Owned = Self;
17837
17838        #[inline(always)]
17839        fn inline_align(_context: fidl::encoding::Context) -> usize {
17840            8
17841        }
17842
17843        #[inline(always)]
17844        fn inline_size(_context: fidl::encoding::Context) -> usize {
17845            16
17846        }
17847    }
17848
17849    unsafe impl
17850        fidl::encoding::Encode<
17851            NodeAttachNodeTrackingRequest,
17852            fdomain_client::fidl::FDomainResourceDialect,
17853        > for &mut NodeAttachNodeTrackingRequest
17854    {
17855        unsafe fn encode(
17856            self,
17857            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17858            offset: usize,
17859            mut depth: fidl::encoding::Depth,
17860        ) -> fidl::Result<()> {
17861            encoder.debug_check_bounds::<NodeAttachNodeTrackingRequest>(offset);
17862            // Vector header
17863            let max_ordinal: u64 = self.max_ordinal_present();
17864            encoder.write_num(max_ordinal, offset);
17865            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17866            // Calling encoder.out_of_line_offset(0) is not allowed.
17867            if max_ordinal == 0 {
17868                return Ok(());
17869            }
17870            depth.increment()?;
17871            let envelope_size = 8;
17872            let bytes_len = max_ordinal as usize * envelope_size;
17873            #[allow(unused_variables)]
17874            let offset = encoder.out_of_line_offset(bytes_len);
17875            let mut _prev_end_offset: usize = 0;
17876            if 1 > max_ordinal {
17877                return Ok(());
17878            }
17879
17880            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17881            // are envelope_size bytes.
17882            let cur_offset: usize = (1 - 1) * envelope_size;
17883
17884            // Zero reserved fields.
17885            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17886
17887            // Safety:
17888            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17889            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17890            //   envelope_size bytes, there is always sufficient room.
17891            fidl::encoding::encode_in_envelope_optional::<
17892                fidl::encoding::HandleType<
17893                    fdomain_client::EventPair,
17894                    { fidl::ObjectType::EVENTPAIR.into_raw() },
17895                    2147483648,
17896                >,
17897                fdomain_client::fidl::FDomainResourceDialect,
17898            >(
17899                self.server_end.as_mut().map(
17900                    <fidl::encoding::HandleType<
17901                        fdomain_client::EventPair,
17902                        { fidl::ObjectType::EVENTPAIR.into_raw() },
17903                        2147483648,
17904                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17905                ),
17906                encoder,
17907                offset + cur_offset,
17908                depth,
17909            )?;
17910
17911            _prev_end_offset = cur_offset + envelope_size;
17912
17913            Ok(())
17914        }
17915    }
17916
17917    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17918        for NodeAttachNodeTrackingRequest
17919    {
17920        #[inline(always)]
17921        fn new_empty() -> Self {
17922            Self::default()
17923        }
17924
17925        unsafe fn decode(
17926            &mut self,
17927            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17928            offset: usize,
17929            mut depth: fidl::encoding::Depth,
17930        ) -> fidl::Result<()> {
17931            decoder.debug_check_bounds::<Self>(offset);
17932            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17933                None => return Err(fidl::Error::NotNullable),
17934                Some(len) => len,
17935            };
17936            // Calling decoder.out_of_line_offset(0) is not allowed.
17937            if len == 0 {
17938                return Ok(());
17939            };
17940            depth.increment()?;
17941            let envelope_size = 8;
17942            let bytes_len = len * envelope_size;
17943            let offset = decoder.out_of_line_offset(bytes_len)?;
17944            // Decode the envelope for each type.
17945            let mut _next_ordinal_to_read = 0;
17946            let mut next_offset = offset;
17947            let end_offset = offset + bytes_len;
17948            _next_ordinal_to_read += 1;
17949            if next_offset >= end_offset {
17950                return Ok(());
17951            }
17952
17953            // Decode unknown envelopes for gaps in ordinals.
17954            while _next_ordinal_to_read < 1 {
17955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17956                _next_ordinal_to_read += 1;
17957                next_offset += envelope_size;
17958            }
17959
17960            let next_out_of_line = decoder.next_out_of_line();
17961            let handles_before = decoder.remaining_handles();
17962            if let Some((inlined, num_bytes, num_handles)) =
17963                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17964            {
17965                let member_inline_size = <fidl::encoding::HandleType<
17966                    fdomain_client::EventPair,
17967                    { fidl::ObjectType::EVENTPAIR.into_raw() },
17968                    2147483648,
17969                > as fidl::encoding::TypeMarker>::inline_size(
17970                    decoder.context
17971                );
17972                if inlined != (member_inline_size <= 4) {
17973                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17974                }
17975                let inner_offset;
17976                let mut inner_depth = depth.clone();
17977                if inlined {
17978                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17979                    inner_offset = next_offset;
17980                } else {
17981                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17982                    inner_depth.increment()?;
17983                }
17984                let val_ref =
17985                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));
17986                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)?;
17987                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17988                {
17989                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17990                }
17991                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17992                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17993                }
17994            }
17995
17996            next_offset += envelope_size;
17997
17998            // Decode the remaining unknown envelopes.
17999            while next_offset < end_offset {
18000                _next_ordinal_to_read += 1;
18001                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18002                next_offset += envelope_size;
18003            }
18004
18005            Ok(())
18006        }
18007    }
18008
18009    impl NodeIsAlternateForRequest {
18010        #[inline(always)]
18011        fn max_ordinal_present(&self) -> u64 {
18012            if let Some(_) = self.node_ref {
18013                return 1;
18014            }
18015            0
18016        }
18017    }
18018
18019    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
18020        type Borrowed<'a> = &'a mut Self;
18021        fn take_or_borrow<'a>(
18022            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18023        ) -> Self::Borrowed<'a> {
18024            value
18025        }
18026    }
18027
18028    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
18029        type Owned = Self;
18030
18031        #[inline(always)]
18032        fn inline_align(_context: fidl::encoding::Context) -> usize {
18033            8
18034        }
18035
18036        #[inline(always)]
18037        fn inline_size(_context: fidl::encoding::Context) -> usize {
18038            16
18039        }
18040    }
18041
18042    unsafe impl
18043        fidl::encoding::Encode<
18044            NodeIsAlternateForRequest,
18045            fdomain_client::fidl::FDomainResourceDialect,
18046        > for &mut NodeIsAlternateForRequest
18047    {
18048        unsafe fn encode(
18049            self,
18050            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18051            offset: usize,
18052            mut depth: fidl::encoding::Depth,
18053        ) -> fidl::Result<()> {
18054            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
18055            // Vector header
18056            let max_ordinal: u64 = self.max_ordinal_present();
18057            encoder.write_num(max_ordinal, offset);
18058            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18059            // Calling encoder.out_of_line_offset(0) is not allowed.
18060            if max_ordinal == 0 {
18061                return Ok(());
18062            }
18063            depth.increment()?;
18064            let envelope_size = 8;
18065            let bytes_len = max_ordinal as usize * envelope_size;
18066            #[allow(unused_variables)]
18067            let offset = encoder.out_of_line_offset(bytes_len);
18068            let mut _prev_end_offset: usize = 0;
18069            if 1 > max_ordinal {
18070                return Ok(());
18071            }
18072
18073            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18074            // are envelope_size bytes.
18075            let cur_offset: usize = (1 - 1) * envelope_size;
18076
18077            // Zero reserved fields.
18078            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18079
18080            // Safety:
18081            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18082            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18083            //   envelope_size bytes, there is always sufficient room.
18084            fidl::encoding::encode_in_envelope_optional::<
18085                fidl::encoding::HandleType<
18086                    fdomain_client::Event,
18087                    { fidl::ObjectType::EVENT.into_raw() },
18088                    2147483648,
18089                >,
18090                fdomain_client::fidl::FDomainResourceDialect,
18091            >(
18092                self.node_ref.as_mut().map(
18093                    <fidl::encoding::HandleType<
18094                        fdomain_client::Event,
18095                        { fidl::ObjectType::EVENT.into_raw() },
18096                        2147483648,
18097                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18098                ),
18099                encoder,
18100                offset + cur_offset,
18101                depth,
18102            )?;
18103
18104            _prev_end_offset = cur_offset + envelope_size;
18105
18106            Ok(())
18107        }
18108    }
18109
18110    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18111        for NodeIsAlternateForRequest
18112    {
18113        #[inline(always)]
18114        fn new_empty() -> Self {
18115            Self::default()
18116        }
18117
18118        unsafe fn decode(
18119            &mut self,
18120            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18121            offset: usize,
18122            mut depth: fidl::encoding::Depth,
18123        ) -> fidl::Result<()> {
18124            decoder.debug_check_bounds::<Self>(offset);
18125            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18126                None => return Err(fidl::Error::NotNullable),
18127                Some(len) => len,
18128            };
18129            // Calling decoder.out_of_line_offset(0) is not allowed.
18130            if len == 0 {
18131                return Ok(());
18132            };
18133            depth.increment()?;
18134            let envelope_size = 8;
18135            let bytes_len = len * envelope_size;
18136            let offset = decoder.out_of_line_offset(bytes_len)?;
18137            // Decode the envelope for each type.
18138            let mut _next_ordinal_to_read = 0;
18139            let mut next_offset = offset;
18140            let end_offset = offset + bytes_len;
18141            _next_ordinal_to_read += 1;
18142            if next_offset >= end_offset {
18143                return Ok(());
18144            }
18145
18146            // Decode unknown envelopes for gaps in ordinals.
18147            while _next_ordinal_to_read < 1 {
18148                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18149                _next_ordinal_to_read += 1;
18150                next_offset += envelope_size;
18151            }
18152
18153            let next_out_of_line = decoder.next_out_of_line();
18154            let handles_before = decoder.remaining_handles();
18155            if let Some((inlined, num_bytes, num_handles)) =
18156                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18157            {
18158                let member_inline_size = <fidl::encoding::HandleType<
18159                    fdomain_client::Event,
18160                    { fidl::ObjectType::EVENT.into_raw() },
18161                    2147483648,
18162                > as fidl::encoding::TypeMarker>::inline_size(
18163                    decoder.context
18164                );
18165                if inlined != (member_inline_size <= 4) {
18166                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18167                }
18168                let inner_offset;
18169                let mut inner_depth = depth.clone();
18170                if inlined {
18171                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18172                    inner_offset = next_offset;
18173                } else {
18174                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18175                    inner_depth.increment()?;
18176                }
18177                let val_ref =
18178                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));
18179                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)?;
18180                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18181                {
18182                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18183                }
18184                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18185                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18186                }
18187            }
18188
18189            next_offset += envelope_size;
18190
18191            // Decode the remaining unknown envelopes.
18192            while next_offset < end_offset {
18193                _next_ordinal_to_read += 1;
18194                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18195                next_offset += envelope_size;
18196            }
18197
18198            Ok(())
18199        }
18200    }
18201
18202    impl NodeSetWeakOkRequest {
18203        #[inline(always)]
18204        fn max_ordinal_present(&self) -> u64 {
18205            if let Some(_) = self.for_child_nodes_also {
18206                return 1;
18207            }
18208            0
18209        }
18210    }
18211
18212    impl fidl::encoding::ResourceTypeMarker for NodeSetWeakOkRequest {
18213        type Borrowed<'a> = &'a mut Self;
18214        fn take_or_borrow<'a>(
18215            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18216        ) -> Self::Borrowed<'a> {
18217            value
18218        }
18219    }
18220
18221    unsafe impl fidl::encoding::TypeMarker for NodeSetWeakOkRequest {
18222        type Owned = Self;
18223
18224        #[inline(always)]
18225        fn inline_align(_context: fidl::encoding::Context) -> usize {
18226            8
18227        }
18228
18229        #[inline(always)]
18230        fn inline_size(_context: fidl::encoding::Context) -> usize {
18231            16
18232        }
18233    }
18234
18235    unsafe impl
18236        fidl::encoding::Encode<NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect>
18237        for &mut NodeSetWeakOkRequest
18238    {
18239        unsafe fn encode(
18240            self,
18241            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18242            offset: usize,
18243            mut depth: fidl::encoding::Depth,
18244        ) -> fidl::Result<()> {
18245            encoder.debug_check_bounds::<NodeSetWeakOkRequest>(offset);
18246            // Vector header
18247            let max_ordinal: u64 = self.max_ordinal_present();
18248            encoder.write_num(max_ordinal, offset);
18249            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18250            // Calling encoder.out_of_line_offset(0) is not allowed.
18251            if max_ordinal == 0 {
18252                return Ok(());
18253            }
18254            depth.increment()?;
18255            let envelope_size = 8;
18256            let bytes_len = max_ordinal as usize * envelope_size;
18257            #[allow(unused_variables)]
18258            let offset = encoder.out_of_line_offset(bytes_len);
18259            let mut _prev_end_offset: usize = 0;
18260            if 1 > max_ordinal {
18261                return Ok(());
18262            }
18263
18264            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18265            // are envelope_size bytes.
18266            let cur_offset: usize = (1 - 1) * envelope_size;
18267
18268            // Zero reserved fields.
18269            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18270
18271            // Safety:
18272            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18273            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18274            //   envelope_size bytes, there is always sufficient room.
18275            fidl::encoding::encode_in_envelope_optional::<
18276                bool,
18277                fdomain_client::fidl::FDomainResourceDialect,
18278            >(
18279                self.for_child_nodes_also
18280                    .as_ref()
18281                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
18282                encoder,
18283                offset + cur_offset,
18284                depth,
18285            )?;
18286
18287            _prev_end_offset = cur_offset + envelope_size;
18288
18289            Ok(())
18290        }
18291    }
18292
18293    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18294        for NodeSetWeakOkRequest
18295    {
18296        #[inline(always)]
18297        fn new_empty() -> Self {
18298            Self::default()
18299        }
18300
18301        unsafe fn decode(
18302            &mut self,
18303            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18304            offset: usize,
18305            mut depth: fidl::encoding::Depth,
18306        ) -> fidl::Result<()> {
18307            decoder.debug_check_bounds::<Self>(offset);
18308            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18309                None => return Err(fidl::Error::NotNullable),
18310                Some(len) => len,
18311            };
18312            // Calling decoder.out_of_line_offset(0) is not allowed.
18313            if len == 0 {
18314                return Ok(());
18315            };
18316            depth.increment()?;
18317            let envelope_size = 8;
18318            let bytes_len = len * envelope_size;
18319            let offset = decoder.out_of_line_offset(bytes_len)?;
18320            // Decode the envelope for each type.
18321            let mut _next_ordinal_to_read = 0;
18322            let mut next_offset = offset;
18323            let end_offset = offset + bytes_len;
18324            _next_ordinal_to_read += 1;
18325            if next_offset >= end_offset {
18326                return Ok(());
18327            }
18328
18329            // Decode unknown envelopes for gaps in ordinals.
18330            while _next_ordinal_to_read < 1 {
18331                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18332                _next_ordinal_to_read += 1;
18333                next_offset += envelope_size;
18334            }
18335
18336            let next_out_of_line = decoder.next_out_of_line();
18337            let handles_before = decoder.remaining_handles();
18338            if let Some((inlined, num_bytes, num_handles)) =
18339                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18340            {
18341                let member_inline_size =
18342                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
18343                if inlined != (member_inline_size <= 4) {
18344                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18345                }
18346                let inner_offset;
18347                let mut inner_depth = depth.clone();
18348                if inlined {
18349                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18350                    inner_offset = next_offset;
18351                } else {
18352                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18353                    inner_depth.increment()?;
18354                }
18355                let val_ref = self.for_child_nodes_also.get_or_insert_with(|| {
18356                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
18357                });
18358                fidl::decode!(
18359                    bool,
18360                    fdomain_client::fidl::FDomainResourceDialect,
18361                    val_ref,
18362                    decoder,
18363                    inner_offset,
18364                    inner_depth
18365                )?;
18366                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18367                {
18368                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18369                }
18370                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18371                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18372                }
18373            }
18374
18375            next_offset += envelope_size;
18376
18377            // Decode the remaining unknown envelopes.
18378            while next_offset < end_offset {
18379                _next_ordinal_to_read += 1;
18380                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18381                next_offset += envelope_size;
18382            }
18383
18384            Ok(())
18385        }
18386    }
18387
18388    impl NodeGetNodeRefResponse {
18389        #[inline(always)]
18390        fn max_ordinal_present(&self) -> u64 {
18391            if let Some(_) = self.node_ref {
18392                return 1;
18393            }
18394            0
18395        }
18396    }
18397
18398    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
18399        type Borrowed<'a> = &'a mut Self;
18400        fn take_or_borrow<'a>(
18401            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18402        ) -> Self::Borrowed<'a> {
18403            value
18404        }
18405    }
18406
18407    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
18408        type Owned = Self;
18409
18410        #[inline(always)]
18411        fn inline_align(_context: fidl::encoding::Context) -> usize {
18412            8
18413        }
18414
18415        #[inline(always)]
18416        fn inline_size(_context: fidl::encoding::Context) -> usize {
18417            16
18418        }
18419    }
18420
18421    unsafe impl
18422        fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
18423        for &mut NodeGetNodeRefResponse
18424    {
18425        unsafe fn encode(
18426            self,
18427            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18428            offset: usize,
18429            mut depth: fidl::encoding::Depth,
18430        ) -> fidl::Result<()> {
18431            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
18432            // Vector header
18433            let max_ordinal: u64 = self.max_ordinal_present();
18434            encoder.write_num(max_ordinal, offset);
18435            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18436            // Calling encoder.out_of_line_offset(0) is not allowed.
18437            if max_ordinal == 0 {
18438                return Ok(());
18439            }
18440            depth.increment()?;
18441            let envelope_size = 8;
18442            let bytes_len = max_ordinal as usize * envelope_size;
18443            #[allow(unused_variables)]
18444            let offset = encoder.out_of_line_offset(bytes_len);
18445            let mut _prev_end_offset: usize = 0;
18446            if 1 > max_ordinal {
18447                return Ok(());
18448            }
18449
18450            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18451            // are envelope_size bytes.
18452            let cur_offset: usize = (1 - 1) * envelope_size;
18453
18454            // Zero reserved fields.
18455            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18456
18457            // Safety:
18458            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18459            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18460            //   envelope_size bytes, there is always sufficient room.
18461            fidl::encoding::encode_in_envelope_optional::<
18462                fidl::encoding::HandleType<
18463                    fdomain_client::Event,
18464                    { fidl::ObjectType::EVENT.into_raw() },
18465                    2147483648,
18466                >,
18467                fdomain_client::fidl::FDomainResourceDialect,
18468            >(
18469                self.node_ref.as_mut().map(
18470                    <fidl::encoding::HandleType<
18471                        fdomain_client::Event,
18472                        { fidl::ObjectType::EVENT.into_raw() },
18473                        2147483648,
18474                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18475                ),
18476                encoder,
18477                offset + cur_offset,
18478                depth,
18479            )?;
18480
18481            _prev_end_offset = cur_offset + envelope_size;
18482
18483            Ok(())
18484        }
18485    }
18486
18487    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18488        for NodeGetNodeRefResponse
18489    {
18490        #[inline(always)]
18491        fn new_empty() -> Self {
18492            Self::default()
18493        }
18494
18495        unsafe fn decode(
18496            &mut self,
18497            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18498            offset: usize,
18499            mut depth: fidl::encoding::Depth,
18500        ) -> fidl::Result<()> {
18501            decoder.debug_check_bounds::<Self>(offset);
18502            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18503                None => return Err(fidl::Error::NotNullable),
18504                Some(len) => len,
18505            };
18506            // Calling decoder.out_of_line_offset(0) is not allowed.
18507            if len == 0 {
18508                return Ok(());
18509            };
18510            depth.increment()?;
18511            let envelope_size = 8;
18512            let bytes_len = len * envelope_size;
18513            let offset = decoder.out_of_line_offset(bytes_len)?;
18514            // Decode the envelope for each type.
18515            let mut _next_ordinal_to_read = 0;
18516            let mut next_offset = offset;
18517            let end_offset = offset + bytes_len;
18518            _next_ordinal_to_read += 1;
18519            if next_offset >= end_offset {
18520                return Ok(());
18521            }
18522
18523            // Decode unknown envelopes for gaps in ordinals.
18524            while _next_ordinal_to_read < 1 {
18525                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18526                _next_ordinal_to_read += 1;
18527                next_offset += envelope_size;
18528            }
18529
18530            let next_out_of_line = decoder.next_out_of_line();
18531            let handles_before = decoder.remaining_handles();
18532            if let Some((inlined, num_bytes, num_handles)) =
18533                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18534            {
18535                let member_inline_size = <fidl::encoding::HandleType<
18536                    fdomain_client::Event,
18537                    { fidl::ObjectType::EVENT.into_raw() },
18538                    2147483648,
18539                > as fidl::encoding::TypeMarker>::inline_size(
18540                    decoder.context
18541                );
18542                if inlined != (member_inline_size <= 4) {
18543                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18544                }
18545                let inner_offset;
18546                let mut inner_depth = depth.clone();
18547                if inlined {
18548                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18549                    inner_offset = next_offset;
18550                } else {
18551                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18552                    inner_depth.increment()?;
18553                }
18554                let val_ref =
18555                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));
18556                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)?;
18557                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18558                {
18559                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18560                }
18561                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18562                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18563                }
18564            }
18565
18566            next_offset += envelope_size;
18567
18568            // Decode the remaining unknown envelopes.
18569            while next_offset < end_offset {
18570                _next_ordinal_to_read += 1;
18571                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18572                next_offset += envelope_size;
18573            }
18574
18575            Ok(())
18576        }
18577    }
18578
18579    impl VmoBuffer {
18580        #[inline(always)]
18581        fn max_ordinal_present(&self) -> u64 {
18582            if let Some(_) = self.close_weak_asap {
18583                return 3;
18584            }
18585            if let Some(_) = self.vmo_usable_start {
18586                return 2;
18587            }
18588            if let Some(_) = self.vmo {
18589                return 1;
18590            }
18591            0
18592        }
18593    }
18594
18595    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
18596        type Borrowed<'a> = &'a mut Self;
18597        fn take_or_borrow<'a>(
18598            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18599        ) -> Self::Borrowed<'a> {
18600            value
18601        }
18602    }
18603
18604    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
18605        type Owned = Self;
18606
18607        #[inline(always)]
18608        fn inline_align(_context: fidl::encoding::Context) -> usize {
18609            8
18610        }
18611
18612        #[inline(always)]
18613        fn inline_size(_context: fidl::encoding::Context) -> usize {
18614            16
18615        }
18616    }
18617
18618    unsafe impl fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>
18619        for &mut VmoBuffer
18620    {
18621        unsafe fn encode(
18622            self,
18623            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18624            offset: usize,
18625            mut depth: fidl::encoding::Depth,
18626        ) -> fidl::Result<()> {
18627            encoder.debug_check_bounds::<VmoBuffer>(offset);
18628            // Vector header
18629            let max_ordinal: u64 = self.max_ordinal_present();
18630            encoder.write_num(max_ordinal, offset);
18631            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18632            // Calling encoder.out_of_line_offset(0) is not allowed.
18633            if max_ordinal == 0 {
18634                return Ok(());
18635            }
18636            depth.increment()?;
18637            let envelope_size = 8;
18638            let bytes_len = max_ordinal as usize * envelope_size;
18639            #[allow(unused_variables)]
18640            let offset = encoder.out_of_line_offset(bytes_len);
18641            let mut _prev_end_offset: usize = 0;
18642            if 1 > max_ordinal {
18643                return Ok(());
18644            }
18645
18646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18647            // are envelope_size bytes.
18648            let cur_offset: usize = (1 - 1) * envelope_size;
18649
18650            // Zero reserved fields.
18651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18652
18653            // Safety:
18654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18656            //   envelope_size bytes, there is always sufficient room.
18657            fidl::encoding::encode_in_envelope_optional::<
18658                fidl::encoding::HandleType<
18659                    fdomain_client::Vmo,
18660                    { fidl::ObjectType::VMO.into_raw() },
18661                    2147483648,
18662                >,
18663                fdomain_client::fidl::FDomainResourceDialect,
18664            >(
18665                self.vmo.as_mut().map(
18666                    <fidl::encoding::HandleType<
18667                        fdomain_client::Vmo,
18668                        { fidl::ObjectType::VMO.into_raw() },
18669                        2147483648,
18670                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18671                ),
18672                encoder,
18673                offset + cur_offset,
18674                depth,
18675            )?;
18676
18677            _prev_end_offset = cur_offset + envelope_size;
18678            if 2 > max_ordinal {
18679                return Ok(());
18680            }
18681
18682            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18683            // are envelope_size bytes.
18684            let cur_offset: usize = (2 - 1) * envelope_size;
18685
18686            // Zero reserved fields.
18687            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18688
18689            // Safety:
18690            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18691            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18692            //   envelope_size bytes, there is always sufficient room.
18693            fidl::encoding::encode_in_envelope_optional::<
18694                u64,
18695                fdomain_client::fidl::FDomainResourceDialect,
18696            >(
18697                self.vmo_usable_start
18698                    .as_ref()
18699                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
18700                encoder,
18701                offset + cur_offset,
18702                depth,
18703            )?;
18704
18705            _prev_end_offset = cur_offset + envelope_size;
18706            if 3 > max_ordinal {
18707                return Ok(());
18708            }
18709
18710            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18711            // are envelope_size bytes.
18712            let cur_offset: usize = (3 - 1) * envelope_size;
18713
18714            // Zero reserved fields.
18715            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18716
18717            // Safety:
18718            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18719            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18720            //   envelope_size bytes, there is always sufficient room.
18721            fidl::encoding::encode_in_envelope_optional::<
18722                fidl::encoding::HandleType<
18723                    fdomain_client::EventPair,
18724                    { fidl::ObjectType::EVENTPAIR.into_raw() },
18725                    2147483648,
18726                >,
18727                fdomain_client::fidl::FDomainResourceDialect,
18728            >(
18729                self.close_weak_asap.as_mut().map(
18730                    <fidl::encoding::HandleType<
18731                        fdomain_client::EventPair,
18732                        { fidl::ObjectType::EVENTPAIR.into_raw() },
18733                        2147483648,
18734                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18735                ),
18736                encoder,
18737                offset + cur_offset,
18738                depth,
18739            )?;
18740
18741            _prev_end_offset = cur_offset + envelope_size;
18742
18743            Ok(())
18744        }
18745    }
18746
18747    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {
18748        #[inline(always)]
18749        fn new_empty() -> Self {
18750            Self::default()
18751        }
18752
18753        unsafe fn decode(
18754            &mut self,
18755            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18756            offset: usize,
18757            mut depth: fidl::encoding::Depth,
18758        ) -> fidl::Result<()> {
18759            decoder.debug_check_bounds::<Self>(offset);
18760            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18761                None => return Err(fidl::Error::NotNullable),
18762                Some(len) => len,
18763            };
18764            // Calling decoder.out_of_line_offset(0) is not allowed.
18765            if len == 0 {
18766                return Ok(());
18767            };
18768            depth.increment()?;
18769            let envelope_size = 8;
18770            let bytes_len = len * envelope_size;
18771            let offset = decoder.out_of_line_offset(bytes_len)?;
18772            // Decode the envelope for each type.
18773            let mut _next_ordinal_to_read = 0;
18774            let mut next_offset = offset;
18775            let end_offset = offset + bytes_len;
18776            _next_ordinal_to_read += 1;
18777            if next_offset >= end_offset {
18778                return Ok(());
18779            }
18780
18781            // Decode unknown envelopes for gaps in ordinals.
18782            while _next_ordinal_to_read < 1 {
18783                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18784                _next_ordinal_to_read += 1;
18785                next_offset += envelope_size;
18786            }
18787
18788            let next_out_of_line = decoder.next_out_of_line();
18789            let handles_before = decoder.remaining_handles();
18790            if let Some((inlined, num_bytes, num_handles)) =
18791                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18792            {
18793                let member_inline_size = <fidl::encoding::HandleType<
18794                    fdomain_client::Vmo,
18795                    { fidl::ObjectType::VMO.into_raw() },
18796                    2147483648,
18797                > as fidl::encoding::TypeMarker>::inline_size(
18798                    decoder.context
18799                );
18800                if inlined != (member_inline_size <= 4) {
18801                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18802                }
18803                let inner_offset;
18804                let mut inner_depth = depth.clone();
18805                if inlined {
18806                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18807                    inner_offset = next_offset;
18808                } else {
18809                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18810                    inner_depth.increment()?;
18811                }
18812                let val_ref =
18813                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));
18814                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)?;
18815                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18816                {
18817                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18818                }
18819                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18820                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18821                }
18822            }
18823
18824            next_offset += envelope_size;
18825            _next_ordinal_to_read += 1;
18826            if next_offset >= end_offset {
18827                return Ok(());
18828            }
18829
18830            // Decode unknown envelopes for gaps in ordinals.
18831            while _next_ordinal_to_read < 2 {
18832                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18833                _next_ordinal_to_read += 1;
18834                next_offset += envelope_size;
18835            }
18836
18837            let next_out_of_line = decoder.next_out_of_line();
18838            let handles_before = decoder.remaining_handles();
18839            if let Some((inlined, num_bytes, num_handles)) =
18840                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18841            {
18842                let member_inline_size =
18843                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
18844                if inlined != (member_inline_size <= 4) {
18845                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18846                }
18847                let inner_offset;
18848                let mut inner_depth = depth.clone();
18849                if inlined {
18850                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18851                    inner_offset = next_offset;
18852                } else {
18853                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18854                    inner_depth.increment()?;
18855                }
18856                let val_ref = self.vmo_usable_start.get_or_insert_with(|| {
18857                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
18858                });
18859                fidl::decode!(
18860                    u64,
18861                    fdomain_client::fidl::FDomainResourceDialect,
18862                    val_ref,
18863                    decoder,
18864                    inner_offset,
18865                    inner_depth
18866                )?;
18867                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18868                {
18869                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18870                }
18871                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18872                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18873                }
18874            }
18875
18876            next_offset += envelope_size;
18877            _next_ordinal_to_read += 1;
18878            if next_offset >= end_offset {
18879                return Ok(());
18880            }
18881
18882            // Decode unknown envelopes for gaps in ordinals.
18883            while _next_ordinal_to_read < 3 {
18884                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18885                _next_ordinal_to_read += 1;
18886                next_offset += envelope_size;
18887            }
18888
18889            let next_out_of_line = decoder.next_out_of_line();
18890            let handles_before = decoder.remaining_handles();
18891            if let Some((inlined, num_bytes, num_handles)) =
18892                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18893            {
18894                let member_inline_size = <fidl::encoding::HandleType<
18895                    fdomain_client::EventPair,
18896                    { fidl::ObjectType::EVENTPAIR.into_raw() },
18897                    2147483648,
18898                > as fidl::encoding::TypeMarker>::inline_size(
18899                    decoder.context
18900                );
18901                if inlined != (member_inline_size <= 4) {
18902                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18903                }
18904                let inner_offset;
18905                let mut inner_depth = depth.clone();
18906                if inlined {
18907                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18908                    inner_offset = next_offset;
18909                } else {
18910                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18911                    inner_depth.increment()?;
18912                }
18913                let val_ref =
18914                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));
18915                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)?;
18916                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18917                {
18918                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18919                }
18920                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18921                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18922                }
18923            }
18924
18925            next_offset += envelope_size;
18926
18927            // Decode the remaining unknown envelopes.
18928            while next_offset < end_offset {
18929                _next_ordinal_to_read += 1;
18930                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18931                next_offset += envelope_size;
18932            }
18933
18934            Ok(())
18935        }
18936    }
18937}