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 AllocatorControlHandle {
1551    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1552        self.inner.shutdown_with_epitaph(status.into())
1553    }
1554}
1555
1556impl fdomain_client::fidl::ControlHandle for AllocatorControlHandle {
1557    fn shutdown(&self) {
1558        self.inner.shutdown()
1559    }
1560
1561    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1562        self.inner.shutdown_with_epitaph(status)
1563    }
1564
1565    fn is_closed(&self) -> bool {
1566        self.inner.channel().is_closed()
1567    }
1568    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1569        self.inner.channel().on_closed()
1570    }
1571}
1572
1573impl AllocatorControlHandle {}
1574
1575#[must_use = "FIDL methods require a response to be sent"]
1576#[derive(Debug)]
1577pub struct AllocatorValidateBufferCollectionTokenResponder {
1578    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1579    tx_id: u32,
1580}
1581
1582/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1583/// if the responder is dropped without sending a response, so that the client
1584/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1585impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1586    fn drop(&mut self) {
1587        self.control_handle.shutdown();
1588        // Safety: drops once, never accessed again
1589        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1590    }
1591}
1592
1593impl fdomain_client::fidl::Responder for AllocatorValidateBufferCollectionTokenResponder {
1594    type ControlHandle = AllocatorControlHandle;
1595
1596    fn control_handle(&self) -> &AllocatorControlHandle {
1597        &self.control_handle
1598    }
1599
1600    fn drop_without_shutdown(mut self) {
1601        // Safety: drops once, never accessed again due to mem::forget
1602        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1603        // Prevent Drop from running (which would shut down the channel)
1604        std::mem::forget(self);
1605    }
1606}
1607
1608impl AllocatorValidateBufferCollectionTokenResponder {
1609    /// Sends a response to the FIDL transaction.
1610    ///
1611    /// Sets the channel to shutdown if an error occurs.
1612    pub fn send(
1613        self,
1614        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1615    ) -> Result<(), fidl::Error> {
1616        let _result = self.send_raw(payload);
1617        if _result.is_err() {
1618            self.control_handle.shutdown();
1619        }
1620        self.drop_without_shutdown();
1621        _result
1622    }
1623
1624    /// Similar to "send" but does not shutdown the channel if an error occurs.
1625    pub fn send_no_shutdown_on_err(
1626        self,
1627        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1628    ) -> Result<(), fidl::Error> {
1629        let _result = self.send_raw(payload);
1630        self.drop_without_shutdown();
1631        _result
1632    }
1633
1634    fn send_raw(
1635        &self,
1636        mut payload: &AllocatorValidateBufferCollectionTokenResponse,
1637    ) -> Result<(), fidl::Error> {
1638        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1639            AllocatorValidateBufferCollectionTokenResponse,
1640        >>(
1641            fidl::encoding::Flexible::new(payload),
1642            self.tx_id,
1643            0x4c5ee91b02a7e68d,
1644            fidl::encoding::DynamicFlags::FLEXIBLE,
1645        )
1646    }
1647}
1648
1649#[must_use = "FIDL methods require a response to be sent"]
1650#[derive(Debug)]
1651pub struct AllocatorGetVmoInfoResponder {
1652    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1653    tx_id: u32,
1654}
1655
1656/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1657/// if the responder is dropped without sending a response, so that the client
1658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1659impl std::ops::Drop for AllocatorGetVmoInfoResponder {
1660    fn drop(&mut self) {
1661        self.control_handle.shutdown();
1662        // Safety: drops once, never accessed again
1663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1664    }
1665}
1666
1667impl fdomain_client::fidl::Responder for AllocatorGetVmoInfoResponder {
1668    type ControlHandle = AllocatorControlHandle;
1669
1670    fn control_handle(&self) -> &AllocatorControlHandle {
1671        &self.control_handle
1672    }
1673
1674    fn drop_without_shutdown(mut self) {
1675        // Safety: drops once, never accessed again due to mem::forget
1676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1677        // Prevent Drop from running (which would shut down the channel)
1678        std::mem::forget(self);
1679    }
1680}
1681
1682impl AllocatorGetVmoInfoResponder {
1683    /// Sends a response to the FIDL transaction.
1684    ///
1685    /// Sets the channel to shutdown if an error occurs.
1686    pub fn send(
1687        self,
1688        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1689    ) -> Result<(), fidl::Error> {
1690        let _result = self.send_raw(result);
1691        if _result.is_err() {
1692            self.control_handle.shutdown();
1693        }
1694        self.drop_without_shutdown();
1695        _result
1696    }
1697
1698    /// Similar to "send" but does not shutdown the channel if an error occurs.
1699    pub fn send_no_shutdown_on_err(
1700        self,
1701        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1702    ) -> Result<(), fidl::Error> {
1703        let _result = self.send_raw(result);
1704        self.drop_without_shutdown();
1705        _result
1706    }
1707
1708    fn send_raw(
1709        &self,
1710        mut result: Result<AllocatorGetVmoInfoResponse, Error>,
1711    ) -> Result<(), fidl::Error> {
1712        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1713            AllocatorGetVmoInfoResponse,
1714            Error,
1715        >>(
1716            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
1717            self.tx_id,
1718            0x21a881120aa0ddf9,
1719            fidl::encoding::DynamicFlags::FLEXIBLE,
1720        )
1721    }
1722}
1723
1724#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1725pub struct BufferCollectionMarker;
1726
1727impl fdomain_client::fidl::ProtocolMarker for BufferCollectionMarker {
1728    type Proxy = BufferCollectionProxy;
1729    type RequestStream = BufferCollectionRequestStream;
1730
1731    const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1732}
1733pub type BufferCollectionWaitForAllBuffersAllocatedResult =
1734    Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>;
1735pub type BufferCollectionCheckAllBuffersAllocatedResult = Result<(), Error>;
1736
1737pub trait BufferCollectionProxyInterface: Send + Sync {
1738    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1739    fn r#sync(&self) -> Self::SyncResponseFut;
1740    fn r#release(&self) -> Result<(), fidl::Error>;
1741    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
1742    fn r#set_debug_client_info(
1743        &self,
1744        payload: &NodeSetDebugClientInfoRequest,
1745    ) -> Result<(), fidl::Error>;
1746    fn r#set_debug_timeout_log_deadline(
1747        &self,
1748        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
1749    ) -> Result<(), fidl::Error>;
1750    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1751    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
1752        + Send;
1753    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1754    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1755        + Send;
1756    fn r#is_alternate_for(
1757        &self,
1758        payload: NodeIsAlternateForRequest,
1759    ) -> Self::IsAlternateForResponseFut;
1760    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
1761        + Send;
1762    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
1763    fn r#set_weak(&self) -> Result<(), fidl::Error>;
1764    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
1765    fn r#attach_node_tracking(
1766        &self,
1767        payload: NodeAttachNodeTrackingRequest,
1768    ) -> Result<(), fidl::Error>;
1769    fn r#set_constraints(
1770        &self,
1771        payload: BufferCollectionSetConstraintsRequest,
1772    ) -> Result<(), fidl::Error>;
1773    type WaitForAllBuffersAllocatedResponseFut: std::future::Future<
1774            Output = Result<BufferCollectionWaitForAllBuffersAllocatedResult, fidl::Error>,
1775        > + Send;
1776    fn r#wait_for_all_buffers_allocated(&self) -> Self::WaitForAllBuffersAllocatedResponseFut;
1777    type CheckAllBuffersAllocatedResponseFut: std::future::Future<
1778            Output = Result<BufferCollectionCheckAllBuffersAllocatedResult, fidl::Error>,
1779        > + Send;
1780    fn r#check_all_buffers_allocated(&self) -> Self::CheckAllBuffersAllocatedResponseFut;
1781    fn r#attach_token(
1782        &self,
1783        payload: BufferCollectionAttachTokenRequest,
1784    ) -> Result<(), fidl::Error>;
1785    fn r#attach_lifetime_tracking(
1786        &self,
1787        payload: BufferCollectionAttachLifetimeTrackingRequest,
1788    ) -> Result<(), fidl::Error>;
1789}
1790
1791#[derive(Debug, Clone)]
1792pub struct BufferCollectionProxy {
1793    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1794}
1795
1796impl fdomain_client::fidl::Proxy for BufferCollectionProxy {
1797    type Protocol = BufferCollectionMarker;
1798
1799    fn from_channel(inner: fdomain_client::Channel) -> Self {
1800        Self::new(inner)
1801    }
1802
1803    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1804        self.client.into_channel().map_err(|client| Self { client })
1805    }
1806
1807    fn as_channel(&self) -> &fdomain_client::Channel {
1808        self.client.as_channel()
1809    }
1810}
1811
1812impl BufferCollectionProxy {
1813    /// Create a new Proxy for fuchsia.sysmem2/BufferCollection.
1814    pub fn new(channel: fdomain_client::Channel) -> Self {
1815        let protocol_name =
1816            <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1817        Self { client: fidl::client::Client::new(channel, protocol_name) }
1818    }
1819
1820    /// Get a Stream of events from the remote end of the protocol.
1821    ///
1822    /// # Panics
1823    ///
1824    /// Panics if the event stream was already taken.
1825    pub fn take_event_stream(&self) -> BufferCollectionEventStream {
1826        BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
1827    }
1828
1829    /// Ensure that previous messages have been received server side. This is
1830    /// particularly useful after previous messages that created new tokens,
1831    /// because a token must be known to the sysmem server before sending the
1832    /// token to another participant.
1833    ///
1834    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
1835    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
1836    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
1837    /// to mitigate the possibility of a hostile/fake
1838    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
1839    /// Another way is to pass the token to
1840    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
1841    /// the token as part of exchanging it for a
1842    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
1843    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
1844    /// of stalling.
1845    ///
1846    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
1847    /// and then starting and completing a `Sync`, it's then safe to send the
1848    /// `BufferCollectionToken` client ends to other participants knowing the
1849    /// server will recognize the tokens when they're sent by the other
1850    /// participants to sysmem in a
1851    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
1852    /// efficient way to create tokens while avoiding unnecessary round trips.
1853    ///
1854    /// Other options include waiting for each
1855    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
1856    /// individually (using separate call to `Sync` after each), or calling
1857    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
1858    /// converted to a `BufferCollection` via
1859    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
1860    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
1861    /// the sync step and can create multiple tokens at once.
1862    pub fn r#sync(
1863        &self,
1864    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1865        BufferCollectionProxyInterface::r#sync(self)
1866    }
1867
1868    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
1869    ///
1870    /// Normally a participant will convert a `BufferCollectionToken` into a
1871    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
1872    /// `Release` via the token (and then close the channel immediately or
1873    /// shortly later in response to server closing the server end), which
1874    /// avoids causing buffer collection failure. Without a prior `Release`,
1875    /// closing the `BufferCollectionToken` client end will cause buffer
1876    /// collection failure.
1877    ///
1878    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
1879    ///
1880    /// By default the server handles unexpected closure of a
1881    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
1882    /// first) by failing the buffer collection. Partly this is to expedite
1883    /// closing VMO handles to reclaim memory when any participant fails. If a
1884    /// participant would like to cleanly close a `BufferCollection` without
1885    /// causing buffer collection failure, the participant can send `Release`
1886    /// before closing the `BufferCollection` client end. The `Release` can
1887    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
1888    /// buffer collection won't require constraints from this node in order to
1889    /// allocate. If after `SetConstraints`, the constraints are retained and
1890    /// aggregated, despite the lack of `BufferCollection` connection at the
1891    /// time of constraints aggregation.
1892    ///
1893    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
1894    ///
1895    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
1896    /// end (without `Release` first) will trigger failure of the buffer
1897    /// collection. To close a `BufferCollectionTokenGroup` channel without
1898    /// failing the buffer collection, ensure that AllChildrenPresent() has been
1899    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
1900    /// client end.
1901    ///
1902    /// If `Release` occurs before
1903    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
1904    /// buffer collection will fail (triggered by reception of `Release` without
1905    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
1906    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
1907    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
1908    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
1909    /// close requires `AllChildrenPresent` (if not already sent), then
1910    /// `Release`, then close client end.
1911    ///
1912    /// If `Release` occurs after `AllChildrenPresent`, the children and all
1913    /// their constraints remain intact (just as they would if the
1914    /// `BufferCollectionTokenGroup` channel had remained open), and the client
1915    /// end close doesn't trigger buffer collection failure.
1916    ///
1917    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
1918    ///
1919    /// For brevity, the per-channel-protocol paragraphs above ignore the
1920    /// separate failure domain created by
1921    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
1922    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
1923    /// unexpectedly closes (without `Release` first) and that client end is
1924    /// under a failure domain, instead of failing the whole buffer collection,
1925    /// the failure domain is failed, but the buffer collection itself is
1926    /// isolated from failure of the failure domain. Such failure domains can be
1927    /// nested, in which case only the inner-most failure domain in which the
1928    /// `Node` resides fails.
1929    pub fn r#release(&self) -> Result<(), fidl::Error> {
1930        BufferCollectionProxyInterface::r#release(self)
1931    }
1932
1933    /// Set a name for VMOs in this buffer collection.
1934    ///
1935    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
1936    /// will be truncated to fit. The name of the vmo will be suffixed with the
1937    /// buffer index within the collection (if the suffix fits within
1938    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
1939    /// listed in the inspect data.
1940    ///
1941    /// The name only affects VMOs allocated after the name is set; this call
1942    /// does not rename existing VMOs. If multiple clients set different names
1943    /// then the larger priority value will win. Setting a new name with the
1944    /// same priority as a prior name doesn't change the name.
1945    ///
1946    /// All table fields are currently required.
1947    ///
1948    /// + request `priority` The name is only set if this is the first `SetName`
1949    ///   or if `priority` is greater than any previous `priority` value in
1950    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
1951    /// + request `name` The name for VMOs created under this buffer collection.
1952    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
1953        BufferCollectionProxyInterface::r#set_name(self, payload)
1954    }
1955
1956    /// Set information about the current client that can be used by sysmem to
1957    /// help diagnose leaking memory and allocation stalls waiting for a
1958    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
1959    ///
1960    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
1961    /// `Node`(s) derived from this `Node`, unless overriden by
1962    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
1963    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
1964    ///
1965    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
1966    /// `Allocator` is the most efficient way to ensure that all
1967    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
1968    /// set, and is also more efficient than separately sending the same debug
1969    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
1970    /// created [`fuchsia.sysmem2/Node`].
1971    ///
1972    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
1973    /// indicate which client is closing their channel first, leading to subtree
1974    /// failure (which can be normal if the purpose of the subtree is over, but
1975    /// if happening earlier than expected, the client-channel-specific name can
1976    /// help diagnose where the failure is first coming from, from sysmem's
1977    /// point of view).
1978    ///
1979    /// All table fields are currently required.
1980    ///
1981    /// + request `name` This can be an arbitrary string, but the current
1982    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
1983    /// + request `id` This can be an arbitrary id, but the current process ID
1984    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
1985    pub fn r#set_debug_client_info(
1986        &self,
1987        mut payload: &NodeSetDebugClientInfoRequest,
1988    ) -> Result<(), fidl::Error> {
1989        BufferCollectionProxyInterface::r#set_debug_client_info(self, payload)
1990    }
1991
1992    /// Sysmem logs a warning if sysmem hasn't seen
1993    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
1994    /// within 5 seconds after creation of a new collection.
1995    ///
1996    /// Clients can call this method to change when the log is printed. If
1997    /// multiple client set the deadline, it's unspecified which deadline will
1998    /// take effect.
1999    ///
2000    /// In most cases the default works well.
2001    ///
2002    /// All table fields are currently required.
2003    ///
2004    /// + request `deadline` The time at which sysmem will start trying to log
2005    ///   the warning, unless all constraints are with sysmem by then.
2006    pub fn r#set_debug_timeout_log_deadline(
2007        &self,
2008        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
2009    ) -> Result<(), fidl::Error> {
2010        BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
2011    }
2012
2013    /// This enables verbose logging for the buffer collection.
2014    ///
2015    /// Verbose logging includes constraints set via
2016    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
2017    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
2018    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
2019    /// the tree of `Node`(s).
2020    ///
2021    /// Normally sysmem prints only a single line complaint when aggregation
2022    /// fails, with just the specific detailed reason that aggregation failed,
2023    /// with little surrounding context.  While this is often enough to diagnose
2024    /// a problem if only a small change was made and everything was working
2025    /// before the small change, it's often not particularly helpful for getting
2026    /// a new buffer collection to work for the first time.  Especially with
2027    /// more complex trees of nodes, involving things like
2028    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
2029    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
2030    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
2031    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
2032    /// looks like and why it's failing a logical allocation, or why a tree or
2033    /// subtree is failing sooner than expected.
2034    ///
2035    /// The intent of the extra logging is to be acceptable from a performance
2036    /// point of view, under the assumption that verbose logging is only enabled
2037    /// on a low number of buffer collections. If we're not tracking down a bug,
2038    /// we shouldn't send this message.
2039    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2040        BufferCollectionProxyInterface::r#set_verbose_logging(self)
2041    }
2042
2043    /// This gets a handle that can be used as a parameter to
2044    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
2045    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
2046    /// client obtained this handle from this `Node`.
2047    ///
2048    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
2049    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
2050    /// despite the two calls typically being on different channels.
2051    ///
2052    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
2053    ///
2054    /// All table fields are currently required.
2055    ///
2056    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
2057    ///   different `Node` channel, to prove that the client obtained the handle
2058    ///   from this `Node`.
2059    pub fn r#get_node_ref(
2060        &self,
2061    ) -> fidl::client::QueryResponseFut<
2062        NodeGetNodeRefResponse,
2063        fdomain_client::fidl::FDomainResourceDialect,
2064    > {
2065        BufferCollectionProxyInterface::r#get_node_ref(self)
2066    }
2067
2068    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
2069    /// rooted at a different child token of a common parent
2070    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
2071    /// passed-in `node_ref`.
2072    ///
2073    /// This call is for assisting with admission control de-duplication, and
2074    /// with debugging.
2075    ///
2076    /// The `node_ref` must be obtained using
2077    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
2078    ///
2079    /// The `node_ref` can be a duplicated handle; it's not necessary to call
2080    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
2081    ///
2082    /// If a calling token may not actually be a valid token at all due to a
2083    /// potentially hostile/untrusted provider of the token, call
2084    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
2085    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
2086    /// never responds due to a calling token not being a real token (not really
2087    /// talking to sysmem).  Another option is to call
2088    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
2089    /// which also validates the token along with converting it to a
2090    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
2091    ///
2092    /// All table fields are currently required.
2093    ///
2094    /// - response `is_alternate`
2095    ///   - true: The first parent node in common between the calling node and
2096    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
2097    ///     that the calling `Node` and the `node_ref` `Node` will not have both
2098    ///     their constraints apply - rather sysmem will choose one or the other
2099    ///     of the constraints - never both.  This is because only one child of
2100    ///     a `BufferCollectionTokenGroup` is selected during logical
2101    ///     allocation, with only that one child's subtree contributing to
2102    ///     constraints aggregation.
2103    ///   - false: The first parent node in common between the calling `Node`
2104    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
2105    ///     Currently, this means the first parent node in common is a
2106    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
2107    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
2108    ///     `Node` may have both their constraints apply during constraints
2109    ///     aggregation of the logical allocation, if both `Node`(s) are
2110    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
2111    ///     this case, there is no `BufferCollectionTokenGroup` that will
2112    ///     directly prevent the two `Node`(s) from both being selected and
2113    ///     their constraints both aggregated, but even when false, one or both
2114    ///     `Node`(s) may still be eliminated from consideration if one or both
2115    ///     `Node`(s) has a direct or indirect parent
2116    ///     `BufferCollectionTokenGroup` which selects a child subtree other
2117    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
2118    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
2119    ///   associated with the same buffer collection as the calling `Node`.
2120    ///   Another reason for this error is if the `node_ref` is an
2121    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
2122    ///   a real `node_ref` obtained from `GetNodeRef`.
2123    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
2124    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
2125    ///   the needed rights expected on a real `node_ref`.
2126    /// * No other failing status codes are returned by this call.  However,
2127    ///   sysmem may add additional codes in future, so the client should have
2128    ///   sensible default handling for any failing status code.
2129    pub fn r#is_alternate_for(
2130        &self,
2131        mut payload: NodeIsAlternateForRequest,
2132    ) -> fidl::client::QueryResponseFut<
2133        NodeIsAlternateForResult,
2134        fdomain_client::fidl::FDomainResourceDialect,
2135    > {
2136        BufferCollectionProxyInterface::r#is_alternate_for(self, payload)
2137    }
2138
2139    /// Get the buffer collection ID. This ID is also available from
2140    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
2141    /// within the collection).
2142    ///
2143    /// This call is mainly useful in situations where we can't convey a
2144    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
2145    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
2146    /// handle, which can be joined back up with a `BufferCollection` client end
2147    /// that was created via a different path. Prefer to convey a
2148    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
2149    ///
2150    /// Trusting a `buffer_collection_id` value from a source other than sysmem
2151    /// is analogous to trusting a koid value from a source other than zircon.
2152    /// Both should be avoided unless really necessary, and both require
2153    /// caution. In some situations it may be reasonable to refer to a
2154    /// pre-established `BufferCollection` by `buffer_collection_id` via a
2155    /// protocol for efficiency reasons, but an incoming value purporting to be
2156    /// a `buffer_collection_id` is not sufficient alone to justify granting the
2157    /// sender of the `buffer_collection_id` any capability. The sender must
2158    /// first prove to a receiver that the sender has/had a VMO or has/had a
2159    /// `BufferCollectionToken` to the same collection by sending a handle that
2160    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
2161    /// `buffer_collection_id` value. The receiver should take care to avoid
2162    /// assuming that a sender had a `BufferCollectionToken` in cases where the
2163    /// sender has only proven that the sender had a VMO.
2164    ///
2165    /// - response `buffer_collection_id` This ID is unique per buffer
2166    ///   collection per boot. Each buffer is uniquely identified by the
2167    ///   `buffer_collection_id` and `buffer_index` together.
2168    pub fn r#get_buffer_collection_id(
2169        &self,
2170    ) -> fidl::client::QueryResponseFut<
2171        NodeGetBufferCollectionIdResponse,
2172        fdomain_client::fidl::FDomainResourceDialect,
2173    > {
2174        BufferCollectionProxyInterface::r#get_buffer_collection_id(self)
2175    }
2176
2177    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
2178    /// created after this message to weak, which means that a client's `Node`
2179    /// client end (or a child created after this message) is not alone
2180    /// sufficient to keep allocated VMOs alive.
2181    ///
2182    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
2183    /// `close_weak_asap`.
2184    ///
2185    /// This message is only permitted before the `Node` becomes ready for
2186    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
2187    ///   * `BufferCollectionToken`: any time
2188    ///   * `BufferCollection`: before `SetConstraints`
2189    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
2190    ///
2191    /// Currently, no conversion from strong `Node` to weak `Node` after ready
2192    /// for allocation is provided, but a client can simulate that by creating
2193    /// an additional `Node` before allocation and setting that additional
2194    /// `Node` to weak, and then potentially at some point later sending
2195    /// `Release` and closing the client end of the client's strong `Node`, but
2196    /// keeping the client's weak `Node`.
2197    ///
2198    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
2199    /// collection failure (all `Node` client end(s) will see
2200    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
2201    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
2202    /// this situation until all `Node`(s) are ready for allocation. For initial
2203    /// allocation to succeed, at least one strong `Node` is required to exist
2204    /// at allocation time, but after that client receives VMO handles, that
2205    /// client can `BufferCollection.Release` and close the client end without
2206    /// causing this type of failure.
2207    ///
2208    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
2209    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
2210    /// separately as appropriate.
2211    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
2212        BufferCollectionProxyInterface::r#set_weak(self)
2213    }
2214
2215    /// This indicates to sysmem that the client is prepared to pay attention to
2216    /// `close_weak_asap`.
2217    ///
2218    /// If sent, this message must be before
2219    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
2220    ///
2221    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
2222    /// send this message before `WaitForAllBuffersAllocated`, or a parent
2223    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
2224    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
2225    /// trigger buffer collection failure.
2226    ///
2227    /// This message is necessary because weak sysmem VMOs have not always been
2228    /// a thing, so older clients are not aware of the need to pay attention to
2229    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
2230    /// sysmem weak VMO handles asap. By having this message and requiring
2231    /// participants to indicate their acceptance of this aspect of the overall
2232    /// protocol, we avoid situations where an older client is delivered a weak
2233    /// VMO without any way for sysmem to get that VMO to close quickly later
2234    /// (and on a per-buffer basis).
2235    ///
2236    /// A participant that doesn't handle `close_weak_asap` and also doesn't
2237    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
2238    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
2239    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
2240    /// same participant has a child/delegate which does retrieve VMOs, that
2241    /// child/delegate will need to send `SetWeakOk` before
2242    /// `WaitForAllBuffersAllocated`.
2243    ///
2244    /// + request `for_child_nodes_also` If present and true, this means direct
2245    ///   child nodes of this node created after this message plus all
2246    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
2247    ///   those nodes. Any child node of this node that was created before this
2248    ///   message is not included. This setting is "sticky" in the sense that a
2249    ///   subsequent `SetWeakOk` without this bool set to true does not reset
2250    ///   the server-side bool. If this creates a problem for a participant, a
2251    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
2252    ///   tokens instead, as appropriate. A participant should only set
2253    ///   `for_child_nodes_also` true if the participant can really promise to
2254    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
2255    ///   weak VMO handles held by participants holding the corresponding child
2256    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
2257    ///   which are using sysmem(1) can be weak, despite the clients of those
2258    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
2259    ///   direct way to find out about `close_weak_asap`. This only applies to
2260    ///   descendents of this `Node` which are using sysmem(1), not to this
2261    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
2262    ///   token, which will fail allocation unless an ancestor of this `Node`
2263    ///   specified `for_child_nodes_also` true.
2264    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
2265        BufferCollectionProxyInterface::r#set_weak_ok(self, payload)
2266    }
2267
2268    /// The server_end will be closed after this `Node` and any child nodes have
2269    /// have released their buffer counts, making those counts available for
2270    /// reservation by a different `Node` via
2271    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
2272    ///
2273    /// The `Node` buffer counts may not be released until the entire tree of
2274    /// `Node`(s) is closed or failed, because
2275    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
2276    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
2277    /// `Node` buffer counts remain reserved until the orphaned node is later
2278    /// cleaned up.
2279    ///
2280    /// If the `Node` exceeds a fairly large number of attached eventpair server
2281    /// ends, a log message will indicate this and the `Node` (and the
2282    /// appropriate) sub-tree will fail.
2283    ///
2284    /// The `server_end` will remain open when
2285    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
2286    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
2287    /// [`fuchsia.sysmem2/BufferCollection`].
2288    ///
2289    /// This message can also be used with a
2290    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
2291    pub fn r#attach_node_tracking(
2292        &self,
2293        mut payload: NodeAttachNodeTrackingRequest,
2294    ) -> Result<(), fidl::Error> {
2295        BufferCollectionProxyInterface::r#attach_node_tracking(self, payload)
2296    }
2297
2298    /// Provide [`fuchsia.sysmem2/BufferCollectionConstraints`] to the buffer
2299    /// collection.
2300    ///
2301    /// A participant may only call
2302    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] up to once per
2303    /// [`fuchsia.sysmem2/BufferCollection`].
2304    ///
2305    /// For buffer allocation to be attempted, all holders of a
2306    /// `BufferCollection` client end need to call `SetConstraints` before
2307    /// sysmem will attempt to allocate buffers.
2308    pub fn r#set_constraints(
2309        &self,
2310        mut payload: BufferCollectionSetConstraintsRequest,
2311    ) -> Result<(), fidl::Error> {
2312        BufferCollectionProxyInterface::r#set_constraints(self, payload)
2313    }
2314
2315    /// Wait until all buffers are allocated.
2316    ///
2317    /// This FIDL call completes when buffers have been allocated, or completes
2318    /// with some failure detail if allocation has been attempted but failed.
2319    ///
2320    /// The following must occur before buffers will be allocated:
2321    ///   * All [`fuchsia.sysmem2/BufferCollectionToken`](s) of the buffer
2322    ///     collection must be turned in via `BindSharedCollection` to get a
2323    ///     [`fuchsia.sysmem2/BufferCollection`] (for brevity, this is assuming
2324    ///     [`fuchsia.sysmem2/BufferCollection.AttachToken`] isn't being used),
2325    ///     or have had [`fuchsia.sysmem2/BufferCollectionToken.Release`] sent
2326    ///     to them.
2327    ///   * All [`fuchsia.sysmem2/BufferCollection`](s) of the buffer collection
2328    ///     must have had [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
2329    ///     sent to them, or had [`fuchsia.sysmem2/BufferCollection.Release`]
2330    ///     sent to them.
2331    ///
2332    /// - result `buffer_collection_info` The VMO handles and other related
2333    ///   info.
2334    /// * error `[fuchsia.sysmem2/Error.NO_MEMORY]` The request is valid but
2335    ///   cannot be fulfilled due to resource exhaustion.
2336    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION`] The request is
2337    ///   malformed.
2338    /// * error `[fuchsia.sysmem2/Error.CONSTRAINTS_INTERSECTION_EMPTY`] The
2339    ///   request is valid but cannot be satisfied, perhaps due to hardware
2340    ///   limitations. This can happen if participants have incompatible
2341    ///   constraints (empty intersection, roughly speaking). See the log for
2342    ///   more info. In cases where a participant could potentially be treated
2343    ///   as optional, see [`BufferCollectionTokenGroup`]. When using
2344    ///   [`fuchsia.sysmem2/BufferCollection.AttachToken`], this will be the
2345    ///   error code if there aren't enough buffers in the pre-existing
2346    ///   collection to satisfy the constraints set on the attached token and
2347    ///   any sub-tree of tokens derived from the attached token.
2348    pub fn r#wait_for_all_buffers_allocated(
2349        &self,
2350    ) -> fidl::client::QueryResponseFut<
2351        BufferCollectionWaitForAllBuffersAllocatedResult,
2352        fdomain_client::fidl::FDomainResourceDialect,
2353    > {
2354        BufferCollectionProxyInterface::r#wait_for_all_buffers_allocated(self)
2355    }
2356
2357    /// Checks whether all the buffers have been allocated, in a polling
2358    /// fashion.
2359    ///
2360    /// * If the buffer collection has been allocated, returns success.
2361    /// * If the buffer collection failed allocation, returns the same
2362    ///   [`fuchsia.sysmem2/Error`] as
2363    ///   [`fuchsia.sysmem2/BufferCollection/WaitForAllBuffersAllocated`] would
2364    ///   return.
2365    /// * error [`fuchsia.sysmem2/Error.PENDING`] The buffer collection hasn't
2366    ///   attempted allocation yet. This means that WaitForAllBuffersAllocated
2367    ///   would not respond quickly.
2368    pub fn r#check_all_buffers_allocated(
2369        &self,
2370    ) -> fidl::client::QueryResponseFut<
2371        BufferCollectionCheckAllBuffersAllocatedResult,
2372        fdomain_client::fidl::FDomainResourceDialect,
2373    > {
2374        BufferCollectionProxyInterface::r#check_all_buffers_allocated(self)
2375    }
2376
2377    /// Create a new token to add a new participant to an existing logical
2378    /// buffer collection, if the existing collection's buffer counts,
2379    /// constraints, and participants allow.
2380    ///
2381    /// This can be useful in replacing a failed participant, and/or in
2382    /// adding/re-adding a participant after buffers have already been
2383    /// allocated.
2384    ///
2385    /// When [`fuchsia.sysmem2/BufferCollection.AttachToken`] is used, the sub
2386    /// tree rooted at the attached [`fuchsia.sysmem2/BufferCollectionToken`]
2387    /// goes through the normal procedure of setting constraints or closing
2388    /// [`fuchsia.sysmem2/Node`](s), and then appearing to allocate buffers from
2389    /// clients' point of view, despite the possibility that all the buffers
2390    /// were actually allocated previously. This process is called "logical
2391    /// allocation". Most instances of "allocation" in docs for other messages
2392    /// can also be read as "allocation or logical allocation" while remaining
2393    /// valid, but we just say "allocation" in most places for brevity/clarity
2394    /// of explanation, with the details of "logical allocation" left for the
2395    /// docs here on `AttachToken`.
2396    ///
2397    /// Failure of an attached `Node` does not propagate to the parent of the
2398    /// attached `Node`. More generally, failure of a child `Node` is blocked
2399    /// from reaching its parent `Node` if the child is attached, or if the
2400    /// child is dispensable and the failure occurred after logical allocation
2401    /// (see [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`]).
2402    ///
2403    /// A participant may in some scenarios choose to initially use a
2404    /// dispensable token for a given instance of a delegate participant, and
2405    /// then later if the first instance of that delegate participant fails, a
2406    /// new second instance of that delegate participant my be given a token
2407    /// created with `AttachToken`.
2408    ///
2409    /// From the point of view of the [`fuchsia.sysmem2/BufferCollectionToken`]
2410    /// client end, the token acts like any other token. The client can
2411    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] the token as needed,
2412    /// and can send the token to a different process/participant. The
2413    /// `BufferCollectionToken` `Node` should be converted to a
2414    /// `BufferCollection` `Node` as normal by sending
2415    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or can be closed
2416    /// without causing subtree failure by sending
2417    /// [`fuchsia.sysmem2/BufferCollectionToken.Release`]. Assuming the former,
2418    /// the [`fuchsia.sysmem2/BufferCollection.SetConstraints`] message or
2419    /// [`fuchsia.sysmem2/BufferCollection.Release`] message should be sent to
2420    /// the `BufferCollection`.
2421    ///
2422    /// Within the subtree, a success result from
2423    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] means
2424    /// the subtree participants' constraints were satisfiable using the
2425    /// already-existing buffer collection, the already-established
2426    /// [`fuchsia.sysmem2/BufferCollectionInfo`] including image format
2427    /// constraints, and the already-existing other participants (already added
2428    /// via successful logical allocation) and their specified buffer counts in
2429    /// their constraints. A failure result means the new participants'
2430    /// constraints cannot be satisfied using the existing buffer collection and
2431    /// its already-added participants. Creating a new collection instead may
2432    /// allow all participants' constraints to be satisfied, assuming
2433    /// `SetDispensable` is used in place of `AttachToken`, or a normal token is
2434    /// used.
2435    ///
2436    /// A token created with `AttachToken` performs constraints aggregation with
2437    /// all constraints currently in effect on the buffer collection, plus the
2438    /// attached token under consideration plus child tokens under the attached
2439    /// token which are not themselves an attached token or under such a token.
2440    /// Further subtrees under this subtree are considered for logical
2441    /// allocation only after this subtree has completed logical allocation.
2442    ///
2443    /// Assignment of existing buffers to participants'
2444    /// [`fuchsia.sysmem2/BufferCollectionConstraints.min_buffer_count_for_camping`]
2445    /// etc is first-come first-served, but a child can't logically allocate
2446    /// before all its parents have sent `SetConstraints`.
2447    ///
2448    /// See also [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`], which
2449    /// in contrast to `AttachToken`, has the created token `Node` + child
2450    /// `Node`(s) (in the created subtree but not in any subtree under this
2451    /// subtree) participate in constraints aggregation along with its parent
2452    /// during the parent's allocation or logical allocation.
2453    ///
2454    /// Similar to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], the
2455    /// newly created token needs to be [`fuchsia.sysmem2/Node.Sync`]ed to
2456    /// sysmem before the new token can be passed to `BindSharedCollection`. The
2457    /// `Sync` of the new token can be accomplished with
2458    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after converting the created
2459    /// `BufferCollectionToken` to a `BufferCollection`. Alternately,
2460    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on the new token also
2461    /// works. Or using [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`]
2462    /// works. As usual, a `BufferCollectionToken.Sync` can be started after any
2463    /// `BufferCollectionToken.Duplicate` messages have been sent via the newly
2464    /// created token, to also sync those additional tokens to sysmem using a
2465    /// single round-trip.
2466    ///
2467    /// All table fields are currently required.
2468    ///
2469    /// + request `rights_attentuation_mask` This allows attenuating the VMO
2470    ///   rights of the subtree. These values for `rights_attenuation_mask`
2471    ///   result in no attenuation (note that 0 is not on this list):
2472    ///   + ZX_RIGHT_SAME_RIGHTS (preferred)
2473    ///   + 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2474    /// + request `token_request` The server end of the `BufferCollectionToken`
2475    ///   channel. The client retains the client end.
2476    pub fn r#attach_token(
2477        &self,
2478        mut payload: BufferCollectionAttachTokenRequest,
2479    ) -> Result<(), fidl::Error> {
2480        BufferCollectionProxyInterface::r#attach_token(self, payload)
2481    }
2482
2483    /// Set up an eventpair to be signalled (`ZX_EVENTPAIR_PEER_CLOSED`) when
2484    /// buffers have been allocated and only the specified number of buffers (or
2485    /// fewer) remain in the buffer collection.
2486    ///
2487    /// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] allows a
2488    /// client to wait until an old buffer collection is fully or mostly
2489    /// deallocated before attempting allocation of a new buffer collection. The
2490    /// eventpair is only signalled when the buffers of this collection have
2491    /// been fully deallocated (not just un-referenced by clients, but all the
2492    /// memory consumed by those buffers has been fully reclaimed/recycled), or
2493    /// when allocation or logical allocation fails for the tree or subtree
2494    /// including this [`fuchsia.sysmem2/BufferCollection`].
2495    ///
2496    /// The eventpair won't be signalled until allocation or logical allocation
2497    /// has completed; until then, the collection's current buffer count is
2498    /// ignored.
2499    ///
2500    /// If logical allocation fails for an attached subtree (using
2501    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]), the server end of the
2502    /// eventpair will close during that failure regardless of the number of
2503    /// buffers potenitally allocated in the overall buffer collection. This is
2504    /// for logical allocation consistency with normal allocation.
2505    ///
2506    /// The lifetime signalled by this event includes asynchronous cleanup of
2507    /// allocated buffers, and this asynchronous cleanup cannot occur until all
2508    /// holders of VMO handles to the buffers have closed those VMO handles.
2509    /// Therefore, clients should take care not to become blocked forever
2510    /// waiting for `ZX_EVENTPAIR_PEER_CLOSED` to be signalled if any of the
2511    /// participants using the logical buffer collection (including the waiter
2512    /// itself) are less trusted, less reliable, or potentially blocked by the
2513    /// wait itself. Waiting asynchronously is recommended. Setting a deadline
2514    /// for the client wait may be prudent, depending on details of how the
2515    /// collection and/or its VMOs are used or shared. Failure to allocate a
2516    /// new/replacement buffer collection is better than getting stuck forever.
2517    ///
2518    /// The sysmem server itself intentionally does not perform any waiting on
2519    /// already-failed collections' VMOs to finish cleaning up before attempting
2520    /// a new allocation, and the sysmem server intentionally doesn't retry
2521    /// allocation if a new allocation fails due to out of memory, even if that
2522    /// failure is potentially due to continued existence of an old collection's
2523    /// VMOs. This `AttachLifetimeTracking` message is how an initiator can
2524    /// mitigate too much overlap of old VMO lifetimes with new VMO lifetimes,
2525    /// as long as the waiting client is careful to not create a deadlock.
2526    ///
2527    /// Continued existence of old collections that are still cleaning up is not
2528    /// the only reason that a new allocation may fail due to insufficient
2529    /// memory, even if the new allocation is allocating physically contiguous
2530    /// buffers. Overall system memory pressure can also be the cause of failure
2531    /// to allocate a new collection. See also
2532    /// [`fuchsia.memorypressure/Provider`].
2533    ///
2534    /// `AttachLifetimeTracking` is meant to be compatible with other protocols
2535    /// with a similar `AttachLifetimeTracking` message; duplicates of the same
2536    /// `eventpair` handle (server end) can be sent via more than one
2537    /// `AttachLifetimeTracking` message to different protocols, and the
2538    /// `ZX_EVENTPAIR_PEER_CLOSED` will be signalled for the client end when all
2539    /// the conditions are met (all holders of duplicates have closed their
2540    /// server end handle(s)). Also, thanks to how eventpair endponts work, the
2541    /// client end can (also) be duplicated without preventing the
2542    /// `ZX_EVENTPAIR_PEER_CLOSED` signal.
2543    ///
2544    /// The server intentionally doesn't "trust" any signals set on the
2545    /// `server_end`. This mechanism intentionally uses only
2546    /// `ZX_EVENTPAIR_PEER_CLOSED` set on the client end, which can't be set
2547    /// "early", and is only set when all handles to the server end eventpair
2548    /// are closed. No meaning is associated with any of the other signals, and
2549    /// clients should ignore any other signal bits on either end of the
2550    /// `eventpair`.
2551    ///
2552    /// The `server_end` may lack `ZX_RIGHT_SIGNAL` or `ZX_RIGHT_SIGNAL_PEER`,
2553    /// but must have `ZX_RIGHT_DUPLICATE` (and must have `ZX_RIGHT_TRANSFER` to
2554    /// transfer without causing `BufferCollection` channel failure).
2555    ///
2556    /// All table fields are currently required.
2557    ///
2558    /// + request `server_end` This eventpair handle will be closed by the
2559    ///   sysmem server when buffers have been allocated initially and the
2560    ///   number of buffers is then less than or equal to `buffers_remaining`.
2561    /// + request `buffers_remaining` Wait for all but `buffers_remaining` (or
2562    ///   fewer) buffers to be fully deallocated. A number greater than zero can
2563    ///   be useful in situations where a known number of buffers are
2564    ///   intentionally not closed so that the data can continue to be used,
2565    ///   such as for keeping the last available video frame displayed in the UI
2566    ///   even if the video stream was using protected output buffers. It's
2567    ///   outside the scope of the `BufferCollection` interface (at least for
2568    ///   now) to determine how many buffers may be held without closing, but
2569    ///   it'll typically be in the range 0-2.
2570    pub fn r#attach_lifetime_tracking(
2571        &self,
2572        mut payload: BufferCollectionAttachLifetimeTrackingRequest,
2573    ) -> Result<(), fidl::Error> {
2574        BufferCollectionProxyInterface::r#attach_lifetime_tracking(self, payload)
2575    }
2576}
2577
2578impl BufferCollectionProxyInterface for BufferCollectionProxy {
2579    type SyncResponseFut =
2580        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2581    fn r#sync(&self) -> Self::SyncResponseFut {
2582        fn _decode(
2583            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2584        ) -> Result<(), fidl::Error> {
2585            let _response = fidl::client::decode_transaction_body::<
2586                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2587                fdomain_client::fidl::FDomainResourceDialect,
2588                0x11ac2555cf575b54,
2589            >(_buf?)?
2590            .into_result_fdomain::<BufferCollectionMarker>("sync")?;
2591            Ok(_response)
2592        }
2593        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2594            (),
2595            0x11ac2555cf575b54,
2596            fidl::encoding::DynamicFlags::FLEXIBLE,
2597            _decode,
2598        )
2599    }
2600
2601    fn r#release(&self) -> Result<(), fidl::Error> {
2602        self.client.send::<fidl::encoding::EmptyPayload>(
2603            (),
2604            0x6a5cae7d6d6e04c6,
2605            fidl::encoding::DynamicFlags::FLEXIBLE,
2606        )
2607    }
2608
2609    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
2610        self.client.send::<NodeSetNameRequest>(
2611            payload,
2612            0xb41f1624f48c1e9,
2613            fidl::encoding::DynamicFlags::FLEXIBLE,
2614        )
2615    }
2616
2617    fn r#set_debug_client_info(
2618        &self,
2619        mut payload: &NodeSetDebugClientInfoRequest,
2620    ) -> Result<(), fidl::Error> {
2621        self.client.send::<NodeSetDebugClientInfoRequest>(
2622            payload,
2623            0x5cde8914608d99b1,
2624            fidl::encoding::DynamicFlags::FLEXIBLE,
2625        )
2626    }
2627
2628    fn r#set_debug_timeout_log_deadline(
2629        &self,
2630        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
2631    ) -> Result<(), fidl::Error> {
2632        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
2633            payload,
2634            0x716b0af13d5c0806,
2635            fidl::encoding::DynamicFlags::FLEXIBLE,
2636        )
2637    }
2638
2639    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
2640        self.client.send::<fidl::encoding::EmptyPayload>(
2641            (),
2642            0x5209c77415b4dfad,
2643            fidl::encoding::DynamicFlags::FLEXIBLE,
2644        )
2645    }
2646
2647    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
2648        NodeGetNodeRefResponse,
2649        fdomain_client::fidl::FDomainResourceDialect,
2650    >;
2651    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
2652        fn _decode(
2653            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2654        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
2655            let _response = fidl::client::decode_transaction_body::<
2656                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
2657                fdomain_client::fidl::FDomainResourceDialect,
2658                0x5b3d0e51614df053,
2659            >(_buf?)?
2660            .into_result_fdomain::<BufferCollectionMarker>("get_node_ref")?;
2661            Ok(_response)
2662        }
2663        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
2664            (),
2665            0x5b3d0e51614df053,
2666            fidl::encoding::DynamicFlags::FLEXIBLE,
2667            _decode,
2668        )
2669    }
2670
2671    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
2672        NodeIsAlternateForResult,
2673        fdomain_client::fidl::FDomainResourceDialect,
2674    >;
2675    fn r#is_alternate_for(
2676        &self,
2677        mut payload: NodeIsAlternateForRequest,
2678    ) -> Self::IsAlternateForResponseFut {
2679        fn _decode(
2680            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2681        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
2682            let _response = fidl::client::decode_transaction_body::<
2683                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
2684                fdomain_client::fidl::FDomainResourceDialect,
2685                0x3a58e00157e0825,
2686            >(_buf?)?
2687            .into_result_fdomain::<BufferCollectionMarker>("is_alternate_for")?;
2688            Ok(_response.map(|x| x))
2689        }
2690        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
2691            &mut payload,
2692            0x3a58e00157e0825,
2693            fidl::encoding::DynamicFlags::FLEXIBLE,
2694            _decode,
2695        )
2696    }
2697
2698    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
2699        NodeGetBufferCollectionIdResponse,
2700        fdomain_client::fidl::FDomainResourceDialect,
2701    >;
2702    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
2703        fn _decode(
2704            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2705        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
2706            let _response = fidl::client::decode_transaction_body::<
2707                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
2708                fdomain_client::fidl::FDomainResourceDialect,
2709                0x77d19a494b78ba8c,
2710            >(_buf?)?
2711            .into_result_fdomain::<BufferCollectionMarker>("get_buffer_collection_id")?;
2712            Ok(_response)
2713        }
2714        self.client.send_query_and_decode::<
2715            fidl::encoding::EmptyPayload,
2716            NodeGetBufferCollectionIdResponse,
2717        >(
2718            (),
2719            0x77d19a494b78ba8c,
2720            fidl::encoding::DynamicFlags::FLEXIBLE,
2721            _decode,
2722        )
2723    }
2724
2725    fn r#set_weak(&self) -> Result<(), fidl::Error> {
2726        self.client.send::<fidl::encoding::EmptyPayload>(
2727            (),
2728            0x22dd3ea514eeffe1,
2729            fidl::encoding::DynamicFlags::FLEXIBLE,
2730        )
2731    }
2732
2733    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
2734        self.client.send::<NodeSetWeakOkRequest>(
2735            &mut payload,
2736            0x38a44fc4d7724be9,
2737            fidl::encoding::DynamicFlags::FLEXIBLE,
2738        )
2739    }
2740
2741    fn r#attach_node_tracking(
2742        &self,
2743        mut payload: NodeAttachNodeTrackingRequest,
2744    ) -> Result<(), fidl::Error> {
2745        self.client.send::<NodeAttachNodeTrackingRequest>(
2746            &mut payload,
2747            0x3f22f2a293d3cdac,
2748            fidl::encoding::DynamicFlags::FLEXIBLE,
2749        )
2750    }
2751
2752    fn r#set_constraints(
2753        &self,
2754        mut payload: BufferCollectionSetConstraintsRequest,
2755    ) -> Result<(), fidl::Error> {
2756        self.client.send::<BufferCollectionSetConstraintsRequest>(
2757            &mut payload,
2758            0x1fde0f19d650197b,
2759            fidl::encoding::DynamicFlags::FLEXIBLE,
2760        )
2761    }
2762
2763    type WaitForAllBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2764        BufferCollectionWaitForAllBuffersAllocatedResult,
2765        fdomain_client::fidl::FDomainResourceDialect,
2766    >;
2767    fn r#wait_for_all_buffers_allocated(&self) -> Self::WaitForAllBuffersAllocatedResponseFut {
2768        fn _decode(
2769            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2770        ) -> Result<BufferCollectionWaitForAllBuffersAllocatedResult, fidl::Error> {
2771            let _response = fidl::client::decode_transaction_body::<
2772                fidl::encoding::FlexibleResultType<
2773                    BufferCollectionWaitForAllBuffersAllocatedResponse,
2774                    Error,
2775                >,
2776                fdomain_client::fidl::FDomainResourceDialect,
2777                0x62300344b61404e,
2778            >(_buf?)?
2779            .into_result_fdomain::<BufferCollectionMarker>("wait_for_all_buffers_allocated")?;
2780            Ok(_response.map(|x| x))
2781        }
2782        self.client.send_query_and_decode::<
2783            fidl::encoding::EmptyPayload,
2784            BufferCollectionWaitForAllBuffersAllocatedResult,
2785        >(
2786            (),
2787            0x62300344b61404e,
2788            fidl::encoding::DynamicFlags::FLEXIBLE,
2789            _decode,
2790        )
2791    }
2792
2793    type CheckAllBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
2794        BufferCollectionCheckAllBuffersAllocatedResult,
2795        fdomain_client::fidl::FDomainResourceDialect,
2796    >;
2797    fn r#check_all_buffers_allocated(&self) -> Self::CheckAllBuffersAllocatedResponseFut {
2798        fn _decode(
2799            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2800        ) -> Result<BufferCollectionCheckAllBuffersAllocatedResult, fidl::Error> {
2801            let _response = fidl::client::decode_transaction_body::<
2802                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
2803                fdomain_client::fidl::FDomainResourceDialect,
2804                0x35a5fe77ce939c10,
2805            >(_buf?)?
2806            .into_result_fdomain::<BufferCollectionMarker>("check_all_buffers_allocated")?;
2807            Ok(_response.map(|x| x))
2808        }
2809        self.client.send_query_and_decode::<
2810            fidl::encoding::EmptyPayload,
2811            BufferCollectionCheckAllBuffersAllocatedResult,
2812        >(
2813            (),
2814            0x35a5fe77ce939c10,
2815            fidl::encoding::DynamicFlags::FLEXIBLE,
2816            _decode,
2817        )
2818    }
2819
2820    fn r#attach_token(
2821        &self,
2822        mut payload: BufferCollectionAttachTokenRequest,
2823    ) -> Result<(), fidl::Error> {
2824        self.client.send::<BufferCollectionAttachTokenRequest>(
2825            &mut payload,
2826            0x46ac7d0008492982,
2827            fidl::encoding::DynamicFlags::FLEXIBLE,
2828        )
2829    }
2830
2831    fn r#attach_lifetime_tracking(
2832        &self,
2833        mut payload: BufferCollectionAttachLifetimeTrackingRequest,
2834    ) -> Result<(), fidl::Error> {
2835        self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
2836            &mut payload,
2837            0x3ecb510113116dcf,
2838            fidl::encoding::DynamicFlags::FLEXIBLE,
2839        )
2840    }
2841}
2842
2843pub struct BufferCollectionEventStream {
2844    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2845}
2846
2847impl std::marker::Unpin for BufferCollectionEventStream {}
2848
2849impl futures::stream::FusedStream for BufferCollectionEventStream {
2850    fn is_terminated(&self) -> bool {
2851        self.event_receiver.is_terminated()
2852    }
2853}
2854
2855impl futures::Stream for BufferCollectionEventStream {
2856    type Item = Result<BufferCollectionEvent, fidl::Error>;
2857
2858    fn poll_next(
2859        mut self: std::pin::Pin<&mut Self>,
2860        cx: &mut std::task::Context<'_>,
2861    ) -> std::task::Poll<Option<Self::Item>> {
2862        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2863            &mut self.event_receiver,
2864            cx
2865        )?) {
2866            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
2867            None => std::task::Poll::Ready(None),
2868        }
2869    }
2870}
2871
2872#[derive(Debug)]
2873pub enum BufferCollectionEvent {
2874    #[non_exhaustive]
2875    _UnknownEvent {
2876        /// Ordinal of the event that was sent.
2877        ordinal: u64,
2878    },
2879}
2880
2881impl BufferCollectionEvent {
2882    /// Decodes a message buffer as a [`BufferCollectionEvent`].
2883    fn decode(
2884        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2885    ) -> Result<BufferCollectionEvent, fidl::Error> {
2886        let (bytes, _handles) = buf.split_mut();
2887        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2888        debug_assert_eq!(tx_header.tx_id, 0);
2889        match tx_header.ordinal {
2890            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2891                Ok(BufferCollectionEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2892            }
2893            _ => Err(fidl::Error::UnknownOrdinal {
2894                ordinal: tx_header.ordinal,
2895                protocol_name:
2896                    <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2897            }),
2898        }
2899    }
2900}
2901
2902/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollection.
2903pub struct BufferCollectionRequestStream {
2904    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2905    is_terminated: bool,
2906}
2907
2908impl std::marker::Unpin for BufferCollectionRequestStream {}
2909
2910impl futures::stream::FusedStream for BufferCollectionRequestStream {
2911    fn is_terminated(&self) -> bool {
2912        self.is_terminated
2913    }
2914}
2915
2916impl fdomain_client::fidl::RequestStream for BufferCollectionRequestStream {
2917    type Protocol = BufferCollectionMarker;
2918    type ControlHandle = BufferCollectionControlHandle;
2919
2920    fn from_channel(channel: fdomain_client::Channel) -> Self {
2921        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2922    }
2923
2924    fn control_handle(&self) -> Self::ControlHandle {
2925        BufferCollectionControlHandle { inner: self.inner.clone() }
2926    }
2927
2928    fn into_inner(
2929        self,
2930    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2931    {
2932        (self.inner, self.is_terminated)
2933    }
2934
2935    fn from_inner(
2936        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2937        is_terminated: bool,
2938    ) -> Self {
2939        Self { inner, is_terminated }
2940    }
2941}
2942
2943impl futures::Stream for BufferCollectionRequestStream {
2944    type Item = Result<BufferCollectionRequest, fidl::Error>;
2945
2946    fn poll_next(
2947        mut self: std::pin::Pin<&mut Self>,
2948        cx: &mut std::task::Context<'_>,
2949    ) -> std::task::Poll<Option<Self::Item>> {
2950        let this = &mut *self;
2951        if this.inner.check_shutdown(cx) {
2952            this.is_terminated = true;
2953            return std::task::Poll::Ready(None);
2954        }
2955        if this.is_terminated {
2956            panic!("polled BufferCollectionRequestStream after completion");
2957        }
2958        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2959            |bytes, handles| {
2960                match this.inner.channel().read_etc(cx, bytes, handles) {
2961                    std::task::Poll::Ready(Ok(())) => {}
2962                    std::task::Poll::Pending => return std::task::Poll::Pending,
2963                    std::task::Poll::Ready(Err(None)) => {
2964                        this.is_terminated = true;
2965                        return std::task::Poll::Ready(None);
2966                    }
2967                    std::task::Poll::Ready(Err(Some(e))) => {
2968                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2969                            e.into(),
2970                        ))));
2971                    }
2972                }
2973
2974                // A message has been received from the channel
2975                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2976
2977                std::task::Poll::Ready(Some(match header.ordinal {
2978                0x11ac2555cf575b54 => {
2979                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2980                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2981                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2982                    let control_handle = BufferCollectionControlHandle {
2983                        inner: this.inner.clone(),
2984                    };
2985                    Ok(BufferCollectionRequest::Sync {
2986                        responder: BufferCollectionSyncResponder {
2987                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2988                            tx_id: header.tx_id,
2989                        },
2990                    })
2991                }
2992                0x6a5cae7d6d6e04c6 => {
2993                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2994                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2995                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2996                    let control_handle = BufferCollectionControlHandle {
2997                        inner: this.inner.clone(),
2998                    };
2999                    Ok(BufferCollectionRequest::Release {
3000                        control_handle,
3001                    })
3002                }
3003                0xb41f1624f48c1e9 => {
3004                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3005                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
3006                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
3007                    let control_handle = BufferCollectionControlHandle {
3008                        inner: this.inner.clone(),
3009                    };
3010                    Ok(BufferCollectionRequest::SetName {payload: req,
3011                        control_handle,
3012                    })
3013                }
3014                0x5cde8914608d99b1 => {
3015                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3016                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
3017                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
3018                    let control_handle = BufferCollectionControlHandle {
3019                        inner: this.inner.clone(),
3020                    };
3021                    Ok(BufferCollectionRequest::SetDebugClientInfo {payload: req,
3022                        control_handle,
3023                    })
3024                }
3025                0x716b0af13d5c0806 => {
3026                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3027                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
3028                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
3029                    let control_handle = BufferCollectionControlHandle {
3030                        inner: this.inner.clone(),
3031                    };
3032                    Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {payload: req,
3033                        control_handle,
3034                    })
3035                }
3036                0x5209c77415b4dfad => {
3037                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3038                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3039                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3040                    let control_handle = BufferCollectionControlHandle {
3041                        inner: this.inner.clone(),
3042                    };
3043                    Ok(BufferCollectionRequest::SetVerboseLogging {
3044                        control_handle,
3045                    })
3046                }
3047                0x5b3d0e51614df053 => {
3048                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3049                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3050                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3051                    let control_handle = BufferCollectionControlHandle {
3052                        inner: this.inner.clone(),
3053                    };
3054                    Ok(BufferCollectionRequest::GetNodeRef {
3055                        responder: BufferCollectionGetNodeRefResponder {
3056                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3057                            tx_id: header.tx_id,
3058                        },
3059                    })
3060                }
3061                0x3a58e00157e0825 => {
3062                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3063                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
3064                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
3065                    let control_handle = BufferCollectionControlHandle {
3066                        inner: this.inner.clone(),
3067                    };
3068                    Ok(BufferCollectionRequest::IsAlternateFor {payload: req,
3069                        responder: BufferCollectionIsAlternateForResponder {
3070                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3071                            tx_id: header.tx_id,
3072                        },
3073                    })
3074                }
3075                0x77d19a494b78ba8c => {
3076                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3077                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3078                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3079                    let control_handle = BufferCollectionControlHandle {
3080                        inner: this.inner.clone(),
3081                    };
3082                    Ok(BufferCollectionRequest::GetBufferCollectionId {
3083                        responder: BufferCollectionGetBufferCollectionIdResponder {
3084                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3085                            tx_id: header.tx_id,
3086                        },
3087                    })
3088                }
3089                0x22dd3ea514eeffe1 => {
3090                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3091                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3092                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3093                    let control_handle = BufferCollectionControlHandle {
3094                        inner: this.inner.clone(),
3095                    };
3096                    Ok(BufferCollectionRequest::SetWeak {
3097                        control_handle,
3098                    })
3099                }
3100                0x38a44fc4d7724be9 => {
3101                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3102                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
3103                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
3104                    let control_handle = BufferCollectionControlHandle {
3105                        inner: this.inner.clone(),
3106                    };
3107                    Ok(BufferCollectionRequest::SetWeakOk {payload: req,
3108                        control_handle,
3109                    })
3110                }
3111                0x3f22f2a293d3cdac => {
3112                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3113                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
3114                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3115                    let control_handle = BufferCollectionControlHandle {
3116                        inner: this.inner.clone(),
3117                    };
3118                    Ok(BufferCollectionRequest::AttachNodeTracking {payload: req,
3119                        control_handle,
3120                    })
3121                }
3122                0x1fde0f19d650197b => {
3123                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3124                    let mut req = fidl::new_empty!(BufferCollectionSetConstraintsRequest, fdomain_client::fidl::FDomainResourceDialect);
3125                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
3126                    let control_handle = BufferCollectionControlHandle {
3127                        inner: this.inner.clone(),
3128                    };
3129                    Ok(BufferCollectionRequest::SetConstraints {payload: req,
3130                        control_handle,
3131                    })
3132                }
3133                0x62300344b61404e => {
3134                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3135                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3136                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3137                    let control_handle = BufferCollectionControlHandle {
3138                        inner: this.inner.clone(),
3139                    };
3140                    Ok(BufferCollectionRequest::WaitForAllBuffersAllocated {
3141                        responder: BufferCollectionWaitForAllBuffersAllocatedResponder {
3142                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3143                            tx_id: header.tx_id,
3144                        },
3145                    })
3146                }
3147                0x35a5fe77ce939c10 => {
3148                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3149                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3150                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3151                    let control_handle = BufferCollectionControlHandle {
3152                        inner: this.inner.clone(),
3153                    };
3154                    Ok(BufferCollectionRequest::CheckAllBuffersAllocated {
3155                        responder: BufferCollectionCheckAllBuffersAllocatedResponder {
3156                            control_handle: std::mem::ManuallyDrop::new(control_handle),
3157                            tx_id: header.tx_id,
3158                        },
3159                    })
3160                }
3161                0x46ac7d0008492982 => {
3162                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3163                    let mut req = fidl::new_empty!(BufferCollectionAttachTokenRequest, fdomain_client::fidl::FDomainResourceDialect);
3164                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
3165                    let control_handle = BufferCollectionControlHandle {
3166                        inner: this.inner.clone(),
3167                    };
3168                    Ok(BufferCollectionRequest::AttachToken {payload: req,
3169                        control_handle,
3170                    })
3171                }
3172                0x3ecb510113116dcf => {
3173                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3174                    let mut req = fidl::new_empty!(BufferCollectionAttachLifetimeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
3175                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
3176                    let control_handle = BufferCollectionControlHandle {
3177                        inner: this.inner.clone(),
3178                    };
3179                    Ok(BufferCollectionRequest::AttachLifetimeTracking {payload: req,
3180                        control_handle,
3181                    })
3182                }
3183                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3184                    Ok(BufferCollectionRequest::_UnknownMethod {
3185                        ordinal: header.ordinal,
3186                        control_handle: BufferCollectionControlHandle { inner: this.inner.clone() },
3187                        method_type: fidl::MethodType::OneWay,
3188                    })
3189                }
3190                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3191                    this.inner.send_framework_err(
3192                        fidl::encoding::FrameworkErr::UnknownMethod,
3193                        header.tx_id,
3194                        header.ordinal,
3195                        header.dynamic_flags(),
3196                        (bytes, handles),
3197                    )?;
3198                    Ok(BufferCollectionRequest::_UnknownMethod {
3199                        ordinal: header.ordinal,
3200                        control_handle: BufferCollectionControlHandle { inner: this.inner.clone() },
3201                        method_type: fidl::MethodType::TwoWay,
3202                    })
3203                }
3204                _ => Err(fidl::Error::UnknownOrdinal {
3205                    ordinal: header.ordinal,
3206                    protocol_name: <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3207                }),
3208            }))
3209            },
3210        )
3211    }
3212}
3213
3214/// [`fuchsia.sysmem2/BufferCollection`] is a connection directly from a
3215/// participant to sysmem re. a buffer collection; often the buffer collection
3216/// is shared with other participants which have their own `BufferCollection`
3217/// client end(s) associated with the same buffer collection.  In other words,
3218/// an instance of the `BufferCollection` interface is a view of a buffer
3219/// collection, not the buffer collection itself.
3220///
3221/// The `BufferCollection` connection exists to facilitate async indication of
3222/// when the buffer collection has been populated with buffers.
3223///
3224/// Also, the channel's closure by the sysmem server is an indication to the
3225/// client that the client should close all VMO handles that were obtained from
3226/// the `BufferCollection` ASAP.
3227///
3228/// Some buffer collections can use enough memory that it can be worth avoiding
3229/// allocation overlap (in time) using
3230/// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] so that the
3231/// initiator can tell when enough buffers of the buffer collection have been
3232/// fully deallocated prior to the initiator allocating a new buffer collection.
3233///
3234/// Epitaphs are not used in this protocol.
3235#[derive(Debug)]
3236pub enum BufferCollectionRequest {
3237    /// Ensure that previous messages have been received server side. This is
3238    /// particularly useful after previous messages that created new tokens,
3239    /// because a token must be known to the sysmem server before sending the
3240    /// token to another participant.
3241    ///
3242    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
3243    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
3244    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
3245    /// to mitigate the possibility of a hostile/fake
3246    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
3247    /// Another way is to pass the token to
3248    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
3249    /// the token as part of exchanging it for a
3250    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
3251    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
3252    /// of stalling.
3253    ///
3254    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
3255    /// and then starting and completing a `Sync`, it's then safe to send the
3256    /// `BufferCollectionToken` client ends to other participants knowing the
3257    /// server will recognize the tokens when they're sent by the other
3258    /// participants to sysmem in a
3259    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
3260    /// efficient way to create tokens while avoiding unnecessary round trips.
3261    ///
3262    /// Other options include waiting for each
3263    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
3264    /// individually (using separate call to `Sync` after each), or calling
3265    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
3266    /// converted to a `BufferCollection` via
3267    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
3268    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
3269    /// the sync step and can create multiple tokens at once.
3270    Sync { responder: BufferCollectionSyncResponder },
3271    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
3272    ///
3273    /// Normally a participant will convert a `BufferCollectionToken` into a
3274    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
3275    /// `Release` via the token (and then close the channel immediately or
3276    /// shortly later in response to server closing the server end), which
3277    /// avoids causing buffer collection failure. Without a prior `Release`,
3278    /// closing the `BufferCollectionToken` client end will cause buffer
3279    /// collection failure.
3280    ///
3281    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
3282    ///
3283    /// By default the server handles unexpected closure of a
3284    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
3285    /// first) by failing the buffer collection. Partly this is to expedite
3286    /// closing VMO handles to reclaim memory when any participant fails. If a
3287    /// participant would like to cleanly close a `BufferCollection` without
3288    /// causing buffer collection failure, the participant can send `Release`
3289    /// before closing the `BufferCollection` client end. The `Release` can
3290    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
3291    /// buffer collection won't require constraints from this node in order to
3292    /// allocate. If after `SetConstraints`, the constraints are retained and
3293    /// aggregated, despite the lack of `BufferCollection` connection at the
3294    /// time of constraints aggregation.
3295    ///
3296    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
3297    ///
3298    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
3299    /// end (without `Release` first) will trigger failure of the buffer
3300    /// collection. To close a `BufferCollectionTokenGroup` channel without
3301    /// failing the buffer collection, ensure that AllChildrenPresent() has been
3302    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
3303    /// client end.
3304    ///
3305    /// If `Release` occurs before
3306    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
3307    /// buffer collection will fail (triggered by reception of `Release` without
3308    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
3309    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
3310    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
3311    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
3312    /// close requires `AllChildrenPresent` (if not already sent), then
3313    /// `Release`, then close client end.
3314    ///
3315    /// If `Release` occurs after `AllChildrenPresent`, the children and all
3316    /// their constraints remain intact (just as they would if the
3317    /// `BufferCollectionTokenGroup` channel had remained open), and the client
3318    /// end close doesn't trigger buffer collection failure.
3319    ///
3320    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
3321    ///
3322    /// For brevity, the per-channel-protocol paragraphs above ignore the
3323    /// separate failure domain created by
3324    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
3325    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
3326    /// unexpectedly closes (without `Release` first) and that client end is
3327    /// under a failure domain, instead of failing the whole buffer collection,
3328    /// the failure domain is failed, but the buffer collection itself is
3329    /// isolated from failure of the failure domain. Such failure domains can be
3330    /// nested, in which case only the inner-most failure domain in which the
3331    /// `Node` resides fails.
3332    Release { control_handle: BufferCollectionControlHandle },
3333    /// Set a name for VMOs in this buffer collection.
3334    ///
3335    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
3336    /// will be truncated to fit. The name of the vmo will be suffixed with the
3337    /// buffer index within the collection (if the suffix fits within
3338    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
3339    /// listed in the inspect data.
3340    ///
3341    /// The name only affects VMOs allocated after the name is set; this call
3342    /// does not rename existing VMOs. If multiple clients set different names
3343    /// then the larger priority value will win. Setting a new name with the
3344    /// same priority as a prior name doesn't change the name.
3345    ///
3346    /// All table fields are currently required.
3347    ///
3348    /// + request `priority` The name is only set if this is the first `SetName`
3349    ///   or if `priority` is greater than any previous `priority` value in
3350    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
3351    /// + request `name` The name for VMOs created under this buffer collection.
3352    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionControlHandle },
3353    /// Set information about the current client that can be used by sysmem to
3354    /// help diagnose leaking memory and allocation stalls waiting for a
3355    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
3356    ///
3357    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
3358    /// `Node`(s) derived from this `Node`, unless overriden by
3359    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
3360    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
3361    ///
3362    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
3363    /// `Allocator` is the most efficient way to ensure that all
3364    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
3365    /// set, and is also more efficient than separately sending the same debug
3366    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
3367    /// created [`fuchsia.sysmem2/Node`].
3368    ///
3369    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
3370    /// indicate which client is closing their channel first, leading to subtree
3371    /// failure (which can be normal if the purpose of the subtree is over, but
3372    /// if happening earlier than expected, the client-channel-specific name can
3373    /// help diagnose where the failure is first coming from, from sysmem's
3374    /// point of view).
3375    ///
3376    /// All table fields are currently required.
3377    ///
3378    /// + request `name` This can be an arbitrary string, but the current
3379    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
3380    /// + request `id` This can be an arbitrary id, but the current process ID
3381    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
3382    SetDebugClientInfo {
3383        payload: NodeSetDebugClientInfoRequest,
3384        control_handle: BufferCollectionControlHandle,
3385    },
3386    /// Sysmem logs a warning if sysmem hasn't seen
3387    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
3388    /// within 5 seconds after creation of a new collection.
3389    ///
3390    /// Clients can call this method to change when the log is printed. If
3391    /// multiple client set the deadline, it's unspecified which deadline will
3392    /// take effect.
3393    ///
3394    /// In most cases the default works well.
3395    ///
3396    /// All table fields are currently required.
3397    ///
3398    /// + request `deadline` The time at which sysmem will start trying to log
3399    ///   the warning, unless all constraints are with sysmem by then.
3400    SetDebugTimeoutLogDeadline {
3401        payload: NodeSetDebugTimeoutLogDeadlineRequest,
3402        control_handle: BufferCollectionControlHandle,
3403    },
3404    /// This enables verbose logging for the buffer collection.
3405    ///
3406    /// Verbose logging includes constraints set via
3407    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
3408    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
3409    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
3410    /// the tree of `Node`(s).
3411    ///
3412    /// Normally sysmem prints only a single line complaint when aggregation
3413    /// fails, with just the specific detailed reason that aggregation failed,
3414    /// with little surrounding context.  While this is often enough to diagnose
3415    /// a problem if only a small change was made and everything was working
3416    /// before the small change, it's often not particularly helpful for getting
3417    /// a new buffer collection to work for the first time.  Especially with
3418    /// more complex trees of nodes, involving things like
3419    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
3420    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
3421    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
3422    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
3423    /// looks like and why it's failing a logical allocation, or why a tree or
3424    /// subtree is failing sooner than expected.
3425    ///
3426    /// The intent of the extra logging is to be acceptable from a performance
3427    /// point of view, under the assumption that verbose logging is only enabled
3428    /// on a low number of buffer collections. If we're not tracking down a bug,
3429    /// we shouldn't send this message.
3430    SetVerboseLogging { control_handle: BufferCollectionControlHandle },
3431    /// This gets a handle that can be used as a parameter to
3432    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
3433    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
3434    /// client obtained this handle from this `Node`.
3435    ///
3436    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
3437    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
3438    /// despite the two calls typically being on different channels.
3439    ///
3440    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
3441    ///
3442    /// All table fields are currently required.
3443    ///
3444    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
3445    ///   different `Node` channel, to prove that the client obtained the handle
3446    ///   from this `Node`.
3447    GetNodeRef { responder: BufferCollectionGetNodeRefResponder },
3448    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
3449    /// rooted at a different child token of a common parent
3450    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
3451    /// passed-in `node_ref`.
3452    ///
3453    /// This call is for assisting with admission control de-duplication, and
3454    /// with debugging.
3455    ///
3456    /// The `node_ref` must be obtained using
3457    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
3458    ///
3459    /// The `node_ref` can be a duplicated handle; it's not necessary to call
3460    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
3461    ///
3462    /// If a calling token may not actually be a valid token at all due to a
3463    /// potentially hostile/untrusted provider of the token, call
3464    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
3465    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
3466    /// never responds due to a calling token not being a real token (not really
3467    /// talking to sysmem).  Another option is to call
3468    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
3469    /// which also validates the token along with converting it to a
3470    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
3471    ///
3472    /// All table fields are currently required.
3473    ///
3474    /// - response `is_alternate`
3475    ///   - true: The first parent node in common between the calling node and
3476    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
3477    ///     that the calling `Node` and the `node_ref` `Node` will not have both
3478    ///     their constraints apply - rather sysmem will choose one or the other
3479    ///     of the constraints - never both.  This is because only one child of
3480    ///     a `BufferCollectionTokenGroup` is selected during logical
3481    ///     allocation, with only that one child's subtree contributing to
3482    ///     constraints aggregation.
3483    ///   - false: The first parent node in common between the calling `Node`
3484    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
3485    ///     Currently, this means the first parent node in common is a
3486    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
3487    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
3488    ///     `Node` may have both their constraints apply during constraints
3489    ///     aggregation of the logical allocation, if both `Node`(s) are
3490    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
3491    ///     this case, there is no `BufferCollectionTokenGroup` that will
3492    ///     directly prevent the two `Node`(s) from both being selected and
3493    ///     their constraints both aggregated, but even when false, one or both
3494    ///     `Node`(s) may still be eliminated from consideration if one or both
3495    ///     `Node`(s) has a direct or indirect parent
3496    ///     `BufferCollectionTokenGroup` which selects a child subtree other
3497    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
3498    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
3499    ///   associated with the same buffer collection as the calling `Node`.
3500    ///   Another reason for this error is if the `node_ref` is an
3501    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
3502    ///   a real `node_ref` obtained from `GetNodeRef`.
3503    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
3504    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
3505    ///   the needed rights expected on a real `node_ref`.
3506    /// * No other failing status codes are returned by this call.  However,
3507    ///   sysmem may add additional codes in future, so the client should have
3508    ///   sensible default handling for any failing status code.
3509    IsAlternateFor {
3510        payload: NodeIsAlternateForRequest,
3511        responder: BufferCollectionIsAlternateForResponder,
3512    },
3513    /// Get the buffer collection ID. This ID is also available from
3514    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
3515    /// within the collection).
3516    ///
3517    /// This call is mainly useful in situations where we can't convey a
3518    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
3519    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
3520    /// handle, which can be joined back up with a `BufferCollection` client end
3521    /// that was created via a different path. Prefer to convey a
3522    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
3523    ///
3524    /// Trusting a `buffer_collection_id` value from a source other than sysmem
3525    /// is analogous to trusting a koid value from a source other than zircon.
3526    /// Both should be avoided unless really necessary, and both require
3527    /// caution. In some situations it may be reasonable to refer to a
3528    /// pre-established `BufferCollection` by `buffer_collection_id` via a
3529    /// protocol for efficiency reasons, but an incoming value purporting to be
3530    /// a `buffer_collection_id` is not sufficient alone to justify granting the
3531    /// sender of the `buffer_collection_id` any capability. The sender must
3532    /// first prove to a receiver that the sender has/had a VMO or has/had a
3533    /// `BufferCollectionToken` to the same collection by sending a handle that
3534    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
3535    /// `buffer_collection_id` value. The receiver should take care to avoid
3536    /// assuming that a sender had a `BufferCollectionToken` in cases where the
3537    /// sender has only proven that the sender had a VMO.
3538    ///
3539    /// - response `buffer_collection_id` This ID is unique per buffer
3540    ///   collection per boot. Each buffer is uniquely identified by the
3541    ///   `buffer_collection_id` and `buffer_index` together.
3542    GetBufferCollectionId { responder: BufferCollectionGetBufferCollectionIdResponder },
3543    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
3544    /// created after this message to weak, which means that a client's `Node`
3545    /// client end (or a child created after this message) is not alone
3546    /// sufficient to keep allocated VMOs alive.
3547    ///
3548    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
3549    /// `close_weak_asap`.
3550    ///
3551    /// This message is only permitted before the `Node` becomes ready for
3552    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
3553    ///   * `BufferCollectionToken`: any time
3554    ///   * `BufferCollection`: before `SetConstraints`
3555    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
3556    ///
3557    /// Currently, no conversion from strong `Node` to weak `Node` after ready
3558    /// for allocation is provided, but a client can simulate that by creating
3559    /// an additional `Node` before allocation and setting that additional
3560    /// `Node` to weak, and then potentially at some point later sending
3561    /// `Release` and closing the client end of the client's strong `Node`, but
3562    /// keeping the client's weak `Node`.
3563    ///
3564    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
3565    /// collection failure (all `Node` client end(s) will see
3566    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
3567    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
3568    /// this situation until all `Node`(s) are ready for allocation. For initial
3569    /// allocation to succeed, at least one strong `Node` is required to exist
3570    /// at allocation time, but after that client receives VMO handles, that
3571    /// client can `BufferCollection.Release` and close the client end without
3572    /// causing this type of failure.
3573    ///
3574    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
3575    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
3576    /// separately as appropriate.
3577    SetWeak { control_handle: BufferCollectionControlHandle },
3578    /// This indicates to sysmem that the client is prepared to pay attention to
3579    /// `close_weak_asap`.
3580    ///
3581    /// If sent, this message must be before
3582    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
3583    ///
3584    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
3585    /// send this message before `WaitForAllBuffersAllocated`, or a parent
3586    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
3587    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
3588    /// trigger buffer collection failure.
3589    ///
3590    /// This message is necessary because weak sysmem VMOs have not always been
3591    /// a thing, so older clients are not aware of the need to pay attention to
3592    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
3593    /// sysmem weak VMO handles asap. By having this message and requiring
3594    /// participants to indicate their acceptance of this aspect of the overall
3595    /// protocol, we avoid situations where an older client is delivered a weak
3596    /// VMO without any way for sysmem to get that VMO to close quickly later
3597    /// (and on a per-buffer basis).
3598    ///
3599    /// A participant that doesn't handle `close_weak_asap` and also doesn't
3600    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
3601    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
3602    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
3603    /// same participant has a child/delegate which does retrieve VMOs, that
3604    /// child/delegate will need to send `SetWeakOk` before
3605    /// `WaitForAllBuffersAllocated`.
3606    ///
3607    /// + request `for_child_nodes_also` If present and true, this means direct
3608    ///   child nodes of this node created after this message plus all
3609    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
3610    ///   those nodes. Any child node of this node that was created before this
3611    ///   message is not included. This setting is "sticky" in the sense that a
3612    ///   subsequent `SetWeakOk` without this bool set to true does not reset
3613    ///   the server-side bool. If this creates a problem for a participant, a
3614    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
3615    ///   tokens instead, as appropriate. A participant should only set
3616    ///   `for_child_nodes_also` true if the participant can really promise to
3617    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
3618    ///   weak VMO handles held by participants holding the corresponding child
3619    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
3620    ///   which are using sysmem(1) can be weak, despite the clients of those
3621    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
3622    ///   direct way to find out about `close_weak_asap`. This only applies to
3623    ///   descendents of this `Node` which are using sysmem(1), not to this
3624    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
3625    ///   token, which will fail allocation unless an ancestor of this `Node`
3626    ///   specified `for_child_nodes_also` true.
3627    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: BufferCollectionControlHandle },
3628    /// The server_end will be closed after this `Node` and any child nodes have
3629    /// have released their buffer counts, making those counts available for
3630    /// reservation by a different `Node` via
3631    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
3632    ///
3633    /// The `Node` buffer counts may not be released until the entire tree of
3634    /// `Node`(s) is closed or failed, because
3635    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
3636    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
3637    /// `Node` buffer counts remain reserved until the orphaned node is later
3638    /// cleaned up.
3639    ///
3640    /// If the `Node` exceeds a fairly large number of attached eventpair server
3641    /// ends, a log message will indicate this and the `Node` (and the
3642    /// appropriate) sub-tree will fail.
3643    ///
3644    /// The `server_end` will remain open when
3645    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
3646    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
3647    /// [`fuchsia.sysmem2/BufferCollection`].
3648    ///
3649    /// This message can also be used with a
3650    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
3651    AttachNodeTracking {
3652        payload: NodeAttachNodeTrackingRequest,
3653        control_handle: BufferCollectionControlHandle,
3654    },
3655    /// Provide [`fuchsia.sysmem2/BufferCollectionConstraints`] to the buffer
3656    /// collection.
3657    ///
3658    /// A participant may only call
3659    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] up to once per
3660    /// [`fuchsia.sysmem2/BufferCollection`].
3661    ///
3662    /// For buffer allocation to be attempted, all holders of a
3663    /// `BufferCollection` client end need to call `SetConstraints` before
3664    /// sysmem will attempt to allocate buffers.
3665    SetConstraints {
3666        payload: BufferCollectionSetConstraintsRequest,
3667        control_handle: BufferCollectionControlHandle,
3668    },
3669    /// Wait until all buffers are allocated.
3670    ///
3671    /// This FIDL call completes when buffers have been allocated, or completes
3672    /// with some failure detail if allocation has been attempted but failed.
3673    ///
3674    /// The following must occur before buffers will be allocated:
3675    ///   * All [`fuchsia.sysmem2/BufferCollectionToken`](s) of the buffer
3676    ///     collection must be turned in via `BindSharedCollection` to get a
3677    ///     [`fuchsia.sysmem2/BufferCollection`] (for brevity, this is assuming
3678    ///     [`fuchsia.sysmem2/BufferCollection.AttachToken`] isn't being used),
3679    ///     or have had [`fuchsia.sysmem2/BufferCollectionToken.Release`] sent
3680    ///     to them.
3681    ///   * All [`fuchsia.sysmem2/BufferCollection`](s) of the buffer collection
3682    ///     must have had [`fuchsia.sysmem2/BufferCollection.SetConstraints`]
3683    ///     sent to them, or had [`fuchsia.sysmem2/BufferCollection.Release`]
3684    ///     sent to them.
3685    ///
3686    /// - result `buffer_collection_info` The VMO handles and other related
3687    ///   info.
3688    /// * error `[fuchsia.sysmem2/Error.NO_MEMORY]` The request is valid but
3689    ///   cannot be fulfilled due to resource exhaustion.
3690    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION`] The request is
3691    ///   malformed.
3692    /// * error `[fuchsia.sysmem2/Error.CONSTRAINTS_INTERSECTION_EMPTY`] The
3693    ///   request is valid but cannot be satisfied, perhaps due to hardware
3694    ///   limitations. This can happen if participants have incompatible
3695    ///   constraints (empty intersection, roughly speaking). See the log for
3696    ///   more info. In cases where a participant could potentially be treated
3697    ///   as optional, see [`BufferCollectionTokenGroup`]. When using
3698    ///   [`fuchsia.sysmem2/BufferCollection.AttachToken`], this will be the
3699    ///   error code if there aren't enough buffers in the pre-existing
3700    ///   collection to satisfy the constraints set on the attached token and
3701    ///   any sub-tree of tokens derived from the attached token.
3702    WaitForAllBuffersAllocated { responder: BufferCollectionWaitForAllBuffersAllocatedResponder },
3703    /// Checks whether all the buffers have been allocated, in a polling
3704    /// fashion.
3705    ///
3706    /// * If the buffer collection has been allocated, returns success.
3707    /// * If the buffer collection failed allocation, returns the same
3708    ///   [`fuchsia.sysmem2/Error`] as
3709    ///   [`fuchsia.sysmem2/BufferCollection/WaitForAllBuffersAllocated`] would
3710    ///   return.
3711    /// * error [`fuchsia.sysmem2/Error.PENDING`] The buffer collection hasn't
3712    ///   attempted allocation yet. This means that WaitForAllBuffersAllocated
3713    ///   would not respond quickly.
3714    CheckAllBuffersAllocated { responder: BufferCollectionCheckAllBuffersAllocatedResponder },
3715    /// Create a new token to add a new participant to an existing logical
3716    /// buffer collection, if the existing collection's buffer counts,
3717    /// constraints, and participants allow.
3718    ///
3719    /// This can be useful in replacing a failed participant, and/or in
3720    /// adding/re-adding a participant after buffers have already been
3721    /// allocated.
3722    ///
3723    /// When [`fuchsia.sysmem2/BufferCollection.AttachToken`] is used, the sub
3724    /// tree rooted at the attached [`fuchsia.sysmem2/BufferCollectionToken`]
3725    /// goes through the normal procedure of setting constraints or closing
3726    /// [`fuchsia.sysmem2/Node`](s), and then appearing to allocate buffers from
3727    /// clients' point of view, despite the possibility that all the buffers
3728    /// were actually allocated previously. This process is called "logical
3729    /// allocation". Most instances of "allocation" in docs for other messages
3730    /// can also be read as "allocation or logical allocation" while remaining
3731    /// valid, but we just say "allocation" in most places for brevity/clarity
3732    /// of explanation, with the details of "logical allocation" left for the
3733    /// docs here on `AttachToken`.
3734    ///
3735    /// Failure of an attached `Node` does not propagate to the parent of the
3736    /// attached `Node`. More generally, failure of a child `Node` is blocked
3737    /// from reaching its parent `Node` if the child is attached, or if the
3738    /// child is dispensable and the failure occurred after logical allocation
3739    /// (see [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`]).
3740    ///
3741    /// A participant may in some scenarios choose to initially use a
3742    /// dispensable token for a given instance of a delegate participant, and
3743    /// then later if the first instance of that delegate participant fails, a
3744    /// new second instance of that delegate participant my be given a token
3745    /// created with `AttachToken`.
3746    ///
3747    /// From the point of view of the [`fuchsia.sysmem2/BufferCollectionToken`]
3748    /// client end, the token acts like any other token. The client can
3749    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] the token as needed,
3750    /// and can send the token to a different process/participant. The
3751    /// `BufferCollectionToken` `Node` should be converted to a
3752    /// `BufferCollection` `Node` as normal by sending
3753    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or can be closed
3754    /// without causing subtree failure by sending
3755    /// [`fuchsia.sysmem2/BufferCollectionToken.Release`]. Assuming the former,
3756    /// the [`fuchsia.sysmem2/BufferCollection.SetConstraints`] message or
3757    /// [`fuchsia.sysmem2/BufferCollection.Release`] message should be sent to
3758    /// the `BufferCollection`.
3759    ///
3760    /// Within the subtree, a success result from
3761    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`] means
3762    /// the subtree participants' constraints were satisfiable using the
3763    /// already-existing buffer collection, the already-established
3764    /// [`fuchsia.sysmem2/BufferCollectionInfo`] including image format
3765    /// constraints, and the already-existing other participants (already added
3766    /// via successful logical allocation) and their specified buffer counts in
3767    /// their constraints. A failure result means the new participants'
3768    /// constraints cannot be satisfied using the existing buffer collection and
3769    /// its already-added participants. Creating a new collection instead may
3770    /// allow all participants' constraints to be satisfied, assuming
3771    /// `SetDispensable` is used in place of `AttachToken`, or a normal token is
3772    /// used.
3773    ///
3774    /// A token created with `AttachToken` performs constraints aggregation with
3775    /// all constraints currently in effect on the buffer collection, plus the
3776    /// attached token under consideration plus child tokens under the attached
3777    /// token which are not themselves an attached token or under such a token.
3778    /// Further subtrees under this subtree are considered for logical
3779    /// allocation only after this subtree has completed logical allocation.
3780    ///
3781    /// Assignment of existing buffers to participants'
3782    /// [`fuchsia.sysmem2/BufferCollectionConstraints.min_buffer_count_for_camping`]
3783    /// etc is first-come first-served, but a child can't logically allocate
3784    /// before all its parents have sent `SetConstraints`.
3785    ///
3786    /// See also [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`], which
3787    /// in contrast to `AttachToken`, has the created token `Node` + child
3788    /// `Node`(s) (in the created subtree but not in any subtree under this
3789    /// subtree) participate in constraints aggregation along with its parent
3790    /// during the parent's allocation or logical allocation.
3791    ///
3792    /// Similar to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], the
3793    /// newly created token needs to be [`fuchsia.sysmem2/Node.Sync`]ed to
3794    /// sysmem before the new token can be passed to `BindSharedCollection`. The
3795    /// `Sync` of the new token can be accomplished with
3796    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after converting the created
3797    /// `BufferCollectionToken` to a `BufferCollection`. Alternately,
3798    /// [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on the new token also
3799    /// works. Or using [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`]
3800    /// works. As usual, a `BufferCollectionToken.Sync` can be started after any
3801    /// `BufferCollectionToken.Duplicate` messages have been sent via the newly
3802    /// created token, to also sync those additional tokens to sysmem using a
3803    /// single round-trip.
3804    ///
3805    /// All table fields are currently required.
3806    ///
3807    /// + request `rights_attentuation_mask` This allows attenuating the VMO
3808    ///   rights of the subtree. These values for `rights_attenuation_mask`
3809    ///   result in no attenuation (note that 0 is not on this list):
3810    ///   + ZX_RIGHT_SAME_RIGHTS (preferred)
3811    ///   + 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3812    /// + request `token_request` The server end of the `BufferCollectionToken`
3813    ///   channel. The client retains the client end.
3814    AttachToken {
3815        payload: BufferCollectionAttachTokenRequest,
3816        control_handle: BufferCollectionControlHandle,
3817    },
3818    /// Set up an eventpair to be signalled (`ZX_EVENTPAIR_PEER_CLOSED`) when
3819    /// buffers have been allocated and only the specified number of buffers (or
3820    /// fewer) remain in the buffer collection.
3821    ///
3822    /// [`fuchsia.sysmem2/BufferCollection.AttachLifetimeTracking`] allows a
3823    /// client to wait until an old buffer collection is fully or mostly
3824    /// deallocated before attempting allocation of a new buffer collection. The
3825    /// eventpair is only signalled when the buffers of this collection have
3826    /// been fully deallocated (not just un-referenced by clients, but all the
3827    /// memory consumed by those buffers has been fully reclaimed/recycled), or
3828    /// when allocation or logical allocation fails for the tree or subtree
3829    /// including this [`fuchsia.sysmem2/BufferCollection`].
3830    ///
3831    /// The eventpair won't be signalled until allocation or logical allocation
3832    /// has completed; until then, the collection's current buffer count is
3833    /// ignored.
3834    ///
3835    /// If logical allocation fails for an attached subtree (using
3836    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]), the server end of the
3837    /// eventpair will close during that failure regardless of the number of
3838    /// buffers potenitally allocated in the overall buffer collection. This is
3839    /// for logical allocation consistency with normal allocation.
3840    ///
3841    /// The lifetime signalled by this event includes asynchronous cleanup of
3842    /// allocated buffers, and this asynchronous cleanup cannot occur until all
3843    /// holders of VMO handles to the buffers have closed those VMO handles.
3844    /// Therefore, clients should take care not to become blocked forever
3845    /// waiting for `ZX_EVENTPAIR_PEER_CLOSED` to be signalled if any of the
3846    /// participants using the logical buffer collection (including the waiter
3847    /// itself) are less trusted, less reliable, or potentially blocked by the
3848    /// wait itself. Waiting asynchronously is recommended. Setting a deadline
3849    /// for the client wait may be prudent, depending on details of how the
3850    /// collection and/or its VMOs are used or shared. Failure to allocate a
3851    /// new/replacement buffer collection is better than getting stuck forever.
3852    ///
3853    /// The sysmem server itself intentionally does not perform any waiting on
3854    /// already-failed collections' VMOs to finish cleaning up before attempting
3855    /// a new allocation, and the sysmem server intentionally doesn't retry
3856    /// allocation if a new allocation fails due to out of memory, even if that
3857    /// failure is potentially due to continued existence of an old collection's
3858    /// VMOs. This `AttachLifetimeTracking` message is how an initiator can
3859    /// mitigate too much overlap of old VMO lifetimes with new VMO lifetimes,
3860    /// as long as the waiting client is careful to not create a deadlock.
3861    ///
3862    /// Continued existence of old collections that are still cleaning up is not
3863    /// the only reason that a new allocation may fail due to insufficient
3864    /// memory, even if the new allocation is allocating physically contiguous
3865    /// buffers. Overall system memory pressure can also be the cause of failure
3866    /// to allocate a new collection. See also
3867    /// [`fuchsia.memorypressure/Provider`].
3868    ///
3869    /// `AttachLifetimeTracking` is meant to be compatible with other protocols
3870    /// with a similar `AttachLifetimeTracking` message; duplicates of the same
3871    /// `eventpair` handle (server end) can be sent via more than one
3872    /// `AttachLifetimeTracking` message to different protocols, and the
3873    /// `ZX_EVENTPAIR_PEER_CLOSED` will be signalled for the client end when all
3874    /// the conditions are met (all holders of duplicates have closed their
3875    /// server end handle(s)). Also, thanks to how eventpair endponts work, the
3876    /// client end can (also) be duplicated without preventing the
3877    /// `ZX_EVENTPAIR_PEER_CLOSED` signal.
3878    ///
3879    /// The server intentionally doesn't "trust" any signals set on the
3880    /// `server_end`. This mechanism intentionally uses only
3881    /// `ZX_EVENTPAIR_PEER_CLOSED` set on the client end, which can't be set
3882    /// "early", and is only set when all handles to the server end eventpair
3883    /// are closed. No meaning is associated with any of the other signals, and
3884    /// clients should ignore any other signal bits on either end of the
3885    /// `eventpair`.
3886    ///
3887    /// The `server_end` may lack `ZX_RIGHT_SIGNAL` or `ZX_RIGHT_SIGNAL_PEER`,
3888    /// but must have `ZX_RIGHT_DUPLICATE` (and must have `ZX_RIGHT_TRANSFER` to
3889    /// transfer without causing `BufferCollection` channel failure).
3890    ///
3891    /// All table fields are currently required.
3892    ///
3893    /// + request `server_end` This eventpair handle will be closed by the
3894    ///   sysmem server when buffers have been allocated initially and the
3895    ///   number of buffers is then less than or equal to `buffers_remaining`.
3896    /// + request `buffers_remaining` Wait for all but `buffers_remaining` (or
3897    ///   fewer) buffers to be fully deallocated. A number greater than zero can
3898    ///   be useful in situations where a known number of buffers are
3899    ///   intentionally not closed so that the data can continue to be used,
3900    ///   such as for keeping the last available video frame displayed in the UI
3901    ///   even if the video stream was using protected output buffers. It's
3902    ///   outside the scope of the `BufferCollection` interface (at least for
3903    ///   now) to determine how many buffers may be held without closing, but
3904    ///   it'll typically be in the range 0-2.
3905    AttachLifetimeTracking {
3906        payload: BufferCollectionAttachLifetimeTrackingRequest,
3907        control_handle: BufferCollectionControlHandle,
3908    },
3909    /// An interaction was received which does not match any known method.
3910    #[non_exhaustive]
3911    _UnknownMethod {
3912        /// Ordinal of the method that was called.
3913        ordinal: u64,
3914        control_handle: BufferCollectionControlHandle,
3915        method_type: fidl::MethodType,
3916    },
3917}
3918
3919impl BufferCollectionRequest {
3920    #[allow(irrefutable_let_patterns)]
3921    pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
3922        if let BufferCollectionRequest::Sync { responder } = self {
3923            Some((responder))
3924        } else {
3925            None
3926        }
3927    }
3928
3929    #[allow(irrefutable_let_patterns)]
3930    pub fn into_release(self) -> Option<(BufferCollectionControlHandle)> {
3931        if let BufferCollectionRequest::Release { control_handle } = self {
3932            Some((control_handle))
3933        } else {
3934            None
3935        }
3936    }
3937
3938    #[allow(irrefutable_let_patterns)]
3939    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, BufferCollectionControlHandle)> {
3940        if let BufferCollectionRequest::SetName { payload, control_handle } = self {
3941            Some((payload, control_handle))
3942        } else {
3943            None
3944        }
3945    }
3946
3947    #[allow(irrefutable_let_patterns)]
3948    pub fn into_set_debug_client_info(
3949        self,
3950    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionControlHandle)> {
3951        if let BufferCollectionRequest::SetDebugClientInfo { payload, control_handle } = self {
3952            Some((payload, control_handle))
3953        } else {
3954            None
3955        }
3956    }
3957
3958    #[allow(irrefutable_let_patterns)]
3959    pub fn into_set_debug_timeout_log_deadline(
3960        self,
3961    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionControlHandle)> {
3962        if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { payload, control_handle } =
3963            self
3964        {
3965            Some((payload, control_handle))
3966        } else {
3967            None
3968        }
3969    }
3970
3971    #[allow(irrefutable_let_patterns)]
3972    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
3973        if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
3974            Some((control_handle))
3975        } else {
3976            None
3977        }
3978    }
3979
3980    #[allow(irrefutable_let_patterns)]
3981    pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
3982        if let BufferCollectionRequest::GetNodeRef { responder } = self {
3983            Some((responder))
3984        } else {
3985            None
3986        }
3987    }
3988
3989    #[allow(irrefutable_let_patterns)]
3990    pub fn into_is_alternate_for(
3991        self,
3992    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionIsAlternateForResponder)> {
3993        if let BufferCollectionRequest::IsAlternateFor { payload, responder } = self {
3994            Some((payload, responder))
3995        } else {
3996            None
3997        }
3998    }
3999
4000    #[allow(irrefutable_let_patterns)]
4001    pub fn into_get_buffer_collection_id(
4002        self,
4003    ) -> Option<(BufferCollectionGetBufferCollectionIdResponder)> {
4004        if let BufferCollectionRequest::GetBufferCollectionId { responder } = self {
4005            Some((responder))
4006        } else {
4007            None
4008        }
4009    }
4010
4011    #[allow(irrefutable_let_patterns)]
4012    pub fn into_set_weak(self) -> Option<(BufferCollectionControlHandle)> {
4013        if let BufferCollectionRequest::SetWeak { control_handle } = self {
4014            Some((control_handle))
4015        } else {
4016            None
4017        }
4018    }
4019
4020    #[allow(irrefutable_let_patterns)]
4021    pub fn into_set_weak_ok(self) -> Option<(NodeSetWeakOkRequest, BufferCollectionControlHandle)> {
4022        if let BufferCollectionRequest::SetWeakOk { payload, control_handle } = self {
4023            Some((payload, control_handle))
4024        } else {
4025            None
4026        }
4027    }
4028
4029    #[allow(irrefutable_let_patterns)]
4030    pub fn into_attach_node_tracking(
4031        self,
4032    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionControlHandle)> {
4033        if let BufferCollectionRequest::AttachNodeTracking { payload, control_handle } = self {
4034            Some((payload, control_handle))
4035        } else {
4036            None
4037        }
4038    }
4039
4040    #[allow(irrefutable_let_patterns)]
4041    pub fn into_set_constraints(
4042        self,
4043    ) -> Option<(BufferCollectionSetConstraintsRequest, BufferCollectionControlHandle)> {
4044        if let BufferCollectionRequest::SetConstraints { payload, control_handle } = self {
4045            Some((payload, control_handle))
4046        } else {
4047            None
4048        }
4049    }
4050
4051    #[allow(irrefutable_let_patterns)]
4052    pub fn into_wait_for_all_buffers_allocated(
4053        self,
4054    ) -> Option<(BufferCollectionWaitForAllBuffersAllocatedResponder)> {
4055        if let BufferCollectionRequest::WaitForAllBuffersAllocated { responder } = self {
4056            Some((responder))
4057        } else {
4058            None
4059        }
4060    }
4061
4062    #[allow(irrefutable_let_patterns)]
4063    pub fn into_check_all_buffers_allocated(
4064        self,
4065    ) -> Option<(BufferCollectionCheckAllBuffersAllocatedResponder)> {
4066        if let BufferCollectionRequest::CheckAllBuffersAllocated { responder } = self {
4067            Some((responder))
4068        } else {
4069            None
4070        }
4071    }
4072
4073    #[allow(irrefutable_let_patterns)]
4074    pub fn into_attach_token(
4075        self,
4076    ) -> Option<(BufferCollectionAttachTokenRequest, BufferCollectionControlHandle)> {
4077        if let BufferCollectionRequest::AttachToken { payload, control_handle } = self {
4078            Some((payload, control_handle))
4079        } else {
4080            None
4081        }
4082    }
4083
4084    #[allow(irrefutable_let_patterns)]
4085    pub fn into_attach_lifetime_tracking(
4086        self,
4087    ) -> Option<(BufferCollectionAttachLifetimeTrackingRequest, BufferCollectionControlHandle)>
4088    {
4089        if let BufferCollectionRequest::AttachLifetimeTracking { payload, control_handle } = self {
4090            Some((payload, control_handle))
4091        } else {
4092            None
4093        }
4094    }
4095
4096    /// Name of the method defined in FIDL
4097    pub fn method_name(&self) -> &'static str {
4098        match *self {
4099            BufferCollectionRequest::Sync { .. } => "sync",
4100            BufferCollectionRequest::Release { .. } => "release",
4101            BufferCollectionRequest::SetName { .. } => "set_name",
4102            BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
4103            BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
4104                "set_debug_timeout_log_deadline"
4105            }
4106            BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
4107            BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
4108            BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
4109            BufferCollectionRequest::GetBufferCollectionId { .. } => "get_buffer_collection_id",
4110            BufferCollectionRequest::SetWeak { .. } => "set_weak",
4111            BufferCollectionRequest::SetWeakOk { .. } => "set_weak_ok",
4112            BufferCollectionRequest::AttachNodeTracking { .. } => "attach_node_tracking",
4113            BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
4114            BufferCollectionRequest::WaitForAllBuffersAllocated { .. } => {
4115                "wait_for_all_buffers_allocated"
4116            }
4117            BufferCollectionRequest::CheckAllBuffersAllocated { .. } => {
4118                "check_all_buffers_allocated"
4119            }
4120            BufferCollectionRequest::AttachToken { .. } => "attach_token",
4121            BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
4122            BufferCollectionRequest::_UnknownMethod {
4123                method_type: fidl::MethodType::OneWay,
4124                ..
4125            } => "unknown one-way method",
4126            BufferCollectionRequest::_UnknownMethod {
4127                method_type: fidl::MethodType::TwoWay,
4128                ..
4129            } => "unknown two-way method",
4130        }
4131    }
4132}
4133
4134#[derive(Debug, Clone)]
4135pub struct BufferCollectionControlHandle {
4136    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4137}
4138
4139impl BufferCollectionControlHandle {
4140    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4141        self.inner.shutdown_with_epitaph(status.into())
4142    }
4143}
4144
4145impl fdomain_client::fidl::ControlHandle for BufferCollectionControlHandle {
4146    fn shutdown(&self) {
4147        self.inner.shutdown()
4148    }
4149
4150    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4151        self.inner.shutdown_with_epitaph(status)
4152    }
4153
4154    fn is_closed(&self) -> bool {
4155        self.inner.channel().is_closed()
4156    }
4157    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4158        self.inner.channel().on_closed()
4159    }
4160}
4161
4162impl BufferCollectionControlHandle {}
4163
4164#[must_use = "FIDL methods require a response to be sent"]
4165#[derive(Debug)]
4166pub struct BufferCollectionSyncResponder {
4167    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4168    tx_id: u32,
4169}
4170
4171/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4172/// if the responder is dropped without sending a response, so that the client
4173/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4174impl std::ops::Drop for BufferCollectionSyncResponder {
4175    fn drop(&mut self) {
4176        self.control_handle.shutdown();
4177        // Safety: drops once, never accessed again
4178        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4179    }
4180}
4181
4182impl fdomain_client::fidl::Responder for BufferCollectionSyncResponder {
4183    type ControlHandle = BufferCollectionControlHandle;
4184
4185    fn control_handle(&self) -> &BufferCollectionControlHandle {
4186        &self.control_handle
4187    }
4188
4189    fn drop_without_shutdown(mut self) {
4190        // Safety: drops once, never accessed again due to mem::forget
4191        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4192        // Prevent Drop from running (which would shut down the channel)
4193        std::mem::forget(self);
4194    }
4195}
4196
4197impl BufferCollectionSyncResponder {
4198    /// Sends a response to the FIDL transaction.
4199    ///
4200    /// Sets the channel to shutdown if an error occurs.
4201    pub fn send(self) -> Result<(), fidl::Error> {
4202        let _result = self.send_raw();
4203        if _result.is_err() {
4204            self.control_handle.shutdown();
4205        }
4206        self.drop_without_shutdown();
4207        _result
4208    }
4209
4210    /// Similar to "send" but does not shutdown the channel if an error occurs.
4211    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4212        let _result = self.send_raw();
4213        self.drop_without_shutdown();
4214        _result
4215    }
4216
4217    fn send_raw(&self) -> Result<(), fidl::Error> {
4218        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4219            fidl::encoding::Flexible::new(()),
4220            self.tx_id,
4221            0x11ac2555cf575b54,
4222            fidl::encoding::DynamicFlags::FLEXIBLE,
4223        )
4224    }
4225}
4226
4227#[must_use = "FIDL methods require a response to be sent"]
4228#[derive(Debug)]
4229pub struct BufferCollectionGetNodeRefResponder {
4230    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4231    tx_id: u32,
4232}
4233
4234/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4235/// if the responder is dropped without sending a response, so that the client
4236/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4237impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
4238    fn drop(&mut self) {
4239        self.control_handle.shutdown();
4240        // Safety: drops once, never accessed again
4241        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4242    }
4243}
4244
4245impl fdomain_client::fidl::Responder for BufferCollectionGetNodeRefResponder {
4246    type ControlHandle = BufferCollectionControlHandle;
4247
4248    fn control_handle(&self) -> &BufferCollectionControlHandle {
4249        &self.control_handle
4250    }
4251
4252    fn drop_without_shutdown(mut self) {
4253        // Safety: drops once, never accessed again due to mem::forget
4254        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4255        // Prevent Drop from running (which would shut down the channel)
4256        std::mem::forget(self);
4257    }
4258}
4259
4260impl BufferCollectionGetNodeRefResponder {
4261    /// Sends a response to the FIDL transaction.
4262    ///
4263    /// Sets the channel to shutdown if an error occurs.
4264    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
4265        let _result = self.send_raw(payload);
4266        if _result.is_err() {
4267            self.control_handle.shutdown();
4268        }
4269        self.drop_without_shutdown();
4270        _result
4271    }
4272
4273    /// Similar to "send" but does not shutdown the channel if an error occurs.
4274    pub fn send_no_shutdown_on_err(
4275        self,
4276        mut payload: NodeGetNodeRefResponse,
4277    ) -> Result<(), fidl::Error> {
4278        let _result = self.send_raw(payload);
4279        self.drop_without_shutdown();
4280        _result
4281    }
4282
4283    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
4284        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
4285            fidl::encoding::Flexible::new(&mut payload),
4286            self.tx_id,
4287            0x5b3d0e51614df053,
4288            fidl::encoding::DynamicFlags::FLEXIBLE,
4289        )
4290    }
4291}
4292
4293#[must_use = "FIDL methods require a response to be sent"]
4294#[derive(Debug)]
4295pub struct BufferCollectionIsAlternateForResponder {
4296    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4297    tx_id: u32,
4298}
4299
4300/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4301/// if the responder is dropped without sending a response, so that the client
4302/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4303impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
4304    fn drop(&mut self) {
4305        self.control_handle.shutdown();
4306        // Safety: drops once, never accessed again
4307        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4308    }
4309}
4310
4311impl fdomain_client::fidl::Responder for BufferCollectionIsAlternateForResponder {
4312    type ControlHandle = BufferCollectionControlHandle;
4313
4314    fn control_handle(&self) -> &BufferCollectionControlHandle {
4315        &self.control_handle
4316    }
4317
4318    fn drop_without_shutdown(mut self) {
4319        // Safety: drops once, never accessed again due to mem::forget
4320        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4321        // Prevent Drop from running (which would shut down the channel)
4322        std::mem::forget(self);
4323    }
4324}
4325
4326impl BufferCollectionIsAlternateForResponder {
4327    /// Sends a response to the FIDL transaction.
4328    ///
4329    /// Sets the channel to shutdown if an error occurs.
4330    pub fn send(
4331        self,
4332        mut result: Result<&NodeIsAlternateForResponse, Error>,
4333    ) -> Result<(), fidl::Error> {
4334        let _result = self.send_raw(result);
4335        if _result.is_err() {
4336            self.control_handle.shutdown();
4337        }
4338        self.drop_without_shutdown();
4339        _result
4340    }
4341
4342    /// Similar to "send" but does not shutdown the channel if an error occurs.
4343    pub fn send_no_shutdown_on_err(
4344        self,
4345        mut result: Result<&NodeIsAlternateForResponse, Error>,
4346    ) -> Result<(), fidl::Error> {
4347        let _result = self.send_raw(result);
4348        self.drop_without_shutdown();
4349        _result
4350    }
4351
4352    fn send_raw(
4353        &self,
4354        mut result: Result<&NodeIsAlternateForResponse, Error>,
4355    ) -> Result<(), fidl::Error> {
4356        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4357            NodeIsAlternateForResponse,
4358            Error,
4359        >>(
4360            fidl::encoding::FlexibleResult::new(result),
4361            self.tx_id,
4362            0x3a58e00157e0825,
4363            fidl::encoding::DynamicFlags::FLEXIBLE,
4364        )
4365    }
4366}
4367
4368#[must_use = "FIDL methods require a response to be sent"]
4369#[derive(Debug)]
4370pub struct BufferCollectionGetBufferCollectionIdResponder {
4371    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4372    tx_id: u32,
4373}
4374
4375/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4376/// if the responder is dropped without sending a response, so that the client
4377/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4378impl std::ops::Drop for BufferCollectionGetBufferCollectionIdResponder {
4379    fn drop(&mut self) {
4380        self.control_handle.shutdown();
4381        // Safety: drops once, never accessed again
4382        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4383    }
4384}
4385
4386impl fdomain_client::fidl::Responder for BufferCollectionGetBufferCollectionIdResponder {
4387    type ControlHandle = BufferCollectionControlHandle;
4388
4389    fn control_handle(&self) -> &BufferCollectionControlHandle {
4390        &self.control_handle
4391    }
4392
4393    fn drop_without_shutdown(mut self) {
4394        // Safety: drops once, never accessed again due to mem::forget
4395        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4396        // Prevent Drop from running (which would shut down the channel)
4397        std::mem::forget(self);
4398    }
4399}
4400
4401impl BufferCollectionGetBufferCollectionIdResponder {
4402    /// Sends a response to the FIDL transaction.
4403    ///
4404    /// Sets the channel to shutdown if an error occurs.
4405    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
4406        let _result = self.send_raw(payload);
4407        if _result.is_err() {
4408            self.control_handle.shutdown();
4409        }
4410        self.drop_without_shutdown();
4411        _result
4412    }
4413
4414    /// Similar to "send" but does not shutdown the channel if an error occurs.
4415    pub fn send_no_shutdown_on_err(
4416        self,
4417        mut payload: &NodeGetBufferCollectionIdResponse,
4418    ) -> Result<(), fidl::Error> {
4419        let _result = self.send_raw(payload);
4420        self.drop_without_shutdown();
4421        _result
4422    }
4423
4424    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
4425        self.control_handle
4426            .inner
4427            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
4428                fidl::encoding::Flexible::new(payload),
4429                self.tx_id,
4430                0x77d19a494b78ba8c,
4431                fidl::encoding::DynamicFlags::FLEXIBLE,
4432            )
4433    }
4434}
4435
4436#[must_use = "FIDL methods require a response to be sent"]
4437#[derive(Debug)]
4438pub struct BufferCollectionWaitForAllBuffersAllocatedResponder {
4439    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4440    tx_id: u32,
4441}
4442
4443/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4444/// if the responder is dropped without sending a response, so that the client
4445/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4446impl std::ops::Drop for BufferCollectionWaitForAllBuffersAllocatedResponder {
4447    fn drop(&mut self) {
4448        self.control_handle.shutdown();
4449        // Safety: drops once, never accessed again
4450        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4451    }
4452}
4453
4454impl fdomain_client::fidl::Responder for BufferCollectionWaitForAllBuffersAllocatedResponder {
4455    type ControlHandle = BufferCollectionControlHandle;
4456
4457    fn control_handle(&self) -> &BufferCollectionControlHandle {
4458        &self.control_handle
4459    }
4460
4461    fn drop_without_shutdown(mut self) {
4462        // Safety: drops once, never accessed again due to mem::forget
4463        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4464        // Prevent Drop from running (which would shut down the channel)
4465        std::mem::forget(self);
4466    }
4467}
4468
4469impl BufferCollectionWaitForAllBuffersAllocatedResponder {
4470    /// Sends a response to the FIDL transaction.
4471    ///
4472    /// Sets the channel to shutdown if an error occurs.
4473    pub fn send(
4474        self,
4475        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4476    ) -> Result<(), fidl::Error> {
4477        let _result = self.send_raw(result);
4478        if _result.is_err() {
4479            self.control_handle.shutdown();
4480        }
4481        self.drop_without_shutdown();
4482        _result
4483    }
4484
4485    /// Similar to "send" but does not shutdown the channel if an error occurs.
4486    pub fn send_no_shutdown_on_err(
4487        self,
4488        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4489    ) -> Result<(), fidl::Error> {
4490        let _result = self.send_raw(result);
4491        self.drop_without_shutdown();
4492        _result
4493    }
4494
4495    fn send_raw(
4496        &self,
4497        mut result: Result<BufferCollectionWaitForAllBuffersAllocatedResponse, Error>,
4498    ) -> Result<(), fidl::Error> {
4499        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4500            BufferCollectionWaitForAllBuffersAllocatedResponse,
4501            Error,
4502        >>(
4503            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4504            self.tx_id,
4505            0x62300344b61404e,
4506            fidl::encoding::DynamicFlags::FLEXIBLE,
4507        )
4508    }
4509}
4510
4511#[must_use = "FIDL methods require a response to be sent"]
4512#[derive(Debug)]
4513pub struct BufferCollectionCheckAllBuffersAllocatedResponder {
4514    control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
4515    tx_id: u32,
4516}
4517
4518/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
4519/// if the responder is dropped without sending a response, so that the client
4520/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4521impl std::ops::Drop for BufferCollectionCheckAllBuffersAllocatedResponder {
4522    fn drop(&mut self) {
4523        self.control_handle.shutdown();
4524        // Safety: drops once, never accessed again
4525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4526    }
4527}
4528
4529impl fdomain_client::fidl::Responder for BufferCollectionCheckAllBuffersAllocatedResponder {
4530    type ControlHandle = BufferCollectionControlHandle;
4531
4532    fn control_handle(&self) -> &BufferCollectionControlHandle {
4533        &self.control_handle
4534    }
4535
4536    fn drop_without_shutdown(mut self) {
4537        // Safety: drops once, never accessed again due to mem::forget
4538        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4539        // Prevent Drop from running (which would shut down the channel)
4540        std::mem::forget(self);
4541    }
4542}
4543
4544impl BufferCollectionCheckAllBuffersAllocatedResponder {
4545    /// Sends a response to the FIDL transaction.
4546    ///
4547    /// Sets the channel to shutdown if an error occurs.
4548    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4549        let _result = self.send_raw(result);
4550        if _result.is_err() {
4551            self.control_handle.shutdown();
4552        }
4553        self.drop_without_shutdown();
4554        _result
4555    }
4556
4557    /// Similar to "send" but does not shutdown the channel if an error occurs.
4558    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4559        let _result = self.send_raw(result);
4560        self.drop_without_shutdown();
4561        _result
4562    }
4563
4564    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
4565        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4566            fidl::encoding::EmptyStruct,
4567            Error,
4568        >>(
4569            fidl::encoding::FlexibleResult::new(result),
4570            self.tx_id,
4571            0x35a5fe77ce939c10,
4572            fidl::encoding::DynamicFlags::FLEXIBLE,
4573        )
4574    }
4575}
4576
4577#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4578pub struct BufferCollectionTokenMarker;
4579
4580impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenMarker {
4581    type Proxy = BufferCollectionTokenProxy;
4582    type RequestStream = BufferCollectionTokenRequestStream;
4583
4584    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
4585}
4586
4587pub trait BufferCollectionTokenProxyInterface: Send + Sync {
4588    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
4589    fn r#sync(&self) -> Self::SyncResponseFut;
4590    fn r#release(&self) -> Result<(), fidl::Error>;
4591    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
4592    fn r#set_debug_client_info(
4593        &self,
4594        payload: &NodeSetDebugClientInfoRequest,
4595    ) -> Result<(), fidl::Error>;
4596    fn r#set_debug_timeout_log_deadline(
4597        &self,
4598        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
4599    ) -> Result<(), fidl::Error>;
4600    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
4601    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
4602        + Send;
4603    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
4604    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
4605        + Send;
4606    fn r#is_alternate_for(
4607        &self,
4608        payload: NodeIsAlternateForRequest,
4609    ) -> Self::IsAlternateForResponseFut;
4610    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
4611        + Send;
4612    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
4613    fn r#set_weak(&self) -> Result<(), fidl::Error>;
4614    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
4615    fn r#attach_node_tracking(
4616        &self,
4617        payload: NodeAttachNodeTrackingRequest,
4618    ) -> Result<(), fidl::Error>;
4619    type DuplicateSyncResponseFut: std::future::Future<
4620            Output = Result<BufferCollectionTokenDuplicateSyncResponse, fidl::Error>,
4621        > + Send;
4622    fn r#duplicate_sync(
4623        &self,
4624        payload: &BufferCollectionTokenDuplicateSyncRequest,
4625    ) -> Self::DuplicateSyncResponseFut;
4626    fn r#duplicate(
4627        &self,
4628        payload: BufferCollectionTokenDuplicateRequest,
4629    ) -> Result<(), fidl::Error>;
4630    fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
4631    fn r#create_buffer_collection_token_group(
4632        &self,
4633        payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
4634    ) -> Result<(), fidl::Error>;
4635}
4636
4637#[derive(Debug, Clone)]
4638pub struct BufferCollectionTokenProxy {
4639    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4640}
4641
4642impl fdomain_client::fidl::Proxy for BufferCollectionTokenProxy {
4643    type Protocol = BufferCollectionTokenMarker;
4644
4645    fn from_channel(inner: fdomain_client::Channel) -> Self {
4646        Self::new(inner)
4647    }
4648
4649    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4650        self.client.into_channel().map_err(|client| Self { client })
4651    }
4652
4653    fn as_channel(&self) -> &fdomain_client::Channel {
4654        self.client.as_channel()
4655    }
4656}
4657
4658impl BufferCollectionTokenProxy {
4659    /// Create a new Proxy for fuchsia.sysmem2/BufferCollectionToken.
4660    pub fn new(channel: fdomain_client::Channel) -> Self {
4661        let protocol_name =
4662            <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4663        Self { client: fidl::client::Client::new(channel, protocol_name) }
4664    }
4665
4666    /// Get a Stream of events from the remote end of the protocol.
4667    ///
4668    /// # Panics
4669    ///
4670    /// Panics if the event stream was already taken.
4671    pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
4672        BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
4673    }
4674
4675    /// Ensure that previous messages have been received server side. This is
4676    /// particularly useful after previous messages that created new tokens,
4677    /// because a token must be known to the sysmem server before sending the
4678    /// token to another participant.
4679    ///
4680    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
4681    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
4682    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
4683    /// to mitigate the possibility of a hostile/fake
4684    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
4685    /// Another way is to pass the token to
4686    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
4687    /// the token as part of exchanging it for a
4688    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
4689    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
4690    /// of stalling.
4691    ///
4692    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
4693    /// and then starting and completing a `Sync`, it's then safe to send the
4694    /// `BufferCollectionToken` client ends to other participants knowing the
4695    /// server will recognize the tokens when they're sent by the other
4696    /// participants to sysmem in a
4697    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
4698    /// efficient way to create tokens while avoiding unnecessary round trips.
4699    ///
4700    /// Other options include waiting for each
4701    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
4702    /// individually (using separate call to `Sync` after each), or calling
4703    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
4704    /// converted to a `BufferCollection` via
4705    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
4706    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
4707    /// the sync step and can create multiple tokens at once.
4708    pub fn r#sync(
4709        &self,
4710    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
4711        BufferCollectionTokenProxyInterface::r#sync(self)
4712    }
4713
4714    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
4715    ///
4716    /// Normally a participant will convert a `BufferCollectionToken` into a
4717    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
4718    /// `Release` via the token (and then close the channel immediately or
4719    /// shortly later in response to server closing the server end), which
4720    /// avoids causing buffer collection failure. Without a prior `Release`,
4721    /// closing the `BufferCollectionToken` client end will cause buffer
4722    /// collection failure.
4723    ///
4724    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
4725    ///
4726    /// By default the server handles unexpected closure of a
4727    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
4728    /// first) by failing the buffer collection. Partly this is to expedite
4729    /// closing VMO handles to reclaim memory when any participant fails. If a
4730    /// participant would like to cleanly close a `BufferCollection` without
4731    /// causing buffer collection failure, the participant can send `Release`
4732    /// before closing the `BufferCollection` client end. The `Release` can
4733    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
4734    /// buffer collection won't require constraints from this node in order to
4735    /// allocate. If after `SetConstraints`, the constraints are retained and
4736    /// aggregated, despite the lack of `BufferCollection` connection at the
4737    /// time of constraints aggregation.
4738    ///
4739    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
4740    ///
4741    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
4742    /// end (without `Release` first) will trigger failure of the buffer
4743    /// collection. To close a `BufferCollectionTokenGroup` channel without
4744    /// failing the buffer collection, ensure that AllChildrenPresent() has been
4745    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
4746    /// client end.
4747    ///
4748    /// If `Release` occurs before
4749    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
4750    /// buffer collection will fail (triggered by reception of `Release` without
4751    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
4752    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
4753    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
4754    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
4755    /// close requires `AllChildrenPresent` (if not already sent), then
4756    /// `Release`, then close client end.
4757    ///
4758    /// If `Release` occurs after `AllChildrenPresent`, the children and all
4759    /// their constraints remain intact (just as they would if the
4760    /// `BufferCollectionTokenGroup` channel had remained open), and the client
4761    /// end close doesn't trigger buffer collection failure.
4762    ///
4763    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
4764    ///
4765    /// For brevity, the per-channel-protocol paragraphs above ignore the
4766    /// separate failure domain created by
4767    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
4768    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
4769    /// unexpectedly closes (without `Release` first) and that client end is
4770    /// under a failure domain, instead of failing the whole buffer collection,
4771    /// the failure domain is failed, but the buffer collection itself is
4772    /// isolated from failure of the failure domain. Such failure domains can be
4773    /// nested, in which case only the inner-most failure domain in which the
4774    /// `Node` resides fails.
4775    pub fn r#release(&self) -> Result<(), fidl::Error> {
4776        BufferCollectionTokenProxyInterface::r#release(self)
4777    }
4778
4779    /// Set a name for VMOs in this buffer collection.
4780    ///
4781    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
4782    /// will be truncated to fit. The name of the vmo will be suffixed with the
4783    /// buffer index within the collection (if the suffix fits within
4784    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
4785    /// listed in the inspect data.
4786    ///
4787    /// The name only affects VMOs allocated after the name is set; this call
4788    /// does not rename existing VMOs. If multiple clients set different names
4789    /// then the larger priority value will win. Setting a new name with the
4790    /// same priority as a prior name doesn't change the name.
4791    ///
4792    /// All table fields are currently required.
4793    ///
4794    /// + request `priority` The name is only set if this is the first `SetName`
4795    ///   or if `priority` is greater than any previous `priority` value in
4796    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
4797    /// + request `name` The name for VMOs created under this buffer collection.
4798    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
4799        BufferCollectionTokenProxyInterface::r#set_name(self, payload)
4800    }
4801
4802    /// Set information about the current client that can be used by sysmem to
4803    /// help diagnose leaking memory and allocation stalls waiting for a
4804    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
4805    ///
4806    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
4807    /// `Node`(s) derived from this `Node`, unless overriden by
4808    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
4809    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
4810    ///
4811    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
4812    /// `Allocator` is the most efficient way to ensure that all
4813    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
4814    /// set, and is also more efficient than separately sending the same debug
4815    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
4816    /// created [`fuchsia.sysmem2/Node`].
4817    ///
4818    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
4819    /// indicate which client is closing their channel first, leading to subtree
4820    /// failure (which can be normal if the purpose of the subtree is over, but
4821    /// if happening earlier than expected, the client-channel-specific name can
4822    /// help diagnose where the failure is first coming from, from sysmem's
4823    /// point of view).
4824    ///
4825    /// All table fields are currently required.
4826    ///
4827    /// + request `name` This can be an arbitrary string, but the current
4828    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
4829    /// + request `id` This can be an arbitrary id, but the current process ID
4830    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
4831    pub fn r#set_debug_client_info(
4832        &self,
4833        mut payload: &NodeSetDebugClientInfoRequest,
4834    ) -> Result<(), fidl::Error> {
4835        BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, payload)
4836    }
4837
4838    /// Sysmem logs a warning if sysmem hasn't seen
4839    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
4840    /// within 5 seconds after creation of a new collection.
4841    ///
4842    /// Clients can call this method to change when the log is printed. If
4843    /// multiple client set the deadline, it's unspecified which deadline will
4844    /// take effect.
4845    ///
4846    /// In most cases the default works well.
4847    ///
4848    /// All table fields are currently required.
4849    ///
4850    /// + request `deadline` The time at which sysmem will start trying to log
4851    ///   the warning, unless all constraints are with sysmem by then.
4852    pub fn r#set_debug_timeout_log_deadline(
4853        &self,
4854        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
4855    ) -> Result<(), fidl::Error> {
4856        BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
4857    }
4858
4859    /// This enables verbose logging for the buffer collection.
4860    ///
4861    /// Verbose logging includes constraints set via
4862    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
4863    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
4864    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
4865    /// the tree of `Node`(s).
4866    ///
4867    /// Normally sysmem prints only a single line complaint when aggregation
4868    /// fails, with just the specific detailed reason that aggregation failed,
4869    /// with little surrounding context.  While this is often enough to diagnose
4870    /// a problem if only a small change was made and everything was working
4871    /// before the small change, it's often not particularly helpful for getting
4872    /// a new buffer collection to work for the first time.  Especially with
4873    /// more complex trees of nodes, involving things like
4874    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
4875    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
4876    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
4877    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
4878    /// looks like and why it's failing a logical allocation, or why a tree or
4879    /// subtree is failing sooner than expected.
4880    ///
4881    /// The intent of the extra logging is to be acceptable from a performance
4882    /// point of view, under the assumption that verbose logging is only enabled
4883    /// on a low number of buffer collections. If we're not tracking down a bug,
4884    /// we shouldn't send this message.
4885    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
4886        BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
4887    }
4888
4889    /// This gets a handle that can be used as a parameter to
4890    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
4891    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
4892    /// client obtained this handle from this `Node`.
4893    ///
4894    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
4895    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
4896    /// despite the two calls typically being on different channels.
4897    ///
4898    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
4899    ///
4900    /// All table fields are currently required.
4901    ///
4902    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
4903    ///   different `Node` channel, to prove that the client obtained the handle
4904    ///   from this `Node`.
4905    pub fn r#get_node_ref(
4906        &self,
4907    ) -> fidl::client::QueryResponseFut<
4908        NodeGetNodeRefResponse,
4909        fdomain_client::fidl::FDomainResourceDialect,
4910    > {
4911        BufferCollectionTokenProxyInterface::r#get_node_ref(self)
4912    }
4913
4914    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
4915    /// rooted at a different child token of a common parent
4916    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
4917    /// passed-in `node_ref`.
4918    ///
4919    /// This call is for assisting with admission control de-duplication, and
4920    /// with debugging.
4921    ///
4922    /// The `node_ref` must be obtained using
4923    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
4924    ///
4925    /// The `node_ref` can be a duplicated handle; it's not necessary to call
4926    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
4927    ///
4928    /// If a calling token may not actually be a valid token at all due to a
4929    /// potentially hostile/untrusted provider of the token, call
4930    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
4931    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
4932    /// never responds due to a calling token not being a real token (not really
4933    /// talking to sysmem).  Another option is to call
4934    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
4935    /// which also validates the token along with converting it to a
4936    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
4937    ///
4938    /// All table fields are currently required.
4939    ///
4940    /// - response `is_alternate`
4941    ///   - true: The first parent node in common between the calling node and
4942    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
4943    ///     that the calling `Node` and the `node_ref` `Node` will not have both
4944    ///     their constraints apply - rather sysmem will choose one or the other
4945    ///     of the constraints - never both.  This is because only one child of
4946    ///     a `BufferCollectionTokenGroup` is selected during logical
4947    ///     allocation, with only that one child's subtree contributing to
4948    ///     constraints aggregation.
4949    ///   - false: The first parent node in common between the calling `Node`
4950    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
4951    ///     Currently, this means the first parent node in common is a
4952    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
4953    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
4954    ///     `Node` may have both their constraints apply during constraints
4955    ///     aggregation of the logical allocation, if both `Node`(s) are
4956    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
4957    ///     this case, there is no `BufferCollectionTokenGroup` that will
4958    ///     directly prevent the two `Node`(s) from both being selected and
4959    ///     their constraints both aggregated, but even when false, one or both
4960    ///     `Node`(s) may still be eliminated from consideration if one or both
4961    ///     `Node`(s) has a direct or indirect parent
4962    ///     `BufferCollectionTokenGroup` which selects a child subtree other
4963    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
4964    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
4965    ///   associated with the same buffer collection as the calling `Node`.
4966    ///   Another reason for this error is if the `node_ref` is an
4967    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
4968    ///   a real `node_ref` obtained from `GetNodeRef`.
4969    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
4970    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
4971    ///   the needed rights expected on a real `node_ref`.
4972    /// * No other failing status codes are returned by this call.  However,
4973    ///   sysmem may add additional codes in future, so the client should have
4974    ///   sensible default handling for any failing status code.
4975    pub fn r#is_alternate_for(
4976        &self,
4977        mut payload: NodeIsAlternateForRequest,
4978    ) -> fidl::client::QueryResponseFut<
4979        NodeIsAlternateForResult,
4980        fdomain_client::fidl::FDomainResourceDialect,
4981    > {
4982        BufferCollectionTokenProxyInterface::r#is_alternate_for(self, payload)
4983    }
4984
4985    /// Get the buffer collection ID. This ID is also available from
4986    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
4987    /// within the collection).
4988    ///
4989    /// This call is mainly useful in situations where we can't convey a
4990    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
4991    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
4992    /// handle, which can be joined back up with a `BufferCollection` client end
4993    /// that was created via a different path. Prefer to convey a
4994    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
4995    ///
4996    /// Trusting a `buffer_collection_id` value from a source other than sysmem
4997    /// is analogous to trusting a koid value from a source other than zircon.
4998    /// Both should be avoided unless really necessary, and both require
4999    /// caution. In some situations it may be reasonable to refer to a
5000    /// pre-established `BufferCollection` by `buffer_collection_id` via a
5001    /// protocol for efficiency reasons, but an incoming value purporting to be
5002    /// a `buffer_collection_id` is not sufficient alone to justify granting the
5003    /// sender of the `buffer_collection_id` any capability. The sender must
5004    /// first prove to a receiver that the sender has/had a VMO or has/had a
5005    /// `BufferCollectionToken` to the same collection by sending a handle that
5006    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
5007    /// `buffer_collection_id` value. The receiver should take care to avoid
5008    /// assuming that a sender had a `BufferCollectionToken` in cases where the
5009    /// sender has only proven that the sender had a VMO.
5010    ///
5011    /// - response `buffer_collection_id` This ID is unique per buffer
5012    ///   collection per boot. Each buffer is uniquely identified by the
5013    ///   `buffer_collection_id` and `buffer_index` together.
5014    pub fn r#get_buffer_collection_id(
5015        &self,
5016    ) -> fidl::client::QueryResponseFut<
5017        NodeGetBufferCollectionIdResponse,
5018        fdomain_client::fidl::FDomainResourceDialect,
5019    > {
5020        BufferCollectionTokenProxyInterface::r#get_buffer_collection_id(self)
5021    }
5022
5023    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
5024    /// created after this message to weak, which means that a client's `Node`
5025    /// client end (or a child created after this message) is not alone
5026    /// sufficient to keep allocated VMOs alive.
5027    ///
5028    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
5029    /// `close_weak_asap`.
5030    ///
5031    /// This message is only permitted before the `Node` becomes ready for
5032    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
5033    ///   * `BufferCollectionToken`: any time
5034    ///   * `BufferCollection`: before `SetConstraints`
5035    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
5036    ///
5037    /// Currently, no conversion from strong `Node` to weak `Node` after ready
5038    /// for allocation is provided, but a client can simulate that by creating
5039    /// an additional `Node` before allocation and setting that additional
5040    /// `Node` to weak, and then potentially at some point later sending
5041    /// `Release` and closing the client end of the client's strong `Node`, but
5042    /// keeping the client's weak `Node`.
5043    ///
5044    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
5045    /// collection failure (all `Node` client end(s) will see
5046    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
5047    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
5048    /// this situation until all `Node`(s) are ready for allocation. For initial
5049    /// allocation to succeed, at least one strong `Node` is required to exist
5050    /// at allocation time, but after that client receives VMO handles, that
5051    /// client can `BufferCollection.Release` and close the client end without
5052    /// causing this type of failure.
5053    ///
5054    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
5055    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
5056    /// separately as appropriate.
5057    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
5058        BufferCollectionTokenProxyInterface::r#set_weak(self)
5059    }
5060
5061    /// This indicates to sysmem that the client is prepared to pay attention to
5062    /// `close_weak_asap`.
5063    ///
5064    /// If sent, this message must be before
5065    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
5066    ///
5067    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
5068    /// send this message before `WaitForAllBuffersAllocated`, or a parent
5069    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
5070    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
5071    /// trigger buffer collection failure.
5072    ///
5073    /// This message is necessary because weak sysmem VMOs have not always been
5074    /// a thing, so older clients are not aware of the need to pay attention to
5075    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
5076    /// sysmem weak VMO handles asap. By having this message and requiring
5077    /// participants to indicate their acceptance of this aspect of the overall
5078    /// protocol, we avoid situations where an older client is delivered a weak
5079    /// VMO without any way for sysmem to get that VMO to close quickly later
5080    /// (and on a per-buffer basis).
5081    ///
5082    /// A participant that doesn't handle `close_weak_asap` and also doesn't
5083    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
5084    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
5085    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
5086    /// same participant has a child/delegate which does retrieve VMOs, that
5087    /// child/delegate will need to send `SetWeakOk` before
5088    /// `WaitForAllBuffersAllocated`.
5089    ///
5090    /// + request `for_child_nodes_also` If present and true, this means direct
5091    ///   child nodes of this node created after this message plus all
5092    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
5093    ///   those nodes. Any child node of this node that was created before this
5094    ///   message is not included. This setting is "sticky" in the sense that a
5095    ///   subsequent `SetWeakOk` without this bool set to true does not reset
5096    ///   the server-side bool. If this creates a problem for a participant, a
5097    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
5098    ///   tokens instead, as appropriate. A participant should only set
5099    ///   `for_child_nodes_also` true if the participant can really promise to
5100    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
5101    ///   weak VMO handles held by participants holding the corresponding child
5102    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
5103    ///   which are using sysmem(1) can be weak, despite the clients of those
5104    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
5105    ///   direct way to find out about `close_weak_asap`. This only applies to
5106    ///   descendents of this `Node` which are using sysmem(1), not to this
5107    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
5108    ///   token, which will fail allocation unless an ancestor of this `Node`
5109    ///   specified `for_child_nodes_also` true.
5110    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
5111        BufferCollectionTokenProxyInterface::r#set_weak_ok(self, payload)
5112    }
5113
5114    /// The server_end will be closed after this `Node` and any child nodes have
5115    /// have released their buffer counts, making those counts available for
5116    /// reservation by a different `Node` via
5117    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
5118    ///
5119    /// The `Node` buffer counts may not be released until the entire tree of
5120    /// `Node`(s) is closed or failed, because
5121    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
5122    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
5123    /// `Node` buffer counts remain reserved until the orphaned node is later
5124    /// cleaned up.
5125    ///
5126    /// If the `Node` exceeds a fairly large number of attached eventpair server
5127    /// ends, a log message will indicate this and the `Node` (and the
5128    /// appropriate) sub-tree will fail.
5129    ///
5130    /// The `server_end` will remain open when
5131    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
5132    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
5133    /// [`fuchsia.sysmem2/BufferCollection`].
5134    ///
5135    /// This message can also be used with a
5136    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
5137    pub fn r#attach_node_tracking(
5138        &self,
5139        mut payload: NodeAttachNodeTrackingRequest,
5140    ) -> Result<(), fidl::Error> {
5141        BufferCollectionTokenProxyInterface::r#attach_node_tracking(self, payload)
5142    }
5143
5144    /// Create additional [`fuchsia.sysmem2/BufferCollectionToken`](s) from this
5145    /// one, referring to the same buffer collection.
5146    ///
5147    /// The created tokens are children of this token in the
5148    /// [`fuchsia.sysmem2/Node`] heirarchy.
5149    ///
5150    /// This method can be used to add more participants, by transferring the
5151    /// newly created tokens to additional participants.
5152    ///
5153    /// A new token will be returned for each entry in the
5154    /// `rights_attenuation_masks` array.
5155    ///
5156    /// If the called token may not actually be a valid token due to a
5157    /// potentially hostile/untrusted provider of the token, consider using
5158    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
5159    /// instead of potentially getting stuck indefinitely if
5160    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] never responds
5161    /// due to the calling token not being a real token.
5162    ///
5163    /// In contrast to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], no
5164    /// separate [`fuchsia.sysmem2/Node.Sync`] is needed after calling this
5165    /// method, because the sync step is included in this call, at the cost of a
5166    /// round trip during this call.
5167    ///
5168    /// All tokens must be turned in to sysmem via
5169    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
5170    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
5171    /// successfully allocate buffers (or to logically allocate buffers in the
5172    /// case of subtrees involving
5173    /// [`fuchsia.sysmem2/BufferCollectionToken.AttachToken`]).
5174    ///
5175    /// All table fields are currently required.
5176    ///
5177    /// + request `rights_attenuation_mask` In each entry of
5178    ///   `rights_attenuation_masks`, rights bits that are zero will be absent
5179    ///   in the buffer VMO rights obtainable via the corresponding returned
5180    ///   token. This allows an initiator or intermediary participant to
5181    ///   attenuate the rights available to a participant. This does not allow a
5182    ///   participant to gain rights that the participant doesn't already have.
5183    ///   The value `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no
5184    ///   attenuation should be applied.
5185    /// - response `tokens` The client ends of each newly created token.
5186    pub fn r#duplicate_sync(
5187        &self,
5188        mut payload: &BufferCollectionTokenDuplicateSyncRequest,
5189    ) -> fidl::client::QueryResponseFut<
5190        BufferCollectionTokenDuplicateSyncResponse,
5191        fdomain_client::fidl::FDomainResourceDialect,
5192    > {
5193        BufferCollectionTokenProxyInterface::r#duplicate_sync(self, payload)
5194    }
5195
5196    /// Create an additional [`fuchsia.sysmem2/BufferCollectionToken`] from this
5197    /// one, referring to the same buffer collection.
5198    ///
5199    /// The created token is a child of this token in the
5200    /// [`fuchsia.sysmem2/Node`] heirarchy.
5201    ///
5202    /// This method can be used to add a participant, by transferring the newly
5203    /// created token to another participant.
5204    ///
5205    /// This one-way message can be used instead of the two-way
5206    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] FIDL call in
5207    /// performance sensitive cases where it would be undesireable to wait for
5208    /// sysmem to respond to
5209    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or when the
5210    /// client code isn't structured to make it easy to duplicate all the needed
5211    /// tokens at once.
5212    ///
5213    /// After sending one or more `Duplicate` messages, and before sending the
5214    /// newly created child tokens to other participants (or to other
5215    /// [`fuchsia.sysmem2/Allocator`] channels), the client must send a
5216    /// [`fuchsia.sysmem2/Node.Sync`] and wait for the `Sync` response. The
5217    /// `Sync` call can be made on the token, or on the `BufferCollection`
5218    /// obtained by passing this token to `BindSharedCollection`.  Either will
5219    /// ensure that the server knows about the tokens created via `Duplicate`
5220    /// before the other participant sends the token to the server via separate
5221    /// `Allocator` channel.
5222    ///
5223    /// All tokens must be turned in via
5224    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
5225    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
5226    /// successfully allocate buffers.
5227    ///
5228    /// All table fields are currently required.
5229    ///
5230    /// + request `rights_attenuation_mask` The rights bits that are zero in
5231    ///   this mask will be absent in the buffer VMO rights obtainable via the
5232    ///   client end of `token_request`. This allows an initiator or
5233    ///   intermediary participant to attenuate the rights available to a
5234    ///   delegate participant. This does not allow a participant to gain rights
5235    ///   that the participant doesn't already have. The value
5236    ///   `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no attenuation
5237    ///   should be applied.
5238    ///   + These values for rights_attenuation_mask result in no attenuation:
5239    ///     + `ZX_RIGHT_SAME_RIGHTS` (preferred)
5240    ///     + 0xFFFFFFFF (this is reasonable when an attenuation mask is
5241    ///       computed)
5242    ///     + 0 (deprecated - do not use 0 - an ERROR will go to the log)
5243    /// + request `token_request` is the server end of a `BufferCollectionToken`
5244    ///   channel. The client end of this channel acts as another participant in
5245    ///   the shared buffer collection.
5246    pub fn r#duplicate(
5247        &self,
5248        mut payload: BufferCollectionTokenDuplicateRequest,
5249    ) -> Result<(), fidl::Error> {
5250        BufferCollectionTokenProxyInterface::r#duplicate(self, payload)
5251    }
5252
5253    /// Set this [`fuchsia.sysmem2/BufferCollectionToken`] to dispensable.
5254    ///
5255    /// When the `BufferCollectionToken` is converted to a
5256    /// [`fuchsia.sysmem2/BufferCollection`], the dispensable status applies to
5257    /// the `BufferCollection` also.
5258    ///
5259    /// Normally, if a client closes a [`fuchsia.sysmem2/BufferCollection`]
5260    /// client end without having sent
5261    /// [`fuchsia.sysmem2/BufferCollection.Release`] first, the
5262    /// `BufferCollection` [`fuchisa.sysmem2/Node`] will fail, which also
5263    /// propagates failure to the parent [`fuchsia.sysmem2/Node`] and so on up
5264    /// to the root `Node`, which fails the whole buffer collection. In
5265    /// contrast, a dispensable `Node` can fail after buffers are allocated
5266    /// without causing failure of its parent in the [`fuchsia.sysmem2/Node`]
5267    /// heirarchy.
5268    ///
5269    /// The dispensable `Node` participates in constraints aggregation along
5270    /// with its parent before buffer allocation. If the dispensable `Node`
5271    /// fails before buffers are allocated, the failure propagates to the
5272    /// dispensable `Node`'s parent.
5273    ///
5274    /// After buffers are allocated, failure of the dispensable `Node` (or any
5275    /// child of the dispensable `Node`) does not propagate to the dispensable
5276    /// `Node`'s parent. Failure does propagate from a normal child of a
5277    /// dispensable `Node` to the dispensable `Node`.  Failure of a child is
5278    /// blocked from reaching its parent if the child is attached using
5279    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or if the child is
5280    /// dispensable and the failure occurred after allocation.
5281    ///
5282    /// A dispensable `Node` can be used in cases where a participant needs to
5283    /// provide constraints, but after buffers are allocated, the participant
5284    /// can fail without causing buffer collection failure from the parent
5285    /// `Node`'s point of view.
5286    ///
5287    /// In contrast, `BufferCollection.AttachToken` can be used to create a
5288    /// `BufferCollectionToken` which does not participate in constraints
5289    /// aggregation with its parent `Node`, and whose failure at any time does
5290    /// not propagate to its parent `Node`, and whose potential delay providing
5291    /// constraints does not prevent the parent `Node` from completing its
5292    /// buffer allocation.
5293    ///
5294    /// An initiator (creator of the root `Node` using
5295    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`]) may in some
5296    /// scenarios choose to initially use a dispensable `Node` for a first
5297    /// instance of a participant, and then later if the first instance of that
5298    /// participant fails, a new second instance of that participant my be given
5299    /// a `BufferCollectionToken` created with `AttachToken`.
5300    ///
5301    /// Normally a client will `SetDispensable` on a `BufferCollectionToken`
5302    /// shortly before sending the dispensable `BufferCollectionToken` to a
5303    /// delegate participant. Because `SetDispensable` prevents propagation of
5304    /// child `Node` failure to parent `Node`(s), if the client was relying on
5305    /// noticing child failure via failure of the parent `Node` retained by the
5306    /// client, the client may instead need to notice failure via other means.
5307    /// If other means aren't available/convenient, the client can instead
5308    /// retain the dispensable `Node` and create a child `Node` under that to
5309    /// send to the delegate participant, retaining this `Node` in order to
5310    /// notice failure of the subtree rooted at this `Node` via this `Node`'s
5311    /// ZX_CHANNEL_PEER_CLOSED signal, and take whatever action is appropriate
5312    /// (e.g. starting a new instance of the delegate participant and handing it
5313    /// a `BufferCollectionToken` created using
5314    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or propagate failure
5315    /// and clean up in a client-specific way).
5316    ///
5317    /// While it is possible (and potentially useful) to `SetDispensable` on a
5318    /// direct child of a `BufferCollectionTokenGroup` `Node`, it isn't possible
5319    /// to later replace a failed dispensable `Node` that was a direct child of
5320    /// a `BufferCollectionTokenGroup` with a new token using `AttachToken`
5321    /// (since there's no `AttachToken` on a group). Instead, to enable
5322    /// `AttachToken` replacement in this case, create an additional
5323    /// non-dispensable token that's a direct child of the group and make the
5324    /// existing dispensable token a child of the additional token.  This way,
5325    /// the additional token that is a direct child of the group has
5326    /// `BufferCollection.AttachToken` which can be used to replace the failed
5327    /// dispensable token.
5328    ///
5329    /// `SetDispensable` on an already-dispensable token is idempotent.
5330    pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5331        BufferCollectionTokenProxyInterface::r#set_dispensable(self)
5332    }
5333
5334    /// Create a logical OR among a set of tokens, called a
5335    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
5336    ///
5337    /// Most sysmem clients and many participants don't need to care about this
5338    /// message or about `BufferCollectionTokenGroup`(s). However, in some cases
5339    /// a participant wants to attempt to include one set of delegate
5340    /// participants, but if constraints don't combine successfully that way,
5341    /// fall back to a different (possibly overlapping) set of delegate
5342    /// participants, and/or fall back to a less demanding strategy (in terms of
5343    /// how strict the [`fuchisa.sysmem2/BufferCollectionConstraints`] are,
5344    /// across all involved delegate participants). In such cases, a
5345    /// `BufferCollectionTokenGroup` is useful.
5346    ///
5347    /// A `BufferCollectionTokenGroup` is used to create a 1 of N OR among N
5348    /// child [`fuchsia.sysmem2/BufferCollectionToken`](s).  The child tokens
5349    /// which are not selected during aggregation will fail (close), which a
5350    /// potential participant should notice when their `BufferCollection`
5351    /// channel client endpoint sees PEER_CLOSED, allowing the participant to
5352    /// clean up the speculative usage that didn't end up happening (this is
5353    /// simimlar to a normal `BufferCollection` server end closing on failure to
5354    /// allocate a logical buffer collection or later async failure of a buffer
5355    /// collection).
5356    ///
5357    /// See comments on protocol `BufferCollectionTokenGroup`.
5358    ///
5359    /// Any `rights_attenuation_mask` or `AttachToken`/`SetDispensable` to be
5360    /// applied to the whole group can be achieved with a
5361    /// `BufferCollectionToken` for this purpose as a direct parent of the
5362    /// `BufferCollectionTokenGroup`.
5363    ///
5364    /// All table fields are currently required.
5365    ///
5366    /// + request `group_request` The server end of a
5367    ///   `BufferCollectionTokenGroup` channel to be served by sysmem.
5368    pub fn r#create_buffer_collection_token_group(
5369        &self,
5370        mut payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
5371    ) -> Result<(), fidl::Error> {
5372        BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(self, payload)
5373    }
5374}
5375
5376impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
5377    type SyncResponseFut =
5378        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
5379    fn r#sync(&self) -> Self::SyncResponseFut {
5380        fn _decode(
5381            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5382        ) -> Result<(), fidl::Error> {
5383            let _response = fidl::client::decode_transaction_body::<
5384                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
5385                fdomain_client::fidl::FDomainResourceDialect,
5386                0x11ac2555cf575b54,
5387            >(_buf?)?
5388            .into_result_fdomain::<BufferCollectionTokenMarker>("sync")?;
5389            Ok(_response)
5390        }
5391        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5392            (),
5393            0x11ac2555cf575b54,
5394            fidl::encoding::DynamicFlags::FLEXIBLE,
5395            _decode,
5396        )
5397    }
5398
5399    fn r#release(&self) -> Result<(), fidl::Error> {
5400        self.client.send::<fidl::encoding::EmptyPayload>(
5401            (),
5402            0x6a5cae7d6d6e04c6,
5403            fidl::encoding::DynamicFlags::FLEXIBLE,
5404        )
5405    }
5406
5407    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
5408        self.client.send::<NodeSetNameRequest>(
5409            payload,
5410            0xb41f1624f48c1e9,
5411            fidl::encoding::DynamicFlags::FLEXIBLE,
5412        )
5413    }
5414
5415    fn r#set_debug_client_info(
5416        &self,
5417        mut payload: &NodeSetDebugClientInfoRequest,
5418    ) -> Result<(), fidl::Error> {
5419        self.client.send::<NodeSetDebugClientInfoRequest>(
5420            payload,
5421            0x5cde8914608d99b1,
5422            fidl::encoding::DynamicFlags::FLEXIBLE,
5423        )
5424    }
5425
5426    fn r#set_debug_timeout_log_deadline(
5427        &self,
5428        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
5429    ) -> Result<(), fidl::Error> {
5430        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5431            payload,
5432            0x716b0af13d5c0806,
5433            fidl::encoding::DynamicFlags::FLEXIBLE,
5434        )
5435    }
5436
5437    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5438        self.client.send::<fidl::encoding::EmptyPayload>(
5439            (),
5440            0x5209c77415b4dfad,
5441            fidl::encoding::DynamicFlags::FLEXIBLE,
5442        )
5443    }
5444
5445    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
5446        NodeGetNodeRefResponse,
5447        fdomain_client::fidl::FDomainResourceDialect,
5448    >;
5449    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5450        fn _decode(
5451            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5452        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
5453            let _response = fidl::client::decode_transaction_body::<
5454                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
5455                fdomain_client::fidl::FDomainResourceDialect,
5456                0x5b3d0e51614df053,
5457            >(_buf?)?
5458            .into_result_fdomain::<BufferCollectionTokenMarker>("get_node_ref")?;
5459            Ok(_response)
5460        }
5461        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
5462            (),
5463            0x5b3d0e51614df053,
5464            fidl::encoding::DynamicFlags::FLEXIBLE,
5465            _decode,
5466        )
5467    }
5468
5469    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5470        NodeIsAlternateForResult,
5471        fdomain_client::fidl::FDomainResourceDialect,
5472    >;
5473    fn r#is_alternate_for(
5474        &self,
5475        mut payload: NodeIsAlternateForRequest,
5476    ) -> Self::IsAlternateForResponseFut {
5477        fn _decode(
5478            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5479        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5480            let _response = fidl::client::decode_transaction_body::<
5481                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
5482                fdomain_client::fidl::FDomainResourceDialect,
5483                0x3a58e00157e0825,
5484            >(_buf?)?
5485            .into_result_fdomain::<BufferCollectionTokenMarker>("is_alternate_for")?;
5486            Ok(_response.map(|x| x))
5487        }
5488        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5489            &mut payload,
5490            0x3a58e00157e0825,
5491            fidl::encoding::DynamicFlags::FLEXIBLE,
5492            _decode,
5493        )
5494    }
5495
5496    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
5497        NodeGetBufferCollectionIdResponse,
5498        fdomain_client::fidl::FDomainResourceDialect,
5499    >;
5500    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
5501        fn _decode(
5502            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5503        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
5504            let _response = fidl::client::decode_transaction_body::<
5505                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
5506                fdomain_client::fidl::FDomainResourceDialect,
5507                0x77d19a494b78ba8c,
5508            >(_buf?)?
5509            .into_result_fdomain::<BufferCollectionTokenMarker>("get_buffer_collection_id")?;
5510            Ok(_response)
5511        }
5512        self.client.send_query_and_decode::<
5513            fidl::encoding::EmptyPayload,
5514            NodeGetBufferCollectionIdResponse,
5515        >(
5516            (),
5517            0x77d19a494b78ba8c,
5518            fidl::encoding::DynamicFlags::FLEXIBLE,
5519            _decode,
5520        )
5521    }
5522
5523    fn r#set_weak(&self) -> Result<(), fidl::Error> {
5524        self.client.send::<fidl::encoding::EmptyPayload>(
5525            (),
5526            0x22dd3ea514eeffe1,
5527            fidl::encoding::DynamicFlags::FLEXIBLE,
5528        )
5529    }
5530
5531    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
5532        self.client.send::<NodeSetWeakOkRequest>(
5533            &mut payload,
5534            0x38a44fc4d7724be9,
5535            fidl::encoding::DynamicFlags::FLEXIBLE,
5536        )
5537    }
5538
5539    fn r#attach_node_tracking(
5540        &self,
5541        mut payload: NodeAttachNodeTrackingRequest,
5542    ) -> Result<(), fidl::Error> {
5543        self.client.send::<NodeAttachNodeTrackingRequest>(
5544            &mut payload,
5545            0x3f22f2a293d3cdac,
5546            fidl::encoding::DynamicFlags::FLEXIBLE,
5547        )
5548    }
5549
5550    type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
5551        BufferCollectionTokenDuplicateSyncResponse,
5552        fdomain_client::fidl::FDomainResourceDialect,
5553    >;
5554    fn r#duplicate_sync(
5555        &self,
5556        mut payload: &BufferCollectionTokenDuplicateSyncRequest,
5557    ) -> Self::DuplicateSyncResponseFut {
5558        fn _decode(
5559            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5560        ) -> Result<BufferCollectionTokenDuplicateSyncResponse, fidl::Error> {
5561            let _response = fidl::client::decode_transaction_body::<
5562                fidl::encoding::FlexibleType<BufferCollectionTokenDuplicateSyncResponse>,
5563                fdomain_client::fidl::FDomainResourceDialect,
5564                0x1c1af9919d1ca45c,
5565            >(_buf?)?
5566            .into_result_fdomain::<BufferCollectionTokenMarker>("duplicate_sync")?;
5567            Ok(_response)
5568        }
5569        self.client.send_query_and_decode::<
5570            BufferCollectionTokenDuplicateSyncRequest,
5571            BufferCollectionTokenDuplicateSyncResponse,
5572        >(
5573            payload,
5574            0x1c1af9919d1ca45c,
5575            fidl::encoding::DynamicFlags::FLEXIBLE,
5576            _decode,
5577        )
5578    }
5579
5580    fn r#duplicate(
5581        &self,
5582        mut payload: BufferCollectionTokenDuplicateRequest,
5583    ) -> Result<(), fidl::Error> {
5584        self.client.send::<BufferCollectionTokenDuplicateRequest>(
5585            &mut payload,
5586            0x73e78f92ee7fb887,
5587            fidl::encoding::DynamicFlags::FLEXIBLE,
5588        )
5589    }
5590
5591    fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
5592        self.client.send::<fidl::encoding::EmptyPayload>(
5593            (),
5594            0x228acf979254df8b,
5595            fidl::encoding::DynamicFlags::FLEXIBLE,
5596        )
5597    }
5598
5599    fn r#create_buffer_collection_token_group(
5600        &self,
5601        mut payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
5602    ) -> Result<(), fidl::Error> {
5603        self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
5604            &mut payload,
5605            0x30f8d48e77bd36f2,
5606            fidl::encoding::DynamicFlags::FLEXIBLE,
5607        )
5608    }
5609}
5610
5611pub struct BufferCollectionTokenEventStream {
5612    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5613}
5614
5615impl std::marker::Unpin for BufferCollectionTokenEventStream {}
5616
5617impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
5618    fn is_terminated(&self) -> bool {
5619        self.event_receiver.is_terminated()
5620    }
5621}
5622
5623impl futures::Stream for BufferCollectionTokenEventStream {
5624    type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
5625
5626    fn poll_next(
5627        mut self: std::pin::Pin<&mut Self>,
5628        cx: &mut std::task::Context<'_>,
5629    ) -> std::task::Poll<Option<Self::Item>> {
5630        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5631            &mut self.event_receiver,
5632            cx
5633        )?) {
5634            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
5635            None => std::task::Poll::Ready(None),
5636        }
5637    }
5638}
5639
5640#[derive(Debug)]
5641pub enum BufferCollectionTokenEvent {
5642    #[non_exhaustive]
5643    _UnknownEvent {
5644        /// Ordinal of the event that was sent.
5645        ordinal: u64,
5646    },
5647}
5648
5649impl BufferCollectionTokenEvent {
5650    /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
5651    fn decode(
5652        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5653    ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
5654        let (bytes, _handles) = buf.split_mut();
5655        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5656        debug_assert_eq!(tx_header.tx_id, 0);
5657        match tx_header.ordinal {
5658            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5659                Ok(BufferCollectionTokenEvent::_UnknownEvent {
5660                    ordinal: tx_header.ordinal,
5661                })
5662            }
5663            _ => Err(fidl::Error::UnknownOrdinal {
5664                ordinal: tx_header.ordinal,
5665                protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5666            })
5667        }
5668    }
5669}
5670
5671/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollectionToken.
5672pub struct BufferCollectionTokenRequestStream {
5673    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5674    is_terminated: bool,
5675}
5676
5677impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
5678
5679impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
5680    fn is_terminated(&self) -> bool {
5681        self.is_terminated
5682    }
5683}
5684
5685impl fdomain_client::fidl::RequestStream for BufferCollectionTokenRequestStream {
5686    type Protocol = BufferCollectionTokenMarker;
5687    type ControlHandle = BufferCollectionTokenControlHandle;
5688
5689    fn from_channel(channel: fdomain_client::Channel) -> Self {
5690        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5691    }
5692
5693    fn control_handle(&self) -> Self::ControlHandle {
5694        BufferCollectionTokenControlHandle { inner: self.inner.clone() }
5695    }
5696
5697    fn into_inner(
5698        self,
5699    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
5700    {
5701        (self.inner, self.is_terminated)
5702    }
5703
5704    fn from_inner(
5705        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5706        is_terminated: bool,
5707    ) -> Self {
5708        Self { inner, is_terminated }
5709    }
5710}
5711
5712impl futures::Stream for BufferCollectionTokenRequestStream {
5713    type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
5714
5715    fn poll_next(
5716        mut self: std::pin::Pin<&mut Self>,
5717        cx: &mut std::task::Context<'_>,
5718    ) -> std::task::Poll<Option<Self::Item>> {
5719        let this = &mut *self;
5720        if this.inner.check_shutdown(cx) {
5721            this.is_terminated = true;
5722            return std::task::Poll::Ready(None);
5723        }
5724        if this.is_terminated {
5725            panic!("polled BufferCollectionTokenRequestStream after completion");
5726        }
5727        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5728            |bytes, handles| {
5729                match this.inner.channel().read_etc(cx, bytes, handles) {
5730                    std::task::Poll::Ready(Ok(())) => {}
5731                    std::task::Poll::Pending => return std::task::Poll::Pending,
5732                    std::task::Poll::Ready(Err(None)) => {
5733                        this.is_terminated = true;
5734                        return std::task::Poll::Ready(None);
5735                    }
5736                    std::task::Poll::Ready(Err(Some(e))) => {
5737                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5738                            e.into(),
5739                        ))));
5740                    }
5741                }
5742
5743                // A message has been received from the channel
5744                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5745
5746                std::task::Poll::Ready(Some(match header.ordinal {
5747                0x11ac2555cf575b54 => {
5748                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5749                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5750                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5751                    let control_handle = BufferCollectionTokenControlHandle {
5752                        inner: this.inner.clone(),
5753                    };
5754                    Ok(BufferCollectionTokenRequest::Sync {
5755                        responder: BufferCollectionTokenSyncResponder {
5756                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5757                            tx_id: header.tx_id,
5758                        },
5759                    })
5760                }
5761                0x6a5cae7d6d6e04c6 => {
5762                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5763                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5764                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5765                    let control_handle = BufferCollectionTokenControlHandle {
5766                        inner: this.inner.clone(),
5767                    };
5768                    Ok(BufferCollectionTokenRequest::Release {
5769                        control_handle,
5770                    })
5771                }
5772                0xb41f1624f48c1e9 => {
5773                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5774                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
5775                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5776                    let control_handle = BufferCollectionTokenControlHandle {
5777                        inner: this.inner.clone(),
5778                    };
5779                    Ok(BufferCollectionTokenRequest::SetName {payload: req,
5780                        control_handle,
5781                    })
5782                }
5783                0x5cde8914608d99b1 => {
5784                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5785                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
5786                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5787                    let control_handle = BufferCollectionTokenControlHandle {
5788                        inner: this.inner.clone(),
5789                    };
5790                    Ok(BufferCollectionTokenRequest::SetDebugClientInfo {payload: req,
5791                        control_handle,
5792                    })
5793                }
5794                0x716b0af13d5c0806 => {
5795                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5796                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
5797                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5798                    let control_handle = BufferCollectionTokenControlHandle {
5799                        inner: this.inner.clone(),
5800                    };
5801                    Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {payload: req,
5802                        control_handle,
5803                    })
5804                }
5805                0x5209c77415b4dfad => {
5806                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5807                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5808                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5809                    let control_handle = BufferCollectionTokenControlHandle {
5810                        inner: this.inner.clone(),
5811                    };
5812                    Ok(BufferCollectionTokenRequest::SetVerboseLogging {
5813                        control_handle,
5814                    })
5815                }
5816                0x5b3d0e51614df053 => {
5817                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5818                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5819                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5820                    let control_handle = BufferCollectionTokenControlHandle {
5821                        inner: this.inner.clone(),
5822                    };
5823                    Ok(BufferCollectionTokenRequest::GetNodeRef {
5824                        responder: BufferCollectionTokenGetNodeRefResponder {
5825                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5826                            tx_id: header.tx_id,
5827                        },
5828                    })
5829                }
5830                0x3a58e00157e0825 => {
5831                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5832                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
5833                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5834                    let control_handle = BufferCollectionTokenControlHandle {
5835                        inner: this.inner.clone(),
5836                    };
5837                    Ok(BufferCollectionTokenRequest::IsAlternateFor {payload: req,
5838                        responder: BufferCollectionTokenIsAlternateForResponder {
5839                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5840                            tx_id: header.tx_id,
5841                        },
5842                    })
5843                }
5844                0x77d19a494b78ba8c => {
5845                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5846                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5847                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5848                    let control_handle = BufferCollectionTokenControlHandle {
5849                        inner: this.inner.clone(),
5850                    };
5851                    Ok(BufferCollectionTokenRequest::GetBufferCollectionId {
5852                        responder: BufferCollectionTokenGetBufferCollectionIdResponder {
5853                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5854                            tx_id: header.tx_id,
5855                        },
5856                    })
5857                }
5858                0x22dd3ea514eeffe1 => {
5859                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5860                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5861                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5862                    let control_handle = BufferCollectionTokenControlHandle {
5863                        inner: this.inner.clone(),
5864                    };
5865                    Ok(BufferCollectionTokenRequest::SetWeak {
5866                        control_handle,
5867                    })
5868                }
5869                0x38a44fc4d7724be9 => {
5870                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5871                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
5872                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
5873                    let control_handle = BufferCollectionTokenControlHandle {
5874                        inner: this.inner.clone(),
5875                    };
5876                    Ok(BufferCollectionTokenRequest::SetWeakOk {payload: req,
5877                        control_handle,
5878                    })
5879                }
5880                0x3f22f2a293d3cdac => {
5881                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5882                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
5883                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
5884                    let control_handle = BufferCollectionTokenControlHandle {
5885                        inner: this.inner.clone(),
5886                    };
5887                    Ok(BufferCollectionTokenRequest::AttachNodeTracking {payload: req,
5888                        control_handle,
5889                    })
5890                }
5891                0x1c1af9919d1ca45c => {
5892                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5893                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
5894                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5895                    let control_handle = BufferCollectionTokenControlHandle {
5896                        inner: this.inner.clone(),
5897                    };
5898                    Ok(BufferCollectionTokenRequest::DuplicateSync {payload: req,
5899                        responder: BufferCollectionTokenDuplicateSyncResponder {
5900                            control_handle: std::mem::ManuallyDrop::new(control_handle),
5901                            tx_id: header.tx_id,
5902                        },
5903                    })
5904                }
5905                0x73e78f92ee7fb887 => {
5906                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5907                    let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fdomain_client::fidl::FDomainResourceDialect);
5908                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
5909                    let control_handle = BufferCollectionTokenControlHandle {
5910                        inner: this.inner.clone(),
5911                    };
5912                    Ok(BufferCollectionTokenRequest::Duplicate {payload: req,
5913                        control_handle,
5914                    })
5915                }
5916                0x228acf979254df8b => {
5917                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5918                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5919                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5920                    let control_handle = BufferCollectionTokenControlHandle {
5921                        inner: this.inner.clone(),
5922                    };
5923                    Ok(BufferCollectionTokenRequest::SetDispensable {
5924                        control_handle,
5925                    })
5926                }
5927                0x30f8d48e77bd36f2 => {
5928                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5929                    let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fdomain_client::fidl::FDomainResourceDialect);
5930                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
5931                    let control_handle = BufferCollectionTokenControlHandle {
5932                        inner: this.inner.clone(),
5933                    };
5934                    Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {payload: req,
5935                        control_handle,
5936                    })
5937                }
5938                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5939                    Ok(BufferCollectionTokenRequest::_UnknownMethod {
5940                        ordinal: header.ordinal,
5941                        control_handle: BufferCollectionTokenControlHandle { inner: this.inner.clone() },
5942                        method_type: fidl::MethodType::OneWay,
5943                    })
5944                }
5945                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5946                    this.inner.send_framework_err(
5947                        fidl::encoding::FrameworkErr::UnknownMethod,
5948                        header.tx_id,
5949                        header.ordinal,
5950                        header.dynamic_flags(),
5951                        (bytes, handles),
5952                    )?;
5953                    Ok(BufferCollectionTokenRequest::_UnknownMethod {
5954                        ordinal: header.ordinal,
5955                        control_handle: BufferCollectionTokenControlHandle { inner: this.inner.clone() },
5956                        method_type: fidl::MethodType::TwoWay,
5957                    })
5958                }
5959                _ => Err(fidl::Error::UnknownOrdinal {
5960                    ordinal: header.ordinal,
5961                    protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5962                }),
5963            }))
5964            },
5965        )
5966    }
5967}
5968
5969/// A [`fuchsia.sysmem2/BufferCollectionToken`] is not a buffer collection, but
5970/// rather is a way to identify a specific potential shared buffer collection,
5971/// and a way to distribute that potential shared buffer collection to
5972/// additional participants prior to the buffer collection allocating any
5973/// buffers.
5974///
5975/// Epitaphs are not used in this protocol.
5976///
5977/// We use a channel for the `BufferCollectionToken` instead of a single
5978/// `eventpair` (pair) because this way we can detect error conditions like a
5979/// participant failing mid-create.
5980#[derive(Debug)]
5981pub enum BufferCollectionTokenRequest {
5982    /// Ensure that previous messages have been received server side. This is
5983    /// particularly useful after previous messages that created new tokens,
5984    /// because a token must be known to the sysmem server before sending the
5985    /// token to another participant.
5986    ///
5987    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
5988    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
5989    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
5990    /// to mitigate the possibility of a hostile/fake
5991    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
5992    /// Another way is to pass the token to
5993    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
5994    /// the token as part of exchanging it for a
5995    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
5996    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
5997    /// of stalling.
5998    ///
5999    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
6000    /// and then starting and completing a `Sync`, it's then safe to send the
6001    /// `BufferCollectionToken` client ends to other participants knowing the
6002    /// server will recognize the tokens when they're sent by the other
6003    /// participants to sysmem in a
6004    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
6005    /// efficient way to create tokens while avoiding unnecessary round trips.
6006    ///
6007    /// Other options include waiting for each
6008    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
6009    /// individually (using separate call to `Sync` after each), or calling
6010    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
6011    /// converted to a `BufferCollection` via
6012    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
6013    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
6014    /// the sync step and can create multiple tokens at once.
6015    Sync { responder: BufferCollectionTokenSyncResponder },
6016    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
6017    ///
6018    /// Normally a participant will convert a `BufferCollectionToken` into a
6019    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
6020    /// `Release` via the token (and then close the channel immediately or
6021    /// shortly later in response to server closing the server end), which
6022    /// avoids causing buffer collection failure. Without a prior `Release`,
6023    /// closing the `BufferCollectionToken` client end will cause buffer
6024    /// collection failure.
6025    ///
6026    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
6027    ///
6028    /// By default the server handles unexpected closure of a
6029    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
6030    /// first) by failing the buffer collection. Partly this is to expedite
6031    /// closing VMO handles to reclaim memory when any participant fails. If a
6032    /// participant would like to cleanly close a `BufferCollection` without
6033    /// causing buffer collection failure, the participant can send `Release`
6034    /// before closing the `BufferCollection` client end. The `Release` can
6035    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
6036    /// buffer collection won't require constraints from this node in order to
6037    /// allocate. If after `SetConstraints`, the constraints are retained and
6038    /// aggregated, despite the lack of `BufferCollection` connection at the
6039    /// time of constraints aggregation.
6040    ///
6041    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
6042    ///
6043    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
6044    /// end (without `Release` first) will trigger failure of the buffer
6045    /// collection. To close a `BufferCollectionTokenGroup` channel without
6046    /// failing the buffer collection, ensure that AllChildrenPresent() has been
6047    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
6048    /// client end.
6049    ///
6050    /// If `Release` occurs before
6051    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
6052    /// buffer collection will fail (triggered by reception of `Release` without
6053    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
6054    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
6055    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
6056    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
6057    /// close requires `AllChildrenPresent` (if not already sent), then
6058    /// `Release`, then close client end.
6059    ///
6060    /// If `Release` occurs after `AllChildrenPresent`, the children and all
6061    /// their constraints remain intact (just as they would if the
6062    /// `BufferCollectionTokenGroup` channel had remained open), and the client
6063    /// end close doesn't trigger buffer collection failure.
6064    ///
6065    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
6066    ///
6067    /// For brevity, the per-channel-protocol paragraphs above ignore the
6068    /// separate failure domain created by
6069    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
6070    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
6071    /// unexpectedly closes (without `Release` first) and that client end is
6072    /// under a failure domain, instead of failing the whole buffer collection,
6073    /// the failure domain is failed, but the buffer collection itself is
6074    /// isolated from failure of the failure domain. Such failure domains can be
6075    /// nested, in which case only the inner-most failure domain in which the
6076    /// `Node` resides fails.
6077    Release { control_handle: BufferCollectionTokenControlHandle },
6078    /// Set a name for VMOs in this buffer collection.
6079    ///
6080    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
6081    /// will be truncated to fit. The name of the vmo will be suffixed with the
6082    /// buffer index within the collection (if the suffix fits within
6083    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
6084    /// listed in the inspect data.
6085    ///
6086    /// The name only affects VMOs allocated after the name is set; this call
6087    /// does not rename existing VMOs. If multiple clients set different names
6088    /// then the larger priority value will win. Setting a new name with the
6089    /// same priority as a prior name doesn't change the name.
6090    ///
6091    /// All table fields are currently required.
6092    ///
6093    /// + request `priority` The name is only set if this is the first `SetName`
6094    ///   or if `priority` is greater than any previous `priority` value in
6095    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
6096    /// + request `name` The name for VMOs created under this buffer collection.
6097    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionTokenControlHandle },
6098    /// Set information about the current client that can be used by sysmem to
6099    /// help diagnose leaking memory and allocation stalls waiting for a
6100    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
6101    ///
6102    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
6103    /// `Node`(s) derived from this `Node`, unless overriden by
6104    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
6105    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
6106    ///
6107    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
6108    /// `Allocator` is the most efficient way to ensure that all
6109    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
6110    /// set, and is also more efficient than separately sending the same debug
6111    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
6112    /// created [`fuchsia.sysmem2/Node`].
6113    ///
6114    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
6115    /// indicate which client is closing their channel first, leading to subtree
6116    /// failure (which can be normal if the purpose of the subtree is over, but
6117    /// if happening earlier than expected, the client-channel-specific name can
6118    /// help diagnose where the failure is first coming from, from sysmem's
6119    /// point of view).
6120    ///
6121    /// All table fields are currently required.
6122    ///
6123    /// + request `name` This can be an arbitrary string, but the current
6124    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
6125    /// + request `id` This can be an arbitrary id, but the current process ID
6126    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
6127    SetDebugClientInfo {
6128        payload: NodeSetDebugClientInfoRequest,
6129        control_handle: BufferCollectionTokenControlHandle,
6130    },
6131    /// Sysmem logs a warning if sysmem hasn't seen
6132    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
6133    /// within 5 seconds after creation of a new collection.
6134    ///
6135    /// Clients can call this method to change when the log is printed. If
6136    /// multiple client set the deadline, it's unspecified which deadline will
6137    /// take effect.
6138    ///
6139    /// In most cases the default works well.
6140    ///
6141    /// All table fields are currently required.
6142    ///
6143    /// + request `deadline` The time at which sysmem will start trying to log
6144    ///   the warning, unless all constraints are with sysmem by then.
6145    SetDebugTimeoutLogDeadline {
6146        payload: NodeSetDebugTimeoutLogDeadlineRequest,
6147        control_handle: BufferCollectionTokenControlHandle,
6148    },
6149    /// This enables verbose logging for the buffer collection.
6150    ///
6151    /// Verbose logging includes constraints set via
6152    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
6153    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
6154    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
6155    /// the tree of `Node`(s).
6156    ///
6157    /// Normally sysmem prints only a single line complaint when aggregation
6158    /// fails, with just the specific detailed reason that aggregation failed,
6159    /// with little surrounding context.  While this is often enough to diagnose
6160    /// a problem if only a small change was made and everything was working
6161    /// before the small change, it's often not particularly helpful for getting
6162    /// a new buffer collection to work for the first time.  Especially with
6163    /// more complex trees of nodes, involving things like
6164    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
6165    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
6166    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
6167    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
6168    /// looks like and why it's failing a logical allocation, or why a tree or
6169    /// subtree is failing sooner than expected.
6170    ///
6171    /// The intent of the extra logging is to be acceptable from a performance
6172    /// point of view, under the assumption that verbose logging is only enabled
6173    /// on a low number of buffer collections. If we're not tracking down a bug,
6174    /// we shouldn't send this message.
6175    SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
6176    /// This gets a handle that can be used as a parameter to
6177    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
6178    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
6179    /// client obtained this handle from this `Node`.
6180    ///
6181    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
6182    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
6183    /// despite the two calls typically being on different channels.
6184    ///
6185    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
6186    ///
6187    /// All table fields are currently required.
6188    ///
6189    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
6190    ///   different `Node` channel, to prove that the client obtained the handle
6191    ///   from this `Node`.
6192    GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
6193    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
6194    /// rooted at a different child token of a common parent
6195    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
6196    /// passed-in `node_ref`.
6197    ///
6198    /// This call is for assisting with admission control de-duplication, and
6199    /// with debugging.
6200    ///
6201    /// The `node_ref` must be obtained using
6202    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
6203    ///
6204    /// The `node_ref` can be a duplicated handle; it's not necessary to call
6205    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
6206    ///
6207    /// If a calling token may not actually be a valid token at all due to a
6208    /// potentially hostile/untrusted provider of the token, call
6209    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
6210    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
6211    /// never responds due to a calling token not being a real token (not really
6212    /// talking to sysmem).  Another option is to call
6213    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
6214    /// which also validates the token along with converting it to a
6215    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
6216    ///
6217    /// All table fields are currently required.
6218    ///
6219    /// - response `is_alternate`
6220    ///   - true: The first parent node in common between the calling node and
6221    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
6222    ///     that the calling `Node` and the `node_ref` `Node` will not have both
6223    ///     their constraints apply - rather sysmem will choose one or the other
6224    ///     of the constraints - never both.  This is because only one child of
6225    ///     a `BufferCollectionTokenGroup` is selected during logical
6226    ///     allocation, with only that one child's subtree contributing to
6227    ///     constraints aggregation.
6228    ///   - false: The first parent node in common between the calling `Node`
6229    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
6230    ///     Currently, this means the first parent node in common is a
6231    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
6232    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
6233    ///     `Node` may have both their constraints apply during constraints
6234    ///     aggregation of the logical allocation, if both `Node`(s) are
6235    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
6236    ///     this case, there is no `BufferCollectionTokenGroup` that will
6237    ///     directly prevent the two `Node`(s) from both being selected and
6238    ///     their constraints both aggregated, but even when false, one or both
6239    ///     `Node`(s) may still be eliminated from consideration if one or both
6240    ///     `Node`(s) has a direct or indirect parent
6241    ///     `BufferCollectionTokenGroup` which selects a child subtree other
6242    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
6243    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
6244    ///   associated with the same buffer collection as the calling `Node`.
6245    ///   Another reason for this error is if the `node_ref` is an
6246    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
6247    ///   a real `node_ref` obtained from `GetNodeRef`.
6248    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
6249    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
6250    ///   the needed rights expected on a real `node_ref`.
6251    /// * No other failing status codes are returned by this call.  However,
6252    ///   sysmem may add additional codes in future, so the client should have
6253    ///   sensible default handling for any failing status code.
6254    IsAlternateFor {
6255        payload: NodeIsAlternateForRequest,
6256        responder: BufferCollectionTokenIsAlternateForResponder,
6257    },
6258    /// Get the buffer collection ID. This ID is also available from
6259    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
6260    /// within the collection).
6261    ///
6262    /// This call is mainly useful in situations where we can't convey a
6263    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
6264    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
6265    /// handle, which can be joined back up with a `BufferCollection` client end
6266    /// that was created via a different path. Prefer to convey a
6267    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
6268    ///
6269    /// Trusting a `buffer_collection_id` value from a source other than sysmem
6270    /// is analogous to trusting a koid value from a source other than zircon.
6271    /// Both should be avoided unless really necessary, and both require
6272    /// caution. In some situations it may be reasonable to refer to a
6273    /// pre-established `BufferCollection` by `buffer_collection_id` via a
6274    /// protocol for efficiency reasons, but an incoming value purporting to be
6275    /// a `buffer_collection_id` is not sufficient alone to justify granting the
6276    /// sender of the `buffer_collection_id` any capability. The sender must
6277    /// first prove to a receiver that the sender has/had a VMO or has/had a
6278    /// `BufferCollectionToken` to the same collection by sending a handle that
6279    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
6280    /// `buffer_collection_id` value. The receiver should take care to avoid
6281    /// assuming that a sender had a `BufferCollectionToken` in cases where the
6282    /// sender has only proven that the sender had a VMO.
6283    ///
6284    /// - response `buffer_collection_id` This ID is unique per buffer
6285    ///   collection per boot. Each buffer is uniquely identified by the
6286    ///   `buffer_collection_id` and `buffer_index` together.
6287    GetBufferCollectionId { responder: BufferCollectionTokenGetBufferCollectionIdResponder },
6288    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
6289    /// created after this message to weak, which means that a client's `Node`
6290    /// client end (or a child created after this message) is not alone
6291    /// sufficient to keep allocated VMOs alive.
6292    ///
6293    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
6294    /// `close_weak_asap`.
6295    ///
6296    /// This message is only permitted before the `Node` becomes ready for
6297    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
6298    ///   * `BufferCollectionToken`: any time
6299    ///   * `BufferCollection`: before `SetConstraints`
6300    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
6301    ///
6302    /// Currently, no conversion from strong `Node` to weak `Node` after ready
6303    /// for allocation is provided, but a client can simulate that by creating
6304    /// an additional `Node` before allocation and setting that additional
6305    /// `Node` to weak, and then potentially at some point later sending
6306    /// `Release` and closing the client end of the client's strong `Node`, but
6307    /// keeping the client's weak `Node`.
6308    ///
6309    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
6310    /// collection failure (all `Node` client end(s) will see
6311    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
6312    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
6313    /// this situation until all `Node`(s) are ready for allocation. For initial
6314    /// allocation to succeed, at least one strong `Node` is required to exist
6315    /// at allocation time, but after that client receives VMO handles, that
6316    /// client can `BufferCollection.Release` and close the client end without
6317    /// causing this type of failure.
6318    ///
6319    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
6320    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
6321    /// separately as appropriate.
6322    SetWeak { control_handle: BufferCollectionTokenControlHandle },
6323    /// This indicates to sysmem that the client is prepared to pay attention to
6324    /// `close_weak_asap`.
6325    ///
6326    /// If sent, this message must be before
6327    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
6328    ///
6329    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
6330    /// send this message before `WaitForAllBuffersAllocated`, or a parent
6331    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
6332    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
6333    /// trigger buffer collection failure.
6334    ///
6335    /// This message is necessary because weak sysmem VMOs have not always been
6336    /// a thing, so older clients are not aware of the need to pay attention to
6337    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
6338    /// sysmem weak VMO handles asap. By having this message and requiring
6339    /// participants to indicate their acceptance of this aspect of the overall
6340    /// protocol, we avoid situations where an older client is delivered a weak
6341    /// VMO without any way for sysmem to get that VMO to close quickly later
6342    /// (and on a per-buffer basis).
6343    ///
6344    /// A participant that doesn't handle `close_weak_asap` and also doesn't
6345    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
6346    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
6347    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
6348    /// same participant has a child/delegate which does retrieve VMOs, that
6349    /// child/delegate will need to send `SetWeakOk` before
6350    /// `WaitForAllBuffersAllocated`.
6351    ///
6352    /// + request `for_child_nodes_also` If present and true, this means direct
6353    ///   child nodes of this node created after this message plus all
6354    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
6355    ///   those nodes. Any child node of this node that was created before this
6356    ///   message is not included. This setting is "sticky" in the sense that a
6357    ///   subsequent `SetWeakOk` without this bool set to true does not reset
6358    ///   the server-side bool. If this creates a problem for a participant, a
6359    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
6360    ///   tokens instead, as appropriate. A participant should only set
6361    ///   `for_child_nodes_also` true if the participant can really promise to
6362    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
6363    ///   weak VMO handles held by participants holding the corresponding child
6364    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
6365    ///   which are using sysmem(1) can be weak, despite the clients of those
6366    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
6367    ///   direct way to find out about `close_weak_asap`. This only applies to
6368    ///   descendents of this `Node` which are using sysmem(1), not to this
6369    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
6370    ///   token, which will fail allocation unless an ancestor of this `Node`
6371    ///   specified `for_child_nodes_also` true.
6372    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: BufferCollectionTokenControlHandle },
6373    /// The server_end will be closed after this `Node` and any child nodes have
6374    /// have released their buffer counts, making those counts available for
6375    /// reservation by a different `Node` via
6376    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
6377    ///
6378    /// The `Node` buffer counts may not be released until the entire tree of
6379    /// `Node`(s) is closed or failed, because
6380    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
6381    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
6382    /// `Node` buffer counts remain reserved until the orphaned node is later
6383    /// cleaned up.
6384    ///
6385    /// If the `Node` exceeds a fairly large number of attached eventpair server
6386    /// ends, a log message will indicate this and the `Node` (and the
6387    /// appropriate) sub-tree will fail.
6388    ///
6389    /// The `server_end` will remain open when
6390    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
6391    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
6392    /// [`fuchsia.sysmem2/BufferCollection`].
6393    ///
6394    /// This message can also be used with a
6395    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
6396    AttachNodeTracking {
6397        payload: NodeAttachNodeTrackingRequest,
6398        control_handle: BufferCollectionTokenControlHandle,
6399    },
6400    /// Create additional [`fuchsia.sysmem2/BufferCollectionToken`](s) from this
6401    /// one, referring to the same buffer collection.
6402    ///
6403    /// The created tokens are children of this token in the
6404    /// [`fuchsia.sysmem2/Node`] heirarchy.
6405    ///
6406    /// This method can be used to add more participants, by transferring the
6407    /// newly created tokens to additional participants.
6408    ///
6409    /// A new token will be returned for each entry in the
6410    /// `rights_attenuation_masks` array.
6411    ///
6412    /// If the called token may not actually be a valid token due to a
6413    /// potentially hostile/untrusted provider of the token, consider using
6414    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
6415    /// instead of potentially getting stuck indefinitely if
6416    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] never responds
6417    /// due to the calling token not being a real token.
6418    ///
6419    /// In contrast to [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`], no
6420    /// separate [`fuchsia.sysmem2/Node.Sync`] is needed after calling this
6421    /// method, because the sync step is included in this call, at the cost of a
6422    /// round trip during this call.
6423    ///
6424    /// All tokens must be turned in to sysmem via
6425    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
6426    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
6427    /// successfully allocate buffers (or to logically allocate buffers in the
6428    /// case of subtrees involving
6429    /// [`fuchsia.sysmem2/BufferCollectionToken.AttachToken`]).
6430    ///
6431    /// All table fields are currently required.
6432    ///
6433    /// + request `rights_attenuation_mask` In each entry of
6434    ///   `rights_attenuation_masks`, rights bits that are zero will be absent
6435    ///   in the buffer VMO rights obtainable via the corresponding returned
6436    ///   token. This allows an initiator or intermediary participant to
6437    ///   attenuate the rights available to a participant. This does not allow a
6438    ///   participant to gain rights that the participant doesn't already have.
6439    ///   The value `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no
6440    ///   attenuation should be applied.
6441    /// - response `tokens` The client ends of each newly created token.
6442    DuplicateSync {
6443        payload: BufferCollectionTokenDuplicateSyncRequest,
6444        responder: BufferCollectionTokenDuplicateSyncResponder,
6445    },
6446    /// Create an additional [`fuchsia.sysmem2/BufferCollectionToken`] from this
6447    /// one, referring to the same buffer collection.
6448    ///
6449    /// The created token is a child of this token in the
6450    /// [`fuchsia.sysmem2/Node`] heirarchy.
6451    ///
6452    /// This method can be used to add a participant, by transferring the newly
6453    /// created token to another participant.
6454    ///
6455    /// This one-way message can be used instead of the two-way
6456    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] FIDL call in
6457    /// performance sensitive cases where it would be undesireable to wait for
6458    /// sysmem to respond to
6459    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] or when the
6460    /// client code isn't structured to make it easy to duplicate all the needed
6461    /// tokens at once.
6462    ///
6463    /// After sending one or more `Duplicate` messages, and before sending the
6464    /// newly created child tokens to other participants (or to other
6465    /// [`fuchsia.sysmem2/Allocator`] channels), the client must send a
6466    /// [`fuchsia.sysmem2/Node.Sync`] and wait for the `Sync` response. The
6467    /// `Sync` call can be made on the token, or on the `BufferCollection`
6468    /// obtained by passing this token to `BindSharedCollection`.  Either will
6469    /// ensure that the server knows about the tokens created via `Duplicate`
6470    /// before the other participant sends the token to the server via separate
6471    /// `Allocator` channel.
6472    ///
6473    /// All tokens must be turned in via
6474    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] or
6475    /// [`fuchsia.sysmem2/Node.Release`] for a `BufferCollection` to
6476    /// successfully allocate buffers.
6477    ///
6478    /// All table fields are currently required.
6479    ///
6480    /// + request `rights_attenuation_mask` The rights bits that are zero in
6481    ///   this mask will be absent in the buffer VMO rights obtainable via the
6482    ///   client end of `token_request`. This allows an initiator or
6483    ///   intermediary participant to attenuate the rights available to a
6484    ///   delegate participant. This does not allow a participant to gain rights
6485    ///   that the participant doesn't already have. The value
6486    ///   `ZX_RIGHT_SAME_RIGHTS` can be used to specify that no attenuation
6487    ///   should be applied.
6488    ///   + These values for rights_attenuation_mask result in no attenuation:
6489    ///     + `ZX_RIGHT_SAME_RIGHTS` (preferred)
6490    ///     + 0xFFFFFFFF (this is reasonable when an attenuation mask is
6491    ///       computed)
6492    ///     + 0 (deprecated - do not use 0 - an ERROR will go to the log)
6493    /// + request `token_request` is the server end of a `BufferCollectionToken`
6494    ///   channel. The client end of this channel acts as another participant in
6495    ///   the shared buffer collection.
6496    Duplicate {
6497        payload: BufferCollectionTokenDuplicateRequest,
6498        control_handle: BufferCollectionTokenControlHandle,
6499    },
6500    /// Set this [`fuchsia.sysmem2/BufferCollectionToken`] to dispensable.
6501    ///
6502    /// When the `BufferCollectionToken` is converted to a
6503    /// [`fuchsia.sysmem2/BufferCollection`], the dispensable status applies to
6504    /// the `BufferCollection` also.
6505    ///
6506    /// Normally, if a client closes a [`fuchsia.sysmem2/BufferCollection`]
6507    /// client end without having sent
6508    /// [`fuchsia.sysmem2/BufferCollection.Release`] first, the
6509    /// `BufferCollection` [`fuchisa.sysmem2/Node`] will fail, which also
6510    /// propagates failure to the parent [`fuchsia.sysmem2/Node`] and so on up
6511    /// to the root `Node`, which fails the whole buffer collection. In
6512    /// contrast, a dispensable `Node` can fail after buffers are allocated
6513    /// without causing failure of its parent in the [`fuchsia.sysmem2/Node`]
6514    /// heirarchy.
6515    ///
6516    /// The dispensable `Node` participates in constraints aggregation along
6517    /// with its parent before buffer allocation. If the dispensable `Node`
6518    /// fails before buffers are allocated, the failure propagates to the
6519    /// dispensable `Node`'s parent.
6520    ///
6521    /// After buffers are allocated, failure of the dispensable `Node` (or any
6522    /// child of the dispensable `Node`) does not propagate to the dispensable
6523    /// `Node`'s parent. Failure does propagate from a normal child of a
6524    /// dispensable `Node` to the dispensable `Node`.  Failure of a child is
6525    /// blocked from reaching its parent if the child is attached using
6526    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or if the child is
6527    /// dispensable and the failure occurred after allocation.
6528    ///
6529    /// A dispensable `Node` can be used in cases where a participant needs to
6530    /// provide constraints, but after buffers are allocated, the participant
6531    /// can fail without causing buffer collection failure from the parent
6532    /// `Node`'s point of view.
6533    ///
6534    /// In contrast, `BufferCollection.AttachToken` can be used to create a
6535    /// `BufferCollectionToken` which does not participate in constraints
6536    /// aggregation with its parent `Node`, and whose failure at any time does
6537    /// not propagate to its parent `Node`, and whose potential delay providing
6538    /// constraints does not prevent the parent `Node` from completing its
6539    /// buffer allocation.
6540    ///
6541    /// An initiator (creator of the root `Node` using
6542    /// [`fuchsia.sysmem2/Allocator.AllocateSharedCollection`]) may in some
6543    /// scenarios choose to initially use a dispensable `Node` for a first
6544    /// instance of a participant, and then later if the first instance of that
6545    /// participant fails, a new second instance of that participant my be given
6546    /// a `BufferCollectionToken` created with `AttachToken`.
6547    ///
6548    /// Normally a client will `SetDispensable` on a `BufferCollectionToken`
6549    /// shortly before sending the dispensable `BufferCollectionToken` to a
6550    /// delegate participant. Because `SetDispensable` prevents propagation of
6551    /// child `Node` failure to parent `Node`(s), if the client was relying on
6552    /// noticing child failure via failure of the parent `Node` retained by the
6553    /// client, the client may instead need to notice failure via other means.
6554    /// If other means aren't available/convenient, the client can instead
6555    /// retain the dispensable `Node` and create a child `Node` under that to
6556    /// send to the delegate participant, retaining this `Node` in order to
6557    /// notice failure of the subtree rooted at this `Node` via this `Node`'s
6558    /// ZX_CHANNEL_PEER_CLOSED signal, and take whatever action is appropriate
6559    /// (e.g. starting a new instance of the delegate participant and handing it
6560    /// a `BufferCollectionToken` created using
6561    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`], or propagate failure
6562    /// and clean up in a client-specific way).
6563    ///
6564    /// While it is possible (and potentially useful) to `SetDispensable` on a
6565    /// direct child of a `BufferCollectionTokenGroup` `Node`, it isn't possible
6566    /// to later replace a failed dispensable `Node` that was a direct child of
6567    /// a `BufferCollectionTokenGroup` with a new token using `AttachToken`
6568    /// (since there's no `AttachToken` on a group). Instead, to enable
6569    /// `AttachToken` replacement in this case, create an additional
6570    /// non-dispensable token that's a direct child of the group and make the
6571    /// existing dispensable token a child of the additional token.  This way,
6572    /// the additional token that is a direct child of the group has
6573    /// `BufferCollection.AttachToken` which can be used to replace the failed
6574    /// dispensable token.
6575    ///
6576    /// `SetDispensable` on an already-dispensable token is idempotent.
6577    SetDispensable { control_handle: BufferCollectionTokenControlHandle },
6578    /// Create a logical OR among a set of tokens, called a
6579    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
6580    ///
6581    /// Most sysmem clients and many participants don't need to care about this
6582    /// message or about `BufferCollectionTokenGroup`(s). However, in some cases
6583    /// a participant wants to attempt to include one set of delegate
6584    /// participants, but if constraints don't combine successfully that way,
6585    /// fall back to a different (possibly overlapping) set of delegate
6586    /// participants, and/or fall back to a less demanding strategy (in terms of
6587    /// how strict the [`fuchisa.sysmem2/BufferCollectionConstraints`] are,
6588    /// across all involved delegate participants). In such cases, a
6589    /// `BufferCollectionTokenGroup` is useful.
6590    ///
6591    /// A `BufferCollectionTokenGroup` is used to create a 1 of N OR among N
6592    /// child [`fuchsia.sysmem2/BufferCollectionToken`](s).  The child tokens
6593    /// which are not selected during aggregation will fail (close), which a
6594    /// potential participant should notice when their `BufferCollection`
6595    /// channel client endpoint sees PEER_CLOSED, allowing the participant to
6596    /// clean up the speculative usage that didn't end up happening (this is
6597    /// simimlar to a normal `BufferCollection` server end closing on failure to
6598    /// allocate a logical buffer collection or later async failure of a buffer
6599    /// collection).
6600    ///
6601    /// See comments on protocol `BufferCollectionTokenGroup`.
6602    ///
6603    /// Any `rights_attenuation_mask` or `AttachToken`/`SetDispensable` to be
6604    /// applied to the whole group can be achieved with a
6605    /// `BufferCollectionToken` for this purpose as a direct parent of the
6606    /// `BufferCollectionTokenGroup`.
6607    ///
6608    /// All table fields are currently required.
6609    ///
6610    /// + request `group_request` The server end of a
6611    ///   `BufferCollectionTokenGroup` channel to be served by sysmem.
6612    CreateBufferCollectionTokenGroup {
6613        payload: BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
6614        control_handle: BufferCollectionTokenControlHandle,
6615    },
6616    /// An interaction was received which does not match any known method.
6617    #[non_exhaustive]
6618    _UnknownMethod {
6619        /// Ordinal of the method that was called.
6620        ordinal: u64,
6621        control_handle: BufferCollectionTokenControlHandle,
6622        method_type: fidl::MethodType,
6623    },
6624}
6625
6626impl BufferCollectionTokenRequest {
6627    #[allow(irrefutable_let_patterns)]
6628    pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
6629        if let BufferCollectionTokenRequest::Sync { responder } = self {
6630            Some((responder))
6631        } else {
6632            None
6633        }
6634    }
6635
6636    #[allow(irrefutable_let_patterns)]
6637    pub fn into_release(self) -> Option<(BufferCollectionTokenControlHandle)> {
6638        if let BufferCollectionTokenRequest::Release { control_handle } = self {
6639            Some((control_handle))
6640        } else {
6641            None
6642        }
6643    }
6644
6645    #[allow(irrefutable_let_patterns)]
6646    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, BufferCollectionTokenControlHandle)> {
6647        if let BufferCollectionTokenRequest::SetName { payload, control_handle } = self {
6648            Some((payload, control_handle))
6649        } else {
6650            None
6651        }
6652    }
6653
6654    #[allow(irrefutable_let_patterns)]
6655    pub fn into_set_debug_client_info(
6656        self,
6657    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionTokenControlHandle)> {
6658        if let BufferCollectionTokenRequest::SetDebugClientInfo { payload, control_handle } = self {
6659            Some((payload, control_handle))
6660        } else {
6661            None
6662        }
6663    }
6664
6665    #[allow(irrefutable_let_patterns)]
6666    pub fn into_set_debug_timeout_log_deadline(
6667        self,
6668    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionTokenControlHandle)> {
6669        if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
6670            payload,
6671            control_handle,
6672        } = self
6673        {
6674            Some((payload, control_handle))
6675        } else {
6676            None
6677        }
6678    }
6679
6680    #[allow(irrefutable_let_patterns)]
6681    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
6682        if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
6683            Some((control_handle))
6684        } else {
6685            None
6686        }
6687    }
6688
6689    #[allow(irrefutable_let_patterns)]
6690    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
6691        if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
6692            Some((responder))
6693        } else {
6694            None
6695        }
6696    }
6697
6698    #[allow(irrefutable_let_patterns)]
6699    pub fn into_is_alternate_for(
6700        self,
6701    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionTokenIsAlternateForResponder)> {
6702        if let BufferCollectionTokenRequest::IsAlternateFor { payload, responder } = self {
6703            Some((payload, responder))
6704        } else {
6705            None
6706        }
6707    }
6708
6709    #[allow(irrefutable_let_patterns)]
6710    pub fn into_get_buffer_collection_id(
6711        self,
6712    ) -> Option<(BufferCollectionTokenGetBufferCollectionIdResponder)> {
6713        if let BufferCollectionTokenRequest::GetBufferCollectionId { responder } = self {
6714            Some((responder))
6715        } else {
6716            None
6717        }
6718    }
6719
6720    #[allow(irrefutable_let_patterns)]
6721    pub fn into_set_weak(self) -> Option<(BufferCollectionTokenControlHandle)> {
6722        if let BufferCollectionTokenRequest::SetWeak { control_handle } = self {
6723            Some((control_handle))
6724        } else {
6725            None
6726        }
6727    }
6728
6729    #[allow(irrefutable_let_patterns)]
6730    pub fn into_set_weak_ok(
6731        self,
6732    ) -> Option<(NodeSetWeakOkRequest, BufferCollectionTokenControlHandle)> {
6733        if let BufferCollectionTokenRequest::SetWeakOk { payload, control_handle } = self {
6734            Some((payload, control_handle))
6735        } else {
6736            None
6737        }
6738    }
6739
6740    #[allow(irrefutable_let_patterns)]
6741    pub fn into_attach_node_tracking(
6742        self,
6743    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionTokenControlHandle)> {
6744        if let BufferCollectionTokenRequest::AttachNodeTracking { payload, control_handle } = self {
6745            Some((payload, control_handle))
6746        } else {
6747            None
6748        }
6749    }
6750
6751    #[allow(irrefutable_let_patterns)]
6752    pub fn into_duplicate_sync(
6753        self,
6754    ) -> Option<(
6755        BufferCollectionTokenDuplicateSyncRequest,
6756        BufferCollectionTokenDuplicateSyncResponder,
6757    )> {
6758        if let BufferCollectionTokenRequest::DuplicateSync { payload, responder } = self {
6759            Some((payload, responder))
6760        } else {
6761            None
6762        }
6763    }
6764
6765    #[allow(irrefutable_let_patterns)]
6766    pub fn into_duplicate(
6767        self,
6768    ) -> Option<(BufferCollectionTokenDuplicateRequest, BufferCollectionTokenControlHandle)> {
6769        if let BufferCollectionTokenRequest::Duplicate { payload, control_handle } = self {
6770            Some((payload, control_handle))
6771        } else {
6772            None
6773        }
6774    }
6775
6776    #[allow(irrefutable_let_patterns)]
6777    pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
6778        if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
6779            Some((control_handle))
6780        } else {
6781            None
6782        }
6783    }
6784
6785    #[allow(irrefutable_let_patterns)]
6786    pub fn into_create_buffer_collection_token_group(
6787        self,
6788    ) -> Option<(
6789        BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
6790        BufferCollectionTokenControlHandle,
6791    )> {
6792        if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
6793            payload,
6794            control_handle,
6795        } = self
6796        {
6797            Some((payload, control_handle))
6798        } else {
6799            None
6800        }
6801    }
6802
6803    /// Name of the method defined in FIDL
6804    pub fn method_name(&self) -> &'static str {
6805        match *self {
6806            BufferCollectionTokenRequest::Sync { .. } => "sync",
6807            BufferCollectionTokenRequest::Release { .. } => "release",
6808            BufferCollectionTokenRequest::SetName { .. } => "set_name",
6809            BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6810            BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
6811                "set_debug_timeout_log_deadline"
6812            }
6813            BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6814            BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
6815            BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
6816            BufferCollectionTokenRequest::GetBufferCollectionId { .. } => {
6817                "get_buffer_collection_id"
6818            }
6819            BufferCollectionTokenRequest::SetWeak { .. } => "set_weak",
6820            BufferCollectionTokenRequest::SetWeakOk { .. } => "set_weak_ok",
6821            BufferCollectionTokenRequest::AttachNodeTracking { .. } => "attach_node_tracking",
6822            BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
6823            BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
6824            BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
6825            BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
6826                "create_buffer_collection_token_group"
6827            }
6828            BufferCollectionTokenRequest::_UnknownMethod {
6829                method_type: fidl::MethodType::OneWay,
6830                ..
6831            } => "unknown one-way method",
6832            BufferCollectionTokenRequest::_UnknownMethod {
6833                method_type: fidl::MethodType::TwoWay,
6834                ..
6835            } => "unknown two-way method",
6836        }
6837    }
6838}
6839
6840#[derive(Debug, Clone)]
6841pub struct BufferCollectionTokenControlHandle {
6842    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6843}
6844
6845impl BufferCollectionTokenControlHandle {
6846    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6847        self.inner.shutdown_with_epitaph(status.into())
6848    }
6849}
6850
6851impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenControlHandle {
6852    fn shutdown(&self) {
6853        self.inner.shutdown()
6854    }
6855
6856    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6857        self.inner.shutdown_with_epitaph(status)
6858    }
6859
6860    fn is_closed(&self) -> bool {
6861        self.inner.channel().is_closed()
6862    }
6863    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6864        self.inner.channel().on_closed()
6865    }
6866}
6867
6868impl BufferCollectionTokenControlHandle {}
6869
6870#[must_use = "FIDL methods require a response to be sent"]
6871#[derive(Debug)]
6872pub struct BufferCollectionTokenSyncResponder {
6873    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6874    tx_id: u32,
6875}
6876
6877/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6878/// if the responder is dropped without sending a response, so that the client
6879/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6880impl std::ops::Drop for BufferCollectionTokenSyncResponder {
6881    fn drop(&mut self) {
6882        self.control_handle.shutdown();
6883        // Safety: drops once, never accessed again
6884        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6885    }
6886}
6887
6888impl fdomain_client::fidl::Responder for BufferCollectionTokenSyncResponder {
6889    type ControlHandle = BufferCollectionTokenControlHandle;
6890
6891    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6892        &self.control_handle
6893    }
6894
6895    fn drop_without_shutdown(mut self) {
6896        // Safety: drops once, never accessed again due to mem::forget
6897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6898        // Prevent Drop from running (which would shut down the channel)
6899        std::mem::forget(self);
6900    }
6901}
6902
6903impl BufferCollectionTokenSyncResponder {
6904    /// Sends a response to the FIDL transaction.
6905    ///
6906    /// Sets the channel to shutdown if an error occurs.
6907    pub fn send(self) -> Result<(), fidl::Error> {
6908        let _result = self.send_raw();
6909        if _result.is_err() {
6910            self.control_handle.shutdown();
6911        }
6912        self.drop_without_shutdown();
6913        _result
6914    }
6915
6916    /// Similar to "send" but does not shutdown the channel if an error occurs.
6917    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6918        let _result = self.send_raw();
6919        self.drop_without_shutdown();
6920        _result
6921    }
6922
6923    fn send_raw(&self) -> Result<(), fidl::Error> {
6924        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
6925            fidl::encoding::Flexible::new(()),
6926            self.tx_id,
6927            0x11ac2555cf575b54,
6928            fidl::encoding::DynamicFlags::FLEXIBLE,
6929        )
6930    }
6931}
6932
6933#[must_use = "FIDL methods require a response to be sent"]
6934#[derive(Debug)]
6935pub struct BufferCollectionTokenGetNodeRefResponder {
6936    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
6937    tx_id: u32,
6938}
6939
6940/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
6941/// if the responder is dropped without sending a response, so that the client
6942/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6943impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
6944    fn drop(&mut self) {
6945        self.control_handle.shutdown();
6946        // Safety: drops once, never accessed again
6947        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6948    }
6949}
6950
6951impl fdomain_client::fidl::Responder for BufferCollectionTokenGetNodeRefResponder {
6952    type ControlHandle = BufferCollectionTokenControlHandle;
6953
6954    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
6955        &self.control_handle
6956    }
6957
6958    fn drop_without_shutdown(mut self) {
6959        // Safety: drops once, never accessed again due to mem::forget
6960        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6961        // Prevent Drop from running (which would shut down the channel)
6962        std::mem::forget(self);
6963    }
6964}
6965
6966impl BufferCollectionTokenGetNodeRefResponder {
6967    /// Sends a response to the FIDL transaction.
6968    ///
6969    /// Sets the channel to shutdown if an error occurs.
6970    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
6971        let _result = self.send_raw(payload);
6972        if _result.is_err() {
6973            self.control_handle.shutdown();
6974        }
6975        self.drop_without_shutdown();
6976        _result
6977    }
6978
6979    /// Similar to "send" but does not shutdown the channel if an error occurs.
6980    pub fn send_no_shutdown_on_err(
6981        self,
6982        mut payload: NodeGetNodeRefResponse,
6983    ) -> Result<(), fidl::Error> {
6984        let _result = self.send_raw(payload);
6985        self.drop_without_shutdown();
6986        _result
6987    }
6988
6989    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
6990        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
6991            fidl::encoding::Flexible::new(&mut payload),
6992            self.tx_id,
6993            0x5b3d0e51614df053,
6994            fidl::encoding::DynamicFlags::FLEXIBLE,
6995        )
6996    }
6997}
6998
6999#[must_use = "FIDL methods require a response to be sent"]
7000#[derive(Debug)]
7001pub struct BufferCollectionTokenIsAlternateForResponder {
7002    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
7003    tx_id: u32,
7004}
7005
7006/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
7007/// if the responder is dropped without sending a response, so that the client
7008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7009impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
7010    fn drop(&mut self) {
7011        self.control_handle.shutdown();
7012        // Safety: drops once, never accessed again
7013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7014    }
7015}
7016
7017impl fdomain_client::fidl::Responder for BufferCollectionTokenIsAlternateForResponder {
7018    type ControlHandle = BufferCollectionTokenControlHandle;
7019
7020    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
7021        &self.control_handle
7022    }
7023
7024    fn drop_without_shutdown(mut self) {
7025        // Safety: drops once, never accessed again due to mem::forget
7026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7027        // Prevent Drop from running (which would shut down the channel)
7028        std::mem::forget(self);
7029    }
7030}
7031
7032impl BufferCollectionTokenIsAlternateForResponder {
7033    /// Sends a response to the FIDL transaction.
7034    ///
7035    /// Sets the channel to shutdown if an error occurs.
7036    pub fn send(
7037        self,
7038        mut result: Result<&NodeIsAlternateForResponse, Error>,
7039    ) -> Result<(), fidl::Error> {
7040        let _result = self.send_raw(result);
7041        if _result.is_err() {
7042            self.control_handle.shutdown();
7043        }
7044        self.drop_without_shutdown();
7045        _result
7046    }
7047
7048    /// Similar to "send" but does not shutdown the channel if an error occurs.
7049    pub fn send_no_shutdown_on_err(
7050        self,
7051        mut result: Result<&NodeIsAlternateForResponse, Error>,
7052    ) -> Result<(), fidl::Error> {
7053        let _result = self.send_raw(result);
7054        self.drop_without_shutdown();
7055        _result
7056    }
7057
7058    fn send_raw(
7059        &self,
7060        mut result: Result<&NodeIsAlternateForResponse, Error>,
7061    ) -> Result<(), fidl::Error> {
7062        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
7063            NodeIsAlternateForResponse,
7064            Error,
7065        >>(
7066            fidl::encoding::FlexibleResult::new(result),
7067            self.tx_id,
7068            0x3a58e00157e0825,
7069            fidl::encoding::DynamicFlags::FLEXIBLE,
7070        )
7071    }
7072}
7073
7074#[must_use = "FIDL methods require a response to be sent"]
7075#[derive(Debug)]
7076pub struct BufferCollectionTokenGetBufferCollectionIdResponder {
7077    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
7078    tx_id: u32,
7079}
7080
7081/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
7082/// if the responder is dropped without sending a response, so that the client
7083/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7084impl std::ops::Drop for BufferCollectionTokenGetBufferCollectionIdResponder {
7085    fn drop(&mut self) {
7086        self.control_handle.shutdown();
7087        // Safety: drops once, never accessed again
7088        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7089    }
7090}
7091
7092impl fdomain_client::fidl::Responder for BufferCollectionTokenGetBufferCollectionIdResponder {
7093    type ControlHandle = BufferCollectionTokenControlHandle;
7094
7095    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
7096        &self.control_handle
7097    }
7098
7099    fn drop_without_shutdown(mut self) {
7100        // Safety: drops once, never accessed again due to mem::forget
7101        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7102        // Prevent Drop from running (which would shut down the channel)
7103        std::mem::forget(self);
7104    }
7105}
7106
7107impl BufferCollectionTokenGetBufferCollectionIdResponder {
7108    /// Sends a response to the FIDL transaction.
7109    ///
7110    /// Sets the channel to shutdown if an error occurs.
7111    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
7112        let _result = self.send_raw(payload);
7113        if _result.is_err() {
7114            self.control_handle.shutdown();
7115        }
7116        self.drop_without_shutdown();
7117        _result
7118    }
7119
7120    /// Similar to "send" but does not shutdown the channel if an error occurs.
7121    pub fn send_no_shutdown_on_err(
7122        self,
7123        mut payload: &NodeGetBufferCollectionIdResponse,
7124    ) -> Result<(), fidl::Error> {
7125        let _result = self.send_raw(payload);
7126        self.drop_without_shutdown();
7127        _result
7128    }
7129
7130    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
7131        self.control_handle
7132            .inner
7133            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
7134                fidl::encoding::Flexible::new(payload),
7135                self.tx_id,
7136                0x77d19a494b78ba8c,
7137                fidl::encoding::DynamicFlags::FLEXIBLE,
7138            )
7139    }
7140}
7141
7142#[must_use = "FIDL methods require a response to be sent"]
7143#[derive(Debug)]
7144pub struct BufferCollectionTokenDuplicateSyncResponder {
7145    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
7146    tx_id: u32,
7147}
7148
7149/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
7150/// if the responder is dropped without sending a response, so that the client
7151/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7152impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
7153    fn drop(&mut self) {
7154        self.control_handle.shutdown();
7155        // Safety: drops once, never accessed again
7156        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7157    }
7158}
7159
7160impl fdomain_client::fidl::Responder for BufferCollectionTokenDuplicateSyncResponder {
7161    type ControlHandle = BufferCollectionTokenControlHandle;
7162
7163    fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
7164        &self.control_handle
7165    }
7166
7167    fn drop_without_shutdown(mut self) {
7168        // Safety: drops once, never accessed again due to mem::forget
7169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7170        // Prevent Drop from running (which would shut down the channel)
7171        std::mem::forget(self);
7172    }
7173}
7174
7175impl BufferCollectionTokenDuplicateSyncResponder {
7176    /// Sends a response to the FIDL transaction.
7177    ///
7178    /// Sets the channel to shutdown if an error occurs.
7179    pub fn send(
7180        self,
7181        mut payload: BufferCollectionTokenDuplicateSyncResponse,
7182    ) -> Result<(), fidl::Error> {
7183        let _result = self.send_raw(payload);
7184        if _result.is_err() {
7185            self.control_handle.shutdown();
7186        }
7187        self.drop_without_shutdown();
7188        _result
7189    }
7190
7191    /// Similar to "send" but does not shutdown the channel if an error occurs.
7192    pub fn send_no_shutdown_on_err(
7193        self,
7194        mut payload: BufferCollectionTokenDuplicateSyncResponse,
7195    ) -> Result<(), fidl::Error> {
7196        let _result = self.send_raw(payload);
7197        self.drop_without_shutdown();
7198        _result
7199    }
7200
7201    fn send_raw(
7202        &self,
7203        mut payload: BufferCollectionTokenDuplicateSyncResponse,
7204    ) -> Result<(), fidl::Error> {
7205        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
7206            BufferCollectionTokenDuplicateSyncResponse,
7207        >>(
7208            fidl::encoding::Flexible::new(&mut payload),
7209            self.tx_id,
7210            0x1c1af9919d1ca45c,
7211            fidl::encoding::DynamicFlags::FLEXIBLE,
7212        )
7213    }
7214}
7215
7216#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7217pub struct BufferCollectionTokenGroupMarker;
7218
7219impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenGroupMarker {
7220    type Proxy = BufferCollectionTokenGroupProxy;
7221    type RequestStream = BufferCollectionTokenGroupRequestStream;
7222
7223    const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
7224}
7225
7226pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
7227    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
7228    fn r#sync(&self) -> Self::SyncResponseFut;
7229    fn r#release(&self) -> Result<(), fidl::Error>;
7230    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
7231    fn r#set_debug_client_info(
7232        &self,
7233        payload: &NodeSetDebugClientInfoRequest,
7234    ) -> Result<(), fidl::Error>;
7235    fn r#set_debug_timeout_log_deadline(
7236        &self,
7237        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7238    ) -> Result<(), fidl::Error>;
7239    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
7240    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
7241        + Send;
7242    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
7243    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
7244        + Send;
7245    fn r#is_alternate_for(
7246        &self,
7247        payload: NodeIsAlternateForRequest,
7248    ) -> Self::IsAlternateForResponseFut;
7249    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
7250        + Send;
7251    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
7252    fn r#set_weak(&self) -> Result<(), fidl::Error>;
7253    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
7254    fn r#attach_node_tracking(
7255        &self,
7256        payload: NodeAttachNodeTrackingRequest,
7257    ) -> Result<(), fidl::Error>;
7258    fn r#create_child(
7259        &self,
7260        payload: BufferCollectionTokenGroupCreateChildRequest,
7261    ) -> Result<(), fidl::Error>;
7262    type CreateChildrenSyncResponseFut: std::future::Future<
7263            Output = Result<BufferCollectionTokenGroupCreateChildrenSyncResponse, fidl::Error>,
7264        > + Send;
7265    fn r#create_children_sync(
7266        &self,
7267        payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7268    ) -> Self::CreateChildrenSyncResponseFut;
7269    fn r#all_children_present(&self) -> Result<(), fidl::Error>;
7270}
7271
7272#[derive(Debug, Clone)]
7273pub struct BufferCollectionTokenGroupProxy {
7274    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
7275}
7276
7277impl fdomain_client::fidl::Proxy for BufferCollectionTokenGroupProxy {
7278    type Protocol = BufferCollectionTokenGroupMarker;
7279
7280    fn from_channel(inner: fdomain_client::Channel) -> Self {
7281        Self::new(inner)
7282    }
7283
7284    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
7285        self.client.into_channel().map_err(|client| Self { client })
7286    }
7287
7288    fn as_channel(&self) -> &fdomain_client::Channel {
7289        self.client.as_channel()
7290    }
7291}
7292
7293impl BufferCollectionTokenGroupProxy {
7294    /// Create a new Proxy for fuchsia.sysmem2/BufferCollectionTokenGroup.
7295    pub fn new(channel: fdomain_client::Channel) -> Self {
7296        let protocol_name =
7297            <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
7298        Self { client: fidl::client::Client::new(channel, protocol_name) }
7299    }
7300
7301    /// Get a Stream of events from the remote end of the protocol.
7302    ///
7303    /// # Panics
7304    ///
7305    /// Panics if the event stream was already taken.
7306    pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
7307        BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
7308    }
7309
7310    /// Ensure that previous messages have been received server side. This is
7311    /// particularly useful after previous messages that created new tokens,
7312    /// because a token must be known to the sysmem server before sending the
7313    /// token to another participant.
7314    ///
7315    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
7316    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
7317    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
7318    /// to mitigate the possibility of a hostile/fake
7319    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
7320    /// Another way is to pass the token to
7321    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
7322    /// the token as part of exchanging it for a
7323    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
7324    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
7325    /// of stalling.
7326    ///
7327    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
7328    /// and then starting and completing a `Sync`, it's then safe to send the
7329    /// `BufferCollectionToken` client ends to other participants knowing the
7330    /// server will recognize the tokens when they're sent by the other
7331    /// participants to sysmem in a
7332    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
7333    /// efficient way to create tokens while avoiding unnecessary round trips.
7334    ///
7335    /// Other options include waiting for each
7336    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
7337    /// individually (using separate call to `Sync` after each), or calling
7338    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
7339    /// converted to a `BufferCollection` via
7340    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
7341    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
7342    /// the sync step and can create multiple tokens at once.
7343    pub fn r#sync(
7344        &self,
7345    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
7346        BufferCollectionTokenGroupProxyInterface::r#sync(self)
7347    }
7348
7349    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
7350    ///
7351    /// Normally a participant will convert a `BufferCollectionToken` into a
7352    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
7353    /// `Release` via the token (and then close the channel immediately or
7354    /// shortly later in response to server closing the server end), which
7355    /// avoids causing buffer collection failure. Without a prior `Release`,
7356    /// closing the `BufferCollectionToken` client end will cause buffer
7357    /// collection failure.
7358    ///
7359    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
7360    ///
7361    /// By default the server handles unexpected closure of a
7362    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
7363    /// first) by failing the buffer collection. Partly this is to expedite
7364    /// closing VMO handles to reclaim memory when any participant fails. If a
7365    /// participant would like to cleanly close a `BufferCollection` without
7366    /// causing buffer collection failure, the participant can send `Release`
7367    /// before closing the `BufferCollection` client end. The `Release` can
7368    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
7369    /// buffer collection won't require constraints from this node in order to
7370    /// allocate. If after `SetConstraints`, the constraints are retained and
7371    /// aggregated, despite the lack of `BufferCollection` connection at the
7372    /// time of constraints aggregation.
7373    ///
7374    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
7375    ///
7376    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
7377    /// end (without `Release` first) will trigger failure of the buffer
7378    /// collection. To close a `BufferCollectionTokenGroup` channel without
7379    /// failing the buffer collection, ensure that AllChildrenPresent() has been
7380    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
7381    /// client end.
7382    ///
7383    /// If `Release` occurs before
7384    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
7385    /// buffer collection will fail (triggered by reception of `Release` without
7386    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
7387    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
7388    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
7389    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
7390    /// close requires `AllChildrenPresent` (if not already sent), then
7391    /// `Release`, then close client end.
7392    ///
7393    /// If `Release` occurs after `AllChildrenPresent`, the children and all
7394    /// their constraints remain intact (just as they would if the
7395    /// `BufferCollectionTokenGroup` channel had remained open), and the client
7396    /// end close doesn't trigger buffer collection failure.
7397    ///
7398    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
7399    ///
7400    /// For brevity, the per-channel-protocol paragraphs above ignore the
7401    /// separate failure domain created by
7402    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
7403    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
7404    /// unexpectedly closes (without `Release` first) and that client end is
7405    /// under a failure domain, instead of failing the whole buffer collection,
7406    /// the failure domain is failed, but the buffer collection itself is
7407    /// isolated from failure of the failure domain. Such failure domains can be
7408    /// nested, in which case only the inner-most failure domain in which the
7409    /// `Node` resides fails.
7410    pub fn r#release(&self) -> Result<(), fidl::Error> {
7411        BufferCollectionTokenGroupProxyInterface::r#release(self)
7412    }
7413
7414    /// Set a name for VMOs in this buffer collection.
7415    ///
7416    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
7417    /// will be truncated to fit. The name of the vmo will be suffixed with the
7418    /// buffer index within the collection (if the suffix fits within
7419    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
7420    /// listed in the inspect data.
7421    ///
7422    /// The name only affects VMOs allocated after the name is set; this call
7423    /// does not rename existing VMOs. If multiple clients set different names
7424    /// then the larger priority value will win. Setting a new name with the
7425    /// same priority as a prior name doesn't change the name.
7426    ///
7427    /// All table fields are currently required.
7428    ///
7429    /// + request `priority` The name is only set if this is the first `SetName`
7430    ///   or if `priority` is greater than any previous `priority` value in
7431    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
7432    /// + request `name` The name for VMOs created under this buffer collection.
7433    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
7434        BufferCollectionTokenGroupProxyInterface::r#set_name(self, payload)
7435    }
7436
7437    /// Set information about the current client that can be used by sysmem to
7438    /// help diagnose leaking memory and allocation stalls waiting for a
7439    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
7440    ///
7441    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
7442    /// `Node`(s) derived from this `Node`, unless overriden by
7443    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
7444    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
7445    ///
7446    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
7447    /// `Allocator` is the most efficient way to ensure that all
7448    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
7449    /// set, and is also more efficient than separately sending the same debug
7450    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
7451    /// created [`fuchsia.sysmem2/Node`].
7452    ///
7453    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
7454    /// indicate which client is closing their channel first, leading to subtree
7455    /// failure (which can be normal if the purpose of the subtree is over, but
7456    /// if happening earlier than expected, the client-channel-specific name can
7457    /// help diagnose where the failure is first coming from, from sysmem's
7458    /// point of view).
7459    ///
7460    /// All table fields are currently required.
7461    ///
7462    /// + request `name` This can be an arbitrary string, but the current
7463    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
7464    /// + request `id` This can be an arbitrary id, but the current process ID
7465    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
7466    pub fn r#set_debug_client_info(
7467        &self,
7468        mut payload: &NodeSetDebugClientInfoRequest,
7469    ) -> Result<(), fidl::Error> {
7470        BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, payload)
7471    }
7472
7473    /// Sysmem logs a warning if sysmem hasn't seen
7474    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
7475    /// within 5 seconds after creation of a new collection.
7476    ///
7477    /// Clients can call this method to change when the log is printed. If
7478    /// multiple client set the deadline, it's unspecified which deadline will
7479    /// take effect.
7480    ///
7481    /// In most cases the default works well.
7482    ///
7483    /// All table fields are currently required.
7484    ///
7485    /// + request `deadline` The time at which sysmem will start trying to log
7486    ///   the warning, unless all constraints are with sysmem by then.
7487    pub fn r#set_debug_timeout_log_deadline(
7488        &self,
7489        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7490    ) -> Result<(), fidl::Error> {
7491        BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
7492    }
7493
7494    /// This enables verbose logging for the buffer collection.
7495    ///
7496    /// Verbose logging includes constraints set via
7497    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
7498    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
7499    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
7500    /// the tree of `Node`(s).
7501    ///
7502    /// Normally sysmem prints only a single line complaint when aggregation
7503    /// fails, with just the specific detailed reason that aggregation failed,
7504    /// with little surrounding context.  While this is often enough to diagnose
7505    /// a problem if only a small change was made and everything was working
7506    /// before the small change, it's often not particularly helpful for getting
7507    /// a new buffer collection to work for the first time.  Especially with
7508    /// more complex trees of nodes, involving things like
7509    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
7510    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
7511    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
7512    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
7513    /// looks like and why it's failing a logical allocation, or why a tree or
7514    /// subtree is failing sooner than expected.
7515    ///
7516    /// The intent of the extra logging is to be acceptable from a performance
7517    /// point of view, under the assumption that verbose logging is only enabled
7518    /// on a low number of buffer collections. If we're not tracking down a bug,
7519    /// we shouldn't send this message.
7520    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7521        BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
7522    }
7523
7524    /// This gets a handle that can be used as a parameter to
7525    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
7526    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
7527    /// client obtained this handle from this `Node`.
7528    ///
7529    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
7530    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
7531    /// despite the two calls typically being on different channels.
7532    ///
7533    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
7534    ///
7535    /// All table fields are currently required.
7536    ///
7537    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
7538    ///   different `Node` channel, to prove that the client obtained the handle
7539    ///   from this `Node`.
7540    pub fn r#get_node_ref(
7541        &self,
7542    ) -> fidl::client::QueryResponseFut<
7543        NodeGetNodeRefResponse,
7544        fdomain_client::fidl::FDomainResourceDialect,
7545    > {
7546        BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
7547    }
7548
7549    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
7550    /// rooted at a different child token of a common parent
7551    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
7552    /// passed-in `node_ref`.
7553    ///
7554    /// This call is for assisting with admission control de-duplication, and
7555    /// with debugging.
7556    ///
7557    /// The `node_ref` must be obtained using
7558    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
7559    ///
7560    /// The `node_ref` can be a duplicated handle; it's not necessary to call
7561    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
7562    ///
7563    /// If a calling token may not actually be a valid token at all due to a
7564    /// potentially hostile/untrusted provider of the token, call
7565    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
7566    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
7567    /// never responds due to a calling token not being a real token (not really
7568    /// talking to sysmem).  Another option is to call
7569    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
7570    /// which also validates the token along with converting it to a
7571    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
7572    ///
7573    /// All table fields are currently required.
7574    ///
7575    /// - response `is_alternate`
7576    ///   - true: The first parent node in common between the calling node and
7577    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
7578    ///     that the calling `Node` and the `node_ref` `Node` will not have both
7579    ///     their constraints apply - rather sysmem will choose one or the other
7580    ///     of the constraints - never both.  This is because only one child of
7581    ///     a `BufferCollectionTokenGroup` is selected during logical
7582    ///     allocation, with only that one child's subtree contributing to
7583    ///     constraints aggregation.
7584    ///   - false: The first parent node in common between the calling `Node`
7585    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
7586    ///     Currently, this means the first parent node in common is a
7587    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
7588    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
7589    ///     `Node` may have both their constraints apply during constraints
7590    ///     aggregation of the logical allocation, if both `Node`(s) are
7591    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
7592    ///     this case, there is no `BufferCollectionTokenGroup` that will
7593    ///     directly prevent the two `Node`(s) from both being selected and
7594    ///     their constraints both aggregated, but even when false, one or both
7595    ///     `Node`(s) may still be eliminated from consideration if one or both
7596    ///     `Node`(s) has a direct or indirect parent
7597    ///     `BufferCollectionTokenGroup` which selects a child subtree other
7598    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
7599    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
7600    ///   associated with the same buffer collection as the calling `Node`.
7601    ///   Another reason for this error is if the `node_ref` is an
7602    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
7603    ///   a real `node_ref` obtained from `GetNodeRef`.
7604    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
7605    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
7606    ///   the needed rights expected on a real `node_ref`.
7607    /// * No other failing status codes are returned by this call.  However,
7608    ///   sysmem may add additional codes in future, so the client should have
7609    ///   sensible default handling for any failing status code.
7610    pub fn r#is_alternate_for(
7611        &self,
7612        mut payload: NodeIsAlternateForRequest,
7613    ) -> fidl::client::QueryResponseFut<
7614        NodeIsAlternateForResult,
7615        fdomain_client::fidl::FDomainResourceDialect,
7616    > {
7617        BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, payload)
7618    }
7619
7620    /// Get the buffer collection ID. This ID is also available from
7621    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
7622    /// within the collection).
7623    ///
7624    /// This call is mainly useful in situations where we can't convey a
7625    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
7626    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
7627    /// handle, which can be joined back up with a `BufferCollection` client end
7628    /// that was created via a different path. Prefer to convey a
7629    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
7630    ///
7631    /// Trusting a `buffer_collection_id` value from a source other than sysmem
7632    /// is analogous to trusting a koid value from a source other than zircon.
7633    /// Both should be avoided unless really necessary, and both require
7634    /// caution. In some situations it may be reasonable to refer to a
7635    /// pre-established `BufferCollection` by `buffer_collection_id` via a
7636    /// protocol for efficiency reasons, but an incoming value purporting to be
7637    /// a `buffer_collection_id` is not sufficient alone to justify granting the
7638    /// sender of the `buffer_collection_id` any capability. The sender must
7639    /// first prove to a receiver that the sender has/had a VMO or has/had a
7640    /// `BufferCollectionToken` to the same collection by sending a handle that
7641    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
7642    /// `buffer_collection_id` value. The receiver should take care to avoid
7643    /// assuming that a sender had a `BufferCollectionToken` in cases where the
7644    /// sender has only proven that the sender had a VMO.
7645    ///
7646    /// - response `buffer_collection_id` This ID is unique per buffer
7647    ///   collection per boot. Each buffer is uniquely identified by the
7648    ///   `buffer_collection_id` and `buffer_index` together.
7649    pub fn r#get_buffer_collection_id(
7650        &self,
7651    ) -> fidl::client::QueryResponseFut<
7652        NodeGetBufferCollectionIdResponse,
7653        fdomain_client::fidl::FDomainResourceDialect,
7654    > {
7655        BufferCollectionTokenGroupProxyInterface::r#get_buffer_collection_id(self)
7656    }
7657
7658    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
7659    /// created after this message to weak, which means that a client's `Node`
7660    /// client end (or a child created after this message) is not alone
7661    /// sufficient to keep allocated VMOs alive.
7662    ///
7663    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
7664    /// `close_weak_asap`.
7665    ///
7666    /// This message is only permitted before the `Node` becomes ready for
7667    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
7668    ///   * `BufferCollectionToken`: any time
7669    ///   * `BufferCollection`: before `SetConstraints`
7670    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
7671    ///
7672    /// Currently, no conversion from strong `Node` to weak `Node` after ready
7673    /// for allocation is provided, but a client can simulate that by creating
7674    /// an additional `Node` before allocation and setting that additional
7675    /// `Node` to weak, and then potentially at some point later sending
7676    /// `Release` and closing the client end of the client's strong `Node`, but
7677    /// keeping the client's weak `Node`.
7678    ///
7679    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
7680    /// collection failure (all `Node` client end(s) will see
7681    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
7682    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
7683    /// this situation until all `Node`(s) are ready for allocation. For initial
7684    /// allocation to succeed, at least one strong `Node` is required to exist
7685    /// at allocation time, but after that client receives VMO handles, that
7686    /// client can `BufferCollection.Release` and close the client end without
7687    /// causing this type of failure.
7688    ///
7689    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
7690    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
7691    /// separately as appropriate.
7692    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
7693        BufferCollectionTokenGroupProxyInterface::r#set_weak(self)
7694    }
7695
7696    /// This indicates to sysmem that the client is prepared to pay attention to
7697    /// `close_weak_asap`.
7698    ///
7699    /// If sent, this message must be before
7700    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
7701    ///
7702    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
7703    /// send this message before `WaitForAllBuffersAllocated`, or a parent
7704    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
7705    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
7706    /// trigger buffer collection failure.
7707    ///
7708    /// This message is necessary because weak sysmem VMOs have not always been
7709    /// a thing, so older clients are not aware of the need to pay attention to
7710    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
7711    /// sysmem weak VMO handles asap. By having this message and requiring
7712    /// participants to indicate their acceptance of this aspect of the overall
7713    /// protocol, we avoid situations where an older client is delivered a weak
7714    /// VMO without any way for sysmem to get that VMO to close quickly later
7715    /// (and on a per-buffer basis).
7716    ///
7717    /// A participant that doesn't handle `close_weak_asap` and also doesn't
7718    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
7719    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
7720    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
7721    /// same participant has a child/delegate which does retrieve VMOs, that
7722    /// child/delegate will need to send `SetWeakOk` before
7723    /// `WaitForAllBuffersAllocated`.
7724    ///
7725    /// + request `for_child_nodes_also` If present and true, this means direct
7726    ///   child nodes of this node created after this message plus all
7727    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
7728    ///   those nodes. Any child node of this node that was created before this
7729    ///   message is not included. This setting is "sticky" in the sense that a
7730    ///   subsequent `SetWeakOk` without this bool set to true does not reset
7731    ///   the server-side bool. If this creates a problem for a participant, a
7732    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
7733    ///   tokens instead, as appropriate. A participant should only set
7734    ///   `for_child_nodes_also` true if the participant can really promise to
7735    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
7736    ///   weak VMO handles held by participants holding the corresponding child
7737    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
7738    ///   which are using sysmem(1) can be weak, despite the clients of those
7739    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
7740    ///   direct way to find out about `close_weak_asap`. This only applies to
7741    ///   descendents of this `Node` which are using sysmem(1), not to this
7742    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
7743    ///   token, which will fail allocation unless an ancestor of this `Node`
7744    ///   specified `for_child_nodes_also` true.
7745    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
7746        BufferCollectionTokenGroupProxyInterface::r#set_weak_ok(self, payload)
7747    }
7748
7749    /// The server_end will be closed after this `Node` and any child nodes have
7750    /// have released their buffer counts, making those counts available for
7751    /// reservation by a different `Node` via
7752    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
7753    ///
7754    /// The `Node` buffer counts may not be released until the entire tree of
7755    /// `Node`(s) is closed or failed, because
7756    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
7757    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
7758    /// `Node` buffer counts remain reserved until the orphaned node is later
7759    /// cleaned up.
7760    ///
7761    /// If the `Node` exceeds a fairly large number of attached eventpair server
7762    /// ends, a log message will indicate this and the `Node` (and the
7763    /// appropriate) sub-tree will fail.
7764    ///
7765    /// The `server_end` will remain open when
7766    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
7767    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
7768    /// [`fuchsia.sysmem2/BufferCollection`].
7769    ///
7770    /// This message can also be used with a
7771    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
7772    pub fn r#attach_node_tracking(
7773        &self,
7774        mut payload: NodeAttachNodeTrackingRequest,
7775    ) -> Result<(), fidl::Error> {
7776        BufferCollectionTokenGroupProxyInterface::r#attach_node_tracking(self, payload)
7777    }
7778
7779    /// Create a child [`fuchsia.sysmem2/BufferCollectionToken`]. Only one child
7780    /// (including its children) will be selected during allocation (or logical
7781    /// allocation).
7782    ///
7783    /// Before passing the client end of this token to
7784    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], completion of
7785    /// [`fuchsia.sysmem2/Node.Sync`] after
7786    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] is required.
7787    /// Or the client can use
7788    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`] which
7789    /// essentially includes the `Sync`.
7790    ///
7791    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
7792    /// fail the group's subtree and close the connection.
7793    ///
7794    /// After all children have been created, send AllChildrenPresent.
7795    ///
7796    /// + request `token_request` The server end of the new token channel.
7797    /// + request `rights_attenuation_mask` If ZX_RIGHT_SAME_RIGHTS, the created
7798    ///   token allows the holder to get the same rights to buffers as the
7799    ///   parent token (of the group) had. When the value isn't
7800    ///   ZX_RIGHT_SAME_RIGHTS, the value is interpretted as a bitmask with 0
7801    ///   bits ensuring those rights are attentuated, so 0xFFFFFFFF is a synonym
7802    ///   for ZX_RIGHT_SAME_RIGHTS. The value 0 is not allowed and intentionally
7803    ///   causes subtree failure.
7804    pub fn r#create_child(
7805        &self,
7806        mut payload: BufferCollectionTokenGroupCreateChildRequest,
7807    ) -> Result<(), fidl::Error> {
7808        BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
7809    }
7810
7811    /// Create 1 or more child tokens at once, synchronously.  In contrast to
7812    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`], no
7813    /// [`fuchsia.sysmem2/Node.Sync`] is required before passing the client end
7814    /// of a returned token to
7815    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`].
7816    ///
7817    /// The lower-index child tokens are higher priority (attempted sooner) than
7818    /// higher-index child tokens.
7819    ///
7820    /// As per all child tokens, successful aggregation will choose exactly one
7821    /// child among all created children (across all children created across
7822    /// potentially multiple calls to
7823    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] and
7824    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`]).
7825    ///
7826    /// The maximum permissible total number of children per group, and total
7827    /// number of nodes in an overall tree (from the root) are capped to limits
7828    /// which are not configurable via these protocols.
7829    ///
7830    /// Sending CreateChildrenSync after AllChildrenPresent is not permitted;
7831    /// this will fail the group's subtree and close the connection.
7832    ///
7833    /// After all children have been created, send AllChildrenPresent.
7834    ///
7835    /// + request `rights_attentuation_masks` The size of the
7836    ///   `rights_attentuation_masks` determines the number of created child
7837    ///   tokens. The value ZX_RIGHT_SAME_RIGHTS doesn't attenuate any rights.
7838    ///   The value 0xFFFFFFFF is a synonym for ZX_RIGHT_SAME_RIGHTS. For any
7839    ///   other value, each 0 bit in the mask attenuates that right.
7840    /// - response `tokens` The created child tokens.
7841    pub fn r#create_children_sync(
7842        &self,
7843        mut payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
7844    ) -> fidl::client::QueryResponseFut<
7845        BufferCollectionTokenGroupCreateChildrenSyncResponse,
7846        fdomain_client::fidl::FDomainResourceDialect,
7847    > {
7848        BufferCollectionTokenGroupProxyInterface::r#create_children_sync(self, payload)
7849    }
7850
7851    /// Indicate that no more children will be created.
7852    ///
7853    /// After creating all children, the client should send
7854    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent`] to
7855    /// inform sysmem that no more children will be created, so that sysmem can
7856    /// know when it's ok to start aggregating constraints.
7857    ///
7858    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
7859    /// fail the group's subtree and close the connection.
7860    ///
7861    /// If [`fuchsia.sysmem2/Node.Release`] is to be sent, it should be sent
7862    /// after `AllChildrenPresent`, else failure of the group's subtree will be
7863    /// triggered. This is intentionally not analogous to how `Release` without
7864    /// prior [`fuchsia.sysmem2/BufferCollection.SetConstraints`] doesn't cause
7865    /// subtree failure.
7866    pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
7867        BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
7868    }
7869}
7870
7871impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
7872    type SyncResponseFut =
7873        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7874    fn r#sync(&self) -> Self::SyncResponseFut {
7875        fn _decode(
7876            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7877        ) -> Result<(), fidl::Error> {
7878            let _response = fidl::client::decode_transaction_body::<
7879                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
7880                fdomain_client::fidl::FDomainResourceDialect,
7881                0x11ac2555cf575b54,
7882            >(_buf?)?
7883            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("sync")?;
7884            Ok(_response)
7885        }
7886        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7887            (),
7888            0x11ac2555cf575b54,
7889            fidl::encoding::DynamicFlags::FLEXIBLE,
7890            _decode,
7891        )
7892    }
7893
7894    fn r#release(&self) -> Result<(), fidl::Error> {
7895        self.client.send::<fidl::encoding::EmptyPayload>(
7896            (),
7897            0x6a5cae7d6d6e04c6,
7898            fidl::encoding::DynamicFlags::FLEXIBLE,
7899        )
7900    }
7901
7902    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
7903        self.client.send::<NodeSetNameRequest>(
7904            payload,
7905            0xb41f1624f48c1e9,
7906            fidl::encoding::DynamicFlags::FLEXIBLE,
7907        )
7908    }
7909
7910    fn r#set_debug_client_info(
7911        &self,
7912        mut payload: &NodeSetDebugClientInfoRequest,
7913    ) -> Result<(), fidl::Error> {
7914        self.client.send::<NodeSetDebugClientInfoRequest>(
7915            payload,
7916            0x5cde8914608d99b1,
7917            fidl::encoding::DynamicFlags::FLEXIBLE,
7918        )
7919    }
7920
7921    fn r#set_debug_timeout_log_deadline(
7922        &self,
7923        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
7924    ) -> Result<(), fidl::Error> {
7925        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7926            payload,
7927            0x716b0af13d5c0806,
7928            fidl::encoding::DynamicFlags::FLEXIBLE,
7929        )
7930    }
7931
7932    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7933        self.client.send::<fidl::encoding::EmptyPayload>(
7934            (),
7935            0x5209c77415b4dfad,
7936            fidl::encoding::DynamicFlags::FLEXIBLE,
7937        )
7938    }
7939
7940    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
7941        NodeGetNodeRefResponse,
7942        fdomain_client::fidl::FDomainResourceDialect,
7943    >;
7944    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7945        fn _decode(
7946            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7947        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
7948            let _response = fidl::client::decode_transaction_body::<
7949                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
7950                fdomain_client::fidl::FDomainResourceDialect,
7951                0x5b3d0e51614df053,
7952            >(_buf?)?
7953            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("get_node_ref")?;
7954            Ok(_response)
7955        }
7956        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
7957            (),
7958            0x5b3d0e51614df053,
7959            fidl::encoding::DynamicFlags::FLEXIBLE,
7960            _decode,
7961        )
7962    }
7963
7964    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7965        NodeIsAlternateForResult,
7966        fdomain_client::fidl::FDomainResourceDialect,
7967    >;
7968    fn r#is_alternate_for(
7969        &self,
7970        mut payload: NodeIsAlternateForRequest,
7971    ) -> Self::IsAlternateForResponseFut {
7972        fn _decode(
7973            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7974        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7975            let _response = fidl::client::decode_transaction_body::<
7976                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
7977                fdomain_client::fidl::FDomainResourceDialect,
7978                0x3a58e00157e0825,
7979            >(_buf?)?
7980            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("is_alternate_for")?;
7981            Ok(_response.map(|x| x))
7982        }
7983        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7984            &mut payload,
7985            0x3a58e00157e0825,
7986            fidl::encoding::DynamicFlags::FLEXIBLE,
7987            _decode,
7988        )
7989    }
7990
7991    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
7992        NodeGetBufferCollectionIdResponse,
7993        fdomain_client::fidl::FDomainResourceDialect,
7994    >;
7995    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
7996        fn _decode(
7997            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7998        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
7999            let _response = fidl::client::decode_transaction_body::<
8000                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
8001                fdomain_client::fidl::FDomainResourceDialect,
8002                0x77d19a494b78ba8c,
8003            >(_buf?)?
8004            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("get_buffer_collection_id")?;
8005            Ok(_response)
8006        }
8007        self.client.send_query_and_decode::<
8008            fidl::encoding::EmptyPayload,
8009            NodeGetBufferCollectionIdResponse,
8010        >(
8011            (),
8012            0x77d19a494b78ba8c,
8013            fidl::encoding::DynamicFlags::FLEXIBLE,
8014            _decode,
8015        )
8016    }
8017
8018    fn r#set_weak(&self) -> Result<(), fidl::Error> {
8019        self.client.send::<fidl::encoding::EmptyPayload>(
8020            (),
8021            0x22dd3ea514eeffe1,
8022            fidl::encoding::DynamicFlags::FLEXIBLE,
8023        )
8024    }
8025
8026    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
8027        self.client.send::<NodeSetWeakOkRequest>(
8028            &mut payload,
8029            0x38a44fc4d7724be9,
8030            fidl::encoding::DynamicFlags::FLEXIBLE,
8031        )
8032    }
8033
8034    fn r#attach_node_tracking(
8035        &self,
8036        mut payload: NodeAttachNodeTrackingRequest,
8037    ) -> Result<(), fidl::Error> {
8038        self.client.send::<NodeAttachNodeTrackingRequest>(
8039            &mut payload,
8040            0x3f22f2a293d3cdac,
8041            fidl::encoding::DynamicFlags::FLEXIBLE,
8042        )
8043    }
8044
8045    fn r#create_child(
8046        &self,
8047        mut payload: BufferCollectionTokenGroupCreateChildRequest,
8048    ) -> Result<(), fidl::Error> {
8049        self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
8050            &mut payload,
8051            0x41a0075d419f30c5,
8052            fidl::encoding::DynamicFlags::FLEXIBLE,
8053        )
8054    }
8055
8056    type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
8057        BufferCollectionTokenGroupCreateChildrenSyncResponse,
8058        fdomain_client::fidl::FDomainResourceDialect,
8059    >;
8060    fn r#create_children_sync(
8061        &self,
8062        mut payload: &BufferCollectionTokenGroupCreateChildrenSyncRequest,
8063    ) -> Self::CreateChildrenSyncResponseFut {
8064        fn _decode(
8065            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8066        ) -> Result<BufferCollectionTokenGroupCreateChildrenSyncResponse, fidl::Error> {
8067            let _response = fidl::client::decode_transaction_body::<
8068                fidl::encoding::FlexibleType<BufferCollectionTokenGroupCreateChildrenSyncResponse>,
8069                fdomain_client::fidl::FDomainResourceDialect,
8070                0x15dea448c536070a,
8071            >(_buf?)?
8072            .into_result_fdomain::<BufferCollectionTokenGroupMarker>("create_children_sync")?;
8073            Ok(_response)
8074        }
8075        self.client.send_query_and_decode::<
8076            BufferCollectionTokenGroupCreateChildrenSyncRequest,
8077            BufferCollectionTokenGroupCreateChildrenSyncResponse,
8078        >(
8079            payload,
8080            0x15dea448c536070a,
8081            fidl::encoding::DynamicFlags::FLEXIBLE,
8082            _decode,
8083        )
8084    }
8085
8086    fn r#all_children_present(&self) -> Result<(), fidl::Error> {
8087        self.client.send::<fidl::encoding::EmptyPayload>(
8088            (),
8089            0x5c327e4a23391312,
8090            fidl::encoding::DynamicFlags::FLEXIBLE,
8091        )
8092    }
8093}
8094
8095pub struct BufferCollectionTokenGroupEventStream {
8096    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
8097}
8098
8099impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
8100
8101impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
8102    fn is_terminated(&self) -> bool {
8103        self.event_receiver.is_terminated()
8104    }
8105}
8106
8107impl futures::Stream for BufferCollectionTokenGroupEventStream {
8108    type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
8109
8110    fn poll_next(
8111        mut self: std::pin::Pin<&mut Self>,
8112        cx: &mut std::task::Context<'_>,
8113    ) -> std::task::Poll<Option<Self::Item>> {
8114        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8115            &mut self.event_receiver,
8116            cx
8117        )?) {
8118            Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
8119            None => std::task::Poll::Ready(None),
8120        }
8121    }
8122}
8123
8124#[derive(Debug)]
8125pub enum BufferCollectionTokenGroupEvent {
8126    #[non_exhaustive]
8127    _UnknownEvent {
8128        /// Ordinal of the event that was sent.
8129        ordinal: u64,
8130    },
8131}
8132
8133impl BufferCollectionTokenGroupEvent {
8134    /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
8135    fn decode(
8136        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8137    ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
8138        let (bytes, _handles) = buf.split_mut();
8139        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8140        debug_assert_eq!(tx_header.tx_id, 0);
8141        match tx_header.ordinal {
8142            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8143                Ok(BufferCollectionTokenGroupEvent::_UnknownEvent {
8144                    ordinal: tx_header.ordinal,
8145                })
8146            }
8147            _ => Err(fidl::Error::UnknownOrdinal {
8148                ordinal: tx_header.ordinal,
8149                protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8150            })
8151        }
8152    }
8153}
8154
8155/// A Stream of incoming requests for fuchsia.sysmem2/BufferCollectionTokenGroup.
8156pub struct BufferCollectionTokenGroupRequestStream {
8157    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8158    is_terminated: bool,
8159}
8160
8161impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
8162
8163impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
8164    fn is_terminated(&self) -> bool {
8165        self.is_terminated
8166    }
8167}
8168
8169impl fdomain_client::fidl::RequestStream for BufferCollectionTokenGroupRequestStream {
8170    type Protocol = BufferCollectionTokenGroupMarker;
8171    type ControlHandle = BufferCollectionTokenGroupControlHandle;
8172
8173    fn from_channel(channel: fdomain_client::Channel) -> Self {
8174        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8175    }
8176
8177    fn control_handle(&self) -> Self::ControlHandle {
8178        BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
8179    }
8180
8181    fn into_inner(
8182        self,
8183    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
8184    {
8185        (self.inner, self.is_terminated)
8186    }
8187
8188    fn from_inner(
8189        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8190        is_terminated: bool,
8191    ) -> Self {
8192        Self { inner, is_terminated }
8193    }
8194}
8195
8196impl futures::Stream for BufferCollectionTokenGroupRequestStream {
8197    type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
8198
8199    fn poll_next(
8200        mut self: std::pin::Pin<&mut Self>,
8201        cx: &mut std::task::Context<'_>,
8202    ) -> std::task::Poll<Option<Self::Item>> {
8203        let this = &mut *self;
8204        if this.inner.check_shutdown(cx) {
8205            this.is_terminated = true;
8206            return std::task::Poll::Ready(None);
8207        }
8208        if this.is_terminated {
8209            panic!("polled BufferCollectionTokenGroupRequestStream after completion");
8210        }
8211        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
8212            |bytes, handles| {
8213                match this.inner.channel().read_etc(cx, bytes, handles) {
8214                    std::task::Poll::Ready(Ok(())) => {}
8215                    std::task::Poll::Pending => return std::task::Poll::Pending,
8216                    std::task::Poll::Ready(Err(None)) => {
8217                        this.is_terminated = true;
8218                        return std::task::Poll::Ready(None);
8219                    }
8220                    std::task::Poll::Ready(Err(Some(e))) => {
8221                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8222                            e.into(),
8223                        ))));
8224                    }
8225                }
8226
8227                // A message has been received from the channel
8228                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8229
8230                std::task::Poll::Ready(Some(match header.ordinal {
8231                0x11ac2555cf575b54 => {
8232                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8233                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8234                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8235                    let control_handle = BufferCollectionTokenGroupControlHandle {
8236                        inner: this.inner.clone(),
8237                    };
8238                    Ok(BufferCollectionTokenGroupRequest::Sync {
8239                        responder: BufferCollectionTokenGroupSyncResponder {
8240                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8241                            tx_id: header.tx_id,
8242                        },
8243                    })
8244                }
8245                0x6a5cae7d6d6e04c6 => {
8246                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8247                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8248                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8249                    let control_handle = BufferCollectionTokenGroupControlHandle {
8250                        inner: this.inner.clone(),
8251                    };
8252                    Ok(BufferCollectionTokenGroupRequest::Release {
8253                        control_handle,
8254                    })
8255                }
8256                0xb41f1624f48c1e9 => {
8257                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8258                    let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
8259                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
8260                    let control_handle = BufferCollectionTokenGroupControlHandle {
8261                        inner: this.inner.clone(),
8262                    };
8263                    Ok(BufferCollectionTokenGroupRequest::SetName {payload: req,
8264                        control_handle,
8265                    })
8266                }
8267                0x5cde8914608d99b1 => {
8268                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8269                    let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
8270                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
8271                    let control_handle = BufferCollectionTokenGroupControlHandle {
8272                        inner: this.inner.clone(),
8273                    };
8274                    Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {payload: req,
8275                        control_handle,
8276                    })
8277                }
8278                0x716b0af13d5c0806 => {
8279                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8280                    let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
8281                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
8282                    let control_handle = BufferCollectionTokenGroupControlHandle {
8283                        inner: this.inner.clone(),
8284                    };
8285                    Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {payload: req,
8286                        control_handle,
8287                    })
8288                }
8289                0x5209c77415b4dfad => {
8290                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8291                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8292                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8293                    let control_handle = BufferCollectionTokenGroupControlHandle {
8294                        inner: this.inner.clone(),
8295                    };
8296                    Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
8297                        control_handle,
8298                    })
8299                }
8300                0x5b3d0e51614df053 => {
8301                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8302                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8303                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8304                    let control_handle = BufferCollectionTokenGroupControlHandle {
8305                        inner: this.inner.clone(),
8306                    };
8307                    Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
8308                        responder: BufferCollectionTokenGroupGetNodeRefResponder {
8309                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8310                            tx_id: header.tx_id,
8311                        },
8312                    })
8313                }
8314                0x3a58e00157e0825 => {
8315                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8316                    let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
8317                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
8318                    let control_handle = BufferCollectionTokenGroupControlHandle {
8319                        inner: this.inner.clone(),
8320                    };
8321                    Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {payload: req,
8322                        responder: BufferCollectionTokenGroupIsAlternateForResponder {
8323                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8324                            tx_id: header.tx_id,
8325                        },
8326                    })
8327                }
8328                0x77d19a494b78ba8c => {
8329                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8330                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8331                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8332                    let control_handle = BufferCollectionTokenGroupControlHandle {
8333                        inner: this.inner.clone(),
8334                    };
8335                    Ok(BufferCollectionTokenGroupRequest::GetBufferCollectionId {
8336                        responder: BufferCollectionTokenGroupGetBufferCollectionIdResponder {
8337                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8338                            tx_id: header.tx_id,
8339                        },
8340                    })
8341                }
8342                0x22dd3ea514eeffe1 => {
8343                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8344                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8345                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8346                    let control_handle = BufferCollectionTokenGroupControlHandle {
8347                        inner: this.inner.clone(),
8348                    };
8349                    Ok(BufferCollectionTokenGroupRequest::SetWeak {
8350                        control_handle,
8351                    })
8352                }
8353                0x38a44fc4d7724be9 => {
8354                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8355                    let mut req = fidl::new_empty!(NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect);
8356                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
8357                    let control_handle = BufferCollectionTokenGroupControlHandle {
8358                        inner: this.inner.clone(),
8359                    };
8360                    Ok(BufferCollectionTokenGroupRequest::SetWeakOk {payload: req,
8361                        control_handle,
8362                    })
8363                }
8364                0x3f22f2a293d3cdac => {
8365                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8366                    let mut req = fidl::new_empty!(NodeAttachNodeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
8367                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
8368                    let control_handle = BufferCollectionTokenGroupControlHandle {
8369                        inner: this.inner.clone(),
8370                    };
8371                    Ok(BufferCollectionTokenGroupRequest::AttachNodeTracking {payload: req,
8372                        control_handle,
8373                    })
8374                }
8375                0x41a0075d419f30c5 => {
8376                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8377                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fdomain_client::fidl::FDomainResourceDialect);
8378                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
8379                    let control_handle = BufferCollectionTokenGroupControlHandle {
8380                        inner: this.inner.clone(),
8381                    };
8382                    Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
8383                        control_handle,
8384                    })
8385                }
8386                0x15dea448c536070a => {
8387                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8388                    let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
8389                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
8390                    let control_handle = BufferCollectionTokenGroupControlHandle {
8391                        inner: this.inner.clone(),
8392                    };
8393                    Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {payload: req,
8394                        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
8395                            control_handle: std::mem::ManuallyDrop::new(control_handle),
8396                            tx_id: header.tx_id,
8397                        },
8398                    })
8399                }
8400                0x5c327e4a23391312 => {
8401                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8402                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8403                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8404                    let control_handle = BufferCollectionTokenGroupControlHandle {
8405                        inner: this.inner.clone(),
8406                    };
8407                    Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
8408                        control_handle,
8409                    })
8410                }
8411                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8412                    Ok(BufferCollectionTokenGroupRequest::_UnknownMethod {
8413                        ordinal: header.ordinal,
8414                        control_handle: BufferCollectionTokenGroupControlHandle { inner: this.inner.clone() },
8415                        method_type: fidl::MethodType::OneWay,
8416                    })
8417                }
8418                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8419                    this.inner.send_framework_err(
8420                        fidl::encoding::FrameworkErr::UnknownMethod,
8421                        header.tx_id,
8422                        header.ordinal,
8423                        header.dynamic_flags(),
8424                        (bytes, handles),
8425                    )?;
8426                    Ok(BufferCollectionTokenGroupRequest::_UnknownMethod {
8427                        ordinal: header.ordinal,
8428                        control_handle: BufferCollectionTokenGroupControlHandle { inner: this.inner.clone() },
8429                        method_type: fidl::MethodType::TwoWay,
8430                    })
8431                }
8432                _ => Err(fidl::Error::UnknownOrdinal {
8433                    ordinal: header.ordinal,
8434                    protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8435                }),
8436            }))
8437            },
8438        )
8439    }
8440}
8441
8442/// The sysmem implementation is consistent with a logical / conceptual model of
8443/// allocation / logical allocation as follows:
8444///
8445/// As usual, a logical allocation considers either the root and all nodes with
8446/// connectivity to the root that don't transit a [`fuchsia.sysmem2/Node`]
8447/// created with [`fuchsia.sysmem2/BufferCollection.AttachToken`], or a subtree
8448/// rooted at an `AttachToken` `Node` and all `Node`(s) with connectivity to
8449/// that subtree that don't transit another `AttachToken`.  This is called the
8450/// logical allocation pruned subtree, or pruned subtree for short.
8451///
8452/// During constraints aggregation, each
8453/// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] will select a single child
8454/// `Node` among its direct children. The rest of the children will appear to
8455/// fail the logical allocation, while the selected child may succeed.
8456///
8457/// When more than one `BufferCollectionTokenGroup` exists in the overall
8458/// logical allocation pruned subtree, the relative priority between two groups
8459/// is equivalent to their ordering in a DFS pre-order iteration of the tree,
8460/// with parents higher priority than children, and left children higher
8461/// priority than right children.
8462///
8463/// When a particular child of a group is selected (whether provisionally during
8464/// a constraints aggregation attempt, or as a final selection), the
8465/// non-selection of other children of the group will "hide" any other groups
8466/// under those non-selected children.
8467///
8468/// Within a logical allocation, aggregation is attempted first by provisionally
8469/// selecting child 0 of the highest-priority group, and child 0 of the next
8470/// highest-priority group that isn't hidden by the provisional selections so
8471/// far, etc.
8472///
8473/// If that aggregation attempt fails, aggregation will be attempted with the
8474/// ordinal 0 child of all the same groups except the lowest priority non-hidden
8475/// group which will provisionally select its ordinal 1 child (and then child 2
8476/// and so on). If a new lowest-priority group is un-hidden as provisional
8477/// selections are updated, that newly un-hidden lowest-priority group has all
8478/// its children considered in order, before changing the provisional selection
8479/// in the former lowest-priority group. In terms of result, this is equivalent
8480/// to systematic enumeration of all possible combinations of choices in a
8481/// counting-like order updating the lowest-priority group the most often and
8482/// the highest-priority group the least often. Rather than actually attempting
8483/// aggregation with all the combinations, we can skip over combinations which
8484/// are redundant/equivalent due to hiding without any change to the result.
8485///
8486/// Attempted constraint aggregations of enumerated non-equivalent combinations
8487/// of choices continue in this manner until either (a) all aggregation attempts
8488/// fail in which case the overall logical allocation fails, or (b) until an
8489/// attempted aggregation succeeds, in which case buffer allocation (if needed;
8490/// if this is the pruned subtree rooted at the overall root `Node`) is
8491/// attempted once. If buffer allocation based on the first successful
8492/// constraints aggregation fails, the overall logical allocation fails (there
8493/// is no buffer allocation retry / re-attempt). If buffer allocation succeeds
8494/// (or is not needed due to being a pruned subtree that doesn't include the
8495/// root), the logical allocation succeeds.
8496///
8497/// If this prioritization scheme cannot reasonably work for your usage of
8498/// sysmem, please don't hesitate to contact sysmem folks to discuss potentially
8499/// adding a way to achieve what you need.
8500///
8501/// Please avoid creating a large number of `BufferCollectionTokenGroup`(s) per
8502/// logical allocation, especially with large number of children overall, and
8503/// especially in cases where aggregation may reasonably be expected to often
8504/// fail using ordinal 0 children and possibly with later children as well.
8505/// Sysmem mitigates potentially high time complexity of evaluating too many
8506/// child combinations/selections across too many groups by simply failing
8507/// logical allocation beyond a certain (fairly high, but not huge) max number
8508/// of considered group child combinations/selections. More advanced (and more
8509/// complicated) mitigation is not anticipated to be practically necessary or
8510/// worth the added complexity. Please contact sysmem folks if the max limit is
8511/// getting hit or if you anticipate it getting hit, to discuss potential
8512/// options.
8513///
8514/// Prefer to use multiple [`fuchsia.sysmem2/ImageFormatConstraints`] in a
8515/// single [`fuchsia.sysmem2/BufferCollectionConstraints`] when feasible (when a
8516/// participant just needs to express the ability to work with more than a
8517/// single [`fuchsia.images2/PixelFormat`], with sysmem choosing which
8518/// `PixelFormat` to use among those supported by all participants).
8519///
8520/// Similar to [`fuchsia.sysmem2/BufferCollectionToken`] and
8521/// [`fuchsia.sysmem2/BufferCollection`], closure of the
8522/// `BufferCollectionTokenGroup` channel without sending
8523/// [`fuchsia.sysmem2/Node.Release`] first will cause buffer collection failure
8524/// (or subtree failure if using
8525/// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
8526/// [`fuchsia.sysmem2/BufferCollection.AttachToken`] and the
8527/// `BufferCollectionTokenGroup` is part of a subtree under such a node that
8528/// doesn't propagate failure to its parent).
8529///
8530/// Epitaphs are not used in this protocol.
8531#[derive(Debug)]
8532pub enum BufferCollectionTokenGroupRequest {
8533    /// Ensure that previous messages have been received server side. This is
8534    /// particularly useful after previous messages that created new tokens,
8535    /// because a token must be known to the sysmem server before sending the
8536    /// token to another participant.
8537    ///
8538    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
8539    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
8540    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
8541    /// to mitigate the possibility of a hostile/fake
8542    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
8543    /// Another way is to pass the token to
8544    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
8545    /// the token as part of exchanging it for a
8546    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
8547    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
8548    /// of stalling.
8549    ///
8550    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
8551    /// and then starting and completing a `Sync`, it's then safe to send the
8552    /// `BufferCollectionToken` client ends to other participants knowing the
8553    /// server will recognize the tokens when they're sent by the other
8554    /// participants to sysmem in a
8555    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
8556    /// efficient way to create tokens while avoiding unnecessary round trips.
8557    ///
8558    /// Other options include waiting for each
8559    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
8560    /// individually (using separate call to `Sync` after each), or calling
8561    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
8562    /// converted to a `BufferCollection` via
8563    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
8564    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
8565    /// the sync step and can create multiple tokens at once.
8566    Sync { responder: BufferCollectionTokenGroupSyncResponder },
8567    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
8568    ///
8569    /// Normally a participant will convert a `BufferCollectionToken` into a
8570    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
8571    /// `Release` via the token (and then close the channel immediately or
8572    /// shortly later in response to server closing the server end), which
8573    /// avoids causing buffer collection failure. Without a prior `Release`,
8574    /// closing the `BufferCollectionToken` client end will cause buffer
8575    /// collection failure.
8576    ///
8577    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
8578    ///
8579    /// By default the server handles unexpected closure of a
8580    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
8581    /// first) by failing the buffer collection. Partly this is to expedite
8582    /// closing VMO handles to reclaim memory when any participant fails. If a
8583    /// participant would like to cleanly close a `BufferCollection` without
8584    /// causing buffer collection failure, the participant can send `Release`
8585    /// before closing the `BufferCollection` client end. The `Release` can
8586    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
8587    /// buffer collection won't require constraints from this node in order to
8588    /// allocate. If after `SetConstraints`, the constraints are retained and
8589    /// aggregated, despite the lack of `BufferCollection` connection at the
8590    /// time of constraints aggregation.
8591    ///
8592    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
8593    ///
8594    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
8595    /// end (without `Release` first) will trigger failure of the buffer
8596    /// collection. To close a `BufferCollectionTokenGroup` channel without
8597    /// failing the buffer collection, ensure that AllChildrenPresent() has been
8598    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
8599    /// client end.
8600    ///
8601    /// If `Release` occurs before
8602    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
8603    /// buffer collection will fail (triggered by reception of `Release` without
8604    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
8605    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
8606    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
8607    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
8608    /// close requires `AllChildrenPresent` (if not already sent), then
8609    /// `Release`, then close client end.
8610    ///
8611    /// If `Release` occurs after `AllChildrenPresent`, the children and all
8612    /// their constraints remain intact (just as they would if the
8613    /// `BufferCollectionTokenGroup` channel had remained open), and the client
8614    /// end close doesn't trigger buffer collection failure.
8615    ///
8616    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
8617    ///
8618    /// For brevity, the per-channel-protocol paragraphs above ignore the
8619    /// separate failure domain created by
8620    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
8621    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
8622    /// unexpectedly closes (without `Release` first) and that client end is
8623    /// under a failure domain, instead of failing the whole buffer collection,
8624    /// the failure domain is failed, but the buffer collection itself is
8625    /// isolated from failure of the failure domain. Such failure domains can be
8626    /// nested, in which case only the inner-most failure domain in which the
8627    /// `Node` resides fails.
8628    Release { control_handle: BufferCollectionTokenGroupControlHandle },
8629    /// Set a name for VMOs in this buffer collection.
8630    ///
8631    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
8632    /// will be truncated to fit. The name of the vmo will be suffixed with the
8633    /// buffer index within the collection (if the suffix fits within
8634    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
8635    /// listed in the inspect data.
8636    ///
8637    /// The name only affects VMOs allocated after the name is set; this call
8638    /// does not rename existing VMOs. If multiple clients set different names
8639    /// then the larger priority value will win. Setting a new name with the
8640    /// same priority as a prior name doesn't change the name.
8641    ///
8642    /// All table fields are currently required.
8643    ///
8644    /// + request `priority` The name is only set if this is the first `SetName`
8645    ///   or if `priority` is greater than any previous `priority` value in
8646    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
8647    /// + request `name` The name for VMOs created under this buffer collection.
8648    SetName { payload: NodeSetNameRequest, control_handle: BufferCollectionTokenGroupControlHandle },
8649    /// Set information about the current client that can be used by sysmem to
8650    /// help diagnose leaking memory and allocation stalls waiting for a
8651    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
8652    ///
8653    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
8654    /// `Node`(s) derived from this `Node`, unless overriden by
8655    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
8656    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
8657    ///
8658    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
8659    /// `Allocator` is the most efficient way to ensure that all
8660    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
8661    /// set, and is also more efficient than separately sending the same debug
8662    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
8663    /// created [`fuchsia.sysmem2/Node`].
8664    ///
8665    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
8666    /// indicate which client is closing their channel first, leading to subtree
8667    /// failure (which can be normal if the purpose of the subtree is over, but
8668    /// if happening earlier than expected, the client-channel-specific name can
8669    /// help diagnose where the failure is first coming from, from sysmem's
8670    /// point of view).
8671    ///
8672    /// All table fields are currently required.
8673    ///
8674    /// + request `name` This can be an arbitrary string, but the current
8675    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
8676    /// + request `id` This can be an arbitrary id, but the current process ID
8677    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
8678    SetDebugClientInfo {
8679        payload: NodeSetDebugClientInfoRequest,
8680        control_handle: BufferCollectionTokenGroupControlHandle,
8681    },
8682    /// Sysmem logs a warning if sysmem hasn't seen
8683    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
8684    /// within 5 seconds after creation of a new collection.
8685    ///
8686    /// Clients can call this method to change when the log is printed. If
8687    /// multiple client set the deadline, it's unspecified which deadline will
8688    /// take effect.
8689    ///
8690    /// In most cases the default works well.
8691    ///
8692    /// All table fields are currently required.
8693    ///
8694    /// + request `deadline` The time at which sysmem will start trying to log
8695    ///   the warning, unless all constraints are with sysmem by then.
8696    SetDebugTimeoutLogDeadline {
8697        payload: NodeSetDebugTimeoutLogDeadlineRequest,
8698        control_handle: BufferCollectionTokenGroupControlHandle,
8699    },
8700    /// This enables verbose logging for the buffer collection.
8701    ///
8702    /// Verbose logging includes constraints set via
8703    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
8704    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
8705    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
8706    /// the tree of `Node`(s).
8707    ///
8708    /// Normally sysmem prints only a single line complaint when aggregation
8709    /// fails, with just the specific detailed reason that aggregation failed,
8710    /// with little surrounding context.  While this is often enough to diagnose
8711    /// a problem if only a small change was made and everything was working
8712    /// before the small change, it's often not particularly helpful for getting
8713    /// a new buffer collection to work for the first time.  Especially with
8714    /// more complex trees of nodes, involving things like
8715    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
8716    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
8717    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
8718    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
8719    /// looks like and why it's failing a logical allocation, or why a tree or
8720    /// subtree is failing sooner than expected.
8721    ///
8722    /// The intent of the extra logging is to be acceptable from a performance
8723    /// point of view, under the assumption that verbose logging is only enabled
8724    /// on a low number of buffer collections. If we're not tracking down a bug,
8725    /// we shouldn't send this message.
8726    SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
8727    /// This gets a handle that can be used as a parameter to
8728    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
8729    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
8730    /// client obtained this handle from this `Node`.
8731    ///
8732    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
8733    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
8734    /// despite the two calls typically being on different channels.
8735    ///
8736    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
8737    ///
8738    /// All table fields are currently required.
8739    ///
8740    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
8741    ///   different `Node` channel, to prove that the client obtained the handle
8742    ///   from this `Node`.
8743    GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
8744    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
8745    /// rooted at a different child token of a common parent
8746    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
8747    /// passed-in `node_ref`.
8748    ///
8749    /// This call is for assisting with admission control de-duplication, and
8750    /// with debugging.
8751    ///
8752    /// The `node_ref` must be obtained using
8753    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
8754    ///
8755    /// The `node_ref` can be a duplicated handle; it's not necessary to call
8756    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
8757    ///
8758    /// If a calling token may not actually be a valid token at all due to a
8759    /// potentially hostile/untrusted provider of the token, call
8760    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
8761    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
8762    /// never responds due to a calling token not being a real token (not really
8763    /// talking to sysmem).  Another option is to call
8764    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
8765    /// which also validates the token along with converting it to a
8766    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
8767    ///
8768    /// All table fields are currently required.
8769    ///
8770    /// - response `is_alternate`
8771    ///   - true: The first parent node in common between the calling node and
8772    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
8773    ///     that the calling `Node` and the `node_ref` `Node` will not have both
8774    ///     their constraints apply - rather sysmem will choose one or the other
8775    ///     of the constraints - never both.  This is because only one child of
8776    ///     a `BufferCollectionTokenGroup` is selected during logical
8777    ///     allocation, with only that one child's subtree contributing to
8778    ///     constraints aggregation.
8779    ///   - false: The first parent node in common between the calling `Node`
8780    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
8781    ///     Currently, this means the first parent node in common is a
8782    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
8783    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
8784    ///     `Node` may have both their constraints apply during constraints
8785    ///     aggregation of the logical allocation, if both `Node`(s) are
8786    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
8787    ///     this case, there is no `BufferCollectionTokenGroup` that will
8788    ///     directly prevent the two `Node`(s) from both being selected and
8789    ///     their constraints both aggregated, but even when false, one or both
8790    ///     `Node`(s) may still be eliminated from consideration if one or both
8791    ///     `Node`(s) has a direct or indirect parent
8792    ///     `BufferCollectionTokenGroup` which selects a child subtree other
8793    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
8794    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
8795    ///   associated with the same buffer collection as the calling `Node`.
8796    ///   Another reason for this error is if the `node_ref` is an
8797    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
8798    ///   a real `node_ref` obtained from `GetNodeRef`.
8799    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
8800    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
8801    ///   the needed rights expected on a real `node_ref`.
8802    /// * No other failing status codes are returned by this call.  However,
8803    ///   sysmem may add additional codes in future, so the client should have
8804    ///   sensible default handling for any failing status code.
8805    IsAlternateFor {
8806        payload: NodeIsAlternateForRequest,
8807        responder: BufferCollectionTokenGroupIsAlternateForResponder,
8808    },
8809    /// Get the buffer collection ID. This ID is also available from
8810    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
8811    /// within the collection).
8812    ///
8813    /// This call is mainly useful in situations where we can't convey a
8814    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
8815    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
8816    /// handle, which can be joined back up with a `BufferCollection` client end
8817    /// that was created via a different path. Prefer to convey a
8818    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
8819    ///
8820    /// Trusting a `buffer_collection_id` value from a source other than sysmem
8821    /// is analogous to trusting a koid value from a source other than zircon.
8822    /// Both should be avoided unless really necessary, and both require
8823    /// caution. In some situations it may be reasonable to refer to a
8824    /// pre-established `BufferCollection` by `buffer_collection_id` via a
8825    /// protocol for efficiency reasons, but an incoming value purporting to be
8826    /// a `buffer_collection_id` is not sufficient alone to justify granting the
8827    /// sender of the `buffer_collection_id` any capability. The sender must
8828    /// first prove to a receiver that the sender has/had a VMO or has/had a
8829    /// `BufferCollectionToken` to the same collection by sending a handle that
8830    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
8831    /// `buffer_collection_id` value. The receiver should take care to avoid
8832    /// assuming that a sender had a `BufferCollectionToken` in cases where the
8833    /// sender has only proven that the sender had a VMO.
8834    ///
8835    /// - response `buffer_collection_id` This ID is unique per buffer
8836    ///   collection per boot. Each buffer is uniquely identified by the
8837    ///   `buffer_collection_id` and `buffer_index` together.
8838    GetBufferCollectionId { responder: BufferCollectionTokenGroupGetBufferCollectionIdResponder },
8839    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
8840    /// created after this message to weak, which means that a client's `Node`
8841    /// client end (or a child created after this message) is not alone
8842    /// sufficient to keep allocated VMOs alive.
8843    ///
8844    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
8845    /// `close_weak_asap`.
8846    ///
8847    /// This message is only permitted before the `Node` becomes ready for
8848    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
8849    ///   * `BufferCollectionToken`: any time
8850    ///   * `BufferCollection`: before `SetConstraints`
8851    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
8852    ///
8853    /// Currently, no conversion from strong `Node` to weak `Node` after ready
8854    /// for allocation is provided, but a client can simulate that by creating
8855    /// an additional `Node` before allocation and setting that additional
8856    /// `Node` to weak, and then potentially at some point later sending
8857    /// `Release` and closing the client end of the client's strong `Node`, but
8858    /// keeping the client's weak `Node`.
8859    ///
8860    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
8861    /// collection failure (all `Node` client end(s) will see
8862    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
8863    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
8864    /// this situation until all `Node`(s) are ready for allocation. For initial
8865    /// allocation to succeed, at least one strong `Node` is required to exist
8866    /// at allocation time, but after that client receives VMO handles, that
8867    /// client can `BufferCollection.Release` and close the client end without
8868    /// causing this type of failure.
8869    ///
8870    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
8871    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
8872    /// separately as appropriate.
8873    SetWeak { control_handle: BufferCollectionTokenGroupControlHandle },
8874    /// This indicates to sysmem that the client is prepared to pay attention to
8875    /// `close_weak_asap`.
8876    ///
8877    /// If sent, this message must be before
8878    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
8879    ///
8880    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
8881    /// send this message before `WaitForAllBuffersAllocated`, or a parent
8882    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
8883    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
8884    /// trigger buffer collection failure.
8885    ///
8886    /// This message is necessary because weak sysmem VMOs have not always been
8887    /// a thing, so older clients are not aware of the need to pay attention to
8888    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
8889    /// sysmem weak VMO handles asap. By having this message and requiring
8890    /// participants to indicate their acceptance of this aspect of the overall
8891    /// protocol, we avoid situations where an older client is delivered a weak
8892    /// VMO without any way for sysmem to get that VMO to close quickly later
8893    /// (and on a per-buffer basis).
8894    ///
8895    /// A participant that doesn't handle `close_weak_asap` and also doesn't
8896    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
8897    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
8898    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
8899    /// same participant has a child/delegate which does retrieve VMOs, that
8900    /// child/delegate will need to send `SetWeakOk` before
8901    /// `WaitForAllBuffersAllocated`.
8902    ///
8903    /// + request `for_child_nodes_also` If present and true, this means direct
8904    ///   child nodes of this node created after this message plus all
8905    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
8906    ///   those nodes. Any child node of this node that was created before this
8907    ///   message is not included. This setting is "sticky" in the sense that a
8908    ///   subsequent `SetWeakOk` without this bool set to true does not reset
8909    ///   the server-side bool. If this creates a problem for a participant, a
8910    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
8911    ///   tokens instead, as appropriate. A participant should only set
8912    ///   `for_child_nodes_also` true if the participant can really promise to
8913    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
8914    ///   weak VMO handles held by participants holding the corresponding child
8915    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
8916    ///   which are using sysmem(1) can be weak, despite the clients of those
8917    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
8918    ///   direct way to find out about `close_weak_asap`. This only applies to
8919    ///   descendents of this `Node` which are using sysmem(1), not to this
8920    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
8921    ///   token, which will fail allocation unless an ancestor of this `Node`
8922    ///   specified `for_child_nodes_also` true.
8923    SetWeakOk {
8924        payload: NodeSetWeakOkRequest,
8925        control_handle: BufferCollectionTokenGroupControlHandle,
8926    },
8927    /// The server_end will be closed after this `Node` and any child nodes have
8928    /// have released their buffer counts, making those counts available for
8929    /// reservation by a different `Node` via
8930    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
8931    ///
8932    /// The `Node` buffer counts may not be released until the entire tree of
8933    /// `Node`(s) is closed or failed, because
8934    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
8935    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
8936    /// `Node` buffer counts remain reserved until the orphaned node is later
8937    /// cleaned up.
8938    ///
8939    /// If the `Node` exceeds a fairly large number of attached eventpair server
8940    /// ends, a log message will indicate this and the `Node` (and the
8941    /// appropriate) sub-tree will fail.
8942    ///
8943    /// The `server_end` will remain open when
8944    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
8945    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
8946    /// [`fuchsia.sysmem2/BufferCollection`].
8947    ///
8948    /// This message can also be used with a
8949    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
8950    AttachNodeTracking {
8951        payload: NodeAttachNodeTrackingRequest,
8952        control_handle: BufferCollectionTokenGroupControlHandle,
8953    },
8954    /// Create a child [`fuchsia.sysmem2/BufferCollectionToken`]. Only one child
8955    /// (including its children) will be selected during allocation (or logical
8956    /// allocation).
8957    ///
8958    /// Before passing the client end of this token to
8959    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], completion of
8960    /// [`fuchsia.sysmem2/Node.Sync`] after
8961    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] is required.
8962    /// Or the client can use
8963    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`] which
8964    /// essentially includes the `Sync`.
8965    ///
8966    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
8967    /// fail the group's subtree and close the connection.
8968    ///
8969    /// After all children have been created, send AllChildrenPresent.
8970    ///
8971    /// + request `token_request` The server end of the new token channel.
8972    /// + request `rights_attenuation_mask` If ZX_RIGHT_SAME_RIGHTS, the created
8973    ///   token allows the holder to get the same rights to buffers as the
8974    ///   parent token (of the group) had. When the value isn't
8975    ///   ZX_RIGHT_SAME_RIGHTS, the value is interpretted as a bitmask with 0
8976    ///   bits ensuring those rights are attentuated, so 0xFFFFFFFF is a synonym
8977    ///   for ZX_RIGHT_SAME_RIGHTS. The value 0 is not allowed and intentionally
8978    ///   causes subtree failure.
8979    CreateChild {
8980        payload: BufferCollectionTokenGroupCreateChildRequest,
8981        control_handle: BufferCollectionTokenGroupControlHandle,
8982    },
8983    /// Create 1 or more child tokens at once, synchronously.  In contrast to
8984    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`], no
8985    /// [`fuchsia.sysmem2/Node.Sync`] is required before passing the client end
8986    /// of a returned token to
8987    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`].
8988    ///
8989    /// The lower-index child tokens are higher priority (attempted sooner) than
8990    /// higher-index child tokens.
8991    ///
8992    /// As per all child tokens, successful aggregation will choose exactly one
8993    /// child among all created children (across all children created across
8994    /// potentially multiple calls to
8995    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChild`] and
8996    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.CreateChildrenSync`]).
8997    ///
8998    /// The maximum permissible total number of children per group, and total
8999    /// number of nodes in an overall tree (from the root) are capped to limits
9000    /// which are not configurable via these protocols.
9001    ///
9002    /// Sending CreateChildrenSync after AllChildrenPresent is not permitted;
9003    /// this will fail the group's subtree and close the connection.
9004    ///
9005    /// After all children have been created, send AllChildrenPresent.
9006    ///
9007    /// + request `rights_attentuation_masks` The size of the
9008    ///   `rights_attentuation_masks` determines the number of created child
9009    ///   tokens. The value ZX_RIGHT_SAME_RIGHTS doesn't attenuate any rights.
9010    ///   The value 0xFFFFFFFF is a synonym for ZX_RIGHT_SAME_RIGHTS. For any
9011    ///   other value, each 0 bit in the mask attenuates that right.
9012    /// - response `tokens` The created child tokens.
9013    CreateChildrenSync {
9014        payload: BufferCollectionTokenGroupCreateChildrenSyncRequest,
9015        responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
9016    },
9017    /// Indicate that no more children will be created.
9018    ///
9019    /// After creating all children, the client should send
9020    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent`] to
9021    /// inform sysmem that no more children will be created, so that sysmem can
9022    /// know when it's ok to start aggregating constraints.
9023    ///
9024    /// Sending CreateChild after AllChildrenPresent is not permitted; this will
9025    /// fail the group's subtree and close the connection.
9026    ///
9027    /// If [`fuchsia.sysmem2/Node.Release`] is to be sent, it should be sent
9028    /// after `AllChildrenPresent`, else failure of the group's subtree will be
9029    /// triggered. This is intentionally not analogous to how `Release` without
9030    /// prior [`fuchsia.sysmem2/BufferCollection.SetConstraints`] doesn't cause
9031    /// subtree failure.
9032    AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
9033    /// An interaction was received which does not match any known method.
9034    #[non_exhaustive]
9035    _UnknownMethod {
9036        /// Ordinal of the method that was called.
9037        ordinal: u64,
9038        control_handle: BufferCollectionTokenGroupControlHandle,
9039        method_type: fidl::MethodType,
9040    },
9041}
9042
9043impl BufferCollectionTokenGroupRequest {
9044    #[allow(irrefutable_let_patterns)]
9045    pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
9046        if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
9047            Some((responder))
9048        } else {
9049            None
9050        }
9051    }
9052
9053    #[allow(irrefutable_let_patterns)]
9054    pub fn into_release(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9055        if let BufferCollectionTokenGroupRequest::Release { control_handle } = self {
9056            Some((control_handle))
9057        } else {
9058            None
9059        }
9060    }
9061
9062    #[allow(irrefutable_let_patterns)]
9063    pub fn into_set_name(
9064        self,
9065    ) -> Option<(NodeSetNameRequest, BufferCollectionTokenGroupControlHandle)> {
9066        if let BufferCollectionTokenGroupRequest::SetName { payload, control_handle } = self {
9067            Some((payload, control_handle))
9068        } else {
9069            None
9070        }
9071    }
9072
9073    #[allow(irrefutable_let_patterns)]
9074    pub fn into_set_debug_client_info(
9075        self,
9076    ) -> Option<(NodeSetDebugClientInfoRequest, BufferCollectionTokenGroupControlHandle)> {
9077        if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { payload, control_handle } =
9078            self
9079        {
9080            Some((payload, control_handle))
9081        } else {
9082            None
9083        }
9084    }
9085
9086    #[allow(irrefutable_let_patterns)]
9087    pub fn into_set_debug_timeout_log_deadline(
9088        self,
9089    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, BufferCollectionTokenGroupControlHandle)>
9090    {
9091        if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
9092            payload,
9093            control_handle,
9094        } = self
9095        {
9096            Some((payload, control_handle))
9097        } else {
9098            None
9099        }
9100    }
9101
9102    #[allow(irrefutable_let_patterns)]
9103    pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9104        if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
9105            Some((control_handle))
9106        } else {
9107            None
9108        }
9109    }
9110
9111    #[allow(irrefutable_let_patterns)]
9112    pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
9113        if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
9114            Some((responder))
9115        } else {
9116            None
9117        }
9118    }
9119
9120    #[allow(irrefutable_let_patterns)]
9121    pub fn into_is_alternate_for(
9122        self,
9123    ) -> Option<(NodeIsAlternateForRequest, BufferCollectionTokenGroupIsAlternateForResponder)>
9124    {
9125        if let BufferCollectionTokenGroupRequest::IsAlternateFor { payload, responder } = self {
9126            Some((payload, responder))
9127        } else {
9128            None
9129        }
9130    }
9131
9132    #[allow(irrefutable_let_patterns)]
9133    pub fn into_get_buffer_collection_id(
9134        self,
9135    ) -> Option<(BufferCollectionTokenGroupGetBufferCollectionIdResponder)> {
9136        if let BufferCollectionTokenGroupRequest::GetBufferCollectionId { responder } = self {
9137            Some((responder))
9138        } else {
9139            None
9140        }
9141    }
9142
9143    #[allow(irrefutable_let_patterns)]
9144    pub fn into_set_weak(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9145        if let BufferCollectionTokenGroupRequest::SetWeak { control_handle } = self {
9146            Some((control_handle))
9147        } else {
9148            None
9149        }
9150    }
9151
9152    #[allow(irrefutable_let_patterns)]
9153    pub fn into_set_weak_ok(
9154        self,
9155    ) -> Option<(NodeSetWeakOkRequest, BufferCollectionTokenGroupControlHandle)> {
9156        if let BufferCollectionTokenGroupRequest::SetWeakOk { payload, control_handle } = self {
9157            Some((payload, control_handle))
9158        } else {
9159            None
9160        }
9161    }
9162
9163    #[allow(irrefutable_let_patterns)]
9164    pub fn into_attach_node_tracking(
9165        self,
9166    ) -> Option<(NodeAttachNodeTrackingRequest, BufferCollectionTokenGroupControlHandle)> {
9167        if let BufferCollectionTokenGroupRequest::AttachNodeTracking { payload, control_handle } =
9168            self
9169        {
9170            Some((payload, control_handle))
9171        } else {
9172            None
9173        }
9174    }
9175
9176    #[allow(irrefutable_let_patterns)]
9177    pub fn into_create_child(
9178        self,
9179    ) -> Option<(
9180        BufferCollectionTokenGroupCreateChildRequest,
9181        BufferCollectionTokenGroupControlHandle,
9182    )> {
9183        if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
9184            Some((payload, control_handle))
9185        } else {
9186            None
9187        }
9188    }
9189
9190    #[allow(irrefutable_let_patterns)]
9191    pub fn into_create_children_sync(
9192        self,
9193    ) -> Option<(
9194        BufferCollectionTokenGroupCreateChildrenSyncRequest,
9195        BufferCollectionTokenGroupCreateChildrenSyncResponder,
9196    )> {
9197        if let BufferCollectionTokenGroupRequest::CreateChildrenSync { payload, responder } = self {
9198            Some((payload, responder))
9199        } else {
9200            None
9201        }
9202    }
9203
9204    #[allow(irrefutable_let_patterns)]
9205    pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
9206        if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
9207            Some((control_handle))
9208        } else {
9209            None
9210        }
9211    }
9212
9213    /// Name of the method defined in FIDL
9214    pub fn method_name(&self) -> &'static str {
9215        match *self {
9216            BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
9217            BufferCollectionTokenGroupRequest::Release { .. } => "release",
9218            BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
9219            BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
9220            BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
9221                "set_debug_timeout_log_deadline"
9222            }
9223            BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
9224            BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
9225            BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
9226            BufferCollectionTokenGroupRequest::GetBufferCollectionId { .. } => {
9227                "get_buffer_collection_id"
9228            }
9229            BufferCollectionTokenGroupRequest::SetWeak { .. } => "set_weak",
9230            BufferCollectionTokenGroupRequest::SetWeakOk { .. } => "set_weak_ok",
9231            BufferCollectionTokenGroupRequest::AttachNodeTracking { .. } => "attach_node_tracking",
9232            BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
9233            BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
9234            BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
9235            BufferCollectionTokenGroupRequest::_UnknownMethod {
9236                method_type: fidl::MethodType::OneWay,
9237                ..
9238            } => "unknown one-way method",
9239            BufferCollectionTokenGroupRequest::_UnknownMethod {
9240                method_type: fidl::MethodType::TwoWay,
9241                ..
9242            } => "unknown two-way method",
9243        }
9244    }
9245}
9246
9247#[derive(Debug, Clone)]
9248pub struct BufferCollectionTokenGroupControlHandle {
9249    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9250}
9251
9252impl BufferCollectionTokenGroupControlHandle {
9253    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
9254        self.inner.shutdown_with_epitaph(status.into())
9255    }
9256}
9257
9258impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenGroupControlHandle {
9259    fn shutdown(&self) {
9260        self.inner.shutdown()
9261    }
9262
9263    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
9264        self.inner.shutdown_with_epitaph(status)
9265    }
9266
9267    fn is_closed(&self) -> bool {
9268        self.inner.channel().is_closed()
9269    }
9270    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9271        self.inner.channel().on_closed()
9272    }
9273}
9274
9275impl BufferCollectionTokenGroupControlHandle {}
9276
9277#[must_use = "FIDL methods require a response to be sent"]
9278#[derive(Debug)]
9279pub struct BufferCollectionTokenGroupSyncResponder {
9280    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9281    tx_id: u32,
9282}
9283
9284/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9285/// if the responder is dropped without sending a response, so that the client
9286/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9287impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
9288    fn drop(&mut self) {
9289        self.control_handle.shutdown();
9290        // Safety: drops once, never accessed again
9291        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9292    }
9293}
9294
9295impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupSyncResponder {
9296    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9297
9298    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9299        &self.control_handle
9300    }
9301
9302    fn drop_without_shutdown(mut self) {
9303        // Safety: drops once, never accessed again due to mem::forget
9304        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9305        // Prevent Drop from running (which would shut down the channel)
9306        std::mem::forget(self);
9307    }
9308}
9309
9310impl BufferCollectionTokenGroupSyncResponder {
9311    /// Sends a response to the FIDL transaction.
9312    ///
9313    /// Sets the channel to shutdown if an error occurs.
9314    pub fn send(self) -> Result<(), fidl::Error> {
9315        let _result = self.send_raw();
9316        if _result.is_err() {
9317            self.control_handle.shutdown();
9318        }
9319        self.drop_without_shutdown();
9320        _result
9321    }
9322
9323    /// Similar to "send" but does not shutdown the channel if an error occurs.
9324    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9325        let _result = self.send_raw();
9326        self.drop_without_shutdown();
9327        _result
9328    }
9329
9330    fn send_raw(&self) -> Result<(), fidl::Error> {
9331        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
9332            fidl::encoding::Flexible::new(()),
9333            self.tx_id,
9334            0x11ac2555cf575b54,
9335            fidl::encoding::DynamicFlags::FLEXIBLE,
9336        )
9337    }
9338}
9339
9340#[must_use = "FIDL methods require a response to be sent"]
9341#[derive(Debug)]
9342pub struct BufferCollectionTokenGroupGetNodeRefResponder {
9343    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9344    tx_id: u32,
9345}
9346
9347/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9348/// if the responder is dropped without sending a response, so that the client
9349/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9350impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
9351    fn drop(&mut self) {
9352        self.control_handle.shutdown();
9353        // Safety: drops once, never accessed again
9354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9355    }
9356}
9357
9358impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
9359    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9360
9361    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9362        &self.control_handle
9363    }
9364
9365    fn drop_without_shutdown(mut self) {
9366        // Safety: drops once, never accessed again due to mem::forget
9367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9368        // Prevent Drop from running (which would shut down the channel)
9369        std::mem::forget(self);
9370    }
9371}
9372
9373impl BufferCollectionTokenGroupGetNodeRefResponder {
9374    /// Sends a response to the FIDL transaction.
9375    ///
9376    /// Sets the channel to shutdown if an error occurs.
9377    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
9378        let _result = self.send_raw(payload);
9379        if _result.is_err() {
9380            self.control_handle.shutdown();
9381        }
9382        self.drop_without_shutdown();
9383        _result
9384    }
9385
9386    /// Similar to "send" but does not shutdown the channel if an error occurs.
9387    pub fn send_no_shutdown_on_err(
9388        self,
9389        mut payload: NodeGetNodeRefResponse,
9390    ) -> Result<(), fidl::Error> {
9391        let _result = self.send_raw(payload);
9392        self.drop_without_shutdown();
9393        _result
9394    }
9395
9396    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
9397        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
9398            fidl::encoding::Flexible::new(&mut payload),
9399            self.tx_id,
9400            0x5b3d0e51614df053,
9401            fidl::encoding::DynamicFlags::FLEXIBLE,
9402        )
9403    }
9404}
9405
9406#[must_use = "FIDL methods require a response to be sent"]
9407#[derive(Debug)]
9408pub struct BufferCollectionTokenGroupIsAlternateForResponder {
9409    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9410    tx_id: u32,
9411}
9412
9413/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9414/// if the responder is dropped without sending a response, so that the client
9415/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9416impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
9417    fn drop(&mut self) {
9418        self.control_handle.shutdown();
9419        // Safety: drops once, never accessed again
9420        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9421    }
9422}
9423
9424impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
9425    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9426
9427    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9428        &self.control_handle
9429    }
9430
9431    fn drop_without_shutdown(mut self) {
9432        // Safety: drops once, never accessed again due to mem::forget
9433        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9434        // Prevent Drop from running (which would shut down the channel)
9435        std::mem::forget(self);
9436    }
9437}
9438
9439impl BufferCollectionTokenGroupIsAlternateForResponder {
9440    /// Sends a response to the FIDL transaction.
9441    ///
9442    /// Sets the channel to shutdown if an error occurs.
9443    pub fn send(
9444        self,
9445        mut result: Result<&NodeIsAlternateForResponse, Error>,
9446    ) -> Result<(), fidl::Error> {
9447        let _result = self.send_raw(result);
9448        if _result.is_err() {
9449            self.control_handle.shutdown();
9450        }
9451        self.drop_without_shutdown();
9452        _result
9453    }
9454
9455    /// Similar to "send" but does not shutdown the channel if an error occurs.
9456    pub fn send_no_shutdown_on_err(
9457        self,
9458        mut result: Result<&NodeIsAlternateForResponse, Error>,
9459    ) -> Result<(), fidl::Error> {
9460        let _result = self.send_raw(result);
9461        self.drop_without_shutdown();
9462        _result
9463    }
9464
9465    fn send_raw(
9466        &self,
9467        mut result: Result<&NodeIsAlternateForResponse, Error>,
9468    ) -> Result<(), fidl::Error> {
9469        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
9470            NodeIsAlternateForResponse,
9471            Error,
9472        >>(
9473            fidl::encoding::FlexibleResult::new(result),
9474            self.tx_id,
9475            0x3a58e00157e0825,
9476            fidl::encoding::DynamicFlags::FLEXIBLE,
9477        )
9478    }
9479}
9480
9481#[must_use = "FIDL methods require a response to be sent"]
9482#[derive(Debug)]
9483pub struct BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9484    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9485    tx_id: u32,
9486}
9487
9488/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9489/// if the responder is dropped without sending a response, so that the client
9490/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9491impl std::ops::Drop for BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9492    fn drop(&mut self) {
9493        self.control_handle.shutdown();
9494        // Safety: drops once, never accessed again
9495        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9496    }
9497}
9498
9499impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9500    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9501
9502    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9503        &self.control_handle
9504    }
9505
9506    fn drop_without_shutdown(mut self) {
9507        // Safety: drops once, never accessed again due to mem::forget
9508        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9509        // Prevent Drop from running (which would shut down the channel)
9510        std::mem::forget(self);
9511    }
9512}
9513
9514impl BufferCollectionTokenGroupGetBufferCollectionIdResponder {
9515    /// Sends a response to the FIDL transaction.
9516    ///
9517    /// Sets the channel to shutdown if an error occurs.
9518    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
9519        let _result = self.send_raw(payload);
9520        if _result.is_err() {
9521            self.control_handle.shutdown();
9522        }
9523        self.drop_without_shutdown();
9524        _result
9525    }
9526
9527    /// Similar to "send" but does not shutdown the channel if an error occurs.
9528    pub fn send_no_shutdown_on_err(
9529        self,
9530        mut payload: &NodeGetBufferCollectionIdResponse,
9531    ) -> Result<(), fidl::Error> {
9532        let _result = self.send_raw(payload);
9533        self.drop_without_shutdown();
9534        _result
9535    }
9536
9537    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
9538        self.control_handle
9539            .inner
9540            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
9541                fidl::encoding::Flexible::new(payload),
9542                self.tx_id,
9543                0x77d19a494b78ba8c,
9544                fidl::encoding::DynamicFlags::FLEXIBLE,
9545            )
9546    }
9547}
9548
9549#[must_use = "FIDL methods require a response to be sent"]
9550#[derive(Debug)]
9551pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
9552    control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
9553    tx_id: u32,
9554}
9555
9556/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
9557/// if the responder is dropped without sending a response, so that the client
9558/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9559impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
9560    fn drop(&mut self) {
9561        self.control_handle.shutdown();
9562        // Safety: drops once, never accessed again
9563        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9564    }
9565}
9566
9567impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
9568    type ControlHandle = BufferCollectionTokenGroupControlHandle;
9569
9570    fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
9571        &self.control_handle
9572    }
9573
9574    fn drop_without_shutdown(mut self) {
9575        // Safety: drops once, never accessed again due to mem::forget
9576        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9577        // Prevent Drop from running (which would shut down the channel)
9578        std::mem::forget(self);
9579    }
9580}
9581
9582impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
9583    /// Sends a response to the FIDL transaction.
9584    ///
9585    /// Sets the channel to shutdown if an error occurs.
9586    pub fn send(
9587        self,
9588        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9589    ) -> Result<(), fidl::Error> {
9590        let _result = self.send_raw(payload);
9591        if _result.is_err() {
9592            self.control_handle.shutdown();
9593        }
9594        self.drop_without_shutdown();
9595        _result
9596    }
9597
9598    /// Similar to "send" but does not shutdown the channel if an error occurs.
9599    pub fn send_no_shutdown_on_err(
9600        self,
9601        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9602    ) -> Result<(), fidl::Error> {
9603        let _result = self.send_raw(payload);
9604        self.drop_without_shutdown();
9605        _result
9606    }
9607
9608    fn send_raw(
9609        &self,
9610        mut payload: BufferCollectionTokenGroupCreateChildrenSyncResponse,
9611    ) -> Result<(), fidl::Error> {
9612        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
9613            BufferCollectionTokenGroupCreateChildrenSyncResponse,
9614        >>(
9615            fidl::encoding::Flexible::new(&mut payload),
9616            self.tx_id,
9617            0x15dea448c536070a,
9618            fidl::encoding::DynamicFlags::FLEXIBLE,
9619        )
9620    }
9621}
9622
9623#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9624pub struct NodeMarker;
9625
9626impl fdomain_client::fidl::ProtocolMarker for NodeMarker {
9627    type Proxy = NodeProxy;
9628    type RequestStream = NodeRequestStream;
9629
9630    const DEBUG_NAME: &'static str = "(anonymous) Node";
9631}
9632pub type NodeIsAlternateForResult = Result<NodeIsAlternateForResponse, Error>;
9633
9634pub trait NodeProxyInterface: Send + Sync {
9635    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9636    fn r#sync(&self) -> Self::SyncResponseFut;
9637    fn r#release(&self) -> Result<(), fidl::Error>;
9638    fn r#set_name(&self, payload: &NodeSetNameRequest) -> Result<(), fidl::Error>;
9639    fn r#set_debug_client_info(
9640        &self,
9641        payload: &NodeSetDebugClientInfoRequest,
9642    ) -> Result<(), fidl::Error>;
9643    fn r#set_debug_timeout_log_deadline(
9644        &self,
9645        payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9646    ) -> Result<(), fidl::Error>;
9647    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
9648    type GetNodeRefResponseFut: std::future::Future<Output = Result<NodeGetNodeRefResponse, fidl::Error>>
9649        + Send;
9650    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
9651    type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
9652        + Send;
9653    fn r#is_alternate_for(
9654        &self,
9655        payload: NodeIsAlternateForRequest,
9656    ) -> Self::IsAlternateForResponseFut;
9657    type GetBufferCollectionIdResponseFut: std::future::Future<Output = Result<NodeGetBufferCollectionIdResponse, fidl::Error>>
9658        + Send;
9659    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut;
9660    fn r#set_weak(&self) -> Result<(), fidl::Error>;
9661    fn r#set_weak_ok(&self, payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error>;
9662    fn r#attach_node_tracking(
9663        &self,
9664        payload: NodeAttachNodeTrackingRequest,
9665    ) -> Result<(), fidl::Error>;
9666}
9667
9668#[derive(Debug, Clone)]
9669pub struct NodeProxy {
9670    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9671}
9672
9673impl fdomain_client::fidl::Proxy for NodeProxy {
9674    type Protocol = NodeMarker;
9675
9676    fn from_channel(inner: fdomain_client::Channel) -> Self {
9677        Self::new(inner)
9678    }
9679
9680    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9681        self.client.into_channel().map_err(|client| Self { client })
9682    }
9683
9684    fn as_channel(&self) -> &fdomain_client::Channel {
9685        self.client.as_channel()
9686    }
9687}
9688
9689impl NodeProxy {
9690    /// Create a new Proxy for fuchsia.sysmem2/Node.
9691    pub fn new(channel: fdomain_client::Channel) -> Self {
9692        let protocol_name = <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9693        Self { client: fidl::client::Client::new(channel, protocol_name) }
9694    }
9695
9696    /// Get a Stream of events from the remote end of the protocol.
9697    ///
9698    /// # Panics
9699    ///
9700    /// Panics if the event stream was already taken.
9701    pub fn take_event_stream(&self) -> NodeEventStream {
9702        NodeEventStream { event_receiver: self.client.take_event_receiver() }
9703    }
9704
9705    /// Ensure that previous messages have been received server side. This is
9706    /// particularly useful after previous messages that created new tokens,
9707    /// because a token must be known to the sysmem server before sending the
9708    /// token to another participant.
9709    ///
9710    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
9711    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
9712    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
9713    /// to mitigate the possibility of a hostile/fake
9714    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
9715    /// Another way is to pass the token to
9716    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
9717    /// the token as part of exchanging it for a
9718    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
9719    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
9720    /// of stalling.
9721    ///
9722    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
9723    /// and then starting and completing a `Sync`, it's then safe to send the
9724    /// `BufferCollectionToken` client ends to other participants knowing the
9725    /// server will recognize the tokens when they're sent by the other
9726    /// participants to sysmem in a
9727    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
9728    /// efficient way to create tokens while avoiding unnecessary round trips.
9729    ///
9730    /// Other options include waiting for each
9731    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
9732    /// individually (using separate call to `Sync` after each), or calling
9733    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
9734    /// converted to a `BufferCollection` via
9735    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
9736    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
9737    /// the sync step and can create multiple tokens at once.
9738    pub fn r#sync(
9739        &self,
9740    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9741        NodeProxyInterface::r#sync(self)
9742    }
9743
9744    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
9745    ///
9746    /// Normally a participant will convert a `BufferCollectionToken` into a
9747    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
9748    /// `Release` via the token (and then close the channel immediately or
9749    /// shortly later in response to server closing the server end), which
9750    /// avoids causing buffer collection failure. Without a prior `Release`,
9751    /// closing the `BufferCollectionToken` client end will cause buffer
9752    /// collection failure.
9753    ///
9754    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
9755    ///
9756    /// By default the server handles unexpected closure of a
9757    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
9758    /// first) by failing the buffer collection. Partly this is to expedite
9759    /// closing VMO handles to reclaim memory when any participant fails. If a
9760    /// participant would like to cleanly close a `BufferCollection` without
9761    /// causing buffer collection failure, the participant can send `Release`
9762    /// before closing the `BufferCollection` client end. The `Release` can
9763    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
9764    /// buffer collection won't require constraints from this node in order to
9765    /// allocate. If after `SetConstraints`, the constraints are retained and
9766    /// aggregated, despite the lack of `BufferCollection` connection at the
9767    /// time of constraints aggregation.
9768    ///
9769    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
9770    ///
9771    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
9772    /// end (without `Release` first) will trigger failure of the buffer
9773    /// collection. To close a `BufferCollectionTokenGroup` channel without
9774    /// failing the buffer collection, ensure that AllChildrenPresent() has been
9775    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
9776    /// client end.
9777    ///
9778    /// If `Release` occurs before
9779    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
9780    /// buffer collection will fail (triggered by reception of `Release` without
9781    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
9782    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
9783    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
9784    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
9785    /// close requires `AllChildrenPresent` (if not already sent), then
9786    /// `Release`, then close client end.
9787    ///
9788    /// If `Release` occurs after `AllChildrenPresent`, the children and all
9789    /// their constraints remain intact (just as they would if the
9790    /// `BufferCollectionTokenGroup` channel had remained open), and the client
9791    /// end close doesn't trigger buffer collection failure.
9792    ///
9793    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
9794    ///
9795    /// For brevity, the per-channel-protocol paragraphs above ignore the
9796    /// separate failure domain created by
9797    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
9798    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
9799    /// unexpectedly closes (without `Release` first) and that client end is
9800    /// under a failure domain, instead of failing the whole buffer collection,
9801    /// the failure domain is failed, but the buffer collection itself is
9802    /// isolated from failure of the failure domain. Such failure domains can be
9803    /// nested, in which case only the inner-most failure domain in which the
9804    /// `Node` resides fails.
9805    pub fn r#release(&self) -> Result<(), fidl::Error> {
9806        NodeProxyInterface::r#release(self)
9807    }
9808
9809    /// Set a name for VMOs in this buffer collection.
9810    ///
9811    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
9812    /// will be truncated to fit. The name of the vmo will be suffixed with the
9813    /// buffer index within the collection (if the suffix fits within
9814    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
9815    /// listed in the inspect data.
9816    ///
9817    /// The name only affects VMOs allocated after the name is set; this call
9818    /// does not rename existing VMOs. If multiple clients set different names
9819    /// then the larger priority value will win. Setting a new name with the
9820    /// same priority as a prior name doesn't change the name.
9821    ///
9822    /// All table fields are currently required.
9823    ///
9824    /// + request `priority` The name is only set if this is the first `SetName`
9825    ///   or if `priority` is greater than any previous `priority` value in
9826    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
9827    /// + request `name` The name for VMOs created under this buffer collection.
9828    pub fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
9829        NodeProxyInterface::r#set_name(self, payload)
9830    }
9831
9832    /// Set information about the current client that can be used by sysmem to
9833    /// help diagnose leaking memory and allocation stalls waiting for a
9834    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
9835    ///
9836    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
9837    /// `Node`(s) derived from this `Node`, unless overriden by
9838    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
9839    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
9840    ///
9841    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
9842    /// `Allocator` is the most efficient way to ensure that all
9843    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
9844    /// set, and is also more efficient than separately sending the same debug
9845    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
9846    /// created [`fuchsia.sysmem2/Node`].
9847    ///
9848    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
9849    /// indicate which client is closing their channel first, leading to subtree
9850    /// failure (which can be normal if the purpose of the subtree is over, but
9851    /// if happening earlier than expected, the client-channel-specific name can
9852    /// help diagnose where the failure is first coming from, from sysmem's
9853    /// point of view).
9854    ///
9855    /// All table fields are currently required.
9856    ///
9857    /// + request `name` This can be an arbitrary string, but the current
9858    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
9859    /// + request `id` This can be an arbitrary id, but the current process ID
9860    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
9861    pub fn r#set_debug_client_info(
9862        &self,
9863        mut payload: &NodeSetDebugClientInfoRequest,
9864    ) -> Result<(), fidl::Error> {
9865        NodeProxyInterface::r#set_debug_client_info(self, payload)
9866    }
9867
9868    /// Sysmem logs a warning if sysmem hasn't seen
9869    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
9870    /// within 5 seconds after creation of a new collection.
9871    ///
9872    /// Clients can call this method to change when the log is printed. If
9873    /// multiple client set the deadline, it's unspecified which deadline will
9874    /// take effect.
9875    ///
9876    /// In most cases the default works well.
9877    ///
9878    /// All table fields are currently required.
9879    ///
9880    /// + request `deadline` The time at which sysmem will start trying to log
9881    ///   the warning, unless all constraints are with sysmem by then.
9882    pub fn r#set_debug_timeout_log_deadline(
9883        &self,
9884        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
9885    ) -> Result<(), fidl::Error> {
9886        NodeProxyInterface::r#set_debug_timeout_log_deadline(self, payload)
9887    }
9888
9889    /// This enables verbose logging for the buffer collection.
9890    ///
9891    /// Verbose logging includes constraints set via
9892    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
9893    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
9894    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
9895    /// the tree of `Node`(s).
9896    ///
9897    /// Normally sysmem prints only a single line complaint when aggregation
9898    /// fails, with just the specific detailed reason that aggregation failed,
9899    /// with little surrounding context.  While this is often enough to diagnose
9900    /// a problem if only a small change was made and everything was working
9901    /// before the small change, it's often not particularly helpful for getting
9902    /// a new buffer collection to work for the first time.  Especially with
9903    /// more complex trees of nodes, involving things like
9904    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
9905    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
9906    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
9907    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
9908    /// looks like and why it's failing a logical allocation, or why a tree or
9909    /// subtree is failing sooner than expected.
9910    ///
9911    /// The intent of the extra logging is to be acceptable from a performance
9912    /// point of view, under the assumption that verbose logging is only enabled
9913    /// on a low number of buffer collections. If we're not tracking down a bug,
9914    /// we shouldn't send this message.
9915    pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
9916        NodeProxyInterface::r#set_verbose_logging(self)
9917    }
9918
9919    /// This gets a handle that can be used as a parameter to
9920    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
9921    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
9922    /// client obtained this handle from this `Node`.
9923    ///
9924    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
9925    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
9926    /// despite the two calls typically being on different channels.
9927    ///
9928    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
9929    ///
9930    /// All table fields are currently required.
9931    ///
9932    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
9933    ///   different `Node` channel, to prove that the client obtained the handle
9934    ///   from this `Node`.
9935    pub fn r#get_node_ref(
9936        &self,
9937    ) -> fidl::client::QueryResponseFut<
9938        NodeGetNodeRefResponse,
9939        fdomain_client::fidl::FDomainResourceDialect,
9940    > {
9941        NodeProxyInterface::r#get_node_ref(self)
9942    }
9943
9944    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
9945    /// rooted at a different child token of a common parent
9946    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
9947    /// passed-in `node_ref`.
9948    ///
9949    /// This call is for assisting with admission control de-duplication, and
9950    /// with debugging.
9951    ///
9952    /// The `node_ref` must be obtained using
9953    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
9954    ///
9955    /// The `node_ref` can be a duplicated handle; it's not necessary to call
9956    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
9957    ///
9958    /// If a calling token may not actually be a valid token at all due to a
9959    /// potentially hostile/untrusted provider of the token, call
9960    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
9961    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
9962    /// never responds due to a calling token not being a real token (not really
9963    /// talking to sysmem).  Another option is to call
9964    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
9965    /// which also validates the token along with converting it to a
9966    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
9967    ///
9968    /// All table fields are currently required.
9969    ///
9970    /// - response `is_alternate`
9971    ///   - true: The first parent node in common between the calling node and
9972    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
9973    ///     that the calling `Node` and the `node_ref` `Node` will not have both
9974    ///     their constraints apply - rather sysmem will choose one or the other
9975    ///     of the constraints - never both.  This is because only one child of
9976    ///     a `BufferCollectionTokenGroup` is selected during logical
9977    ///     allocation, with only that one child's subtree contributing to
9978    ///     constraints aggregation.
9979    ///   - false: The first parent node in common between the calling `Node`
9980    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
9981    ///     Currently, this means the first parent node in common is a
9982    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
9983    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
9984    ///     `Node` may have both their constraints apply during constraints
9985    ///     aggregation of the logical allocation, if both `Node`(s) are
9986    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
9987    ///     this case, there is no `BufferCollectionTokenGroup` that will
9988    ///     directly prevent the two `Node`(s) from both being selected and
9989    ///     their constraints both aggregated, but even when false, one or both
9990    ///     `Node`(s) may still be eliminated from consideration if one or both
9991    ///     `Node`(s) has a direct or indirect parent
9992    ///     `BufferCollectionTokenGroup` which selects a child subtree other
9993    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
9994    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
9995    ///   associated with the same buffer collection as the calling `Node`.
9996    ///   Another reason for this error is if the `node_ref` is an
9997    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
9998    ///   a real `node_ref` obtained from `GetNodeRef`.
9999    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
10000    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
10001    ///   the needed rights expected on a real `node_ref`.
10002    /// * No other failing status codes are returned by this call.  However,
10003    ///   sysmem may add additional codes in future, so the client should have
10004    ///   sensible default handling for any failing status code.
10005    pub fn r#is_alternate_for(
10006        &self,
10007        mut payload: NodeIsAlternateForRequest,
10008    ) -> fidl::client::QueryResponseFut<
10009        NodeIsAlternateForResult,
10010        fdomain_client::fidl::FDomainResourceDialect,
10011    > {
10012        NodeProxyInterface::r#is_alternate_for(self, payload)
10013    }
10014
10015    /// Get the buffer collection ID. This ID is also available from
10016    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
10017    /// within the collection).
10018    ///
10019    /// This call is mainly useful in situations where we can't convey a
10020    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
10021    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
10022    /// handle, which can be joined back up with a `BufferCollection` client end
10023    /// that was created via a different path. Prefer to convey a
10024    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
10025    ///
10026    /// Trusting a `buffer_collection_id` value from a source other than sysmem
10027    /// is analogous to trusting a koid value from a source other than zircon.
10028    /// Both should be avoided unless really necessary, and both require
10029    /// caution. In some situations it may be reasonable to refer to a
10030    /// pre-established `BufferCollection` by `buffer_collection_id` via a
10031    /// protocol for efficiency reasons, but an incoming value purporting to be
10032    /// a `buffer_collection_id` is not sufficient alone to justify granting the
10033    /// sender of the `buffer_collection_id` any capability. The sender must
10034    /// first prove to a receiver that the sender has/had a VMO or has/had a
10035    /// `BufferCollectionToken` to the same collection by sending a handle that
10036    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
10037    /// `buffer_collection_id` value. The receiver should take care to avoid
10038    /// assuming that a sender had a `BufferCollectionToken` in cases where the
10039    /// sender has only proven that the sender had a VMO.
10040    ///
10041    /// - response `buffer_collection_id` This ID is unique per buffer
10042    ///   collection per boot. Each buffer is uniquely identified by the
10043    ///   `buffer_collection_id` and `buffer_index` together.
10044    pub fn r#get_buffer_collection_id(
10045        &self,
10046    ) -> fidl::client::QueryResponseFut<
10047        NodeGetBufferCollectionIdResponse,
10048        fdomain_client::fidl::FDomainResourceDialect,
10049    > {
10050        NodeProxyInterface::r#get_buffer_collection_id(self)
10051    }
10052
10053    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
10054    /// created after this message to weak, which means that a client's `Node`
10055    /// client end (or a child created after this message) is not alone
10056    /// sufficient to keep allocated VMOs alive.
10057    ///
10058    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
10059    /// `close_weak_asap`.
10060    ///
10061    /// This message is only permitted before the `Node` becomes ready for
10062    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
10063    ///   * `BufferCollectionToken`: any time
10064    ///   * `BufferCollection`: before `SetConstraints`
10065    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
10066    ///
10067    /// Currently, no conversion from strong `Node` to weak `Node` after ready
10068    /// for allocation is provided, but a client can simulate that by creating
10069    /// an additional `Node` before allocation and setting that additional
10070    /// `Node` to weak, and then potentially at some point later sending
10071    /// `Release` and closing the client end of the client's strong `Node`, but
10072    /// keeping the client's weak `Node`.
10073    ///
10074    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
10075    /// collection failure (all `Node` client end(s) will see
10076    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
10077    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
10078    /// this situation until all `Node`(s) are ready for allocation. For initial
10079    /// allocation to succeed, at least one strong `Node` is required to exist
10080    /// at allocation time, but after that client receives VMO handles, that
10081    /// client can `BufferCollection.Release` and close the client end without
10082    /// causing this type of failure.
10083    ///
10084    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
10085    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
10086    /// separately as appropriate.
10087    pub fn r#set_weak(&self) -> Result<(), fidl::Error> {
10088        NodeProxyInterface::r#set_weak(self)
10089    }
10090
10091    /// This indicates to sysmem that the client is prepared to pay attention to
10092    /// `close_weak_asap`.
10093    ///
10094    /// If sent, this message must be before
10095    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
10096    ///
10097    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
10098    /// send this message before `WaitForAllBuffersAllocated`, or a parent
10099    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
10100    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
10101    /// trigger buffer collection failure.
10102    ///
10103    /// This message is necessary because weak sysmem VMOs have not always been
10104    /// a thing, so older clients are not aware of the need to pay attention to
10105    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
10106    /// sysmem weak VMO handles asap. By having this message and requiring
10107    /// participants to indicate their acceptance of this aspect of the overall
10108    /// protocol, we avoid situations where an older client is delivered a weak
10109    /// VMO without any way for sysmem to get that VMO to close quickly later
10110    /// (and on a per-buffer basis).
10111    ///
10112    /// A participant that doesn't handle `close_weak_asap` and also doesn't
10113    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
10114    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
10115    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
10116    /// same participant has a child/delegate which does retrieve VMOs, that
10117    /// child/delegate will need to send `SetWeakOk` before
10118    /// `WaitForAllBuffersAllocated`.
10119    ///
10120    /// + request `for_child_nodes_also` If present and true, this means direct
10121    ///   child nodes of this node created after this message plus all
10122    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
10123    ///   those nodes. Any child node of this node that was created before this
10124    ///   message is not included. This setting is "sticky" in the sense that a
10125    ///   subsequent `SetWeakOk` without this bool set to true does not reset
10126    ///   the server-side bool. If this creates a problem for a participant, a
10127    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
10128    ///   tokens instead, as appropriate. A participant should only set
10129    ///   `for_child_nodes_also` true if the participant can really promise to
10130    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
10131    ///   weak VMO handles held by participants holding the corresponding child
10132    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
10133    ///   which are using sysmem(1) can be weak, despite the clients of those
10134    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
10135    ///   direct way to find out about `close_weak_asap`. This only applies to
10136    ///   descendents of this `Node` which are using sysmem(1), not to this
10137    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
10138    ///   token, which will fail allocation unless an ancestor of this `Node`
10139    ///   specified `for_child_nodes_also` true.
10140    pub fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
10141        NodeProxyInterface::r#set_weak_ok(self, payload)
10142    }
10143
10144    /// The server_end will be closed after this `Node` and any child nodes have
10145    /// have released their buffer counts, making those counts available for
10146    /// reservation by a different `Node` via
10147    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
10148    ///
10149    /// The `Node` buffer counts may not be released until the entire tree of
10150    /// `Node`(s) is closed or failed, because
10151    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
10152    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
10153    /// `Node` buffer counts remain reserved until the orphaned node is later
10154    /// cleaned up.
10155    ///
10156    /// If the `Node` exceeds a fairly large number of attached eventpair server
10157    /// ends, a log message will indicate this and the `Node` (and the
10158    /// appropriate) sub-tree will fail.
10159    ///
10160    /// The `server_end` will remain open when
10161    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
10162    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
10163    /// [`fuchsia.sysmem2/BufferCollection`].
10164    ///
10165    /// This message can also be used with a
10166    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
10167    pub fn r#attach_node_tracking(
10168        &self,
10169        mut payload: NodeAttachNodeTrackingRequest,
10170    ) -> Result<(), fidl::Error> {
10171        NodeProxyInterface::r#attach_node_tracking(self, payload)
10172    }
10173}
10174
10175impl NodeProxyInterface for NodeProxy {
10176    type SyncResponseFut =
10177        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10178    fn r#sync(&self) -> Self::SyncResponseFut {
10179        fn _decode(
10180            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10181        ) -> Result<(), fidl::Error> {
10182            let _response = fidl::client::decode_transaction_body::<
10183                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
10184                fdomain_client::fidl::FDomainResourceDialect,
10185                0x11ac2555cf575b54,
10186            >(_buf?)?
10187            .into_result_fdomain::<NodeMarker>("sync")?;
10188            Ok(_response)
10189        }
10190        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
10191            (),
10192            0x11ac2555cf575b54,
10193            fidl::encoding::DynamicFlags::FLEXIBLE,
10194            _decode,
10195        )
10196    }
10197
10198    fn r#release(&self) -> Result<(), fidl::Error> {
10199        self.client.send::<fidl::encoding::EmptyPayload>(
10200            (),
10201            0x6a5cae7d6d6e04c6,
10202            fidl::encoding::DynamicFlags::FLEXIBLE,
10203        )
10204    }
10205
10206    fn r#set_name(&self, mut payload: &NodeSetNameRequest) -> Result<(), fidl::Error> {
10207        self.client.send::<NodeSetNameRequest>(
10208            payload,
10209            0xb41f1624f48c1e9,
10210            fidl::encoding::DynamicFlags::FLEXIBLE,
10211        )
10212    }
10213
10214    fn r#set_debug_client_info(
10215        &self,
10216        mut payload: &NodeSetDebugClientInfoRequest,
10217    ) -> Result<(), fidl::Error> {
10218        self.client.send::<NodeSetDebugClientInfoRequest>(
10219            payload,
10220            0x5cde8914608d99b1,
10221            fidl::encoding::DynamicFlags::FLEXIBLE,
10222        )
10223    }
10224
10225    fn r#set_debug_timeout_log_deadline(
10226        &self,
10227        mut payload: &NodeSetDebugTimeoutLogDeadlineRequest,
10228    ) -> Result<(), fidl::Error> {
10229        self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
10230            payload,
10231            0x716b0af13d5c0806,
10232            fidl::encoding::DynamicFlags::FLEXIBLE,
10233        )
10234    }
10235
10236    fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
10237        self.client.send::<fidl::encoding::EmptyPayload>(
10238            (),
10239            0x5209c77415b4dfad,
10240            fidl::encoding::DynamicFlags::FLEXIBLE,
10241        )
10242    }
10243
10244    type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
10245        NodeGetNodeRefResponse,
10246        fdomain_client::fidl::FDomainResourceDialect,
10247    >;
10248    fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
10249        fn _decode(
10250            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10251        ) -> Result<NodeGetNodeRefResponse, fidl::Error> {
10252            let _response = fidl::client::decode_transaction_body::<
10253                fidl::encoding::FlexibleType<NodeGetNodeRefResponse>,
10254                fdomain_client::fidl::FDomainResourceDialect,
10255                0x5b3d0e51614df053,
10256            >(_buf?)?
10257            .into_result_fdomain::<NodeMarker>("get_node_ref")?;
10258            Ok(_response)
10259        }
10260        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, NodeGetNodeRefResponse>(
10261            (),
10262            0x5b3d0e51614df053,
10263            fidl::encoding::DynamicFlags::FLEXIBLE,
10264            _decode,
10265        )
10266    }
10267
10268    type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
10269        NodeIsAlternateForResult,
10270        fdomain_client::fidl::FDomainResourceDialect,
10271    >;
10272    fn r#is_alternate_for(
10273        &self,
10274        mut payload: NodeIsAlternateForRequest,
10275    ) -> Self::IsAlternateForResponseFut {
10276        fn _decode(
10277            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10278        ) -> Result<NodeIsAlternateForResult, fidl::Error> {
10279            let _response = fidl::client::decode_transaction_body::<
10280                fidl::encoding::FlexibleResultType<NodeIsAlternateForResponse, Error>,
10281                fdomain_client::fidl::FDomainResourceDialect,
10282                0x3a58e00157e0825,
10283            >(_buf?)?
10284            .into_result_fdomain::<NodeMarker>("is_alternate_for")?;
10285            Ok(_response.map(|x| x))
10286        }
10287        self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
10288            &mut payload,
10289            0x3a58e00157e0825,
10290            fidl::encoding::DynamicFlags::FLEXIBLE,
10291            _decode,
10292        )
10293    }
10294
10295    type GetBufferCollectionIdResponseFut = fidl::client::QueryResponseFut<
10296        NodeGetBufferCollectionIdResponse,
10297        fdomain_client::fidl::FDomainResourceDialect,
10298    >;
10299    fn r#get_buffer_collection_id(&self) -> Self::GetBufferCollectionIdResponseFut {
10300        fn _decode(
10301            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10302        ) -> Result<NodeGetBufferCollectionIdResponse, fidl::Error> {
10303            let _response = fidl::client::decode_transaction_body::<
10304                fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>,
10305                fdomain_client::fidl::FDomainResourceDialect,
10306                0x77d19a494b78ba8c,
10307            >(_buf?)?
10308            .into_result_fdomain::<NodeMarker>("get_buffer_collection_id")?;
10309            Ok(_response)
10310        }
10311        self.client.send_query_and_decode::<
10312            fidl::encoding::EmptyPayload,
10313            NodeGetBufferCollectionIdResponse,
10314        >(
10315            (),
10316            0x77d19a494b78ba8c,
10317            fidl::encoding::DynamicFlags::FLEXIBLE,
10318            _decode,
10319        )
10320    }
10321
10322    fn r#set_weak(&self) -> Result<(), fidl::Error> {
10323        self.client.send::<fidl::encoding::EmptyPayload>(
10324            (),
10325            0x22dd3ea514eeffe1,
10326            fidl::encoding::DynamicFlags::FLEXIBLE,
10327        )
10328    }
10329
10330    fn r#set_weak_ok(&self, mut payload: NodeSetWeakOkRequest) -> Result<(), fidl::Error> {
10331        self.client.send::<NodeSetWeakOkRequest>(
10332            &mut payload,
10333            0x38a44fc4d7724be9,
10334            fidl::encoding::DynamicFlags::FLEXIBLE,
10335        )
10336    }
10337
10338    fn r#attach_node_tracking(
10339        &self,
10340        mut payload: NodeAttachNodeTrackingRequest,
10341    ) -> Result<(), fidl::Error> {
10342        self.client.send::<NodeAttachNodeTrackingRequest>(
10343            &mut payload,
10344            0x3f22f2a293d3cdac,
10345            fidl::encoding::DynamicFlags::FLEXIBLE,
10346        )
10347    }
10348}
10349
10350pub struct NodeEventStream {
10351    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10352}
10353
10354impl std::marker::Unpin for NodeEventStream {}
10355
10356impl futures::stream::FusedStream for NodeEventStream {
10357    fn is_terminated(&self) -> bool {
10358        self.event_receiver.is_terminated()
10359    }
10360}
10361
10362impl futures::Stream for NodeEventStream {
10363    type Item = Result<NodeEvent, fidl::Error>;
10364
10365    fn poll_next(
10366        mut self: std::pin::Pin<&mut Self>,
10367        cx: &mut std::task::Context<'_>,
10368    ) -> std::task::Poll<Option<Self::Item>> {
10369        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10370            &mut self.event_receiver,
10371            cx
10372        )?) {
10373            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
10374            None => std::task::Poll::Ready(None),
10375        }
10376    }
10377}
10378
10379#[derive(Debug)]
10380pub enum NodeEvent {
10381    #[non_exhaustive]
10382    _UnknownEvent {
10383        /// Ordinal of the event that was sent.
10384        ordinal: u64,
10385    },
10386}
10387
10388impl NodeEvent {
10389    /// Decodes a message buffer as a [`NodeEvent`].
10390    fn decode(
10391        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10392    ) -> Result<NodeEvent, fidl::Error> {
10393        let (bytes, _handles) = buf.split_mut();
10394        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10395        debug_assert_eq!(tx_header.tx_id, 0);
10396        match tx_header.ordinal {
10397            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
10398                Ok(NodeEvent::_UnknownEvent { ordinal: tx_header.ordinal })
10399            }
10400            _ => Err(fidl::Error::UnknownOrdinal {
10401                ordinal: tx_header.ordinal,
10402                protocol_name: <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10403            }),
10404        }
10405    }
10406}
10407
10408/// A Stream of incoming requests for fuchsia.sysmem2/Node.
10409pub struct NodeRequestStream {
10410    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10411    is_terminated: bool,
10412}
10413
10414impl std::marker::Unpin for NodeRequestStream {}
10415
10416impl futures::stream::FusedStream for NodeRequestStream {
10417    fn is_terminated(&self) -> bool {
10418        self.is_terminated
10419    }
10420}
10421
10422impl fdomain_client::fidl::RequestStream for NodeRequestStream {
10423    type Protocol = NodeMarker;
10424    type ControlHandle = NodeControlHandle;
10425
10426    fn from_channel(channel: fdomain_client::Channel) -> Self {
10427        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10428    }
10429
10430    fn control_handle(&self) -> Self::ControlHandle {
10431        NodeControlHandle { inner: self.inner.clone() }
10432    }
10433
10434    fn into_inner(
10435        self,
10436    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10437    {
10438        (self.inner, self.is_terminated)
10439    }
10440
10441    fn from_inner(
10442        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10443        is_terminated: bool,
10444    ) -> Self {
10445        Self { inner, is_terminated }
10446    }
10447}
10448
10449impl futures::Stream for NodeRequestStream {
10450    type Item = Result<NodeRequest, fidl::Error>;
10451
10452    fn poll_next(
10453        mut self: std::pin::Pin<&mut Self>,
10454        cx: &mut std::task::Context<'_>,
10455    ) -> std::task::Poll<Option<Self::Item>> {
10456        let this = &mut *self;
10457        if this.inner.check_shutdown(cx) {
10458            this.is_terminated = true;
10459            return std::task::Poll::Ready(None);
10460        }
10461        if this.is_terminated {
10462            panic!("polled NodeRequestStream after completion");
10463        }
10464        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10465            |bytes, handles| {
10466                match this.inner.channel().read_etc(cx, bytes, handles) {
10467                    std::task::Poll::Ready(Ok(())) => {}
10468                    std::task::Poll::Pending => return std::task::Poll::Pending,
10469                    std::task::Poll::Ready(Err(None)) => {
10470                        this.is_terminated = true;
10471                        return std::task::Poll::Ready(None);
10472                    }
10473                    std::task::Poll::Ready(Err(Some(e))) => {
10474                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10475                            e.into(),
10476                        ))));
10477                    }
10478                }
10479
10480                // A message has been received from the channel
10481                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10482
10483                std::task::Poll::Ready(Some(match header.ordinal {
10484                    0x11ac2555cf575b54 => {
10485                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10486                        let mut req = fidl::new_empty!(
10487                            fidl::encoding::EmptyPayload,
10488                            fdomain_client::fidl::FDomainResourceDialect
10489                        );
10490                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10491                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10492                        Ok(NodeRequest::Sync {
10493                            responder: NodeSyncResponder {
10494                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10495                                tx_id: header.tx_id,
10496                            },
10497                        })
10498                    }
10499                    0x6a5cae7d6d6e04c6 => {
10500                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10501                        let mut req = fidl::new_empty!(
10502                            fidl::encoding::EmptyPayload,
10503                            fdomain_client::fidl::FDomainResourceDialect
10504                        );
10505                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10506                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10507                        Ok(NodeRequest::Release { control_handle })
10508                    }
10509                    0xb41f1624f48c1e9 => {
10510                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10511                        let mut req = fidl::new_empty!(
10512                            NodeSetNameRequest,
10513                            fdomain_client::fidl::FDomainResourceDialect
10514                        );
10515                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
10516                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10517                        Ok(NodeRequest::SetName { payload: req, control_handle })
10518                    }
10519                    0x5cde8914608d99b1 => {
10520                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10521                        let mut req = fidl::new_empty!(
10522                            NodeSetDebugClientInfoRequest,
10523                            fdomain_client::fidl::FDomainResourceDialect
10524                        );
10525                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
10526                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10527                        Ok(NodeRequest::SetDebugClientInfo { payload: req, control_handle })
10528                    }
10529                    0x716b0af13d5c0806 => {
10530                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10531                        let mut req = fidl::new_empty!(
10532                            NodeSetDebugTimeoutLogDeadlineRequest,
10533                            fdomain_client::fidl::FDomainResourceDialect
10534                        );
10535                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
10536                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10537                        Ok(NodeRequest::SetDebugTimeoutLogDeadline { payload: req, control_handle })
10538                    }
10539                    0x5209c77415b4dfad => {
10540                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10541                        let mut req = fidl::new_empty!(
10542                            fidl::encoding::EmptyPayload,
10543                            fdomain_client::fidl::FDomainResourceDialect
10544                        );
10545                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10546                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10547                        Ok(NodeRequest::SetVerboseLogging { control_handle })
10548                    }
10549                    0x5b3d0e51614df053 => {
10550                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10551                        let mut req = fidl::new_empty!(
10552                            fidl::encoding::EmptyPayload,
10553                            fdomain_client::fidl::FDomainResourceDialect
10554                        );
10555                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10556                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10557                        Ok(NodeRequest::GetNodeRef {
10558                            responder: NodeGetNodeRefResponder {
10559                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10560                                tx_id: header.tx_id,
10561                            },
10562                        })
10563                    }
10564                    0x3a58e00157e0825 => {
10565                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10566                        let mut req = fidl::new_empty!(
10567                            NodeIsAlternateForRequest,
10568                            fdomain_client::fidl::FDomainResourceDialect
10569                        );
10570                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
10571                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10572                        Ok(NodeRequest::IsAlternateFor {
10573                            payload: req,
10574                            responder: NodeIsAlternateForResponder {
10575                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10576                                tx_id: header.tx_id,
10577                            },
10578                        })
10579                    }
10580                    0x77d19a494b78ba8c => {
10581                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10582                        let mut req = fidl::new_empty!(
10583                            fidl::encoding::EmptyPayload,
10584                            fdomain_client::fidl::FDomainResourceDialect
10585                        );
10586                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10587                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10588                        Ok(NodeRequest::GetBufferCollectionId {
10589                            responder: NodeGetBufferCollectionIdResponder {
10590                                control_handle: std::mem::ManuallyDrop::new(control_handle),
10591                                tx_id: header.tx_id,
10592                            },
10593                        })
10594                    }
10595                    0x22dd3ea514eeffe1 => {
10596                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10597                        let mut req = fidl::new_empty!(
10598                            fidl::encoding::EmptyPayload,
10599                            fdomain_client::fidl::FDomainResourceDialect
10600                        );
10601                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10602                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10603                        Ok(NodeRequest::SetWeak { control_handle })
10604                    }
10605                    0x38a44fc4d7724be9 => {
10606                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10607                        let mut req = fidl::new_empty!(
10608                            NodeSetWeakOkRequest,
10609                            fdomain_client::fidl::FDomainResourceDialect
10610                        );
10611                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetWeakOkRequest>(&header, _body_bytes, handles, &mut req)?;
10612                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10613                        Ok(NodeRequest::SetWeakOk { payload: req, control_handle })
10614                    }
10615                    0x3f22f2a293d3cdac => {
10616                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10617                        let mut req = fidl::new_empty!(
10618                            NodeAttachNodeTrackingRequest,
10619                            fdomain_client::fidl::FDomainResourceDialect
10620                        );
10621                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeAttachNodeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
10622                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
10623                        Ok(NodeRequest::AttachNodeTracking { payload: req, control_handle })
10624                    }
10625                    _ if header.tx_id == 0
10626                        && header
10627                            .dynamic_flags()
10628                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
10629                    {
10630                        Ok(NodeRequest::_UnknownMethod {
10631                            ordinal: header.ordinal,
10632                            control_handle: NodeControlHandle { inner: this.inner.clone() },
10633                            method_type: fidl::MethodType::OneWay,
10634                        })
10635                    }
10636                    _ if header
10637                        .dynamic_flags()
10638                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
10639                    {
10640                        this.inner.send_framework_err(
10641                            fidl::encoding::FrameworkErr::UnknownMethod,
10642                            header.tx_id,
10643                            header.ordinal,
10644                            header.dynamic_flags(),
10645                            (bytes, handles),
10646                        )?;
10647                        Ok(NodeRequest::_UnknownMethod {
10648                            ordinal: header.ordinal,
10649                            control_handle: NodeControlHandle { inner: this.inner.clone() },
10650                            method_type: fidl::MethodType::TwoWay,
10651                        })
10652                    }
10653                    _ => Err(fidl::Error::UnknownOrdinal {
10654                        ordinal: header.ordinal,
10655                        protocol_name:
10656                            <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10657                    }),
10658                }))
10659            },
10660        )
10661    }
10662}
10663
10664/// This protocol is the parent protocol for all nodes in the tree established
10665/// by [`fuchsia.sysmem2/BufferCollectionToken`] creation and
10666/// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] creation, including
10667/// [`fuchsia.sysmem2/BufferCollectionToken`](s) which have since been converted
10668/// to a [`fuchsia.sysmem2/BufferCollection`] channel.
10669///
10670/// Epitaphs are not used in this protocol.
10671#[derive(Debug)]
10672pub enum NodeRequest {
10673    /// Ensure that previous messages have been received server side. This is
10674    /// particularly useful after previous messages that created new tokens,
10675    /// because a token must be known to the sysmem server before sending the
10676    /// token to another participant.
10677    ///
10678    /// Calling [`fuchsia.sysmem2/BufferCollectionToken.Sync`] on a token that
10679    /// isn't/wasn't a valid token risks the `Sync` stalling forever. See
10680    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] for one way
10681    /// to mitigate the possibility of a hostile/fake
10682    /// [`fuchsia.sysmem2/BufferCollectionToken`] at the cost of one round trip.
10683    /// Another way is to pass the token to
10684    /// [`fuchsia.sysmem2/Allocator/BindSharedCollection`], which also validates
10685    /// the token as part of exchanging it for a
10686    /// [`fuchsia.sysmem2/BufferCollection`] channel, and
10687    /// [`fuchsia.sysmem2/BufferCollection.Sync`] can then be used without risk
10688    /// of stalling.
10689    ///
10690    /// After creating one or more [`fuchsia.sysmem2/BufferCollectionToken`](s)
10691    /// and then starting and completing a `Sync`, it's then safe to send the
10692    /// `BufferCollectionToken` client ends to other participants knowing the
10693    /// server will recognize the tokens when they're sent by the other
10694    /// participants to sysmem in a
10695    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] message. This is an
10696    /// efficient way to create tokens while avoiding unnecessary round trips.
10697    ///
10698    /// Other options include waiting for each
10699    /// [`fuchsia.sysmem2/BufferCollectionToken.Duplicate`] to complete
10700    /// individually (using separate call to `Sync` after each), or calling
10701    /// [`fuchsia.sysmem2/BufferCollection.Sync`] after a token has been
10702    /// converted to a `BufferCollection` via
10703    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`], or using
10704    /// [`fuchsia.sysmem2/BufferCollectionToken.DuplicateSync`] which includes
10705    /// the sync step and can create multiple tokens at once.
10706    Sync { responder: NodeSyncResponder },
10707    /// ###### On a [`fuchsia.sysmem2/BufferCollectionToken`] channel:
10708    ///
10709    /// Normally a participant will convert a `BufferCollectionToken` into a
10710    /// [`fuchsia.sysmem2/BufferCollection`], but a participant can instead send
10711    /// `Release` via the token (and then close the channel immediately or
10712    /// shortly later in response to server closing the server end), which
10713    /// avoids causing buffer collection failure. Without a prior `Release`,
10714    /// closing the `BufferCollectionToken` client end will cause buffer
10715    /// collection failure.
10716    ///
10717    /// ###### On a [`fuchsia.sysmem2/BufferCollection`] channel:
10718    ///
10719    /// By default the server handles unexpected closure of a
10720    /// [`fuchsia.sysmem2/BufferCollection`] client end (without `Release`
10721    /// first) by failing the buffer collection. Partly this is to expedite
10722    /// closing VMO handles to reclaim memory when any participant fails. If a
10723    /// participant would like to cleanly close a `BufferCollection` without
10724    /// causing buffer collection failure, the participant can send `Release`
10725    /// before closing the `BufferCollection` client end. The `Release` can
10726    /// occur before or after `SetConstraints`. If before `SetConstraints`, the
10727    /// buffer collection won't require constraints from this node in order to
10728    /// allocate. If after `SetConstraints`, the constraints are retained and
10729    /// aggregated, despite the lack of `BufferCollection` connection at the
10730    /// time of constraints aggregation.
10731    ///
10732    /// ###### On a [`fuchsia.sysmem2/BufferCollectionTokenGroup`] channel:
10733    ///
10734    /// By default, unexpected closure of a `BufferCollectionTokenGroup` client
10735    /// end (without `Release` first) will trigger failure of the buffer
10736    /// collection. To close a `BufferCollectionTokenGroup` channel without
10737    /// failing the buffer collection, ensure that AllChildrenPresent() has been
10738    /// sent, and send `Release` before closing the `BufferCollectionTokenGroup`
10739    /// client end.
10740    ///
10741    /// If `Release` occurs before
10742    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup.AllChildrenPresent], the
10743    /// buffer collection will fail (triggered by reception of `Release` without
10744    /// prior `AllChildrenPresent`). This is intentionally not analogous to how
10745    /// [`fuchsia.sysmem2/BufferCollection.Release`] without
10746    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] first doesn't cause
10747    /// buffer collection failure. For a `BufferCollectionTokenGroup`, clean
10748    /// close requires `AllChildrenPresent` (if not already sent), then
10749    /// `Release`, then close client end.
10750    ///
10751    /// If `Release` occurs after `AllChildrenPresent`, the children and all
10752    /// their constraints remain intact (just as they would if the
10753    /// `BufferCollectionTokenGroup` channel had remained open), and the client
10754    /// end close doesn't trigger buffer collection failure.
10755    ///
10756    /// ###### On all [`fuchsia.sysmem2/Node`] channels (any of the above):
10757    ///
10758    /// For brevity, the per-channel-protocol paragraphs above ignore the
10759    /// separate failure domain created by
10760    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`] or
10761    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`]. When a client end
10762    /// unexpectedly closes (without `Release` first) and that client end is
10763    /// under a failure domain, instead of failing the whole buffer collection,
10764    /// the failure domain is failed, but the buffer collection itself is
10765    /// isolated from failure of the failure domain. Such failure domains can be
10766    /// nested, in which case only the inner-most failure domain in which the
10767    /// `Node` resides fails.
10768    Release { control_handle: NodeControlHandle },
10769    /// Set a name for VMOs in this buffer collection.
10770    ///
10771    /// If the name doesn't fit in ZX_MAX_NAME_LEN, the name of the vmo itself
10772    /// will be truncated to fit. The name of the vmo will be suffixed with the
10773    /// buffer index within the collection (if the suffix fits within
10774    /// ZX_MAX_NAME_LEN). The name specified here (without truncation) will be
10775    /// listed in the inspect data.
10776    ///
10777    /// The name only affects VMOs allocated after the name is set; this call
10778    /// does not rename existing VMOs. If multiple clients set different names
10779    /// then the larger priority value will win. Setting a new name with the
10780    /// same priority as a prior name doesn't change the name.
10781    ///
10782    /// All table fields are currently required.
10783    ///
10784    /// + request `priority` The name is only set if this is the first `SetName`
10785    ///   or if `priority` is greater than any previous `priority` value in
10786    ///   prior `SetName` calls across all `Node`(s) of this buffer collection.
10787    /// + request `name` The name for VMOs created under this buffer collection.
10788    SetName { payload: NodeSetNameRequest, control_handle: NodeControlHandle },
10789    /// Set information about the current client that can be used by sysmem to
10790    /// help diagnose leaking memory and allocation stalls waiting for a
10791    /// participant to send [`fuchsia.sysmem2/BufferCollection.SetConstraints`].
10792    ///
10793    /// This sets the debug client info on this [`fuchsia.sysmem2/Node`] and all
10794    /// `Node`(s) derived from this `Node`, unless overriden by
10795    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] or a later
10796    /// [`fuchsia.sysmem2/Node.SetDebugClientInfo`].
10797    ///
10798    /// Sending [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`] once per
10799    /// `Allocator` is the most efficient way to ensure that all
10800    /// [`fuchsia.sysmem2/Node`](s) will have at least some debug client info
10801    /// set, and is also more efficient than separately sending the same debug
10802    /// client info via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] for each
10803    /// created [`fuchsia.sysmem2/Node`].
10804    ///
10805    /// Also used when verbose logging is enabled (see `SetVerboseLogging`) to
10806    /// indicate which client is closing their channel first, leading to subtree
10807    /// failure (which can be normal if the purpose of the subtree is over, but
10808    /// if happening earlier than expected, the client-channel-specific name can
10809    /// help diagnose where the failure is first coming from, from sysmem's
10810    /// point of view).
10811    ///
10812    /// All table fields are currently required.
10813    ///
10814    /// + request `name` This can be an arbitrary string, but the current
10815    ///   process name (see `fsl::GetCurrentProcessName`) is a good default.
10816    /// + request `id` This can be an arbitrary id, but the current process ID
10817    ///   (see `fsl::GetCurrentProcessKoid`) is a good default.
10818    SetDebugClientInfo { payload: NodeSetDebugClientInfoRequest, control_handle: NodeControlHandle },
10819    /// Sysmem logs a warning if sysmem hasn't seen
10820    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from all clients
10821    /// within 5 seconds after creation of a new collection.
10822    ///
10823    /// Clients can call this method to change when the log is printed. If
10824    /// multiple client set the deadline, it's unspecified which deadline will
10825    /// take effect.
10826    ///
10827    /// In most cases the default works well.
10828    ///
10829    /// All table fields are currently required.
10830    ///
10831    /// + request `deadline` The time at which sysmem will start trying to log
10832    ///   the warning, unless all constraints are with sysmem by then.
10833    SetDebugTimeoutLogDeadline {
10834        payload: NodeSetDebugTimeoutLogDeadlineRequest,
10835        control_handle: NodeControlHandle,
10836    },
10837    /// This enables verbose logging for the buffer collection.
10838    ///
10839    /// Verbose logging includes constraints set via
10840    /// [`fuchsia.sysmem2/BufferCollection.SetConstraints`] from each client
10841    /// along with info set via [`fuchsia.sysmem2/Node.SetDebugClientInfo`] (or
10842    /// [`fuchsia.sysmem2/Allocator.SetDebugClientInfo`]) and the structure of
10843    /// the tree of `Node`(s).
10844    ///
10845    /// Normally sysmem prints only a single line complaint when aggregation
10846    /// fails, with just the specific detailed reason that aggregation failed,
10847    /// with little surrounding context.  While this is often enough to diagnose
10848    /// a problem if only a small change was made and everything was working
10849    /// before the small change, it's often not particularly helpful for getting
10850    /// a new buffer collection to work for the first time.  Especially with
10851    /// more complex trees of nodes, involving things like
10852    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`],
10853    /// [`fuchsia.sysmem2/BufferCollectionToken.SetDispensable`],
10854    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`] nodes, and associated
10855    /// subtrees of nodes, verbose logging may help in diagnosing what the tree
10856    /// looks like and why it's failing a logical allocation, or why a tree or
10857    /// subtree is failing sooner than expected.
10858    ///
10859    /// The intent of the extra logging is to be acceptable from a performance
10860    /// point of view, under the assumption that verbose logging is only enabled
10861    /// on a low number of buffer collections. If we're not tracking down a bug,
10862    /// we shouldn't send this message.
10863    SetVerboseLogging { control_handle: NodeControlHandle },
10864    /// This gets a handle that can be used as a parameter to
10865    /// [`fuchsia.sysmem2/Node.IsAlternateFor`] called on any
10866    /// [`fuchsia.sysmem2/Node`]. This handle is only for use as proof that the
10867    /// client obtained this handle from this `Node`.
10868    ///
10869    /// Because this is a get not a set, no [`fuchsia.sysmem2/Node.Sync`] is
10870    /// needed between the `GetNodeRef` and the call to `IsAlternateFor`,
10871    /// despite the two calls typically being on different channels.
10872    ///
10873    /// See also [`fuchsia.sysmem2/Node.IsAlternateFor`].
10874    ///
10875    /// All table fields are currently required.
10876    ///
10877    /// - response `node_ref` This handle can be sent via `IsAlternateFor` on a
10878    ///   different `Node` channel, to prove that the client obtained the handle
10879    ///   from this `Node`.
10880    GetNodeRef { responder: NodeGetNodeRefResponder },
10881    /// Check whether the calling [`fuchsia.sysmem2/Node`] is in a subtree
10882    /// rooted at a different child token of a common parent
10883    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`], in relation to the
10884    /// passed-in `node_ref`.
10885    ///
10886    /// This call is for assisting with admission control de-duplication, and
10887    /// with debugging.
10888    ///
10889    /// The `node_ref` must be obtained using
10890    /// [`fuchsia.sysmem2/Node.GetNodeRef`].
10891    ///
10892    /// The `node_ref` can be a duplicated handle; it's not necessary to call
10893    /// `GetNodeRef` for every call to [`fuchsia.sysmem2/Node.IsAlternateFor`].
10894    ///
10895    /// If a calling token may not actually be a valid token at all due to a
10896    /// potentially hostile/untrusted provider of the token, call
10897    /// [`fuchsia.sysmem2/Allocator.ValidateBufferCollectionToken`] first
10898    /// instead of potentially getting stuck indefinitely if `IsAlternateFor`
10899    /// never responds due to a calling token not being a real token (not really
10900    /// talking to sysmem).  Another option is to call
10901    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] with this token first
10902    /// which also validates the token along with converting it to a
10903    /// [`fuchsia.sysmem2/BufferCollection`], then call `IsAlternateFor`.
10904    ///
10905    /// All table fields are currently required.
10906    ///
10907    /// - response `is_alternate`
10908    ///   - true: The first parent node in common between the calling node and
10909    ///     the `node_ref` `Node` is a `BufferCollectionTokenGroup`.  This means
10910    ///     that the calling `Node` and the `node_ref` `Node` will not have both
10911    ///     their constraints apply - rather sysmem will choose one or the other
10912    ///     of the constraints - never both.  This is because only one child of
10913    ///     a `BufferCollectionTokenGroup` is selected during logical
10914    ///     allocation, with only that one child's subtree contributing to
10915    ///     constraints aggregation.
10916    ///   - false: The first parent node in common between the calling `Node`
10917    ///     and the `node_ref` `Node` is not a `BufferCollectionTokenGroup`.
10918    ///     Currently, this means the first parent node in common is a
10919    ///     `BufferCollectionToken` or `BufferCollection` (regardless of not
10920    ///     `Release`ed).  This means that the calling `Node` and the `node_ref`
10921    ///     `Node` may have both their constraints apply during constraints
10922    ///     aggregation of the logical allocation, if both `Node`(s) are
10923    ///     selected by any parent `BufferCollectionTokenGroup`(s) involved. In
10924    ///     this case, there is no `BufferCollectionTokenGroup` that will
10925    ///     directly prevent the two `Node`(s) from both being selected and
10926    ///     their constraints both aggregated, but even when false, one or both
10927    ///     `Node`(s) may still be eliminated from consideration if one or both
10928    ///     `Node`(s) has a direct or indirect parent
10929    ///     `BufferCollectionTokenGroup` which selects a child subtree other
10930    ///     than the subtree containing the calling `Node` or `node_ref` `Node`.
10931    /// * error `[fuchsia.sysmem2/Error.NOT_FOUND]` The node_ref wasn't
10932    ///   associated with the same buffer collection as the calling `Node`.
10933    ///   Another reason for this error is if the `node_ref` is an
10934    ///   [`zx.Handle.EVENT`] handle with sufficient rights, but isn't actually
10935    ///   a real `node_ref` obtained from `GetNodeRef`.
10936    /// * error `[fuchsia.sysmem2/Error.PROTOCOL_DEVIATION]` The caller passed a
10937    ///   `node_ref` that isn't a [`zx.Handle:EVENT`] handle , or doesn't have
10938    ///   the needed rights expected on a real `node_ref`.
10939    /// * No other failing status codes are returned by this call.  However,
10940    ///   sysmem may add additional codes in future, so the client should have
10941    ///   sensible default handling for any failing status code.
10942    IsAlternateFor { payload: NodeIsAlternateForRequest, responder: NodeIsAlternateForResponder },
10943    /// Get the buffer collection ID. This ID is also available from
10944    /// [`fuchsia.sysmem2/Allocator.GetVmoInfo`] (along with the `buffer_index`
10945    /// within the collection).
10946    ///
10947    /// This call is mainly useful in situations where we can't convey a
10948    /// [`fuchsia.sysmem2/BufferCollectionToken`] or
10949    /// [`fuchsia.sysmem2/BufferCollection`] directly, but can only convey a VMO
10950    /// handle, which can be joined back up with a `BufferCollection` client end
10951    /// that was created via a different path. Prefer to convey a
10952    /// `BufferCollectionToken` or `BufferCollection` directly when feasible.
10953    ///
10954    /// Trusting a `buffer_collection_id` value from a source other than sysmem
10955    /// is analogous to trusting a koid value from a source other than zircon.
10956    /// Both should be avoided unless really necessary, and both require
10957    /// caution. In some situations it may be reasonable to refer to a
10958    /// pre-established `BufferCollection` by `buffer_collection_id` via a
10959    /// protocol for efficiency reasons, but an incoming value purporting to be
10960    /// a `buffer_collection_id` is not sufficient alone to justify granting the
10961    /// sender of the `buffer_collection_id` any capability. The sender must
10962    /// first prove to a receiver that the sender has/had a VMO or has/had a
10963    /// `BufferCollectionToken` to the same collection by sending a handle that
10964    /// sysmem confirms is a valid sysmem handle and which sysmem maps to the
10965    /// `buffer_collection_id` value. The receiver should take care to avoid
10966    /// assuming that a sender had a `BufferCollectionToken` in cases where the
10967    /// sender has only proven that the sender had a VMO.
10968    ///
10969    /// - response `buffer_collection_id` This ID is unique per buffer
10970    ///   collection per boot. Each buffer is uniquely identified by the
10971    ///   `buffer_collection_id` and `buffer_index` together.
10972    GetBufferCollectionId { responder: NodeGetBufferCollectionIdResponder },
10973    /// Sets the current [`fuchsia.sysmem2/Node`] and all child `Node`(s)
10974    /// created after this message to weak, which means that a client's `Node`
10975    /// client end (or a child created after this message) is not alone
10976    /// sufficient to keep allocated VMOs alive.
10977    ///
10978    /// All VMOs obtained from weak `Node`(s) are weak sysmem VMOs. See also
10979    /// `close_weak_asap`.
10980    ///
10981    /// This message is only permitted before the `Node` becomes ready for
10982    /// allocation (else the server closes the channel with `ZX_ERR_BAD_STATE`):
10983    ///   * `BufferCollectionToken`: any time
10984    ///   * `BufferCollection`: before `SetConstraints`
10985    ///   * `BufferCollectionTokenGroup`: before `AllChildrenPresent`
10986    ///
10987    /// Currently, no conversion from strong `Node` to weak `Node` after ready
10988    /// for allocation is provided, but a client can simulate that by creating
10989    /// an additional `Node` before allocation and setting that additional
10990    /// `Node` to weak, and then potentially at some point later sending
10991    /// `Release` and closing the client end of the client's strong `Node`, but
10992    /// keeping the client's weak `Node`.
10993    ///
10994    /// Zero strong `Node`(s) and zero strong VMO handles will result in buffer
10995    /// collection failure (all `Node` client end(s) will see
10996    /// `ZX_CHANNEL_PEER_CLOSED` and all `close_weak_asap` `client_end`(s) will
10997    /// see `ZX_EVENTPAIR_PEER_CLOSED`), but sysmem (intentionally) won't notice
10998    /// this situation until all `Node`(s) are ready for allocation. For initial
10999    /// allocation to succeed, at least one strong `Node` is required to exist
11000    /// at allocation time, but after that client receives VMO handles, that
11001    /// client can `BufferCollection.Release` and close the client end without
11002    /// causing this type of failure.
11003    ///
11004    /// This implies [`fuchsia.sysmem2/Node.SetWeakOk`] as well, but does not
11005    /// imply `SetWeakOk` with `for_children_also` true, which can be sent
11006    /// separately as appropriate.
11007    SetWeak { control_handle: NodeControlHandle },
11008    /// This indicates to sysmem that the client is prepared to pay attention to
11009    /// `close_weak_asap`.
11010    ///
11011    /// If sent, this message must be before
11012    /// [`fuchsia.sysmem2/BufferCollection.WaitForAllBuffersAllocated`].
11013    ///
11014    /// All participants using a weak [`fuchsia.sysmem2/BufferCollection`] must
11015    /// send this message before `WaitForAllBuffersAllocated`, or a parent
11016    /// `Node` must have sent [`fuchsia.sysmem2/Node.SetWeakOk`] with
11017    /// `for_child_nodes_also` true, else the `WaitForAllBuffersAllocated` will
11018    /// trigger buffer collection failure.
11019    ///
11020    /// This message is necessary because weak sysmem VMOs have not always been
11021    /// a thing, so older clients are not aware of the need to pay attention to
11022    /// `close_weak_asap` `ZX_EVENTPAIR_PEER_CLOSED` and close all remaining
11023    /// sysmem weak VMO handles asap. By having this message and requiring
11024    /// participants to indicate their acceptance of this aspect of the overall
11025    /// protocol, we avoid situations where an older client is delivered a weak
11026    /// VMO without any way for sysmem to get that VMO to close quickly later
11027    /// (and on a per-buffer basis).
11028    ///
11029    /// A participant that doesn't handle `close_weak_asap` and also doesn't
11030    /// retrieve any VMO handles via `WaitForAllBuffersAllocated` doesn't need
11031    /// to send `SetWeakOk` (and doesn't need to have a parent `Node` send
11032    /// `SetWeakOk` with `for_child_nodes_also` true either). However, if that
11033    /// same participant has a child/delegate which does retrieve VMOs, that
11034    /// child/delegate will need to send `SetWeakOk` before
11035    /// `WaitForAllBuffersAllocated`.
11036    ///
11037    /// + request `for_child_nodes_also` If present and true, this means direct
11038    ///   child nodes of this node created after this message plus all
11039    ///   descendants of those nodes will behave as if `SetWeakOk` was sent on
11040    ///   those nodes. Any child node of this node that was created before this
11041    ///   message is not included. This setting is "sticky" in the sense that a
11042    ///   subsequent `SetWeakOk` without this bool set to true does not reset
11043    ///   the server-side bool. If this creates a problem for a participant, a
11044    ///   workaround is to `SetWeakOk` with `for_child_nodes_also` true on child
11045    ///   tokens instead, as appropriate. A participant should only set
11046    ///   `for_child_nodes_also` true if the participant can really promise to
11047    ///   obey `close_weak_asap` both for its own weak VMO handles, and for all
11048    ///   weak VMO handles held by participants holding the corresponding child
11049    ///   `Node`(s). When `for_child_nodes_also` is set, descendent `Node`(s)
11050    ///   which are using sysmem(1) can be weak, despite the clients of those
11051    ///   sysmem1 `Node`(s) not having any direct way to `SetWeakOk` or any
11052    ///   direct way to find out about `close_weak_asap`. This only applies to
11053    ///   descendents of this `Node` which are using sysmem(1), not to this
11054    ///   `Node` when converted directly from a sysmem2 token to a sysmem(1)
11055    ///   token, which will fail allocation unless an ancestor of this `Node`
11056    ///   specified `for_child_nodes_also` true.
11057    SetWeakOk { payload: NodeSetWeakOkRequest, control_handle: NodeControlHandle },
11058    /// The server_end will be closed after this `Node` and any child nodes have
11059    /// have released their buffer counts, making those counts available for
11060    /// reservation by a different `Node` via
11061    /// [`fuchsia.sysmem2/BufferCollection.AttachToken`].
11062    ///
11063    /// The `Node` buffer counts may not be released until the entire tree of
11064    /// `Node`(s) is closed or failed, because
11065    /// [`fuchsia.sysmem2/BufferCollection.Release`] followed by channel close
11066    /// does not immediately un-reserve the `Node` buffer counts. Instead, the
11067    /// `Node` buffer counts remain reserved until the orphaned node is later
11068    /// cleaned up.
11069    ///
11070    /// If the `Node` exceeds a fairly large number of attached eventpair server
11071    /// ends, a log message will indicate this and the `Node` (and the
11072    /// appropriate) sub-tree will fail.
11073    ///
11074    /// The `server_end` will remain open when
11075    /// [`fuchsia.sysmem2/Allocator.BindSharedCollection`] converts a
11076    /// [`fuchsia.sysmem2/BufferCollectionToken`] into a
11077    /// [`fuchsia.sysmem2/BufferCollection`].
11078    ///
11079    /// This message can also be used with a
11080    /// [`fuchsia.sysmem2/BufferCollectionTokenGroup`].
11081    AttachNodeTracking { payload: NodeAttachNodeTrackingRequest, control_handle: NodeControlHandle },
11082    /// An interaction was received which does not match any known method.
11083    #[non_exhaustive]
11084    _UnknownMethod {
11085        /// Ordinal of the method that was called.
11086        ordinal: u64,
11087        control_handle: NodeControlHandle,
11088        method_type: fidl::MethodType,
11089    },
11090}
11091
11092impl NodeRequest {
11093    #[allow(irrefutable_let_patterns)]
11094    pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
11095        if let NodeRequest::Sync { responder } = self { Some((responder)) } else { None }
11096    }
11097
11098    #[allow(irrefutable_let_patterns)]
11099    pub fn into_release(self) -> Option<(NodeControlHandle)> {
11100        if let NodeRequest::Release { control_handle } = self {
11101            Some((control_handle))
11102        } else {
11103            None
11104        }
11105    }
11106
11107    #[allow(irrefutable_let_patterns)]
11108    pub fn into_set_name(self) -> Option<(NodeSetNameRequest, NodeControlHandle)> {
11109        if let NodeRequest::SetName { payload, control_handle } = self {
11110            Some((payload, control_handle))
11111        } else {
11112            None
11113        }
11114    }
11115
11116    #[allow(irrefutable_let_patterns)]
11117    pub fn into_set_debug_client_info(
11118        self,
11119    ) -> Option<(NodeSetDebugClientInfoRequest, NodeControlHandle)> {
11120        if let NodeRequest::SetDebugClientInfo { payload, control_handle } = self {
11121            Some((payload, control_handle))
11122        } else {
11123            None
11124        }
11125    }
11126
11127    #[allow(irrefutable_let_patterns)]
11128    pub fn into_set_debug_timeout_log_deadline(
11129        self,
11130    ) -> Option<(NodeSetDebugTimeoutLogDeadlineRequest, NodeControlHandle)> {
11131        if let NodeRequest::SetDebugTimeoutLogDeadline { payload, control_handle } = self {
11132            Some((payload, control_handle))
11133        } else {
11134            None
11135        }
11136    }
11137
11138    #[allow(irrefutable_let_patterns)]
11139    pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
11140        if let NodeRequest::SetVerboseLogging { control_handle } = self {
11141            Some((control_handle))
11142        } else {
11143            None
11144        }
11145    }
11146
11147    #[allow(irrefutable_let_patterns)]
11148    pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
11149        if let NodeRequest::GetNodeRef { responder } = self { Some((responder)) } else { None }
11150    }
11151
11152    #[allow(irrefutable_let_patterns)]
11153    pub fn into_is_alternate_for(
11154        self,
11155    ) -> Option<(NodeIsAlternateForRequest, NodeIsAlternateForResponder)> {
11156        if let NodeRequest::IsAlternateFor { payload, responder } = self {
11157            Some((payload, responder))
11158        } else {
11159            None
11160        }
11161    }
11162
11163    #[allow(irrefutable_let_patterns)]
11164    pub fn into_get_buffer_collection_id(self) -> Option<(NodeGetBufferCollectionIdResponder)> {
11165        if let NodeRequest::GetBufferCollectionId { responder } = self {
11166            Some((responder))
11167        } else {
11168            None
11169        }
11170    }
11171
11172    #[allow(irrefutable_let_patterns)]
11173    pub fn into_set_weak(self) -> Option<(NodeControlHandle)> {
11174        if let NodeRequest::SetWeak { control_handle } = self {
11175            Some((control_handle))
11176        } else {
11177            None
11178        }
11179    }
11180
11181    #[allow(irrefutable_let_patterns)]
11182    pub fn into_set_weak_ok(self) -> Option<(NodeSetWeakOkRequest, NodeControlHandle)> {
11183        if let NodeRequest::SetWeakOk { payload, control_handle } = self {
11184            Some((payload, control_handle))
11185        } else {
11186            None
11187        }
11188    }
11189
11190    #[allow(irrefutable_let_patterns)]
11191    pub fn into_attach_node_tracking(
11192        self,
11193    ) -> Option<(NodeAttachNodeTrackingRequest, NodeControlHandle)> {
11194        if let NodeRequest::AttachNodeTracking { payload, control_handle } = self {
11195            Some((payload, control_handle))
11196        } else {
11197            None
11198        }
11199    }
11200
11201    /// Name of the method defined in FIDL
11202    pub fn method_name(&self) -> &'static str {
11203        match *self {
11204            NodeRequest::Sync { .. } => "sync",
11205            NodeRequest::Release { .. } => "release",
11206            NodeRequest::SetName { .. } => "set_name",
11207            NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
11208            NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
11209            NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
11210            NodeRequest::GetNodeRef { .. } => "get_node_ref",
11211            NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
11212            NodeRequest::GetBufferCollectionId { .. } => "get_buffer_collection_id",
11213            NodeRequest::SetWeak { .. } => "set_weak",
11214            NodeRequest::SetWeakOk { .. } => "set_weak_ok",
11215            NodeRequest::AttachNodeTracking { .. } => "attach_node_tracking",
11216            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
11217                "unknown one-way method"
11218            }
11219            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
11220                "unknown two-way method"
11221            }
11222        }
11223    }
11224}
11225
11226#[derive(Debug, Clone)]
11227pub struct NodeControlHandle {
11228    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11229}
11230
11231impl NodeControlHandle {
11232    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
11233        self.inner.shutdown_with_epitaph(status.into())
11234    }
11235}
11236
11237impl fdomain_client::fidl::ControlHandle for NodeControlHandle {
11238    fn shutdown(&self) {
11239        self.inner.shutdown()
11240    }
11241
11242    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
11243        self.inner.shutdown_with_epitaph(status)
11244    }
11245
11246    fn is_closed(&self) -> bool {
11247        self.inner.channel().is_closed()
11248    }
11249    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
11250        self.inner.channel().on_closed()
11251    }
11252}
11253
11254impl NodeControlHandle {}
11255
11256#[must_use = "FIDL methods require a response to be sent"]
11257#[derive(Debug)]
11258pub struct NodeSyncResponder {
11259    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11260    tx_id: u32,
11261}
11262
11263/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11264/// if the responder is dropped without sending a response, so that the client
11265/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11266impl std::ops::Drop for NodeSyncResponder {
11267    fn drop(&mut self) {
11268        self.control_handle.shutdown();
11269        // Safety: drops once, never accessed again
11270        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11271    }
11272}
11273
11274impl fdomain_client::fidl::Responder for NodeSyncResponder {
11275    type ControlHandle = NodeControlHandle;
11276
11277    fn control_handle(&self) -> &NodeControlHandle {
11278        &self.control_handle
11279    }
11280
11281    fn drop_without_shutdown(mut self) {
11282        // Safety: drops once, never accessed again due to mem::forget
11283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11284        // Prevent Drop from running (which would shut down the channel)
11285        std::mem::forget(self);
11286    }
11287}
11288
11289impl NodeSyncResponder {
11290    /// Sends a response to the FIDL transaction.
11291    ///
11292    /// Sets the channel to shutdown if an error occurs.
11293    pub fn send(self) -> Result<(), fidl::Error> {
11294        let _result = self.send_raw();
11295        if _result.is_err() {
11296            self.control_handle.shutdown();
11297        }
11298        self.drop_without_shutdown();
11299        _result
11300    }
11301
11302    /// Similar to "send" but does not shutdown the channel if an error occurs.
11303    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11304        let _result = self.send_raw();
11305        self.drop_without_shutdown();
11306        _result
11307    }
11308
11309    fn send_raw(&self) -> Result<(), fidl::Error> {
11310        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
11311            fidl::encoding::Flexible::new(()),
11312            self.tx_id,
11313            0x11ac2555cf575b54,
11314            fidl::encoding::DynamicFlags::FLEXIBLE,
11315        )
11316    }
11317}
11318
11319#[must_use = "FIDL methods require a response to be sent"]
11320#[derive(Debug)]
11321pub struct NodeGetNodeRefResponder {
11322    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11323    tx_id: u32,
11324}
11325
11326/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11327/// if the responder is dropped without sending a response, so that the client
11328/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11329impl std::ops::Drop for NodeGetNodeRefResponder {
11330    fn drop(&mut self) {
11331        self.control_handle.shutdown();
11332        // Safety: drops once, never accessed again
11333        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11334    }
11335}
11336
11337impl fdomain_client::fidl::Responder for NodeGetNodeRefResponder {
11338    type ControlHandle = NodeControlHandle;
11339
11340    fn control_handle(&self) -> &NodeControlHandle {
11341        &self.control_handle
11342    }
11343
11344    fn drop_without_shutdown(mut self) {
11345        // Safety: drops once, never accessed again due to mem::forget
11346        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11347        // Prevent Drop from running (which would shut down the channel)
11348        std::mem::forget(self);
11349    }
11350}
11351
11352impl NodeGetNodeRefResponder {
11353    /// Sends a response to the FIDL transaction.
11354    ///
11355    /// Sets the channel to shutdown if an error occurs.
11356    pub fn send(self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
11357        let _result = self.send_raw(payload);
11358        if _result.is_err() {
11359            self.control_handle.shutdown();
11360        }
11361        self.drop_without_shutdown();
11362        _result
11363    }
11364
11365    /// Similar to "send" but does not shutdown the channel if an error occurs.
11366    pub fn send_no_shutdown_on_err(
11367        self,
11368        mut payload: NodeGetNodeRefResponse,
11369    ) -> Result<(), fidl::Error> {
11370        let _result = self.send_raw(payload);
11371        self.drop_without_shutdown();
11372        _result
11373    }
11374
11375    fn send_raw(&self, mut payload: NodeGetNodeRefResponse) -> Result<(), fidl::Error> {
11376        self.control_handle.inner.send::<fidl::encoding::FlexibleType<NodeGetNodeRefResponse>>(
11377            fidl::encoding::Flexible::new(&mut payload),
11378            self.tx_id,
11379            0x5b3d0e51614df053,
11380            fidl::encoding::DynamicFlags::FLEXIBLE,
11381        )
11382    }
11383}
11384
11385#[must_use = "FIDL methods require a response to be sent"]
11386#[derive(Debug)]
11387pub struct NodeIsAlternateForResponder {
11388    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11389    tx_id: u32,
11390}
11391
11392/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11393/// if the responder is dropped without sending a response, so that the client
11394/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11395impl std::ops::Drop for NodeIsAlternateForResponder {
11396    fn drop(&mut self) {
11397        self.control_handle.shutdown();
11398        // Safety: drops once, never accessed again
11399        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11400    }
11401}
11402
11403impl fdomain_client::fidl::Responder for NodeIsAlternateForResponder {
11404    type ControlHandle = NodeControlHandle;
11405
11406    fn control_handle(&self) -> &NodeControlHandle {
11407        &self.control_handle
11408    }
11409
11410    fn drop_without_shutdown(mut self) {
11411        // Safety: drops once, never accessed again due to mem::forget
11412        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11413        // Prevent Drop from running (which would shut down the channel)
11414        std::mem::forget(self);
11415    }
11416}
11417
11418impl NodeIsAlternateForResponder {
11419    /// Sends a response to the FIDL transaction.
11420    ///
11421    /// Sets the channel to shutdown if an error occurs.
11422    pub fn send(
11423        self,
11424        mut result: Result<&NodeIsAlternateForResponse, Error>,
11425    ) -> Result<(), fidl::Error> {
11426        let _result = self.send_raw(result);
11427        if _result.is_err() {
11428            self.control_handle.shutdown();
11429        }
11430        self.drop_without_shutdown();
11431        _result
11432    }
11433
11434    /// Similar to "send" but does not shutdown the channel if an error occurs.
11435    pub fn send_no_shutdown_on_err(
11436        self,
11437        mut result: Result<&NodeIsAlternateForResponse, Error>,
11438    ) -> Result<(), fidl::Error> {
11439        let _result = self.send_raw(result);
11440        self.drop_without_shutdown();
11441        _result
11442    }
11443
11444    fn send_raw(
11445        &self,
11446        mut result: Result<&NodeIsAlternateForResponse, Error>,
11447    ) -> Result<(), fidl::Error> {
11448        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
11449            NodeIsAlternateForResponse,
11450            Error,
11451        >>(
11452            fidl::encoding::FlexibleResult::new(result),
11453            self.tx_id,
11454            0x3a58e00157e0825,
11455            fidl::encoding::DynamicFlags::FLEXIBLE,
11456        )
11457    }
11458}
11459
11460#[must_use = "FIDL methods require a response to be sent"]
11461#[derive(Debug)]
11462pub struct NodeGetBufferCollectionIdResponder {
11463    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
11464    tx_id: u32,
11465}
11466
11467/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
11468/// if the responder is dropped without sending a response, so that the client
11469/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11470impl std::ops::Drop for NodeGetBufferCollectionIdResponder {
11471    fn drop(&mut self) {
11472        self.control_handle.shutdown();
11473        // Safety: drops once, never accessed again
11474        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11475    }
11476}
11477
11478impl fdomain_client::fidl::Responder for NodeGetBufferCollectionIdResponder {
11479    type ControlHandle = NodeControlHandle;
11480
11481    fn control_handle(&self) -> &NodeControlHandle {
11482        &self.control_handle
11483    }
11484
11485    fn drop_without_shutdown(mut self) {
11486        // Safety: drops once, never accessed again due to mem::forget
11487        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11488        // Prevent Drop from running (which would shut down the channel)
11489        std::mem::forget(self);
11490    }
11491}
11492
11493impl NodeGetBufferCollectionIdResponder {
11494    /// Sends a response to the FIDL transaction.
11495    ///
11496    /// Sets the channel to shutdown if an error occurs.
11497    pub fn send(self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
11498        let _result = self.send_raw(payload);
11499        if _result.is_err() {
11500            self.control_handle.shutdown();
11501        }
11502        self.drop_without_shutdown();
11503        _result
11504    }
11505
11506    /// Similar to "send" but does not shutdown the channel if an error occurs.
11507    pub fn send_no_shutdown_on_err(
11508        self,
11509        mut payload: &NodeGetBufferCollectionIdResponse,
11510    ) -> Result<(), fidl::Error> {
11511        let _result = self.send_raw(payload);
11512        self.drop_without_shutdown();
11513        _result
11514    }
11515
11516    fn send_raw(&self, mut payload: &NodeGetBufferCollectionIdResponse) -> Result<(), fidl::Error> {
11517        self.control_handle
11518            .inner
11519            .send::<fidl::encoding::FlexibleType<NodeGetBufferCollectionIdResponse>>(
11520                fidl::encoding::Flexible::new(payload),
11521                self.tx_id,
11522                0x77d19a494b78ba8c,
11523                fidl::encoding::DynamicFlags::FLEXIBLE,
11524            )
11525    }
11526}
11527
11528#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11529pub struct SecureMemMarker;
11530
11531impl fdomain_client::fidl::ProtocolMarker for SecureMemMarker {
11532    type Proxy = SecureMemProxy;
11533    type RequestStream = SecureMemRequestStream;
11534
11535    const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
11536}
11537pub type SecureMemGetPhysicalSecureHeapsResult =
11538    Result<SecureMemGetPhysicalSecureHeapsResponse, Error>;
11539pub type SecureMemGetDynamicSecureHeapsResult =
11540    Result<SecureMemGetDynamicSecureHeapsResponse, Error>;
11541pub type SecureMemGetPhysicalSecureHeapPropertiesResult =
11542    Result<SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>;
11543pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), Error>;
11544pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), Error>;
11545pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), Error>;
11546pub type SecureMemZeroSubRangeResult = Result<(), Error>;
11547
11548pub trait SecureMemProxyInterface: Send + Sync {
11549    type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
11550        + Send;
11551    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
11552    type GetDynamicSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetDynamicSecureHeapsResult, fidl::Error>>
11553        + Send;
11554    fn r#get_dynamic_secure_heaps(&self) -> Self::GetDynamicSecureHeapsResponseFut;
11555    type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
11556            Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
11557        > + Send;
11558    fn r#get_physical_secure_heap_properties(
11559        &self,
11560        payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11561    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
11562    type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
11563        + Send;
11564    fn r#add_secure_heap_physical_range(
11565        &self,
11566        payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11567    ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
11568    type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
11569            Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
11570        > + Send;
11571    fn r#delete_secure_heap_physical_range(
11572        &self,
11573        payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11574    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
11575    type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
11576            Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
11577        > + Send;
11578    fn r#modify_secure_heap_physical_range(
11579        &self,
11580        payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11581    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
11582    type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
11583        + Send;
11584    fn r#zero_sub_range(
11585        &self,
11586        payload: &SecureMemZeroSubRangeRequest,
11587    ) -> Self::ZeroSubRangeResponseFut;
11588}
11589
11590#[derive(Debug, Clone)]
11591pub struct SecureMemProxy {
11592    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11593}
11594
11595impl fdomain_client::fidl::Proxy for SecureMemProxy {
11596    type Protocol = SecureMemMarker;
11597
11598    fn from_channel(inner: fdomain_client::Channel) -> Self {
11599        Self::new(inner)
11600    }
11601
11602    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11603        self.client.into_channel().map_err(|client| Self { client })
11604    }
11605
11606    fn as_channel(&self) -> &fdomain_client::Channel {
11607        self.client.as_channel()
11608    }
11609}
11610
11611impl SecureMemProxy {
11612    /// Create a new Proxy for fuchsia.sysmem2/SecureMem.
11613    pub fn new(channel: fdomain_client::Channel) -> Self {
11614        let protocol_name = <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11615        Self { client: fidl::client::Client::new(channel, protocol_name) }
11616    }
11617
11618    /// Get a Stream of events from the remote end of the protocol.
11619    ///
11620    /// # Panics
11621    ///
11622    /// Panics if the event stream was already taken.
11623    pub fn take_event_stream(&self) -> SecureMemEventStream {
11624        SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
11625    }
11626
11627    /// Gets the physical address and length of any secure heap whose physical
11628    /// range is configured via the TEE.
11629    ///
11630    /// Presently, these will be fixed physical addresses and lengths, with the
11631    /// location plumbed via the TEE.
11632    ///
11633    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
11634    /// when there isn't any special heap-specific per-VMO setup or teardown
11635    /// required.
11636    ///
11637    /// The physical range must be secured/protected by the TEE before the
11638    /// securemem driver responds to this request with success.
11639    ///
11640    /// Sysmem should only call this once.  Returning zero heaps is not a
11641    /// failure.
11642    ///
11643    /// Errors:
11644    ///  * PROTOCOL_DEVIATION - called more than once.
11645    ///  * UNSPECIFIED - generic internal error (such as in communication
11646    ///    with TEE which doesn't generate zx_status_t errors).
11647    ///  * other errors are allowed; any other errors should be treated the same
11648    ///    as UNSPECIFIED.
11649    pub fn r#get_physical_secure_heaps(
11650        &self,
11651    ) -> fidl::client::QueryResponseFut<
11652        SecureMemGetPhysicalSecureHeapsResult,
11653        fdomain_client::fidl::FDomainResourceDialect,
11654    > {
11655        SecureMemProxyInterface::r#get_physical_secure_heaps(self)
11656    }
11657
11658    /// Gets information about any secure heaps whose physical pages are not
11659    /// configured by the TEE, but by sysmem.
11660    ///
11661    /// Sysmem should only call this once. Returning zero heaps is not a
11662    /// failure.
11663    ///
11664    /// Errors:
11665    ///  * PROTOCOL_DEVIATION - called more than once.
11666    ///  * UNSPECIFIED - generic internal error (such as in communication
11667    ///    with TEE which doesn't generate zx_status_t errors).
11668    ///  * other errors are allowed; any other errors should be treated the same
11669    ///    as UNSPECIFIED.
11670    pub fn r#get_dynamic_secure_heaps(
11671        &self,
11672    ) -> fidl::client::QueryResponseFut<
11673        SecureMemGetDynamicSecureHeapsResult,
11674        fdomain_client::fidl::FDomainResourceDialect,
11675    > {
11676        SecureMemProxyInterface::r#get_dynamic_secure_heaps(self)
11677    }
11678
11679    /// This request from sysmem to the securemem driver gets the properties of
11680    /// a protected/secure heap.
11681    ///
11682    /// This only handles heaps with a single contiguous physical extent.
11683    ///
11684    /// The heap's entire physical range is indicated in case this request needs
11685    /// some physical space to auto-detect how many ranges are REE-usable.  Any
11686    /// temporary HW protection ranges will be deleted before this request
11687    /// completes.
11688    ///
11689    /// Errors:
11690    ///  * UNSPECIFIED - generic internal error (such as in communication
11691    ///    with TEE which doesn't generate zx_status_t errors).
11692    ///  * other errors are allowed; any other errors should be treated the same
11693    ///    as UNSPECIFIED.
11694    pub fn r#get_physical_secure_heap_properties(
11695        &self,
11696        mut payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11697    ) -> fidl::client::QueryResponseFut<
11698        SecureMemGetPhysicalSecureHeapPropertiesResult,
11699        fdomain_client::fidl::FDomainResourceDialect,
11700    > {
11701        SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, payload)
11702    }
11703
11704    /// This request from sysmem to the securemem driver conveys a physical
11705    /// range to add, for a heap whose physical range(s) are set up via
11706    /// sysmem.
11707    ///
11708    /// Only sysmem can call this because only sysmem is handed the client end
11709    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11710    /// securemem driver is the server end of this protocol.
11711    ///
11712    /// The securemem driver must configure all the covered offsets as protected
11713    /// before responding to this message with success.
11714    ///
11715    /// On failure, the securemem driver must ensure the protected range was not
11716    /// created.
11717    ///
11718    /// Sysmem must only call this up to once if dynamic_protection_ranges
11719    /// false.
11720    ///
11721    /// If dynamic_protection_ranges is true, sysmem can call this multiple
11722    /// times as long as the current number of ranges never exceeds
11723    /// max_protected_range_count.
11724    ///
11725    /// The caller must not attempt to add a range that matches an
11726    /// already-existing range.  Added ranges can overlap each other as long as
11727    /// no two ranges match exactly.
11728    ///
11729    /// Errors:
11730    ///   * PROTOCOL_DEVIATION - called more than once when
11731    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
11732    ///     heap count to exceed max_protected_range_count. Unexpected heap, or
11733    ///     range that doesn't conform to protected_range_granularity. See log.
11734    ///   * UNSPECIFIED - generic internal error (such as in communication
11735    ///     with TEE which doesn't generate zx_status_t errors).
11736    ///   * other errors are possible, such as from communication failures or
11737    ///     server propagation of failures.
11738    pub fn r#add_secure_heap_physical_range(
11739        &self,
11740        mut payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11741    ) -> fidl::client::QueryResponseFut<
11742        SecureMemAddSecureHeapPhysicalRangeResult,
11743        fdomain_client::fidl::FDomainResourceDialect,
11744    > {
11745        SecureMemProxyInterface::r#add_secure_heap_physical_range(self, payload)
11746    }
11747
11748    /// This request from sysmem to the securemem driver conveys a physical
11749    /// range to delete, for a heap whose physical range(s) are set up via
11750    /// sysmem.
11751    ///
11752    /// Only sysmem can call this because only sysmem is handed the client end
11753    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11754    /// securemem driver is the server end of this protocol.
11755    ///
11756    /// The securemem driver must configure all the covered offsets as not
11757    /// protected before responding to this message with success.
11758    ///
11759    /// On failure, the securemem driver must ensure the protected range was not
11760    /// deleted.
11761    ///
11762    /// Sysmem must not call this if dynamic_protection_ranges false.
11763    ///
11764    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11765    /// on various ranges that exist at the time of the call.
11766    ///
11767    /// If any portion of the range being deleted is not also covered by another
11768    /// protected range, then any ongoing DMA to any part of the entire range
11769    /// may be interrupted / may fail, potentially in a way that's disruptive to
11770    /// the entire system (bus lockup or similar, depending on device details).
11771    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
11772    /// any portion of the range being deleted, unless the caller has other
11773    /// active ranges covering every block of the range being deleted.  Ongoing
11774    /// DMA to/from blocks outside the range being deleted is never impacted by
11775    /// the deletion.
11776    ///
11777    /// Errors:
11778    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11779    ///     Unexpected heap, or range that doesn't conform to
11780    ///     protected_range_granularity.
11781    ///   * UNSPECIFIED - generic internal error (such as in communication
11782    ///     with TEE which doesn't generate zx_status_t errors).
11783    ///   * NOT_FOUND - the specified range is not found.
11784    ///   * other errors are possible, such as from communication failures or
11785    ///     server propagation of failures.
11786    pub fn r#delete_secure_heap_physical_range(
11787        &self,
11788        mut payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
11789    ) -> fidl::client::QueryResponseFut<
11790        SecureMemDeleteSecureHeapPhysicalRangeResult,
11791        fdomain_client::fidl::FDomainResourceDialect,
11792    > {
11793        SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, payload)
11794    }
11795
11796    /// This request from sysmem to the securemem driver conveys a physical
11797    /// range to modify and its new base and length, for a heap whose physical
11798    /// range(s) are set up via sysmem.
11799    ///
11800    /// Only sysmem can call this because only sysmem is handed the client end
11801    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
11802    /// securemem driver is the server end of this protocol.
11803    ///
11804    /// The securemem driver must configure the range to cover only the new
11805    /// offsets before responding to this message with success.
11806    ///
11807    /// On failure, the securemem driver must ensure the range was not changed.
11808    ///
11809    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
11810    /// must not call this if !is_mod_protected_range_available.
11811    ///
11812    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
11813    /// on various ranges that exist at the time of the call.
11814    ///
11815    /// The range must only be modified at one end or the other, but not both.
11816    /// If the range is getting shorter, and the un-covered blocks are not
11817    /// covered by other active ranges, any ongoing DMA to the entire range
11818    /// that's geting shorter may fail in a way that disrupts the entire system
11819    /// (bus lockup or similar), so the caller must ensure that no DMA is
11820    /// ongoing to any portion of a range that is getting shorter, unless the
11821    /// blocks being un-covered by the modification to this range are all
11822    /// covered by other active ranges, in which case no disruption to ongoing
11823    /// DMA will occur.
11824    ///
11825    /// If a range is modified to become <= zero length, the range is deleted.
11826    ///
11827    /// Errors:
11828    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11829    ///     Unexpected heap, or old_range or new_range that doesn't conform to
11830    ///     protected_range_granularity, or old_range and new_range differ in
11831    ///     both begin and end (disallowed).
11832    ///   * UNSPECIFIED - generic internal error (such as in communication
11833    ///     with TEE which doesn't generate zx_status_t errors).
11834    ///   * NOT_FOUND - the specified range is not found.
11835    ///   * other errors are possible, such as from communication failures or
11836    ///     server propagation of failures.
11837    pub fn r#modify_secure_heap_physical_range(
11838        &self,
11839        mut payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
11840    ) -> fidl::client::QueryResponseFut<
11841        SecureMemModifySecureHeapPhysicalRangeResult,
11842        fdomain_client::fidl::FDomainResourceDialect,
11843    > {
11844        SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, payload)
11845    }
11846
11847    /// Zero a sub-range of a currently-existing physical range added via
11848    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
11849    /// exactly one physical range, and must not overlap with any other
11850    /// physical range.
11851    ///
11852    /// is_covering_range_explicit - When true, the covering range must be one
11853    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
11854    ///     possibly modified since.  When false, the covering range must not
11855    ///     be one of the ranges explicitly created via
11856    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
11857    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
11858    ///     covering range is typically the entire physical range (or a range
11859    ///     which covers even more) of a heap configured by the TEE and whose
11860    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
11861    ///
11862    /// Ongoing DMA is not disrupted by this request.
11863    ///
11864    /// Errors:
11865    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
11866    ///     Unexpected heap.
11867    ///   * UNSPECIFIED - generic internal error (such as in communication
11868    ///     with TEE which doesn't generate zx_status_t errors).
11869    ///   * other errors are possible, such as from communication failures or
11870    ///     server propagation of failures.
11871    pub fn r#zero_sub_range(
11872        &self,
11873        mut payload: &SecureMemZeroSubRangeRequest,
11874    ) -> fidl::client::QueryResponseFut<
11875        SecureMemZeroSubRangeResult,
11876        fdomain_client::fidl::FDomainResourceDialect,
11877    > {
11878        SecureMemProxyInterface::r#zero_sub_range(self, payload)
11879    }
11880}
11881
11882impl SecureMemProxyInterface for SecureMemProxy {
11883    type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11884        SecureMemGetPhysicalSecureHeapsResult,
11885        fdomain_client::fidl::FDomainResourceDialect,
11886    >;
11887    fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
11888        fn _decode(
11889            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11890        ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
11891            let _response = fidl::client::decode_transaction_body::<
11892                fidl::encoding::FlexibleResultType<SecureMemGetPhysicalSecureHeapsResponse, Error>,
11893                fdomain_client::fidl::FDomainResourceDialect,
11894                0x38716300592073e3,
11895            >(_buf?)?
11896            .into_result_fdomain::<SecureMemMarker>("get_physical_secure_heaps")?;
11897            Ok(_response.map(|x| x))
11898        }
11899        self.client.send_query_and_decode::<
11900            fidl::encoding::EmptyPayload,
11901            SecureMemGetPhysicalSecureHeapsResult,
11902        >(
11903            (),
11904            0x38716300592073e3,
11905            fidl::encoding::DynamicFlags::FLEXIBLE,
11906            _decode,
11907        )
11908    }
11909
11910    type GetDynamicSecureHeapsResponseFut = fidl::client::QueryResponseFut<
11911        SecureMemGetDynamicSecureHeapsResult,
11912        fdomain_client::fidl::FDomainResourceDialect,
11913    >;
11914    fn r#get_dynamic_secure_heaps(&self) -> Self::GetDynamicSecureHeapsResponseFut {
11915        fn _decode(
11916            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11917        ) -> Result<SecureMemGetDynamicSecureHeapsResult, fidl::Error> {
11918            let _response = fidl::client::decode_transaction_body::<
11919                fidl::encoding::FlexibleResultType<SecureMemGetDynamicSecureHeapsResponse, Error>,
11920                fdomain_client::fidl::FDomainResourceDialect,
11921                0x1190847f99952834,
11922            >(_buf?)?
11923            .into_result_fdomain::<SecureMemMarker>("get_dynamic_secure_heaps")?;
11924            Ok(_response.map(|x| x))
11925        }
11926        self.client.send_query_and_decode::<
11927            fidl::encoding::EmptyPayload,
11928            SecureMemGetDynamicSecureHeapsResult,
11929        >(
11930            (),
11931            0x1190847f99952834,
11932            fidl::encoding::DynamicFlags::FLEXIBLE,
11933            _decode,
11934        )
11935    }
11936
11937    type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
11938        SecureMemGetPhysicalSecureHeapPropertiesResult,
11939        fdomain_client::fidl::FDomainResourceDialect,
11940    >;
11941    fn r#get_physical_secure_heap_properties(
11942        &self,
11943        mut payload: &SecureMemGetPhysicalSecureHeapPropertiesRequest,
11944    ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
11945        fn _decode(
11946            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11947        ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
11948            let _response = fidl::client::decode_transaction_body::<
11949                fidl::encoding::FlexibleResultType<
11950                    SecureMemGetPhysicalSecureHeapPropertiesResponse,
11951                    Error,
11952                >,
11953                fdomain_client::fidl::FDomainResourceDialect,
11954                0xc6f06889009c7bc,
11955            >(_buf?)?
11956            .into_result_fdomain::<SecureMemMarker>("get_physical_secure_heap_properties")?;
11957            Ok(_response.map(|x| x))
11958        }
11959        self.client.send_query_and_decode::<
11960            SecureMemGetPhysicalSecureHeapPropertiesRequest,
11961            SecureMemGetPhysicalSecureHeapPropertiesResult,
11962        >(
11963            payload,
11964            0xc6f06889009c7bc,
11965            fidl::encoding::DynamicFlags::FLEXIBLE,
11966            _decode,
11967        )
11968    }
11969
11970    type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
11971        SecureMemAddSecureHeapPhysicalRangeResult,
11972        fdomain_client::fidl::FDomainResourceDialect,
11973    >;
11974    fn r#add_secure_heap_physical_range(
11975        &self,
11976        mut payload: &SecureMemAddSecureHeapPhysicalRangeRequest,
11977    ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
11978        fn _decode(
11979            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11980        ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
11981            let _response = fidl::client::decode_transaction_body::<
11982                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
11983                fdomain_client::fidl::FDomainResourceDialect,
11984                0x35f695b9b6c7217a,
11985            >(_buf?)?
11986            .into_result_fdomain::<SecureMemMarker>("add_secure_heap_physical_range")?;
11987            Ok(_response.map(|x| x))
11988        }
11989        self.client.send_query_and_decode::<
11990            SecureMemAddSecureHeapPhysicalRangeRequest,
11991            SecureMemAddSecureHeapPhysicalRangeResult,
11992        >(
11993            payload,
11994            0x35f695b9b6c7217a,
11995            fidl::encoding::DynamicFlags::FLEXIBLE,
11996            _decode,
11997        )
11998    }
11999
12000    type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
12001        SecureMemDeleteSecureHeapPhysicalRangeResult,
12002        fdomain_client::fidl::FDomainResourceDialect,
12003    >;
12004    fn r#delete_secure_heap_physical_range(
12005        &self,
12006        mut payload: &SecureMemDeleteSecureHeapPhysicalRangeRequest,
12007    ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
12008        fn _decode(
12009            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12010        ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
12011            let _response = fidl::client::decode_transaction_body::<
12012                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
12013                fdomain_client::fidl::FDomainResourceDialect,
12014                0xeaa58c650264c9e,
12015            >(_buf?)?
12016            .into_result_fdomain::<SecureMemMarker>("delete_secure_heap_physical_range")?;
12017            Ok(_response.map(|x| x))
12018        }
12019        self.client.send_query_and_decode::<
12020            SecureMemDeleteSecureHeapPhysicalRangeRequest,
12021            SecureMemDeleteSecureHeapPhysicalRangeResult,
12022        >(
12023            payload,
12024            0xeaa58c650264c9e,
12025            fidl::encoding::DynamicFlags::FLEXIBLE,
12026            _decode,
12027        )
12028    }
12029
12030    type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
12031        SecureMemModifySecureHeapPhysicalRangeResult,
12032        fdomain_client::fidl::FDomainResourceDialect,
12033    >;
12034    fn r#modify_secure_heap_physical_range(
12035        &self,
12036        mut payload: &SecureMemModifySecureHeapPhysicalRangeRequest,
12037    ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
12038        fn _decode(
12039            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12040        ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
12041            let _response = fidl::client::decode_transaction_body::<
12042                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
12043                fdomain_client::fidl::FDomainResourceDialect,
12044                0x60b7448aa1187734,
12045            >(_buf?)?
12046            .into_result_fdomain::<SecureMemMarker>("modify_secure_heap_physical_range")?;
12047            Ok(_response.map(|x| x))
12048        }
12049        self.client.send_query_and_decode::<
12050            SecureMemModifySecureHeapPhysicalRangeRequest,
12051            SecureMemModifySecureHeapPhysicalRangeResult,
12052        >(
12053            payload,
12054            0x60b7448aa1187734,
12055            fidl::encoding::DynamicFlags::FLEXIBLE,
12056            _decode,
12057        )
12058    }
12059
12060    type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
12061        SecureMemZeroSubRangeResult,
12062        fdomain_client::fidl::FDomainResourceDialect,
12063    >;
12064    fn r#zero_sub_range(
12065        &self,
12066        mut payload: &SecureMemZeroSubRangeRequest,
12067    ) -> Self::ZeroSubRangeResponseFut {
12068        fn _decode(
12069            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12070        ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
12071            let _response = fidl::client::decode_transaction_body::<
12072                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
12073                fdomain_client::fidl::FDomainResourceDialect,
12074                0x5b25b7901a385ce5,
12075            >(_buf?)?
12076            .into_result_fdomain::<SecureMemMarker>("zero_sub_range")?;
12077            Ok(_response.map(|x| x))
12078        }
12079        self.client
12080            .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
12081                payload,
12082                0x5b25b7901a385ce5,
12083                fidl::encoding::DynamicFlags::FLEXIBLE,
12084                _decode,
12085            )
12086    }
12087}
12088
12089pub struct SecureMemEventStream {
12090    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
12091}
12092
12093impl std::marker::Unpin for SecureMemEventStream {}
12094
12095impl futures::stream::FusedStream for SecureMemEventStream {
12096    fn is_terminated(&self) -> bool {
12097        self.event_receiver.is_terminated()
12098    }
12099}
12100
12101impl futures::Stream for SecureMemEventStream {
12102    type Item = Result<SecureMemEvent, fidl::Error>;
12103
12104    fn poll_next(
12105        mut self: std::pin::Pin<&mut Self>,
12106        cx: &mut std::task::Context<'_>,
12107    ) -> std::task::Poll<Option<Self::Item>> {
12108        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12109            &mut self.event_receiver,
12110            cx
12111        )?) {
12112            Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
12113            None => std::task::Poll::Ready(None),
12114        }
12115    }
12116}
12117
12118#[derive(Debug)]
12119pub enum SecureMemEvent {
12120    #[non_exhaustive]
12121    _UnknownEvent {
12122        /// Ordinal of the event that was sent.
12123        ordinal: u64,
12124    },
12125}
12126
12127impl SecureMemEvent {
12128    /// Decodes a message buffer as a [`SecureMemEvent`].
12129    fn decode(
12130        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12131    ) -> Result<SecureMemEvent, fidl::Error> {
12132        let (bytes, _handles) = buf.split_mut();
12133        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12134        debug_assert_eq!(tx_header.tx_id, 0);
12135        match tx_header.ordinal {
12136            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12137                Ok(SecureMemEvent::_UnknownEvent { ordinal: tx_header.ordinal })
12138            }
12139            _ => Err(fidl::Error::UnknownOrdinal {
12140                ordinal: tx_header.ordinal,
12141                protocol_name:
12142                    <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12143            }),
12144        }
12145    }
12146}
12147
12148/// A Stream of incoming requests for fuchsia.sysmem2/SecureMem.
12149pub struct SecureMemRequestStream {
12150    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12151    is_terminated: bool,
12152}
12153
12154impl std::marker::Unpin for SecureMemRequestStream {}
12155
12156impl futures::stream::FusedStream for SecureMemRequestStream {
12157    fn is_terminated(&self) -> bool {
12158        self.is_terminated
12159    }
12160}
12161
12162impl fdomain_client::fidl::RequestStream for SecureMemRequestStream {
12163    type Protocol = SecureMemMarker;
12164    type ControlHandle = SecureMemControlHandle;
12165
12166    fn from_channel(channel: fdomain_client::Channel) -> Self {
12167        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12168    }
12169
12170    fn control_handle(&self) -> Self::ControlHandle {
12171        SecureMemControlHandle { inner: self.inner.clone() }
12172    }
12173
12174    fn into_inner(
12175        self,
12176    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
12177    {
12178        (self.inner, self.is_terminated)
12179    }
12180
12181    fn from_inner(
12182        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12183        is_terminated: bool,
12184    ) -> Self {
12185        Self { inner, is_terminated }
12186    }
12187}
12188
12189impl futures::Stream for SecureMemRequestStream {
12190    type Item = Result<SecureMemRequest, fidl::Error>;
12191
12192    fn poll_next(
12193        mut self: std::pin::Pin<&mut Self>,
12194        cx: &mut std::task::Context<'_>,
12195    ) -> std::task::Poll<Option<Self::Item>> {
12196        let this = &mut *self;
12197        if this.inner.check_shutdown(cx) {
12198            this.is_terminated = true;
12199            return std::task::Poll::Ready(None);
12200        }
12201        if this.is_terminated {
12202            panic!("polled SecureMemRequestStream after completion");
12203        }
12204        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
12205            |bytes, handles| {
12206                match this.inner.channel().read_etc(cx, bytes, handles) {
12207                    std::task::Poll::Ready(Ok(())) => {}
12208                    std::task::Poll::Pending => return std::task::Poll::Pending,
12209                    std::task::Poll::Ready(Err(None)) => {
12210                        this.is_terminated = true;
12211                        return std::task::Poll::Ready(None);
12212                    }
12213                    std::task::Poll::Ready(Err(Some(e))) => {
12214                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12215                            e.into(),
12216                        ))));
12217                    }
12218                }
12219
12220                // A message has been received from the channel
12221                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12222
12223                std::task::Poll::Ready(Some(match header.ordinal {
12224                    0x38716300592073e3 => {
12225                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12226                        let mut req = fidl::new_empty!(
12227                            fidl::encoding::EmptyPayload,
12228                            fdomain_client::fidl::FDomainResourceDialect
12229                        );
12230                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12231                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12232                        Ok(SecureMemRequest::GetPhysicalSecureHeaps {
12233                            responder: SecureMemGetPhysicalSecureHeapsResponder {
12234                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12235                                tx_id: header.tx_id,
12236                            },
12237                        })
12238                    }
12239                    0x1190847f99952834 => {
12240                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12241                        let mut req = fidl::new_empty!(
12242                            fidl::encoding::EmptyPayload,
12243                            fdomain_client::fidl::FDomainResourceDialect
12244                        );
12245                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12246                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12247                        Ok(SecureMemRequest::GetDynamicSecureHeaps {
12248                            responder: SecureMemGetDynamicSecureHeapsResponder {
12249                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12250                                tx_id: header.tx_id,
12251                            },
12252                        })
12253                    }
12254                    0xc6f06889009c7bc => {
12255                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12256                        let mut req = fidl::new_empty!(
12257                            SecureMemGetPhysicalSecureHeapPropertiesRequest,
12258                            fdomain_client::fidl::FDomainResourceDialect
12259                        );
12260                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
12261                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12262                        Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
12263                            payload: req,
12264                            responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
12265                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12266                                tx_id: header.tx_id,
12267                            },
12268                        })
12269                    }
12270                    0x35f695b9b6c7217a => {
12271                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12272                        let mut req = fidl::new_empty!(
12273                            SecureMemAddSecureHeapPhysicalRangeRequest,
12274                            fdomain_client::fidl::FDomainResourceDialect
12275                        );
12276                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12277                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12278                        Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
12279                            payload: req,
12280                            responder: SecureMemAddSecureHeapPhysicalRangeResponder {
12281                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12282                                tx_id: header.tx_id,
12283                            },
12284                        })
12285                    }
12286                    0xeaa58c650264c9e => {
12287                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12288                        let mut req = fidl::new_empty!(
12289                            SecureMemDeleteSecureHeapPhysicalRangeRequest,
12290                            fdomain_client::fidl::FDomainResourceDialect
12291                        );
12292                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12293                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12294                        Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
12295                            payload: req,
12296                            responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
12297                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12298                                tx_id: header.tx_id,
12299                            },
12300                        })
12301                    }
12302                    0x60b7448aa1187734 => {
12303                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12304                        let mut req = fidl::new_empty!(
12305                            SecureMemModifySecureHeapPhysicalRangeRequest,
12306                            fdomain_client::fidl::FDomainResourceDialect
12307                        );
12308                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12309                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12310                        Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
12311                            payload: req,
12312                            responder: SecureMemModifySecureHeapPhysicalRangeResponder {
12313                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12314                                tx_id: header.tx_id,
12315                            },
12316                        })
12317                    }
12318                    0x5b25b7901a385ce5 => {
12319                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12320                        let mut req = fidl::new_empty!(
12321                            SecureMemZeroSubRangeRequest,
12322                            fdomain_client::fidl::FDomainResourceDialect
12323                        );
12324                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
12325                        let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
12326                        Ok(SecureMemRequest::ZeroSubRange {
12327                            payload: req,
12328                            responder: SecureMemZeroSubRangeResponder {
12329                                control_handle: std::mem::ManuallyDrop::new(control_handle),
12330                                tx_id: header.tx_id,
12331                            },
12332                        })
12333                    }
12334                    _ if header.tx_id == 0
12335                        && header
12336                            .dynamic_flags()
12337                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
12338                    {
12339                        Ok(SecureMemRequest::_UnknownMethod {
12340                            ordinal: header.ordinal,
12341                            control_handle: SecureMemControlHandle { inner: this.inner.clone() },
12342                            method_type: fidl::MethodType::OneWay,
12343                        })
12344                    }
12345                    _ if header
12346                        .dynamic_flags()
12347                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
12348                    {
12349                        this.inner.send_framework_err(
12350                            fidl::encoding::FrameworkErr::UnknownMethod,
12351                            header.tx_id,
12352                            header.ordinal,
12353                            header.dynamic_flags(),
12354                            (bytes, handles),
12355                        )?;
12356                        Ok(SecureMemRequest::_UnknownMethod {
12357                            ordinal: header.ordinal,
12358                            control_handle: SecureMemControlHandle { inner: this.inner.clone() },
12359                            method_type: fidl::MethodType::TwoWay,
12360                        })
12361                    }
12362                    _ => Err(fidl::Error::UnknownOrdinal {
12363                        ordinal: header.ordinal,
12364                        protocol_name:
12365                            <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12366                    }),
12367                }))
12368            },
12369        )
12370    }
12371}
12372
12373/// SecureMem
12374///
12375/// The client is sysmem.  The server is securemem driver.
12376///
12377/// TEE - Trusted Execution Environment.
12378///
12379/// REE - Rich Execution Environment.
12380///
12381/// Enables sysmem to call the securemem driver to get any secure heaps
12382/// configured via the TEE (or via the securemem driver), and set any physical
12383/// secure heaps configured via sysmem.
12384///
12385/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
12386/// it starts quite early during boot and can successfully reserve contiguous
12387/// physical memory.  Presently, fixed-location secure heaps are configured via
12388/// TEE, as the plumbing goes from the bootloader to the TEE.  However, this
12389/// protocol intentionally doesn't care which heaps are dynamically-allocated
12390/// and which are fixed-location.
12391#[derive(Debug)]
12392pub enum SecureMemRequest {
12393    /// Gets the physical address and length of any secure heap whose physical
12394    /// range is configured via the TEE.
12395    ///
12396    /// Presently, these will be fixed physical addresses and lengths, with the
12397    /// location plumbed via the TEE.
12398    ///
12399    /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
12400    /// when there isn't any special heap-specific per-VMO setup or teardown
12401    /// required.
12402    ///
12403    /// The physical range must be secured/protected by the TEE before the
12404    /// securemem driver responds to this request with success.
12405    ///
12406    /// Sysmem should only call this once.  Returning zero heaps is not a
12407    /// failure.
12408    ///
12409    /// Errors:
12410    ///  * PROTOCOL_DEVIATION - called more than once.
12411    ///  * UNSPECIFIED - generic internal error (such as in communication
12412    ///    with TEE which doesn't generate zx_status_t errors).
12413    ///  * other errors are allowed; any other errors should be treated the same
12414    ///    as UNSPECIFIED.
12415    GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
12416    /// Gets information about any secure heaps whose physical pages are not
12417    /// configured by the TEE, but by sysmem.
12418    ///
12419    /// Sysmem should only call this once. Returning zero heaps is not a
12420    /// failure.
12421    ///
12422    /// Errors:
12423    ///  * PROTOCOL_DEVIATION - called more than once.
12424    ///  * UNSPECIFIED - generic internal error (such as in communication
12425    ///    with TEE which doesn't generate zx_status_t errors).
12426    ///  * other errors are allowed; any other errors should be treated the same
12427    ///    as UNSPECIFIED.
12428    GetDynamicSecureHeaps { responder: SecureMemGetDynamicSecureHeapsResponder },
12429    /// This request from sysmem to the securemem driver gets the properties of
12430    /// a protected/secure heap.
12431    ///
12432    /// This only handles heaps with a single contiguous physical extent.
12433    ///
12434    /// The heap's entire physical range is indicated in case this request needs
12435    /// some physical space to auto-detect how many ranges are REE-usable.  Any
12436    /// temporary HW protection ranges will be deleted before this request
12437    /// completes.
12438    ///
12439    /// Errors:
12440    ///  * UNSPECIFIED - generic internal error (such as in communication
12441    ///    with TEE which doesn't generate zx_status_t errors).
12442    ///  * other errors are allowed; any other errors should be treated the same
12443    ///    as UNSPECIFIED.
12444    GetPhysicalSecureHeapProperties {
12445        payload: SecureMemGetPhysicalSecureHeapPropertiesRequest,
12446        responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
12447    },
12448    /// This request from sysmem to the securemem driver conveys a physical
12449    /// range to add, for a heap whose physical range(s) are set up via
12450    /// sysmem.
12451    ///
12452    /// Only sysmem can call this because only sysmem is handed the client end
12453    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12454    /// securemem driver is the server end of this protocol.
12455    ///
12456    /// The securemem driver must configure all the covered offsets as protected
12457    /// before responding to this message with success.
12458    ///
12459    /// On failure, the securemem driver must ensure the protected range was not
12460    /// created.
12461    ///
12462    /// Sysmem must only call this up to once if dynamic_protection_ranges
12463    /// false.
12464    ///
12465    /// If dynamic_protection_ranges is true, sysmem can call this multiple
12466    /// times as long as the current number of ranges never exceeds
12467    /// max_protected_range_count.
12468    ///
12469    /// The caller must not attempt to add a range that matches an
12470    /// already-existing range.  Added ranges can overlap each other as long as
12471    /// no two ranges match exactly.
12472    ///
12473    /// Errors:
12474    ///   * PROTOCOL_DEVIATION - called more than once when
12475    ///     !dynamic_protection_ranges.  Adding a heap that would cause overall
12476    ///     heap count to exceed max_protected_range_count. Unexpected heap, or
12477    ///     range that doesn't conform to protected_range_granularity. See log.
12478    ///   * UNSPECIFIED - generic internal error (such as in communication
12479    ///     with TEE which doesn't generate zx_status_t errors).
12480    ///   * other errors are possible, such as from communication failures or
12481    ///     server propagation of failures.
12482    AddSecureHeapPhysicalRange {
12483        payload: SecureMemAddSecureHeapPhysicalRangeRequest,
12484        responder: SecureMemAddSecureHeapPhysicalRangeResponder,
12485    },
12486    /// This request from sysmem to the securemem driver conveys a physical
12487    /// range to delete, for a heap whose physical range(s) are set up via
12488    /// sysmem.
12489    ///
12490    /// Only sysmem can call this because only sysmem is handed the client end
12491    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12492    /// securemem driver is the server end of this protocol.
12493    ///
12494    /// The securemem driver must configure all the covered offsets as not
12495    /// protected before responding to this message with success.
12496    ///
12497    /// On failure, the securemem driver must ensure the protected range was not
12498    /// deleted.
12499    ///
12500    /// Sysmem must not call this if dynamic_protection_ranges false.
12501    ///
12502    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
12503    /// on various ranges that exist at the time of the call.
12504    ///
12505    /// If any portion of the range being deleted is not also covered by another
12506    /// protected range, then any ongoing DMA to any part of the entire range
12507    /// may be interrupted / may fail, potentially in a way that's disruptive to
12508    /// the entire system (bus lockup or similar, depending on device details).
12509    /// Therefore, the caller must ensure that no ongoing DMA is occurring to
12510    /// any portion of the range being deleted, unless the caller has other
12511    /// active ranges covering every block of the range being deleted.  Ongoing
12512    /// DMA to/from blocks outside the range being deleted is never impacted by
12513    /// the deletion.
12514    ///
12515    /// Errors:
12516    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12517    ///     Unexpected heap, or range that doesn't conform to
12518    ///     protected_range_granularity.
12519    ///   * UNSPECIFIED - generic internal error (such as in communication
12520    ///     with TEE which doesn't generate zx_status_t errors).
12521    ///   * NOT_FOUND - the specified range is not found.
12522    ///   * other errors are possible, such as from communication failures or
12523    ///     server propagation of failures.
12524    DeleteSecureHeapPhysicalRange {
12525        payload: SecureMemDeleteSecureHeapPhysicalRangeRequest,
12526        responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
12527    },
12528    /// This request from sysmem to the securemem driver conveys a physical
12529    /// range to modify and its new base and length, for a heap whose physical
12530    /// range(s) are set up via sysmem.
12531    ///
12532    /// Only sysmem can call this because only sysmem is handed the client end
12533    /// of a FIDL channel serving this protocol, via RegisterSecureMem().  The
12534    /// securemem driver is the server end of this protocol.
12535    ///
12536    /// The securemem driver must configure the range to cover only the new
12537    /// offsets before responding to this message with success.
12538    ///
12539    /// On failure, the securemem driver must ensure the range was not changed.
12540    ///
12541    /// Sysmem must not call this if dynamic_protection_ranges false.  Sysmem
12542    /// must not call this if !is_mod_protected_range_available.
12543    ///
12544    /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
12545    /// on various ranges that exist at the time of the call.
12546    ///
12547    /// The range must only be modified at one end or the other, but not both.
12548    /// If the range is getting shorter, and the un-covered blocks are not
12549    /// covered by other active ranges, any ongoing DMA to the entire range
12550    /// that's geting shorter may fail in a way that disrupts the entire system
12551    /// (bus lockup or similar), so the caller must ensure that no DMA is
12552    /// ongoing to any portion of a range that is getting shorter, unless the
12553    /// blocks being un-covered by the modification to this range are all
12554    /// covered by other active ranges, in which case no disruption to ongoing
12555    /// DMA will occur.
12556    ///
12557    /// If a range is modified to become <= zero length, the range is deleted.
12558    ///
12559    /// Errors:
12560    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12561    ///     Unexpected heap, or old_range or new_range that doesn't conform to
12562    ///     protected_range_granularity, or old_range and new_range differ in
12563    ///     both begin and end (disallowed).
12564    ///   * UNSPECIFIED - generic internal error (such as in communication
12565    ///     with TEE which doesn't generate zx_status_t errors).
12566    ///   * NOT_FOUND - the specified range is not found.
12567    ///   * other errors are possible, such as from communication failures or
12568    ///     server propagation of failures.
12569    ModifySecureHeapPhysicalRange {
12570        payload: SecureMemModifySecureHeapPhysicalRangeRequest,
12571        responder: SecureMemModifySecureHeapPhysicalRangeResponder,
12572    },
12573    /// Zero a sub-range of a currently-existing physical range added via
12574    /// AddSecureHeapPhysicalRange().  The sub-range must be fully covered by
12575    /// exactly one physical range, and must not overlap with any other
12576    /// physical range.
12577    ///
12578    /// is_covering_range_explicit - When true, the covering range must be one
12579    ///     of the ranges explicitly created via AddSecureHeapPhysicalRange(),
12580    ///     possibly modified since.  When false, the covering range must not
12581    ///     be one of the ranges explicitly created via
12582    ///     AddSecureHeapPhysicalRange(), but the covering range must exist as
12583    ///     a covering range not created via AddSecureHeapPhysicalRange().  The
12584    ///     covering range is typically the entire physical range (or a range
12585    ///     which covers even more) of a heap configured by the TEE and whose
12586    ///     configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
12587    ///
12588    /// Ongoing DMA is not disrupted by this request.
12589    ///
12590    /// Errors:
12591    ///   * PROTOCOL_DEVIATION - called when !dynamic_protection_ranges.
12592    ///     Unexpected heap.
12593    ///   * UNSPECIFIED - generic internal error (such as in communication
12594    ///     with TEE which doesn't generate zx_status_t errors).
12595    ///   * other errors are possible, such as from communication failures or
12596    ///     server propagation of failures.
12597    ZeroSubRange {
12598        payload: SecureMemZeroSubRangeRequest,
12599        responder: SecureMemZeroSubRangeResponder,
12600    },
12601    /// An interaction was received which does not match any known method.
12602    #[non_exhaustive]
12603    _UnknownMethod {
12604        /// Ordinal of the method that was called.
12605        ordinal: u64,
12606        control_handle: SecureMemControlHandle,
12607        method_type: fidl::MethodType,
12608    },
12609}
12610
12611impl SecureMemRequest {
12612    #[allow(irrefutable_let_patterns)]
12613    pub fn into_get_physical_secure_heaps(
12614        self,
12615    ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
12616        if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
12617            Some((responder))
12618        } else {
12619            None
12620        }
12621    }
12622
12623    #[allow(irrefutable_let_patterns)]
12624    pub fn into_get_dynamic_secure_heaps(
12625        self,
12626    ) -> Option<(SecureMemGetDynamicSecureHeapsResponder)> {
12627        if let SecureMemRequest::GetDynamicSecureHeaps { responder } = self {
12628            Some((responder))
12629        } else {
12630            None
12631        }
12632    }
12633
12634    #[allow(irrefutable_let_patterns)]
12635    pub fn into_get_physical_secure_heap_properties(
12636        self,
12637    ) -> Option<(
12638        SecureMemGetPhysicalSecureHeapPropertiesRequest,
12639        SecureMemGetPhysicalSecureHeapPropertiesResponder,
12640    )> {
12641        if let SecureMemRequest::GetPhysicalSecureHeapProperties { payload, responder } = self {
12642            Some((payload, responder))
12643        } else {
12644            None
12645        }
12646    }
12647
12648    #[allow(irrefutable_let_patterns)]
12649    pub fn into_add_secure_heap_physical_range(
12650        self,
12651    ) -> Option<(
12652        SecureMemAddSecureHeapPhysicalRangeRequest,
12653        SecureMemAddSecureHeapPhysicalRangeResponder,
12654    )> {
12655        if let SecureMemRequest::AddSecureHeapPhysicalRange { payload, responder } = self {
12656            Some((payload, responder))
12657        } else {
12658            None
12659        }
12660    }
12661
12662    #[allow(irrefutable_let_patterns)]
12663    pub fn into_delete_secure_heap_physical_range(
12664        self,
12665    ) -> Option<(
12666        SecureMemDeleteSecureHeapPhysicalRangeRequest,
12667        SecureMemDeleteSecureHeapPhysicalRangeResponder,
12668    )> {
12669        if let SecureMemRequest::DeleteSecureHeapPhysicalRange { payload, responder } = self {
12670            Some((payload, responder))
12671        } else {
12672            None
12673        }
12674    }
12675
12676    #[allow(irrefutable_let_patterns)]
12677    pub fn into_modify_secure_heap_physical_range(
12678        self,
12679    ) -> Option<(
12680        SecureMemModifySecureHeapPhysicalRangeRequest,
12681        SecureMemModifySecureHeapPhysicalRangeResponder,
12682    )> {
12683        if let SecureMemRequest::ModifySecureHeapPhysicalRange { payload, responder } = self {
12684            Some((payload, responder))
12685        } else {
12686            None
12687        }
12688    }
12689
12690    #[allow(irrefutable_let_patterns)]
12691    pub fn into_zero_sub_range(
12692        self,
12693    ) -> Option<(SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResponder)> {
12694        if let SecureMemRequest::ZeroSubRange { payload, responder } = self {
12695            Some((payload, responder))
12696        } else {
12697            None
12698        }
12699    }
12700
12701    /// Name of the method defined in FIDL
12702    pub fn method_name(&self) -> &'static str {
12703        match *self {
12704            SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
12705            SecureMemRequest::GetDynamicSecureHeaps { .. } => "get_dynamic_secure_heaps",
12706            SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
12707                "get_physical_secure_heap_properties"
12708            }
12709            SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
12710            SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
12711                "delete_secure_heap_physical_range"
12712            }
12713            SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
12714                "modify_secure_heap_physical_range"
12715            }
12716            SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
12717            SecureMemRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
12718                "unknown one-way method"
12719            }
12720            SecureMemRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
12721                "unknown two-way method"
12722            }
12723        }
12724    }
12725}
12726
12727#[derive(Debug, Clone)]
12728pub struct SecureMemControlHandle {
12729    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12730}
12731
12732impl SecureMemControlHandle {
12733    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
12734        self.inner.shutdown_with_epitaph(status.into())
12735    }
12736}
12737
12738impl fdomain_client::fidl::ControlHandle for SecureMemControlHandle {
12739    fn shutdown(&self) {
12740        self.inner.shutdown()
12741    }
12742
12743    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
12744        self.inner.shutdown_with_epitaph(status)
12745    }
12746
12747    fn is_closed(&self) -> bool {
12748        self.inner.channel().is_closed()
12749    }
12750    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
12751        self.inner.channel().on_closed()
12752    }
12753}
12754
12755impl SecureMemControlHandle {}
12756
12757#[must_use = "FIDL methods require a response to be sent"]
12758#[derive(Debug)]
12759pub struct SecureMemGetPhysicalSecureHeapsResponder {
12760    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12761    tx_id: u32,
12762}
12763
12764/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12765/// if the responder is dropped without sending a response, so that the client
12766/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12767impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
12768    fn drop(&mut self) {
12769        self.control_handle.shutdown();
12770        // Safety: drops once, never accessed again
12771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12772    }
12773}
12774
12775impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapsResponder {
12776    type ControlHandle = SecureMemControlHandle;
12777
12778    fn control_handle(&self) -> &SecureMemControlHandle {
12779        &self.control_handle
12780    }
12781
12782    fn drop_without_shutdown(mut self) {
12783        // Safety: drops once, never accessed again due to mem::forget
12784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12785        // Prevent Drop from running (which would shut down the channel)
12786        std::mem::forget(self);
12787    }
12788}
12789
12790impl SecureMemGetPhysicalSecureHeapsResponder {
12791    /// Sends a response to the FIDL transaction.
12792    ///
12793    /// Sets the channel to shutdown if an error occurs.
12794    pub fn send(
12795        self,
12796        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12797    ) -> Result<(), fidl::Error> {
12798        let _result = self.send_raw(result);
12799        if _result.is_err() {
12800            self.control_handle.shutdown();
12801        }
12802        self.drop_without_shutdown();
12803        _result
12804    }
12805
12806    /// Similar to "send" but does not shutdown the channel if an error occurs.
12807    pub fn send_no_shutdown_on_err(
12808        self,
12809        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12810    ) -> Result<(), fidl::Error> {
12811        let _result = self.send_raw(result);
12812        self.drop_without_shutdown();
12813        _result
12814    }
12815
12816    fn send_raw(
12817        &self,
12818        mut result: Result<&SecureMemGetPhysicalSecureHeapsResponse, Error>,
12819    ) -> Result<(), fidl::Error> {
12820        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12821            SecureMemGetPhysicalSecureHeapsResponse,
12822            Error,
12823        >>(
12824            fidl::encoding::FlexibleResult::new(result),
12825            self.tx_id,
12826            0x38716300592073e3,
12827            fidl::encoding::DynamicFlags::FLEXIBLE,
12828        )
12829    }
12830}
12831
12832#[must_use = "FIDL methods require a response to be sent"]
12833#[derive(Debug)]
12834pub struct SecureMemGetDynamicSecureHeapsResponder {
12835    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12836    tx_id: u32,
12837}
12838
12839/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12840/// if the responder is dropped without sending a response, so that the client
12841/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12842impl std::ops::Drop for SecureMemGetDynamicSecureHeapsResponder {
12843    fn drop(&mut self) {
12844        self.control_handle.shutdown();
12845        // Safety: drops once, never accessed again
12846        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12847    }
12848}
12849
12850impl fdomain_client::fidl::Responder for SecureMemGetDynamicSecureHeapsResponder {
12851    type ControlHandle = SecureMemControlHandle;
12852
12853    fn control_handle(&self) -> &SecureMemControlHandle {
12854        &self.control_handle
12855    }
12856
12857    fn drop_without_shutdown(mut self) {
12858        // Safety: drops once, never accessed again due to mem::forget
12859        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12860        // Prevent Drop from running (which would shut down the channel)
12861        std::mem::forget(self);
12862    }
12863}
12864
12865impl SecureMemGetDynamicSecureHeapsResponder {
12866    /// Sends a response to the FIDL transaction.
12867    ///
12868    /// Sets the channel to shutdown if an error occurs.
12869    pub fn send(
12870        self,
12871        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12872    ) -> Result<(), fidl::Error> {
12873        let _result = self.send_raw(result);
12874        if _result.is_err() {
12875            self.control_handle.shutdown();
12876        }
12877        self.drop_without_shutdown();
12878        _result
12879    }
12880
12881    /// Similar to "send" but does not shutdown the channel if an error occurs.
12882    pub fn send_no_shutdown_on_err(
12883        self,
12884        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12885    ) -> Result<(), fidl::Error> {
12886        let _result = self.send_raw(result);
12887        self.drop_without_shutdown();
12888        _result
12889    }
12890
12891    fn send_raw(
12892        &self,
12893        mut result: Result<&SecureMemGetDynamicSecureHeapsResponse, Error>,
12894    ) -> Result<(), fidl::Error> {
12895        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12896            SecureMemGetDynamicSecureHeapsResponse,
12897            Error,
12898        >>(
12899            fidl::encoding::FlexibleResult::new(result),
12900            self.tx_id,
12901            0x1190847f99952834,
12902            fidl::encoding::DynamicFlags::FLEXIBLE,
12903        )
12904    }
12905}
12906
12907#[must_use = "FIDL methods require a response to be sent"]
12908#[derive(Debug)]
12909pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
12910    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12911    tx_id: u32,
12912}
12913
12914/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12915/// if the responder is dropped without sending a response, so that the client
12916/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12917impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
12918    fn drop(&mut self) {
12919        self.control_handle.shutdown();
12920        // Safety: drops once, never accessed again
12921        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12922    }
12923}
12924
12925impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
12926    type ControlHandle = SecureMemControlHandle;
12927
12928    fn control_handle(&self) -> &SecureMemControlHandle {
12929        &self.control_handle
12930    }
12931
12932    fn drop_without_shutdown(mut self) {
12933        // Safety: drops once, never accessed again due to mem::forget
12934        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12935        // Prevent Drop from running (which would shut down the channel)
12936        std::mem::forget(self);
12937    }
12938}
12939
12940impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
12941    /// Sends a response to the FIDL transaction.
12942    ///
12943    /// Sets the channel to shutdown if an error occurs.
12944    pub fn send(
12945        self,
12946        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12947    ) -> Result<(), fidl::Error> {
12948        let _result = self.send_raw(result);
12949        if _result.is_err() {
12950            self.control_handle.shutdown();
12951        }
12952        self.drop_without_shutdown();
12953        _result
12954    }
12955
12956    /// Similar to "send" but does not shutdown the channel if an error occurs.
12957    pub fn send_no_shutdown_on_err(
12958        self,
12959        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12960    ) -> Result<(), fidl::Error> {
12961        let _result = self.send_raw(result);
12962        self.drop_without_shutdown();
12963        _result
12964    }
12965
12966    fn send_raw(
12967        &self,
12968        mut result: Result<&SecureMemGetPhysicalSecureHeapPropertiesResponse, Error>,
12969    ) -> Result<(), fidl::Error> {
12970        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
12971            SecureMemGetPhysicalSecureHeapPropertiesResponse,
12972            Error,
12973        >>(
12974            fidl::encoding::FlexibleResult::new(result),
12975            self.tx_id,
12976            0xc6f06889009c7bc,
12977            fidl::encoding::DynamicFlags::FLEXIBLE,
12978        )
12979    }
12980}
12981
12982#[must_use = "FIDL methods require a response to be sent"]
12983#[derive(Debug)]
12984pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
12985    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
12986    tx_id: u32,
12987}
12988
12989/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
12990/// if the responder is dropped without sending a response, so that the client
12991/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12992impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
12993    fn drop(&mut self) {
12994        self.control_handle.shutdown();
12995        // Safety: drops once, never accessed again
12996        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12997    }
12998}
12999
13000impl fdomain_client::fidl::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
13001    type ControlHandle = SecureMemControlHandle;
13002
13003    fn control_handle(&self) -> &SecureMemControlHandle {
13004        &self.control_handle
13005    }
13006
13007    fn drop_without_shutdown(mut self) {
13008        // Safety: drops once, never accessed again due to mem::forget
13009        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13010        // Prevent Drop from running (which would shut down the channel)
13011        std::mem::forget(self);
13012    }
13013}
13014
13015impl SecureMemAddSecureHeapPhysicalRangeResponder {
13016    /// Sends a response to the FIDL transaction.
13017    ///
13018    /// Sets the channel to shutdown if an error occurs.
13019    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13020        let _result = self.send_raw(result);
13021        if _result.is_err() {
13022            self.control_handle.shutdown();
13023        }
13024        self.drop_without_shutdown();
13025        _result
13026    }
13027
13028    /// Similar to "send" but does not shutdown the channel if an error occurs.
13029    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13030        let _result = self.send_raw(result);
13031        self.drop_without_shutdown();
13032        _result
13033    }
13034
13035    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13036        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13037            fidl::encoding::EmptyStruct,
13038            Error,
13039        >>(
13040            fidl::encoding::FlexibleResult::new(result),
13041            self.tx_id,
13042            0x35f695b9b6c7217a,
13043            fidl::encoding::DynamicFlags::FLEXIBLE,
13044        )
13045    }
13046}
13047
13048#[must_use = "FIDL methods require a response to be sent"]
13049#[derive(Debug)]
13050pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
13051    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
13052    tx_id: u32,
13053}
13054
13055/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
13056/// if the responder is dropped without sending a response, so that the client
13057/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13058impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
13059    fn drop(&mut self) {
13060        self.control_handle.shutdown();
13061        // Safety: drops once, never accessed again
13062        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13063    }
13064}
13065
13066impl fdomain_client::fidl::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
13067    type ControlHandle = SecureMemControlHandle;
13068
13069    fn control_handle(&self) -> &SecureMemControlHandle {
13070        &self.control_handle
13071    }
13072
13073    fn drop_without_shutdown(mut self) {
13074        // Safety: drops once, never accessed again due to mem::forget
13075        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13076        // Prevent Drop from running (which would shut down the channel)
13077        std::mem::forget(self);
13078    }
13079}
13080
13081impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
13082    /// Sends a response to the FIDL transaction.
13083    ///
13084    /// Sets the channel to shutdown if an error occurs.
13085    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13086        let _result = self.send_raw(result);
13087        if _result.is_err() {
13088            self.control_handle.shutdown();
13089        }
13090        self.drop_without_shutdown();
13091        _result
13092    }
13093
13094    /// Similar to "send" but does not shutdown the channel if an error occurs.
13095    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13096        let _result = self.send_raw(result);
13097        self.drop_without_shutdown();
13098        _result
13099    }
13100
13101    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13102        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13103            fidl::encoding::EmptyStruct,
13104            Error,
13105        >>(
13106            fidl::encoding::FlexibleResult::new(result),
13107            self.tx_id,
13108            0xeaa58c650264c9e,
13109            fidl::encoding::DynamicFlags::FLEXIBLE,
13110        )
13111    }
13112}
13113
13114#[must_use = "FIDL methods require a response to be sent"]
13115#[derive(Debug)]
13116pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
13117    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
13118    tx_id: u32,
13119}
13120
13121/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
13122/// if the responder is dropped without sending a response, so that the client
13123/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13124impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
13125    fn drop(&mut self) {
13126        self.control_handle.shutdown();
13127        // Safety: drops once, never accessed again
13128        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13129    }
13130}
13131
13132impl fdomain_client::fidl::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
13133    type ControlHandle = SecureMemControlHandle;
13134
13135    fn control_handle(&self) -> &SecureMemControlHandle {
13136        &self.control_handle
13137    }
13138
13139    fn drop_without_shutdown(mut self) {
13140        // Safety: drops once, never accessed again due to mem::forget
13141        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13142        // Prevent Drop from running (which would shut down the channel)
13143        std::mem::forget(self);
13144    }
13145}
13146
13147impl SecureMemModifySecureHeapPhysicalRangeResponder {
13148    /// Sends a response to the FIDL transaction.
13149    ///
13150    /// Sets the channel to shutdown if an error occurs.
13151    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13152        let _result = self.send_raw(result);
13153        if _result.is_err() {
13154            self.control_handle.shutdown();
13155        }
13156        self.drop_without_shutdown();
13157        _result
13158    }
13159
13160    /// Similar to "send" but does not shutdown the channel if an error occurs.
13161    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13162        let _result = self.send_raw(result);
13163        self.drop_without_shutdown();
13164        _result
13165    }
13166
13167    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13168        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13169            fidl::encoding::EmptyStruct,
13170            Error,
13171        >>(
13172            fidl::encoding::FlexibleResult::new(result),
13173            self.tx_id,
13174            0x60b7448aa1187734,
13175            fidl::encoding::DynamicFlags::FLEXIBLE,
13176        )
13177    }
13178}
13179
13180#[must_use = "FIDL methods require a response to be sent"]
13181#[derive(Debug)]
13182pub struct SecureMemZeroSubRangeResponder {
13183    control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
13184    tx_id: u32,
13185}
13186
13187/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
13188/// if the responder is dropped without sending a response, so that the client
13189/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13190impl std::ops::Drop for SecureMemZeroSubRangeResponder {
13191    fn drop(&mut self) {
13192        self.control_handle.shutdown();
13193        // Safety: drops once, never accessed again
13194        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13195    }
13196}
13197
13198impl fdomain_client::fidl::Responder for SecureMemZeroSubRangeResponder {
13199    type ControlHandle = SecureMemControlHandle;
13200
13201    fn control_handle(&self) -> &SecureMemControlHandle {
13202        &self.control_handle
13203    }
13204
13205    fn drop_without_shutdown(mut self) {
13206        // Safety: drops once, never accessed again due to mem::forget
13207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13208        // Prevent Drop from running (which would shut down the channel)
13209        std::mem::forget(self);
13210    }
13211}
13212
13213impl SecureMemZeroSubRangeResponder {
13214    /// Sends a response to the FIDL transaction.
13215    ///
13216    /// Sets the channel to shutdown if an error occurs.
13217    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13218        let _result = self.send_raw(result);
13219        if _result.is_err() {
13220            self.control_handle.shutdown();
13221        }
13222        self.drop_without_shutdown();
13223        _result
13224    }
13225
13226    /// Similar to "send" but does not shutdown the channel if an error occurs.
13227    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13228        let _result = self.send_raw(result);
13229        self.drop_without_shutdown();
13230        _result
13231    }
13232
13233    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
13234        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
13235            fidl::encoding::EmptyStruct,
13236            Error,
13237        >>(
13238            fidl::encoding::FlexibleResult::new(result),
13239            self.tx_id,
13240            0x5b25b7901a385ce5,
13241            fidl::encoding::DynamicFlags::FLEXIBLE,
13242        )
13243    }
13244}
13245
13246mod internal {
13247    use super::*;
13248
13249    impl AllocatorAllocateNonSharedCollectionRequest {
13250        #[inline(always)]
13251        fn max_ordinal_present(&self) -> u64 {
13252            if let Some(_) = self.collection_request {
13253                return 1;
13254            }
13255            0
13256        }
13257    }
13258
13259    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
13260        type Borrowed<'a> = &'a mut Self;
13261        fn take_or_borrow<'a>(
13262            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13263        ) -> Self::Borrowed<'a> {
13264            value
13265        }
13266    }
13267
13268    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
13269        type Owned = Self;
13270
13271        #[inline(always)]
13272        fn inline_align(_context: fidl::encoding::Context) -> usize {
13273            8
13274        }
13275
13276        #[inline(always)]
13277        fn inline_size(_context: fidl::encoding::Context) -> usize {
13278            16
13279        }
13280    }
13281
13282    unsafe impl
13283        fidl::encoding::Encode<
13284            AllocatorAllocateNonSharedCollectionRequest,
13285            fdomain_client::fidl::FDomainResourceDialect,
13286        > for &mut AllocatorAllocateNonSharedCollectionRequest
13287    {
13288        unsafe fn encode(
13289            self,
13290            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13291            offset: usize,
13292            mut depth: fidl::encoding::Depth,
13293        ) -> fidl::Result<()> {
13294            encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
13295            // Vector header
13296            let max_ordinal: u64 = self.max_ordinal_present();
13297            encoder.write_num(max_ordinal, offset);
13298            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13299            // Calling encoder.out_of_line_offset(0) is not allowed.
13300            if max_ordinal == 0 {
13301                return Ok(());
13302            }
13303            depth.increment()?;
13304            let envelope_size = 8;
13305            let bytes_len = max_ordinal as usize * envelope_size;
13306            #[allow(unused_variables)]
13307            let offset = encoder.out_of_line_offset(bytes_len);
13308            let mut _prev_end_offset: usize = 0;
13309            if 1 > max_ordinal {
13310                return Ok(());
13311            }
13312
13313            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13314            // are envelope_size bytes.
13315            let cur_offset: usize = (1 - 1) * envelope_size;
13316
13317            // Zero reserved fields.
13318            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13319
13320            // Safety:
13321            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13322            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13323            //   envelope_size bytes, there is always sufficient room.
13324            fidl::encoding::encode_in_envelope_optional::<
13325                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
13326                fdomain_client::fidl::FDomainResourceDialect,
13327            >(
13328                self.collection_request.as_mut().map(
13329                    <fidl::encoding::Endpoint<
13330                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13331                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13332                ),
13333                encoder,
13334                offset + cur_offset,
13335                depth,
13336            )?;
13337
13338            _prev_end_offset = cur_offset + envelope_size;
13339
13340            Ok(())
13341        }
13342    }
13343
13344    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13345        for AllocatorAllocateNonSharedCollectionRequest
13346    {
13347        #[inline(always)]
13348        fn new_empty() -> Self {
13349            Self::default()
13350        }
13351
13352        unsafe fn decode(
13353            &mut self,
13354            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13355            offset: usize,
13356            mut depth: fidl::encoding::Depth,
13357        ) -> fidl::Result<()> {
13358            decoder.debug_check_bounds::<Self>(offset);
13359            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13360                None => return Err(fidl::Error::NotNullable),
13361                Some(len) => len,
13362            };
13363            // Calling decoder.out_of_line_offset(0) is not allowed.
13364            if len == 0 {
13365                return Ok(());
13366            };
13367            depth.increment()?;
13368            let envelope_size = 8;
13369            let bytes_len = len * envelope_size;
13370            let offset = decoder.out_of_line_offset(bytes_len)?;
13371            // Decode the envelope for each type.
13372            let mut _next_ordinal_to_read = 0;
13373            let mut next_offset = offset;
13374            let end_offset = offset + bytes_len;
13375            _next_ordinal_to_read += 1;
13376            if next_offset >= end_offset {
13377                return Ok(());
13378            }
13379
13380            // Decode unknown envelopes for gaps in ordinals.
13381            while _next_ordinal_to_read < 1 {
13382                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13383                _next_ordinal_to_read += 1;
13384                next_offset += envelope_size;
13385            }
13386
13387            let next_out_of_line = decoder.next_out_of_line();
13388            let handles_before = decoder.remaining_handles();
13389            if let Some((inlined, num_bytes, num_handles)) =
13390                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13391            {
13392                let member_inline_size = <fidl::encoding::Endpoint<
13393                    fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13394                > as fidl::encoding::TypeMarker>::inline_size(
13395                    decoder.context
13396                );
13397                if inlined != (member_inline_size <= 4) {
13398                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13399                }
13400                let inner_offset;
13401                let mut inner_depth = depth.clone();
13402                if inlined {
13403                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13404                    inner_offset = next_offset;
13405                } else {
13406                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13407                    inner_depth.increment()?;
13408                }
13409                let val_ref = self.collection_request.get_or_insert_with(|| {
13410                    fidl::new_empty!(
13411                        fidl::encoding::Endpoint<
13412                            fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13413                        >,
13414                        fdomain_client::fidl::FDomainResourceDialect
13415                    )
13416                });
13417                fidl::decode!(
13418                    fidl::encoding::Endpoint<
13419                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13420                    >,
13421                    fdomain_client::fidl::FDomainResourceDialect,
13422                    val_ref,
13423                    decoder,
13424                    inner_offset,
13425                    inner_depth
13426                )?;
13427                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13428                {
13429                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13430                }
13431                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13432                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13433                }
13434            }
13435
13436            next_offset += envelope_size;
13437
13438            // Decode the remaining unknown envelopes.
13439            while next_offset < end_offset {
13440                _next_ordinal_to_read += 1;
13441                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13442                next_offset += envelope_size;
13443            }
13444
13445            Ok(())
13446        }
13447    }
13448
13449    impl AllocatorAllocateSharedCollectionRequest {
13450        #[inline(always)]
13451        fn max_ordinal_present(&self) -> u64 {
13452            if let Some(_) = self.token_request {
13453                return 1;
13454            }
13455            0
13456        }
13457    }
13458
13459    impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
13460        type Borrowed<'a> = &'a mut Self;
13461        fn take_or_borrow<'a>(
13462            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13463        ) -> Self::Borrowed<'a> {
13464            value
13465        }
13466    }
13467
13468    unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
13469        type Owned = Self;
13470
13471        #[inline(always)]
13472        fn inline_align(_context: fidl::encoding::Context) -> usize {
13473            8
13474        }
13475
13476        #[inline(always)]
13477        fn inline_size(_context: fidl::encoding::Context) -> usize {
13478            16
13479        }
13480    }
13481
13482    unsafe impl
13483        fidl::encoding::Encode<
13484            AllocatorAllocateSharedCollectionRequest,
13485            fdomain_client::fidl::FDomainResourceDialect,
13486        > for &mut AllocatorAllocateSharedCollectionRequest
13487    {
13488        unsafe fn encode(
13489            self,
13490            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13491            offset: usize,
13492            mut depth: fidl::encoding::Depth,
13493        ) -> fidl::Result<()> {
13494            encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
13495            // Vector header
13496            let max_ordinal: u64 = self.max_ordinal_present();
13497            encoder.write_num(max_ordinal, offset);
13498            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13499            // Calling encoder.out_of_line_offset(0) is not allowed.
13500            if max_ordinal == 0 {
13501                return Ok(());
13502            }
13503            depth.increment()?;
13504            let envelope_size = 8;
13505            let bytes_len = max_ordinal as usize * envelope_size;
13506            #[allow(unused_variables)]
13507            let offset = encoder.out_of_line_offset(bytes_len);
13508            let mut _prev_end_offset: usize = 0;
13509            if 1 > max_ordinal {
13510                return Ok(());
13511            }
13512
13513            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13514            // are envelope_size bytes.
13515            let cur_offset: usize = (1 - 1) * envelope_size;
13516
13517            // Zero reserved fields.
13518            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13519
13520            // Safety:
13521            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13522            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13523            //   envelope_size bytes, there is always sufficient room.
13524            fidl::encoding::encode_in_envelope_optional::<
13525                fidl::encoding::Endpoint<
13526                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13527                >,
13528                fdomain_client::fidl::FDomainResourceDialect,
13529            >(
13530                self.token_request.as_mut().map(
13531                    <fidl::encoding::Endpoint<
13532                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13533                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13534                ),
13535                encoder,
13536                offset + cur_offset,
13537                depth,
13538            )?;
13539
13540            _prev_end_offset = cur_offset + envelope_size;
13541
13542            Ok(())
13543        }
13544    }
13545
13546    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13547        for AllocatorAllocateSharedCollectionRequest
13548    {
13549        #[inline(always)]
13550        fn new_empty() -> Self {
13551            Self::default()
13552        }
13553
13554        unsafe fn decode(
13555            &mut self,
13556            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13557            offset: usize,
13558            mut depth: fidl::encoding::Depth,
13559        ) -> fidl::Result<()> {
13560            decoder.debug_check_bounds::<Self>(offset);
13561            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13562                None => return Err(fidl::Error::NotNullable),
13563                Some(len) => len,
13564            };
13565            // Calling decoder.out_of_line_offset(0) is not allowed.
13566            if len == 0 {
13567                return Ok(());
13568            };
13569            depth.increment()?;
13570            let envelope_size = 8;
13571            let bytes_len = len * envelope_size;
13572            let offset = decoder.out_of_line_offset(bytes_len)?;
13573            // Decode the envelope for each type.
13574            let mut _next_ordinal_to_read = 0;
13575            let mut next_offset = offset;
13576            let end_offset = offset + bytes_len;
13577            _next_ordinal_to_read += 1;
13578            if next_offset >= end_offset {
13579                return Ok(());
13580            }
13581
13582            // Decode unknown envelopes for gaps in ordinals.
13583            while _next_ordinal_to_read < 1 {
13584                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13585                _next_ordinal_to_read += 1;
13586                next_offset += envelope_size;
13587            }
13588
13589            let next_out_of_line = decoder.next_out_of_line();
13590            let handles_before = decoder.remaining_handles();
13591            if let Some((inlined, num_bytes, num_handles)) =
13592                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13593            {
13594                let member_inline_size = <fidl::encoding::Endpoint<
13595                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13596                > as fidl::encoding::TypeMarker>::inline_size(
13597                    decoder.context
13598                );
13599                if inlined != (member_inline_size <= 4) {
13600                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13601                }
13602                let inner_offset;
13603                let mut inner_depth = depth.clone();
13604                if inlined {
13605                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13606                    inner_offset = next_offset;
13607                } else {
13608                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13609                    inner_depth.increment()?;
13610                }
13611                let val_ref = self.token_request.get_or_insert_with(|| {
13612                    fidl::new_empty!(
13613                        fidl::encoding::Endpoint<
13614                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13615                        >,
13616                        fdomain_client::fidl::FDomainResourceDialect
13617                    )
13618                });
13619                fidl::decode!(
13620                    fidl::encoding::Endpoint<
13621                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
13622                    >,
13623                    fdomain_client::fidl::FDomainResourceDialect,
13624                    val_ref,
13625                    decoder,
13626                    inner_offset,
13627                    inner_depth
13628                )?;
13629                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13630                {
13631                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13632                }
13633                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13634                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13635                }
13636            }
13637
13638            next_offset += envelope_size;
13639
13640            // Decode the remaining unknown envelopes.
13641            while next_offset < end_offset {
13642                _next_ordinal_to_read += 1;
13643                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13644                next_offset += envelope_size;
13645            }
13646
13647            Ok(())
13648        }
13649    }
13650
13651    impl AllocatorBindSharedCollectionRequest {
13652        #[inline(always)]
13653        fn max_ordinal_present(&self) -> u64 {
13654            if let Some(_) = self.buffer_collection_request {
13655                return 2;
13656            }
13657            if let Some(_) = self.token {
13658                return 1;
13659            }
13660            0
13661        }
13662    }
13663
13664    impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
13665        type Borrowed<'a> = &'a mut Self;
13666        fn take_or_borrow<'a>(
13667            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13668        ) -> Self::Borrowed<'a> {
13669            value
13670        }
13671    }
13672
13673    unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
13674        type Owned = Self;
13675
13676        #[inline(always)]
13677        fn inline_align(_context: fidl::encoding::Context) -> usize {
13678            8
13679        }
13680
13681        #[inline(always)]
13682        fn inline_size(_context: fidl::encoding::Context) -> usize {
13683            16
13684        }
13685    }
13686
13687    unsafe impl
13688        fidl::encoding::Encode<
13689            AllocatorBindSharedCollectionRequest,
13690            fdomain_client::fidl::FDomainResourceDialect,
13691        > for &mut AllocatorBindSharedCollectionRequest
13692    {
13693        unsafe fn encode(
13694            self,
13695            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13696            offset: usize,
13697            mut depth: fidl::encoding::Depth,
13698        ) -> fidl::Result<()> {
13699            encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
13700            // Vector header
13701            let max_ordinal: u64 = self.max_ordinal_present();
13702            encoder.write_num(max_ordinal, offset);
13703            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
13704            // Calling encoder.out_of_line_offset(0) is not allowed.
13705            if max_ordinal == 0 {
13706                return Ok(());
13707            }
13708            depth.increment()?;
13709            let envelope_size = 8;
13710            let bytes_len = max_ordinal as usize * envelope_size;
13711            #[allow(unused_variables)]
13712            let offset = encoder.out_of_line_offset(bytes_len);
13713            let mut _prev_end_offset: usize = 0;
13714            if 1 > max_ordinal {
13715                return Ok(());
13716            }
13717
13718            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13719            // are envelope_size bytes.
13720            let cur_offset: usize = (1 - 1) * envelope_size;
13721
13722            // Zero reserved fields.
13723            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13724
13725            // Safety:
13726            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13727            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13728            //   envelope_size bytes, there is always sufficient room.
13729            fidl::encoding::encode_in_envelope_optional::<
13730                fidl::encoding::Endpoint<
13731                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13732                >,
13733                fdomain_client::fidl::FDomainResourceDialect,
13734            >(
13735                self.token.as_mut().map(
13736                    <fidl::encoding::Endpoint<
13737                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13738                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13739                ),
13740                encoder,
13741                offset + cur_offset,
13742                depth,
13743            )?;
13744
13745            _prev_end_offset = cur_offset + envelope_size;
13746            if 2 > max_ordinal {
13747                return Ok(());
13748            }
13749
13750            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13751            // are envelope_size bytes.
13752            let cur_offset: usize = (2 - 1) * envelope_size;
13753
13754            // Zero reserved fields.
13755            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13756
13757            // Safety:
13758            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13759            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13760            //   envelope_size bytes, there is always sufficient room.
13761            fidl::encoding::encode_in_envelope_optional::<
13762                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
13763                fdomain_client::fidl::FDomainResourceDialect,
13764            >(
13765                self.buffer_collection_request.as_mut().map(
13766                    <fidl::encoding::Endpoint<
13767                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13768                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13769                ),
13770                encoder,
13771                offset + cur_offset,
13772                depth,
13773            )?;
13774
13775            _prev_end_offset = cur_offset + envelope_size;
13776
13777            Ok(())
13778        }
13779    }
13780
13781    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
13782        for AllocatorBindSharedCollectionRequest
13783    {
13784        #[inline(always)]
13785        fn new_empty() -> Self {
13786            Self::default()
13787        }
13788
13789        unsafe fn decode(
13790            &mut self,
13791            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
13792            offset: usize,
13793            mut depth: fidl::encoding::Depth,
13794        ) -> fidl::Result<()> {
13795            decoder.debug_check_bounds::<Self>(offset);
13796            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13797                None => return Err(fidl::Error::NotNullable),
13798                Some(len) => len,
13799            };
13800            // Calling decoder.out_of_line_offset(0) is not allowed.
13801            if len == 0 {
13802                return Ok(());
13803            };
13804            depth.increment()?;
13805            let envelope_size = 8;
13806            let bytes_len = len * envelope_size;
13807            let offset = decoder.out_of_line_offset(bytes_len)?;
13808            // Decode the envelope for each type.
13809            let mut _next_ordinal_to_read = 0;
13810            let mut next_offset = offset;
13811            let end_offset = offset + bytes_len;
13812            _next_ordinal_to_read += 1;
13813            if next_offset >= end_offset {
13814                return Ok(());
13815            }
13816
13817            // Decode unknown envelopes for gaps in ordinals.
13818            while _next_ordinal_to_read < 1 {
13819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13820                _next_ordinal_to_read += 1;
13821                next_offset += envelope_size;
13822            }
13823
13824            let next_out_of_line = decoder.next_out_of_line();
13825            let handles_before = decoder.remaining_handles();
13826            if let Some((inlined, num_bytes, num_handles)) =
13827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13828            {
13829                let member_inline_size = <fidl::encoding::Endpoint<
13830                    fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13831                > as fidl::encoding::TypeMarker>::inline_size(
13832                    decoder.context
13833                );
13834                if inlined != (member_inline_size <= 4) {
13835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13836                }
13837                let inner_offset;
13838                let mut inner_depth = depth.clone();
13839                if inlined {
13840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13841                    inner_offset = next_offset;
13842                } else {
13843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13844                    inner_depth.increment()?;
13845                }
13846                let val_ref = self.token.get_or_insert_with(|| {
13847                    fidl::new_empty!(
13848                        fidl::encoding::Endpoint<
13849                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13850                        >,
13851                        fdomain_client::fidl::FDomainResourceDialect
13852                    )
13853                });
13854                fidl::decode!(
13855                    fidl::encoding::Endpoint<
13856                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
13857                    >,
13858                    fdomain_client::fidl::FDomainResourceDialect,
13859                    val_ref,
13860                    decoder,
13861                    inner_offset,
13862                    inner_depth
13863                )?;
13864                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13865                {
13866                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13867                }
13868                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13869                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13870                }
13871            }
13872
13873            next_offset += envelope_size;
13874            _next_ordinal_to_read += 1;
13875            if next_offset >= end_offset {
13876                return Ok(());
13877            }
13878
13879            // Decode unknown envelopes for gaps in ordinals.
13880            while _next_ordinal_to_read < 2 {
13881                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13882                _next_ordinal_to_read += 1;
13883                next_offset += envelope_size;
13884            }
13885
13886            let next_out_of_line = decoder.next_out_of_line();
13887            let handles_before = decoder.remaining_handles();
13888            if let Some((inlined, num_bytes, num_handles)) =
13889                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13890            {
13891                let member_inline_size = <fidl::encoding::Endpoint<
13892                    fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13893                > as fidl::encoding::TypeMarker>::inline_size(
13894                    decoder.context
13895                );
13896                if inlined != (member_inline_size <= 4) {
13897                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13898                }
13899                let inner_offset;
13900                let mut inner_depth = depth.clone();
13901                if inlined {
13902                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13903                    inner_offset = next_offset;
13904                } else {
13905                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13906                    inner_depth.increment()?;
13907                }
13908                let val_ref = self.buffer_collection_request.get_or_insert_with(|| {
13909                    fidl::new_empty!(
13910                        fidl::encoding::Endpoint<
13911                            fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13912                        >,
13913                        fdomain_client::fidl::FDomainResourceDialect
13914                    )
13915                });
13916                fidl::decode!(
13917                    fidl::encoding::Endpoint<
13918                        fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
13919                    >,
13920                    fdomain_client::fidl::FDomainResourceDialect,
13921                    val_ref,
13922                    decoder,
13923                    inner_offset,
13924                    inner_depth
13925                )?;
13926                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13927                {
13928                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13929                }
13930                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13931                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13932                }
13933            }
13934
13935            next_offset += envelope_size;
13936
13937            // Decode the remaining unknown envelopes.
13938            while next_offset < end_offset {
13939                _next_ordinal_to_read += 1;
13940                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13941                next_offset += envelope_size;
13942            }
13943
13944            Ok(())
13945        }
13946    }
13947
13948    impl AllocatorGetVmoInfoRequest {
13949        #[inline(always)]
13950        fn max_ordinal_present(&self) -> u64 {
13951            if let Some(_) = self.vmo_settings_to_check_ignore_size {
13952                return 6;
13953            }
13954            if let Some(_) = self.vmo_settings_to_check {
13955                return 5;
13956            }
13957            if let Some(_) = self.constraints_to_check {
13958                return 4;
13959            }
13960            if let Some(_) = self.need_single_buffer_settings {
13961                return 3;
13962            }
13963            if let Some(_) = self.need_weak {
13964                return 2;
13965            }
13966            if let Some(_) = self.vmo {
13967                return 1;
13968            }
13969            0
13970        }
13971    }
13972
13973    impl fidl::encoding::ResourceTypeMarker for AllocatorGetVmoInfoRequest {
13974        type Borrowed<'a> = &'a mut Self;
13975        fn take_or_borrow<'a>(
13976            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
13977        ) -> Self::Borrowed<'a> {
13978            value
13979        }
13980    }
13981
13982    unsafe impl fidl::encoding::TypeMarker for AllocatorGetVmoInfoRequest {
13983        type Owned = Self;
13984
13985        #[inline(always)]
13986        fn inline_align(_context: fidl::encoding::Context) -> usize {
13987            8
13988        }
13989
13990        #[inline(always)]
13991        fn inline_size(_context: fidl::encoding::Context) -> usize {
13992            16
13993        }
13994    }
13995
13996    unsafe impl
13997        fidl::encoding::Encode<
13998            AllocatorGetVmoInfoRequest,
13999            fdomain_client::fidl::FDomainResourceDialect,
14000        > for &mut AllocatorGetVmoInfoRequest
14001    {
14002        unsafe fn encode(
14003            self,
14004            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14005            offset: usize,
14006            mut depth: fidl::encoding::Depth,
14007        ) -> fidl::Result<()> {
14008            encoder.debug_check_bounds::<AllocatorGetVmoInfoRequest>(offset);
14009            // Vector header
14010            let max_ordinal: u64 = self.max_ordinal_present();
14011            encoder.write_num(max_ordinal, offset);
14012            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14013            // Calling encoder.out_of_line_offset(0) is not allowed.
14014            if max_ordinal == 0 {
14015                return Ok(());
14016            }
14017            depth.increment()?;
14018            let envelope_size = 8;
14019            let bytes_len = max_ordinal as usize * envelope_size;
14020            #[allow(unused_variables)]
14021            let offset = encoder.out_of_line_offset(bytes_len);
14022            let mut _prev_end_offset: usize = 0;
14023            if 1 > 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 = (1 - 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                fidl::encoding::HandleType<
14040                    fdomain_client::Vmo,
14041                    { fidl::ObjectType::VMO.into_raw() },
14042                    2147483648,
14043                >,
14044                fdomain_client::fidl::FDomainResourceDialect,
14045            >(
14046                self.vmo.as_mut().map(
14047                    <fidl::encoding::HandleType<
14048                        fdomain_client::Vmo,
14049                        { fidl::ObjectType::VMO.into_raw() },
14050                        2147483648,
14051                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14052                ),
14053                encoder,
14054                offset + cur_offset,
14055                depth,
14056            )?;
14057
14058            _prev_end_offset = cur_offset + envelope_size;
14059            if 2 > max_ordinal {
14060                return Ok(());
14061            }
14062
14063            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14064            // are envelope_size bytes.
14065            let cur_offset: usize = (2 - 1) * envelope_size;
14066
14067            // Zero reserved fields.
14068            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14069
14070            // Safety:
14071            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14072            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14073            //   envelope_size bytes, there is always sufficient room.
14074            fidl::encoding::encode_in_envelope_optional::<
14075                bool,
14076                fdomain_client::fidl::FDomainResourceDialect,
14077            >(
14078                self.need_weak.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14079                encoder,
14080                offset + cur_offset,
14081                depth,
14082            )?;
14083
14084            _prev_end_offset = cur_offset + envelope_size;
14085            if 3 > max_ordinal {
14086                return Ok(());
14087            }
14088
14089            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14090            // are envelope_size bytes.
14091            let cur_offset: usize = (3 - 1) * envelope_size;
14092
14093            // Zero reserved fields.
14094            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14095
14096            // Safety:
14097            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14098            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14099            //   envelope_size bytes, there is always sufficient room.
14100            fidl::encoding::encode_in_envelope_optional::<
14101                bool,
14102                fdomain_client::fidl::FDomainResourceDialect,
14103            >(
14104                self.need_single_buffer_settings
14105                    .as_ref()
14106                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14107                encoder,
14108                offset + cur_offset,
14109                depth,
14110            )?;
14111
14112            _prev_end_offset = cur_offset + envelope_size;
14113            if 4 > max_ordinal {
14114                return Ok(());
14115            }
14116
14117            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14118            // are envelope_size bytes.
14119            let cur_offset: usize = (4 - 1) * envelope_size;
14120
14121            // Zero reserved fields.
14122            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14123
14124            // Safety:
14125            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14126            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14127            //   envelope_size bytes, there is always sufficient room.
14128            fidl::encoding::encode_in_envelope_optional::<
14129                BufferCollectionConstraints,
14130                fdomain_client::fidl::FDomainResourceDialect,
14131            >(
14132                self.constraints_to_check
14133                    .as_ref()
14134                    .map(<BufferCollectionConstraints as fidl::encoding::ValueTypeMarker>::borrow),
14135                encoder,
14136                offset + cur_offset,
14137                depth,
14138            )?;
14139
14140            _prev_end_offset = cur_offset + envelope_size;
14141            if 5 > 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 = (5 - 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                fidl::encoding::HandleType<
14158                    fdomain_client::Vmo,
14159                    { fidl::ObjectType::VMO.into_raw() },
14160                    2147483648,
14161                >,
14162                fdomain_client::fidl::FDomainResourceDialect,
14163            >(
14164                self.vmo_settings_to_check.as_mut().map(
14165                    <fidl::encoding::HandleType<
14166                        fdomain_client::Vmo,
14167                        { fidl::ObjectType::VMO.into_raw() },
14168                        2147483648,
14169                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14170                ),
14171                encoder,
14172                offset + cur_offset,
14173                depth,
14174            )?;
14175
14176            _prev_end_offset = cur_offset + envelope_size;
14177            if 6 > max_ordinal {
14178                return Ok(());
14179            }
14180
14181            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14182            // are envelope_size bytes.
14183            let cur_offset: usize = (6 - 1) * envelope_size;
14184
14185            // Zero reserved fields.
14186            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14187
14188            // Safety:
14189            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14190            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14191            //   envelope_size bytes, there is always sufficient room.
14192            fidl::encoding::encode_in_envelope_optional::<
14193                bool,
14194                fdomain_client::fidl::FDomainResourceDialect,
14195            >(
14196                self.vmo_settings_to_check_ignore_size
14197                    .as_ref()
14198                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14199                encoder,
14200                offset + cur_offset,
14201                depth,
14202            )?;
14203
14204            _prev_end_offset = cur_offset + envelope_size;
14205
14206            Ok(())
14207        }
14208    }
14209
14210    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14211        for AllocatorGetVmoInfoRequest
14212    {
14213        #[inline(always)]
14214        fn new_empty() -> Self {
14215            Self::default()
14216        }
14217
14218        unsafe fn decode(
14219            &mut self,
14220            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14221            offset: usize,
14222            mut depth: fidl::encoding::Depth,
14223        ) -> fidl::Result<()> {
14224            decoder.debug_check_bounds::<Self>(offset);
14225            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14226                None => return Err(fidl::Error::NotNullable),
14227                Some(len) => len,
14228            };
14229            // Calling decoder.out_of_line_offset(0) is not allowed.
14230            if len == 0 {
14231                return Ok(());
14232            };
14233            depth.increment()?;
14234            let envelope_size = 8;
14235            let bytes_len = len * envelope_size;
14236            let offset = decoder.out_of_line_offset(bytes_len)?;
14237            // Decode the envelope for each type.
14238            let mut _next_ordinal_to_read = 0;
14239            let mut next_offset = offset;
14240            let end_offset = offset + bytes_len;
14241            _next_ordinal_to_read += 1;
14242            if next_offset >= end_offset {
14243                return Ok(());
14244            }
14245
14246            // Decode unknown envelopes for gaps in ordinals.
14247            while _next_ordinal_to_read < 1 {
14248                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14249                _next_ordinal_to_read += 1;
14250                next_offset += envelope_size;
14251            }
14252
14253            let next_out_of_line = decoder.next_out_of_line();
14254            let handles_before = decoder.remaining_handles();
14255            if let Some((inlined, num_bytes, num_handles)) =
14256                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14257            {
14258                let member_inline_size = <fidl::encoding::HandleType<
14259                    fdomain_client::Vmo,
14260                    { fidl::ObjectType::VMO.into_raw() },
14261                    2147483648,
14262                > as fidl::encoding::TypeMarker>::inline_size(
14263                    decoder.context
14264                );
14265                if inlined != (member_inline_size <= 4) {
14266                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14267                }
14268                let inner_offset;
14269                let mut inner_depth = depth.clone();
14270                if inlined {
14271                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14272                    inner_offset = next_offset;
14273                } else {
14274                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14275                    inner_depth.increment()?;
14276                }
14277                let val_ref =
14278                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));
14279                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)?;
14280                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14281                {
14282                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14283                }
14284                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14285                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14286                }
14287            }
14288
14289            next_offset += envelope_size;
14290            _next_ordinal_to_read += 1;
14291            if next_offset >= end_offset {
14292                return Ok(());
14293            }
14294
14295            // Decode unknown envelopes for gaps in ordinals.
14296            while _next_ordinal_to_read < 2 {
14297                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14298                _next_ordinal_to_read += 1;
14299                next_offset += envelope_size;
14300            }
14301
14302            let next_out_of_line = decoder.next_out_of_line();
14303            let handles_before = decoder.remaining_handles();
14304            if let Some((inlined, num_bytes, num_handles)) =
14305                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14306            {
14307                let member_inline_size =
14308                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14309                if inlined != (member_inline_size <= 4) {
14310                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14311                }
14312                let inner_offset;
14313                let mut inner_depth = depth.clone();
14314                if inlined {
14315                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14316                    inner_offset = next_offset;
14317                } else {
14318                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14319                    inner_depth.increment()?;
14320                }
14321                let val_ref = self.need_weak.get_or_insert_with(|| {
14322                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
14323                });
14324                fidl::decode!(
14325                    bool,
14326                    fdomain_client::fidl::FDomainResourceDialect,
14327                    val_ref,
14328                    decoder,
14329                    inner_offset,
14330                    inner_depth
14331                )?;
14332                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14333                {
14334                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14335                }
14336                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14337                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14338                }
14339            }
14340
14341            next_offset += envelope_size;
14342            _next_ordinal_to_read += 1;
14343            if next_offset >= end_offset {
14344                return Ok(());
14345            }
14346
14347            // Decode unknown envelopes for gaps in ordinals.
14348            while _next_ordinal_to_read < 3 {
14349                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14350                _next_ordinal_to_read += 1;
14351                next_offset += envelope_size;
14352            }
14353
14354            let next_out_of_line = decoder.next_out_of_line();
14355            let handles_before = decoder.remaining_handles();
14356            if let Some((inlined, num_bytes, num_handles)) =
14357                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14358            {
14359                let member_inline_size =
14360                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14361                if inlined != (member_inline_size <= 4) {
14362                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14363                }
14364                let inner_offset;
14365                let mut inner_depth = depth.clone();
14366                if inlined {
14367                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14368                    inner_offset = next_offset;
14369                } else {
14370                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14371                    inner_depth.increment()?;
14372                }
14373                let val_ref = self.need_single_buffer_settings.get_or_insert_with(|| {
14374                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
14375                });
14376                fidl::decode!(
14377                    bool,
14378                    fdomain_client::fidl::FDomainResourceDialect,
14379                    val_ref,
14380                    decoder,
14381                    inner_offset,
14382                    inner_depth
14383                )?;
14384                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14385                {
14386                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14387                }
14388                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14389                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14390                }
14391            }
14392
14393            next_offset += envelope_size;
14394            _next_ordinal_to_read += 1;
14395            if next_offset >= end_offset {
14396                return Ok(());
14397            }
14398
14399            // Decode unknown envelopes for gaps in ordinals.
14400            while _next_ordinal_to_read < 4 {
14401                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14402                _next_ordinal_to_read += 1;
14403                next_offset += envelope_size;
14404            }
14405
14406            let next_out_of_line = decoder.next_out_of_line();
14407            let handles_before = decoder.remaining_handles();
14408            if let Some((inlined, num_bytes, num_handles)) =
14409                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14410            {
14411                let member_inline_size =
14412                    <BufferCollectionConstraints as fidl::encoding::TypeMarker>::inline_size(
14413                        decoder.context,
14414                    );
14415                if inlined != (member_inline_size <= 4) {
14416                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14417                }
14418                let inner_offset;
14419                let mut inner_depth = depth.clone();
14420                if inlined {
14421                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14422                    inner_offset = next_offset;
14423                } else {
14424                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14425                    inner_depth.increment()?;
14426                }
14427                let val_ref = self.constraints_to_check.get_or_insert_with(|| {
14428                    fidl::new_empty!(
14429                        BufferCollectionConstraints,
14430                        fdomain_client::fidl::FDomainResourceDialect
14431                    )
14432                });
14433                fidl::decode!(
14434                    BufferCollectionConstraints,
14435                    fdomain_client::fidl::FDomainResourceDialect,
14436                    val_ref,
14437                    decoder,
14438                    inner_offset,
14439                    inner_depth
14440                )?;
14441                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14442                {
14443                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14444                }
14445                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14446                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14447                }
14448            }
14449
14450            next_offset += envelope_size;
14451            _next_ordinal_to_read += 1;
14452            if next_offset >= end_offset {
14453                return Ok(());
14454            }
14455
14456            // Decode unknown envelopes for gaps in ordinals.
14457            while _next_ordinal_to_read < 5 {
14458                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14459                _next_ordinal_to_read += 1;
14460                next_offset += envelope_size;
14461            }
14462
14463            let next_out_of_line = decoder.next_out_of_line();
14464            let handles_before = decoder.remaining_handles();
14465            if let Some((inlined, num_bytes, num_handles)) =
14466                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14467            {
14468                let member_inline_size = <fidl::encoding::HandleType<
14469                    fdomain_client::Vmo,
14470                    { fidl::ObjectType::VMO.into_raw() },
14471                    2147483648,
14472                > as fidl::encoding::TypeMarker>::inline_size(
14473                    decoder.context
14474                );
14475                if inlined != (member_inline_size <= 4) {
14476                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14477                }
14478                let inner_offset;
14479                let mut inner_depth = depth.clone();
14480                if inlined {
14481                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14482                    inner_offset = next_offset;
14483                } else {
14484                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14485                    inner_depth.increment()?;
14486                }
14487                let val_ref =
14488                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));
14489                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)?;
14490                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14491                {
14492                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14493                }
14494                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14495                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14496                }
14497            }
14498
14499            next_offset += envelope_size;
14500            _next_ordinal_to_read += 1;
14501            if next_offset >= end_offset {
14502                return Ok(());
14503            }
14504
14505            // Decode unknown envelopes for gaps in ordinals.
14506            while _next_ordinal_to_read < 6 {
14507                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14508                _next_ordinal_to_read += 1;
14509                next_offset += envelope_size;
14510            }
14511
14512            let next_out_of_line = decoder.next_out_of_line();
14513            let handles_before = decoder.remaining_handles();
14514            if let Some((inlined, num_bytes, num_handles)) =
14515                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14516            {
14517                let member_inline_size =
14518                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14519                if inlined != (member_inline_size <= 4) {
14520                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14521                }
14522                let inner_offset;
14523                let mut inner_depth = depth.clone();
14524                if inlined {
14525                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14526                    inner_offset = next_offset;
14527                } else {
14528                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14529                    inner_depth.increment()?;
14530                }
14531                let val_ref = self.vmo_settings_to_check_ignore_size.get_or_insert_with(|| {
14532                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
14533                });
14534                fidl::decode!(
14535                    bool,
14536                    fdomain_client::fidl::FDomainResourceDialect,
14537                    val_ref,
14538                    decoder,
14539                    inner_offset,
14540                    inner_depth
14541                )?;
14542                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14543                {
14544                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14545                }
14546                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14547                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14548                }
14549            }
14550
14551            next_offset += envelope_size;
14552
14553            // Decode the remaining unknown envelopes.
14554            while next_offset < end_offset {
14555                _next_ordinal_to_read += 1;
14556                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14557                next_offset += envelope_size;
14558            }
14559
14560            Ok(())
14561        }
14562    }
14563
14564    impl AllocatorGetVmoInfoResponse {
14565        #[inline(always)]
14566        fn max_ordinal_present(&self) -> u64 {
14567            if let Some(_) = self.vmo_settings_match {
14568                return 7;
14569            }
14570            if let Some(_) = self.constraints_ok {
14571                return 6;
14572            }
14573            if let Some(_) = self.single_buffer_settings {
14574                return 5;
14575            }
14576            if let Some(_) = self.weak_vmo {
14577                return 4;
14578            }
14579            if let Some(_) = self.close_weak_asap {
14580                return 3;
14581            }
14582            if let Some(_) = self.buffer_index {
14583                return 2;
14584            }
14585            if let Some(_) = self.buffer_collection_id {
14586                return 1;
14587            }
14588            0
14589        }
14590    }
14591
14592    impl fidl::encoding::ResourceTypeMarker for AllocatorGetVmoInfoResponse {
14593        type Borrowed<'a> = &'a mut Self;
14594        fn take_or_borrow<'a>(
14595            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
14596        ) -> Self::Borrowed<'a> {
14597            value
14598        }
14599    }
14600
14601    unsafe impl fidl::encoding::TypeMarker for AllocatorGetVmoInfoResponse {
14602        type Owned = Self;
14603
14604        #[inline(always)]
14605        fn inline_align(_context: fidl::encoding::Context) -> usize {
14606            8
14607        }
14608
14609        #[inline(always)]
14610        fn inline_size(_context: fidl::encoding::Context) -> usize {
14611            16
14612        }
14613    }
14614
14615    unsafe impl
14616        fidl::encoding::Encode<
14617            AllocatorGetVmoInfoResponse,
14618            fdomain_client::fidl::FDomainResourceDialect,
14619        > for &mut AllocatorGetVmoInfoResponse
14620    {
14621        unsafe fn encode(
14622            self,
14623            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14624            offset: usize,
14625            mut depth: fidl::encoding::Depth,
14626        ) -> fidl::Result<()> {
14627            encoder.debug_check_bounds::<AllocatorGetVmoInfoResponse>(offset);
14628            // Vector header
14629            let max_ordinal: u64 = self.max_ordinal_present();
14630            encoder.write_num(max_ordinal, offset);
14631            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
14632            // Calling encoder.out_of_line_offset(0) is not allowed.
14633            if max_ordinal == 0 {
14634                return Ok(());
14635            }
14636            depth.increment()?;
14637            let envelope_size = 8;
14638            let bytes_len = max_ordinal as usize * envelope_size;
14639            #[allow(unused_variables)]
14640            let offset = encoder.out_of_line_offset(bytes_len);
14641            let mut _prev_end_offset: usize = 0;
14642            if 1 > max_ordinal {
14643                return Ok(());
14644            }
14645
14646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14647            // are envelope_size bytes.
14648            let cur_offset: usize = (1 - 1) * envelope_size;
14649
14650            // Zero reserved fields.
14651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14652
14653            // Safety:
14654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14656            //   envelope_size bytes, there is always sufficient room.
14657            fidl::encoding::encode_in_envelope_optional::<
14658                u64,
14659                fdomain_client::fidl::FDomainResourceDialect,
14660            >(
14661                self.buffer_collection_id
14662                    .as_ref()
14663                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
14664                encoder,
14665                offset + cur_offset,
14666                depth,
14667            )?;
14668
14669            _prev_end_offset = cur_offset + envelope_size;
14670            if 2 > max_ordinal {
14671                return Ok(());
14672            }
14673
14674            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14675            // are envelope_size bytes.
14676            let cur_offset: usize = (2 - 1) * envelope_size;
14677
14678            // Zero reserved fields.
14679            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14680
14681            // Safety:
14682            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14683            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14684            //   envelope_size bytes, there is always sufficient room.
14685            fidl::encoding::encode_in_envelope_optional::<
14686                u64,
14687                fdomain_client::fidl::FDomainResourceDialect,
14688            >(
14689                self.buffer_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
14690                encoder,
14691                offset + cur_offset,
14692                depth,
14693            )?;
14694
14695            _prev_end_offset = cur_offset + envelope_size;
14696            if 3 > 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 = (3 - 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::EventPair,
14714                    { fidl::ObjectType::EVENTPAIR.into_raw() },
14715                    2147483648,
14716                >,
14717                fdomain_client::fidl::FDomainResourceDialect,
14718            >(
14719                self.close_weak_asap.as_mut().map(
14720                    <fidl::encoding::HandleType<
14721                        fdomain_client::EventPair,
14722                        { fidl::ObjectType::EVENTPAIR.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 4 > 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 = (4 - 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                fidl::encoding::HandleType<
14749                    fdomain_client::Vmo,
14750                    { fidl::ObjectType::VMO.into_raw() },
14751                    2147483648,
14752                >,
14753                fdomain_client::fidl::FDomainResourceDialect,
14754            >(
14755                self.weak_vmo.as_mut().map(
14756                    <fidl::encoding::HandleType<
14757                        fdomain_client::Vmo,
14758                        { fidl::ObjectType::VMO.into_raw() },
14759                        2147483648,
14760                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
14761                ),
14762                encoder,
14763                offset + cur_offset,
14764                depth,
14765            )?;
14766
14767            _prev_end_offset = cur_offset + envelope_size;
14768            if 5 > max_ordinal {
14769                return Ok(());
14770            }
14771
14772            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14773            // are envelope_size bytes.
14774            let cur_offset: usize = (5 - 1) * envelope_size;
14775
14776            // Zero reserved fields.
14777            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14778
14779            // Safety:
14780            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14781            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14782            //   envelope_size bytes, there is always sufficient room.
14783            fidl::encoding::encode_in_envelope_optional::<
14784                SingleBufferSettings,
14785                fdomain_client::fidl::FDomainResourceDialect,
14786            >(
14787                self.single_buffer_settings
14788                    .as_ref()
14789                    .map(<SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow),
14790                encoder,
14791                offset + cur_offset,
14792                depth,
14793            )?;
14794
14795            _prev_end_offset = cur_offset + envelope_size;
14796            if 6 > max_ordinal {
14797                return Ok(());
14798            }
14799
14800            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14801            // are envelope_size bytes.
14802            let cur_offset: usize = (6 - 1) * envelope_size;
14803
14804            // Zero reserved fields.
14805            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14806
14807            // Safety:
14808            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14809            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14810            //   envelope_size bytes, there is always sufficient room.
14811            fidl::encoding::encode_in_envelope_optional::<
14812                bool,
14813                fdomain_client::fidl::FDomainResourceDialect,
14814            >(
14815                self.constraints_ok.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14816                encoder,
14817                offset + cur_offset,
14818                depth,
14819            )?;
14820
14821            _prev_end_offset = cur_offset + envelope_size;
14822            if 7 > max_ordinal {
14823                return Ok(());
14824            }
14825
14826            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
14827            // are envelope_size bytes.
14828            let cur_offset: usize = (7 - 1) * envelope_size;
14829
14830            // Zero reserved fields.
14831            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
14832
14833            // Safety:
14834            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
14835            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
14836            //   envelope_size bytes, there is always sufficient room.
14837            fidl::encoding::encode_in_envelope_optional::<
14838                bool,
14839                fdomain_client::fidl::FDomainResourceDialect,
14840            >(
14841                self.vmo_settings_match
14842                    .as_ref()
14843                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
14844                encoder,
14845                offset + cur_offset,
14846                depth,
14847            )?;
14848
14849            _prev_end_offset = cur_offset + envelope_size;
14850
14851            Ok(())
14852        }
14853    }
14854
14855    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
14856        for AllocatorGetVmoInfoResponse
14857    {
14858        #[inline(always)]
14859        fn new_empty() -> Self {
14860            Self::default()
14861        }
14862
14863        unsafe fn decode(
14864            &mut self,
14865            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
14866            offset: usize,
14867            mut depth: fidl::encoding::Depth,
14868        ) -> fidl::Result<()> {
14869            decoder.debug_check_bounds::<Self>(offset);
14870            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
14871                None => return Err(fidl::Error::NotNullable),
14872                Some(len) => len,
14873            };
14874            // Calling decoder.out_of_line_offset(0) is not allowed.
14875            if len == 0 {
14876                return Ok(());
14877            };
14878            depth.increment()?;
14879            let envelope_size = 8;
14880            let bytes_len = len * envelope_size;
14881            let offset = decoder.out_of_line_offset(bytes_len)?;
14882            // Decode the envelope for each type.
14883            let mut _next_ordinal_to_read = 0;
14884            let mut next_offset = offset;
14885            let end_offset = offset + bytes_len;
14886            _next_ordinal_to_read += 1;
14887            if next_offset >= end_offset {
14888                return Ok(());
14889            }
14890
14891            // Decode unknown envelopes for gaps in ordinals.
14892            while _next_ordinal_to_read < 1 {
14893                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14894                _next_ordinal_to_read += 1;
14895                next_offset += envelope_size;
14896            }
14897
14898            let next_out_of_line = decoder.next_out_of_line();
14899            let handles_before = decoder.remaining_handles();
14900            if let Some((inlined, num_bytes, num_handles)) =
14901                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14902            {
14903                let member_inline_size =
14904                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14905                if inlined != (member_inline_size <= 4) {
14906                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14907                }
14908                let inner_offset;
14909                let mut inner_depth = depth.clone();
14910                if inlined {
14911                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14912                    inner_offset = next_offset;
14913                } else {
14914                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14915                    inner_depth.increment()?;
14916                }
14917                let val_ref = self.buffer_collection_id.get_or_insert_with(|| {
14918                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
14919                });
14920                fidl::decode!(
14921                    u64,
14922                    fdomain_client::fidl::FDomainResourceDialect,
14923                    val_ref,
14924                    decoder,
14925                    inner_offset,
14926                    inner_depth
14927                )?;
14928                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14929                {
14930                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14931                }
14932                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14933                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14934                }
14935            }
14936
14937            next_offset += envelope_size;
14938            _next_ordinal_to_read += 1;
14939            if next_offset >= end_offset {
14940                return Ok(());
14941            }
14942
14943            // Decode unknown envelopes for gaps in ordinals.
14944            while _next_ordinal_to_read < 2 {
14945                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14946                _next_ordinal_to_read += 1;
14947                next_offset += envelope_size;
14948            }
14949
14950            let next_out_of_line = decoder.next_out_of_line();
14951            let handles_before = decoder.remaining_handles();
14952            if let Some((inlined, num_bytes, num_handles)) =
14953                fidl::encoding::decode_envelope_header(decoder, next_offset)?
14954            {
14955                let member_inline_size =
14956                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
14957                if inlined != (member_inline_size <= 4) {
14958                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
14959                }
14960                let inner_offset;
14961                let mut inner_depth = depth.clone();
14962                if inlined {
14963                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
14964                    inner_offset = next_offset;
14965                } else {
14966                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
14967                    inner_depth.increment()?;
14968                }
14969                let val_ref = self.buffer_index.get_or_insert_with(|| {
14970                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
14971                });
14972                fidl::decode!(
14973                    u64,
14974                    fdomain_client::fidl::FDomainResourceDialect,
14975                    val_ref,
14976                    decoder,
14977                    inner_offset,
14978                    inner_depth
14979                )?;
14980                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
14981                {
14982                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
14983                }
14984                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
14985                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
14986                }
14987            }
14988
14989            next_offset += envelope_size;
14990            _next_ordinal_to_read += 1;
14991            if next_offset >= end_offset {
14992                return Ok(());
14993            }
14994
14995            // Decode unknown envelopes for gaps in ordinals.
14996            while _next_ordinal_to_read < 3 {
14997                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
14998                _next_ordinal_to_read += 1;
14999                next_offset += envelope_size;
15000            }
15001
15002            let next_out_of_line = decoder.next_out_of_line();
15003            let handles_before = decoder.remaining_handles();
15004            if let Some((inlined, num_bytes, num_handles)) =
15005                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15006            {
15007                let member_inline_size = <fidl::encoding::HandleType<
15008                    fdomain_client::EventPair,
15009                    { fidl::ObjectType::EVENTPAIR.into_raw() },
15010                    2147483648,
15011                > as fidl::encoding::TypeMarker>::inline_size(
15012                    decoder.context
15013                );
15014                if inlined != (member_inline_size <= 4) {
15015                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15016                }
15017                let inner_offset;
15018                let mut inner_depth = depth.clone();
15019                if inlined {
15020                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15021                    inner_offset = next_offset;
15022                } else {
15023                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15024                    inner_depth.increment()?;
15025                }
15026                let val_ref =
15027                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));
15028                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)?;
15029                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15030                {
15031                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15032                }
15033                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15034                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15035                }
15036            }
15037
15038            next_offset += envelope_size;
15039            _next_ordinal_to_read += 1;
15040            if next_offset >= end_offset {
15041                return Ok(());
15042            }
15043
15044            // Decode unknown envelopes for gaps in ordinals.
15045            while _next_ordinal_to_read < 4 {
15046                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15047                _next_ordinal_to_read += 1;
15048                next_offset += envelope_size;
15049            }
15050
15051            let next_out_of_line = decoder.next_out_of_line();
15052            let handles_before = decoder.remaining_handles();
15053            if let Some((inlined, num_bytes, num_handles)) =
15054                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15055            {
15056                let member_inline_size = <fidl::encoding::HandleType<
15057                    fdomain_client::Vmo,
15058                    { fidl::ObjectType::VMO.into_raw() },
15059                    2147483648,
15060                > as fidl::encoding::TypeMarker>::inline_size(
15061                    decoder.context
15062                );
15063                if inlined != (member_inline_size <= 4) {
15064                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15065                }
15066                let inner_offset;
15067                let mut inner_depth = depth.clone();
15068                if inlined {
15069                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15070                    inner_offset = next_offset;
15071                } else {
15072                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15073                    inner_depth.increment()?;
15074                }
15075                let val_ref =
15076                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));
15077                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)?;
15078                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15079                {
15080                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15081                }
15082                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15083                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15084                }
15085            }
15086
15087            next_offset += envelope_size;
15088            _next_ordinal_to_read += 1;
15089            if next_offset >= end_offset {
15090                return Ok(());
15091            }
15092
15093            // Decode unknown envelopes for gaps in ordinals.
15094            while _next_ordinal_to_read < 5 {
15095                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15096                _next_ordinal_to_read += 1;
15097                next_offset += envelope_size;
15098            }
15099
15100            let next_out_of_line = decoder.next_out_of_line();
15101            let handles_before = decoder.remaining_handles();
15102            if let Some((inlined, num_bytes, num_handles)) =
15103                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15104            {
15105                let member_inline_size =
15106                    <SingleBufferSettings as fidl::encoding::TypeMarker>::inline_size(
15107                        decoder.context,
15108                    );
15109                if inlined != (member_inline_size <= 4) {
15110                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15111                }
15112                let inner_offset;
15113                let mut inner_depth = depth.clone();
15114                if inlined {
15115                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15116                    inner_offset = next_offset;
15117                } else {
15118                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15119                    inner_depth.increment()?;
15120                }
15121                let val_ref = self.single_buffer_settings.get_or_insert_with(|| {
15122                    fidl::new_empty!(
15123                        SingleBufferSettings,
15124                        fdomain_client::fidl::FDomainResourceDialect
15125                    )
15126                });
15127                fidl::decode!(
15128                    SingleBufferSettings,
15129                    fdomain_client::fidl::FDomainResourceDialect,
15130                    val_ref,
15131                    decoder,
15132                    inner_offset,
15133                    inner_depth
15134                )?;
15135                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15136                {
15137                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15138                }
15139                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15140                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15141                }
15142            }
15143
15144            next_offset += envelope_size;
15145            _next_ordinal_to_read += 1;
15146            if next_offset >= end_offset {
15147                return Ok(());
15148            }
15149
15150            // Decode unknown envelopes for gaps in ordinals.
15151            while _next_ordinal_to_read < 6 {
15152                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15153                _next_ordinal_to_read += 1;
15154                next_offset += envelope_size;
15155            }
15156
15157            let next_out_of_line = decoder.next_out_of_line();
15158            let handles_before = decoder.remaining_handles();
15159            if let Some((inlined, num_bytes, num_handles)) =
15160                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15161            {
15162                let member_inline_size =
15163                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15164                if inlined != (member_inline_size <= 4) {
15165                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15166                }
15167                let inner_offset;
15168                let mut inner_depth = depth.clone();
15169                if inlined {
15170                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15171                    inner_offset = next_offset;
15172                } else {
15173                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15174                    inner_depth.increment()?;
15175                }
15176                let val_ref = self.constraints_ok.get_or_insert_with(|| {
15177                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
15178                });
15179                fidl::decode!(
15180                    bool,
15181                    fdomain_client::fidl::FDomainResourceDialect,
15182                    val_ref,
15183                    decoder,
15184                    inner_offset,
15185                    inner_depth
15186                )?;
15187                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15188                {
15189                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15190                }
15191                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15192                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15193                }
15194            }
15195
15196            next_offset += envelope_size;
15197            _next_ordinal_to_read += 1;
15198            if next_offset >= end_offset {
15199                return Ok(());
15200            }
15201
15202            // Decode unknown envelopes for gaps in ordinals.
15203            while _next_ordinal_to_read < 7 {
15204                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15205                _next_ordinal_to_read += 1;
15206                next_offset += envelope_size;
15207            }
15208
15209            let next_out_of_line = decoder.next_out_of_line();
15210            let handles_before = decoder.remaining_handles();
15211            if let Some((inlined, num_bytes, num_handles)) =
15212                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15213            {
15214                let member_inline_size =
15215                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15216                if inlined != (member_inline_size <= 4) {
15217                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15218                }
15219                let inner_offset;
15220                let mut inner_depth = depth.clone();
15221                if inlined {
15222                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15223                    inner_offset = next_offset;
15224                } else {
15225                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15226                    inner_depth.increment()?;
15227                }
15228                let val_ref = self.vmo_settings_match.get_or_insert_with(|| {
15229                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
15230                });
15231                fidl::decode!(
15232                    bool,
15233                    fdomain_client::fidl::FDomainResourceDialect,
15234                    val_ref,
15235                    decoder,
15236                    inner_offset,
15237                    inner_depth
15238                )?;
15239                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15240                {
15241                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15242                }
15243                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15244                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15245                }
15246            }
15247
15248            next_offset += envelope_size;
15249
15250            // Decode the remaining unknown envelopes.
15251            while next_offset < end_offset {
15252                _next_ordinal_to_read += 1;
15253                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15254                next_offset += envelope_size;
15255            }
15256
15257            Ok(())
15258        }
15259    }
15260
15261    impl BufferCollectionAttachLifetimeTrackingRequest {
15262        #[inline(always)]
15263        fn max_ordinal_present(&self) -> u64 {
15264            if let Some(_) = self.buffers_remaining {
15265                return 2;
15266            }
15267            if let Some(_) = self.server_end {
15268                return 1;
15269            }
15270            0
15271        }
15272    }
15273
15274    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
15275        type Borrowed<'a> = &'a mut Self;
15276        fn take_or_borrow<'a>(
15277            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15278        ) -> Self::Borrowed<'a> {
15279            value
15280        }
15281    }
15282
15283    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
15284        type Owned = Self;
15285
15286        #[inline(always)]
15287        fn inline_align(_context: fidl::encoding::Context) -> usize {
15288            8
15289        }
15290
15291        #[inline(always)]
15292        fn inline_size(_context: fidl::encoding::Context) -> usize {
15293            16
15294        }
15295    }
15296
15297    unsafe impl
15298        fidl::encoding::Encode<
15299            BufferCollectionAttachLifetimeTrackingRequest,
15300            fdomain_client::fidl::FDomainResourceDialect,
15301        > for &mut BufferCollectionAttachLifetimeTrackingRequest
15302    {
15303        unsafe fn encode(
15304            self,
15305            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15306            offset: usize,
15307            mut depth: fidl::encoding::Depth,
15308        ) -> fidl::Result<()> {
15309            encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
15310            // Vector header
15311            let max_ordinal: u64 = self.max_ordinal_present();
15312            encoder.write_num(max_ordinal, offset);
15313            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15314            // Calling encoder.out_of_line_offset(0) is not allowed.
15315            if max_ordinal == 0 {
15316                return Ok(());
15317            }
15318            depth.increment()?;
15319            let envelope_size = 8;
15320            let bytes_len = max_ordinal as usize * envelope_size;
15321            #[allow(unused_variables)]
15322            let offset = encoder.out_of_line_offset(bytes_len);
15323            let mut _prev_end_offset: usize = 0;
15324            if 1 > 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 = (1 - 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                fidl::encoding::HandleType<
15341                    fdomain_client::EventPair,
15342                    { fidl::ObjectType::EVENTPAIR.into_raw() },
15343                    2147483648,
15344                >,
15345                fdomain_client::fidl::FDomainResourceDialect,
15346            >(
15347                self.server_end.as_mut().map(
15348                    <fidl::encoding::HandleType<
15349                        fdomain_client::EventPair,
15350                        { fidl::ObjectType::EVENTPAIR.into_raw() },
15351                        2147483648,
15352                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15353                ),
15354                encoder,
15355                offset + cur_offset,
15356                depth,
15357            )?;
15358
15359            _prev_end_offset = cur_offset + envelope_size;
15360            if 2 > max_ordinal {
15361                return Ok(());
15362            }
15363
15364            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15365            // are envelope_size bytes.
15366            let cur_offset: usize = (2 - 1) * envelope_size;
15367
15368            // Zero reserved fields.
15369            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15370
15371            // Safety:
15372            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15373            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15374            //   envelope_size bytes, there is always sufficient room.
15375            fidl::encoding::encode_in_envelope_optional::<
15376                u32,
15377                fdomain_client::fidl::FDomainResourceDialect,
15378            >(
15379                self.buffers_remaining
15380                    .as_ref()
15381                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
15382                encoder,
15383                offset + cur_offset,
15384                depth,
15385            )?;
15386
15387            _prev_end_offset = cur_offset + envelope_size;
15388
15389            Ok(())
15390        }
15391    }
15392
15393    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15394        for BufferCollectionAttachLifetimeTrackingRequest
15395    {
15396        #[inline(always)]
15397        fn new_empty() -> Self {
15398            Self::default()
15399        }
15400
15401        unsafe fn decode(
15402            &mut self,
15403            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15404            offset: usize,
15405            mut depth: fidl::encoding::Depth,
15406        ) -> fidl::Result<()> {
15407            decoder.debug_check_bounds::<Self>(offset);
15408            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15409                None => return Err(fidl::Error::NotNullable),
15410                Some(len) => len,
15411            };
15412            // Calling decoder.out_of_line_offset(0) is not allowed.
15413            if len == 0 {
15414                return Ok(());
15415            };
15416            depth.increment()?;
15417            let envelope_size = 8;
15418            let bytes_len = len * envelope_size;
15419            let offset = decoder.out_of_line_offset(bytes_len)?;
15420            // Decode the envelope for each type.
15421            let mut _next_ordinal_to_read = 0;
15422            let mut next_offset = offset;
15423            let end_offset = offset + bytes_len;
15424            _next_ordinal_to_read += 1;
15425            if next_offset >= end_offset {
15426                return Ok(());
15427            }
15428
15429            // Decode unknown envelopes for gaps in ordinals.
15430            while _next_ordinal_to_read < 1 {
15431                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15432                _next_ordinal_to_read += 1;
15433                next_offset += envelope_size;
15434            }
15435
15436            let next_out_of_line = decoder.next_out_of_line();
15437            let handles_before = decoder.remaining_handles();
15438            if let Some((inlined, num_bytes, num_handles)) =
15439                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15440            {
15441                let member_inline_size = <fidl::encoding::HandleType<
15442                    fdomain_client::EventPair,
15443                    { fidl::ObjectType::EVENTPAIR.into_raw() },
15444                    2147483648,
15445                > as fidl::encoding::TypeMarker>::inline_size(
15446                    decoder.context
15447                );
15448                if inlined != (member_inline_size <= 4) {
15449                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15450                }
15451                let inner_offset;
15452                let mut inner_depth = depth.clone();
15453                if inlined {
15454                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15455                    inner_offset = next_offset;
15456                } else {
15457                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15458                    inner_depth.increment()?;
15459                }
15460                let val_ref =
15461                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));
15462                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)?;
15463                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15464                {
15465                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15466                }
15467                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15468                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15469                }
15470            }
15471
15472            next_offset += envelope_size;
15473            _next_ordinal_to_read += 1;
15474            if next_offset >= end_offset {
15475                return Ok(());
15476            }
15477
15478            // Decode unknown envelopes for gaps in ordinals.
15479            while _next_ordinal_to_read < 2 {
15480                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15481                _next_ordinal_to_read += 1;
15482                next_offset += envelope_size;
15483            }
15484
15485            let next_out_of_line = decoder.next_out_of_line();
15486            let handles_before = decoder.remaining_handles();
15487            if let Some((inlined, num_bytes, num_handles)) =
15488                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15489            {
15490                let member_inline_size =
15491                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15492                if inlined != (member_inline_size <= 4) {
15493                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15494                }
15495                let inner_offset;
15496                let mut inner_depth = depth.clone();
15497                if inlined {
15498                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15499                    inner_offset = next_offset;
15500                } else {
15501                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15502                    inner_depth.increment()?;
15503                }
15504                let val_ref = self.buffers_remaining.get_or_insert_with(|| {
15505                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
15506                });
15507                fidl::decode!(
15508                    u32,
15509                    fdomain_client::fidl::FDomainResourceDialect,
15510                    val_ref,
15511                    decoder,
15512                    inner_offset,
15513                    inner_depth
15514                )?;
15515                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15516                {
15517                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15518                }
15519                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15520                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15521                }
15522            }
15523
15524            next_offset += envelope_size;
15525
15526            // Decode the remaining unknown envelopes.
15527            while next_offset < end_offset {
15528                _next_ordinal_to_read += 1;
15529                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15530                next_offset += envelope_size;
15531            }
15532
15533            Ok(())
15534        }
15535    }
15536
15537    impl BufferCollectionAttachTokenRequest {
15538        #[inline(always)]
15539        fn max_ordinal_present(&self) -> u64 {
15540            if let Some(_) = self.token_request {
15541                return 2;
15542            }
15543            if let Some(_) = self.rights_attenuation_mask {
15544                return 1;
15545            }
15546            0
15547        }
15548    }
15549
15550    impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
15551        type Borrowed<'a> = &'a mut Self;
15552        fn take_or_borrow<'a>(
15553            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15554        ) -> Self::Borrowed<'a> {
15555            value
15556        }
15557    }
15558
15559    unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
15560        type Owned = Self;
15561
15562        #[inline(always)]
15563        fn inline_align(_context: fidl::encoding::Context) -> usize {
15564            8
15565        }
15566
15567        #[inline(always)]
15568        fn inline_size(_context: fidl::encoding::Context) -> usize {
15569            16
15570        }
15571    }
15572
15573    unsafe impl
15574        fidl::encoding::Encode<
15575            BufferCollectionAttachTokenRequest,
15576            fdomain_client::fidl::FDomainResourceDialect,
15577        > for &mut BufferCollectionAttachTokenRequest
15578    {
15579        unsafe fn encode(
15580            self,
15581            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15582            offset: usize,
15583            mut depth: fidl::encoding::Depth,
15584        ) -> fidl::Result<()> {
15585            encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
15586            // Vector header
15587            let max_ordinal: u64 = self.max_ordinal_present();
15588            encoder.write_num(max_ordinal, offset);
15589            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15590            // Calling encoder.out_of_line_offset(0) is not allowed.
15591            if max_ordinal == 0 {
15592                return Ok(());
15593            }
15594            depth.increment()?;
15595            let envelope_size = 8;
15596            let bytes_len = max_ordinal as usize * envelope_size;
15597            #[allow(unused_variables)]
15598            let offset = encoder.out_of_line_offset(bytes_len);
15599            let mut _prev_end_offset: usize = 0;
15600            if 1 > max_ordinal {
15601                return Ok(());
15602            }
15603
15604            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15605            // are envelope_size bytes.
15606            let cur_offset: usize = (1 - 1) * envelope_size;
15607
15608            // Zero reserved fields.
15609            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15610
15611            // Safety:
15612            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15613            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15614            //   envelope_size bytes, there is always sufficient room.
15615            fidl::encoding::encode_in_envelope_optional::<
15616                fidl::Rights,
15617                fdomain_client::fidl::FDomainResourceDialect,
15618            >(
15619                self.rights_attenuation_mask
15620                    .as_ref()
15621                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
15622                encoder,
15623                offset + cur_offset,
15624                depth,
15625            )?;
15626
15627            _prev_end_offset = cur_offset + envelope_size;
15628            if 2 > max_ordinal {
15629                return Ok(());
15630            }
15631
15632            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15633            // are envelope_size bytes.
15634            let cur_offset: usize = (2 - 1) * envelope_size;
15635
15636            // Zero reserved fields.
15637            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15638
15639            // Safety:
15640            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15641            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15642            //   envelope_size bytes, there is always sufficient room.
15643            fidl::encoding::encode_in_envelope_optional::<
15644                fidl::encoding::Endpoint<
15645                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15646                >,
15647                fdomain_client::fidl::FDomainResourceDialect,
15648            >(
15649                self.token_request.as_mut().map(
15650                    <fidl::encoding::Endpoint<
15651                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15652                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
15653                ),
15654                encoder,
15655                offset + cur_offset,
15656                depth,
15657            )?;
15658
15659            _prev_end_offset = cur_offset + envelope_size;
15660
15661            Ok(())
15662        }
15663    }
15664
15665    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15666        for BufferCollectionAttachTokenRequest
15667    {
15668        #[inline(always)]
15669        fn new_empty() -> Self {
15670            Self::default()
15671        }
15672
15673        unsafe fn decode(
15674            &mut self,
15675            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15676            offset: usize,
15677            mut depth: fidl::encoding::Depth,
15678        ) -> fidl::Result<()> {
15679            decoder.debug_check_bounds::<Self>(offset);
15680            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15681                None => return Err(fidl::Error::NotNullable),
15682                Some(len) => len,
15683            };
15684            // Calling decoder.out_of_line_offset(0) is not allowed.
15685            if len == 0 {
15686                return Ok(());
15687            };
15688            depth.increment()?;
15689            let envelope_size = 8;
15690            let bytes_len = len * envelope_size;
15691            let offset = decoder.out_of_line_offset(bytes_len)?;
15692            // Decode the envelope for each type.
15693            let mut _next_ordinal_to_read = 0;
15694            let mut next_offset = offset;
15695            let end_offset = offset + bytes_len;
15696            _next_ordinal_to_read += 1;
15697            if next_offset >= end_offset {
15698                return Ok(());
15699            }
15700
15701            // Decode unknown envelopes for gaps in ordinals.
15702            while _next_ordinal_to_read < 1 {
15703                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15704                _next_ordinal_to_read += 1;
15705                next_offset += envelope_size;
15706            }
15707
15708            let next_out_of_line = decoder.next_out_of_line();
15709            let handles_before = decoder.remaining_handles();
15710            if let Some((inlined, num_bytes, num_handles)) =
15711                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15712            {
15713                let member_inline_size =
15714                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
15715                if inlined != (member_inline_size <= 4) {
15716                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15717                }
15718                let inner_offset;
15719                let mut inner_depth = depth.clone();
15720                if inlined {
15721                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15722                    inner_offset = next_offset;
15723                } else {
15724                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15725                    inner_depth.increment()?;
15726                }
15727                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
15728                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
15729                });
15730                fidl::decode!(
15731                    fidl::Rights,
15732                    fdomain_client::fidl::FDomainResourceDialect,
15733                    val_ref,
15734                    decoder,
15735                    inner_offset,
15736                    inner_depth
15737                )?;
15738                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15739                {
15740                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15741                }
15742                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15743                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15744                }
15745            }
15746
15747            next_offset += envelope_size;
15748            _next_ordinal_to_read += 1;
15749            if next_offset >= end_offset {
15750                return Ok(());
15751            }
15752
15753            // Decode unknown envelopes for gaps in ordinals.
15754            while _next_ordinal_to_read < 2 {
15755                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15756                _next_ordinal_to_read += 1;
15757                next_offset += envelope_size;
15758            }
15759
15760            let next_out_of_line = decoder.next_out_of_line();
15761            let handles_before = decoder.remaining_handles();
15762            if let Some((inlined, num_bytes, num_handles)) =
15763                fidl::encoding::decode_envelope_header(decoder, next_offset)?
15764            {
15765                let member_inline_size = <fidl::encoding::Endpoint<
15766                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15767                > as fidl::encoding::TypeMarker>::inline_size(
15768                    decoder.context
15769                );
15770                if inlined != (member_inline_size <= 4) {
15771                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
15772                }
15773                let inner_offset;
15774                let mut inner_depth = depth.clone();
15775                if inlined {
15776                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
15777                    inner_offset = next_offset;
15778                } else {
15779                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
15780                    inner_depth.increment()?;
15781                }
15782                let val_ref = self.token_request.get_or_insert_with(|| {
15783                    fidl::new_empty!(
15784                        fidl::encoding::Endpoint<
15785                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15786                        >,
15787                        fdomain_client::fidl::FDomainResourceDialect
15788                    )
15789                });
15790                fidl::decode!(
15791                    fidl::encoding::Endpoint<
15792                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
15793                    >,
15794                    fdomain_client::fidl::FDomainResourceDialect,
15795                    val_ref,
15796                    decoder,
15797                    inner_offset,
15798                    inner_depth
15799                )?;
15800                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
15801                {
15802                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
15803                }
15804                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
15805                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
15806                }
15807            }
15808
15809            next_offset += envelope_size;
15810
15811            // Decode the remaining unknown envelopes.
15812            while next_offset < end_offset {
15813                _next_ordinal_to_read += 1;
15814                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
15815                next_offset += envelope_size;
15816            }
15817
15818            Ok(())
15819        }
15820    }
15821
15822    impl BufferCollectionInfo {
15823        #[inline(always)]
15824        fn max_ordinal_present(&self) -> u64 {
15825            if let Some(_) = self.buffer_collection_id {
15826                return 3;
15827            }
15828            if let Some(_) = self.buffers {
15829                return 2;
15830            }
15831            if let Some(_) = self.settings {
15832                return 1;
15833            }
15834            0
15835        }
15836    }
15837
15838    impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
15839        type Borrowed<'a> = &'a mut Self;
15840        fn take_or_borrow<'a>(
15841            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
15842        ) -> Self::Borrowed<'a> {
15843            value
15844        }
15845    }
15846
15847    unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
15848        type Owned = Self;
15849
15850        #[inline(always)]
15851        fn inline_align(_context: fidl::encoding::Context) -> usize {
15852            8
15853        }
15854
15855        #[inline(always)]
15856        fn inline_size(_context: fidl::encoding::Context) -> usize {
15857            16
15858        }
15859    }
15860
15861    unsafe impl
15862        fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
15863        for &mut BufferCollectionInfo
15864    {
15865        unsafe fn encode(
15866            self,
15867            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15868            offset: usize,
15869            mut depth: fidl::encoding::Depth,
15870        ) -> fidl::Result<()> {
15871            encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
15872            // Vector header
15873            let max_ordinal: u64 = self.max_ordinal_present();
15874            encoder.write_num(max_ordinal, offset);
15875            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
15876            // Calling encoder.out_of_line_offset(0) is not allowed.
15877            if max_ordinal == 0 {
15878                return Ok(());
15879            }
15880            depth.increment()?;
15881            let envelope_size = 8;
15882            let bytes_len = max_ordinal as usize * envelope_size;
15883            #[allow(unused_variables)]
15884            let offset = encoder.out_of_line_offset(bytes_len);
15885            let mut _prev_end_offset: usize = 0;
15886            if 1 > max_ordinal {
15887                return Ok(());
15888            }
15889
15890            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15891            // are envelope_size bytes.
15892            let cur_offset: usize = (1 - 1) * envelope_size;
15893
15894            // Zero reserved fields.
15895            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15896
15897            // Safety:
15898            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15899            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15900            //   envelope_size bytes, there is always sufficient room.
15901            fidl::encoding::encode_in_envelope_optional::<
15902                SingleBufferSettings,
15903                fdomain_client::fidl::FDomainResourceDialect,
15904            >(
15905                self.settings
15906                    .as_ref()
15907                    .map(<SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow),
15908                encoder,
15909                offset + cur_offset,
15910                depth,
15911            )?;
15912
15913            _prev_end_offset = cur_offset + envelope_size;
15914            if 2 > max_ordinal {
15915                return Ok(());
15916            }
15917
15918            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15919            // are envelope_size bytes.
15920            let cur_offset: usize = (2 - 1) * envelope_size;
15921
15922            // Zero reserved fields.
15923            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15924
15925            // Safety:
15926            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15927            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15928            //   envelope_size bytes, there is always sufficient room.
15929            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect>(
15930            self.buffers.as_mut().map(<fidl::encoding::Vector<VmoBuffer, 128> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
15931            encoder, offset + cur_offset, depth
15932        )?;
15933
15934            _prev_end_offset = cur_offset + envelope_size;
15935            if 3 > max_ordinal {
15936                return Ok(());
15937            }
15938
15939            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
15940            // are envelope_size bytes.
15941            let cur_offset: usize = (3 - 1) * envelope_size;
15942
15943            // Zero reserved fields.
15944            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
15945
15946            // Safety:
15947            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
15948            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
15949            //   envelope_size bytes, there is always sufficient room.
15950            fidl::encoding::encode_in_envelope_optional::<
15951                u64,
15952                fdomain_client::fidl::FDomainResourceDialect,
15953            >(
15954                self.buffer_collection_id
15955                    .as_ref()
15956                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
15957                encoder,
15958                offset + cur_offset,
15959                depth,
15960            )?;
15961
15962            _prev_end_offset = cur_offset + envelope_size;
15963
15964            Ok(())
15965        }
15966    }
15967
15968    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
15969        for BufferCollectionInfo
15970    {
15971        #[inline(always)]
15972        fn new_empty() -> Self {
15973            Self::default()
15974        }
15975
15976        unsafe fn decode(
15977            &mut self,
15978            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
15979            offset: usize,
15980            mut depth: fidl::encoding::Depth,
15981        ) -> fidl::Result<()> {
15982            decoder.debug_check_bounds::<Self>(offset);
15983            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
15984                None => return Err(fidl::Error::NotNullable),
15985                Some(len) => len,
15986            };
15987            // Calling decoder.out_of_line_offset(0) is not allowed.
15988            if len == 0 {
15989                return Ok(());
15990            };
15991            depth.increment()?;
15992            let envelope_size = 8;
15993            let bytes_len = len * envelope_size;
15994            let offset = decoder.out_of_line_offset(bytes_len)?;
15995            // Decode the envelope for each type.
15996            let mut _next_ordinal_to_read = 0;
15997            let mut next_offset = offset;
15998            let end_offset = offset + bytes_len;
15999            _next_ordinal_to_read += 1;
16000            if next_offset >= end_offset {
16001                return Ok(());
16002            }
16003
16004            // Decode unknown envelopes for gaps in ordinals.
16005            while _next_ordinal_to_read < 1 {
16006                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16007                _next_ordinal_to_read += 1;
16008                next_offset += envelope_size;
16009            }
16010
16011            let next_out_of_line = decoder.next_out_of_line();
16012            let handles_before = decoder.remaining_handles();
16013            if let Some((inlined, num_bytes, num_handles)) =
16014                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16015            {
16016                let member_inline_size =
16017                    <SingleBufferSettings as fidl::encoding::TypeMarker>::inline_size(
16018                        decoder.context,
16019                    );
16020                if inlined != (member_inline_size <= 4) {
16021                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16022                }
16023                let inner_offset;
16024                let mut inner_depth = depth.clone();
16025                if inlined {
16026                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16027                    inner_offset = next_offset;
16028                } else {
16029                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16030                    inner_depth.increment()?;
16031                }
16032                let val_ref = self.settings.get_or_insert_with(|| {
16033                    fidl::new_empty!(
16034                        SingleBufferSettings,
16035                        fdomain_client::fidl::FDomainResourceDialect
16036                    )
16037                });
16038                fidl::decode!(
16039                    SingleBufferSettings,
16040                    fdomain_client::fidl::FDomainResourceDialect,
16041                    val_ref,
16042                    decoder,
16043                    inner_offset,
16044                    inner_depth
16045                )?;
16046                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16047                {
16048                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16049                }
16050                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16051                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16052                }
16053            }
16054
16055            next_offset += envelope_size;
16056            _next_ordinal_to_read += 1;
16057            if next_offset >= end_offset {
16058                return Ok(());
16059            }
16060
16061            // Decode unknown envelopes for gaps in ordinals.
16062            while _next_ordinal_to_read < 2 {
16063                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16064                _next_ordinal_to_read += 1;
16065                next_offset += envelope_size;
16066            }
16067
16068            let next_out_of_line = decoder.next_out_of_line();
16069            let handles_before = decoder.remaining_handles();
16070            if let Some((inlined, num_bytes, num_handles)) =
16071                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16072            {
16073                let member_inline_size = <fidl::encoding::Vector<VmoBuffer, 128> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16074                if inlined != (member_inline_size <= 4) {
16075                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16076                }
16077                let inner_offset;
16078                let mut inner_depth = depth.clone();
16079                if inlined {
16080                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16081                    inner_offset = next_offset;
16082                } else {
16083                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16084                    inner_depth.increment()?;
16085                }
16086                let val_ref =
16087                self.buffers.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect));
16088                fidl::decode!(fidl::encoding::Vector<VmoBuffer, 128>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
16089                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16090                {
16091                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16092                }
16093                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16094                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16095                }
16096            }
16097
16098            next_offset += envelope_size;
16099            _next_ordinal_to_read += 1;
16100            if next_offset >= end_offset {
16101                return Ok(());
16102            }
16103
16104            // Decode unknown envelopes for gaps in ordinals.
16105            while _next_ordinal_to_read < 3 {
16106                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16107                _next_ordinal_to_read += 1;
16108                next_offset += envelope_size;
16109            }
16110
16111            let next_out_of_line = decoder.next_out_of_line();
16112            let handles_before = decoder.remaining_handles();
16113            if let Some((inlined, num_bytes, num_handles)) =
16114                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16115            {
16116                let member_inline_size =
16117                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16118                if inlined != (member_inline_size <= 4) {
16119                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16120                }
16121                let inner_offset;
16122                let mut inner_depth = depth.clone();
16123                if inlined {
16124                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16125                    inner_offset = next_offset;
16126                } else {
16127                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16128                    inner_depth.increment()?;
16129                }
16130                let val_ref = self.buffer_collection_id.get_or_insert_with(|| {
16131                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
16132                });
16133                fidl::decode!(
16134                    u64,
16135                    fdomain_client::fidl::FDomainResourceDialect,
16136                    val_ref,
16137                    decoder,
16138                    inner_offset,
16139                    inner_depth
16140                )?;
16141                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16142                {
16143                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16144                }
16145                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16146                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16147                }
16148            }
16149
16150            next_offset += envelope_size;
16151
16152            // Decode the remaining unknown envelopes.
16153            while next_offset < end_offset {
16154                _next_ordinal_to_read += 1;
16155                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16156                next_offset += envelope_size;
16157            }
16158
16159            Ok(())
16160        }
16161    }
16162
16163    impl BufferCollectionSetConstraintsRequest {
16164        #[inline(always)]
16165        fn max_ordinal_present(&self) -> u64 {
16166            if let Some(_) = self.must_match_vmo {
16167                return 2;
16168            }
16169            if let Some(_) = self.constraints {
16170                return 1;
16171            }
16172            0
16173        }
16174    }
16175
16176    impl fidl::encoding::ResourceTypeMarker for BufferCollectionSetConstraintsRequest {
16177        type Borrowed<'a> = &'a mut Self;
16178        fn take_or_borrow<'a>(
16179            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16180        ) -> Self::Borrowed<'a> {
16181            value
16182        }
16183    }
16184
16185    unsafe impl fidl::encoding::TypeMarker for BufferCollectionSetConstraintsRequest {
16186        type Owned = Self;
16187
16188        #[inline(always)]
16189        fn inline_align(_context: fidl::encoding::Context) -> usize {
16190            8
16191        }
16192
16193        #[inline(always)]
16194        fn inline_size(_context: fidl::encoding::Context) -> usize {
16195            16
16196        }
16197    }
16198
16199    unsafe impl
16200        fidl::encoding::Encode<
16201            BufferCollectionSetConstraintsRequest,
16202            fdomain_client::fidl::FDomainResourceDialect,
16203        > for &mut BufferCollectionSetConstraintsRequest
16204    {
16205        unsafe fn encode(
16206            self,
16207            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16208            offset: usize,
16209            mut depth: fidl::encoding::Depth,
16210        ) -> fidl::Result<()> {
16211            encoder.debug_check_bounds::<BufferCollectionSetConstraintsRequest>(offset);
16212            // Vector header
16213            let max_ordinal: u64 = self.max_ordinal_present();
16214            encoder.write_num(max_ordinal, offset);
16215            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16216            // Calling encoder.out_of_line_offset(0) is not allowed.
16217            if max_ordinal == 0 {
16218                return Ok(());
16219            }
16220            depth.increment()?;
16221            let envelope_size = 8;
16222            let bytes_len = max_ordinal as usize * envelope_size;
16223            #[allow(unused_variables)]
16224            let offset = encoder.out_of_line_offset(bytes_len);
16225            let mut _prev_end_offset: usize = 0;
16226            if 1 > max_ordinal {
16227                return Ok(());
16228            }
16229
16230            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16231            // are envelope_size bytes.
16232            let cur_offset: usize = (1 - 1) * envelope_size;
16233
16234            // Zero reserved fields.
16235            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16236
16237            // Safety:
16238            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16239            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16240            //   envelope_size bytes, there is always sufficient room.
16241            fidl::encoding::encode_in_envelope_optional::<
16242                BufferCollectionConstraints,
16243                fdomain_client::fidl::FDomainResourceDialect,
16244            >(
16245                self.constraints
16246                    .as_ref()
16247                    .map(<BufferCollectionConstraints as fidl::encoding::ValueTypeMarker>::borrow),
16248                encoder,
16249                offset + cur_offset,
16250                depth,
16251            )?;
16252
16253            _prev_end_offset = cur_offset + envelope_size;
16254            if 2 > max_ordinal {
16255                return Ok(());
16256            }
16257
16258            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16259            // are envelope_size bytes.
16260            let cur_offset: usize = (2 - 1) * envelope_size;
16261
16262            // Zero reserved fields.
16263            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16264
16265            // Safety:
16266            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16267            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16268            //   envelope_size bytes, there is always sufficient room.
16269            fidl::encoding::encode_in_envelope_optional::<
16270                fidl::encoding::HandleType<
16271                    fdomain_client::Vmo,
16272                    { fidl::ObjectType::VMO.into_raw() },
16273                    2147483648,
16274                >,
16275                fdomain_client::fidl::FDomainResourceDialect,
16276            >(
16277                self.must_match_vmo.as_mut().map(
16278                    <fidl::encoding::HandleType<
16279                        fdomain_client::Vmo,
16280                        { fidl::ObjectType::VMO.into_raw() },
16281                        2147483648,
16282                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16283                ),
16284                encoder,
16285                offset + cur_offset,
16286                depth,
16287            )?;
16288
16289            _prev_end_offset = cur_offset + envelope_size;
16290
16291            Ok(())
16292        }
16293    }
16294
16295    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16296        for BufferCollectionSetConstraintsRequest
16297    {
16298        #[inline(always)]
16299        fn new_empty() -> Self {
16300            Self::default()
16301        }
16302
16303        unsafe fn decode(
16304            &mut self,
16305            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16306            offset: usize,
16307            mut depth: fidl::encoding::Depth,
16308        ) -> fidl::Result<()> {
16309            decoder.debug_check_bounds::<Self>(offset);
16310            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16311                None => return Err(fidl::Error::NotNullable),
16312                Some(len) => len,
16313            };
16314            // Calling decoder.out_of_line_offset(0) is not allowed.
16315            if len == 0 {
16316                return Ok(());
16317            };
16318            depth.increment()?;
16319            let envelope_size = 8;
16320            let bytes_len = len * envelope_size;
16321            let offset = decoder.out_of_line_offset(bytes_len)?;
16322            // Decode the envelope for each type.
16323            let mut _next_ordinal_to_read = 0;
16324            let mut next_offset = offset;
16325            let end_offset = offset + bytes_len;
16326            _next_ordinal_to_read += 1;
16327            if next_offset >= end_offset {
16328                return Ok(());
16329            }
16330
16331            // Decode unknown envelopes for gaps in ordinals.
16332            while _next_ordinal_to_read < 1 {
16333                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16334                _next_ordinal_to_read += 1;
16335                next_offset += envelope_size;
16336            }
16337
16338            let next_out_of_line = decoder.next_out_of_line();
16339            let handles_before = decoder.remaining_handles();
16340            if let Some((inlined, num_bytes, num_handles)) =
16341                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16342            {
16343                let member_inline_size =
16344                    <BufferCollectionConstraints as fidl::encoding::TypeMarker>::inline_size(
16345                        decoder.context,
16346                    );
16347                if inlined != (member_inline_size <= 4) {
16348                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16349                }
16350                let inner_offset;
16351                let mut inner_depth = depth.clone();
16352                if inlined {
16353                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16354                    inner_offset = next_offset;
16355                } else {
16356                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16357                    inner_depth.increment()?;
16358                }
16359                let val_ref = self.constraints.get_or_insert_with(|| {
16360                    fidl::new_empty!(
16361                        BufferCollectionConstraints,
16362                        fdomain_client::fidl::FDomainResourceDialect
16363                    )
16364                });
16365                fidl::decode!(
16366                    BufferCollectionConstraints,
16367                    fdomain_client::fidl::FDomainResourceDialect,
16368                    val_ref,
16369                    decoder,
16370                    inner_offset,
16371                    inner_depth
16372                )?;
16373                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16374                {
16375                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16376                }
16377                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16378                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16379                }
16380            }
16381
16382            next_offset += envelope_size;
16383            _next_ordinal_to_read += 1;
16384            if next_offset >= end_offset {
16385                return Ok(());
16386            }
16387
16388            // Decode unknown envelopes for gaps in ordinals.
16389            while _next_ordinal_to_read < 2 {
16390                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16391                _next_ordinal_to_read += 1;
16392                next_offset += envelope_size;
16393            }
16394
16395            let next_out_of_line = decoder.next_out_of_line();
16396            let handles_before = decoder.remaining_handles();
16397            if let Some((inlined, num_bytes, num_handles)) =
16398                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16399            {
16400                let member_inline_size = <fidl::encoding::HandleType<
16401                    fdomain_client::Vmo,
16402                    { fidl::ObjectType::VMO.into_raw() },
16403                    2147483648,
16404                > as fidl::encoding::TypeMarker>::inline_size(
16405                    decoder.context
16406                );
16407                if inlined != (member_inline_size <= 4) {
16408                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16409                }
16410                let inner_offset;
16411                let mut inner_depth = depth.clone();
16412                if inlined {
16413                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16414                    inner_offset = next_offset;
16415                } else {
16416                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16417                    inner_depth.increment()?;
16418                }
16419                let val_ref =
16420                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));
16421                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)?;
16422                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16423                {
16424                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16425                }
16426                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16427                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16428                }
16429            }
16430
16431            next_offset += envelope_size;
16432
16433            // Decode the remaining unknown envelopes.
16434            while next_offset < end_offset {
16435                _next_ordinal_to_read += 1;
16436                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16437                next_offset += envelope_size;
16438            }
16439
16440            Ok(())
16441        }
16442    }
16443
16444    impl BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
16445        #[inline(always)]
16446        fn max_ordinal_present(&self) -> u64 {
16447            if let Some(_) = self.group_request {
16448                return 1;
16449            }
16450            0
16451        }
16452    }
16453
16454    impl fidl::encoding::ResourceTypeMarker
16455        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16456    {
16457        type Borrowed<'a> = &'a mut Self;
16458        fn take_or_borrow<'a>(
16459            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16460        ) -> Self::Borrowed<'a> {
16461            value
16462        }
16463    }
16464
16465    unsafe impl fidl::encoding::TypeMarker
16466        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16467    {
16468        type Owned = Self;
16469
16470        #[inline(always)]
16471        fn inline_align(_context: fidl::encoding::Context) -> usize {
16472            8
16473        }
16474
16475        #[inline(always)]
16476        fn inline_size(_context: fidl::encoding::Context) -> usize {
16477            16
16478        }
16479    }
16480
16481    unsafe impl
16482        fidl::encoding::Encode<
16483            BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
16484            fdomain_client::fidl::FDomainResourceDialect,
16485        > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16486    {
16487        unsafe fn encode(
16488            self,
16489            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16490            offset: usize,
16491            mut depth: fidl::encoding::Depth,
16492        ) -> fidl::Result<()> {
16493            encoder
16494                .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
16495                    offset,
16496                );
16497            // Vector header
16498            let max_ordinal: u64 = self.max_ordinal_present();
16499            encoder.write_num(max_ordinal, offset);
16500            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16501            // Calling encoder.out_of_line_offset(0) is not allowed.
16502            if max_ordinal == 0 {
16503                return Ok(());
16504            }
16505            depth.increment()?;
16506            let envelope_size = 8;
16507            let bytes_len = max_ordinal as usize * envelope_size;
16508            #[allow(unused_variables)]
16509            let offset = encoder.out_of_line_offset(bytes_len);
16510            let mut _prev_end_offset: usize = 0;
16511            if 1 > max_ordinal {
16512                return Ok(());
16513            }
16514
16515            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16516            // are envelope_size bytes.
16517            let cur_offset: usize = (1 - 1) * envelope_size;
16518
16519            // Zero reserved fields.
16520            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16521
16522            // Safety:
16523            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16524            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16525            //   envelope_size bytes, there is always sufficient room.
16526            fidl::encoding::encode_in_envelope_optional::<
16527                fidl::encoding::Endpoint<
16528                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16529                >,
16530                fdomain_client::fidl::FDomainResourceDialect,
16531            >(
16532                self.group_request.as_mut().map(
16533                    <fidl::encoding::Endpoint<
16534                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16535                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16536                ),
16537                encoder,
16538                offset + cur_offset,
16539                depth,
16540            )?;
16541
16542            _prev_end_offset = cur_offset + envelope_size;
16543
16544            Ok(())
16545        }
16546    }
16547
16548    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16549        for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
16550    {
16551        #[inline(always)]
16552        fn new_empty() -> Self {
16553            Self::default()
16554        }
16555
16556        unsafe fn decode(
16557            &mut self,
16558            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16559            offset: usize,
16560            mut depth: fidl::encoding::Depth,
16561        ) -> fidl::Result<()> {
16562            decoder.debug_check_bounds::<Self>(offset);
16563            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16564                None => return Err(fidl::Error::NotNullable),
16565                Some(len) => len,
16566            };
16567            // Calling decoder.out_of_line_offset(0) is not allowed.
16568            if len == 0 {
16569                return Ok(());
16570            };
16571            depth.increment()?;
16572            let envelope_size = 8;
16573            let bytes_len = len * envelope_size;
16574            let offset = decoder.out_of_line_offset(bytes_len)?;
16575            // Decode the envelope for each type.
16576            let mut _next_ordinal_to_read = 0;
16577            let mut next_offset = offset;
16578            let end_offset = offset + bytes_len;
16579            _next_ordinal_to_read += 1;
16580            if next_offset >= end_offset {
16581                return Ok(());
16582            }
16583
16584            // Decode unknown envelopes for gaps in ordinals.
16585            while _next_ordinal_to_read < 1 {
16586                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16587                _next_ordinal_to_read += 1;
16588                next_offset += envelope_size;
16589            }
16590
16591            let next_out_of_line = decoder.next_out_of_line();
16592            let handles_before = decoder.remaining_handles();
16593            if let Some((inlined, num_bytes, num_handles)) =
16594                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16595            {
16596                let member_inline_size = <fidl::encoding::Endpoint<
16597                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16598                > as fidl::encoding::TypeMarker>::inline_size(
16599                    decoder.context
16600                );
16601                if inlined != (member_inline_size <= 4) {
16602                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16603                }
16604                let inner_offset;
16605                let mut inner_depth = depth.clone();
16606                if inlined {
16607                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16608                    inner_offset = next_offset;
16609                } else {
16610                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16611                    inner_depth.increment()?;
16612                }
16613                let val_ref = self.group_request.get_or_insert_with(|| {
16614                    fidl::new_empty!(
16615                        fidl::encoding::Endpoint<
16616                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16617                        >,
16618                        fdomain_client::fidl::FDomainResourceDialect
16619                    )
16620                });
16621                fidl::decode!(
16622                    fidl::encoding::Endpoint<
16623                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
16624                    >,
16625                    fdomain_client::fidl::FDomainResourceDialect,
16626                    val_ref,
16627                    decoder,
16628                    inner_offset,
16629                    inner_depth
16630                )?;
16631                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16632                {
16633                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16634                }
16635                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16636                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16637                }
16638            }
16639
16640            next_offset += envelope_size;
16641
16642            // Decode the remaining unknown envelopes.
16643            while next_offset < end_offset {
16644                _next_ordinal_to_read += 1;
16645                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16646                next_offset += envelope_size;
16647            }
16648
16649            Ok(())
16650        }
16651    }
16652
16653    impl BufferCollectionTokenDuplicateRequest {
16654        #[inline(always)]
16655        fn max_ordinal_present(&self) -> u64 {
16656            if let Some(_) = self.token_request {
16657                return 2;
16658            }
16659            if let Some(_) = self.rights_attenuation_mask {
16660                return 1;
16661            }
16662            0
16663        }
16664    }
16665
16666    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
16667        type Borrowed<'a> = &'a mut Self;
16668        fn take_or_borrow<'a>(
16669            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16670        ) -> Self::Borrowed<'a> {
16671            value
16672        }
16673    }
16674
16675    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
16676        type Owned = Self;
16677
16678        #[inline(always)]
16679        fn inline_align(_context: fidl::encoding::Context) -> usize {
16680            8
16681        }
16682
16683        #[inline(always)]
16684        fn inline_size(_context: fidl::encoding::Context) -> usize {
16685            16
16686        }
16687    }
16688
16689    unsafe impl
16690        fidl::encoding::Encode<
16691            BufferCollectionTokenDuplicateRequest,
16692            fdomain_client::fidl::FDomainResourceDialect,
16693        > for &mut BufferCollectionTokenDuplicateRequest
16694    {
16695        unsafe fn encode(
16696            self,
16697            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16698            offset: usize,
16699            mut depth: fidl::encoding::Depth,
16700        ) -> fidl::Result<()> {
16701            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
16702            // Vector header
16703            let max_ordinal: u64 = self.max_ordinal_present();
16704            encoder.write_num(max_ordinal, offset);
16705            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16706            // Calling encoder.out_of_line_offset(0) is not allowed.
16707            if max_ordinal == 0 {
16708                return Ok(());
16709            }
16710            depth.increment()?;
16711            let envelope_size = 8;
16712            let bytes_len = max_ordinal as usize * envelope_size;
16713            #[allow(unused_variables)]
16714            let offset = encoder.out_of_line_offset(bytes_len);
16715            let mut _prev_end_offset: usize = 0;
16716            if 1 > max_ordinal {
16717                return Ok(());
16718            }
16719
16720            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16721            // are envelope_size bytes.
16722            let cur_offset: usize = (1 - 1) * envelope_size;
16723
16724            // Zero reserved fields.
16725            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16726
16727            // Safety:
16728            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16729            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16730            //   envelope_size bytes, there is always sufficient room.
16731            fidl::encoding::encode_in_envelope_optional::<
16732                fidl::Rights,
16733                fdomain_client::fidl::FDomainResourceDialect,
16734            >(
16735                self.rights_attenuation_mask
16736                    .as_ref()
16737                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
16738                encoder,
16739                offset + cur_offset,
16740                depth,
16741            )?;
16742
16743            _prev_end_offset = cur_offset + envelope_size;
16744            if 2 > max_ordinal {
16745                return Ok(());
16746            }
16747
16748            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
16749            // are envelope_size bytes.
16750            let cur_offset: usize = (2 - 1) * envelope_size;
16751
16752            // Zero reserved fields.
16753            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
16754
16755            // Safety:
16756            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
16757            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
16758            //   envelope_size bytes, there is always sufficient room.
16759            fidl::encoding::encode_in_envelope_optional::<
16760                fidl::encoding::Endpoint<
16761                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16762                >,
16763                fdomain_client::fidl::FDomainResourceDialect,
16764            >(
16765                self.token_request.as_mut().map(
16766                    <fidl::encoding::Endpoint<
16767                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16768                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
16769                ),
16770                encoder,
16771                offset + cur_offset,
16772                depth,
16773            )?;
16774
16775            _prev_end_offset = cur_offset + envelope_size;
16776
16777            Ok(())
16778        }
16779    }
16780
16781    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
16782        for BufferCollectionTokenDuplicateRequest
16783    {
16784        #[inline(always)]
16785        fn new_empty() -> Self {
16786            Self::default()
16787        }
16788
16789        unsafe fn decode(
16790            &mut self,
16791            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16792            offset: usize,
16793            mut depth: fidl::encoding::Depth,
16794        ) -> fidl::Result<()> {
16795            decoder.debug_check_bounds::<Self>(offset);
16796            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
16797                None => return Err(fidl::Error::NotNullable),
16798                Some(len) => len,
16799            };
16800            // Calling decoder.out_of_line_offset(0) is not allowed.
16801            if len == 0 {
16802                return Ok(());
16803            };
16804            depth.increment()?;
16805            let envelope_size = 8;
16806            let bytes_len = len * envelope_size;
16807            let offset = decoder.out_of_line_offset(bytes_len)?;
16808            // Decode the envelope for each type.
16809            let mut _next_ordinal_to_read = 0;
16810            let mut next_offset = offset;
16811            let end_offset = offset + bytes_len;
16812            _next_ordinal_to_read += 1;
16813            if next_offset >= end_offset {
16814                return Ok(());
16815            }
16816
16817            // Decode unknown envelopes for gaps in ordinals.
16818            while _next_ordinal_to_read < 1 {
16819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16820                _next_ordinal_to_read += 1;
16821                next_offset += envelope_size;
16822            }
16823
16824            let next_out_of_line = decoder.next_out_of_line();
16825            let handles_before = decoder.remaining_handles();
16826            if let Some((inlined, num_bytes, num_handles)) =
16827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16828            {
16829                let member_inline_size =
16830                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
16831                if inlined != (member_inline_size <= 4) {
16832                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16833                }
16834                let inner_offset;
16835                let mut inner_depth = depth.clone();
16836                if inlined {
16837                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16838                    inner_offset = next_offset;
16839                } else {
16840                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16841                    inner_depth.increment()?;
16842                }
16843                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
16844                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
16845                });
16846                fidl::decode!(
16847                    fidl::Rights,
16848                    fdomain_client::fidl::FDomainResourceDialect,
16849                    val_ref,
16850                    decoder,
16851                    inner_offset,
16852                    inner_depth
16853                )?;
16854                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16855                {
16856                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16857                }
16858                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16859                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16860                }
16861            }
16862
16863            next_offset += envelope_size;
16864            _next_ordinal_to_read += 1;
16865            if next_offset >= end_offset {
16866                return Ok(());
16867            }
16868
16869            // Decode unknown envelopes for gaps in ordinals.
16870            while _next_ordinal_to_read < 2 {
16871                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16872                _next_ordinal_to_read += 1;
16873                next_offset += envelope_size;
16874            }
16875
16876            let next_out_of_line = decoder.next_out_of_line();
16877            let handles_before = decoder.remaining_handles();
16878            if let Some((inlined, num_bytes, num_handles)) =
16879                fidl::encoding::decode_envelope_header(decoder, next_offset)?
16880            {
16881                let member_inline_size = <fidl::encoding::Endpoint<
16882                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16883                > as fidl::encoding::TypeMarker>::inline_size(
16884                    decoder.context
16885                );
16886                if inlined != (member_inline_size <= 4) {
16887                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
16888                }
16889                let inner_offset;
16890                let mut inner_depth = depth.clone();
16891                if inlined {
16892                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
16893                    inner_offset = next_offset;
16894                } else {
16895                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
16896                    inner_depth.increment()?;
16897                }
16898                let val_ref = self.token_request.get_or_insert_with(|| {
16899                    fidl::new_empty!(
16900                        fidl::encoding::Endpoint<
16901                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16902                        >,
16903                        fdomain_client::fidl::FDomainResourceDialect
16904                    )
16905                });
16906                fidl::decode!(
16907                    fidl::encoding::Endpoint<
16908                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
16909                    >,
16910                    fdomain_client::fidl::FDomainResourceDialect,
16911                    val_ref,
16912                    decoder,
16913                    inner_offset,
16914                    inner_depth
16915                )?;
16916                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
16917                {
16918                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
16919                }
16920                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
16921                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
16922                }
16923            }
16924
16925            next_offset += envelope_size;
16926
16927            // Decode the remaining unknown envelopes.
16928            while next_offset < end_offset {
16929                _next_ordinal_to_read += 1;
16930                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
16931                next_offset += envelope_size;
16932            }
16933
16934            Ok(())
16935        }
16936    }
16937
16938    impl BufferCollectionTokenGroupCreateChildRequest {
16939        #[inline(always)]
16940        fn max_ordinal_present(&self) -> u64 {
16941            if let Some(_) = self.rights_attenuation_mask {
16942                return 2;
16943            }
16944            if let Some(_) = self.token_request {
16945                return 1;
16946            }
16947            0
16948        }
16949    }
16950
16951    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
16952        type Borrowed<'a> = &'a mut Self;
16953        fn take_or_borrow<'a>(
16954            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
16955        ) -> Self::Borrowed<'a> {
16956            value
16957        }
16958    }
16959
16960    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
16961        type Owned = Self;
16962
16963        #[inline(always)]
16964        fn inline_align(_context: fidl::encoding::Context) -> usize {
16965            8
16966        }
16967
16968        #[inline(always)]
16969        fn inline_size(_context: fidl::encoding::Context) -> usize {
16970            16
16971        }
16972    }
16973
16974    unsafe impl
16975        fidl::encoding::Encode<
16976            BufferCollectionTokenGroupCreateChildRequest,
16977            fdomain_client::fidl::FDomainResourceDialect,
16978        > for &mut BufferCollectionTokenGroupCreateChildRequest
16979    {
16980        unsafe fn encode(
16981            self,
16982            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
16983            offset: usize,
16984            mut depth: fidl::encoding::Depth,
16985        ) -> fidl::Result<()> {
16986            encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
16987            // Vector header
16988            let max_ordinal: u64 = self.max_ordinal_present();
16989            encoder.write_num(max_ordinal, offset);
16990            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
16991            // Calling encoder.out_of_line_offset(0) is not allowed.
16992            if max_ordinal == 0 {
16993                return Ok(());
16994            }
16995            depth.increment()?;
16996            let envelope_size = 8;
16997            let bytes_len = max_ordinal as usize * envelope_size;
16998            #[allow(unused_variables)]
16999            let offset = encoder.out_of_line_offset(bytes_len);
17000            let mut _prev_end_offset: usize = 0;
17001            if 1 > max_ordinal {
17002                return Ok(());
17003            }
17004
17005            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17006            // are envelope_size bytes.
17007            let cur_offset: usize = (1 - 1) * envelope_size;
17008
17009            // Zero reserved fields.
17010            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17011
17012            // Safety:
17013            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17014            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17015            //   envelope_size bytes, there is always sufficient room.
17016            fidl::encoding::encode_in_envelope_optional::<
17017                fidl::encoding::Endpoint<
17018                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17019                >,
17020                fdomain_client::fidl::FDomainResourceDialect,
17021            >(
17022                self.token_request.as_mut().map(
17023                    <fidl::encoding::Endpoint<
17024                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17025                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17026                ),
17027                encoder,
17028                offset + cur_offset,
17029                depth,
17030            )?;
17031
17032            _prev_end_offset = cur_offset + envelope_size;
17033            if 2 > max_ordinal {
17034                return Ok(());
17035            }
17036
17037            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17038            // are envelope_size bytes.
17039            let cur_offset: usize = (2 - 1) * envelope_size;
17040
17041            // Zero reserved fields.
17042            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17043
17044            // Safety:
17045            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17046            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17047            //   envelope_size bytes, there is always sufficient room.
17048            fidl::encoding::encode_in_envelope_optional::<
17049                fidl::Rights,
17050                fdomain_client::fidl::FDomainResourceDialect,
17051            >(
17052                self.rights_attenuation_mask
17053                    .as_ref()
17054                    .map(<fidl::Rights as fidl::encoding::ValueTypeMarker>::borrow),
17055                encoder,
17056                offset + cur_offset,
17057                depth,
17058            )?;
17059
17060            _prev_end_offset = cur_offset + envelope_size;
17061
17062            Ok(())
17063        }
17064    }
17065
17066    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17067        for BufferCollectionTokenGroupCreateChildRequest
17068    {
17069        #[inline(always)]
17070        fn new_empty() -> Self {
17071            Self::default()
17072        }
17073
17074        unsafe fn decode(
17075            &mut self,
17076            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17077            offset: usize,
17078            mut depth: fidl::encoding::Depth,
17079        ) -> fidl::Result<()> {
17080            decoder.debug_check_bounds::<Self>(offset);
17081            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17082                None => return Err(fidl::Error::NotNullable),
17083                Some(len) => len,
17084            };
17085            // Calling decoder.out_of_line_offset(0) is not allowed.
17086            if len == 0 {
17087                return Ok(());
17088            };
17089            depth.increment()?;
17090            let envelope_size = 8;
17091            let bytes_len = len * envelope_size;
17092            let offset = decoder.out_of_line_offset(bytes_len)?;
17093            // Decode the envelope for each type.
17094            let mut _next_ordinal_to_read = 0;
17095            let mut next_offset = offset;
17096            let end_offset = offset + bytes_len;
17097            _next_ordinal_to_read += 1;
17098            if next_offset >= end_offset {
17099                return Ok(());
17100            }
17101
17102            // Decode unknown envelopes for gaps in ordinals.
17103            while _next_ordinal_to_read < 1 {
17104                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17105                _next_ordinal_to_read += 1;
17106                next_offset += envelope_size;
17107            }
17108
17109            let next_out_of_line = decoder.next_out_of_line();
17110            let handles_before = decoder.remaining_handles();
17111            if let Some((inlined, num_bytes, num_handles)) =
17112                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17113            {
17114                let member_inline_size = <fidl::encoding::Endpoint<
17115                    fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17116                > as fidl::encoding::TypeMarker>::inline_size(
17117                    decoder.context
17118                );
17119                if inlined != (member_inline_size <= 4) {
17120                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17121                }
17122                let inner_offset;
17123                let mut inner_depth = depth.clone();
17124                if inlined {
17125                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17126                    inner_offset = next_offset;
17127                } else {
17128                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17129                    inner_depth.increment()?;
17130                }
17131                let val_ref = self.token_request.get_or_insert_with(|| {
17132                    fidl::new_empty!(
17133                        fidl::encoding::Endpoint<
17134                            fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17135                        >,
17136                        fdomain_client::fidl::FDomainResourceDialect
17137                    )
17138                });
17139                fidl::decode!(
17140                    fidl::encoding::Endpoint<
17141                        fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
17142                    >,
17143                    fdomain_client::fidl::FDomainResourceDialect,
17144                    val_ref,
17145                    decoder,
17146                    inner_offset,
17147                    inner_depth
17148                )?;
17149                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17150                {
17151                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17152                }
17153                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17154                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17155                }
17156            }
17157
17158            next_offset += envelope_size;
17159            _next_ordinal_to_read += 1;
17160            if next_offset >= end_offset {
17161                return Ok(());
17162            }
17163
17164            // Decode unknown envelopes for gaps in ordinals.
17165            while _next_ordinal_to_read < 2 {
17166                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17167                _next_ordinal_to_read += 1;
17168                next_offset += envelope_size;
17169            }
17170
17171            let next_out_of_line = decoder.next_out_of_line();
17172            let handles_before = decoder.remaining_handles();
17173            if let Some((inlined, num_bytes, num_handles)) =
17174                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17175            {
17176                let member_inline_size =
17177                    <fidl::Rights as fidl::encoding::TypeMarker>::inline_size(decoder.context);
17178                if inlined != (member_inline_size <= 4) {
17179                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17180                }
17181                let inner_offset;
17182                let mut inner_depth = depth.clone();
17183                if inlined {
17184                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17185                    inner_offset = next_offset;
17186                } else {
17187                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17188                    inner_depth.increment()?;
17189                }
17190                let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
17191                    fidl::new_empty!(fidl::Rights, fdomain_client::fidl::FDomainResourceDialect)
17192                });
17193                fidl::decode!(
17194                    fidl::Rights,
17195                    fdomain_client::fidl::FDomainResourceDialect,
17196                    val_ref,
17197                    decoder,
17198                    inner_offset,
17199                    inner_depth
17200                )?;
17201                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17202                {
17203                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17204                }
17205                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17206                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17207                }
17208            }
17209
17210            next_offset += envelope_size;
17211
17212            // Decode the remaining unknown envelopes.
17213            while next_offset < end_offset {
17214                _next_ordinal_to_read += 1;
17215                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17216                next_offset += envelope_size;
17217            }
17218
17219            Ok(())
17220        }
17221    }
17222
17223    impl BufferCollectionTokenGroupCreateChildrenSyncResponse {
17224        #[inline(always)]
17225        fn max_ordinal_present(&self) -> u64 {
17226            if let Some(_) = self.tokens {
17227                return 1;
17228            }
17229            0
17230        }
17231    }
17232
17233    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
17234        type Borrowed<'a> = &'a mut Self;
17235        fn take_or_borrow<'a>(
17236            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17237        ) -> Self::Borrowed<'a> {
17238            value
17239        }
17240    }
17241
17242    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
17243        type Owned = Self;
17244
17245        #[inline(always)]
17246        fn inline_align(_context: fidl::encoding::Context) -> usize {
17247            8
17248        }
17249
17250        #[inline(always)]
17251        fn inline_size(_context: fidl::encoding::Context) -> usize {
17252            16
17253        }
17254    }
17255
17256    unsafe impl
17257        fidl::encoding::Encode<
17258            BufferCollectionTokenGroupCreateChildrenSyncResponse,
17259            fdomain_client::fidl::FDomainResourceDialect,
17260        > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
17261    {
17262        unsafe fn encode(
17263            self,
17264            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17265            offset: usize,
17266            mut depth: fidl::encoding::Depth,
17267        ) -> fidl::Result<()> {
17268            encoder
17269                .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
17270            // Vector header
17271            let max_ordinal: u64 = self.max_ordinal_present();
17272            encoder.write_num(max_ordinal, offset);
17273            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17274            // Calling encoder.out_of_line_offset(0) is not allowed.
17275            if max_ordinal == 0 {
17276                return Ok(());
17277            }
17278            depth.increment()?;
17279            let envelope_size = 8;
17280            let bytes_len = max_ordinal as usize * envelope_size;
17281            #[allow(unused_variables)]
17282            let offset = encoder.out_of_line_offset(bytes_len);
17283            let mut _prev_end_offset: usize = 0;
17284            if 1 > max_ordinal {
17285                return Ok(());
17286            }
17287
17288            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17289            // are envelope_size bytes.
17290            let cur_offset: usize = (1 - 1) * envelope_size;
17291
17292            // Zero reserved fields.
17293            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17294
17295            // Safety:
17296            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17297            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17298            //   envelope_size bytes, there is always sufficient room.
17299            fidl::encoding::encode_in_envelope_optional::<
17300                fidl::encoding::Vector<
17301                    fidl::encoding::Endpoint<
17302                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17303                    >,
17304                    64,
17305                >,
17306                fdomain_client::fidl::FDomainResourceDialect,
17307            >(
17308                self.tokens.as_mut().map(
17309                    <fidl::encoding::Vector<
17310                        fidl::encoding::Endpoint<
17311                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17312                        >,
17313                        64,
17314                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17315                ),
17316                encoder,
17317                offset + cur_offset,
17318                depth,
17319            )?;
17320
17321            _prev_end_offset = cur_offset + envelope_size;
17322
17323            Ok(())
17324        }
17325    }
17326
17327    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17328        for BufferCollectionTokenGroupCreateChildrenSyncResponse
17329    {
17330        #[inline(always)]
17331        fn new_empty() -> Self {
17332            Self::default()
17333        }
17334
17335        unsafe fn decode(
17336            &mut self,
17337            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17338            offset: usize,
17339            mut depth: fidl::encoding::Depth,
17340        ) -> fidl::Result<()> {
17341            decoder.debug_check_bounds::<Self>(offset);
17342            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17343                None => return Err(fidl::Error::NotNullable),
17344                Some(len) => len,
17345            };
17346            // Calling decoder.out_of_line_offset(0) is not allowed.
17347            if len == 0 {
17348                return Ok(());
17349            };
17350            depth.increment()?;
17351            let envelope_size = 8;
17352            let bytes_len = len * envelope_size;
17353            let offset = decoder.out_of_line_offset(bytes_len)?;
17354            // Decode the envelope for each type.
17355            let mut _next_ordinal_to_read = 0;
17356            let mut next_offset = offset;
17357            let end_offset = offset + bytes_len;
17358            _next_ordinal_to_read += 1;
17359            if next_offset >= end_offset {
17360                return Ok(());
17361            }
17362
17363            // Decode unknown envelopes for gaps in ordinals.
17364            while _next_ordinal_to_read < 1 {
17365                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17366                _next_ordinal_to_read += 1;
17367                next_offset += envelope_size;
17368            }
17369
17370            let next_out_of_line = decoder.next_out_of_line();
17371            let handles_before = decoder.remaining_handles();
17372            if let Some((inlined, num_bytes, num_handles)) =
17373                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17374            {
17375                let member_inline_size = <fidl::encoding::Vector<
17376                    fidl::encoding::Endpoint<
17377                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17378                    >,
17379                    64,
17380                > as fidl::encoding::TypeMarker>::inline_size(
17381                    decoder.context
17382                );
17383                if inlined != (member_inline_size <= 4) {
17384                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17385                }
17386                let inner_offset;
17387                let mut inner_depth = depth.clone();
17388                if inlined {
17389                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17390                    inner_offset = next_offset;
17391                } else {
17392                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17393                    inner_depth.increment()?;
17394                }
17395                let val_ref = self.tokens.get_or_insert_with(|| {
17396                    fidl::new_empty!(
17397                        fidl::encoding::Vector<
17398                            fidl::encoding::Endpoint<
17399                                fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17400                            >,
17401                            64,
17402                        >,
17403                        fdomain_client::fidl::FDomainResourceDialect
17404                    )
17405                });
17406                fidl::decode!(
17407                    fidl::encoding::Vector<
17408                        fidl::encoding::Endpoint<
17409                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17410                        >,
17411                        64,
17412                    >,
17413                    fdomain_client::fidl::FDomainResourceDialect,
17414                    val_ref,
17415                    decoder,
17416                    inner_offset,
17417                    inner_depth
17418                )?;
17419                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17420                {
17421                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17422                }
17423                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17424                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17425                }
17426            }
17427
17428            next_offset += envelope_size;
17429
17430            // Decode the remaining unknown envelopes.
17431            while next_offset < end_offset {
17432                _next_ordinal_to_read += 1;
17433                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17434                next_offset += envelope_size;
17435            }
17436
17437            Ok(())
17438        }
17439    }
17440
17441    impl BufferCollectionTokenDuplicateSyncResponse {
17442        #[inline(always)]
17443        fn max_ordinal_present(&self) -> u64 {
17444            if let Some(_) = self.tokens {
17445                return 1;
17446            }
17447            0
17448        }
17449    }
17450
17451    impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
17452        type Borrowed<'a> = &'a mut Self;
17453        fn take_or_borrow<'a>(
17454            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17455        ) -> Self::Borrowed<'a> {
17456            value
17457        }
17458    }
17459
17460    unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
17461        type Owned = Self;
17462
17463        #[inline(always)]
17464        fn inline_align(_context: fidl::encoding::Context) -> usize {
17465            8
17466        }
17467
17468        #[inline(always)]
17469        fn inline_size(_context: fidl::encoding::Context) -> usize {
17470            16
17471        }
17472    }
17473
17474    unsafe impl
17475        fidl::encoding::Encode<
17476            BufferCollectionTokenDuplicateSyncResponse,
17477            fdomain_client::fidl::FDomainResourceDialect,
17478        > for &mut BufferCollectionTokenDuplicateSyncResponse
17479    {
17480        unsafe fn encode(
17481            self,
17482            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17483            offset: usize,
17484            mut depth: fidl::encoding::Depth,
17485        ) -> fidl::Result<()> {
17486            encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
17487            // Vector header
17488            let max_ordinal: u64 = self.max_ordinal_present();
17489            encoder.write_num(max_ordinal, offset);
17490            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17491            // Calling encoder.out_of_line_offset(0) is not allowed.
17492            if max_ordinal == 0 {
17493                return Ok(());
17494            }
17495            depth.increment()?;
17496            let envelope_size = 8;
17497            let bytes_len = max_ordinal as usize * envelope_size;
17498            #[allow(unused_variables)]
17499            let offset = encoder.out_of_line_offset(bytes_len);
17500            let mut _prev_end_offset: usize = 0;
17501            if 1 > max_ordinal {
17502                return Ok(());
17503            }
17504
17505            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17506            // are envelope_size bytes.
17507            let cur_offset: usize = (1 - 1) * envelope_size;
17508
17509            // Zero reserved fields.
17510            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17511
17512            // Safety:
17513            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17514            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17515            //   envelope_size bytes, there is always sufficient room.
17516            fidl::encoding::encode_in_envelope_optional::<
17517                fidl::encoding::Vector<
17518                    fidl::encoding::Endpoint<
17519                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17520                    >,
17521                    64,
17522                >,
17523                fdomain_client::fidl::FDomainResourceDialect,
17524            >(
17525                self.tokens.as_mut().map(
17526                    <fidl::encoding::Vector<
17527                        fidl::encoding::Endpoint<
17528                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17529                        >,
17530                        64,
17531                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17532                ),
17533                encoder,
17534                offset + cur_offset,
17535                depth,
17536            )?;
17537
17538            _prev_end_offset = cur_offset + envelope_size;
17539
17540            Ok(())
17541        }
17542    }
17543
17544    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17545        for BufferCollectionTokenDuplicateSyncResponse
17546    {
17547        #[inline(always)]
17548        fn new_empty() -> Self {
17549            Self::default()
17550        }
17551
17552        unsafe fn decode(
17553            &mut self,
17554            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17555            offset: usize,
17556            mut depth: fidl::encoding::Depth,
17557        ) -> fidl::Result<()> {
17558            decoder.debug_check_bounds::<Self>(offset);
17559            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17560                None => return Err(fidl::Error::NotNullable),
17561                Some(len) => len,
17562            };
17563            // Calling decoder.out_of_line_offset(0) is not allowed.
17564            if len == 0 {
17565                return Ok(());
17566            };
17567            depth.increment()?;
17568            let envelope_size = 8;
17569            let bytes_len = len * envelope_size;
17570            let offset = decoder.out_of_line_offset(bytes_len)?;
17571            // Decode the envelope for each type.
17572            let mut _next_ordinal_to_read = 0;
17573            let mut next_offset = offset;
17574            let end_offset = offset + bytes_len;
17575            _next_ordinal_to_read += 1;
17576            if next_offset >= end_offset {
17577                return Ok(());
17578            }
17579
17580            // Decode unknown envelopes for gaps in ordinals.
17581            while _next_ordinal_to_read < 1 {
17582                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17583                _next_ordinal_to_read += 1;
17584                next_offset += envelope_size;
17585            }
17586
17587            let next_out_of_line = decoder.next_out_of_line();
17588            let handles_before = decoder.remaining_handles();
17589            if let Some((inlined, num_bytes, num_handles)) =
17590                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17591            {
17592                let member_inline_size = <fidl::encoding::Vector<
17593                    fidl::encoding::Endpoint<
17594                        fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17595                    >,
17596                    64,
17597                > as fidl::encoding::TypeMarker>::inline_size(
17598                    decoder.context
17599                );
17600                if inlined != (member_inline_size <= 4) {
17601                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17602                }
17603                let inner_offset;
17604                let mut inner_depth = depth.clone();
17605                if inlined {
17606                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17607                    inner_offset = next_offset;
17608                } else {
17609                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17610                    inner_depth.increment()?;
17611                }
17612                let val_ref = self.tokens.get_or_insert_with(|| {
17613                    fidl::new_empty!(
17614                        fidl::encoding::Vector<
17615                            fidl::encoding::Endpoint<
17616                                fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17617                            >,
17618                            64,
17619                        >,
17620                        fdomain_client::fidl::FDomainResourceDialect
17621                    )
17622                });
17623                fidl::decode!(
17624                    fidl::encoding::Vector<
17625                        fidl::encoding::Endpoint<
17626                            fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
17627                        >,
17628                        64,
17629                    >,
17630                    fdomain_client::fidl::FDomainResourceDialect,
17631                    val_ref,
17632                    decoder,
17633                    inner_offset,
17634                    inner_depth
17635                )?;
17636                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17637                {
17638                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17639                }
17640                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17641                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17642                }
17643            }
17644
17645            next_offset += envelope_size;
17646
17647            // Decode the remaining unknown envelopes.
17648            while next_offset < end_offset {
17649                _next_ordinal_to_read += 1;
17650                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17651                next_offset += envelope_size;
17652            }
17653
17654            Ok(())
17655        }
17656    }
17657
17658    impl BufferCollectionWaitForAllBuffersAllocatedResponse {
17659        #[inline(always)]
17660        fn max_ordinal_present(&self) -> u64 {
17661            if let Some(_) = self.buffer_collection_info {
17662                return 1;
17663            }
17664            0
17665        }
17666    }
17667
17668    impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForAllBuffersAllocatedResponse {
17669        type Borrowed<'a> = &'a mut Self;
17670        fn take_or_borrow<'a>(
17671            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17672        ) -> Self::Borrowed<'a> {
17673            value
17674        }
17675    }
17676
17677    unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForAllBuffersAllocatedResponse {
17678        type Owned = Self;
17679
17680        #[inline(always)]
17681        fn inline_align(_context: fidl::encoding::Context) -> usize {
17682            8
17683        }
17684
17685        #[inline(always)]
17686        fn inline_size(_context: fidl::encoding::Context) -> usize {
17687            16
17688        }
17689    }
17690
17691    unsafe impl
17692        fidl::encoding::Encode<
17693            BufferCollectionWaitForAllBuffersAllocatedResponse,
17694            fdomain_client::fidl::FDomainResourceDialect,
17695        > for &mut BufferCollectionWaitForAllBuffersAllocatedResponse
17696    {
17697        unsafe fn encode(
17698            self,
17699            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17700            offset: usize,
17701            mut depth: fidl::encoding::Depth,
17702        ) -> fidl::Result<()> {
17703            encoder
17704                .debug_check_bounds::<BufferCollectionWaitForAllBuffersAllocatedResponse>(offset);
17705            // Vector header
17706            let max_ordinal: u64 = self.max_ordinal_present();
17707            encoder.write_num(max_ordinal, offset);
17708            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17709            // Calling encoder.out_of_line_offset(0) is not allowed.
17710            if max_ordinal == 0 {
17711                return Ok(());
17712            }
17713            depth.increment()?;
17714            let envelope_size = 8;
17715            let bytes_len = max_ordinal as usize * envelope_size;
17716            #[allow(unused_variables)]
17717            let offset = encoder.out_of_line_offset(bytes_len);
17718            let mut _prev_end_offset: usize = 0;
17719            if 1 > max_ordinal {
17720                return Ok(());
17721            }
17722
17723            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17724            // are envelope_size bytes.
17725            let cur_offset: usize = (1 - 1) * envelope_size;
17726
17727            // Zero reserved fields.
17728            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17729
17730            // Safety:
17731            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17732            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17733            //   envelope_size bytes, there is always sufficient room.
17734            fidl::encoding::encode_in_envelope_optional::<
17735                BufferCollectionInfo,
17736                fdomain_client::fidl::FDomainResourceDialect,
17737            >(
17738                self.buffer_collection_info.as_mut().map(
17739                    <BufferCollectionInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17740                ),
17741                encoder,
17742                offset + cur_offset,
17743                depth,
17744            )?;
17745
17746            _prev_end_offset = cur_offset + envelope_size;
17747
17748            Ok(())
17749        }
17750    }
17751
17752    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17753        for BufferCollectionWaitForAllBuffersAllocatedResponse
17754    {
17755        #[inline(always)]
17756        fn new_empty() -> Self {
17757            Self::default()
17758        }
17759
17760        unsafe fn decode(
17761            &mut self,
17762            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17763            offset: usize,
17764            mut depth: fidl::encoding::Depth,
17765        ) -> fidl::Result<()> {
17766            decoder.debug_check_bounds::<Self>(offset);
17767            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17768                None => return Err(fidl::Error::NotNullable),
17769                Some(len) => len,
17770            };
17771            // Calling decoder.out_of_line_offset(0) is not allowed.
17772            if len == 0 {
17773                return Ok(());
17774            };
17775            depth.increment()?;
17776            let envelope_size = 8;
17777            let bytes_len = len * envelope_size;
17778            let offset = decoder.out_of_line_offset(bytes_len)?;
17779            // Decode the envelope for each type.
17780            let mut _next_ordinal_to_read = 0;
17781            let mut next_offset = offset;
17782            let end_offset = offset + bytes_len;
17783            _next_ordinal_to_read += 1;
17784            if next_offset >= end_offset {
17785                return Ok(());
17786            }
17787
17788            // Decode unknown envelopes for gaps in ordinals.
17789            while _next_ordinal_to_read < 1 {
17790                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17791                _next_ordinal_to_read += 1;
17792                next_offset += envelope_size;
17793            }
17794
17795            let next_out_of_line = decoder.next_out_of_line();
17796            let handles_before = decoder.remaining_handles();
17797            if let Some((inlined, num_bytes, num_handles)) =
17798                fidl::encoding::decode_envelope_header(decoder, next_offset)?
17799            {
17800                let member_inline_size =
17801                    <BufferCollectionInfo as fidl::encoding::TypeMarker>::inline_size(
17802                        decoder.context,
17803                    );
17804                if inlined != (member_inline_size <= 4) {
17805                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
17806                }
17807                let inner_offset;
17808                let mut inner_depth = depth.clone();
17809                if inlined {
17810                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
17811                    inner_offset = next_offset;
17812                } else {
17813                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
17814                    inner_depth.increment()?;
17815                }
17816                let val_ref = self.buffer_collection_info.get_or_insert_with(|| {
17817                    fidl::new_empty!(
17818                        BufferCollectionInfo,
17819                        fdomain_client::fidl::FDomainResourceDialect
17820                    )
17821                });
17822                fidl::decode!(
17823                    BufferCollectionInfo,
17824                    fdomain_client::fidl::FDomainResourceDialect,
17825                    val_ref,
17826                    decoder,
17827                    inner_offset,
17828                    inner_depth
17829                )?;
17830                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
17831                {
17832                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
17833                }
17834                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
17835                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
17836                }
17837            }
17838
17839            next_offset += envelope_size;
17840
17841            // Decode the remaining unknown envelopes.
17842            while next_offset < end_offset {
17843                _next_ordinal_to_read += 1;
17844                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17845                next_offset += envelope_size;
17846            }
17847
17848            Ok(())
17849        }
17850    }
17851
17852    impl NodeAttachNodeTrackingRequest {
17853        #[inline(always)]
17854        fn max_ordinal_present(&self) -> u64 {
17855            if let Some(_) = self.server_end {
17856                return 1;
17857            }
17858            0
17859        }
17860    }
17861
17862    impl fidl::encoding::ResourceTypeMarker for NodeAttachNodeTrackingRequest {
17863        type Borrowed<'a> = &'a mut Self;
17864        fn take_or_borrow<'a>(
17865            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
17866        ) -> Self::Borrowed<'a> {
17867            value
17868        }
17869    }
17870
17871    unsafe impl fidl::encoding::TypeMarker for NodeAttachNodeTrackingRequest {
17872        type Owned = Self;
17873
17874        #[inline(always)]
17875        fn inline_align(_context: fidl::encoding::Context) -> usize {
17876            8
17877        }
17878
17879        #[inline(always)]
17880        fn inline_size(_context: fidl::encoding::Context) -> usize {
17881            16
17882        }
17883    }
17884
17885    unsafe impl
17886        fidl::encoding::Encode<
17887            NodeAttachNodeTrackingRequest,
17888            fdomain_client::fidl::FDomainResourceDialect,
17889        > for &mut NodeAttachNodeTrackingRequest
17890    {
17891        unsafe fn encode(
17892            self,
17893            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17894            offset: usize,
17895            mut depth: fidl::encoding::Depth,
17896        ) -> fidl::Result<()> {
17897            encoder.debug_check_bounds::<NodeAttachNodeTrackingRequest>(offset);
17898            // Vector header
17899            let max_ordinal: u64 = self.max_ordinal_present();
17900            encoder.write_num(max_ordinal, offset);
17901            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
17902            // Calling encoder.out_of_line_offset(0) is not allowed.
17903            if max_ordinal == 0 {
17904                return Ok(());
17905            }
17906            depth.increment()?;
17907            let envelope_size = 8;
17908            let bytes_len = max_ordinal as usize * envelope_size;
17909            #[allow(unused_variables)]
17910            let offset = encoder.out_of_line_offset(bytes_len);
17911            let mut _prev_end_offset: usize = 0;
17912            if 1 > max_ordinal {
17913                return Ok(());
17914            }
17915
17916            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
17917            // are envelope_size bytes.
17918            let cur_offset: usize = (1 - 1) * envelope_size;
17919
17920            // Zero reserved fields.
17921            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
17922
17923            // Safety:
17924            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
17925            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
17926            //   envelope_size bytes, there is always sufficient room.
17927            fidl::encoding::encode_in_envelope_optional::<
17928                fidl::encoding::HandleType<
17929                    fdomain_client::EventPair,
17930                    { fidl::ObjectType::EVENTPAIR.into_raw() },
17931                    2147483648,
17932                >,
17933                fdomain_client::fidl::FDomainResourceDialect,
17934            >(
17935                self.server_end.as_mut().map(
17936                    <fidl::encoding::HandleType<
17937                        fdomain_client::EventPair,
17938                        { fidl::ObjectType::EVENTPAIR.into_raw() },
17939                        2147483648,
17940                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
17941                ),
17942                encoder,
17943                offset + cur_offset,
17944                depth,
17945            )?;
17946
17947            _prev_end_offset = cur_offset + envelope_size;
17948
17949            Ok(())
17950        }
17951    }
17952
17953    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
17954        for NodeAttachNodeTrackingRequest
17955    {
17956        #[inline(always)]
17957        fn new_empty() -> Self {
17958            Self::default()
17959        }
17960
17961        unsafe fn decode(
17962            &mut self,
17963            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
17964            offset: usize,
17965            mut depth: fidl::encoding::Depth,
17966        ) -> fidl::Result<()> {
17967            decoder.debug_check_bounds::<Self>(offset);
17968            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
17969                None => return Err(fidl::Error::NotNullable),
17970                Some(len) => len,
17971            };
17972            // Calling decoder.out_of_line_offset(0) is not allowed.
17973            if len == 0 {
17974                return Ok(());
17975            };
17976            depth.increment()?;
17977            let envelope_size = 8;
17978            let bytes_len = len * envelope_size;
17979            let offset = decoder.out_of_line_offset(bytes_len)?;
17980            // Decode the envelope for each type.
17981            let mut _next_ordinal_to_read = 0;
17982            let mut next_offset = offset;
17983            let end_offset = offset + bytes_len;
17984            _next_ordinal_to_read += 1;
17985            if next_offset >= end_offset {
17986                return Ok(());
17987            }
17988
17989            // Decode unknown envelopes for gaps in ordinals.
17990            while _next_ordinal_to_read < 1 {
17991                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
17992                _next_ordinal_to_read += 1;
17993                next_offset += envelope_size;
17994            }
17995
17996            let next_out_of_line = decoder.next_out_of_line();
17997            let handles_before = decoder.remaining_handles();
17998            if let Some((inlined, num_bytes, num_handles)) =
17999                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18000            {
18001                let member_inline_size = <fidl::encoding::HandleType<
18002                    fdomain_client::EventPair,
18003                    { fidl::ObjectType::EVENTPAIR.into_raw() },
18004                    2147483648,
18005                > as fidl::encoding::TypeMarker>::inline_size(
18006                    decoder.context
18007                );
18008                if inlined != (member_inline_size <= 4) {
18009                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18010                }
18011                let inner_offset;
18012                let mut inner_depth = depth.clone();
18013                if inlined {
18014                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18015                    inner_offset = next_offset;
18016                } else {
18017                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18018                    inner_depth.increment()?;
18019                }
18020                let val_ref =
18021                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));
18022                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)?;
18023                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18024                {
18025                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18026                }
18027                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18028                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18029                }
18030            }
18031
18032            next_offset += envelope_size;
18033
18034            // Decode the remaining unknown envelopes.
18035            while next_offset < end_offset {
18036                _next_ordinal_to_read += 1;
18037                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18038                next_offset += envelope_size;
18039            }
18040
18041            Ok(())
18042        }
18043    }
18044
18045    impl NodeIsAlternateForRequest {
18046        #[inline(always)]
18047        fn max_ordinal_present(&self) -> u64 {
18048            if let Some(_) = self.node_ref {
18049                return 1;
18050            }
18051            0
18052        }
18053    }
18054
18055    impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
18056        type Borrowed<'a> = &'a mut Self;
18057        fn take_or_borrow<'a>(
18058            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18059        ) -> Self::Borrowed<'a> {
18060            value
18061        }
18062    }
18063
18064    unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
18065        type Owned = Self;
18066
18067        #[inline(always)]
18068        fn inline_align(_context: fidl::encoding::Context) -> usize {
18069            8
18070        }
18071
18072        #[inline(always)]
18073        fn inline_size(_context: fidl::encoding::Context) -> usize {
18074            16
18075        }
18076    }
18077
18078    unsafe impl
18079        fidl::encoding::Encode<
18080            NodeIsAlternateForRequest,
18081            fdomain_client::fidl::FDomainResourceDialect,
18082        > for &mut NodeIsAlternateForRequest
18083    {
18084        unsafe fn encode(
18085            self,
18086            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18087            offset: usize,
18088            mut depth: fidl::encoding::Depth,
18089        ) -> fidl::Result<()> {
18090            encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
18091            // Vector header
18092            let max_ordinal: u64 = self.max_ordinal_present();
18093            encoder.write_num(max_ordinal, offset);
18094            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18095            // Calling encoder.out_of_line_offset(0) is not allowed.
18096            if max_ordinal == 0 {
18097                return Ok(());
18098            }
18099            depth.increment()?;
18100            let envelope_size = 8;
18101            let bytes_len = max_ordinal as usize * envelope_size;
18102            #[allow(unused_variables)]
18103            let offset = encoder.out_of_line_offset(bytes_len);
18104            let mut _prev_end_offset: usize = 0;
18105            if 1 > max_ordinal {
18106                return Ok(());
18107            }
18108
18109            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18110            // are envelope_size bytes.
18111            let cur_offset: usize = (1 - 1) * envelope_size;
18112
18113            // Zero reserved fields.
18114            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18115
18116            // Safety:
18117            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18118            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18119            //   envelope_size bytes, there is always sufficient room.
18120            fidl::encoding::encode_in_envelope_optional::<
18121                fidl::encoding::HandleType<
18122                    fdomain_client::Event,
18123                    { fidl::ObjectType::EVENT.into_raw() },
18124                    2147483648,
18125                >,
18126                fdomain_client::fidl::FDomainResourceDialect,
18127            >(
18128                self.node_ref.as_mut().map(
18129                    <fidl::encoding::HandleType<
18130                        fdomain_client::Event,
18131                        { fidl::ObjectType::EVENT.into_raw() },
18132                        2147483648,
18133                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18134                ),
18135                encoder,
18136                offset + cur_offset,
18137                depth,
18138            )?;
18139
18140            _prev_end_offset = cur_offset + envelope_size;
18141
18142            Ok(())
18143        }
18144    }
18145
18146    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18147        for NodeIsAlternateForRequest
18148    {
18149        #[inline(always)]
18150        fn new_empty() -> Self {
18151            Self::default()
18152        }
18153
18154        unsafe fn decode(
18155            &mut self,
18156            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18157            offset: usize,
18158            mut depth: fidl::encoding::Depth,
18159        ) -> fidl::Result<()> {
18160            decoder.debug_check_bounds::<Self>(offset);
18161            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18162                None => return Err(fidl::Error::NotNullable),
18163                Some(len) => len,
18164            };
18165            // Calling decoder.out_of_line_offset(0) is not allowed.
18166            if len == 0 {
18167                return Ok(());
18168            };
18169            depth.increment()?;
18170            let envelope_size = 8;
18171            let bytes_len = len * envelope_size;
18172            let offset = decoder.out_of_line_offset(bytes_len)?;
18173            // Decode the envelope for each type.
18174            let mut _next_ordinal_to_read = 0;
18175            let mut next_offset = offset;
18176            let end_offset = offset + bytes_len;
18177            _next_ordinal_to_read += 1;
18178            if next_offset >= end_offset {
18179                return Ok(());
18180            }
18181
18182            // Decode unknown envelopes for gaps in ordinals.
18183            while _next_ordinal_to_read < 1 {
18184                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18185                _next_ordinal_to_read += 1;
18186                next_offset += envelope_size;
18187            }
18188
18189            let next_out_of_line = decoder.next_out_of_line();
18190            let handles_before = decoder.remaining_handles();
18191            if let Some((inlined, num_bytes, num_handles)) =
18192                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18193            {
18194                let member_inline_size = <fidl::encoding::HandleType<
18195                    fdomain_client::Event,
18196                    { fidl::ObjectType::EVENT.into_raw() },
18197                    2147483648,
18198                > as fidl::encoding::TypeMarker>::inline_size(
18199                    decoder.context
18200                );
18201                if inlined != (member_inline_size <= 4) {
18202                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18203                }
18204                let inner_offset;
18205                let mut inner_depth = depth.clone();
18206                if inlined {
18207                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18208                    inner_offset = next_offset;
18209                } else {
18210                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18211                    inner_depth.increment()?;
18212                }
18213                let val_ref =
18214                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));
18215                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)?;
18216                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18217                {
18218                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18219                }
18220                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18221                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18222                }
18223            }
18224
18225            next_offset += envelope_size;
18226
18227            // Decode the remaining unknown envelopes.
18228            while next_offset < end_offset {
18229                _next_ordinal_to_read += 1;
18230                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18231                next_offset += envelope_size;
18232            }
18233
18234            Ok(())
18235        }
18236    }
18237
18238    impl NodeSetWeakOkRequest {
18239        #[inline(always)]
18240        fn max_ordinal_present(&self) -> u64 {
18241            if let Some(_) = self.for_child_nodes_also {
18242                return 1;
18243            }
18244            0
18245        }
18246    }
18247
18248    impl fidl::encoding::ResourceTypeMarker for NodeSetWeakOkRequest {
18249        type Borrowed<'a> = &'a mut Self;
18250        fn take_or_borrow<'a>(
18251            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18252        ) -> Self::Borrowed<'a> {
18253            value
18254        }
18255    }
18256
18257    unsafe impl fidl::encoding::TypeMarker for NodeSetWeakOkRequest {
18258        type Owned = Self;
18259
18260        #[inline(always)]
18261        fn inline_align(_context: fidl::encoding::Context) -> usize {
18262            8
18263        }
18264
18265        #[inline(always)]
18266        fn inline_size(_context: fidl::encoding::Context) -> usize {
18267            16
18268        }
18269    }
18270
18271    unsafe impl
18272        fidl::encoding::Encode<NodeSetWeakOkRequest, fdomain_client::fidl::FDomainResourceDialect>
18273        for &mut NodeSetWeakOkRequest
18274    {
18275        unsafe fn encode(
18276            self,
18277            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18278            offset: usize,
18279            mut depth: fidl::encoding::Depth,
18280        ) -> fidl::Result<()> {
18281            encoder.debug_check_bounds::<NodeSetWeakOkRequest>(offset);
18282            // Vector header
18283            let max_ordinal: u64 = self.max_ordinal_present();
18284            encoder.write_num(max_ordinal, offset);
18285            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18286            // Calling encoder.out_of_line_offset(0) is not allowed.
18287            if max_ordinal == 0 {
18288                return Ok(());
18289            }
18290            depth.increment()?;
18291            let envelope_size = 8;
18292            let bytes_len = max_ordinal as usize * envelope_size;
18293            #[allow(unused_variables)]
18294            let offset = encoder.out_of_line_offset(bytes_len);
18295            let mut _prev_end_offset: usize = 0;
18296            if 1 > max_ordinal {
18297                return Ok(());
18298            }
18299
18300            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18301            // are envelope_size bytes.
18302            let cur_offset: usize = (1 - 1) * envelope_size;
18303
18304            // Zero reserved fields.
18305            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18306
18307            // Safety:
18308            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18309            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18310            //   envelope_size bytes, there is always sufficient room.
18311            fidl::encoding::encode_in_envelope_optional::<
18312                bool,
18313                fdomain_client::fidl::FDomainResourceDialect,
18314            >(
18315                self.for_child_nodes_also
18316                    .as_ref()
18317                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
18318                encoder,
18319                offset + cur_offset,
18320                depth,
18321            )?;
18322
18323            _prev_end_offset = cur_offset + envelope_size;
18324
18325            Ok(())
18326        }
18327    }
18328
18329    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18330        for NodeSetWeakOkRequest
18331    {
18332        #[inline(always)]
18333        fn new_empty() -> Self {
18334            Self::default()
18335        }
18336
18337        unsafe fn decode(
18338            &mut self,
18339            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18340            offset: usize,
18341            mut depth: fidl::encoding::Depth,
18342        ) -> fidl::Result<()> {
18343            decoder.debug_check_bounds::<Self>(offset);
18344            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18345                None => return Err(fidl::Error::NotNullable),
18346                Some(len) => len,
18347            };
18348            // Calling decoder.out_of_line_offset(0) is not allowed.
18349            if len == 0 {
18350                return Ok(());
18351            };
18352            depth.increment()?;
18353            let envelope_size = 8;
18354            let bytes_len = len * envelope_size;
18355            let offset = decoder.out_of_line_offset(bytes_len)?;
18356            // Decode the envelope for each type.
18357            let mut _next_ordinal_to_read = 0;
18358            let mut next_offset = offset;
18359            let end_offset = offset + bytes_len;
18360            _next_ordinal_to_read += 1;
18361            if next_offset >= end_offset {
18362                return Ok(());
18363            }
18364
18365            // Decode unknown envelopes for gaps in ordinals.
18366            while _next_ordinal_to_read < 1 {
18367                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18368                _next_ordinal_to_read += 1;
18369                next_offset += envelope_size;
18370            }
18371
18372            let next_out_of_line = decoder.next_out_of_line();
18373            let handles_before = decoder.remaining_handles();
18374            if let Some((inlined, num_bytes, num_handles)) =
18375                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18376            {
18377                let member_inline_size =
18378                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
18379                if inlined != (member_inline_size <= 4) {
18380                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18381                }
18382                let inner_offset;
18383                let mut inner_depth = depth.clone();
18384                if inlined {
18385                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18386                    inner_offset = next_offset;
18387                } else {
18388                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18389                    inner_depth.increment()?;
18390                }
18391                let val_ref = self.for_child_nodes_also.get_or_insert_with(|| {
18392                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
18393                });
18394                fidl::decode!(
18395                    bool,
18396                    fdomain_client::fidl::FDomainResourceDialect,
18397                    val_ref,
18398                    decoder,
18399                    inner_offset,
18400                    inner_depth
18401                )?;
18402                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18403                {
18404                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18405                }
18406                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18407                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18408                }
18409            }
18410
18411            next_offset += envelope_size;
18412
18413            // Decode the remaining unknown envelopes.
18414            while next_offset < end_offset {
18415                _next_ordinal_to_read += 1;
18416                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18417                next_offset += envelope_size;
18418            }
18419
18420            Ok(())
18421        }
18422    }
18423
18424    impl NodeGetNodeRefResponse {
18425        #[inline(always)]
18426        fn max_ordinal_present(&self) -> u64 {
18427            if let Some(_) = self.node_ref {
18428                return 1;
18429            }
18430            0
18431        }
18432    }
18433
18434    impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
18435        type Borrowed<'a> = &'a mut Self;
18436        fn take_or_borrow<'a>(
18437            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18438        ) -> Self::Borrowed<'a> {
18439            value
18440        }
18441    }
18442
18443    unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
18444        type Owned = Self;
18445
18446        #[inline(always)]
18447        fn inline_align(_context: fidl::encoding::Context) -> usize {
18448            8
18449        }
18450
18451        #[inline(always)]
18452        fn inline_size(_context: fidl::encoding::Context) -> usize {
18453            16
18454        }
18455    }
18456
18457    unsafe impl
18458        fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
18459        for &mut NodeGetNodeRefResponse
18460    {
18461        unsafe fn encode(
18462            self,
18463            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18464            offset: usize,
18465            mut depth: fidl::encoding::Depth,
18466        ) -> fidl::Result<()> {
18467            encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
18468            // Vector header
18469            let max_ordinal: u64 = self.max_ordinal_present();
18470            encoder.write_num(max_ordinal, offset);
18471            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18472            // Calling encoder.out_of_line_offset(0) is not allowed.
18473            if max_ordinal == 0 {
18474                return Ok(());
18475            }
18476            depth.increment()?;
18477            let envelope_size = 8;
18478            let bytes_len = max_ordinal as usize * envelope_size;
18479            #[allow(unused_variables)]
18480            let offset = encoder.out_of_line_offset(bytes_len);
18481            let mut _prev_end_offset: usize = 0;
18482            if 1 > max_ordinal {
18483                return Ok(());
18484            }
18485
18486            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18487            // are envelope_size bytes.
18488            let cur_offset: usize = (1 - 1) * envelope_size;
18489
18490            // Zero reserved fields.
18491            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18492
18493            // Safety:
18494            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18495            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18496            //   envelope_size bytes, there is always sufficient room.
18497            fidl::encoding::encode_in_envelope_optional::<
18498                fidl::encoding::HandleType<
18499                    fdomain_client::Event,
18500                    { fidl::ObjectType::EVENT.into_raw() },
18501                    2147483648,
18502                >,
18503                fdomain_client::fidl::FDomainResourceDialect,
18504            >(
18505                self.node_ref.as_mut().map(
18506                    <fidl::encoding::HandleType<
18507                        fdomain_client::Event,
18508                        { fidl::ObjectType::EVENT.into_raw() },
18509                        2147483648,
18510                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18511                ),
18512                encoder,
18513                offset + cur_offset,
18514                depth,
18515            )?;
18516
18517            _prev_end_offset = cur_offset + envelope_size;
18518
18519            Ok(())
18520        }
18521    }
18522
18523    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18524        for NodeGetNodeRefResponse
18525    {
18526        #[inline(always)]
18527        fn new_empty() -> Self {
18528            Self::default()
18529        }
18530
18531        unsafe fn decode(
18532            &mut self,
18533            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18534            offset: usize,
18535            mut depth: fidl::encoding::Depth,
18536        ) -> fidl::Result<()> {
18537            decoder.debug_check_bounds::<Self>(offset);
18538            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18539                None => return Err(fidl::Error::NotNullable),
18540                Some(len) => len,
18541            };
18542            // Calling decoder.out_of_line_offset(0) is not allowed.
18543            if len == 0 {
18544                return Ok(());
18545            };
18546            depth.increment()?;
18547            let envelope_size = 8;
18548            let bytes_len = len * envelope_size;
18549            let offset = decoder.out_of_line_offset(bytes_len)?;
18550            // Decode the envelope for each type.
18551            let mut _next_ordinal_to_read = 0;
18552            let mut next_offset = offset;
18553            let end_offset = offset + bytes_len;
18554            _next_ordinal_to_read += 1;
18555            if next_offset >= end_offset {
18556                return Ok(());
18557            }
18558
18559            // Decode unknown envelopes for gaps in ordinals.
18560            while _next_ordinal_to_read < 1 {
18561                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18562                _next_ordinal_to_read += 1;
18563                next_offset += envelope_size;
18564            }
18565
18566            let next_out_of_line = decoder.next_out_of_line();
18567            let handles_before = decoder.remaining_handles();
18568            if let Some((inlined, num_bytes, num_handles)) =
18569                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18570            {
18571                let member_inline_size = <fidl::encoding::HandleType<
18572                    fdomain_client::Event,
18573                    { fidl::ObjectType::EVENT.into_raw() },
18574                    2147483648,
18575                > as fidl::encoding::TypeMarker>::inline_size(
18576                    decoder.context
18577                );
18578                if inlined != (member_inline_size <= 4) {
18579                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18580                }
18581                let inner_offset;
18582                let mut inner_depth = depth.clone();
18583                if inlined {
18584                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18585                    inner_offset = next_offset;
18586                } else {
18587                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18588                    inner_depth.increment()?;
18589                }
18590                let val_ref =
18591                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));
18592                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)?;
18593                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18594                {
18595                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18596                }
18597                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18598                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18599                }
18600            }
18601
18602            next_offset += envelope_size;
18603
18604            // Decode the remaining unknown envelopes.
18605            while next_offset < end_offset {
18606                _next_ordinal_to_read += 1;
18607                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18608                next_offset += envelope_size;
18609            }
18610
18611            Ok(())
18612        }
18613    }
18614
18615    impl VmoBuffer {
18616        #[inline(always)]
18617        fn max_ordinal_present(&self) -> u64 {
18618            if let Some(_) = self.close_weak_asap {
18619                return 3;
18620            }
18621            if let Some(_) = self.vmo_usable_start {
18622                return 2;
18623            }
18624            if let Some(_) = self.vmo {
18625                return 1;
18626            }
18627            0
18628        }
18629    }
18630
18631    impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
18632        type Borrowed<'a> = &'a mut Self;
18633        fn take_or_borrow<'a>(
18634            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18635        ) -> Self::Borrowed<'a> {
18636            value
18637        }
18638    }
18639
18640    unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
18641        type Owned = Self;
18642
18643        #[inline(always)]
18644        fn inline_align(_context: fidl::encoding::Context) -> usize {
18645            8
18646        }
18647
18648        #[inline(always)]
18649        fn inline_size(_context: fidl::encoding::Context) -> usize {
18650            16
18651        }
18652    }
18653
18654    unsafe impl fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>
18655        for &mut VmoBuffer
18656    {
18657        unsafe fn encode(
18658            self,
18659            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18660            offset: usize,
18661            mut depth: fidl::encoding::Depth,
18662        ) -> fidl::Result<()> {
18663            encoder.debug_check_bounds::<VmoBuffer>(offset);
18664            // Vector header
18665            let max_ordinal: u64 = self.max_ordinal_present();
18666            encoder.write_num(max_ordinal, offset);
18667            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
18668            // Calling encoder.out_of_line_offset(0) is not allowed.
18669            if max_ordinal == 0 {
18670                return Ok(());
18671            }
18672            depth.increment()?;
18673            let envelope_size = 8;
18674            let bytes_len = max_ordinal as usize * envelope_size;
18675            #[allow(unused_variables)]
18676            let offset = encoder.out_of_line_offset(bytes_len);
18677            let mut _prev_end_offset: usize = 0;
18678            if 1 > 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 = (1 - 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                fidl::encoding::HandleType<
18695                    fdomain_client::Vmo,
18696                    { fidl::ObjectType::VMO.into_raw() },
18697                    2147483648,
18698                >,
18699                fdomain_client::fidl::FDomainResourceDialect,
18700            >(
18701                self.vmo.as_mut().map(
18702                    <fidl::encoding::HandleType<
18703                        fdomain_client::Vmo,
18704                        { fidl::ObjectType::VMO.into_raw() },
18705                        2147483648,
18706                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18707                ),
18708                encoder,
18709                offset + cur_offset,
18710                depth,
18711            )?;
18712
18713            _prev_end_offset = cur_offset + envelope_size;
18714            if 2 > max_ordinal {
18715                return Ok(());
18716            }
18717
18718            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18719            // are envelope_size bytes.
18720            let cur_offset: usize = (2 - 1) * envelope_size;
18721
18722            // Zero reserved fields.
18723            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18724
18725            // Safety:
18726            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18727            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18728            //   envelope_size bytes, there is always sufficient room.
18729            fidl::encoding::encode_in_envelope_optional::<
18730                u64,
18731                fdomain_client::fidl::FDomainResourceDialect,
18732            >(
18733                self.vmo_usable_start
18734                    .as_ref()
18735                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
18736                encoder,
18737                offset + cur_offset,
18738                depth,
18739            )?;
18740
18741            _prev_end_offset = cur_offset + envelope_size;
18742            if 3 > max_ordinal {
18743                return Ok(());
18744            }
18745
18746            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
18747            // are envelope_size bytes.
18748            let cur_offset: usize = (3 - 1) * envelope_size;
18749
18750            // Zero reserved fields.
18751            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
18752
18753            // Safety:
18754            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
18755            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
18756            //   envelope_size bytes, there is always sufficient room.
18757            fidl::encoding::encode_in_envelope_optional::<
18758                fidl::encoding::HandleType<
18759                    fdomain_client::EventPair,
18760                    { fidl::ObjectType::EVENTPAIR.into_raw() },
18761                    2147483648,
18762                >,
18763                fdomain_client::fidl::FDomainResourceDialect,
18764            >(
18765                self.close_weak_asap.as_mut().map(
18766                    <fidl::encoding::HandleType<
18767                        fdomain_client::EventPair,
18768                        { fidl::ObjectType::EVENTPAIR.into_raw() },
18769                        2147483648,
18770                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
18771                ),
18772                encoder,
18773                offset + cur_offset,
18774                depth,
18775            )?;
18776
18777            _prev_end_offset = cur_offset + envelope_size;
18778
18779            Ok(())
18780        }
18781    }
18782
18783    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {
18784        #[inline(always)]
18785        fn new_empty() -> Self {
18786            Self::default()
18787        }
18788
18789        unsafe fn decode(
18790            &mut self,
18791            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18792            offset: usize,
18793            mut depth: fidl::encoding::Depth,
18794        ) -> fidl::Result<()> {
18795            decoder.debug_check_bounds::<Self>(offset);
18796            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
18797                None => return Err(fidl::Error::NotNullable),
18798                Some(len) => len,
18799            };
18800            // Calling decoder.out_of_line_offset(0) is not allowed.
18801            if len == 0 {
18802                return Ok(());
18803            };
18804            depth.increment()?;
18805            let envelope_size = 8;
18806            let bytes_len = len * envelope_size;
18807            let offset = decoder.out_of_line_offset(bytes_len)?;
18808            // Decode the envelope for each type.
18809            let mut _next_ordinal_to_read = 0;
18810            let mut next_offset = offset;
18811            let end_offset = offset + bytes_len;
18812            _next_ordinal_to_read += 1;
18813            if next_offset >= end_offset {
18814                return Ok(());
18815            }
18816
18817            // Decode unknown envelopes for gaps in ordinals.
18818            while _next_ordinal_to_read < 1 {
18819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18820                _next_ordinal_to_read += 1;
18821                next_offset += envelope_size;
18822            }
18823
18824            let next_out_of_line = decoder.next_out_of_line();
18825            let handles_before = decoder.remaining_handles();
18826            if let Some((inlined, num_bytes, num_handles)) =
18827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18828            {
18829                let member_inline_size = <fidl::encoding::HandleType<
18830                    fdomain_client::Vmo,
18831                    { fidl::ObjectType::VMO.into_raw() },
18832                    2147483648,
18833                > as fidl::encoding::TypeMarker>::inline_size(
18834                    decoder.context
18835                );
18836                if inlined != (member_inline_size <= 4) {
18837                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18838                }
18839                let inner_offset;
18840                let mut inner_depth = depth.clone();
18841                if inlined {
18842                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18843                    inner_offset = next_offset;
18844                } else {
18845                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18846                    inner_depth.increment()?;
18847                }
18848                let val_ref =
18849                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));
18850                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)?;
18851                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18852                {
18853                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18854                }
18855                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18856                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18857                }
18858            }
18859
18860            next_offset += envelope_size;
18861            _next_ordinal_to_read += 1;
18862            if next_offset >= end_offset {
18863                return Ok(());
18864            }
18865
18866            // Decode unknown envelopes for gaps in ordinals.
18867            while _next_ordinal_to_read < 2 {
18868                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18869                _next_ordinal_to_read += 1;
18870                next_offset += envelope_size;
18871            }
18872
18873            let next_out_of_line = decoder.next_out_of_line();
18874            let handles_before = decoder.remaining_handles();
18875            if let Some((inlined, num_bytes, num_handles)) =
18876                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18877            {
18878                let member_inline_size =
18879                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
18880                if inlined != (member_inline_size <= 4) {
18881                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18882                }
18883                let inner_offset;
18884                let mut inner_depth = depth.clone();
18885                if inlined {
18886                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18887                    inner_offset = next_offset;
18888                } else {
18889                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18890                    inner_depth.increment()?;
18891                }
18892                let val_ref = self.vmo_usable_start.get_or_insert_with(|| {
18893                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
18894                });
18895                fidl::decode!(
18896                    u64,
18897                    fdomain_client::fidl::FDomainResourceDialect,
18898                    val_ref,
18899                    decoder,
18900                    inner_offset,
18901                    inner_depth
18902                )?;
18903                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18904                {
18905                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18906                }
18907                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18908                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18909                }
18910            }
18911
18912            next_offset += envelope_size;
18913            _next_ordinal_to_read += 1;
18914            if next_offset >= end_offset {
18915                return Ok(());
18916            }
18917
18918            // Decode unknown envelopes for gaps in ordinals.
18919            while _next_ordinal_to_read < 3 {
18920                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18921                _next_ordinal_to_read += 1;
18922                next_offset += envelope_size;
18923            }
18924
18925            let next_out_of_line = decoder.next_out_of_line();
18926            let handles_before = decoder.remaining_handles();
18927            if let Some((inlined, num_bytes, num_handles)) =
18928                fidl::encoding::decode_envelope_header(decoder, next_offset)?
18929            {
18930                let member_inline_size = <fidl::encoding::HandleType<
18931                    fdomain_client::EventPair,
18932                    { fidl::ObjectType::EVENTPAIR.into_raw() },
18933                    2147483648,
18934                > as fidl::encoding::TypeMarker>::inline_size(
18935                    decoder.context
18936                );
18937                if inlined != (member_inline_size <= 4) {
18938                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
18939                }
18940                let inner_offset;
18941                let mut inner_depth = depth.clone();
18942                if inlined {
18943                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
18944                    inner_offset = next_offset;
18945                } else {
18946                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
18947                    inner_depth.increment()?;
18948                }
18949                let val_ref =
18950                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));
18951                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)?;
18952                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
18953                {
18954                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
18955                }
18956                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
18957                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
18958                }
18959            }
18960
18961            next_offset += envelope_size;
18962
18963            // Decode the remaining unknown envelopes.
18964            while next_offset < end_offset {
18965                _next_ordinal_to_read += 1;
18966                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
18967                next_offset += envelope_size;
18968            }
18969
18970            Ok(())
18971        }
18972    }
18973}