fdomain_fuchsia_sysmem/fdomain_fuchsia_sysmem.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_sysmem__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct AllocatorAllocateNonSharedCollectionRequest {
15 pub collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
16}
17
18impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
19 for AllocatorAllocateNonSharedCollectionRequest
20{
21}
22
23#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24pub struct AllocatorAllocateSharedCollectionRequest {
25 pub token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
26}
27
28impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
29 for AllocatorAllocateSharedCollectionRequest
30{
31}
32
33#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct AllocatorBindSharedCollectionRequest {
35 pub token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
36 pub buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
37}
38
39impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
40 for AllocatorBindSharedCollectionRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct AllocatorConnectToSysmem2AllocatorRequest {
46 pub allocator_request:
47 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
48}
49
50impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
51 for AllocatorConnectToSysmem2AllocatorRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct BufferCollectionAttachLifetimeTrackingRequest {
57 pub server_end: fdomain_client::EventPair,
58 pub buffers_remaining: u32,
59}
60
61impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
62 for BufferCollectionAttachLifetimeTrackingRequest
63{
64}
65
66#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67pub struct BufferCollectionAttachTokenRequest {
68 pub rights_attenuation_mask: u32,
69 pub token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
70}
71
72impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
73 for BufferCollectionAttachTokenRequest
74{
75}
76
77/// Deprecated. Use ['fuchsia.sysmem2.BufferCollectionInfo'].
78///
79/// This type is deprecated for new code but still used by some camera code.
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct BufferCollectionInfo {
82 /// The number of buffers in the collection.
83 pub buffer_count: u32,
84 /// Describes how the contents of buffers are represented.
85 /// All buffers within the collection have the same format.
86 pub format: BufferFormat,
87 /// VMO handles for each buffer in the collection.
88 /// The VMOs are only present when the buffers are backed by VMOs.
89 ///
90 /// If present, all the VMOs after `buffer_count` are invalid handles.
91 /// All buffer VMO handles have identical size and access rights.
92 /// The VMO access rights are determined based on the usages which the
93 /// client specified when allocating the buffer collection. For example,
94 /// a client which expressed a read-only usage will receive VMOs without
95 /// write rights.
96 pub vmos: [Option<fdomain_client::Vmo>; 64],
97 /// The size of each VMO provided.
98 /// This property is only present when the buffers are backed by VMOs.
99 pub vmo_size: u64,
100}
101
102impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for BufferCollectionInfo {}
103
104/// Information about a buffer collection and its buffers.
105#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
106pub struct BufferCollectionInfo2 {
107 /// The total number of buffers.
108 pub buffer_count: u32,
109 /// These settings apply to all the buffers in the initial buffer allocation.
110 pub settings: SingleBufferSettings,
111 /// VMO handles (and vmo_usable_start offset) for each buffer in the
112 /// collection.
113 ///
114 /// If present, all the VMOs at or after index `buffer_count` are invalid
115 /// (0) handles.
116 ///
117 /// All buffer VMO handles have identical size and access rights. The size
118 /// is in settings.buffer_settings.size_bytes.
119 ///
120 /// The VMO access rights are determined based on the usages which the
121 /// client specified when allocating the buffer collection. For example,
122 /// a client which expressed a read-only usage will receive VMOs without
123 /// write rights. In addition, the rights can be attenuated by the
124 /// parameter to BufferCollectionToken.Duplicate() calls.
125 pub buffers: [VmoBuffer; 64],
126}
127
128impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for BufferCollectionInfo2 {}
129
130#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
131pub struct BufferCollectionTokenCreateBufferCollectionTokenGroupRequest {
132 pub group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
133}
134
135impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
136 for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
137{
138}
139
140#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
141pub struct BufferCollectionTokenDuplicateRequest {
142 pub rights_attenuation_mask: u32,
143 pub token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
144}
145
146impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
147 for BufferCollectionTokenDuplicateRequest
148{
149}
150
151#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
152pub struct BufferCollectionTokenDuplicateSyncResponse {
153 pub tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
154}
155
156impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
157 for BufferCollectionTokenDuplicateSyncResponse
158{
159}
160
161#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
162pub struct BufferCollectionTokenGroupCreateChildrenSyncResponse {
163 pub tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
164}
165
166impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
167 for BufferCollectionTokenGroupCreateChildrenSyncResponse
168{
169}
170
171#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
172pub struct BufferCollectionWaitForBuffersAllocatedResponse {
173 pub status: i32,
174 pub buffer_collection_info: BufferCollectionInfo2,
175}
176
177impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
178 for BufferCollectionWaitForBuffersAllocatedResponse
179{
180}
181
182#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
183pub struct NodeGetNodeRefResponse {
184 pub node_ref: fdomain_client::Event,
185}
186
187impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeGetNodeRefResponse {}
188
189#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
190pub struct NodeIsAlternateForRequest {
191 pub node_ref: fdomain_client::Event,
192}
193
194impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for NodeIsAlternateForRequest {}
195
196/// There is no current replacement for this type, but if your use case needs
197/// incremental buffer allocation within a single collection, please reach out.
198#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
199pub struct SingleBufferInfo {
200 pub settings: SingleBufferSettings,
201 pub buffer: VmoBuffer,
202}
203
204impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for SingleBufferInfo {}
205
206#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
207pub struct VmoBuffer {
208 /// The same VMO can be used by more than one CodecBuffer (only of the same
209 /// buffer_lifetime_ordinal), but each vmo handle must be a separate handle.
210 ///
211 /// The vmo field can be 0 if this is a VmoBuffer in BufferCollectionInfo_2
212 /// that's at or beyond BufferCollectionInfo_2.buffer_count.
213 pub vmo: Option<fdomain_client::Vmo>,
214 /// Offset within the VMO of the first usable byte. Must be < the VMO's
215 /// size in bytes, and leave sufficient room for
216 /// BufferMemorySettings.size_bytes before the end of the VMO.
217 pub vmo_usable_start: u64,
218}
219
220impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {}
221
222#[derive(Debug, Default, PartialEq)]
223pub struct BufferCollectionTokenGroupCreateChildRequest {
224 /// Must be set.
225 pub token_request: Option<fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>>,
226 /// If not set, the default is ZX_RIGHT_SAME_RIGHTS.
227 pub rights_attenuation_mask: Option<u32>,
228 #[doc(hidden)]
229 pub __source_breaking: fidl::marker::SourceBreaking,
230}
231
232impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
233 for BufferCollectionTokenGroupCreateChildRequest
234{
235}
236
237#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
238pub struct AllocatorMarker;
239
240impl fdomain_client::fidl::ProtocolMarker for AllocatorMarker {
241 type Proxy = AllocatorProxy;
242 type RequestStream = AllocatorRequestStream;
243
244 const DEBUG_NAME: &'static str = "fuchsia.sysmem.Allocator";
245}
246impl fdomain_client::fidl::DiscoverableProtocolMarker for AllocatorMarker {}
247
248pub trait AllocatorProxyInterface: Send + Sync {
249 fn r#allocate_non_shared_collection(
250 &self,
251 collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
252 ) -> Result<(), fidl::Error>;
253 fn r#allocate_shared_collection(
254 &self,
255 token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
256 ) -> Result<(), fidl::Error>;
257 fn r#bind_shared_collection(
258 &self,
259 token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
260 buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
261 ) -> Result<(), fidl::Error>;
262 type ValidateBufferCollectionTokenResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
263 + Send;
264 fn r#validate_buffer_collection_token(
265 &self,
266 token_server_koid: u64,
267 ) -> Self::ValidateBufferCollectionTokenResponseFut;
268 fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
269 fn r#connect_to_sysmem2_allocator(
270 &self,
271 allocator_request: fdomain_client::fidl::ServerEnd<
272 fdomain_fuchsia_sysmem2::AllocatorMarker,
273 >,
274 ) -> Result<(), fidl::Error>;
275}
276
277#[derive(Debug, Clone)]
278pub struct AllocatorProxy {
279 client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
280}
281
282impl fdomain_client::fidl::Proxy for AllocatorProxy {
283 type Protocol = AllocatorMarker;
284
285 fn from_channel(inner: fdomain_client::Channel) -> Self {
286 Self::new(inner)
287 }
288
289 fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
290 self.client.into_channel().map_err(|client| Self { client })
291 }
292
293 fn as_channel(&self) -> &fdomain_client::Channel {
294 self.client.as_channel()
295 }
296}
297
298impl AllocatorProxy {
299 /// Create a new Proxy for fuchsia.sysmem/Allocator.
300 pub fn new(channel: fdomain_client::Channel) -> Self {
301 let protocol_name = <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
302 Self { client: fidl::client::Client::new(channel, protocol_name) }
303 }
304
305 /// Get a Stream of events from the remote end of the protocol.
306 ///
307 /// # Panics
308 ///
309 /// Panics if the event stream was already taken.
310 pub fn take_event_stream(&self) -> AllocatorEventStream {
311 AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
312 }
313
314 /// Allocates a BufferCollection on behalf of a single client (aka initiator)
315 /// who is also the only participant (from the point of view of sysmem).
316 ///
317 /// This call exists mainly for temp/testing purposes. This call skips the
318 /// BufferCollectionToken stage, so there's no way to allow another
319 /// participant to specify its constraints.
320 ///
321 /// Real clients are encouraged to use AllocateSharedCollection() instead,
322 /// and to let relevant participants directly convey their own constraints to
323 /// sysmem.
324 ///
325 /// `collection_request` is the server end of the BufferCollection FIDL
326 /// channel. The client can call SetConstraints() and then
327 /// WaitForBuffersAllocated() on the client end of this channel to specify
328 /// constraints and then determine success/failure and get the
329 /// BufferCollectionInfo_2 for the BufferCollection. The client should also
330 /// keep the client end of this channel open while using the
331 /// BufferCollection, and should notice when this channel closes and stop
332 /// using the BufferCollection ASAP.
333 pub fn r#allocate_non_shared_collection(
334 &self,
335 mut collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
336 ) -> Result<(), fidl::Error> {
337 AllocatorProxyInterface::r#allocate_non_shared_collection(self, collection_request)
338 }
339
340 /// Creates a logical BufferCollectionToken which can be shared among
341 /// participants (using BufferCollectionToken.Duplicate()), and then
342 /// converted into a BufferCollection using BindSharedCollection().
343 ///
344 /// Success/failure to populate the BufferCollection with buffers is
345 /// determined via the BufferCollection interface.
346 pub fn r#allocate_shared_collection(
347 &self,
348 mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
349 ) -> Result<(), fidl::Error> {
350 AllocatorProxyInterface::r#allocate_shared_collection(self, token_request)
351 }
352
353 /// Convert a BufferCollectionToken into a connection to the logical
354 /// BufferCollection. The BufferCollection hasn't yet been populated with
355 /// buffers - the participant must first also send SetConstraints() via the
356 /// client end of buffer_collection.
357 ///
358 /// All BufferCollectionToken(s) duplicated from a logical
359 /// BufferCollectionToken created via AllocateSharedCollection() must be
360 /// turned in via BindSharedCollection() before the logical BufferCollection
361 /// will be populated with buffers.
362 ///
363 /// `token` the client endpoint of a channel whose server end was sent to
364 /// sysmem using AllocateSharedCollection or whose server end was sent to
365 /// sysmem using BufferCollectionToken.Duplicate(). The token is being
366 /// "exchanged" for a channel to the logical BufferCollection.
367 ///
368 /// `buffer_collection_request` the server end of a BufferCollection
369 /// channel. The sender retains the client end as usual. The
370 /// BufferCollection channel is a single participant's connection to the
371 /// logical BufferCollection. There typically will be other participants
372 /// with their own BufferCollection channel to the logical BufferCollection.
373 pub fn r#bind_shared_collection(
374 &self,
375 mut token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
376 mut buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
377 ) -> Result<(), fidl::Error> {
378 AllocatorProxyInterface::r#bind_shared_collection(self, token, buffer_collection_request)
379 }
380
381 /// Validate that a BufferCollectionToken is known to the sysmem server.
382 ///
383 /// This can be used in cases where BindSharedCollection() won't be called
384 /// until after BufferCollectionToken.Duplicate() +
385 /// BufferCollectionToken.Sync(), when the client code wants to know earlier
386 /// whether an incoming token is valid (so far).
387 ///
388 /// Calling BufferCollectionToken.Sync() on a token that isn't known to
389 /// sysmem risks the Sync() hanging forever.
390 ///
391 /// Given that an incoming token can become invalid at any time if any
392 /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
393 /// authors of client code are encouraged to consider not calling
394 /// ValidateBufferCollectionToken() and instead dealing with async failure
395 /// of the BufferCollection.Sync() after all the
396 /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
397 /// sending any duplicate tokens to other processes).
398 ///
399 /// Regardless of the result of this call, this call has no effect on the
400 /// token with the referenced koid.
401 ///
402 /// A true result from this call doesn't guarantee that the token remains
403 /// valid for any duration afterwards.
404 ///
405 /// Client code will zx_object_get_info() on the client's token handle,
406 /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
407 /// which then gets passed to ValidateBufferCollectionToken().
408 ///
409 /// If ValidateBufferCollectionToken() returns true, the token was known at
410 /// the time the sysmem server processed the call, but may no longer be
411 /// valid/known by the time the client code receives the response.
412 ///
413 /// If ValidateBufferCollectionToken() returns false, the token wasn't known
414 /// at the time the sysmem server processed the call, but the token may
415 /// become known by the time the client code receives the response. However
416 /// client code is not required to mitigate the possibility that the token
417 /// may become known late, since the source of the token should have synced
418 /// the token to sysmem before sending the token to the client code.
419 ///
420 /// If calling ValidateBufferCollectionToken() fails in some way, there will
421 /// be a zx_status_t from the FIDL layer.
422 ///
423 /// `token_server_koid` the koid of the server end of a channel that might
424 /// be a BufferCollectionToken channel. This can be obtained from
425 /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
426 pub fn r#validate_buffer_collection_token(
427 &self,
428 mut token_server_koid: u64,
429 ) -> fidl::client::QueryResponseFut<bool, fdomain_client::fidl::FDomainResourceDialect> {
430 AllocatorProxyInterface::r#validate_buffer_collection_token(self, token_server_koid)
431 }
432
433 /// Set information about the current client that can be used by sysmem to
434 /// help debug leaking memory and hangs waiting for constraints. |name| can
435 /// be an arbitrary string, but the current process name (see
436 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
437 /// arbitrary id, but the current process ID (see
438 /// fsl::GetCurrentProcessKoid()) is a good default.
439 ///
440 /// This information is propagated to all BufferCollections created using
441 /// BindSharedCollection() or AllocateNonSharedCollection() from this
442 /// allocator. It does not affect BufferCollectionTokens, since they are
443 /// often passed cross-process and should have their names managed manually.
444 pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
445 AllocatorProxyInterface::r#set_debug_client_info(self, name, id)
446 }
447
448 /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
449 /// `Allocator`.
450 ///
451 /// This is mainly useful in situations where library code is handed a
452 /// sysmem(1) allocator, but the library code has been updated to use
453 /// sysmem2. Typically the library will provide a way to pass in a sysmem2
454 /// `Allocator` instead, but client code isn't always in the same repo, so
455 /// this message allows the library to still accept the sysmem(1) Allocator
456 /// temporarily.
457 ///
458 /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
459 /// `Allocator`.
460 pub fn r#connect_to_sysmem2_allocator(
461 &self,
462 mut allocator_request: fdomain_client::fidl::ServerEnd<
463 fdomain_fuchsia_sysmem2::AllocatorMarker,
464 >,
465 ) -> Result<(), fidl::Error> {
466 AllocatorProxyInterface::r#connect_to_sysmem2_allocator(self, allocator_request)
467 }
468}
469
470impl AllocatorProxyInterface for AllocatorProxy {
471 fn r#allocate_non_shared_collection(
472 &self,
473 mut collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
474 ) -> Result<(), fidl::Error> {
475 self.client.send::<AllocatorAllocateNonSharedCollectionRequest>(
476 (collection_request,),
477 0x20f79299bbb4d2c6,
478 fidl::encoding::DynamicFlags::empty(),
479 )
480 }
481
482 fn r#allocate_shared_collection(
483 &self,
484 mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
485 ) -> Result<(), fidl::Error> {
486 self.client.send::<AllocatorAllocateSharedCollectionRequest>(
487 (token_request,),
488 0x7a757a57bfda0f71,
489 fidl::encoding::DynamicFlags::empty(),
490 )
491 }
492
493 fn r#bind_shared_collection(
494 &self,
495 mut token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
496 mut buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
497 ) -> Result<(), fidl::Error> {
498 self.client.send::<AllocatorBindSharedCollectionRequest>(
499 (token, buffer_collection_request),
500 0x146eca7ec46ff4ee,
501 fidl::encoding::DynamicFlags::empty(),
502 )
503 }
504
505 type ValidateBufferCollectionTokenResponseFut =
506 fidl::client::QueryResponseFut<bool, fdomain_client::fidl::FDomainResourceDialect>;
507 fn r#validate_buffer_collection_token(
508 &self,
509 mut token_server_koid: u64,
510 ) -> Self::ValidateBufferCollectionTokenResponseFut {
511 fn _decode(
512 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
513 ) -> Result<bool, fidl::Error> {
514 let _response = fidl::client::decode_transaction_body::<
515 AllocatorValidateBufferCollectionTokenResponse,
516 fdomain_client::fidl::FDomainResourceDialect,
517 0x575b279b0236faea,
518 >(_buf?)?;
519 Ok(_response.is_known)
520 }
521 self.client.send_query_and_decode::<AllocatorValidateBufferCollectionTokenRequest, bool>(
522 (token_server_koid,),
523 0x575b279b0236faea,
524 fidl::encoding::DynamicFlags::empty(),
525 _decode,
526 )
527 }
528
529 fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
530 self.client.send::<AllocatorSetDebugClientInfoRequest>(
531 (name, id),
532 0x419f0d5b30728b26,
533 fidl::encoding::DynamicFlags::empty(),
534 )
535 }
536
537 fn r#connect_to_sysmem2_allocator(
538 &self,
539 mut allocator_request: fdomain_client::fidl::ServerEnd<
540 fdomain_fuchsia_sysmem2::AllocatorMarker,
541 >,
542 ) -> Result<(), fidl::Error> {
543 self.client.send::<AllocatorConnectToSysmem2AllocatorRequest>(
544 (allocator_request,),
545 0x13db3e3abac2e24,
546 fidl::encoding::DynamicFlags::empty(),
547 )
548 }
549}
550
551pub struct AllocatorEventStream {
552 event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
553}
554
555impl std::marker::Unpin for AllocatorEventStream {}
556
557impl futures::stream::FusedStream for AllocatorEventStream {
558 fn is_terminated(&self) -> bool {
559 self.event_receiver.is_terminated()
560 }
561}
562
563impl futures::Stream for AllocatorEventStream {
564 type Item = Result<AllocatorEvent, fidl::Error>;
565
566 fn poll_next(
567 mut self: std::pin::Pin<&mut Self>,
568 cx: &mut std::task::Context<'_>,
569 ) -> std::task::Poll<Option<Self::Item>> {
570 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
571 &mut self.event_receiver,
572 cx
573 )?) {
574 Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
575 None => std::task::Poll::Ready(None),
576 }
577 }
578}
579
580#[derive(Debug)]
581pub enum AllocatorEvent {}
582
583impl AllocatorEvent {
584 /// Decodes a message buffer as a [`AllocatorEvent`].
585 fn decode(
586 mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
587 ) -> Result<AllocatorEvent, fidl::Error> {
588 let (bytes, _handles) = buf.split_mut();
589 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
590 debug_assert_eq!(tx_header.tx_id, 0);
591 match tx_header.ordinal {
592 _ => Err(fidl::Error::UnknownOrdinal {
593 ordinal: tx_header.ordinal,
594 protocol_name:
595 <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
596 }),
597 }
598 }
599}
600
601/// A Stream of incoming requests for fuchsia.sysmem/Allocator.
602pub struct AllocatorRequestStream {
603 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
604 is_terminated: bool,
605}
606
607impl std::marker::Unpin for AllocatorRequestStream {}
608
609impl futures::stream::FusedStream for AllocatorRequestStream {
610 fn is_terminated(&self) -> bool {
611 self.is_terminated
612 }
613}
614
615impl fdomain_client::fidl::RequestStream for AllocatorRequestStream {
616 type Protocol = AllocatorMarker;
617 type ControlHandle = AllocatorControlHandle;
618
619 fn from_channel(channel: fdomain_client::Channel) -> Self {
620 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
621 }
622
623 fn control_handle(&self) -> Self::ControlHandle {
624 AllocatorControlHandle { inner: self.inner.clone() }
625 }
626
627 fn into_inner(
628 self,
629 ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
630 {
631 (self.inner, self.is_terminated)
632 }
633
634 fn from_inner(
635 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
636 is_terminated: bool,
637 ) -> Self {
638 Self { inner, is_terminated }
639 }
640}
641
642impl futures::Stream for AllocatorRequestStream {
643 type Item = Result<AllocatorRequest, fidl::Error>;
644
645 fn poll_next(
646 mut self: std::pin::Pin<&mut Self>,
647 cx: &mut std::task::Context<'_>,
648 ) -> std::task::Poll<Option<Self::Item>> {
649 let this = &mut *self;
650 if this.inner.check_shutdown(cx) {
651 this.is_terminated = true;
652 return std::task::Poll::Ready(None);
653 }
654 if this.is_terminated {
655 panic!("polled AllocatorRequestStream after completion");
656 }
657 fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
658 |bytes, handles| {
659 match this.inner.channel().read_etc(cx, bytes, handles) {
660 std::task::Poll::Ready(Ok(())) => {}
661 std::task::Poll::Pending => return std::task::Poll::Pending,
662 std::task::Poll::Ready(Err(None)) => {
663 this.is_terminated = true;
664 return std::task::Poll::Ready(None);
665 }
666 std::task::Poll::Ready(Err(Some(e))) => {
667 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
668 e.into(),
669 ))));
670 }
671 }
672
673 // A message has been received from the channel
674 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
675
676 std::task::Poll::Ready(Some(match header.ordinal {
677 0x20f79299bbb4d2c6 => {
678 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
679 let mut req = fidl::new_empty!(
680 AllocatorAllocateNonSharedCollectionRequest,
681 fdomain_client::fidl::FDomainResourceDialect
682 );
683 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateNonSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
684 let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
685 Ok(AllocatorRequest::AllocateNonSharedCollection {
686 collection_request: req.collection_request,
687
688 control_handle,
689 })
690 }
691 0x7a757a57bfda0f71 => {
692 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
693 let mut req = fidl::new_empty!(
694 AllocatorAllocateSharedCollectionRequest,
695 fdomain_client::fidl::FDomainResourceDialect
696 );
697 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorAllocateSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
698 let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
699 Ok(AllocatorRequest::AllocateSharedCollection {
700 token_request: req.token_request,
701
702 control_handle,
703 })
704 }
705 0x146eca7ec46ff4ee => {
706 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
707 let mut req = fidl::new_empty!(
708 AllocatorBindSharedCollectionRequest,
709 fdomain_client::fidl::FDomainResourceDialect
710 );
711 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorBindSharedCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
712 let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
713 Ok(AllocatorRequest::BindSharedCollection {
714 token: req.token,
715 buffer_collection_request: req.buffer_collection_request,
716
717 control_handle,
718 })
719 }
720 0x575b279b0236faea => {
721 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
722 let mut req = fidl::new_empty!(
723 AllocatorValidateBufferCollectionTokenRequest,
724 fdomain_client::fidl::FDomainResourceDialect
725 );
726 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorValidateBufferCollectionTokenRequest>(&header, _body_bytes, handles, &mut req)?;
727 let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
728 Ok(AllocatorRequest::ValidateBufferCollectionToken {
729 token_server_koid: req.token_server_koid,
730
731 responder: AllocatorValidateBufferCollectionTokenResponder {
732 control_handle: std::mem::ManuallyDrop::new(control_handle),
733 tx_id: header.tx_id,
734 },
735 })
736 }
737 0x419f0d5b30728b26 => {
738 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
739 let mut req = fidl::new_empty!(
740 AllocatorSetDebugClientInfoRequest,
741 fdomain_client::fidl::FDomainResourceDialect
742 );
743 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
744 let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
745 Ok(AllocatorRequest::SetDebugClientInfo {
746 name: req.name,
747 id: req.id,
748
749 control_handle,
750 })
751 }
752 0x13db3e3abac2e24 => {
753 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
754 let mut req = fidl::new_empty!(
755 AllocatorConnectToSysmem2AllocatorRequest,
756 fdomain_client::fidl::FDomainResourceDialect
757 );
758 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AllocatorConnectToSysmem2AllocatorRequest>(&header, _body_bytes, handles, &mut req)?;
759 let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
760 Ok(AllocatorRequest::ConnectToSysmem2Allocator {
761 allocator_request: req.allocator_request,
762
763 control_handle,
764 })
765 }
766 _ => Err(fidl::Error::UnknownOrdinal {
767 ordinal: header.ordinal,
768 protocol_name:
769 <AllocatorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
770 }),
771 }))
772 },
773 )
774 }
775}
776
777/// Allocates system memory buffers.
778#[derive(Debug)]
779pub enum AllocatorRequest {
780 /// Allocates a BufferCollection on behalf of a single client (aka initiator)
781 /// who is also the only participant (from the point of view of sysmem).
782 ///
783 /// This call exists mainly for temp/testing purposes. This call skips the
784 /// BufferCollectionToken stage, so there's no way to allow another
785 /// participant to specify its constraints.
786 ///
787 /// Real clients are encouraged to use AllocateSharedCollection() instead,
788 /// and to let relevant participants directly convey their own constraints to
789 /// sysmem.
790 ///
791 /// `collection_request` is the server end of the BufferCollection FIDL
792 /// channel. The client can call SetConstraints() and then
793 /// WaitForBuffersAllocated() on the client end of this channel to specify
794 /// constraints and then determine success/failure and get the
795 /// BufferCollectionInfo_2 for the BufferCollection. The client should also
796 /// keep the client end of this channel open while using the
797 /// BufferCollection, and should notice when this channel closes and stop
798 /// using the BufferCollection ASAP.
799 AllocateNonSharedCollection {
800 collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
801 control_handle: AllocatorControlHandle,
802 },
803 /// Creates a logical BufferCollectionToken which can be shared among
804 /// participants (using BufferCollectionToken.Duplicate()), and then
805 /// converted into a BufferCollection using BindSharedCollection().
806 ///
807 /// Success/failure to populate the BufferCollection with buffers is
808 /// determined via the BufferCollection interface.
809 AllocateSharedCollection {
810 token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
811 control_handle: AllocatorControlHandle,
812 },
813 /// Convert a BufferCollectionToken into a connection to the logical
814 /// BufferCollection. The BufferCollection hasn't yet been populated with
815 /// buffers - the participant must first also send SetConstraints() via the
816 /// client end of buffer_collection.
817 ///
818 /// All BufferCollectionToken(s) duplicated from a logical
819 /// BufferCollectionToken created via AllocateSharedCollection() must be
820 /// turned in via BindSharedCollection() before the logical BufferCollection
821 /// will be populated with buffers.
822 ///
823 /// `token` the client endpoint of a channel whose server end was sent to
824 /// sysmem using AllocateSharedCollection or whose server end was sent to
825 /// sysmem using BufferCollectionToken.Duplicate(). The token is being
826 /// "exchanged" for a channel to the logical BufferCollection.
827 ///
828 /// `buffer_collection_request` the server end of a BufferCollection
829 /// channel. The sender retains the client end as usual. The
830 /// BufferCollection channel is a single participant's connection to the
831 /// logical BufferCollection. There typically will be other participants
832 /// with their own BufferCollection channel to the logical BufferCollection.
833 BindSharedCollection {
834 token: fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
835 buffer_collection_request: fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
836 control_handle: AllocatorControlHandle,
837 },
838 /// Validate that a BufferCollectionToken is known to the sysmem server.
839 ///
840 /// This can be used in cases where BindSharedCollection() won't be called
841 /// until after BufferCollectionToken.Duplicate() +
842 /// BufferCollectionToken.Sync(), when the client code wants to know earlier
843 /// whether an incoming token is valid (so far).
844 ///
845 /// Calling BufferCollectionToken.Sync() on a token that isn't known to
846 /// sysmem risks the Sync() hanging forever.
847 ///
848 /// Given that an incoming token can become invalid at any time if any
849 /// participant drops their BufferCollectionToken(s) or BufferCollection(s),
850 /// authors of client code are encouraged to consider not calling
851 /// ValidateBufferCollectionToken() and instead dealing with async failure
852 /// of the BufferCollection.Sync() after all the
853 /// BufferCollectionToken.Duplicate() and BindSharedCollection() (before
854 /// sending any duplicate tokens to other processes).
855 ///
856 /// Regardless of the result of this call, this call has no effect on the
857 /// token with the referenced koid.
858 ///
859 /// A true result from this call doesn't guarantee that the token remains
860 /// valid for any duration afterwards.
861 ///
862 /// Client code will zx_object_get_info() on the client's token handle,
863 /// passing ZX_INFO_HANDLE_BASIC and getting back the related_koid
864 /// which then gets passed to ValidateBufferCollectionToken().
865 ///
866 /// If ValidateBufferCollectionToken() returns true, the token was known at
867 /// the time the sysmem server processed the call, but may no longer be
868 /// valid/known by the time the client code receives the response.
869 ///
870 /// If ValidateBufferCollectionToken() returns false, the token wasn't known
871 /// at the time the sysmem server processed the call, but the token may
872 /// become known by the time the client code receives the response. However
873 /// client code is not required to mitigate the possibility that the token
874 /// may become known late, since the source of the token should have synced
875 /// the token to sysmem before sending the token to the client code.
876 ///
877 /// If calling ValidateBufferCollectionToken() fails in some way, there will
878 /// be a zx_status_t from the FIDL layer.
879 ///
880 /// `token_server_koid` the koid of the server end of a channel that might
881 /// be a BufferCollectionToken channel. This can be obtained from
882 /// zx_object_get_info() ZX_INFO_HANDLE_BASIC related_koid.
883 ValidateBufferCollectionToken {
884 token_server_koid: u64,
885 responder: AllocatorValidateBufferCollectionTokenResponder,
886 },
887 /// Set information about the current client that can be used by sysmem to
888 /// help debug leaking memory and hangs waiting for constraints. |name| can
889 /// be an arbitrary string, but the current process name (see
890 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
891 /// arbitrary id, but the current process ID (see
892 /// fsl::GetCurrentProcessKoid()) is a good default.
893 ///
894 /// This information is propagated to all BufferCollections created using
895 /// BindSharedCollection() or AllocateNonSharedCollection() from this
896 /// allocator. It does not affect BufferCollectionTokens, since they are
897 /// often passed cross-process and should have their names managed manually.
898 SetDebugClientInfo { name: String, id: u64, control_handle: AllocatorControlHandle },
899 /// This allows creating a sysmem2 `Allocator` given a sysmem(1)
900 /// `Allocator`.
901 ///
902 /// This is mainly useful in situations where library code is handed a
903 /// sysmem(1) allocator, but the library code has been updated to use
904 /// sysmem2. Typically the library will provide a way to pass in a sysmem2
905 /// `Allocator` instead, but client code isn't always in the same repo, so
906 /// this message allows the library to still accept the sysmem(1) Allocator
907 /// temporarily.
908 ///
909 /// The info set via `SetDebugClientInfo` (if any) is copied to the sysmem2
910 /// `Allocator`.
911 ConnectToSysmem2Allocator {
912 allocator_request:
913 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
914 control_handle: AllocatorControlHandle,
915 },
916}
917
918impl AllocatorRequest {
919 #[allow(irrefutable_let_patterns)]
920 pub fn into_allocate_non_shared_collection(
921 self,
922 ) -> Option<(fdomain_client::fidl::ServerEnd<BufferCollectionMarker>, AllocatorControlHandle)>
923 {
924 if let AllocatorRequest::AllocateNonSharedCollection {
925 collection_request,
926 control_handle,
927 } = self
928 {
929 Some((collection_request, control_handle))
930 } else {
931 None
932 }
933 }
934
935 #[allow(irrefutable_let_patterns)]
936 pub fn into_allocate_shared_collection(
937 self,
938 ) -> Option<(
939 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
940 AllocatorControlHandle,
941 )> {
942 if let AllocatorRequest::AllocateSharedCollection { token_request, control_handle } = self {
943 Some((token_request, control_handle))
944 } else {
945 None
946 }
947 }
948
949 #[allow(irrefutable_let_patterns)]
950 pub fn into_bind_shared_collection(
951 self,
952 ) -> Option<(
953 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
954 fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
955 AllocatorControlHandle,
956 )> {
957 if let AllocatorRequest::BindSharedCollection {
958 token,
959 buffer_collection_request,
960 control_handle,
961 } = self
962 {
963 Some((token, buffer_collection_request, control_handle))
964 } else {
965 None
966 }
967 }
968
969 #[allow(irrefutable_let_patterns)]
970 pub fn into_validate_buffer_collection_token(
971 self,
972 ) -> Option<(u64, AllocatorValidateBufferCollectionTokenResponder)> {
973 if let AllocatorRequest::ValidateBufferCollectionToken { token_server_koid, responder } =
974 self
975 {
976 Some((token_server_koid, responder))
977 } else {
978 None
979 }
980 }
981
982 #[allow(irrefutable_let_patterns)]
983 pub fn into_set_debug_client_info(self) -> Option<(String, u64, AllocatorControlHandle)> {
984 if let AllocatorRequest::SetDebugClientInfo { name, id, control_handle } = self {
985 Some((name, id, control_handle))
986 } else {
987 None
988 }
989 }
990
991 #[allow(irrefutable_let_patterns)]
992 pub fn into_connect_to_sysmem2_allocator(
993 self,
994 ) -> Option<(
995 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
996 AllocatorControlHandle,
997 )> {
998 if let AllocatorRequest::ConnectToSysmem2Allocator { allocator_request, control_handle } =
999 self
1000 {
1001 Some((allocator_request, control_handle))
1002 } else {
1003 None
1004 }
1005 }
1006
1007 /// Name of the method defined in FIDL
1008 pub fn method_name(&self) -> &'static str {
1009 match *self {
1010 AllocatorRequest::AllocateNonSharedCollection { .. } => {
1011 "allocate_non_shared_collection"
1012 }
1013 AllocatorRequest::AllocateSharedCollection { .. } => "allocate_shared_collection",
1014 AllocatorRequest::BindSharedCollection { .. } => "bind_shared_collection",
1015 AllocatorRequest::ValidateBufferCollectionToken { .. } => {
1016 "validate_buffer_collection_token"
1017 }
1018 AllocatorRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
1019 AllocatorRequest::ConnectToSysmem2Allocator { .. } => "connect_to_sysmem2_allocator",
1020 }
1021 }
1022}
1023
1024#[derive(Debug, Clone)]
1025pub struct AllocatorControlHandle {
1026 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1027}
1028
1029impl fdomain_client::fidl::ControlHandle for AllocatorControlHandle {
1030 fn shutdown(&self) {
1031 self.inner.shutdown()
1032 }
1033
1034 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1035 self.inner.shutdown_with_epitaph(status)
1036 }
1037
1038 fn is_closed(&self) -> bool {
1039 self.inner.channel().is_closed()
1040 }
1041 fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1042 self.inner.channel().on_closed()
1043 }
1044}
1045
1046impl AllocatorControlHandle {}
1047
1048#[must_use = "FIDL methods require a response to be sent"]
1049#[derive(Debug)]
1050pub struct AllocatorValidateBufferCollectionTokenResponder {
1051 control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
1052 tx_id: u32,
1053}
1054
1055/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
1056/// if the responder is dropped without sending a response, so that the client
1057/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1058impl std::ops::Drop for AllocatorValidateBufferCollectionTokenResponder {
1059 fn drop(&mut self) {
1060 self.control_handle.shutdown();
1061 // Safety: drops once, never accessed again
1062 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1063 }
1064}
1065
1066impl fdomain_client::fidl::Responder for AllocatorValidateBufferCollectionTokenResponder {
1067 type ControlHandle = AllocatorControlHandle;
1068
1069 fn control_handle(&self) -> &AllocatorControlHandle {
1070 &self.control_handle
1071 }
1072
1073 fn drop_without_shutdown(mut self) {
1074 // Safety: drops once, never accessed again due to mem::forget
1075 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1076 // Prevent Drop from running (which would shut down the channel)
1077 std::mem::forget(self);
1078 }
1079}
1080
1081impl AllocatorValidateBufferCollectionTokenResponder {
1082 /// Sends a response to the FIDL transaction.
1083 ///
1084 /// Sets the channel to shutdown if an error occurs.
1085 pub fn send(self, mut is_known: bool) -> Result<(), fidl::Error> {
1086 let _result = self.send_raw(is_known);
1087 if _result.is_err() {
1088 self.control_handle.shutdown();
1089 }
1090 self.drop_without_shutdown();
1091 _result
1092 }
1093
1094 /// Similar to "send" but does not shutdown the channel if an error occurs.
1095 pub fn send_no_shutdown_on_err(self, mut is_known: bool) -> Result<(), fidl::Error> {
1096 let _result = self.send_raw(is_known);
1097 self.drop_without_shutdown();
1098 _result
1099 }
1100
1101 fn send_raw(&self, mut is_known: bool) -> Result<(), fidl::Error> {
1102 self.control_handle.inner.send::<AllocatorValidateBufferCollectionTokenResponse>(
1103 (is_known,),
1104 self.tx_id,
1105 0x575b279b0236faea,
1106 fidl::encoding::DynamicFlags::empty(),
1107 )
1108 }
1109}
1110
1111#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1112pub struct BufferCollectionMarker;
1113
1114impl fdomain_client::fidl::ProtocolMarker for BufferCollectionMarker {
1115 type Proxy = BufferCollectionProxy;
1116 type RequestStream = BufferCollectionRequestStream;
1117
1118 const DEBUG_NAME: &'static str = "(anonymous) BufferCollection";
1119}
1120
1121pub trait BufferCollectionProxyInterface: Send + Sync {
1122 type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1123 fn r#sync(&self) -> Self::SyncResponseFut;
1124 fn r#close(&self) -> Result<(), fidl::Error>;
1125 fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
1126 fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
1127 fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
1128 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
1129 type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
1130 + Send;
1131 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
1132 type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
1133 + Send;
1134 fn r#is_alternate_for(
1135 &self,
1136 node_ref: fdomain_client::Event,
1137 ) -> Self::IsAlternateForResponseFut;
1138 fn r#set_constraints(
1139 &self,
1140 has_constraints: bool,
1141 constraints: &BufferCollectionConstraints,
1142 ) -> Result<(), fidl::Error>;
1143 type WaitForBuffersAllocatedResponseFut: std::future::Future<Output = Result<(i32, BufferCollectionInfo2), fidl::Error>>
1144 + Send;
1145 fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut;
1146 type CheckBuffersAllocatedResponseFut: std::future::Future<Output = Result<i32, fidl::Error>>
1147 + Send;
1148 fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut;
1149 fn r#attach_token(
1150 &self,
1151 rights_attenuation_mask: u32,
1152 token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
1153 ) -> Result<(), fidl::Error>;
1154 fn r#attach_lifetime_tracking(
1155 &self,
1156 server_end: fdomain_client::EventPair,
1157 buffers_remaining: u32,
1158 ) -> Result<(), fidl::Error>;
1159}
1160
1161#[derive(Debug, Clone)]
1162pub struct BufferCollectionProxy {
1163 client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1164}
1165
1166impl fdomain_client::fidl::Proxy for BufferCollectionProxy {
1167 type Protocol = BufferCollectionMarker;
1168
1169 fn from_channel(inner: fdomain_client::Channel) -> Self {
1170 Self::new(inner)
1171 }
1172
1173 fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1174 self.client.into_channel().map_err(|client| Self { client })
1175 }
1176
1177 fn as_channel(&self) -> &fdomain_client::Channel {
1178 self.client.as_channel()
1179 }
1180}
1181
1182impl BufferCollectionProxy {
1183 /// Create a new Proxy for fuchsia.sysmem/BufferCollection.
1184 pub fn new(channel: fdomain_client::Channel) -> Self {
1185 let protocol_name =
1186 <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1187 Self { client: fidl::client::Client::new(channel, protocol_name) }
1188 }
1189
1190 /// Get a Stream of events from the remote end of the protocol.
1191 ///
1192 /// # Panics
1193 ///
1194 /// Panics if the event stream was already taken.
1195 pub fn take_event_stream(&self) -> BufferCollectionEventStream {
1196 BufferCollectionEventStream { event_receiver: self.client.take_event_receiver() }
1197 }
1198
1199 /// Ensure that previous messages, including Duplicate() messages on a
1200 /// token, collection, or group, have been received server side.
1201 ///
1202 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
1203 /// valid sysmem token risks the Sync() hanging forever. See
1204 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
1205 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
1206 /// Another way is to pass the token to BindSharedCollection(), which also
1207 /// validates the token as part of exchanging it for a BufferCollection
1208 /// channel, and BufferCollection Sync() can then be used.
1209 ///
1210 /// After a Sync(), it's then safe to send the client end of token_request
1211 /// to another participant knowing the server will recognize the token when
1212 /// it's sent into BindSharedCollection() by the other participant.
1213 ///
1214 /// Other options include waiting for each token.Duplicate() to complete
1215 /// individually (using separate call to token.Sync() after each), or
1216 /// calling Sync() on BufferCollection after the token has been turned in
1217 /// via BindSharedCollection().
1218 ///
1219 /// Another way to mitigate is to avoid calling Sync() on the token, and
1220 /// instead later deal with potential failure of BufferCollection.Sync() if
1221 /// the original token was invalid. This option can be preferable from a
1222 /// performance point of view, but requires client code to delay sending
1223 /// tokens duplicated from this token until after client code has converted
1224 /// the duplicating token to a BufferCollection and received successful
1225 /// response from BufferCollection.Sync().
1226 ///
1227 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
1228 /// When BufferCollection.Sync() isn't feasible, the caller must already
1229 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
1230 /// hang forever. See ValidateBufferCollectionToken() to check token
1231 /// validity first if the token isn't already known to be (is/was) valid.
1232 pub fn r#sync(
1233 &self,
1234 ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1235 BufferCollectionProxyInterface::r#sync(self)
1236 }
1237
1238 /// On a BufferCollectionToken channel:
1239 ///
1240 /// Normally a participant will convert a BufferCollectionToken into a
1241 /// BufferCollection view, but a participant is also free to Close() the
1242 /// token (and then close the channel immediately or shortly later in
1243 /// response to server closing its end), which avoids causing logical buffer
1244 /// collection failure. Â Normally an unexpected token channel close will
1245 /// cause logical buffer collection failure (the only exceptions being
1246 /// certain cases involving AttachToken() or SetDispensable()).
1247 ///
1248 /// On a BufferCollection channel:
1249 ///
1250 /// By default the server handles unexpected failure of a BufferCollection
1251 /// by failing the whole logical buffer collection. Partly this is to
1252 /// expedite closing VMO handles to reclaim memory when any participant
1253 /// fails. If a participant would like to cleanly close a BufferCollection
1254 /// view without causing logical buffer collection failure, the participant
1255 /// can send Close() before closing the client end of the BufferCollection
1256 /// channel. If this is the last BufferCollection view, the logical buffer
1257 /// collection will still go away. The Close() can occur before or after
1258 /// SetConstraints(). If before SetConstraints(), the buffer collection
1259 /// won't require constraints from this node in order to allocate. If
1260 /// after SetConstraints(), the constraints are retained and aggregated
1261 /// along with any subsequent logical allocation(s), despite the lack of
1262 /// channel connection.
1263 ///
1264 /// On a BufferCollectionTokenGroup channel:
1265 ///
1266 /// By default, unexpected failure of a BufferCollectionTokenGroup will
1267 /// trigger failure of the logical BufferCollectionTokenGroup and will
1268 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
1269 /// channel without failing the logical group or propagating failure, send
1270 /// Close() before closing the channel client endpoint.
1271 ///
1272 /// If Close() occurs before AllChildrenPresent(), the logical buffer
1273 /// collection will still fail despite the Close() (because sysmem can't be
1274 /// sure whether all relevant children were created, so it's ambiguous
1275 /// whether all relevant constraints will be provided to sysmem). If
1276 /// Close() occurs after AllChildrenPresent(), the children and all their
1277 /// constraints remain intact (just as they would if the
1278 /// BufferCollectionTokenGroup channel had remained open), and the close
1279 /// doesn't trigger or propagate failure.
1280 pub fn r#close(&self) -> Result<(), fidl::Error> {
1281 BufferCollectionProxyInterface::r#close(self)
1282 }
1283
1284 /// Set a name for VMOs in this buffer collection. The name may be truncated
1285 /// shorter. The name only affects VMOs allocated after it's set - this call
1286 /// does not rename existing VMOs. If multiple clients set different names
1287 /// then the larger priority value will win.
1288 pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1289 BufferCollectionProxyInterface::r#set_name(self, priority, name)
1290 }
1291
1292 /// Set information about the current client that can be used by sysmem to
1293 /// help debug leaking memory and hangs waiting for constraints. |name| can
1294 /// be an arbitrary string, but the current process name (see
1295 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
1296 /// arbitrary id, but the current process ID (see
1297 /// fsl::GetCurrentProcessKoid()) is a good default.
1298 ///
1299 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
1300 /// indicate which client is closing their channel first, leading to
1301 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
1302 /// over, but if happening earlier than expected, the
1303 /// client-channel-specific name can help diagnose where the failure is
1304 /// first coming from, from sysmem's point of view).
1305 ///
1306 /// By default (unless overriden by this message or using
1307 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
1308 /// parent Node at the time the child Node is created. While this can be
1309 /// better than nothing, it's often better for each participant to use
1310 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
1311 /// info directly relevant to the current client. Also, SetVerboseLogging()
1312 /// can be used to help disambiguate if a Node is suspected of having info
1313 /// that was copied from its parent.
1314 pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1315 BufferCollectionProxyInterface::r#set_debug_client_info(self, name, id)
1316 }
1317
1318 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
1319 /// after creating a collection. Clients can call this method to change
1320 /// when the log is printed. If multiple client set the deadline, it's
1321 /// unspecified which deadline will take effect.
1322 pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1323 BufferCollectionProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
1324 }
1325
1326 /// Verbose logging includes constraints set via SetConstraints() from each
1327 /// client along with info set via SetDebugClientInfo() and the structure of
1328 /// the tree of Node(s).
1329 ///
1330 /// Normally sysmem prints only a single line complaint when aggregation
1331 /// fails, with just the specific detailed reason that aggregation failed,
1332 /// with minimal context. While this is often enough to diagnose a problem
1333 /// if only a small change was made and the system had been working before
1334 /// the small change, it's often not particularly helpful for getting a new
1335 /// buffer collection to work for the first time. Especially with more
1336 /// complex trees of nodes, involving things like AttachToken(),
1337 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
1338 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
1339 /// looks like and why it's failing a logical allocation, or why a tree or
1340 /// sub-tree is failing sooner than expected.
1341 ///
1342 /// The intent of the extra logging is to be acceptable from a performance
1343 /// point of view, if only enabled on a low number of buffer collections.
1344 /// If we're not tracking down a bug, we shouldn't send this message.
1345 ///
1346 /// If too many participants leave verbose logging enabled, we may end up
1347 /// needing to require that system-wide sysmem verbose logging be permitted
1348 /// via some other setting, to avoid sysmem spamming the log too much due to
1349 /// this message.
1350 ///
1351 /// This may be a NOP for some nodes due to intentional policy associated
1352 /// with the node, if we don't trust a node enough to let it turn on verbose
1353 /// logging.
1354 pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1355 BufferCollectionProxyInterface::r#set_verbose_logging(self)
1356 }
1357
1358 /// This gets an event handle that can be used as a parameter to
1359 /// IsAlternateFor() called on any Node. The client will not be granted the
1360 /// right to signal this event, as this handle should only be used as proof
1361 /// that the client obtained this handle from this Node.
1362 ///
1363 /// Because this is a get not a set, no Sync() is needed between the
1364 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
1365 /// potentially being on different channels.
1366 ///
1367 /// See also IsAlternateFor().
1368 pub fn r#get_node_ref(
1369 &self,
1370 ) -> fidl::client::QueryResponseFut<
1371 fdomain_client::Event,
1372 fdomain_client::fidl::FDomainResourceDialect,
1373 > {
1374 BufferCollectionProxyInterface::r#get_node_ref(self)
1375 }
1376
1377 /// This checks whether the calling node is in a subtree rooted at a
1378 /// different child token of a common parent BufferCollectionTokenGroup, in
1379 /// relation to the passed-in node_ref.
1380 ///
1381 /// This call is for assisting with admission control de-duplication, and
1382 /// with debugging.
1383 ///
1384 /// The node_ref must be obtained using GetNodeRef() of a
1385 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
1386 ///
1387 /// The node_ref can be a duplicated handle; it's not necessary to call
1388 /// GetNodeRef() for every call to IsAlternateFor().
1389 ///
1390 /// If a calling token may not actually be a valid token at all due to
1391 /// a potentially hostile/untrusted provider of the token, call
1392 /// ValidateBufferCollectionToken() first instead of potentially getting
1393 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
1394 /// token not being a real token (not really talking to sysmem). Another
1395 /// option is to call BindSharedCollection with this token first which also
1396 /// validates the token along with converting it to a BufferCollection, then
1397 /// call BufferCollection IsAlternateFor().
1398 ///
1399 /// error values:
1400 ///
1401 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
1402 /// buffer collection as the calling Node. Before logical allocation and
1403 /// within the same logical allocation sub-tree, this essentially means that
1404 /// the node_ref was never part of this logical buffer collection, since
1405 /// before logical allocation all node_refs that come into existence remain
1406 /// in existence at least until logical allocation (including Node(s) that
1407 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
1408 /// to be returned, this Node's channel needs to still be connected server
1409 /// side, which won't be the case if the whole logical allocation has
1410 /// failed. After logical allocation or in a different logical allocation
1411 /// sub-tree there are additional potential reasons for this error. For
1412 /// example a different logical allocation (separated from this Node(s)
1413 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
1414 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
1415 /// exist and may select a different child sub-tree than the sub-tree the
1416 /// node_ref is in causing deletion of the node_ref Node. The only time
1417 /// sysmem keeps a Node around after that Node has no corresponding channel
1418 /// is when Close() is used and the Node's sub-tree has not yet failed.
1419 /// Another reason for this error is if the node_ref is an eventpair handle
1420 /// with sufficient rights, but isn't actually a real node_ref obtained from
1421 /// GetNodeRef().
1422 ///
1423 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
1424 /// eventpair handle, or doesn't have the needed rights expected on a real
1425 /// node_ref.
1426 ///
1427 /// No other failing status codes are returned by this call. However,
1428 /// sysmem may add additional codes in future, so the client should have
1429 /// sensible default handling for any failing status code.
1430 ///
1431 /// On success, is_alternate has the following meaning:
1432 /// * true - The first parent node in common between the calling node and
1433 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
1434 /// the calling Node and the node_ref Node will _not_ have both their
1435 /// constraints apply - rather sysmem will choose one or the other of
1436 /// the constraints - never both. This is because only one child of
1437 /// a BufferCollectionTokenGroup is selected during logical allocation,
1438 /// with only that one child's sub-tree contributing to constraints
1439 /// aggregation.
1440 /// * false - The first parent node in common between the calling Node and
1441 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
1442 /// this means the first parent node in common is a
1443 /// BufferCollectionToken or BufferCollection (regardless of not
1444 /// Close()ed or Close()ed). This means that the calling Node and the
1445 /// node_ref Node _may_ have both their constraints apply during
1446 /// constraints aggregation of the logical allocation, if both Node(s)
1447 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
1448 /// In this case, there is no BufferCollectionTokenGroup that will
1449 /// directly prevent the two Node(s) from both being selected and their
1450 /// constraints both aggregated, but even when false, one or both
1451 /// Node(s) may still be eliminated from consideration if one or both
1452 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
1453 /// which selects a child sub-tree other than the sub-tree containing
1454 /// the calling Node or node_ref Node.
1455 pub fn r#is_alternate_for(
1456 &self,
1457 mut node_ref: fdomain_client::Event,
1458 ) -> fidl::client::QueryResponseFut<
1459 NodeIsAlternateForResult,
1460 fdomain_client::fidl::FDomainResourceDialect,
1461 > {
1462 BufferCollectionProxyInterface::r#is_alternate_for(self, node_ref)
1463 }
1464
1465 /// Provide BufferCollectionConstraints to the logical BufferCollection.
1466 ///
1467 /// A participant may only call SetConstraints() once.
1468 ///
1469 /// Sometimes the initiator is a participant only in the sense of wanting to
1470 /// keep an eye on success/failure to populate with buffers, and zx.Status
1471 /// on failure. In that case, `has_constraints` can be false, and
1472 /// `constraints` will be ignored.
1473 ///
1474 /// VMO handles will not be provided to the client that sends null
1475 /// constraints - that can be intentional for an initiator that doesn't need
1476 /// VMO handles. Not having VMO handles doesn't prevent the initator from
1477 /// adjusting which portion of a buffer is considered valid and similar, but
1478 /// the initiator can't hold a VMO handle open to prevent the logical
1479 /// BufferCollection from cleaning up if the logical BufferCollection needs
1480 /// to go away regardless of the initiator's degree of involvement for
1481 /// whatever reason.
1482 ///
1483 /// For population of buffers to be attempted, all holders of a
1484 /// BufferCollection client channel need to call SetConstraints() before
1485 /// sysmem will attempt to allocate buffers.
1486 ///
1487 /// `has_constraints` if false, the constraints are effectively null, and
1488 /// `constraints` are ignored. The sender of null constraints won't get any
1489 /// VMO handles in BufferCollectionInfo, but can still find out how many
1490 /// buffers were allocated and can still refer to buffers by their
1491 /// buffer_index.
1492 ///
1493 /// `constraints` are constraints on the buffer collection.
1494 pub fn r#set_constraints(
1495 &self,
1496 mut has_constraints: bool,
1497 mut constraints: &BufferCollectionConstraints,
1498 ) -> Result<(), fidl::Error> {
1499 BufferCollectionProxyInterface::r#set_constraints(self, has_constraints, constraints)
1500 }
1501
1502 /// This request completes when buffers have been allocated, responds with
1503 /// some failure detail if allocation has been attempted but failed.
1504 ///
1505 /// The following must occur before buffers will be allocated:
1506 /// * All BufferCollectionToken(s) of the logical BufferCollectionToken
1507 /// must be turned in via BindSharedCollection().
1508 /// * All BufferCollection(s) of the logical BufferCollection must have
1509 /// had SetConstraints() sent to them.
1510 ///
1511 /// Returns `ZX_OK` if successful.
1512 /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
1513 /// fulfilled due to resource exhaustion.
1514 /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
1515 /// obtain the buffers it requested.
1516 /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
1517 /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
1518 /// satisfied, perhaps due to hardware limitations.
1519 ///
1520 /// `buffer_collection_info` has the VMO handles and other related info.
1521 pub fn r#wait_for_buffers_allocated(
1522 &self,
1523 ) -> fidl::client::QueryResponseFut<
1524 (i32, BufferCollectionInfo2),
1525 fdomain_client::fidl::FDomainResourceDialect,
1526 > {
1527 BufferCollectionProxyInterface::r#wait_for_buffers_allocated(self)
1528 }
1529
1530 /// This returns the same result code as WaitForBuffersAllocated if the
1531 /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
1532 /// if WaitForBuffersAllocated would block.
1533 pub fn r#check_buffers_allocated(
1534 &self,
1535 ) -> fidl::client::QueryResponseFut<i32, fdomain_client::fidl::FDomainResourceDialect> {
1536 BufferCollectionProxyInterface::r#check_buffers_allocated(self)
1537 }
1538
1539 /// Create a new token, for trying to add a new participant to an existing
1540 /// collection, if the existing collection's buffer counts, constraints,
1541 /// and participants allow.
1542 ///
1543 /// This can be useful in replacing a failed participant, and/or in
1544 /// adding/re-adding a participant after buffers have already been
1545 /// allocated.
1546 ///
1547 /// Failure of an attached token / collection does not propagate to the
1548 /// parent of the attached token. Failure does propagate from a normal
1549 /// child of a dispensable token to the dispensable token. Failure
1550 /// of a child is blocked from reaching its parent if the child is attached,
1551 /// or if the child is dispensable and the failure occurred after logical
1552 /// allocation.
1553 ///
1554 /// An initiator may in some scenarios choose to initially use a dispensable
1555 /// token for a given instance of a participant, and then later if the first
1556 /// instance of that participant fails, a new second instance of that
1557 /// participant my be given a token created with AttachToken().
1558 ///
1559 /// From the point of view of the client end of the BufferCollectionToken
1560 /// channel, the token acts like any other token. The client can
1561 /// Duplicate() the token as needed, and can send the token to a different
1562 /// process. The token should be converted to a BufferCollection channel
1563 /// as normal by calling BindSharedCollection(). SetConstraints() should
1564 /// be called on that BufferCollection channel.
1565 ///
1566 /// A success result from WaitForBuffersAllocated() means the new
1567 /// participant's constraints were satisfiable using the already-existing
1568 /// buffer collection, the already-established BufferCollectionInfo
1569 /// including image format constraints, and the already-existing other
1570 /// participants and their buffer counts. A failure result means the new
1571 /// participant's constraints cannot be satisfied using the existing
1572 /// buffer collection and its already-logically-allocated participants.
1573 /// Creating a new collection instead may allow all participant's
1574 /// constraints to be satisfied, assuming SetDispensable() is used in place
1575 /// of AttachToken(), or a normal token is used.
1576 ///
1577 /// A token created with AttachToken() performs constraints aggregation with
1578 /// all constraints currently in effect on the buffer collection, plus the
1579 /// attached token under consideration plus child tokens under the attached
1580 /// token which are not themselves an attached token or under such a token.
1581 ///
1582 /// Allocation of buffer_count to min_buffer_count_for_camping etc is
1583 /// first-come first-served, but a child can't logically allocate before
1584 /// all its parents have sent SetConstraints().
1585 ///
1586 /// See also SetDispensable(), which in contrast to AttachToken(), has the
1587 /// created token + children participate in constraints aggregation along
1588 /// with its parent.
1589 ///
1590 /// The newly created token needs to be Sync()ed to sysmem before the new
1591 /// token can be passed to BindSharedCollection(). The Sync() of the new
1592 /// token can be accomplished with BufferCollection.Sync() on this
1593 /// BufferCollection. Alternately BufferCollectionToken.Sync() on the new
1594 /// token also works. A BufferCollectionToken.Sync() can be started after
1595 /// any BufferCollectionToken.Duplicate() messages have been sent via the
1596 /// newly created token, to also sync those additional tokens to sysmem
1597 /// using a single round-trip.
1598 ///
1599 /// These values for rights_attenuation_mask result in no attenuation (note
1600 /// that 0 is not on this list; 0 will output an ERROR to the system log
1601 /// to help diagnose the bug in client code):
1602 /// * ZX_RIGHT_SAME_RIGHTS (preferred)
1603 /// * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
1604 pub fn r#attach_token(
1605 &self,
1606 mut rights_attenuation_mask: u32,
1607 mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
1608 ) -> Result<(), fidl::Error> {
1609 BufferCollectionProxyInterface::r#attach_token(self, rights_attenuation_mask, token_request)
1610 }
1611
1612 /// AttachLifetimeTracking:
1613 ///
1614 /// AttachLifetimeTracking() is intended to allow a client to wait until an
1615 /// old logical buffer collection is fully or mostly deallocated before
1616 /// attempting allocation of a new logical buffer collection.
1617 ///
1618 /// Attach an eventpair endpoint to the logical buffer collection, so that
1619 /// the server_end will be closed when the number of buffers allocated
1620 /// drops to 'buffers_remaining'. The server_end won't close until after
1621 /// logical allocation has completed.
1622 ///
1623 /// If logical allocation fails, such as for an attached sub-tree (using
1624 /// AttachToken()), the server_end will close during that failure regardless
1625 /// of the number of buffers potenitally allocated in the overall logical
1626 /// buffer collection.
1627 ///
1628 /// The lifetime signalled by this event includes asynchronous cleanup of
1629 /// allocated buffers, and this asynchronous cleanup cannot occur until all
1630 /// holders of VMO handles to the buffers have closed those VMO handles.
1631 /// Therefore clients should take care not to become blocked forever waiting
1632 /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
1633 /// participants using the logical buffer collection are less trusted or
1634 /// less reliable.
1635 ///
1636 /// The buffers_remaining parameter allows waiting for all but
1637 /// buffers_remaining buffers to be fully deallocated. This can be useful
1638 /// in situations where a known number of buffers are intentionally not
1639 /// closed so that the data can continue to be used, such as for keeping the
1640 /// last available video picture displayed in the UI even if the video
1641 /// stream was using protected output buffers. It's outside the scope of
1642 /// the BufferCollection interface (at least for now) to determine how many
1643 /// buffers may be held without closing, but it'll typically be in the range
1644 /// 0-2.
1645 ///
1646 /// This mechanism is meant to be compatible with other protocols providing
1647 /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
1648 /// same event can be sent to more than one AttachLifetimeTracking(), and
1649 /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
1650 /// over conditions are met (all holders of duplicates have closed their
1651 /// handle(s)).
1652 ///
1653 /// There is no way to cancel an attach. Closing the client end of the
1654 /// eventpair doesn't subtract from the number of pending attach(es).
1655 ///
1656 /// Closing the client's end doesn't result in any action by the server.
1657 /// If the server listens to events from the client end at all, it is for
1658 /// debug logging only.
1659 ///
1660 /// The server intentionally doesn't "trust" any bits signalled by the
1661 /// client. This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
1662 /// which can't be triggered early, and is only triggered when all handles
1663 /// to server_end are closed. No meaning is associated with any of the
1664 /// other signal bits, and clients should functionally ignore any other
1665 /// signal bits on either end of the eventpair or its peer.
1666 ///
1667 /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
1668 /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
1669 /// transfer without causing CodecFactory channel failure).
1670 pub fn r#attach_lifetime_tracking(
1671 &self,
1672 mut server_end: fdomain_client::EventPair,
1673 mut buffers_remaining: u32,
1674 ) -> Result<(), fidl::Error> {
1675 BufferCollectionProxyInterface::r#attach_lifetime_tracking(
1676 self,
1677 server_end,
1678 buffers_remaining,
1679 )
1680 }
1681}
1682
1683impl BufferCollectionProxyInterface for BufferCollectionProxy {
1684 type SyncResponseFut =
1685 fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
1686 fn r#sync(&self) -> Self::SyncResponseFut {
1687 fn _decode(
1688 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1689 ) -> Result<(), fidl::Error> {
1690 let _response = fidl::client::decode_transaction_body::<
1691 fidl::encoding::EmptyPayload,
1692 fdomain_client::fidl::FDomainResourceDialect,
1693 0x4577e238ae26291,
1694 >(_buf?)?;
1695 Ok(_response)
1696 }
1697 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1698 (),
1699 0x4577e238ae26291,
1700 fidl::encoding::DynamicFlags::empty(),
1701 _decode,
1702 )
1703 }
1704
1705 fn r#close(&self) -> Result<(), fidl::Error> {
1706 self.client.send::<fidl::encoding::EmptyPayload>(
1707 (),
1708 0x5b1d7a4f5681fca7,
1709 fidl::encoding::DynamicFlags::empty(),
1710 )
1711 }
1712
1713 fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
1714 self.client.send::<NodeSetNameRequest>(
1715 (priority, name),
1716 0x77a41bb6217e2443,
1717 fidl::encoding::DynamicFlags::empty(),
1718 )
1719 }
1720
1721 fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
1722 self.client.send::<NodeSetDebugClientInfoRequest>(
1723 (name, id),
1724 0x7275759070eb5ee2,
1725 fidl::encoding::DynamicFlags::empty(),
1726 )
1727 }
1728
1729 fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
1730 self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
1731 (deadline,),
1732 0x46d38f4772638867,
1733 fidl::encoding::DynamicFlags::empty(),
1734 )
1735 }
1736
1737 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
1738 self.client.send::<fidl::encoding::EmptyPayload>(
1739 (),
1740 0x6bfbe2cf1701d288,
1741 fidl::encoding::DynamicFlags::empty(),
1742 )
1743 }
1744
1745 type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
1746 fdomain_client::Event,
1747 fdomain_client::fidl::FDomainResourceDialect,
1748 >;
1749 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
1750 fn _decode(
1751 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1752 ) -> Result<fdomain_client::Event, fidl::Error> {
1753 let _response = fidl::client::decode_transaction_body::<
1754 NodeGetNodeRefResponse,
1755 fdomain_client::fidl::FDomainResourceDialect,
1756 0x467b7c75c35c3b84,
1757 >(_buf?)?;
1758 Ok(_response.node_ref)
1759 }
1760 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
1761 (),
1762 0x467b7c75c35c3b84,
1763 fidl::encoding::DynamicFlags::empty(),
1764 _decode,
1765 )
1766 }
1767
1768 type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
1769 NodeIsAlternateForResult,
1770 fdomain_client::fidl::FDomainResourceDialect,
1771 >;
1772 fn r#is_alternate_for(
1773 &self,
1774 mut node_ref: fdomain_client::Event,
1775 ) -> Self::IsAlternateForResponseFut {
1776 fn _decode(
1777 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1778 ) -> Result<NodeIsAlternateForResult, fidl::Error> {
1779 let _response = fidl::client::decode_transaction_body::<
1780 fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
1781 fdomain_client::fidl::FDomainResourceDialect,
1782 0x33a2a7aff2776c07,
1783 >(_buf?)?;
1784 Ok(_response.map(|x| x.is_alternate))
1785 }
1786 self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
1787 (node_ref,),
1788 0x33a2a7aff2776c07,
1789 fidl::encoding::DynamicFlags::empty(),
1790 _decode,
1791 )
1792 }
1793
1794 fn r#set_constraints(
1795 &self,
1796 mut has_constraints: bool,
1797 mut constraints: &BufferCollectionConstraints,
1798 ) -> Result<(), fidl::Error> {
1799 self.client.send::<BufferCollectionSetConstraintsRequest>(
1800 (has_constraints, constraints),
1801 0x4d9c3406c213227b,
1802 fidl::encoding::DynamicFlags::empty(),
1803 )
1804 }
1805
1806 type WaitForBuffersAllocatedResponseFut = fidl::client::QueryResponseFut<
1807 (i32, BufferCollectionInfo2),
1808 fdomain_client::fidl::FDomainResourceDialect,
1809 >;
1810 fn r#wait_for_buffers_allocated(&self) -> Self::WaitForBuffersAllocatedResponseFut {
1811 fn _decode(
1812 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1813 ) -> Result<(i32, BufferCollectionInfo2), fidl::Error> {
1814 let _response = fidl::client::decode_transaction_body::<
1815 BufferCollectionWaitForBuffersAllocatedResponse,
1816 fdomain_client::fidl::FDomainResourceDialect,
1817 0x714667ea2a29a3a2,
1818 >(_buf?)?;
1819 Ok((_response.status, _response.buffer_collection_info))
1820 }
1821 self.client
1822 .send_query_and_decode::<fidl::encoding::EmptyPayload, (i32, BufferCollectionInfo2)>(
1823 (),
1824 0x714667ea2a29a3a2,
1825 fidl::encoding::DynamicFlags::empty(),
1826 _decode,
1827 )
1828 }
1829
1830 type CheckBuffersAllocatedResponseFut =
1831 fidl::client::QueryResponseFut<i32, fdomain_client::fidl::FDomainResourceDialect>;
1832 fn r#check_buffers_allocated(&self) -> Self::CheckBuffersAllocatedResponseFut {
1833 fn _decode(
1834 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1835 ) -> Result<i32, fidl::Error> {
1836 let _response = fidl::client::decode_transaction_body::<
1837 BufferCollectionCheckBuffersAllocatedResponse,
1838 fdomain_client::fidl::FDomainResourceDialect,
1839 0x245bb81f79189e9,
1840 >(_buf?)?;
1841 Ok(_response.status)
1842 }
1843 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i32>(
1844 (),
1845 0x245bb81f79189e9,
1846 fidl::encoding::DynamicFlags::empty(),
1847 _decode,
1848 )
1849 }
1850
1851 fn r#attach_token(
1852 &self,
1853 mut rights_attenuation_mask: u32,
1854 mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
1855 ) -> Result<(), fidl::Error> {
1856 self.client.send::<BufferCollectionAttachTokenRequest>(
1857 (rights_attenuation_mask, token_request),
1858 0x6f5adcca4ac7443e,
1859 fidl::encoding::DynamicFlags::empty(),
1860 )
1861 }
1862
1863 fn r#attach_lifetime_tracking(
1864 &self,
1865 mut server_end: fdomain_client::EventPair,
1866 mut buffers_remaining: u32,
1867 ) -> Result<(), fidl::Error> {
1868 self.client.send::<BufferCollectionAttachLifetimeTrackingRequest>(
1869 (server_end, buffers_remaining),
1870 0x170d0f1d89d50989,
1871 fidl::encoding::DynamicFlags::empty(),
1872 )
1873 }
1874}
1875
1876pub struct BufferCollectionEventStream {
1877 event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1878}
1879
1880impl std::marker::Unpin for BufferCollectionEventStream {}
1881
1882impl futures::stream::FusedStream for BufferCollectionEventStream {
1883 fn is_terminated(&self) -> bool {
1884 self.event_receiver.is_terminated()
1885 }
1886}
1887
1888impl futures::Stream for BufferCollectionEventStream {
1889 type Item = Result<BufferCollectionEvent, fidl::Error>;
1890
1891 fn poll_next(
1892 mut self: std::pin::Pin<&mut Self>,
1893 cx: &mut std::task::Context<'_>,
1894 ) -> std::task::Poll<Option<Self::Item>> {
1895 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1896 &mut self.event_receiver,
1897 cx
1898 )?) {
1899 Some(buf) => std::task::Poll::Ready(Some(BufferCollectionEvent::decode(buf))),
1900 None => std::task::Poll::Ready(None),
1901 }
1902 }
1903}
1904
1905#[derive(Debug)]
1906pub enum BufferCollectionEvent {}
1907
1908impl BufferCollectionEvent {
1909 /// Decodes a message buffer as a [`BufferCollectionEvent`].
1910 fn decode(
1911 mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1912 ) -> Result<BufferCollectionEvent, fidl::Error> {
1913 let (bytes, _handles) = buf.split_mut();
1914 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1915 debug_assert_eq!(tx_header.tx_id, 0);
1916 match tx_header.ordinal {
1917 _ => Err(fidl::Error::UnknownOrdinal {
1918 ordinal: tx_header.ordinal,
1919 protocol_name:
1920 <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1921 }),
1922 }
1923 }
1924}
1925
1926/// A Stream of incoming requests for fuchsia.sysmem/BufferCollection.
1927pub struct BufferCollectionRequestStream {
1928 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1929 is_terminated: bool,
1930}
1931
1932impl std::marker::Unpin for BufferCollectionRequestStream {}
1933
1934impl futures::stream::FusedStream for BufferCollectionRequestStream {
1935 fn is_terminated(&self) -> bool {
1936 self.is_terminated
1937 }
1938}
1939
1940impl fdomain_client::fidl::RequestStream for BufferCollectionRequestStream {
1941 type Protocol = BufferCollectionMarker;
1942 type ControlHandle = BufferCollectionControlHandle;
1943
1944 fn from_channel(channel: fdomain_client::Channel) -> Self {
1945 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1946 }
1947
1948 fn control_handle(&self) -> Self::ControlHandle {
1949 BufferCollectionControlHandle { inner: self.inner.clone() }
1950 }
1951
1952 fn into_inner(
1953 self,
1954 ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1955 {
1956 (self.inner, self.is_terminated)
1957 }
1958
1959 fn from_inner(
1960 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1961 is_terminated: bool,
1962 ) -> Self {
1963 Self { inner, is_terminated }
1964 }
1965}
1966
1967impl futures::Stream for BufferCollectionRequestStream {
1968 type Item = Result<BufferCollectionRequest, fidl::Error>;
1969
1970 fn poll_next(
1971 mut self: std::pin::Pin<&mut Self>,
1972 cx: &mut std::task::Context<'_>,
1973 ) -> std::task::Poll<Option<Self::Item>> {
1974 let this = &mut *self;
1975 if this.inner.check_shutdown(cx) {
1976 this.is_terminated = true;
1977 return std::task::Poll::Ready(None);
1978 }
1979 if this.is_terminated {
1980 panic!("polled BufferCollectionRequestStream after completion");
1981 }
1982 fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1983 |bytes, handles| {
1984 match this.inner.channel().read_etc(cx, bytes, handles) {
1985 std::task::Poll::Ready(Ok(())) => {}
1986 std::task::Poll::Pending => return std::task::Poll::Pending,
1987 std::task::Poll::Ready(Err(None)) => {
1988 this.is_terminated = true;
1989 return std::task::Poll::Ready(None);
1990 }
1991 std::task::Poll::Ready(Err(Some(e))) => {
1992 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1993 e.into(),
1994 ))));
1995 }
1996 }
1997
1998 // A message has been received from the channel
1999 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2000
2001 std::task::Poll::Ready(Some(match header.ordinal {
2002 0x4577e238ae26291 => {
2003 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2004 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2005 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2006 let control_handle = BufferCollectionControlHandle {
2007 inner: this.inner.clone(),
2008 };
2009 Ok(BufferCollectionRequest::Sync {
2010 responder: BufferCollectionSyncResponder {
2011 control_handle: std::mem::ManuallyDrop::new(control_handle),
2012 tx_id: header.tx_id,
2013 },
2014 })
2015 }
2016 0x5b1d7a4f5681fca7 => {
2017 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2018 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2019 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2020 let control_handle = BufferCollectionControlHandle {
2021 inner: this.inner.clone(),
2022 };
2023 Ok(BufferCollectionRequest::Close {
2024 control_handle,
2025 })
2026 }
2027 0x77a41bb6217e2443 => {
2028 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2029 let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
2030 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
2031 let control_handle = BufferCollectionControlHandle {
2032 inner: this.inner.clone(),
2033 };
2034 Ok(BufferCollectionRequest::SetName {priority: req.priority,
2035name: req.name,
2036
2037 control_handle,
2038 })
2039 }
2040 0x7275759070eb5ee2 => {
2041 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2042 let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
2043 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
2044 let control_handle = BufferCollectionControlHandle {
2045 inner: this.inner.clone(),
2046 };
2047 Ok(BufferCollectionRequest::SetDebugClientInfo {name: req.name,
2048id: req.id,
2049
2050 control_handle,
2051 })
2052 }
2053 0x46d38f4772638867 => {
2054 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2055 let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
2056 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
2057 let control_handle = BufferCollectionControlHandle {
2058 inner: this.inner.clone(),
2059 };
2060 Ok(BufferCollectionRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
2061
2062 control_handle,
2063 })
2064 }
2065 0x6bfbe2cf1701d288 => {
2066 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2067 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2068 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2069 let control_handle = BufferCollectionControlHandle {
2070 inner: this.inner.clone(),
2071 };
2072 Ok(BufferCollectionRequest::SetVerboseLogging {
2073 control_handle,
2074 })
2075 }
2076 0x467b7c75c35c3b84 => {
2077 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2078 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2079 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2080 let control_handle = BufferCollectionControlHandle {
2081 inner: this.inner.clone(),
2082 };
2083 Ok(BufferCollectionRequest::GetNodeRef {
2084 responder: BufferCollectionGetNodeRefResponder {
2085 control_handle: std::mem::ManuallyDrop::new(control_handle),
2086 tx_id: header.tx_id,
2087 },
2088 })
2089 }
2090 0x33a2a7aff2776c07 => {
2091 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2092 let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
2093 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
2094 let control_handle = BufferCollectionControlHandle {
2095 inner: this.inner.clone(),
2096 };
2097 Ok(BufferCollectionRequest::IsAlternateFor {node_ref: req.node_ref,
2098
2099 responder: BufferCollectionIsAlternateForResponder {
2100 control_handle: std::mem::ManuallyDrop::new(control_handle),
2101 tx_id: header.tx_id,
2102 },
2103 })
2104 }
2105 0x4d9c3406c213227b => {
2106 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2107 let mut req = fidl::new_empty!(BufferCollectionSetConstraintsRequest, fdomain_client::fidl::FDomainResourceDialect);
2108 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionSetConstraintsRequest>(&header, _body_bytes, handles, &mut req)?;
2109 let control_handle = BufferCollectionControlHandle {
2110 inner: this.inner.clone(),
2111 };
2112 Ok(BufferCollectionRequest::SetConstraints {has_constraints: req.has_constraints,
2113constraints: req.constraints,
2114
2115 control_handle,
2116 })
2117 }
2118 0x714667ea2a29a3a2 => {
2119 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2120 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2121 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2122 let control_handle = BufferCollectionControlHandle {
2123 inner: this.inner.clone(),
2124 };
2125 Ok(BufferCollectionRequest::WaitForBuffersAllocated {
2126 responder: BufferCollectionWaitForBuffersAllocatedResponder {
2127 control_handle: std::mem::ManuallyDrop::new(control_handle),
2128 tx_id: header.tx_id,
2129 },
2130 })
2131 }
2132 0x245bb81f79189e9 => {
2133 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2134 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2135 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2136 let control_handle = BufferCollectionControlHandle {
2137 inner: this.inner.clone(),
2138 };
2139 Ok(BufferCollectionRequest::CheckBuffersAllocated {
2140 responder: BufferCollectionCheckBuffersAllocatedResponder {
2141 control_handle: std::mem::ManuallyDrop::new(control_handle),
2142 tx_id: header.tx_id,
2143 },
2144 })
2145 }
2146 0x6f5adcca4ac7443e => {
2147 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2148 let mut req = fidl::new_empty!(BufferCollectionAttachTokenRequest, fdomain_client::fidl::FDomainResourceDialect);
2149 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachTokenRequest>(&header, _body_bytes, handles, &mut req)?;
2150 let control_handle = BufferCollectionControlHandle {
2151 inner: this.inner.clone(),
2152 };
2153 Ok(BufferCollectionRequest::AttachToken {rights_attenuation_mask: req.rights_attenuation_mask,
2154token_request: req.token_request,
2155
2156 control_handle,
2157 })
2158 }
2159 0x170d0f1d89d50989 => {
2160 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2161 let mut req = fidl::new_empty!(BufferCollectionAttachLifetimeTrackingRequest, fdomain_client::fidl::FDomainResourceDialect);
2162 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionAttachLifetimeTrackingRequest>(&header, _body_bytes, handles, &mut req)?;
2163 let control_handle = BufferCollectionControlHandle {
2164 inner: this.inner.clone(),
2165 };
2166 Ok(BufferCollectionRequest::AttachLifetimeTracking {server_end: req.server_end,
2167buffers_remaining: req.buffers_remaining,
2168
2169 control_handle,
2170 })
2171 }
2172 _ => Err(fidl::Error::UnknownOrdinal {
2173 ordinal: header.ordinal,
2174 protocol_name: <BufferCollectionMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2175 }),
2176 }))
2177 },
2178 )
2179 }
2180}
2181
2182/// BufferCollection is a connection directly from a participant to sysmem re.
2183/// a logical BufferCollection; typically the logical BufferCollection is shared
2184/// with other participants. In other words, an instance of the BufferCollection
2185/// interface is a view of a "logical buffer collection".
2186///
2187/// This connection exists to facilitate async indication of when the logical
2188/// BufferCollection has been populated with buffers.
2189///
2190/// Also, the channel's closure by the server is an indication to the client
2191/// that the client should close all VMO handles that were obtained from the
2192/// BufferCollection ASAP.
2193///
2194/// Also, this interface may in future allow specifying constraints in other
2195/// ways, and may allow for back-and-forth negotiation of constraints to some
2196/// degree.
2197///
2198/// This interface may in future allow for more than 64 VMO handles per
2199/// BufferCollection, but currently the limit is 64.
2200///
2201/// This interface may in future allow for allocating/deallocating single
2202/// buffers.
2203///
2204/// Some initiators may wait a short duration until all old logical
2205/// BufferCollection VMO handles have closed (or until the short duration times
2206/// out) before allocating a new BufferCollection, to help control physical
2207/// memory fragmentation and avoid overlap of buffer allocation lifetimes for
2208/// the old and new collections. Collections can be large enough that it's worth
2209/// avoiding allocation overlap (in time).
2210#[derive(Debug)]
2211pub enum BufferCollectionRequest {
2212 /// Ensure that previous messages, including Duplicate() messages on a
2213 /// token, collection, or group, have been received server side.
2214 ///
2215 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
2216 /// valid sysmem token risks the Sync() hanging forever. See
2217 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
2218 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
2219 /// Another way is to pass the token to BindSharedCollection(), which also
2220 /// validates the token as part of exchanging it for a BufferCollection
2221 /// channel, and BufferCollection Sync() can then be used.
2222 ///
2223 /// After a Sync(), it's then safe to send the client end of token_request
2224 /// to another participant knowing the server will recognize the token when
2225 /// it's sent into BindSharedCollection() by the other participant.
2226 ///
2227 /// Other options include waiting for each token.Duplicate() to complete
2228 /// individually (using separate call to token.Sync() after each), or
2229 /// calling Sync() on BufferCollection after the token has been turned in
2230 /// via BindSharedCollection().
2231 ///
2232 /// Another way to mitigate is to avoid calling Sync() on the token, and
2233 /// instead later deal with potential failure of BufferCollection.Sync() if
2234 /// the original token was invalid. This option can be preferable from a
2235 /// performance point of view, but requires client code to delay sending
2236 /// tokens duplicated from this token until after client code has converted
2237 /// the duplicating token to a BufferCollection and received successful
2238 /// response from BufferCollection.Sync().
2239 ///
2240 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
2241 /// When BufferCollection.Sync() isn't feasible, the caller must already
2242 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
2243 /// hang forever. See ValidateBufferCollectionToken() to check token
2244 /// validity first if the token isn't already known to be (is/was) valid.
2245 Sync { responder: BufferCollectionSyncResponder },
2246 /// On a BufferCollectionToken channel:
2247 ///
2248 /// Normally a participant will convert a BufferCollectionToken into a
2249 /// BufferCollection view, but a participant is also free to Close() the
2250 /// token (and then close the channel immediately or shortly later in
2251 /// response to server closing its end), which avoids causing logical buffer
2252 /// collection failure. Â Normally an unexpected token channel close will
2253 /// cause logical buffer collection failure (the only exceptions being
2254 /// certain cases involving AttachToken() or SetDispensable()).
2255 ///
2256 /// On a BufferCollection channel:
2257 ///
2258 /// By default the server handles unexpected failure of a BufferCollection
2259 /// by failing the whole logical buffer collection. Partly this is to
2260 /// expedite closing VMO handles to reclaim memory when any participant
2261 /// fails. If a participant would like to cleanly close a BufferCollection
2262 /// view without causing logical buffer collection failure, the participant
2263 /// can send Close() before closing the client end of the BufferCollection
2264 /// channel. If this is the last BufferCollection view, the logical buffer
2265 /// collection will still go away. The Close() can occur before or after
2266 /// SetConstraints(). If before SetConstraints(), the buffer collection
2267 /// won't require constraints from this node in order to allocate. If
2268 /// after SetConstraints(), the constraints are retained and aggregated
2269 /// along with any subsequent logical allocation(s), despite the lack of
2270 /// channel connection.
2271 ///
2272 /// On a BufferCollectionTokenGroup channel:
2273 ///
2274 /// By default, unexpected failure of a BufferCollectionTokenGroup will
2275 /// trigger failure of the logical BufferCollectionTokenGroup and will
2276 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
2277 /// channel without failing the logical group or propagating failure, send
2278 /// Close() before closing the channel client endpoint.
2279 ///
2280 /// If Close() occurs before AllChildrenPresent(), the logical buffer
2281 /// collection will still fail despite the Close() (because sysmem can't be
2282 /// sure whether all relevant children were created, so it's ambiguous
2283 /// whether all relevant constraints will be provided to sysmem). If
2284 /// Close() occurs after AllChildrenPresent(), the children and all their
2285 /// constraints remain intact (just as they would if the
2286 /// BufferCollectionTokenGroup channel had remained open), and the close
2287 /// doesn't trigger or propagate failure.
2288 Close { control_handle: BufferCollectionControlHandle },
2289 /// Set a name for VMOs in this buffer collection. The name may be truncated
2290 /// shorter. The name only affects VMOs allocated after it's set - this call
2291 /// does not rename existing VMOs. If multiple clients set different names
2292 /// then the larger priority value will win.
2293 SetName { priority: u32, name: String, control_handle: BufferCollectionControlHandle },
2294 /// Set information about the current client that can be used by sysmem to
2295 /// help debug leaking memory and hangs waiting for constraints. |name| can
2296 /// be an arbitrary string, but the current process name (see
2297 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
2298 /// arbitrary id, but the current process ID (see
2299 /// fsl::GetCurrentProcessKoid()) is a good default.
2300 ///
2301 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
2302 /// indicate which client is closing their channel first, leading to
2303 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
2304 /// over, but if happening earlier than expected, the
2305 /// client-channel-specific name can help diagnose where the failure is
2306 /// first coming from, from sysmem's point of view).
2307 ///
2308 /// By default (unless overriden by this message or using
2309 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
2310 /// parent Node at the time the child Node is created. While this can be
2311 /// better than nothing, it's often better for each participant to use
2312 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
2313 /// info directly relevant to the current client. Also, SetVerboseLogging()
2314 /// can be used to help disambiguate if a Node is suspected of having info
2315 /// that was copied from its parent.
2316 SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionControlHandle },
2317 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
2318 /// after creating a collection. Clients can call this method to change
2319 /// when the log is printed. If multiple client set the deadline, it's
2320 /// unspecified which deadline will take effect.
2321 SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionControlHandle },
2322 /// Verbose logging includes constraints set via SetConstraints() from each
2323 /// client along with info set via SetDebugClientInfo() and the structure of
2324 /// the tree of Node(s).
2325 ///
2326 /// Normally sysmem prints only a single line complaint when aggregation
2327 /// fails, with just the specific detailed reason that aggregation failed,
2328 /// with minimal context. While this is often enough to diagnose a problem
2329 /// if only a small change was made and the system had been working before
2330 /// the small change, it's often not particularly helpful for getting a new
2331 /// buffer collection to work for the first time. Especially with more
2332 /// complex trees of nodes, involving things like AttachToken(),
2333 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
2334 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
2335 /// looks like and why it's failing a logical allocation, or why a tree or
2336 /// sub-tree is failing sooner than expected.
2337 ///
2338 /// The intent of the extra logging is to be acceptable from a performance
2339 /// point of view, if only enabled on a low number of buffer collections.
2340 /// If we're not tracking down a bug, we shouldn't send this message.
2341 ///
2342 /// If too many participants leave verbose logging enabled, we may end up
2343 /// needing to require that system-wide sysmem verbose logging be permitted
2344 /// via some other setting, to avoid sysmem spamming the log too much due to
2345 /// this message.
2346 ///
2347 /// This may be a NOP for some nodes due to intentional policy associated
2348 /// with the node, if we don't trust a node enough to let it turn on verbose
2349 /// logging.
2350 SetVerboseLogging { control_handle: BufferCollectionControlHandle },
2351 /// This gets an event handle that can be used as a parameter to
2352 /// IsAlternateFor() called on any Node. The client will not be granted the
2353 /// right to signal this event, as this handle should only be used as proof
2354 /// that the client obtained this handle from this Node.
2355 ///
2356 /// Because this is a get not a set, no Sync() is needed between the
2357 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
2358 /// potentially being on different channels.
2359 ///
2360 /// See also IsAlternateFor().
2361 GetNodeRef { responder: BufferCollectionGetNodeRefResponder },
2362 /// This checks whether the calling node is in a subtree rooted at a
2363 /// different child token of a common parent BufferCollectionTokenGroup, in
2364 /// relation to the passed-in node_ref.
2365 ///
2366 /// This call is for assisting with admission control de-duplication, and
2367 /// with debugging.
2368 ///
2369 /// The node_ref must be obtained using GetNodeRef() of a
2370 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
2371 ///
2372 /// The node_ref can be a duplicated handle; it's not necessary to call
2373 /// GetNodeRef() for every call to IsAlternateFor().
2374 ///
2375 /// If a calling token may not actually be a valid token at all due to
2376 /// a potentially hostile/untrusted provider of the token, call
2377 /// ValidateBufferCollectionToken() first instead of potentially getting
2378 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
2379 /// token not being a real token (not really talking to sysmem). Another
2380 /// option is to call BindSharedCollection with this token first which also
2381 /// validates the token along with converting it to a BufferCollection, then
2382 /// call BufferCollection IsAlternateFor().
2383 ///
2384 /// error values:
2385 ///
2386 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
2387 /// buffer collection as the calling Node. Before logical allocation and
2388 /// within the same logical allocation sub-tree, this essentially means that
2389 /// the node_ref was never part of this logical buffer collection, since
2390 /// before logical allocation all node_refs that come into existence remain
2391 /// in existence at least until logical allocation (including Node(s) that
2392 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
2393 /// to be returned, this Node's channel needs to still be connected server
2394 /// side, which won't be the case if the whole logical allocation has
2395 /// failed. After logical allocation or in a different logical allocation
2396 /// sub-tree there are additional potential reasons for this error. For
2397 /// example a different logical allocation (separated from this Node(s)
2398 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
2399 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
2400 /// exist and may select a different child sub-tree than the sub-tree the
2401 /// node_ref is in causing deletion of the node_ref Node. The only time
2402 /// sysmem keeps a Node around after that Node has no corresponding channel
2403 /// is when Close() is used and the Node's sub-tree has not yet failed.
2404 /// Another reason for this error is if the node_ref is an eventpair handle
2405 /// with sufficient rights, but isn't actually a real node_ref obtained from
2406 /// GetNodeRef().
2407 ///
2408 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
2409 /// eventpair handle, or doesn't have the needed rights expected on a real
2410 /// node_ref.
2411 ///
2412 /// No other failing status codes are returned by this call. However,
2413 /// sysmem may add additional codes in future, so the client should have
2414 /// sensible default handling for any failing status code.
2415 ///
2416 /// On success, is_alternate has the following meaning:
2417 /// * true - The first parent node in common between the calling node and
2418 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
2419 /// the calling Node and the node_ref Node will _not_ have both their
2420 /// constraints apply - rather sysmem will choose one or the other of
2421 /// the constraints - never both. This is because only one child of
2422 /// a BufferCollectionTokenGroup is selected during logical allocation,
2423 /// with only that one child's sub-tree contributing to constraints
2424 /// aggregation.
2425 /// * false - The first parent node in common between the calling Node and
2426 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
2427 /// this means the first parent node in common is a
2428 /// BufferCollectionToken or BufferCollection (regardless of not
2429 /// Close()ed or Close()ed). This means that the calling Node and the
2430 /// node_ref Node _may_ have both their constraints apply during
2431 /// constraints aggregation of the logical allocation, if both Node(s)
2432 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
2433 /// In this case, there is no BufferCollectionTokenGroup that will
2434 /// directly prevent the two Node(s) from both being selected and their
2435 /// constraints both aggregated, but even when false, one or both
2436 /// Node(s) may still be eliminated from consideration if one or both
2437 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
2438 /// which selects a child sub-tree other than the sub-tree containing
2439 /// the calling Node or node_ref Node.
2440 IsAlternateFor {
2441 node_ref: fdomain_client::Event,
2442 responder: BufferCollectionIsAlternateForResponder,
2443 },
2444 /// Provide BufferCollectionConstraints to the logical BufferCollection.
2445 ///
2446 /// A participant may only call SetConstraints() once.
2447 ///
2448 /// Sometimes the initiator is a participant only in the sense of wanting to
2449 /// keep an eye on success/failure to populate with buffers, and zx.Status
2450 /// on failure. In that case, `has_constraints` can be false, and
2451 /// `constraints` will be ignored.
2452 ///
2453 /// VMO handles will not be provided to the client that sends null
2454 /// constraints - that can be intentional for an initiator that doesn't need
2455 /// VMO handles. Not having VMO handles doesn't prevent the initator from
2456 /// adjusting which portion of a buffer is considered valid and similar, but
2457 /// the initiator can't hold a VMO handle open to prevent the logical
2458 /// BufferCollection from cleaning up if the logical BufferCollection needs
2459 /// to go away regardless of the initiator's degree of involvement for
2460 /// whatever reason.
2461 ///
2462 /// For population of buffers to be attempted, all holders of a
2463 /// BufferCollection client channel need to call SetConstraints() before
2464 /// sysmem will attempt to allocate buffers.
2465 ///
2466 /// `has_constraints` if false, the constraints are effectively null, and
2467 /// `constraints` are ignored. The sender of null constraints won't get any
2468 /// VMO handles in BufferCollectionInfo, but can still find out how many
2469 /// buffers were allocated and can still refer to buffers by their
2470 /// buffer_index.
2471 ///
2472 /// `constraints` are constraints on the buffer collection.
2473 SetConstraints {
2474 has_constraints: bool,
2475 constraints: BufferCollectionConstraints,
2476 control_handle: BufferCollectionControlHandle,
2477 },
2478 /// This request completes when buffers have been allocated, responds with
2479 /// some failure detail if allocation has been attempted but failed.
2480 ///
2481 /// The following must occur before buffers will be allocated:
2482 /// * All BufferCollectionToken(s) of the logical BufferCollectionToken
2483 /// must be turned in via BindSharedCollection().
2484 /// * All BufferCollection(s) of the logical BufferCollection must have
2485 /// had SetConstraints() sent to them.
2486 ///
2487 /// Returns `ZX_OK` if successful.
2488 /// Returns `ZX_ERR_NO_MEMORY` if the request is valid but cannot be
2489 /// fulfilled due to resource exhaustion.
2490 /// Returns `ZX_ERR_ACCESS_DENIED` if the caller is not permitted to
2491 /// obtain the buffers it requested.
2492 /// Returns `ZX_ERR_INVALID_ARGS` if the request is malformed.
2493 /// Returns `ZX_ERR_NOT_SUPPORTED` if request is valid but cannot be
2494 /// satisfied, perhaps due to hardware limitations.
2495 ///
2496 /// `buffer_collection_info` has the VMO handles and other related info.
2497 WaitForBuffersAllocated { responder: BufferCollectionWaitForBuffersAllocatedResponder },
2498 /// This returns the same result code as WaitForBuffersAllocated if the
2499 /// buffer collection has been allocated or failed, or `ZX_ERR_UNAVAILABLE`
2500 /// if WaitForBuffersAllocated would block.
2501 CheckBuffersAllocated { responder: BufferCollectionCheckBuffersAllocatedResponder },
2502 /// Create a new token, for trying to add a new participant to an existing
2503 /// collection, if the existing collection's buffer counts, constraints,
2504 /// and participants allow.
2505 ///
2506 /// This can be useful in replacing a failed participant, and/or in
2507 /// adding/re-adding a participant after buffers have already been
2508 /// allocated.
2509 ///
2510 /// Failure of an attached token / collection does not propagate to the
2511 /// parent of the attached token. Failure does propagate from a normal
2512 /// child of a dispensable token to the dispensable token. Failure
2513 /// of a child is blocked from reaching its parent if the child is attached,
2514 /// or if the child is dispensable and the failure occurred after logical
2515 /// allocation.
2516 ///
2517 /// An initiator may in some scenarios choose to initially use a dispensable
2518 /// token for a given instance of a participant, and then later if the first
2519 /// instance of that participant fails, a new second instance of that
2520 /// participant my be given a token created with AttachToken().
2521 ///
2522 /// From the point of view of the client end of the BufferCollectionToken
2523 /// channel, the token acts like any other token. The client can
2524 /// Duplicate() the token as needed, and can send the token to a different
2525 /// process. The token should be converted to a BufferCollection channel
2526 /// as normal by calling BindSharedCollection(). SetConstraints() should
2527 /// be called on that BufferCollection channel.
2528 ///
2529 /// A success result from WaitForBuffersAllocated() means the new
2530 /// participant's constraints were satisfiable using the already-existing
2531 /// buffer collection, the already-established BufferCollectionInfo
2532 /// including image format constraints, and the already-existing other
2533 /// participants and their buffer counts. A failure result means the new
2534 /// participant's constraints cannot be satisfied using the existing
2535 /// buffer collection and its already-logically-allocated participants.
2536 /// Creating a new collection instead may allow all participant's
2537 /// constraints to be satisfied, assuming SetDispensable() is used in place
2538 /// of AttachToken(), or a normal token is used.
2539 ///
2540 /// A token created with AttachToken() performs constraints aggregation with
2541 /// all constraints currently in effect on the buffer collection, plus the
2542 /// attached token under consideration plus child tokens under the attached
2543 /// token which are not themselves an attached token or under such a token.
2544 ///
2545 /// Allocation of buffer_count to min_buffer_count_for_camping etc is
2546 /// first-come first-served, but a child can't logically allocate before
2547 /// all its parents have sent SetConstraints().
2548 ///
2549 /// See also SetDispensable(), which in contrast to AttachToken(), has the
2550 /// created token + children participate in constraints aggregation along
2551 /// with its parent.
2552 ///
2553 /// The newly created token needs to be Sync()ed to sysmem before the new
2554 /// token can be passed to BindSharedCollection(). The Sync() of the new
2555 /// token can be accomplished with BufferCollection.Sync() on this
2556 /// BufferCollection. Alternately BufferCollectionToken.Sync() on the new
2557 /// token also works. A BufferCollectionToken.Sync() can be started after
2558 /// any BufferCollectionToken.Duplicate() messages have been sent via the
2559 /// newly created token, to also sync those additional tokens to sysmem
2560 /// using a single round-trip.
2561 ///
2562 /// These values for rights_attenuation_mask result in no attenuation (note
2563 /// that 0 is not on this list; 0 will output an ERROR to the system log
2564 /// to help diagnose the bug in client code):
2565 /// * ZX_RIGHT_SAME_RIGHTS (preferred)
2566 /// * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
2567 AttachToken {
2568 rights_attenuation_mask: u32,
2569 token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
2570 control_handle: BufferCollectionControlHandle,
2571 },
2572 /// AttachLifetimeTracking:
2573 ///
2574 /// AttachLifetimeTracking() is intended to allow a client to wait until an
2575 /// old logical buffer collection is fully or mostly deallocated before
2576 /// attempting allocation of a new logical buffer collection.
2577 ///
2578 /// Attach an eventpair endpoint to the logical buffer collection, so that
2579 /// the server_end will be closed when the number of buffers allocated
2580 /// drops to 'buffers_remaining'. The server_end won't close until after
2581 /// logical allocation has completed.
2582 ///
2583 /// If logical allocation fails, such as for an attached sub-tree (using
2584 /// AttachToken()), the server_end will close during that failure regardless
2585 /// of the number of buffers potenitally allocated in the overall logical
2586 /// buffer collection.
2587 ///
2588 /// The lifetime signalled by this event includes asynchronous cleanup of
2589 /// allocated buffers, and this asynchronous cleanup cannot occur until all
2590 /// holders of VMO handles to the buffers have closed those VMO handles.
2591 /// Therefore clients should take care not to become blocked forever waiting
2592 /// for ZX_EVENTPAIR_PEER_CLOSED to be signalled, especially if any of the
2593 /// participants using the logical buffer collection are less trusted or
2594 /// less reliable.
2595 ///
2596 /// The buffers_remaining parameter allows waiting for all but
2597 /// buffers_remaining buffers to be fully deallocated. This can be useful
2598 /// in situations where a known number of buffers are intentionally not
2599 /// closed so that the data can continue to be used, such as for keeping the
2600 /// last available video picture displayed in the UI even if the video
2601 /// stream was using protected output buffers. It's outside the scope of
2602 /// the BufferCollection interface (at least for now) to determine how many
2603 /// buffers may be held without closing, but it'll typically be in the range
2604 /// 0-2.
2605 ///
2606 /// This mechanism is meant to be compatible with other protocols providing
2607 /// a similar AttachLifetimeTracking() mechanism, in that duplicates of the
2608 /// same event can be sent to more than one AttachLifetimeTracking(), and
2609 /// the ZX_EVENTPAIR_PEER_CLOSED will be signalled when all the lifetime
2610 /// over conditions are met (all holders of duplicates have closed their
2611 /// handle(s)).
2612 ///
2613 /// There is no way to cancel an attach. Closing the client end of the
2614 /// eventpair doesn't subtract from the number of pending attach(es).
2615 ///
2616 /// Closing the client's end doesn't result in any action by the server.
2617 /// If the server listens to events from the client end at all, it is for
2618 /// debug logging only.
2619 ///
2620 /// The server intentionally doesn't "trust" any bits signalled by the
2621 /// client. This mechanism intentionally uses only ZX_EVENTPAIR_PEER_CLOSED
2622 /// which can't be triggered early, and is only triggered when all handles
2623 /// to server_end are closed. No meaning is associated with any of the
2624 /// other signal bits, and clients should functionally ignore any other
2625 /// signal bits on either end of the eventpair or its peer.
2626 ///
2627 /// The server_end may lack ZX_RIGHT_SIGNAL or ZX_RIGHT_SIGNAL_PEER, but
2628 /// must have ZX_RIGHT_DUPLICATE (and must have ZX_RIGHT_TRANSFER to
2629 /// transfer without causing CodecFactory channel failure).
2630 AttachLifetimeTracking {
2631 server_end: fdomain_client::EventPair,
2632 buffers_remaining: u32,
2633 control_handle: BufferCollectionControlHandle,
2634 },
2635}
2636
2637impl BufferCollectionRequest {
2638 #[allow(irrefutable_let_patterns)]
2639 pub fn into_sync(self) -> Option<(BufferCollectionSyncResponder)> {
2640 if let BufferCollectionRequest::Sync { responder } = self {
2641 Some((responder))
2642 } else {
2643 None
2644 }
2645 }
2646
2647 #[allow(irrefutable_let_patterns)]
2648 pub fn into_close(self) -> Option<(BufferCollectionControlHandle)> {
2649 if let BufferCollectionRequest::Close { control_handle } = self {
2650 Some((control_handle))
2651 } else {
2652 None
2653 }
2654 }
2655
2656 #[allow(irrefutable_let_patterns)]
2657 pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionControlHandle)> {
2658 if let BufferCollectionRequest::SetName { priority, name, control_handle } = self {
2659 Some((priority, name, control_handle))
2660 } else {
2661 None
2662 }
2663 }
2664
2665 #[allow(irrefutable_let_patterns)]
2666 pub fn into_set_debug_client_info(
2667 self,
2668 ) -> Option<(String, u64, BufferCollectionControlHandle)> {
2669 if let BufferCollectionRequest::SetDebugClientInfo { name, id, control_handle } = self {
2670 Some((name, id, control_handle))
2671 } else {
2672 None
2673 }
2674 }
2675
2676 #[allow(irrefutable_let_patterns)]
2677 pub fn into_set_debug_timeout_log_deadline(
2678 self,
2679 ) -> Option<(i64, BufferCollectionControlHandle)> {
2680 if let BufferCollectionRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } =
2681 self
2682 {
2683 Some((deadline, control_handle))
2684 } else {
2685 None
2686 }
2687 }
2688
2689 #[allow(irrefutable_let_patterns)]
2690 pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionControlHandle)> {
2691 if let BufferCollectionRequest::SetVerboseLogging { control_handle } = self {
2692 Some((control_handle))
2693 } else {
2694 None
2695 }
2696 }
2697
2698 #[allow(irrefutable_let_patterns)]
2699 pub fn into_get_node_ref(self) -> Option<(BufferCollectionGetNodeRefResponder)> {
2700 if let BufferCollectionRequest::GetNodeRef { responder } = self {
2701 Some((responder))
2702 } else {
2703 None
2704 }
2705 }
2706
2707 #[allow(irrefutable_let_patterns)]
2708 pub fn into_is_alternate_for(
2709 self,
2710 ) -> Option<(fdomain_client::Event, BufferCollectionIsAlternateForResponder)> {
2711 if let BufferCollectionRequest::IsAlternateFor { node_ref, responder } = self {
2712 Some((node_ref, responder))
2713 } else {
2714 None
2715 }
2716 }
2717
2718 #[allow(irrefutable_let_patterns)]
2719 pub fn into_set_constraints(
2720 self,
2721 ) -> Option<(bool, BufferCollectionConstraints, BufferCollectionControlHandle)> {
2722 if let BufferCollectionRequest::SetConstraints {
2723 has_constraints,
2724 constraints,
2725 control_handle,
2726 } = self
2727 {
2728 Some((has_constraints, constraints, control_handle))
2729 } else {
2730 None
2731 }
2732 }
2733
2734 #[allow(irrefutable_let_patterns)]
2735 pub fn into_wait_for_buffers_allocated(
2736 self,
2737 ) -> Option<(BufferCollectionWaitForBuffersAllocatedResponder)> {
2738 if let BufferCollectionRequest::WaitForBuffersAllocated { responder } = self {
2739 Some((responder))
2740 } else {
2741 None
2742 }
2743 }
2744
2745 #[allow(irrefutable_let_patterns)]
2746 pub fn into_check_buffers_allocated(
2747 self,
2748 ) -> Option<(BufferCollectionCheckBuffersAllocatedResponder)> {
2749 if let BufferCollectionRequest::CheckBuffersAllocated { responder } = self {
2750 Some((responder))
2751 } else {
2752 None
2753 }
2754 }
2755
2756 #[allow(irrefutable_let_patterns)]
2757 pub fn into_attach_token(
2758 self,
2759 ) -> Option<(
2760 u32,
2761 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
2762 BufferCollectionControlHandle,
2763 )> {
2764 if let BufferCollectionRequest::AttachToken {
2765 rights_attenuation_mask,
2766 token_request,
2767 control_handle,
2768 } = self
2769 {
2770 Some((rights_attenuation_mask, token_request, control_handle))
2771 } else {
2772 None
2773 }
2774 }
2775
2776 #[allow(irrefutable_let_patterns)]
2777 pub fn into_attach_lifetime_tracking(
2778 self,
2779 ) -> Option<(fdomain_client::EventPair, u32, BufferCollectionControlHandle)> {
2780 if let BufferCollectionRequest::AttachLifetimeTracking {
2781 server_end,
2782 buffers_remaining,
2783 control_handle,
2784 } = self
2785 {
2786 Some((server_end, buffers_remaining, control_handle))
2787 } else {
2788 None
2789 }
2790 }
2791
2792 /// Name of the method defined in FIDL
2793 pub fn method_name(&self) -> &'static str {
2794 match *self {
2795 BufferCollectionRequest::Sync { .. } => "sync",
2796 BufferCollectionRequest::Close { .. } => "close",
2797 BufferCollectionRequest::SetName { .. } => "set_name",
2798 BufferCollectionRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
2799 BufferCollectionRequest::SetDebugTimeoutLogDeadline { .. } => {
2800 "set_debug_timeout_log_deadline"
2801 }
2802 BufferCollectionRequest::SetVerboseLogging { .. } => "set_verbose_logging",
2803 BufferCollectionRequest::GetNodeRef { .. } => "get_node_ref",
2804 BufferCollectionRequest::IsAlternateFor { .. } => "is_alternate_for",
2805 BufferCollectionRequest::SetConstraints { .. } => "set_constraints",
2806 BufferCollectionRequest::WaitForBuffersAllocated { .. } => "wait_for_buffers_allocated",
2807 BufferCollectionRequest::CheckBuffersAllocated { .. } => "check_buffers_allocated",
2808 BufferCollectionRequest::AttachToken { .. } => "attach_token",
2809 BufferCollectionRequest::AttachLifetimeTracking { .. } => "attach_lifetime_tracking",
2810 }
2811 }
2812}
2813
2814#[derive(Debug, Clone)]
2815pub struct BufferCollectionControlHandle {
2816 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2817}
2818
2819impl fdomain_client::fidl::ControlHandle for BufferCollectionControlHandle {
2820 fn shutdown(&self) {
2821 self.inner.shutdown()
2822 }
2823
2824 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2825 self.inner.shutdown_with_epitaph(status)
2826 }
2827
2828 fn is_closed(&self) -> bool {
2829 self.inner.channel().is_closed()
2830 }
2831 fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
2832 self.inner.channel().on_closed()
2833 }
2834}
2835
2836impl BufferCollectionControlHandle {}
2837
2838#[must_use = "FIDL methods require a response to be sent"]
2839#[derive(Debug)]
2840pub struct BufferCollectionSyncResponder {
2841 control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
2842 tx_id: u32,
2843}
2844
2845/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
2846/// if the responder is dropped without sending a response, so that the client
2847/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2848impl std::ops::Drop for BufferCollectionSyncResponder {
2849 fn drop(&mut self) {
2850 self.control_handle.shutdown();
2851 // Safety: drops once, never accessed again
2852 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2853 }
2854}
2855
2856impl fdomain_client::fidl::Responder for BufferCollectionSyncResponder {
2857 type ControlHandle = BufferCollectionControlHandle;
2858
2859 fn control_handle(&self) -> &BufferCollectionControlHandle {
2860 &self.control_handle
2861 }
2862
2863 fn drop_without_shutdown(mut self) {
2864 // Safety: drops once, never accessed again due to mem::forget
2865 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2866 // Prevent Drop from running (which would shut down the channel)
2867 std::mem::forget(self);
2868 }
2869}
2870
2871impl BufferCollectionSyncResponder {
2872 /// Sends a response to the FIDL transaction.
2873 ///
2874 /// Sets the channel to shutdown if an error occurs.
2875 pub fn send(self) -> Result<(), fidl::Error> {
2876 let _result = self.send_raw();
2877 if _result.is_err() {
2878 self.control_handle.shutdown();
2879 }
2880 self.drop_without_shutdown();
2881 _result
2882 }
2883
2884 /// Similar to "send" but does not shutdown the channel if an error occurs.
2885 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2886 let _result = self.send_raw();
2887 self.drop_without_shutdown();
2888 _result
2889 }
2890
2891 fn send_raw(&self) -> Result<(), fidl::Error> {
2892 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2893 (),
2894 self.tx_id,
2895 0x4577e238ae26291,
2896 fidl::encoding::DynamicFlags::empty(),
2897 )
2898 }
2899}
2900
2901#[must_use = "FIDL methods require a response to be sent"]
2902#[derive(Debug)]
2903pub struct BufferCollectionGetNodeRefResponder {
2904 control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
2905 tx_id: u32,
2906}
2907
2908/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
2909/// if the responder is dropped without sending a response, so that the client
2910/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2911impl std::ops::Drop for BufferCollectionGetNodeRefResponder {
2912 fn drop(&mut self) {
2913 self.control_handle.shutdown();
2914 // Safety: drops once, never accessed again
2915 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2916 }
2917}
2918
2919impl fdomain_client::fidl::Responder for BufferCollectionGetNodeRefResponder {
2920 type ControlHandle = BufferCollectionControlHandle;
2921
2922 fn control_handle(&self) -> &BufferCollectionControlHandle {
2923 &self.control_handle
2924 }
2925
2926 fn drop_without_shutdown(mut self) {
2927 // Safety: drops once, never accessed again due to mem::forget
2928 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2929 // Prevent Drop from running (which would shut down the channel)
2930 std::mem::forget(self);
2931 }
2932}
2933
2934impl BufferCollectionGetNodeRefResponder {
2935 /// Sends a response to the FIDL transaction.
2936 ///
2937 /// Sets the channel to shutdown if an error occurs.
2938 pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
2939 let _result = self.send_raw(node_ref);
2940 if _result.is_err() {
2941 self.control_handle.shutdown();
2942 }
2943 self.drop_without_shutdown();
2944 _result
2945 }
2946
2947 /// Similar to "send" but does not shutdown the channel if an error occurs.
2948 pub fn send_no_shutdown_on_err(
2949 self,
2950 mut node_ref: fdomain_client::Event,
2951 ) -> Result<(), fidl::Error> {
2952 let _result = self.send_raw(node_ref);
2953 self.drop_without_shutdown();
2954 _result
2955 }
2956
2957 fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
2958 self.control_handle.inner.send::<NodeGetNodeRefResponse>(
2959 (node_ref,),
2960 self.tx_id,
2961 0x467b7c75c35c3b84,
2962 fidl::encoding::DynamicFlags::empty(),
2963 )
2964 }
2965}
2966
2967#[must_use = "FIDL methods require a response to be sent"]
2968#[derive(Debug)]
2969pub struct BufferCollectionIsAlternateForResponder {
2970 control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
2971 tx_id: u32,
2972}
2973
2974/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
2975/// if the responder is dropped without sending a response, so that the client
2976/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2977impl std::ops::Drop for BufferCollectionIsAlternateForResponder {
2978 fn drop(&mut self) {
2979 self.control_handle.shutdown();
2980 // Safety: drops once, never accessed again
2981 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2982 }
2983}
2984
2985impl fdomain_client::fidl::Responder for BufferCollectionIsAlternateForResponder {
2986 type ControlHandle = BufferCollectionControlHandle;
2987
2988 fn control_handle(&self) -> &BufferCollectionControlHandle {
2989 &self.control_handle
2990 }
2991
2992 fn drop_without_shutdown(mut self) {
2993 // Safety: drops once, never accessed again due to mem::forget
2994 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2995 // Prevent Drop from running (which would shut down the channel)
2996 std::mem::forget(self);
2997 }
2998}
2999
3000impl BufferCollectionIsAlternateForResponder {
3001 /// Sends a response to the FIDL transaction.
3002 ///
3003 /// Sets the channel to shutdown if an error occurs.
3004 pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3005 let _result = self.send_raw(result);
3006 if _result.is_err() {
3007 self.control_handle.shutdown();
3008 }
3009 self.drop_without_shutdown();
3010 _result
3011 }
3012
3013 /// Similar to "send" but does not shutdown the channel if an error occurs.
3014 pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3015 let _result = self.send_raw(result);
3016 self.drop_without_shutdown();
3017 _result
3018 }
3019
3020 fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
3021 self.control_handle
3022 .inner
3023 .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
3024 result.map(|is_alternate| (is_alternate,)),
3025 self.tx_id,
3026 0x33a2a7aff2776c07,
3027 fidl::encoding::DynamicFlags::empty(),
3028 )
3029 }
3030}
3031
3032#[must_use = "FIDL methods require a response to be sent"]
3033#[derive(Debug)]
3034pub struct BufferCollectionWaitForBuffersAllocatedResponder {
3035 control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3036 tx_id: u32,
3037}
3038
3039/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3040/// if the responder is dropped without sending a response, so that the client
3041/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3042impl std::ops::Drop for BufferCollectionWaitForBuffersAllocatedResponder {
3043 fn drop(&mut self) {
3044 self.control_handle.shutdown();
3045 // Safety: drops once, never accessed again
3046 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3047 }
3048}
3049
3050impl fdomain_client::fidl::Responder for BufferCollectionWaitForBuffersAllocatedResponder {
3051 type ControlHandle = BufferCollectionControlHandle;
3052
3053 fn control_handle(&self) -> &BufferCollectionControlHandle {
3054 &self.control_handle
3055 }
3056
3057 fn drop_without_shutdown(mut self) {
3058 // Safety: drops once, never accessed again due to mem::forget
3059 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3060 // Prevent Drop from running (which would shut down the channel)
3061 std::mem::forget(self);
3062 }
3063}
3064
3065impl BufferCollectionWaitForBuffersAllocatedResponder {
3066 /// Sends a response to the FIDL transaction.
3067 ///
3068 /// Sets the channel to shutdown if an error occurs.
3069 pub fn send(
3070 self,
3071 mut status: i32,
3072 mut buffer_collection_info: BufferCollectionInfo2,
3073 ) -> Result<(), fidl::Error> {
3074 let _result = self.send_raw(status, buffer_collection_info);
3075 if _result.is_err() {
3076 self.control_handle.shutdown();
3077 }
3078 self.drop_without_shutdown();
3079 _result
3080 }
3081
3082 /// Similar to "send" but does not shutdown the channel if an error occurs.
3083 pub fn send_no_shutdown_on_err(
3084 self,
3085 mut status: i32,
3086 mut buffer_collection_info: BufferCollectionInfo2,
3087 ) -> Result<(), fidl::Error> {
3088 let _result = self.send_raw(status, buffer_collection_info);
3089 self.drop_without_shutdown();
3090 _result
3091 }
3092
3093 fn send_raw(
3094 &self,
3095 mut status: i32,
3096 mut buffer_collection_info: BufferCollectionInfo2,
3097 ) -> Result<(), fidl::Error> {
3098 self.control_handle.inner.send::<BufferCollectionWaitForBuffersAllocatedResponse>(
3099 (status, &mut buffer_collection_info),
3100 self.tx_id,
3101 0x714667ea2a29a3a2,
3102 fidl::encoding::DynamicFlags::empty(),
3103 )
3104 }
3105}
3106
3107#[must_use = "FIDL methods require a response to be sent"]
3108#[derive(Debug)]
3109pub struct BufferCollectionCheckBuffersAllocatedResponder {
3110 control_handle: std::mem::ManuallyDrop<BufferCollectionControlHandle>,
3111 tx_id: u32,
3112}
3113
3114/// Set the the channel to be shutdown (see [`BufferCollectionControlHandle::shutdown`])
3115/// if the responder is dropped without sending a response, so that the client
3116/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3117impl std::ops::Drop for BufferCollectionCheckBuffersAllocatedResponder {
3118 fn drop(&mut self) {
3119 self.control_handle.shutdown();
3120 // Safety: drops once, never accessed again
3121 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3122 }
3123}
3124
3125impl fdomain_client::fidl::Responder for BufferCollectionCheckBuffersAllocatedResponder {
3126 type ControlHandle = BufferCollectionControlHandle;
3127
3128 fn control_handle(&self) -> &BufferCollectionControlHandle {
3129 &self.control_handle
3130 }
3131
3132 fn drop_without_shutdown(mut self) {
3133 // Safety: drops once, never accessed again due to mem::forget
3134 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3135 // Prevent Drop from running (which would shut down the channel)
3136 std::mem::forget(self);
3137 }
3138}
3139
3140impl BufferCollectionCheckBuffersAllocatedResponder {
3141 /// Sends a response to the FIDL transaction.
3142 ///
3143 /// Sets the channel to shutdown if an error occurs.
3144 pub fn send(self, mut status: i32) -> Result<(), fidl::Error> {
3145 let _result = self.send_raw(status);
3146 if _result.is_err() {
3147 self.control_handle.shutdown();
3148 }
3149 self.drop_without_shutdown();
3150 _result
3151 }
3152
3153 /// Similar to "send" but does not shutdown the channel if an error occurs.
3154 pub fn send_no_shutdown_on_err(self, mut status: i32) -> Result<(), fidl::Error> {
3155 let _result = self.send_raw(status);
3156 self.drop_without_shutdown();
3157 _result
3158 }
3159
3160 fn send_raw(&self, mut status: i32) -> Result<(), fidl::Error> {
3161 self.control_handle.inner.send::<BufferCollectionCheckBuffersAllocatedResponse>(
3162 (status,),
3163 self.tx_id,
3164 0x245bb81f79189e9,
3165 fidl::encoding::DynamicFlags::empty(),
3166 )
3167 }
3168}
3169
3170#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3171pub struct BufferCollectionTokenMarker;
3172
3173impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenMarker {
3174 type Proxy = BufferCollectionTokenProxy;
3175 type RequestStream = BufferCollectionTokenRequestStream;
3176
3177 const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionToken";
3178}
3179
3180pub trait BufferCollectionTokenProxyInterface: Send + Sync {
3181 type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3182 fn r#sync(&self) -> Self::SyncResponseFut;
3183 fn r#close(&self) -> Result<(), fidl::Error>;
3184 fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
3185 fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
3186 fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
3187 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
3188 type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
3189 + Send;
3190 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
3191 type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
3192 + Send;
3193 fn r#is_alternate_for(
3194 &self,
3195 node_ref: fdomain_client::Event,
3196 ) -> Self::IsAlternateForResponseFut;
3197 type DuplicateSyncResponseFut: std::future::Future<
3198 Output = Result<
3199 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3200 fidl::Error,
3201 >,
3202 > + Send;
3203 fn r#duplicate_sync(
3204 &self,
3205 rights_attenuation_masks: &[fidl::Rights],
3206 ) -> Self::DuplicateSyncResponseFut;
3207 fn r#duplicate(
3208 &self,
3209 rights_attenuation_mask: u32,
3210 token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
3211 ) -> Result<(), fidl::Error>;
3212 fn r#set_dispensable(&self) -> Result<(), fidl::Error>;
3213 fn r#create_buffer_collection_token_group(
3214 &self,
3215 group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
3216 ) -> Result<(), fidl::Error>;
3217}
3218
3219#[derive(Debug, Clone)]
3220pub struct BufferCollectionTokenProxy {
3221 client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3222}
3223
3224impl fdomain_client::fidl::Proxy for BufferCollectionTokenProxy {
3225 type Protocol = BufferCollectionTokenMarker;
3226
3227 fn from_channel(inner: fdomain_client::Channel) -> Self {
3228 Self::new(inner)
3229 }
3230
3231 fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3232 self.client.into_channel().map_err(|client| Self { client })
3233 }
3234
3235 fn as_channel(&self) -> &fdomain_client::Channel {
3236 self.client.as_channel()
3237 }
3238}
3239
3240impl BufferCollectionTokenProxy {
3241 /// Create a new Proxy for fuchsia.sysmem/BufferCollectionToken.
3242 pub fn new(channel: fdomain_client::Channel) -> Self {
3243 let protocol_name =
3244 <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3245 Self { client: fidl::client::Client::new(channel, protocol_name) }
3246 }
3247
3248 /// Get a Stream of events from the remote end of the protocol.
3249 ///
3250 /// # Panics
3251 ///
3252 /// Panics if the event stream was already taken.
3253 pub fn take_event_stream(&self) -> BufferCollectionTokenEventStream {
3254 BufferCollectionTokenEventStream { event_receiver: self.client.take_event_receiver() }
3255 }
3256
3257 /// Ensure that previous messages, including Duplicate() messages on a
3258 /// token, collection, or group, have been received server side.
3259 ///
3260 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
3261 /// valid sysmem token risks the Sync() hanging forever. See
3262 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
3263 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
3264 /// Another way is to pass the token to BindSharedCollection(), which also
3265 /// validates the token as part of exchanging it for a BufferCollection
3266 /// channel, and BufferCollection Sync() can then be used.
3267 ///
3268 /// After a Sync(), it's then safe to send the client end of token_request
3269 /// to another participant knowing the server will recognize the token when
3270 /// it's sent into BindSharedCollection() by the other participant.
3271 ///
3272 /// Other options include waiting for each token.Duplicate() to complete
3273 /// individually (using separate call to token.Sync() after each), or
3274 /// calling Sync() on BufferCollection after the token has been turned in
3275 /// via BindSharedCollection().
3276 ///
3277 /// Another way to mitigate is to avoid calling Sync() on the token, and
3278 /// instead later deal with potential failure of BufferCollection.Sync() if
3279 /// the original token was invalid. This option can be preferable from a
3280 /// performance point of view, but requires client code to delay sending
3281 /// tokens duplicated from this token until after client code has converted
3282 /// the duplicating token to a BufferCollection and received successful
3283 /// response from BufferCollection.Sync().
3284 ///
3285 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
3286 /// When BufferCollection.Sync() isn't feasible, the caller must already
3287 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
3288 /// hang forever. See ValidateBufferCollectionToken() to check token
3289 /// validity first if the token isn't already known to be (is/was) valid.
3290 pub fn r#sync(
3291 &self,
3292 ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
3293 BufferCollectionTokenProxyInterface::r#sync(self)
3294 }
3295
3296 /// On a BufferCollectionToken channel:
3297 ///
3298 /// Normally a participant will convert a BufferCollectionToken into a
3299 /// BufferCollection view, but a participant is also free to Close() the
3300 /// token (and then close the channel immediately or shortly later in
3301 /// response to server closing its end), which avoids causing logical buffer
3302 /// collection failure. Â Normally an unexpected token channel close will
3303 /// cause logical buffer collection failure (the only exceptions being
3304 /// certain cases involving AttachToken() or SetDispensable()).
3305 ///
3306 /// On a BufferCollection channel:
3307 ///
3308 /// By default the server handles unexpected failure of a BufferCollection
3309 /// by failing the whole logical buffer collection. Partly this is to
3310 /// expedite closing VMO handles to reclaim memory when any participant
3311 /// fails. If a participant would like to cleanly close a BufferCollection
3312 /// view without causing logical buffer collection failure, the participant
3313 /// can send Close() before closing the client end of the BufferCollection
3314 /// channel. If this is the last BufferCollection view, the logical buffer
3315 /// collection will still go away. The Close() can occur before or after
3316 /// SetConstraints(). If before SetConstraints(), the buffer collection
3317 /// won't require constraints from this node in order to allocate. If
3318 /// after SetConstraints(), the constraints are retained and aggregated
3319 /// along with any subsequent logical allocation(s), despite the lack of
3320 /// channel connection.
3321 ///
3322 /// On a BufferCollectionTokenGroup channel:
3323 ///
3324 /// By default, unexpected failure of a BufferCollectionTokenGroup will
3325 /// trigger failure of the logical BufferCollectionTokenGroup and will
3326 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
3327 /// channel without failing the logical group or propagating failure, send
3328 /// Close() before closing the channel client endpoint.
3329 ///
3330 /// If Close() occurs before AllChildrenPresent(), the logical buffer
3331 /// collection will still fail despite the Close() (because sysmem can't be
3332 /// sure whether all relevant children were created, so it's ambiguous
3333 /// whether all relevant constraints will be provided to sysmem). If
3334 /// Close() occurs after AllChildrenPresent(), the children and all their
3335 /// constraints remain intact (just as they would if the
3336 /// BufferCollectionTokenGroup channel had remained open), and the close
3337 /// doesn't trigger or propagate failure.
3338 pub fn r#close(&self) -> Result<(), fidl::Error> {
3339 BufferCollectionTokenProxyInterface::r#close(self)
3340 }
3341
3342 /// Set a name for VMOs in this buffer collection. The name may be truncated
3343 /// shorter. The name only affects VMOs allocated after it's set - this call
3344 /// does not rename existing VMOs. If multiple clients set different names
3345 /// then the larger priority value will win.
3346 pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
3347 BufferCollectionTokenProxyInterface::r#set_name(self, priority, name)
3348 }
3349
3350 /// Set information about the current client that can be used by sysmem to
3351 /// help debug leaking memory and hangs waiting for constraints. |name| can
3352 /// be an arbitrary string, but the current process name (see
3353 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
3354 /// arbitrary id, but the current process ID (see
3355 /// fsl::GetCurrentProcessKoid()) is a good default.
3356 ///
3357 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
3358 /// indicate which client is closing their channel first, leading to
3359 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
3360 /// over, but if happening earlier than expected, the
3361 /// client-channel-specific name can help diagnose where the failure is
3362 /// first coming from, from sysmem's point of view).
3363 ///
3364 /// By default (unless overriden by this message or using
3365 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
3366 /// parent Node at the time the child Node is created. While this can be
3367 /// better than nothing, it's often better for each participant to use
3368 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
3369 /// info directly relevant to the current client. Also, SetVerboseLogging()
3370 /// can be used to help disambiguate if a Node is suspected of having info
3371 /// that was copied from its parent.
3372 pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
3373 BufferCollectionTokenProxyInterface::r#set_debug_client_info(self, name, id)
3374 }
3375
3376 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
3377 /// after creating a collection. Clients can call this method to change
3378 /// when the log is printed. If multiple client set the deadline, it's
3379 /// unspecified which deadline will take effect.
3380 pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
3381 BufferCollectionTokenProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
3382 }
3383
3384 /// Verbose logging includes constraints set via SetConstraints() from each
3385 /// client along with info set via SetDebugClientInfo() and the structure of
3386 /// the tree of Node(s).
3387 ///
3388 /// Normally sysmem prints only a single line complaint when aggregation
3389 /// fails, with just the specific detailed reason that aggregation failed,
3390 /// with minimal context. While this is often enough to diagnose a problem
3391 /// if only a small change was made and the system had been working before
3392 /// the small change, it's often not particularly helpful for getting a new
3393 /// buffer collection to work for the first time. Especially with more
3394 /// complex trees of nodes, involving things like AttachToken(),
3395 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
3396 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
3397 /// looks like and why it's failing a logical allocation, or why a tree or
3398 /// sub-tree is failing sooner than expected.
3399 ///
3400 /// The intent of the extra logging is to be acceptable from a performance
3401 /// point of view, if only enabled on a low number of buffer collections.
3402 /// If we're not tracking down a bug, we shouldn't send this message.
3403 ///
3404 /// If too many participants leave verbose logging enabled, we may end up
3405 /// needing to require that system-wide sysmem verbose logging be permitted
3406 /// via some other setting, to avoid sysmem spamming the log too much due to
3407 /// this message.
3408 ///
3409 /// This may be a NOP for some nodes due to intentional policy associated
3410 /// with the node, if we don't trust a node enough to let it turn on verbose
3411 /// logging.
3412 pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
3413 BufferCollectionTokenProxyInterface::r#set_verbose_logging(self)
3414 }
3415
3416 /// This gets an event handle that can be used as a parameter to
3417 /// IsAlternateFor() called on any Node. The client will not be granted the
3418 /// right to signal this event, as this handle should only be used as proof
3419 /// that the client obtained this handle from this Node.
3420 ///
3421 /// Because this is a get not a set, no Sync() is needed between the
3422 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
3423 /// potentially being on different channels.
3424 ///
3425 /// See also IsAlternateFor().
3426 pub fn r#get_node_ref(
3427 &self,
3428 ) -> fidl::client::QueryResponseFut<
3429 fdomain_client::Event,
3430 fdomain_client::fidl::FDomainResourceDialect,
3431 > {
3432 BufferCollectionTokenProxyInterface::r#get_node_ref(self)
3433 }
3434
3435 /// This checks whether the calling node is in a subtree rooted at a
3436 /// different child token of a common parent BufferCollectionTokenGroup, in
3437 /// relation to the passed-in node_ref.
3438 ///
3439 /// This call is for assisting with admission control de-duplication, and
3440 /// with debugging.
3441 ///
3442 /// The node_ref must be obtained using GetNodeRef() of a
3443 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
3444 ///
3445 /// The node_ref can be a duplicated handle; it's not necessary to call
3446 /// GetNodeRef() for every call to IsAlternateFor().
3447 ///
3448 /// If a calling token may not actually be a valid token at all due to
3449 /// a potentially hostile/untrusted provider of the token, call
3450 /// ValidateBufferCollectionToken() first instead of potentially getting
3451 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
3452 /// token not being a real token (not really talking to sysmem). Another
3453 /// option is to call BindSharedCollection with this token first which also
3454 /// validates the token along with converting it to a BufferCollection, then
3455 /// call BufferCollection IsAlternateFor().
3456 ///
3457 /// error values:
3458 ///
3459 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
3460 /// buffer collection as the calling Node. Before logical allocation and
3461 /// within the same logical allocation sub-tree, this essentially means that
3462 /// the node_ref was never part of this logical buffer collection, since
3463 /// before logical allocation all node_refs that come into existence remain
3464 /// in existence at least until logical allocation (including Node(s) that
3465 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
3466 /// to be returned, this Node's channel needs to still be connected server
3467 /// side, which won't be the case if the whole logical allocation has
3468 /// failed. After logical allocation or in a different logical allocation
3469 /// sub-tree there are additional potential reasons for this error. For
3470 /// example a different logical allocation (separated from this Node(s)
3471 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
3472 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
3473 /// exist and may select a different child sub-tree than the sub-tree the
3474 /// node_ref is in causing deletion of the node_ref Node. The only time
3475 /// sysmem keeps a Node around after that Node has no corresponding channel
3476 /// is when Close() is used and the Node's sub-tree has not yet failed.
3477 /// Another reason for this error is if the node_ref is an eventpair handle
3478 /// with sufficient rights, but isn't actually a real node_ref obtained from
3479 /// GetNodeRef().
3480 ///
3481 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
3482 /// eventpair handle, or doesn't have the needed rights expected on a real
3483 /// node_ref.
3484 ///
3485 /// No other failing status codes are returned by this call. However,
3486 /// sysmem may add additional codes in future, so the client should have
3487 /// sensible default handling for any failing status code.
3488 ///
3489 /// On success, is_alternate has the following meaning:
3490 /// * true - The first parent node in common between the calling node and
3491 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
3492 /// the calling Node and the node_ref Node will _not_ have both their
3493 /// constraints apply - rather sysmem will choose one or the other of
3494 /// the constraints - never both. This is because only one child of
3495 /// a BufferCollectionTokenGroup is selected during logical allocation,
3496 /// with only that one child's sub-tree contributing to constraints
3497 /// aggregation.
3498 /// * false - The first parent node in common between the calling Node and
3499 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
3500 /// this means the first parent node in common is a
3501 /// BufferCollectionToken or BufferCollection (regardless of not
3502 /// Close()ed or Close()ed). This means that the calling Node and the
3503 /// node_ref Node _may_ have both their constraints apply during
3504 /// constraints aggregation of the logical allocation, if both Node(s)
3505 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
3506 /// In this case, there is no BufferCollectionTokenGroup that will
3507 /// directly prevent the two Node(s) from both being selected and their
3508 /// constraints both aggregated, but even when false, one or both
3509 /// Node(s) may still be eliminated from consideration if one or both
3510 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
3511 /// which selects a child sub-tree other than the sub-tree containing
3512 /// the calling Node or node_ref Node.
3513 pub fn r#is_alternate_for(
3514 &self,
3515 mut node_ref: fdomain_client::Event,
3516 ) -> fidl::client::QueryResponseFut<
3517 NodeIsAlternateForResult,
3518 fdomain_client::fidl::FDomainResourceDialect,
3519 > {
3520 BufferCollectionTokenProxyInterface::r#is_alternate_for(self, node_ref)
3521 }
3522
3523 /// This method can be used to add more participants prior to creating a
3524 /// shared BufferCollection. A new token will be returned for each entry in
3525 /// the `rights_attenuation_masks` array. The return value is the client
3526 /// ends of each new participant token.
3527 ///
3528 /// If the calling token may not actually be a valid token at all due to
3529 /// a potentially hostile/untrusted provider of the token, consider using
3530 /// ValidateBufferCollectionToken() first instead of potentially getting
3531 /// stuck indefinitely if DuplicateSync() never responds due to the calling
3532 /// token not being a real token.
3533 ///
3534 /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
3535 /// after calling this method.
3536 ///
3537 /// All tokens must be turned in via BindSharedCollection() or Close() for a
3538 /// BufferCollection to be successfully created.
3539 ///
3540 /// In each entry of `rights_attenuation_masks`, rights bits that are zero
3541 /// will be absent in the buffer VMO rights obtainable via the corresponding
3542 /// returned token. This allows an initiator or intermediary participant to
3543 /// attenuate the rights available to a participant. This does not allow a
3544 /// participant to gain rights that the participant doesn't already have.
3545 /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
3546 /// attenuation should be applied.
3547 pub fn r#duplicate_sync(
3548 &self,
3549 mut rights_attenuation_masks: &[fidl::Rights],
3550 ) -> fidl::client::QueryResponseFut<
3551 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3552 fdomain_client::fidl::FDomainResourceDialect,
3553 > {
3554 BufferCollectionTokenProxyInterface::r#duplicate_sync(self, rights_attenuation_masks)
3555 }
3556
3557 /// This method can be used to add a participant prior to creating a shared
3558 /// BufferCollection. It should only be used instead of DuplicateSync in
3559 /// performance sensitive cases where it would be undesireable to wait for
3560 /// sysmem to respond as part of each duplicate.
3561 ///
3562 /// After sending one or more Duplicate() messages, and before sending the
3563 /// created tokens to other participants (or to other Allocator channels),
3564 /// the client should send a Sync() and wait for its response. The Sync()
3565 /// call can be made on the token, or on the BufferCollection obtained by
3566 /// passing this token to BindSharedCollection(). Either will ensure that
3567 /// the server knows about the tokens created via Duplicate() before the
3568 /// other participant sends the token to the server via separate Allocator
3569 /// channel.
3570 ///
3571 /// All tokens must be turned in via BindSharedCollection() or Close() for a
3572 /// BufferCollection to be successfully created.
3573 ///
3574 /// When a client calls BindSharedCollection() to turn in a
3575 /// BufferCollectionToken, the server will process all Duplicate() messages
3576 /// before closing down the BufferCollectionToken. This allows the client
3577 /// to Duplicate() and immediately turn in the BufferCollectionToken using
3578 /// BindSharedCollection, then later transfer the client end of token_request
3579 /// to another participant - the server will notice the existence of the
3580 /// token_request before considering this BufferCollectionToken fully closed.
3581 ///
3582 /// `rights_attenuation_mask` rights bits that are zero in this mask will be
3583 /// absent in the buffer VMO rights obtainable via the client end of
3584 /// token_request. This allows an initiator or intermediary participant to
3585 /// attenuate the rights available to a participant. This does not allow a
3586 /// participant to gain rights that the participant doesn't already have.
3587 /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
3588 /// attenuation should be applied.
3589 ///
3590 /// These values for rights_attenuation_mask result in no attenuation:
3591 /// * ZX_RIGHT_SAME_RIGHTS (preferred)
3592 /// * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
3593 /// * 0 (deprecated - do not use 0 - an ERROR will go to the log)
3594 ///
3595 /// `token_request` is the server end of a BufferCollectionToken channel.
3596 /// The client end of this channel acts as another participant in creating the
3597 /// shared BufferCollection.
3598 pub fn r#duplicate(
3599 &self,
3600 mut rights_attenuation_mask: u32,
3601 mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
3602 ) -> Result<(), fidl::Error> {
3603 BufferCollectionTokenProxyInterface::r#duplicate(
3604 self,
3605 rights_attenuation_mask,
3606 token_request,
3607 )
3608 }
3609
3610 /// A dispensable token can fail after buffers are logically allocated
3611 /// without causing failure of its parent (if any).
3612 ///
3613 /// The dispensable token participates in constraints aggregation along with
3614 /// its parent before logical buffer allocation. If the dispensable token
3615 /// fails before buffers are logically allocated, the failure propagates to
3616 /// the dispensable token's parent.
3617 ///
3618 /// After buffers are logically allocated, failure of the dispensable token
3619 /// (or any child of the dispensable token) does not propagate to the
3620 /// dispensable token's parent. Failure does propagate from a normal
3621 /// child of a dispensable token to the dispensable token. Failure
3622 /// of a child is blocked from reaching its parent if the child is attached,
3623 /// or if the child is dispensable and the failure occurred after logical
3624 /// allocation.
3625 ///
3626 /// A dispensable token can be used in cases where a participant needs to
3627 /// provide constraints, but after buffers are allocated, the participant
3628 /// can fail without causing buffer collection failure from the parent's
3629 /// point of view.
3630 ///
3631 /// In contrast, AttachToken() can be used to create a token which does not
3632 /// participate in constraints aggregation with its parent, and whose
3633 /// failure at any time does not propagate to its parent, and whose delay
3634 /// providing constraints does not prevent the parent from completing its
3635 /// buffer allocation.
3636 ///
3637 /// An initiator may in some scenarios choose to initially use a dispensable
3638 /// token for a given instance of a participant, and then later if the first
3639 /// instance of that participant fails, a new second instance of that
3640 /// participant my be given a token created with AttachToken().
3641 ///
3642 /// If a client uses this message, the client should not rely on the
3643 /// client's own BufferCollectionToken or BufferCollection channel to close
3644 /// from the server end due to abrupt failure of any BufferCollectionToken
3645 /// or BufferCollection that the client has SetDispensable() and given out
3646 /// to another process. For this reason, the client should take extra care
3647 /// to notice failure of that other process via other means.
3648 ///
3649 /// While it is possible (and potentially useful) to SetDispensable() on a
3650 /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
3651 /// replace a failed dispensable token that was a direct child of a group
3652 /// with a new token using AttachToken() (since there's no AttachToken() on
3653 /// a group). Instead, to enable AttachToken() replacement in this case,
3654 /// create an additional non-dispensable token (node) that's a direct child
3655 /// of the group and make the existing dispensable token a child of the
3656 /// additional token (node). This way, the additional token (node) that is
3657 /// a direct child of the group has BufferCollection.AttachToken() which can
3658 /// be used to replace the failed dispensable token.
3659 ///
3660 /// SetDispensable() on an already-dispensable token is idempotent.
3661 pub fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
3662 BufferCollectionTokenProxyInterface::r#set_dispensable(self)
3663 }
3664
3665 /// Most sysmem clients and many participants don't need to care about this
3666 /// message or about BufferCollectionTokenGroup(s) in general.
3667 ///
3668 /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
3669 /// tokens. The child tokens which are not selected during aggregation will
3670 /// fail (close), which a potential participant should notice when their
3671 /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
3672 /// participant to clean up the speculative usage that didn't end up
3673 /// happening (similarly to a normal BufferCollection server end closing
3674 /// on failure of a logical buffer collection).
3675 ///
3676 /// See comments on protocol BufferCollectionTokenGroup.
3677 ///
3678 /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
3679 /// applied to the whole group can be achieved with a token for this purpose
3680 /// as a direct parent of the group.
3681 ///
3682 /// group_request - the server end of a BufferCollectionTokenGroup channel
3683 /// to be served by sysmem.
3684 pub fn r#create_buffer_collection_token_group(
3685 &self,
3686 mut group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
3687 ) -> Result<(), fidl::Error> {
3688 BufferCollectionTokenProxyInterface::r#create_buffer_collection_token_group(
3689 self,
3690 group_request,
3691 )
3692 }
3693}
3694
3695impl BufferCollectionTokenProxyInterface for BufferCollectionTokenProxy {
3696 type SyncResponseFut =
3697 fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
3698 fn r#sync(&self) -> Self::SyncResponseFut {
3699 fn _decode(
3700 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3701 ) -> Result<(), fidl::Error> {
3702 let _response = fidl::client::decode_transaction_body::<
3703 fidl::encoding::EmptyPayload,
3704 fdomain_client::fidl::FDomainResourceDialect,
3705 0x4577e238ae26291,
3706 >(_buf?)?;
3707 Ok(_response)
3708 }
3709 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3710 (),
3711 0x4577e238ae26291,
3712 fidl::encoding::DynamicFlags::empty(),
3713 _decode,
3714 )
3715 }
3716
3717 fn r#close(&self) -> Result<(), fidl::Error> {
3718 self.client.send::<fidl::encoding::EmptyPayload>(
3719 (),
3720 0x5b1d7a4f5681fca7,
3721 fidl::encoding::DynamicFlags::empty(),
3722 )
3723 }
3724
3725 fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
3726 self.client.send::<NodeSetNameRequest>(
3727 (priority, name),
3728 0x77a41bb6217e2443,
3729 fidl::encoding::DynamicFlags::empty(),
3730 )
3731 }
3732
3733 fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
3734 self.client.send::<NodeSetDebugClientInfoRequest>(
3735 (name, id),
3736 0x7275759070eb5ee2,
3737 fidl::encoding::DynamicFlags::empty(),
3738 )
3739 }
3740
3741 fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
3742 self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
3743 (deadline,),
3744 0x46d38f4772638867,
3745 fidl::encoding::DynamicFlags::empty(),
3746 )
3747 }
3748
3749 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
3750 self.client.send::<fidl::encoding::EmptyPayload>(
3751 (),
3752 0x6bfbe2cf1701d288,
3753 fidl::encoding::DynamicFlags::empty(),
3754 )
3755 }
3756
3757 type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
3758 fdomain_client::Event,
3759 fdomain_client::fidl::FDomainResourceDialect,
3760 >;
3761 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
3762 fn _decode(
3763 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3764 ) -> Result<fdomain_client::Event, fidl::Error> {
3765 let _response = fidl::client::decode_transaction_body::<
3766 NodeGetNodeRefResponse,
3767 fdomain_client::fidl::FDomainResourceDialect,
3768 0x467b7c75c35c3b84,
3769 >(_buf?)?;
3770 Ok(_response.node_ref)
3771 }
3772 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
3773 (),
3774 0x467b7c75c35c3b84,
3775 fidl::encoding::DynamicFlags::empty(),
3776 _decode,
3777 )
3778 }
3779
3780 type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
3781 NodeIsAlternateForResult,
3782 fdomain_client::fidl::FDomainResourceDialect,
3783 >;
3784 fn r#is_alternate_for(
3785 &self,
3786 mut node_ref: fdomain_client::Event,
3787 ) -> Self::IsAlternateForResponseFut {
3788 fn _decode(
3789 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3790 ) -> Result<NodeIsAlternateForResult, fidl::Error> {
3791 let _response = fidl::client::decode_transaction_body::<
3792 fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
3793 fdomain_client::fidl::FDomainResourceDialect,
3794 0x33a2a7aff2776c07,
3795 >(_buf?)?;
3796 Ok(_response.map(|x| x.is_alternate))
3797 }
3798 self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
3799 (node_ref,),
3800 0x33a2a7aff2776c07,
3801 fidl::encoding::DynamicFlags::empty(),
3802 _decode,
3803 )
3804 }
3805
3806 type DuplicateSyncResponseFut = fidl::client::QueryResponseFut<
3807 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3808 fdomain_client::fidl::FDomainResourceDialect,
3809 >;
3810 fn r#duplicate_sync(
3811 &self,
3812 mut rights_attenuation_masks: &[fidl::Rights],
3813 ) -> Self::DuplicateSyncResponseFut {
3814 fn _decode(
3815 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3816 ) -> Result<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
3817 {
3818 let _response = fidl::client::decode_transaction_body::<
3819 BufferCollectionTokenDuplicateSyncResponse,
3820 fdomain_client::fidl::FDomainResourceDialect,
3821 0x49ed7ab7cc19f18,
3822 >(_buf?)?;
3823 Ok(_response.tokens)
3824 }
3825 self.client.send_query_and_decode::<
3826 BufferCollectionTokenDuplicateSyncRequest,
3827 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
3828 >(
3829 (rights_attenuation_masks,),
3830 0x49ed7ab7cc19f18,
3831 fidl::encoding::DynamicFlags::empty(),
3832 _decode,
3833 )
3834 }
3835
3836 fn r#duplicate(
3837 &self,
3838 mut rights_attenuation_mask: u32,
3839 mut token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
3840 ) -> Result<(), fidl::Error> {
3841 self.client.send::<BufferCollectionTokenDuplicateRequest>(
3842 (rights_attenuation_mask, token_request),
3843 0x2f9f81bdde4b7292,
3844 fidl::encoding::DynamicFlags::empty(),
3845 )
3846 }
3847
3848 fn r#set_dispensable(&self) -> Result<(), fidl::Error> {
3849 self.client.send::<fidl::encoding::EmptyPayload>(
3850 (),
3851 0x76e4ec34fc2cf5b3,
3852 fidl::encoding::DynamicFlags::empty(),
3853 )
3854 }
3855
3856 fn r#create_buffer_collection_token_group(
3857 &self,
3858 mut group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
3859 ) -> Result<(), fidl::Error> {
3860 self.client.send::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
3861 (group_request,),
3862 0x2f6243e05f22b9a7,
3863 fidl::encoding::DynamicFlags::empty(),
3864 )
3865 }
3866}
3867
3868pub struct BufferCollectionTokenEventStream {
3869 event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3870}
3871
3872impl std::marker::Unpin for BufferCollectionTokenEventStream {}
3873
3874impl futures::stream::FusedStream for BufferCollectionTokenEventStream {
3875 fn is_terminated(&self) -> bool {
3876 self.event_receiver.is_terminated()
3877 }
3878}
3879
3880impl futures::Stream for BufferCollectionTokenEventStream {
3881 type Item = Result<BufferCollectionTokenEvent, fidl::Error>;
3882
3883 fn poll_next(
3884 mut self: std::pin::Pin<&mut Self>,
3885 cx: &mut std::task::Context<'_>,
3886 ) -> std::task::Poll<Option<Self::Item>> {
3887 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3888 &mut self.event_receiver,
3889 cx
3890 )?) {
3891 Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenEvent::decode(buf))),
3892 None => std::task::Poll::Ready(None),
3893 }
3894 }
3895}
3896
3897#[derive(Debug)]
3898pub enum BufferCollectionTokenEvent {}
3899
3900impl BufferCollectionTokenEvent {
3901 /// Decodes a message buffer as a [`BufferCollectionTokenEvent`].
3902 fn decode(
3903 mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3904 ) -> Result<BufferCollectionTokenEvent, fidl::Error> {
3905 let (bytes, _handles) = buf.split_mut();
3906 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3907 debug_assert_eq!(tx_header.tx_id, 0);
3908 match tx_header.ordinal {
3909 _ => Err(fidl::Error::UnknownOrdinal {
3910 ordinal: tx_header.ordinal,
3911 protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3912 })
3913 }
3914 }
3915}
3916
3917/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionToken.
3918pub struct BufferCollectionTokenRequestStream {
3919 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3920 is_terminated: bool,
3921}
3922
3923impl std::marker::Unpin for BufferCollectionTokenRequestStream {}
3924
3925impl futures::stream::FusedStream for BufferCollectionTokenRequestStream {
3926 fn is_terminated(&self) -> bool {
3927 self.is_terminated
3928 }
3929}
3930
3931impl fdomain_client::fidl::RequestStream for BufferCollectionTokenRequestStream {
3932 type Protocol = BufferCollectionTokenMarker;
3933 type ControlHandle = BufferCollectionTokenControlHandle;
3934
3935 fn from_channel(channel: fdomain_client::Channel) -> Self {
3936 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3937 }
3938
3939 fn control_handle(&self) -> Self::ControlHandle {
3940 BufferCollectionTokenControlHandle { inner: self.inner.clone() }
3941 }
3942
3943 fn into_inner(
3944 self,
3945 ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3946 {
3947 (self.inner, self.is_terminated)
3948 }
3949
3950 fn from_inner(
3951 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3952 is_terminated: bool,
3953 ) -> Self {
3954 Self { inner, is_terminated }
3955 }
3956}
3957
3958impl futures::Stream for BufferCollectionTokenRequestStream {
3959 type Item = Result<BufferCollectionTokenRequest, fidl::Error>;
3960
3961 fn poll_next(
3962 mut self: std::pin::Pin<&mut Self>,
3963 cx: &mut std::task::Context<'_>,
3964 ) -> std::task::Poll<Option<Self::Item>> {
3965 let this = &mut *self;
3966 if this.inner.check_shutdown(cx) {
3967 this.is_terminated = true;
3968 return std::task::Poll::Ready(None);
3969 }
3970 if this.is_terminated {
3971 panic!("polled BufferCollectionTokenRequestStream after completion");
3972 }
3973 fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3974 |bytes, handles| {
3975 match this.inner.channel().read_etc(cx, bytes, handles) {
3976 std::task::Poll::Ready(Ok(())) => {}
3977 std::task::Poll::Pending => return std::task::Poll::Pending,
3978 std::task::Poll::Ready(Err(None)) => {
3979 this.is_terminated = true;
3980 return std::task::Poll::Ready(None);
3981 }
3982 std::task::Poll::Ready(Err(Some(e))) => {
3983 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3984 e.into(),
3985 ))));
3986 }
3987 }
3988
3989 // A message has been received from the channel
3990 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3991
3992 std::task::Poll::Ready(Some(match header.ordinal {
3993 0x4577e238ae26291 => {
3994 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3995 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
3996 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3997 let control_handle = BufferCollectionTokenControlHandle {
3998 inner: this.inner.clone(),
3999 };
4000 Ok(BufferCollectionTokenRequest::Sync {
4001 responder: BufferCollectionTokenSyncResponder {
4002 control_handle: std::mem::ManuallyDrop::new(control_handle),
4003 tx_id: header.tx_id,
4004 },
4005 })
4006 }
4007 0x5b1d7a4f5681fca7 => {
4008 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4009 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4010 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4011 let control_handle = BufferCollectionTokenControlHandle {
4012 inner: this.inner.clone(),
4013 };
4014 Ok(BufferCollectionTokenRequest::Close {
4015 control_handle,
4016 })
4017 }
4018 0x77a41bb6217e2443 => {
4019 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4020 let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
4021 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
4022 let control_handle = BufferCollectionTokenControlHandle {
4023 inner: this.inner.clone(),
4024 };
4025 Ok(BufferCollectionTokenRequest::SetName {priority: req.priority,
4026name: req.name,
4027
4028 control_handle,
4029 })
4030 }
4031 0x7275759070eb5ee2 => {
4032 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4033 let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
4034 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
4035 let control_handle = BufferCollectionTokenControlHandle {
4036 inner: this.inner.clone(),
4037 };
4038 Ok(BufferCollectionTokenRequest::SetDebugClientInfo {name: req.name,
4039id: req.id,
4040
4041 control_handle,
4042 })
4043 }
4044 0x46d38f4772638867 => {
4045 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4046 let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
4047 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
4048 let control_handle = BufferCollectionTokenControlHandle {
4049 inner: this.inner.clone(),
4050 };
4051 Ok(BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
4052
4053 control_handle,
4054 })
4055 }
4056 0x6bfbe2cf1701d288 => {
4057 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4058 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4059 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4060 let control_handle = BufferCollectionTokenControlHandle {
4061 inner: this.inner.clone(),
4062 };
4063 Ok(BufferCollectionTokenRequest::SetVerboseLogging {
4064 control_handle,
4065 })
4066 }
4067 0x467b7c75c35c3b84 => {
4068 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4069 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4070 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4071 let control_handle = BufferCollectionTokenControlHandle {
4072 inner: this.inner.clone(),
4073 };
4074 Ok(BufferCollectionTokenRequest::GetNodeRef {
4075 responder: BufferCollectionTokenGetNodeRefResponder {
4076 control_handle: std::mem::ManuallyDrop::new(control_handle),
4077 tx_id: header.tx_id,
4078 },
4079 })
4080 }
4081 0x33a2a7aff2776c07 => {
4082 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4083 let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
4084 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
4085 let control_handle = BufferCollectionTokenControlHandle {
4086 inner: this.inner.clone(),
4087 };
4088 Ok(BufferCollectionTokenRequest::IsAlternateFor {node_ref: req.node_ref,
4089
4090 responder: BufferCollectionTokenIsAlternateForResponder {
4091 control_handle: std::mem::ManuallyDrop::new(control_handle),
4092 tx_id: header.tx_id,
4093 },
4094 })
4095 }
4096 0x49ed7ab7cc19f18 => {
4097 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4098 let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
4099 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateSyncRequest>(&header, _body_bytes, handles, &mut req)?;
4100 let control_handle = BufferCollectionTokenControlHandle {
4101 inner: this.inner.clone(),
4102 };
4103 Ok(BufferCollectionTokenRequest::DuplicateSync {rights_attenuation_masks: req.rights_attenuation_masks,
4104
4105 responder: BufferCollectionTokenDuplicateSyncResponder {
4106 control_handle: std::mem::ManuallyDrop::new(control_handle),
4107 tx_id: header.tx_id,
4108 },
4109 })
4110 }
4111 0x2f9f81bdde4b7292 => {
4112 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4113 let mut req = fidl::new_empty!(BufferCollectionTokenDuplicateRequest, fdomain_client::fidl::FDomainResourceDialect);
4114 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenDuplicateRequest>(&header, _body_bytes, handles, &mut req)?;
4115 let control_handle = BufferCollectionTokenControlHandle {
4116 inner: this.inner.clone(),
4117 };
4118 Ok(BufferCollectionTokenRequest::Duplicate {rights_attenuation_mask: req.rights_attenuation_mask,
4119token_request: req.token_request,
4120
4121 control_handle,
4122 })
4123 }
4124 0x76e4ec34fc2cf5b3 => {
4125 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4126 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4127 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4128 let control_handle = BufferCollectionTokenControlHandle {
4129 inner: this.inner.clone(),
4130 };
4131 Ok(BufferCollectionTokenRequest::SetDispensable {
4132 control_handle,
4133 })
4134 }
4135 0x2f6243e05f22b9a7 => {
4136 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4137 let mut req = fidl::new_empty!(BufferCollectionTokenCreateBufferCollectionTokenGroupRequest, fdomain_client::fidl::FDomainResourceDialect);
4138 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(&header, _body_bytes, handles, &mut req)?;
4139 let control_handle = BufferCollectionTokenControlHandle {
4140 inner: this.inner.clone(),
4141 };
4142 Ok(BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {group_request: req.group_request,
4143
4144 control_handle,
4145 })
4146 }
4147 _ => Err(fidl::Error::UnknownOrdinal {
4148 ordinal: header.ordinal,
4149 protocol_name: <BufferCollectionTokenMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4150 }),
4151 }))
4152 },
4153 )
4154 }
4155}
4156
4157/// A BufferCollectionToken is not a BufferCollection, but rather a way to
4158/// identify a potential shared BufferCollection prior to the BufferCollection
4159/// being allocated.
4160///
4161/// We use a channel for the BufferCollectionToken instead of a single eventpair
4162/// (pair) because this way we can detect error conditions like a participant
4163/// dying mid-create.
4164///
4165/// The fuchsia.sysmem.BufferCollectionToken type is not yet deprecated due to
4166/// its use in some other protocols (for now), but all the internals of
4167/// fuchsia.sysmem.BufferCollectionToken are deprecated. Token channels serve
4168/// both fuchsia.sysmem.BufferCollectionToken and
4169/// fuchsia.sysmem2.BufferCollectionToken.
4170///
4171/// This protocol will be deprecated once other protocols have switched their
4172/// token fields to fuchsia.sysmem2.BufferCollectionToken.
4173#[derive(Debug)]
4174pub enum BufferCollectionTokenRequest {
4175 /// Ensure that previous messages, including Duplicate() messages on a
4176 /// token, collection, or group, have been received server side.
4177 ///
4178 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
4179 /// valid sysmem token risks the Sync() hanging forever. See
4180 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
4181 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
4182 /// Another way is to pass the token to BindSharedCollection(), which also
4183 /// validates the token as part of exchanging it for a BufferCollection
4184 /// channel, and BufferCollection Sync() can then be used.
4185 ///
4186 /// After a Sync(), it's then safe to send the client end of token_request
4187 /// to another participant knowing the server will recognize the token when
4188 /// it's sent into BindSharedCollection() by the other participant.
4189 ///
4190 /// Other options include waiting for each token.Duplicate() to complete
4191 /// individually (using separate call to token.Sync() after each), or
4192 /// calling Sync() on BufferCollection after the token has been turned in
4193 /// via BindSharedCollection().
4194 ///
4195 /// Another way to mitigate is to avoid calling Sync() on the token, and
4196 /// instead later deal with potential failure of BufferCollection.Sync() if
4197 /// the original token was invalid. This option can be preferable from a
4198 /// performance point of view, but requires client code to delay sending
4199 /// tokens duplicated from this token until after client code has converted
4200 /// the duplicating token to a BufferCollection and received successful
4201 /// response from BufferCollection.Sync().
4202 ///
4203 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
4204 /// When BufferCollection.Sync() isn't feasible, the caller must already
4205 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
4206 /// hang forever. See ValidateBufferCollectionToken() to check token
4207 /// validity first if the token isn't already known to be (is/was) valid.
4208 Sync { responder: BufferCollectionTokenSyncResponder },
4209 /// On a BufferCollectionToken channel:
4210 ///
4211 /// Normally a participant will convert a BufferCollectionToken into a
4212 /// BufferCollection view, but a participant is also free to Close() the
4213 /// token (and then close the channel immediately or shortly later in
4214 /// response to server closing its end), which avoids causing logical buffer
4215 /// collection failure. Â Normally an unexpected token channel close will
4216 /// cause logical buffer collection failure (the only exceptions being
4217 /// certain cases involving AttachToken() or SetDispensable()).
4218 ///
4219 /// On a BufferCollection channel:
4220 ///
4221 /// By default the server handles unexpected failure of a BufferCollection
4222 /// by failing the whole logical buffer collection. Partly this is to
4223 /// expedite closing VMO handles to reclaim memory when any participant
4224 /// fails. If a participant would like to cleanly close a BufferCollection
4225 /// view without causing logical buffer collection failure, the participant
4226 /// can send Close() before closing the client end of the BufferCollection
4227 /// channel. If this is the last BufferCollection view, the logical buffer
4228 /// collection will still go away. The Close() can occur before or after
4229 /// SetConstraints(). If before SetConstraints(), the buffer collection
4230 /// won't require constraints from this node in order to allocate. If
4231 /// after SetConstraints(), the constraints are retained and aggregated
4232 /// along with any subsequent logical allocation(s), despite the lack of
4233 /// channel connection.
4234 ///
4235 /// On a BufferCollectionTokenGroup channel:
4236 ///
4237 /// By default, unexpected failure of a BufferCollectionTokenGroup will
4238 /// trigger failure of the logical BufferCollectionTokenGroup and will
4239 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
4240 /// channel without failing the logical group or propagating failure, send
4241 /// Close() before closing the channel client endpoint.
4242 ///
4243 /// If Close() occurs before AllChildrenPresent(), the logical buffer
4244 /// collection will still fail despite the Close() (because sysmem can't be
4245 /// sure whether all relevant children were created, so it's ambiguous
4246 /// whether all relevant constraints will be provided to sysmem). If
4247 /// Close() occurs after AllChildrenPresent(), the children and all their
4248 /// constraints remain intact (just as they would if the
4249 /// BufferCollectionTokenGroup channel had remained open), and the close
4250 /// doesn't trigger or propagate failure.
4251 Close { control_handle: BufferCollectionTokenControlHandle },
4252 /// Set a name for VMOs in this buffer collection. The name may be truncated
4253 /// shorter. The name only affects VMOs allocated after it's set - this call
4254 /// does not rename existing VMOs. If multiple clients set different names
4255 /// then the larger priority value will win.
4256 SetName { priority: u32, name: String, control_handle: BufferCollectionTokenControlHandle },
4257 /// Set information about the current client that can be used by sysmem to
4258 /// help debug leaking memory and hangs waiting for constraints. |name| can
4259 /// be an arbitrary string, but the current process name (see
4260 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
4261 /// arbitrary id, but the current process ID (see
4262 /// fsl::GetCurrentProcessKoid()) is a good default.
4263 ///
4264 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
4265 /// indicate which client is closing their channel first, leading to
4266 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
4267 /// over, but if happening earlier than expected, the
4268 /// client-channel-specific name can help diagnose where the failure is
4269 /// first coming from, from sysmem's point of view).
4270 ///
4271 /// By default (unless overriden by this message or using
4272 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
4273 /// parent Node at the time the child Node is created. While this can be
4274 /// better than nothing, it's often better for each participant to use
4275 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
4276 /// info directly relevant to the current client. Also, SetVerboseLogging()
4277 /// can be used to help disambiguate if a Node is suspected of having info
4278 /// that was copied from its parent.
4279 SetDebugClientInfo { name: String, id: u64, control_handle: BufferCollectionTokenControlHandle },
4280 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
4281 /// after creating a collection. Clients can call this method to change
4282 /// when the log is printed. If multiple client set the deadline, it's
4283 /// unspecified which deadline will take effect.
4284 SetDebugTimeoutLogDeadline { deadline: i64, control_handle: BufferCollectionTokenControlHandle },
4285 /// Verbose logging includes constraints set via SetConstraints() from each
4286 /// client along with info set via SetDebugClientInfo() and the structure of
4287 /// the tree of Node(s).
4288 ///
4289 /// Normally sysmem prints only a single line complaint when aggregation
4290 /// fails, with just the specific detailed reason that aggregation failed,
4291 /// with minimal context. While this is often enough to diagnose a problem
4292 /// if only a small change was made and the system had been working before
4293 /// the small change, it's often not particularly helpful for getting a new
4294 /// buffer collection to work for the first time. Especially with more
4295 /// complex trees of nodes, involving things like AttachToken(),
4296 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
4297 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
4298 /// looks like and why it's failing a logical allocation, or why a tree or
4299 /// sub-tree is failing sooner than expected.
4300 ///
4301 /// The intent of the extra logging is to be acceptable from a performance
4302 /// point of view, if only enabled on a low number of buffer collections.
4303 /// If we're not tracking down a bug, we shouldn't send this message.
4304 ///
4305 /// If too many participants leave verbose logging enabled, we may end up
4306 /// needing to require that system-wide sysmem verbose logging be permitted
4307 /// via some other setting, to avoid sysmem spamming the log too much due to
4308 /// this message.
4309 ///
4310 /// This may be a NOP for some nodes due to intentional policy associated
4311 /// with the node, if we don't trust a node enough to let it turn on verbose
4312 /// logging.
4313 SetVerboseLogging { control_handle: BufferCollectionTokenControlHandle },
4314 /// This gets an event handle that can be used as a parameter to
4315 /// IsAlternateFor() called on any Node. The client will not be granted the
4316 /// right to signal this event, as this handle should only be used as proof
4317 /// that the client obtained this handle from this Node.
4318 ///
4319 /// Because this is a get not a set, no Sync() is needed between the
4320 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
4321 /// potentially being on different channels.
4322 ///
4323 /// See also IsAlternateFor().
4324 GetNodeRef { responder: BufferCollectionTokenGetNodeRefResponder },
4325 /// This checks whether the calling node is in a subtree rooted at a
4326 /// different child token of a common parent BufferCollectionTokenGroup, in
4327 /// relation to the passed-in node_ref.
4328 ///
4329 /// This call is for assisting with admission control de-duplication, and
4330 /// with debugging.
4331 ///
4332 /// The node_ref must be obtained using GetNodeRef() of a
4333 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
4334 ///
4335 /// The node_ref can be a duplicated handle; it's not necessary to call
4336 /// GetNodeRef() for every call to IsAlternateFor().
4337 ///
4338 /// If a calling token may not actually be a valid token at all due to
4339 /// a potentially hostile/untrusted provider of the token, call
4340 /// ValidateBufferCollectionToken() first instead of potentially getting
4341 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
4342 /// token not being a real token (not really talking to sysmem). Another
4343 /// option is to call BindSharedCollection with this token first which also
4344 /// validates the token along with converting it to a BufferCollection, then
4345 /// call BufferCollection IsAlternateFor().
4346 ///
4347 /// error values:
4348 ///
4349 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
4350 /// buffer collection as the calling Node. Before logical allocation and
4351 /// within the same logical allocation sub-tree, this essentially means that
4352 /// the node_ref was never part of this logical buffer collection, since
4353 /// before logical allocation all node_refs that come into existence remain
4354 /// in existence at least until logical allocation (including Node(s) that
4355 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
4356 /// to be returned, this Node's channel needs to still be connected server
4357 /// side, which won't be the case if the whole logical allocation has
4358 /// failed. After logical allocation or in a different logical allocation
4359 /// sub-tree there are additional potential reasons for this error. For
4360 /// example a different logical allocation (separated from this Node(s)
4361 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
4362 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
4363 /// exist and may select a different child sub-tree than the sub-tree the
4364 /// node_ref is in causing deletion of the node_ref Node. The only time
4365 /// sysmem keeps a Node around after that Node has no corresponding channel
4366 /// is when Close() is used and the Node's sub-tree has not yet failed.
4367 /// Another reason for this error is if the node_ref is an eventpair handle
4368 /// with sufficient rights, but isn't actually a real node_ref obtained from
4369 /// GetNodeRef().
4370 ///
4371 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
4372 /// eventpair handle, or doesn't have the needed rights expected on a real
4373 /// node_ref.
4374 ///
4375 /// No other failing status codes are returned by this call. However,
4376 /// sysmem may add additional codes in future, so the client should have
4377 /// sensible default handling for any failing status code.
4378 ///
4379 /// On success, is_alternate has the following meaning:
4380 /// * true - The first parent node in common between the calling node and
4381 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
4382 /// the calling Node and the node_ref Node will _not_ have both their
4383 /// constraints apply - rather sysmem will choose one or the other of
4384 /// the constraints - never both. This is because only one child of
4385 /// a BufferCollectionTokenGroup is selected during logical allocation,
4386 /// with only that one child's sub-tree contributing to constraints
4387 /// aggregation.
4388 /// * false - The first parent node in common between the calling Node and
4389 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
4390 /// this means the first parent node in common is a
4391 /// BufferCollectionToken or BufferCollection (regardless of not
4392 /// Close()ed or Close()ed). This means that the calling Node and the
4393 /// node_ref Node _may_ have both their constraints apply during
4394 /// constraints aggregation of the logical allocation, if both Node(s)
4395 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
4396 /// In this case, there is no BufferCollectionTokenGroup that will
4397 /// directly prevent the two Node(s) from both being selected and their
4398 /// constraints both aggregated, but even when false, one or both
4399 /// Node(s) may still be eliminated from consideration if one or both
4400 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
4401 /// which selects a child sub-tree other than the sub-tree containing
4402 /// the calling Node or node_ref Node.
4403 IsAlternateFor {
4404 node_ref: fdomain_client::Event,
4405 responder: BufferCollectionTokenIsAlternateForResponder,
4406 },
4407 /// This method can be used to add more participants prior to creating a
4408 /// shared BufferCollection. A new token will be returned for each entry in
4409 /// the `rights_attenuation_masks` array. The return value is the client
4410 /// ends of each new participant token.
4411 ///
4412 /// If the calling token may not actually be a valid token at all due to
4413 /// a potentially hostile/untrusted provider of the token, consider using
4414 /// ValidateBufferCollectionToken() first instead of potentially getting
4415 /// stuck indefinitely if DuplicateSync() never responds due to the calling
4416 /// token not being a real token.
4417 ///
4418 /// In contrast to Duplicate(), no Sync() (see "protocol Node") is needed
4419 /// after calling this method.
4420 ///
4421 /// All tokens must be turned in via BindSharedCollection() or Close() for a
4422 /// BufferCollection to be successfully created.
4423 ///
4424 /// In each entry of `rights_attenuation_masks`, rights bits that are zero
4425 /// will be absent in the buffer VMO rights obtainable via the corresponding
4426 /// returned token. This allows an initiator or intermediary participant to
4427 /// attenuate the rights available to a participant. This does not allow a
4428 /// participant to gain rights that the participant doesn't already have.
4429 /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4430 /// attenuation should be applied.
4431 DuplicateSync {
4432 rights_attenuation_masks: Vec<fidl::Rights>,
4433 responder: BufferCollectionTokenDuplicateSyncResponder,
4434 },
4435 /// This method can be used to add a participant prior to creating a shared
4436 /// BufferCollection. It should only be used instead of DuplicateSync in
4437 /// performance sensitive cases where it would be undesireable to wait for
4438 /// sysmem to respond as part of each duplicate.
4439 ///
4440 /// After sending one or more Duplicate() messages, and before sending the
4441 /// created tokens to other participants (or to other Allocator channels),
4442 /// the client should send a Sync() and wait for its response. The Sync()
4443 /// call can be made on the token, or on the BufferCollection obtained by
4444 /// passing this token to BindSharedCollection(). Either will ensure that
4445 /// the server knows about the tokens created via Duplicate() before the
4446 /// other participant sends the token to the server via separate Allocator
4447 /// channel.
4448 ///
4449 /// All tokens must be turned in via BindSharedCollection() or Close() for a
4450 /// BufferCollection to be successfully created.
4451 ///
4452 /// When a client calls BindSharedCollection() to turn in a
4453 /// BufferCollectionToken, the server will process all Duplicate() messages
4454 /// before closing down the BufferCollectionToken. This allows the client
4455 /// to Duplicate() and immediately turn in the BufferCollectionToken using
4456 /// BindSharedCollection, then later transfer the client end of token_request
4457 /// to another participant - the server will notice the existence of the
4458 /// token_request before considering this BufferCollectionToken fully closed.
4459 ///
4460 /// `rights_attenuation_mask` rights bits that are zero in this mask will be
4461 /// absent in the buffer VMO rights obtainable via the client end of
4462 /// token_request. This allows an initiator or intermediary participant to
4463 /// attenuate the rights available to a participant. This does not allow a
4464 /// participant to gain rights that the participant doesn't already have.
4465 /// The value ZX_RIGHT_SAME_RIGHTS can be used to specify that no
4466 /// attenuation should be applied.
4467 ///
4468 /// These values for rights_attenuation_mask result in no attenuation:
4469 /// * ZX_RIGHT_SAME_RIGHTS (preferred)
4470 /// * 0xFFFFFFFF (this is reasonable when an attenuation mask is computed)
4471 /// * 0 (deprecated - do not use 0 - an ERROR will go to the log)
4472 ///
4473 /// `token_request` is the server end of a BufferCollectionToken channel.
4474 /// The client end of this channel acts as another participant in creating the
4475 /// shared BufferCollection.
4476 Duplicate {
4477 rights_attenuation_mask: u32,
4478 token_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
4479 control_handle: BufferCollectionTokenControlHandle,
4480 },
4481 /// A dispensable token can fail after buffers are logically allocated
4482 /// without causing failure of its parent (if any).
4483 ///
4484 /// The dispensable token participates in constraints aggregation along with
4485 /// its parent before logical buffer allocation. If the dispensable token
4486 /// fails before buffers are logically allocated, the failure propagates to
4487 /// the dispensable token's parent.
4488 ///
4489 /// After buffers are logically allocated, failure of the dispensable token
4490 /// (or any child of the dispensable token) does not propagate to the
4491 /// dispensable token's parent. Failure does propagate from a normal
4492 /// child of a dispensable token to the dispensable token. Failure
4493 /// of a child is blocked from reaching its parent if the child is attached,
4494 /// or if the child is dispensable and the failure occurred after logical
4495 /// allocation.
4496 ///
4497 /// A dispensable token can be used in cases where a participant needs to
4498 /// provide constraints, but after buffers are allocated, the participant
4499 /// can fail without causing buffer collection failure from the parent's
4500 /// point of view.
4501 ///
4502 /// In contrast, AttachToken() can be used to create a token which does not
4503 /// participate in constraints aggregation with its parent, and whose
4504 /// failure at any time does not propagate to its parent, and whose delay
4505 /// providing constraints does not prevent the parent from completing its
4506 /// buffer allocation.
4507 ///
4508 /// An initiator may in some scenarios choose to initially use a dispensable
4509 /// token for a given instance of a participant, and then later if the first
4510 /// instance of that participant fails, a new second instance of that
4511 /// participant my be given a token created with AttachToken().
4512 ///
4513 /// If a client uses this message, the client should not rely on the
4514 /// client's own BufferCollectionToken or BufferCollection channel to close
4515 /// from the server end due to abrupt failure of any BufferCollectionToken
4516 /// or BufferCollection that the client has SetDispensable() and given out
4517 /// to another process. For this reason, the client should take extra care
4518 /// to notice failure of that other process via other means.
4519 ///
4520 /// While it is possible (and potentially useful) to SetDispensable() on a
4521 /// direct child of a BufferCollectionTokenGroup, it isn't possible to later
4522 /// replace a failed dispensable token that was a direct child of a group
4523 /// with a new token using AttachToken() (since there's no AttachToken() on
4524 /// a group). Instead, to enable AttachToken() replacement in this case,
4525 /// create an additional non-dispensable token (node) that's a direct child
4526 /// of the group and make the existing dispensable token a child of the
4527 /// additional token (node). This way, the additional token (node) that is
4528 /// a direct child of the group has BufferCollection.AttachToken() which can
4529 /// be used to replace the failed dispensable token.
4530 ///
4531 /// SetDispensable() on an already-dispensable token is idempotent.
4532 SetDispensable { control_handle: BufferCollectionTokenControlHandle },
4533 /// Most sysmem clients and many participants don't need to care about this
4534 /// message or about BufferCollectionTokenGroup(s) in general.
4535 ///
4536 /// A BufferCollectionTokenGroup is used to create a 1 of N OR among N child
4537 /// tokens. The child tokens which are not selected during aggregation will
4538 /// fail (close), which a potential participant should notice when their
4539 /// BufferCollection channel client endpoint sees PEER_CLOSED, allowing the
4540 /// participant to clean up the speculative usage that didn't end up
4541 /// happening (similarly to a normal BufferCollection server end closing
4542 /// on failure of a logical buffer collection).
4543 ///
4544 /// See comments on protocol BufferCollectionTokenGroup.
4545 ///
4546 /// Any rights_attenuation_mask or AttachToken()/SetDispensable() to be
4547 /// applied to the whole group can be achieved with a token for this purpose
4548 /// as a direct parent of the group.
4549 ///
4550 /// group_request - the server end of a BufferCollectionTokenGroup channel
4551 /// to be served by sysmem.
4552 CreateBufferCollectionTokenGroup {
4553 group_request: fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
4554 control_handle: BufferCollectionTokenControlHandle,
4555 },
4556}
4557
4558impl BufferCollectionTokenRequest {
4559 #[allow(irrefutable_let_patterns)]
4560 pub fn into_sync(self) -> Option<(BufferCollectionTokenSyncResponder)> {
4561 if let BufferCollectionTokenRequest::Sync { responder } = self {
4562 Some((responder))
4563 } else {
4564 None
4565 }
4566 }
4567
4568 #[allow(irrefutable_let_patterns)]
4569 pub fn into_close(self) -> Option<(BufferCollectionTokenControlHandle)> {
4570 if let BufferCollectionTokenRequest::Close { control_handle } = self {
4571 Some((control_handle))
4572 } else {
4573 None
4574 }
4575 }
4576
4577 #[allow(irrefutable_let_patterns)]
4578 pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenControlHandle)> {
4579 if let BufferCollectionTokenRequest::SetName { priority, name, control_handle } = self {
4580 Some((priority, name, control_handle))
4581 } else {
4582 None
4583 }
4584 }
4585
4586 #[allow(irrefutable_let_patterns)]
4587 pub fn into_set_debug_client_info(
4588 self,
4589 ) -> Option<(String, u64, BufferCollectionTokenControlHandle)> {
4590 if let BufferCollectionTokenRequest::SetDebugClientInfo { name, id, control_handle } = self
4591 {
4592 Some((name, id, control_handle))
4593 } else {
4594 None
4595 }
4596 }
4597
4598 #[allow(irrefutable_let_patterns)]
4599 pub fn into_set_debug_timeout_log_deadline(
4600 self,
4601 ) -> Option<(i64, BufferCollectionTokenControlHandle)> {
4602 if let BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline {
4603 deadline,
4604 control_handle,
4605 } = self
4606 {
4607 Some((deadline, control_handle))
4608 } else {
4609 None
4610 }
4611 }
4612
4613 #[allow(irrefutable_let_patterns)]
4614 pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenControlHandle)> {
4615 if let BufferCollectionTokenRequest::SetVerboseLogging { control_handle } = self {
4616 Some((control_handle))
4617 } else {
4618 None
4619 }
4620 }
4621
4622 #[allow(irrefutable_let_patterns)]
4623 pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGetNodeRefResponder)> {
4624 if let BufferCollectionTokenRequest::GetNodeRef { responder } = self {
4625 Some((responder))
4626 } else {
4627 None
4628 }
4629 }
4630
4631 #[allow(irrefutable_let_patterns)]
4632 pub fn into_is_alternate_for(
4633 self,
4634 ) -> Option<(fdomain_client::Event, BufferCollectionTokenIsAlternateForResponder)> {
4635 if let BufferCollectionTokenRequest::IsAlternateFor { node_ref, responder } = self {
4636 Some((node_ref, responder))
4637 } else {
4638 None
4639 }
4640 }
4641
4642 #[allow(irrefutable_let_patterns)]
4643 pub fn into_duplicate_sync(
4644 self,
4645 ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenDuplicateSyncResponder)> {
4646 if let BufferCollectionTokenRequest::DuplicateSync { rights_attenuation_masks, responder } =
4647 self
4648 {
4649 Some((rights_attenuation_masks, responder))
4650 } else {
4651 None
4652 }
4653 }
4654
4655 #[allow(irrefutable_let_patterns)]
4656 pub fn into_duplicate(
4657 self,
4658 ) -> Option<(
4659 u32,
4660 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
4661 BufferCollectionTokenControlHandle,
4662 )> {
4663 if let BufferCollectionTokenRequest::Duplicate {
4664 rights_attenuation_mask,
4665 token_request,
4666 control_handle,
4667 } = self
4668 {
4669 Some((rights_attenuation_mask, token_request, control_handle))
4670 } else {
4671 None
4672 }
4673 }
4674
4675 #[allow(irrefutable_let_patterns)]
4676 pub fn into_set_dispensable(self) -> Option<(BufferCollectionTokenControlHandle)> {
4677 if let BufferCollectionTokenRequest::SetDispensable { control_handle } = self {
4678 Some((control_handle))
4679 } else {
4680 None
4681 }
4682 }
4683
4684 #[allow(irrefutable_let_patterns)]
4685 pub fn into_create_buffer_collection_token_group(
4686 self,
4687 ) -> Option<(
4688 fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
4689 BufferCollectionTokenControlHandle,
4690 )> {
4691 if let BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup {
4692 group_request,
4693 control_handle,
4694 } = self
4695 {
4696 Some((group_request, control_handle))
4697 } else {
4698 None
4699 }
4700 }
4701
4702 /// Name of the method defined in FIDL
4703 pub fn method_name(&self) -> &'static str {
4704 match *self {
4705 BufferCollectionTokenRequest::Sync { .. } => "sync",
4706 BufferCollectionTokenRequest::Close { .. } => "close",
4707 BufferCollectionTokenRequest::SetName { .. } => "set_name",
4708 BufferCollectionTokenRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
4709 BufferCollectionTokenRequest::SetDebugTimeoutLogDeadline { .. } => {
4710 "set_debug_timeout_log_deadline"
4711 }
4712 BufferCollectionTokenRequest::SetVerboseLogging { .. } => "set_verbose_logging",
4713 BufferCollectionTokenRequest::GetNodeRef { .. } => "get_node_ref",
4714 BufferCollectionTokenRequest::IsAlternateFor { .. } => "is_alternate_for",
4715 BufferCollectionTokenRequest::DuplicateSync { .. } => "duplicate_sync",
4716 BufferCollectionTokenRequest::Duplicate { .. } => "duplicate",
4717 BufferCollectionTokenRequest::SetDispensable { .. } => "set_dispensable",
4718 BufferCollectionTokenRequest::CreateBufferCollectionTokenGroup { .. } => {
4719 "create_buffer_collection_token_group"
4720 }
4721 }
4722 }
4723}
4724
4725#[derive(Debug, Clone)]
4726pub struct BufferCollectionTokenControlHandle {
4727 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4728}
4729
4730impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenControlHandle {
4731 fn shutdown(&self) {
4732 self.inner.shutdown()
4733 }
4734
4735 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4736 self.inner.shutdown_with_epitaph(status)
4737 }
4738
4739 fn is_closed(&self) -> bool {
4740 self.inner.channel().is_closed()
4741 }
4742 fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4743 self.inner.channel().on_closed()
4744 }
4745}
4746
4747impl BufferCollectionTokenControlHandle {}
4748
4749#[must_use = "FIDL methods require a response to be sent"]
4750#[derive(Debug)]
4751pub struct BufferCollectionTokenSyncResponder {
4752 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4753 tx_id: u32,
4754}
4755
4756/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4757/// if the responder is dropped without sending a response, so that the client
4758/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4759impl std::ops::Drop for BufferCollectionTokenSyncResponder {
4760 fn drop(&mut self) {
4761 self.control_handle.shutdown();
4762 // Safety: drops once, never accessed again
4763 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4764 }
4765}
4766
4767impl fdomain_client::fidl::Responder for BufferCollectionTokenSyncResponder {
4768 type ControlHandle = BufferCollectionTokenControlHandle;
4769
4770 fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4771 &self.control_handle
4772 }
4773
4774 fn drop_without_shutdown(mut self) {
4775 // Safety: drops once, never accessed again due to mem::forget
4776 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4777 // Prevent Drop from running (which would shut down the channel)
4778 std::mem::forget(self);
4779 }
4780}
4781
4782impl BufferCollectionTokenSyncResponder {
4783 /// Sends a response to the FIDL transaction.
4784 ///
4785 /// Sets the channel to shutdown if an error occurs.
4786 pub fn send(self) -> Result<(), fidl::Error> {
4787 let _result = self.send_raw();
4788 if _result.is_err() {
4789 self.control_handle.shutdown();
4790 }
4791 self.drop_without_shutdown();
4792 _result
4793 }
4794
4795 /// Similar to "send" but does not shutdown the channel if an error occurs.
4796 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4797 let _result = self.send_raw();
4798 self.drop_without_shutdown();
4799 _result
4800 }
4801
4802 fn send_raw(&self) -> Result<(), fidl::Error> {
4803 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4804 (),
4805 self.tx_id,
4806 0x4577e238ae26291,
4807 fidl::encoding::DynamicFlags::empty(),
4808 )
4809 }
4810}
4811
4812#[must_use = "FIDL methods require a response to be sent"]
4813#[derive(Debug)]
4814pub struct BufferCollectionTokenGetNodeRefResponder {
4815 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4816 tx_id: u32,
4817}
4818
4819/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4820/// if the responder is dropped without sending a response, so that the client
4821/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4822impl std::ops::Drop for BufferCollectionTokenGetNodeRefResponder {
4823 fn drop(&mut self) {
4824 self.control_handle.shutdown();
4825 // Safety: drops once, never accessed again
4826 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4827 }
4828}
4829
4830impl fdomain_client::fidl::Responder for BufferCollectionTokenGetNodeRefResponder {
4831 type ControlHandle = BufferCollectionTokenControlHandle;
4832
4833 fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4834 &self.control_handle
4835 }
4836
4837 fn drop_without_shutdown(mut self) {
4838 // Safety: drops once, never accessed again due to mem::forget
4839 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4840 // Prevent Drop from running (which would shut down the channel)
4841 std::mem::forget(self);
4842 }
4843}
4844
4845impl BufferCollectionTokenGetNodeRefResponder {
4846 /// Sends a response to the FIDL transaction.
4847 ///
4848 /// Sets the channel to shutdown if an error occurs.
4849 pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
4850 let _result = self.send_raw(node_ref);
4851 if _result.is_err() {
4852 self.control_handle.shutdown();
4853 }
4854 self.drop_without_shutdown();
4855 _result
4856 }
4857
4858 /// Similar to "send" but does not shutdown the channel if an error occurs.
4859 pub fn send_no_shutdown_on_err(
4860 self,
4861 mut node_ref: fdomain_client::Event,
4862 ) -> Result<(), fidl::Error> {
4863 let _result = self.send_raw(node_ref);
4864 self.drop_without_shutdown();
4865 _result
4866 }
4867
4868 fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
4869 self.control_handle.inner.send::<NodeGetNodeRefResponse>(
4870 (node_ref,),
4871 self.tx_id,
4872 0x467b7c75c35c3b84,
4873 fidl::encoding::DynamicFlags::empty(),
4874 )
4875 }
4876}
4877
4878#[must_use = "FIDL methods require a response to be sent"]
4879#[derive(Debug)]
4880pub struct BufferCollectionTokenIsAlternateForResponder {
4881 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4882 tx_id: u32,
4883}
4884
4885/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4886/// if the responder is dropped without sending a response, so that the client
4887/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4888impl std::ops::Drop for BufferCollectionTokenIsAlternateForResponder {
4889 fn drop(&mut self) {
4890 self.control_handle.shutdown();
4891 // Safety: drops once, never accessed again
4892 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4893 }
4894}
4895
4896impl fdomain_client::fidl::Responder for BufferCollectionTokenIsAlternateForResponder {
4897 type ControlHandle = BufferCollectionTokenControlHandle;
4898
4899 fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4900 &self.control_handle
4901 }
4902
4903 fn drop_without_shutdown(mut self) {
4904 // Safety: drops once, never accessed again due to mem::forget
4905 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4906 // Prevent Drop from running (which would shut down the channel)
4907 std::mem::forget(self);
4908 }
4909}
4910
4911impl BufferCollectionTokenIsAlternateForResponder {
4912 /// Sends a response to the FIDL transaction.
4913 ///
4914 /// Sets the channel to shutdown if an error occurs.
4915 pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4916 let _result = self.send_raw(result);
4917 if _result.is_err() {
4918 self.control_handle.shutdown();
4919 }
4920 self.drop_without_shutdown();
4921 _result
4922 }
4923
4924 /// Similar to "send" but does not shutdown the channel if an error occurs.
4925 pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4926 let _result = self.send_raw(result);
4927 self.drop_without_shutdown();
4928 _result
4929 }
4930
4931 fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
4932 self.control_handle
4933 .inner
4934 .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
4935 result.map(|is_alternate| (is_alternate,)),
4936 self.tx_id,
4937 0x33a2a7aff2776c07,
4938 fidl::encoding::DynamicFlags::empty(),
4939 )
4940 }
4941}
4942
4943#[must_use = "FIDL methods require a response to be sent"]
4944#[derive(Debug)]
4945pub struct BufferCollectionTokenDuplicateSyncResponder {
4946 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenControlHandle>,
4947 tx_id: u32,
4948}
4949
4950/// Set the the channel to be shutdown (see [`BufferCollectionTokenControlHandle::shutdown`])
4951/// if the responder is dropped without sending a response, so that the client
4952/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4953impl std::ops::Drop for BufferCollectionTokenDuplicateSyncResponder {
4954 fn drop(&mut self) {
4955 self.control_handle.shutdown();
4956 // Safety: drops once, never accessed again
4957 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4958 }
4959}
4960
4961impl fdomain_client::fidl::Responder for BufferCollectionTokenDuplicateSyncResponder {
4962 type ControlHandle = BufferCollectionTokenControlHandle;
4963
4964 fn control_handle(&self) -> &BufferCollectionTokenControlHandle {
4965 &self.control_handle
4966 }
4967
4968 fn drop_without_shutdown(mut self) {
4969 // Safety: drops once, never accessed again due to mem::forget
4970 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4971 // Prevent Drop from running (which would shut down the channel)
4972 std::mem::forget(self);
4973 }
4974}
4975
4976impl BufferCollectionTokenDuplicateSyncResponder {
4977 /// Sends a response to the FIDL transaction.
4978 ///
4979 /// Sets the channel to shutdown if an error occurs.
4980 pub fn send(
4981 self,
4982 mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
4983 ) -> Result<(), fidl::Error> {
4984 let _result = self.send_raw(tokens);
4985 if _result.is_err() {
4986 self.control_handle.shutdown();
4987 }
4988 self.drop_without_shutdown();
4989 _result
4990 }
4991
4992 /// Similar to "send" but does not shutdown the channel if an error occurs.
4993 pub fn send_no_shutdown_on_err(
4994 self,
4995 mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
4996 ) -> Result<(), fidl::Error> {
4997 let _result = self.send_raw(tokens);
4998 self.drop_without_shutdown();
4999 _result
5000 }
5001
5002 fn send_raw(
5003 &self,
5004 mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5005 ) -> Result<(), fidl::Error> {
5006 self.control_handle.inner.send::<BufferCollectionTokenDuplicateSyncResponse>(
5007 (tokens.as_mut(),),
5008 self.tx_id,
5009 0x49ed7ab7cc19f18,
5010 fidl::encoding::DynamicFlags::empty(),
5011 )
5012 }
5013}
5014
5015#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5016pub struct BufferCollectionTokenGroupMarker;
5017
5018impl fdomain_client::fidl::ProtocolMarker for BufferCollectionTokenGroupMarker {
5019 type Proxy = BufferCollectionTokenGroupProxy;
5020 type RequestStream = BufferCollectionTokenGroupRequestStream;
5021
5022 const DEBUG_NAME: &'static str = "(anonymous) BufferCollectionTokenGroup";
5023}
5024
5025pub trait BufferCollectionTokenGroupProxyInterface: Send + Sync {
5026 type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
5027 fn r#sync(&self) -> Self::SyncResponseFut;
5028 fn r#close(&self) -> Result<(), fidl::Error>;
5029 fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
5030 fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
5031 fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
5032 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
5033 type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
5034 + Send;
5035 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
5036 type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
5037 + Send;
5038 fn r#is_alternate_for(
5039 &self,
5040 node_ref: fdomain_client::Event,
5041 ) -> Self::IsAlternateForResponseFut;
5042 fn r#create_child(
5043 &self,
5044 payload: BufferCollectionTokenGroupCreateChildRequest,
5045 ) -> Result<(), fidl::Error>;
5046 type CreateChildrenSyncResponseFut: std::future::Future<
5047 Output = Result<
5048 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5049 fidl::Error,
5050 >,
5051 > + Send;
5052 fn r#create_children_sync(
5053 &self,
5054 rights_attenuation_masks: &[fidl::Rights],
5055 ) -> Self::CreateChildrenSyncResponseFut;
5056 fn r#all_children_present(&self) -> Result<(), fidl::Error>;
5057}
5058
5059#[derive(Debug, Clone)]
5060pub struct BufferCollectionTokenGroupProxy {
5061 client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
5062}
5063
5064impl fdomain_client::fidl::Proxy for BufferCollectionTokenGroupProxy {
5065 type Protocol = BufferCollectionTokenGroupMarker;
5066
5067 fn from_channel(inner: fdomain_client::Channel) -> Self {
5068 Self::new(inner)
5069 }
5070
5071 fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
5072 self.client.into_channel().map_err(|client| Self { client })
5073 }
5074
5075 fn as_channel(&self) -> &fdomain_client::Channel {
5076 self.client.as_channel()
5077 }
5078}
5079
5080impl BufferCollectionTokenGroupProxy {
5081 /// Create a new Proxy for fuchsia.sysmem/BufferCollectionTokenGroup.
5082 pub fn new(channel: fdomain_client::Channel) -> Self {
5083 let protocol_name =
5084 <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
5085 Self { client: fidl::client::Client::new(channel, protocol_name) }
5086 }
5087
5088 /// Get a Stream of events from the remote end of the protocol.
5089 ///
5090 /// # Panics
5091 ///
5092 /// Panics if the event stream was already taken.
5093 pub fn take_event_stream(&self) -> BufferCollectionTokenGroupEventStream {
5094 BufferCollectionTokenGroupEventStream { event_receiver: self.client.take_event_receiver() }
5095 }
5096
5097 /// Ensure that previous messages, including Duplicate() messages on a
5098 /// token, collection, or group, have been received server side.
5099 ///
5100 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5101 /// valid sysmem token risks the Sync() hanging forever. See
5102 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5103 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5104 /// Another way is to pass the token to BindSharedCollection(), which also
5105 /// validates the token as part of exchanging it for a BufferCollection
5106 /// channel, and BufferCollection Sync() can then be used.
5107 ///
5108 /// After a Sync(), it's then safe to send the client end of token_request
5109 /// to another participant knowing the server will recognize the token when
5110 /// it's sent into BindSharedCollection() by the other participant.
5111 ///
5112 /// Other options include waiting for each token.Duplicate() to complete
5113 /// individually (using separate call to token.Sync() after each), or
5114 /// calling Sync() on BufferCollection after the token has been turned in
5115 /// via BindSharedCollection().
5116 ///
5117 /// Another way to mitigate is to avoid calling Sync() on the token, and
5118 /// instead later deal with potential failure of BufferCollection.Sync() if
5119 /// the original token was invalid. This option can be preferable from a
5120 /// performance point of view, but requires client code to delay sending
5121 /// tokens duplicated from this token until after client code has converted
5122 /// the duplicating token to a BufferCollection and received successful
5123 /// response from BufferCollection.Sync().
5124 ///
5125 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5126 /// When BufferCollection.Sync() isn't feasible, the caller must already
5127 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5128 /// hang forever. See ValidateBufferCollectionToken() to check token
5129 /// validity first if the token isn't already known to be (is/was) valid.
5130 pub fn r#sync(
5131 &self,
5132 ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
5133 BufferCollectionTokenGroupProxyInterface::r#sync(self)
5134 }
5135
5136 /// On a BufferCollectionToken channel:
5137 ///
5138 /// Normally a participant will convert a BufferCollectionToken into a
5139 /// BufferCollection view, but a participant is also free to Close() the
5140 /// token (and then close the channel immediately or shortly later in
5141 /// response to server closing its end), which avoids causing logical buffer
5142 /// collection failure. Â Normally an unexpected token channel close will
5143 /// cause logical buffer collection failure (the only exceptions being
5144 /// certain cases involving AttachToken() or SetDispensable()).
5145 ///
5146 /// On a BufferCollection channel:
5147 ///
5148 /// By default the server handles unexpected failure of a BufferCollection
5149 /// by failing the whole logical buffer collection. Partly this is to
5150 /// expedite closing VMO handles to reclaim memory when any participant
5151 /// fails. If a participant would like to cleanly close a BufferCollection
5152 /// view without causing logical buffer collection failure, the participant
5153 /// can send Close() before closing the client end of the BufferCollection
5154 /// channel. If this is the last BufferCollection view, the logical buffer
5155 /// collection will still go away. The Close() can occur before or after
5156 /// SetConstraints(). If before SetConstraints(), the buffer collection
5157 /// won't require constraints from this node in order to allocate. If
5158 /// after SetConstraints(), the constraints are retained and aggregated
5159 /// along with any subsequent logical allocation(s), despite the lack of
5160 /// channel connection.
5161 ///
5162 /// On a BufferCollectionTokenGroup channel:
5163 ///
5164 /// By default, unexpected failure of a BufferCollectionTokenGroup will
5165 /// trigger failure of the logical BufferCollectionTokenGroup and will
5166 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
5167 /// channel without failing the logical group or propagating failure, send
5168 /// Close() before closing the channel client endpoint.
5169 ///
5170 /// If Close() occurs before AllChildrenPresent(), the logical buffer
5171 /// collection will still fail despite the Close() (because sysmem can't be
5172 /// sure whether all relevant children were created, so it's ambiguous
5173 /// whether all relevant constraints will be provided to sysmem). If
5174 /// Close() occurs after AllChildrenPresent(), the children and all their
5175 /// constraints remain intact (just as they would if the
5176 /// BufferCollectionTokenGroup channel had remained open), and the close
5177 /// doesn't trigger or propagate failure.
5178 pub fn r#close(&self) -> Result<(), fidl::Error> {
5179 BufferCollectionTokenGroupProxyInterface::r#close(self)
5180 }
5181
5182 /// Set a name for VMOs in this buffer collection. The name may be truncated
5183 /// shorter. The name only affects VMOs allocated after it's set - this call
5184 /// does not rename existing VMOs. If multiple clients set different names
5185 /// then the larger priority value will win.
5186 pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5187 BufferCollectionTokenGroupProxyInterface::r#set_name(self, priority, name)
5188 }
5189
5190 /// Set information about the current client that can be used by sysmem to
5191 /// help debug leaking memory and hangs waiting for constraints. |name| can
5192 /// be an arbitrary string, but the current process name (see
5193 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
5194 /// arbitrary id, but the current process ID (see
5195 /// fsl::GetCurrentProcessKoid()) is a good default.
5196 ///
5197 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
5198 /// indicate which client is closing their channel first, leading to
5199 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
5200 /// over, but if happening earlier than expected, the
5201 /// client-channel-specific name can help diagnose where the failure is
5202 /// first coming from, from sysmem's point of view).
5203 ///
5204 /// By default (unless overriden by this message or using
5205 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
5206 /// parent Node at the time the child Node is created. While this can be
5207 /// better than nothing, it's often better for each participant to use
5208 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
5209 /// info directly relevant to the current client. Also, SetVerboseLogging()
5210 /// can be used to help disambiguate if a Node is suspected of having info
5211 /// that was copied from its parent.
5212 pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5213 BufferCollectionTokenGroupProxyInterface::r#set_debug_client_info(self, name, id)
5214 }
5215
5216 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
5217 /// after creating a collection. Clients can call this method to change
5218 /// when the log is printed. If multiple client set the deadline, it's
5219 /// unspecified which deadline will take effect.
5220 pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5221 BufferCollectionTokenGroupProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
5222 }
5223
5224 /// Verbose logging includes constraints set via SetConstraints() from each
5225 /// client along with info set via SetDebugClientInfo() and the structure of
5226 /// the tree of Node(s).
5227 ///
5228 /// Normally sysmem prints only a single line complaint when aggregation
5229 /// fails, with just the specific detailed reason that aggregation failed,
5230 /// with minimal context. While this is often enough to diagnose a problem
5231 /// if only a small change was made and the system had been working before
5232 /// the small change, it's often not particularly helpful for getting a new
5233 /// buffer collection to work for the first time. Especially with more
5234 /// complex trees of nodes, involving things like AttachToken(),
5235 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
5236 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
5237 /// looks like and why it's failing a logical allocation, or why a tree or
5238 /// sub-tree is failing sooner than expected.
5239 ///
5240 /// The intent of the extra logging is to be acceptable from a performance
5241 /// point of view, if only enabled on a low number of buffer collections.
5242 /// If we're not tracking down a bug, we shouldn't send this message.
5243 ///
5244 /// If too many participants leave verbose logging enabled, we may end up
5245 /// needing to require that system-wide sysmem verbose logging be permitted
5246 /// via some other setting, to avoid sysmem spamming the log too much due to
5247 /// this message.
5248 ///
5249 /// This may be a NOP for some nodes due to intentional policy associated
5250 /// with the node, if we don't trust a node enough to let it turn on verbose
5251 /// logging.
5252 pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5253 BufferCollectionTokenGroupProxyInterface::r#set_verbose_logging(self)
5254 }
5255
5256 /// This gets an event handle that can be used as a parameter to
5257 /// IsAlternateFor() called on any Node. The client will not be granted the
5258 /// right to signal this event, as this handle should only be used as proof
5259 /// that the client obtained this handle from this Node.
5260 ///
5261 /// Because this is a get not a set, no Sync() is needed between the
5262 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
5263 /// potentially being on different channels.
5264 ///
5265 /// See also IsAlternateFor().
5266 pub fn r#get_node_ref(
5267 &self,
5268 ) -> fidl::client::QueryResponseFut<
5269 fdomain_client::Event,
5270 fdomain_client::fidl::FDomainResourceDialect,
5271 > {
5272 BufferCollectionTokenGroupProxyInterface::r#get_node_ref(self)
5273 }
5274
5275 /// This checks whether the calling node is in a subtree rooted at a
5276 /// different child token of a common parent BufferCollectionTokenGroup, in
5277 /// relation to the passed-in node_ref.
5278 ///
5279 /// This call is for assisting with admission control de-duplication, and
5280 /// with debugging.
5281 ///
5282 /// The node_ref must be obtained using GetNodeRef() of a
5283 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
5284 ///
5285 /// The node_ref can be a duplicated handle; it's not necessary to call
5286 /// GetNodeRef() for every call to IsAlternateFor().
5287 ///
5288 /// If a calling token may not actually be a valid token at all due to
5289 /// a potentially hostile/untrusted provider of the token, call
5290 /// ValidateBufferCollectionToken() first instead of potentially getting
5291 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
5292 /// token not being a real token (not really talking to sysmem). Another
5293 /// option is to call BindSharedCollection with this token first which also
5294 /// validates the token along with converting it to a BufferCollection, then
5295 /// call BufferCollection IsAlternateFor().
5296 ///
5297 /// error values:
5298 ///
5299 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
5300 /// buffer collection as the calling Node. Before logical allocation and
5301 /// within the same logical allocation sub-tree, this essentially means that
5302 /// the node_ref was never part of this logical buffer collection, since
5303 /// before logical allocation all node_refs that come into existence remain
5304 /// in existence at least until logical allocation (including Node(s) that
5305 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
5306 /// to be returned, this Node's channel needs to still be connected server
5307 /// side, which won't be the case if the whole logical allocation has
5308 /// failed. After logical allocation or in a different logical allocation
5309 /// sub-tree there are additional potential reasons for this error. For
5310 /// example a different logical allocation (separated from this Node(s)
5311 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
5312 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
5313 /// exist and may select a different child sub-tree than the sub-tree the
5314 /// node_ref is in causing deletion of the node_ref Node. The only time
5315 /// sysmem keeps a Node around after that Node has no corresponding channel
5316 /// is when Close() is used and the Node's sub-tree has not yet failed.
5317 /// Another reason for this error is if the node_ref is an eventpair handle
5318 /// with sufficient rights, but isn't actually a real node_ref obtained from
5319 /// GetNodeRef().
5320 ///
5321 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
5322 /// eventpair handle, or doesn't have the needed rights expected on a real
5323 /// node_ref.
5324 ///
5325 /// No other failing status codes are returned by this call. However,
5326 /// sysmem may add additional codes in future, so the client should have
5327 /// sensible default handling for any failing status code.
5328 ///
5329 /// On success, is_alternate has the following meaning:
5330 /// * true - The first parent node in common between the calling node and
5331 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
5332 /// the calling Node and the node_ref Node will _not_ have both their
5333 /// constraints apply - rather sysmem will choose one or the other of
5334 /// the constraints - never both. This is because only one child of
5335 /// a BufferCollectionTokenGroup is selected during logical allocation,
5336 /// with only that one child's sub-tree contributing to constraints
5337 /// aggregation.
5338 /// * false - The first parent node in common between the calling Node and
5339 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
5340 /// this means the first parent node in common is a
5341 /// BufferCollectionToken or BufferCollection (regardless of not
5342 /// Close()ed or Close()ed). This means that the calling Node and the
5343 /// node_ref Node _may_ have both their constraints apply during
5344 /// constraints aggregation of the logical allocation, if both Node(s)
5345 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
5346 /// In this case, there is no BufferCollectionTokenGroup that will
5347 /// directly prevent the two Node(s) from both being selected and their
5348 /// constraints both aggregated, but even when false, one or both
5349 /// Node(s) may still be eliminated from consideration if one or both
5350 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
5351 /// which selects a child sub-tree other than the sub-tree containing
5352 /// the calling Node or node_ref Node.
5353 pub fn r#is_alternate_for(
5354 &self,
5355 mut node_ref: fdomain_client::Event,
5356 ) -> fidl::client::QueryResponseFut<
5357 NodeIsAlternateForResult,
5358 fdomain_client::fidl::FDomainResourceDialect,
5359 > {
5360 BufferCollectionTokenGroupProxyInterface::r#is_alternate_for(self, node_ref)
5361 }
5362
5363 /// Create a child token. Before passing the client end of this token to
5364 /// BindSharedCollection(), completion of Sync() after CreateChild() is
5365 /// required. Or the client can use CreateChildrenSync() which essentially
5366 /// includes the Sync().
5367 ///
5368 /// token_request - the server end of the new token channel.
5369 ///
5370 /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
5371 /// allows the holder to get the same rights to buffers as the parent token
5372 /// (of the group) had.
5373 pub fn r#create_child(
5374 &self,
5375 mut payload: BufferCollectionTokenGroupCreateChildRequest,
5376 ) -> Result<(), fidl::Error> {
5377 BufferCollectionTokenGroupProxyInterface::r#create_child(self, payload)
5378 }
5379
5380 /// Create 1 or more child tokens at once, synchronously. In contrast to
5381 /// CreateChild(), no Sync() completion is required before passing the
5382 /// client end of a returned token to BindSharedCollection().
5383 ///
5384 /// The size of the rights_attentuation_mask determines the number of
5385 /// created child tokens.
5386 ///
5387 /// The lower-index child tokens are higher priority (attempted sooner) than
5388 /// higher-index child tokens.
5389 ///
5390 /// As per all child tokens, successful aggregation will choose exactly one
5391 /// child among all created children (across all children created across
5392 /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
5393 ///
5394 /// The maximum permissible total number of children per group, and total
5395 /// number of nodes in an overall tree (from the root) are capped to limits
5396 /// which are not configurable via these protocols.
5397 pub fn r#create_children_sync(
5398 &self,
5399 mut rights_attenuation_masks: &[fidl::Rights],
5400 ) -> fidl::client::QueryResponseFut<
5401 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5402 fdomain_client::fidl::FDomainResourceDialect,
5403 > {
5404 BufferCollectionTokenGroupProxyInterface::r#create_children_sync(
5405 self,
5406 rights_attenuation_masks,
5407 )
5408 }
5409
5410 /// AllChildrenPresent()
5411 ///
5412 /// After creating all children, the client must call AllChildrenPresent()
5413 /// to inform sysmem that no more children will be created, so that sysmem
5414 /// can know when it's ok to start aggregating constraints.
5415 ///
5416 /// If Close() is to be sent, it should be sent _after_
5417 /// AllChildrenPresent(), else failure of the group and propagation of the
5418 /// failure to the group's parent will still be triggered.
5419 pub fn r#all_children_present(&self) -> Result<(), fidl::Error> {
5420 BufferCollectionTokenGroupProxyInterface::r#all_children_present(self)
5421 }
5422}
5423
5424impl BufferCollectionTokenGroupProxyInterface for BufferCollectionTokenGroupProxy {
5425 type SyncResponseFut =
5426 fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
5427 fn r#sync(&self) -> Self::SyncResponseFut {
5428 fn _decode(
5429 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5430 ) -> Result<(), fidl::Error> {
5431 let _response = fidl::client::decode_transaction_body::<
5432 fidl::encoding::EmptyPayload,
5433 fdomain_client::fidl::FDomainResourceDialect,
5434 0x4577e238ae26291,
5435 >(_buf?)?;
5436 Ok(_response)
5437 }
5438 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
5439 (),
5440 0x4577e238ae26291,
5441 fidl::encoding::DynamicFlags::empty(),
5442 _decode,
5443 )
5444 }
5445
5446 fn r#close(&self) -> Result<(), fidl::Error> {
5447 self.client.send::<fidl::encoding::EmptyPayload>(
5448 (),
5449 0x5b1d7a4f5681fca7,
5450 fidl::encoding::DynamicFlags::empty(),
5451 )
5452 }
5453
5454 fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
5455 self.client.send::<NodeSetNameRequest>(
5456 (priority, name),
5457 0x77a41bb6217e2443,
5458 fidl::encoding::DynamicFlags::empty(),
5459 )
5460 }
5461
5462 fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
5463 self.client.send::<NodeSetDebugClientInfoRequest>(
5464 (name, id),
5465 0x7275759070eb5ee2,
5466 fidl::encoding::DynamicFlags::empty(),
5467 )
5468 }
5469
5470 fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
5471 self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
5472 (deadline,),
5473 0x46d38f4772638867,
5474 fidl::encoding::DynamicFlags::empty(),
5475 )
5476 }
5477
5478 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
5479 self.client.send::<fidl::encoding::EmptyPayload>(
5480 (),
5481 0x6bfbe2cf1701d288,
5482 fidl::encoding::DynamicFlags::empty(),
5483 )
5484 }
5485
5486 type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
5487 fdomain_client::Event,
5488 fdomain_client::fidl::FDomainResourceDialect,
5489 >;
5490 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
5491 fn _decode(
5492 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5493 ) -> Result<fdomain_client::Event, fidl::Error> {
5494 let _response = fidl::client::decode_transaction_body::<
5495 NodeGetNodeRefResponse,
5496 fdomain_client::fidl::FDomainResourceDialect,
5497 0x467b7c75c35c3b84,
5498 >(_buf?)?;
5499 Ok(_response.node_ref)
5500 }
5501 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
5502 (),
5503 0x467b7c75c35c3b84,
5504 fidl::encoding::DynamicFlags::empty(),
5505 _decode,
5506 )
5507 }
5508
5509 type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
5510 NodeIsAlternateForResult,
5511 fdomain_client::fidl::FDomainResourceDialect,
5512 >;
5513 fn r#is_alternate_for(
5514 &self,
5515 mut node_ref: fdomain_client::Event,
5516 ) -> Self::IsAlternateForResponseFut {
5517 fn _decode(
5518 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5519 ) -> Result<NodeIsAlternateForResult, fidl::Error> {
5520 let _response = fidl::client::decode_transaction_body::<
5521 fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
5522 fdomain_client::fidl::FDomainResourceDialect,
5523 0x33a2a7aff2776c07,
5524 >(_buf?)?;
5525 Ok(_response.map(|x| x.is_alternate))
5526 }
5527 self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
5528 (node_ref,),
5529 0x33a2a7aff2776c07,
5530 fidl::encoding::DynamicFlags::empty(),
5531 _decode,
5532 )
5533 }
5534
5535 fn r#create_child(
5536 &self,
5537 mut payload: BufferCollectionTokenGroupCreateChildRequest,
5538 ) -> Result<(), fidl::Error> {
5539 self.client.send::<BufferCollectionTokenGroupCreateChildRequest>(
5540 &mut payload,
5541 0x2e74f8bcbf59ee59,
5542 fidl::encoding::DynamicFlags::empty(),
5543 )
5544 }
5545
5546 type CreateChildrenSyncResponseFut = fidl::client::QueryResponseFut<
5547 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5548 fdomain_client::fidl::FDomainResourceDialect,
5549 >;
5550 fn r#create_children_sync(
5551 &self,
5552 mut rights_attenuation_masks: &[fidl::Rights],
5553 ) -> Self::CreateChildrenSyncResponseFut {
5554 fn _decode(
5555 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5556 ) -> Result<Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>, fidl::Error>
5557 {
5558 let _response = fidl::client::decode_transaction_body::<
5559 BufferCollectionTokenGroupCreateChildrenSyncResponse,
5560 fdomain_client::fidl::FDomainResourceDialect,
5561 0x569dc3ca2a98f535,
5562 >(_buf?)?;
5563 Ok(_response.tokens)
5564 }
5565 self.client.send_query_and_decode::<
5566 BufferCollectionTokenGroupCreateChildrenSyncRequest,
5567 Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
5568 >(
5569 (rights_attenuation_masks,),
5570 0x569dc3ca2a98f535,
5571 fidl::encoding::DynamicFlags::empty(),
5572 _decode,
5573 )
5574 }
5575
5576 fn r#all_children_present(&self) -> Result<(), fidl::Error> {
5577 self.client.send::<fidl::encoding::EmptyPayload>(
5578 (),
5579 0x1d41715f6f044b50,
5580 fidl::encoding::DynamicFlags::empty(),
5581 )
5582 }
5583}
5584
5585pub struct BufferCollectionTokenGroupEventStream {
5586 event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
5587}
5588
5589impl std::marker::Unpin for BufferCollectionTokenGroupEventStream {}
5590
5591impl futures::stream::FusedStream for BufferCollectionTokenGroupEventStream {
5592 fn is_terminated(&self) -> bool {
5593 self.event_receiver.is_terminated()
5594 }
5595}
5596
5597impl futures::Stream for BufferCollectionTokenGroupEventStream {
5598 type Item = Result<BufferCollectionTokenGroupEvent, fidl::Error>;
5599
5600 fn poll_next(
5601 mut self: std::pin::Pin<&mut Self>,
5602 cx: &mut std::task::Context<'_>,
5603 ) -> std::task::Poll<Option<Self::Item>> {
5604 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5605 &mut self.event_receiver,
5606 cx
5607 )?) {
5608 Some(buf) => std::task::Poll::Ready(Some(BufferCollectionTokenGroupEvent::decode(buf))),
5609 None => std::task::Poll::Ready(None),
5610 }
5611 }
5612}
5613
5614#[derive(Debug)]
5615pub enum BufferCollectionTokenGroupEvent {}
5616
5617impl BufferCollectionTokenGroupEvent {
5618 /// Decodes a message buffer as a [`BufferCollectionTokenGroupEvent`].
5619 fn decode(
5620 mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5621 ) -> Result<BufferCollectionTokenGroupEvent, fidl::Error> {
5622 let (bytes, _handles) = buf.split_mut();
5623 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5624 debug_assert_eq!(tx_header.tx_id, 0);
5625 match tx_header.ordinal {
5626 _ => Err(fidl::Error::UnknownOrdinal {
5627 ordinal: tx_header.ordinal,
5628 protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5629 })
5630 }
5631 }
5632}
5633
5634/// A Stream of incoming requests for fuchsia.sysmem/BufferCollectionTokenGroup.
5635pub struct BufferCollectionTokenGroupRequestStream {
5636 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5637 is_terminated: bool,
5638}
5639
5640impl std::marker::Unpin for BufferCollectionTokenGroupRequestStream {}
5641
5642impl futures::stream::FusedStream for BufferCollectionTokenGroupRequestStream {
5643 fn is_terminated(&self) -> bool {
5644 self.is_terminated
5645 }
5646}
5647
5648impl fdomain_client::fidl::RequestStream for BufferCollectionTokenGroupRequestStream {
5649 type Protocol = BufferCollectionTokenGroupMarker;
5650 type ControlHandle = BufferCollectionTokenGroupControlHandle;
5651
5652 fn from_channel(channel: fdomain_client::Channel) -> Self {
5653 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5654 }
5655
5656 fn control_handle(&self) -> Self::ControlHandle {
5657 BufferCollectionTokenGroupControlHandle { inner: self.inner.clone() }
5658 }
5659
5660 fn into_inner(
5661 self,
5662 ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
5663 {
5664 (self.inner, self.is_terminated)
5665 }
5666
5667 fn from_inner(
5668 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5669 is_terminated: bool,
5670 ) -> Self {
5671 Self { inner, is_terminated }
5672 }
5673}
5674
5675impl futures::Stream for BufferCollectionTokenGroupRequestStream {
5676 type Item = Result<BufferCollectionTokenGroupRequest, fidl::Error>;
5677
5678 fn poll_next(
5679 mut self: std::pin::Pin<&mut Self>,
5680 cx: &mut std::task::Context<'_>,
5681 ) -> std::task::Poll<Option<Self::Item>> {
5682 let this = &mut *self;
5683 if this.inner.check_shutdown(cx) {
5684 this.is_terminated = true;
5685 return std::task::Poll::Ready(None);
5686 }
5687 if this.is_terminated {
5688 panic!("polled BufferCollectionTokenGroupRequestStream after completion");
5689 }
5690 fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5691 |bytes, handles| {
5692 match this.inner.channel().read_etc(cx, bytes, handles) {
5693 std::task::Poll::Ready(Ok(())) => {}
5694 std::task::Poll::Pending => return std::task::Poll::Pending,
5695 std::task::Poll::Ready(Err(None)) => {
5696 this.is_terminated = true;
5697 return std::task::Poll::Ready(None);
5698 }
5699 std::task::Poll::Ready(Err(Some(e))) => {
5700 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5701 e.into(),
5702 ))));
5703 }
5704 }
5705
5706 // A message has been received from the channel
5707 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5708
5709 std::task::Poll::Ready(Some(match header.ordinal {
5710 0x4577e238ae26291 => {
5711 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5712 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5713 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5714 let control_handle = BufferCollectionTokenGroupControlHandle {
5715 inner: this.inner.clone(),
5716 };
5717 Ok(BufferCollectionTokenGroupRequest::Sync {
5718 responder: BufferCollectionTokenGroupSyncResponder {
5719 control_handle: std::mem::ManuallyDrop::new(control_handle),
5720 tx_id: header.tx_id,
5721 },
5722 })
5723 }
5724 0x5b1d7a4f5681fca7 => {
5725 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5726 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5727 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5728 let control_handle = BufferCollectionTokenGroupControlHandle {
5729 inner: this.inner.clone(),
5730 };
5731 Ok(BufferCollectionTokenGroupRequest::Close {
5732 control_handle,
5733 })
5734 }
5735 0x77a41bb6217e2443 => {
5736 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5737 let mut req = fidl::new_empty!(NodeSetNameRequest, fdomain_client::fidl::FDomainResourceDialect);
5738 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
5739 let control_handle = BufferCollectionTokenGroupControlHandle {
5740 inner: this.inner.clone(),
5741 };
5742 Ok(BufferCollectionTokenGroupRequest::SetName {priority: req.priority,
5743name: req.name,
5744
5745 control_handle,
5746 })
5747 }
5748 0x7275759070eb5ee2 => {
5749 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5750 let mut req = fidl::new_empty!(NodeSetDebugClientInfoRequest, fdomain_client::fidl::FDomainResourceDialect);
5751 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
5752 let control_handle = BufferCollectionTokenGroupControlHandle {
5753 inner: this.inner.clone(),
5754 };
5755 Ok(BufferCollectionTokenGroupRequest::SetDebugClientInfo {name: req.name,
5756id: req.id,
5757
5758 control_handle,
5759 })
5760 }
5761 0x46d38f4772638867 => {
5762 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5763 let mut req = fidl::new_empty!(NodeSetDebugTimeoutLogDeadlineRequest, fdomain_client::fidl::FDomainResourceDialect);
5764 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
5765 let control_handle = BufferCollectionTokenGroupControlHandle {
5766 inner: this.inner.clone(),
5767 };
5768 Ok(BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {deadline: req.deadline,
5769
5770 control_handle,
5771 })
5772 }
5773 0x6bfbe2cf1701d288 => {
5774 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5775 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5776 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5777 let control_handle = BufferCollectionTokenGroupControlHandle {
5778 inner: this.inner.clone(),
5779 };
5780 Ok(BufferCollectionTokenGroupRequest::SetVerboseLogging {
5781 control_handle,
5782 })
5783 }
5784 0x467b7c75c35c3b84 => {
5785 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5786 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5787 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5788 let control_handle = BufferCollectionTokenGroupControlHandle {
5789 inner: this.inner.clone(),
5790 };
5791 Ok(BufferCollectionTokenGroupRequest::GetNodeRef {
5792 responder: BufferCollectionTokenGroupGetNodeRefResponder {
5793 control_handle: std::mem::ManuallyDrop::new(control_handle),
5794 tx_id: header.tx_id,
5795 },
5796 })
5797 }
5798 0x33a2a7aff2776c07 => {
5799 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5800 let mut req = fidl::new_empty!(NodeIsAlternateForRequest, fdomain_client::fidl::FDomainResourceDialect);
5801 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
5802 let control_handle = BufferCollectionTokenGroupControlHandle {
5803 inner: this.inner.clone(),
5804 };
5805 Ok(BufferCollectionTokenGroupRequest::IsAlternateFor {node_ref: req.node_ref,
5806
5807 responder: BufferCollectionTokenGroupIsAlternateForResponder {
5808 control_handle: std::mem::ManuallyDrop::new(control_handle),
5809 tx_id: header.tx_id,
5810 },
5811 })
5812 }
5813 0x2e74f8bcbf59ee59 => {
5814 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5815 let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildRequest, fdomain_client::fidl::FDomainResourceDialect);
5816 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildRequest>(&header, _body_bytes, handles, &mut req)?;
5817 let control_handle = BufferCollectionTokenGroupControlHandle {
5818 inner: this.inner.clone(),
5819 };
5820 Ok(BufferCollectionTokenGroupRequest::CreateChild {payload: req,
5821 control_handle,
5822 })
5823 }
5824 0x569dc3ca2a98f535 => {
5825 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5826 let mut req = fidl::new_empty!(BufferCollectionTokenGroupCreateChildrenSyncRequest, fdomain_client::fidl::FDomainResourceDialect);
5827 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<BufferCollectionTokenGroupCreateChildrenSyncRequest>(&header, _body_bytes, handles, &mut req)?;
5828 let control_handle = BufferCollectionTokenGroupControlHandle {
5829 inner: this.inner.clone(),
5830 };
5831 Ok(BufferCollectionTokenGroupRequest::CreateChildrenSync {rights_attenuation_masks: req.rights_attenuation_masks,
5832
5833 responder: BufferCollectionTokenGroupCreateChildrenSyncResponder {
5834 control_handle: std::mem::ManuallyDrop::new(control_handle),
5835 tx_id: header.tx_id,
5836 },
5837 })
5838 }
5839 0x1d41715f6f044b50 => {
5840 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5841 let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
5842 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5843 let control_handle = BufferCollectionTokenGroupControlHandle {
5844 inner: this.inner.clone(),
5845 };
5846 Ok(BufferCollectionTokenGroupRequest::AllChildrenPresent {
5847 control_handle,
5848 })
5849 }
5850 _ => Err(fidl::Error::UnknownOrdinal {
5851 ordinal: header.ordinal,
5852 protocol_name: <BufferCollectionTokenGroupMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5853 }),
5854 }))
5855 },
5856 )
5857 }
5858}
5859
5860/// The sysmem implementation is guaranteed to be consistent with a logical /
5861/// conceptual model as follows:
5862///
5863/// As usual, a logical allocation considers either the root and all nodes with
5864/// connectivity to the root that don't transit an AttachToken(), or a sub-tree
5865/// rooted at an AttachToken() token and all nodes with connectivity to that
5866/// subtree that don't transit another AttachToken(). This is called the
5867/// logical allocation pruned sub-tree, or pruned sub-tree for short.
5868///
5869/// During constraints aggregation, each BufferCollectionTokenGroup will select
5870/// a single child token among its children. The rest of the children will
5871/// appear to fail the logical allocation, while the selected child may succeed.
5872///
5873/// When more than one BufferCollectionTokenGroup exists in the overall logical
5874/// allocation pruned sub-tree, the relative priority between two groups is
5875/// equivalent to their ordering in a DFS pre-order iteration of the tree, with
5876/// parents higher priority than children, and left children higher priority
5877/// than right children.
5878///
5879/// When a particular child of a group is selected (whether provisionally during
5880/// a constraints aggregation attempt, or as a final selection), the
5881/// non-selection of other children of the group can potentially "hide" other
5882/// groups under those non-selected children.
5883///
5884/// Within a logical allocation, aggregation is attempted first by provisionally
5885/// selecting the child 0 of the highest-priority group, and child 0 of the next
5886/// highest-priority group that isn't hidden by the provisional selections so
5887/// far, etc.
5888///
5889/// If that aggregation attempt fails, aggregation will be attempted with the
5890/// ordinal 0 child of all the same groups except the lowest priority non-hidden
5891/// group which will provisionally select its ordinal 1 child (and then child 2
5892/// and so on). If a new lowest-priority group is un-hidden as provisional
5893/// selections are updated, that newly un-hidden lowest-priority group has all
5894/// its children considered in order, before changing the provisional selection
5895/// in the former lowest-priority group. In terms of result, this is equivalent
5896/// to systematic enumeration of all possible combinations of choices in a
5897/// counting-like order updating the lowest-priority group the most often and
5898/// the highest-priority group the least often. Rather than actually attempting
5899/// aggregation with all the combinations, we can skip over combinations which
5900/// are redundant/equivalent due to hiding without any change to the result.
5901///
5902/// Attempted aggregations of enumerated non-equivalent combinations of choices
5903/// continue in this manner until either (a) all aggregation attempts fail in
5904/// which case the overall logical allocation fails, or (b) until an attempted
5905/// aggregation succeeds, in which case buffer allocation (if needed) is
5906/// attempted once. If buffer allocation based on the first successful
5907/// aggregation fails, the overall logical allocation fails (there is no buffer
5908/// allocation retry / re-attempt). If buffer allocation succeeds (or is not
5909/// needed), the logical allocation succeeds.
5910///
5911/// If this prioritization scheme cannot reasonably work for your usage of
5912/// sysmem, please contact sysmem folks to discuss potentially adding a way to
5913/// achieve what you need.
5914///
5915/// Please avoid creating a large number of BufferCollectionTokenGroup(s) per
5916/// logical allocation, especially with large number of children overall, and
5917/// especially in cases where aggregation may reasonably be expected to often
5918/// fail using ordinal 0 children and possibly with later children as well. We
5919/// anticipate mitigating potentially high time complexity of evaluating too
5920/// many child combinations/selections across too many groups by simply failing
5921/// logical allocation beyond a certain (fairly high, but not huge) max number
5922/// of considered group child combinations/selections. More advanced (and more
5923/// complicated) mitigation is not anticipated to be practically necessary or
5924/// worth the added complexity. Please contact sysmem folks if the max limit
5925/// is getting hit or if you anticipate it getting hit, to discuss potential
5926/// options.
5927///
5928/// Prefer to use multiple ImageFormatConstraints in a single
5929/// BufferCollectionConstraints when feasible (when a participant just needs to
5930/// express the ability to work with more than a single PixelFormat, with
5931/// sysmem choosing which PixelFormat to use among those supported by all
5932/// participants).
5933///
5934/// Similar to BufferCollectionToken and BufferCollection, closure of the
5935/// BufferCollectionTokenGroup channel without sending Close() first will cause
5936/// logical buffer collection failure (or sub-tree failure if using
5937/// SetDispensable() or AttachToken() and the BufferCollectionTokenGroup is part
5938/// of a sub-tree under such a node that doesn't propagate failure to its
5939/// parent).
5940#[derive(Debug)]
5941pub enum BufferCollectionTokenGroupRequest {
5942 /// Ensure that previous messages, including Duplicate() messages on a
5943 /// token, collection, or group, have been received server side.
5944 ///
5945 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
5946 /// valid sysmem token risks the Sync() hanging forever. See
5947 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
5948 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
5949 /// Another way is to pass the token to BindSharedCollection(), which also
5950 /// validates the token as part of exchanging it for a BufferCollection
5951 /// channel, and BufferCollection Sync() can then be used.
5952 ///
5953 /// After a Sync(), it's then safe to send the client end of token_request
5954 /// to another participant knowing the server will recognize the token when
5955 /// it's sent into BindSharedCollection() by the other participant.
5956 ///
5957 /// Other options include waiting for each token.Duplicate() to complete
5958 /// individually (using separate call to token.Sync() after each), or
5959 /// calling Sync() on BufferCollection after the token has been turned in
5960 /// via BindSharedCollection().
5961 ///
5962 /// Another way to mitigate is to avoid calling Sync() on the token, and
5963 /// instead later deal with potential failure of BufferCollection.Sync() if
5964 /// the original token was invalid. This option can be preferable from a
5965 /// performance point of view, but requires client code to delay sending
5966 /// tokens duplicated from this token until after client code has converted
5967 /// the duplicating token to a BufferCollection and received successful
5968 /// response from BufferCollection.Sync().
5969 ///
5970 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
5971 /// When BufferCollection.Sync() isn't feasible, the caller must already
5972 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
5973 /// hang forever. See ValidateBufferCollectionToken() to check token
5974 /// validity first if the token isn't already known to be (is/was) valid.
5975 Sync { responder: BufferCollectionTokenGroupSyncResponder },
5976 /// On a BufferCollectionToken channel:
5977 ///
5978 /// Normally a participant will convert a BufferCollectionToken into a
5979 /// BufferCollection view, but a participant is also free to Close() the
5980 /// token (and then close the channel immediately or shortly later in
5981 /// response to server closing its end), which avoids causing logical buffer
5982 /// collection failure. Â Normally an unexpected token channel close will
5983 /// cause logical buffer collection failure (the only exceptions being
5984 /// certain cases involving AttachToken() or SetDispensable()).
5985 ///
5986 /// On a BufferCollection channel:
5987 ///
5988 /// By default the server handles unexpected failure of a BufferCollection
5989 /// by failing the whole logical buffer collection. Partly this is to
5990 /// expedite closing VMO handles to reclaim memory when any participant
5991 /// fails. If a participant would like to cleanly close a BufferCollection
5992 /// view without causing logical buffer collection failure, the participant
5993 /// can send Close() before closing the client end of the BufferCollection
5994 /// channel. If this is the last BufferCollection view, the logical buffer
5995 /// collection will still go away. The Close() can occur before or after
5996 /// SetConstraints(). If before SetConstraints(), the buffer collection
5997 /// won't require constraints from this node in order to allocate. If
5998 /// after SetConstraints(), the constraints are retained and aggregated
5999 /// along with any subsequent logical allocation(s), despite the lack of
6000 /// channel connection.
6001 ///
6002 /// On a BufferCollectionTokenGroup channel:
6003 ///
6004 /// By default, unexpected failure of a BufferCollectionTokenGroup will
6005 /// trigger failure of the logical BufferCollectionTokenGroup and will
6006 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
6007 /// channel without failing the logical group or propagating failure, send
6008 /// Close() before closing the channel client endpoint.
6009 ///
6010 /// If Close() occurs before AllChildrenPresent(), the logical buffer
6011 /// collection will still fail despite the Close() (because sysmem can't be
6012 /// sure whether all relevant children were created, so it's ambiguous
6013 /// whether all relevant constraints will be provided to sysmem). If
6014 /// Close() occurs after AllChildrenPresent(), the children and all their
6015 /// constraints remain intact (just as they would if the
6016 /// BufferCollectionTokenGroup channel had remained open), and the close
6017 /// doesn't trigger or propagate failure.
6018 Close { control_handle: BufferCollectionTokenGroupControlHandle },
6019 /// Set a name for VMOs in this buffer collection. The name may be truncated
6020 /// shorter. The name only affects VMOs allocated after it's set - this call
6021 /// does not rename existing VMOs. If multiple clients set different names
6022 /// then the larger priority value will win.
6023 SetName { priority: u32, name: String, control_handle: BufferCollectionTokenGroupControlHandle },
6024 /// Set information about the current client that can be used by sysmem to
6025 /// help debug leaking memory and hangs waiting for constraints. |name| can
6026 /// be an arbitrary string, but the current process name (see
6027 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6028 /// arbitrary id, but the current process ID (see
6029 /// fsl::GetCurrentProcessKoid()) is a good default.
6030 ///
6031 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6032 /// indicate which client is closing their channel first, leading to
6033 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6034 /// over, but if happening earlier than expected, the
6035 /// client-channel-specific name can help diagnose where the failure is
6036 /// first coming from, from sysmem's point of view).
6037 ///
6038 /// By default (unless overriden by this message or using
6039 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6040 /// parent Node at the time the child Node is created. While this can be
6041 /// better than nothing, it's often better for each participant to use
6042 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6043 /// info directly relevant to the current client. Also, SetVerboseLogging()
6044 /// can be used to help disambiguate if a Node is suspected of having info
6045 /// that was copied from its parent.
6046 SetDebugClientInfo {
6047 name: String,
6048 id: u64,
6049 control_handle: BufferCollectionTokenGroupControlHandle,
6050 },
6051 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6052 /// after creating a collection. Clients can call this method to change
6053 /// when the log is printed. If multiple client set the deadline, it's
6054 /// unspecified which deadline will take effect.
6055 SetDebugTimeoutLogDeadline {
6056 deadline: i64,
6057 control_handle: BufferCollectionTokenGroupControlHandle,
6058 },
6059 /// Verbose logging includes constraints set via SetConstraints() from each
6060 /// client along with info set via SetDebugClientInfo() and the structure of
6061 /// the tree of Node(s).
6062 ///
6063 /// Normally sysmem prints only a single line complaint when aggregation
6064 /// fails, with just the specific detailed reason that aggregation failed,
6065 /// with minimal context. While this is often enough to diagnose a problem
6066 /// if only a small change was made and the system had been working before
6067 /// the small change, it's often not particularly helpful for getting a new
6068 /// buffer collection to work for the first time. Especially with more
6069 /// complex trees of nodes, involving things like AttachToken(),
6070 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6071 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6072 /// looks like and why it's failing a logical allocation, or why a tree or
6073 /// sub-tree is failing sooner than expected.
6074 ///
6075 /// The intent of the extra logging is to be acceptable from a performance
6076 /// point of view, if only enabled on a low number of buffer collections.
6077 /// If we're not tracking down a bug, we shouldn't send this message.
6078 ///
6079 /// If too many participants leave verbose logging enabled, we may end up
6080 /// needing to require that system-wide sysmem verbose logging be permitted
6081 /// via some other setting, to avoid sysmem spamming the log too much due to
6082 /// this message.
6083 ///
6084 /// This may be a NOP for some nodes due to intentional policy associated
6085 /// with the node, if we don't trust a node enough to let it turn on verbose
6086 /// logging.
6087 SetVerboseLogging { control_handle: BufferCollectionTokenGroupControlHandle },
6088 /// This gets an event handle that can be used as a parameter to
6089 /// IsAlternateFor() called on any Node. The client will not be granted the
6090 /// right to signal this event, as this handle should only be used as proof
6091 /// that the client obtained this handle from this Node.
6092 ///
6093 /// Because this is a get not a set, no Sync() is needed between the
6094 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6095 /// potentially being on different channels.
6096 ///
6097 /// See also IsAlternateFor().
6098 GetNodeRef { responder: BufferCollectionTokenGroupGetNodeRefResponder },
6099 /// This checks whether the calling node is in a subtree rooted at a
6100 /// different child token of a common parent BufferCollectionTokenGroup, in
6101 /// relation to the passed-in node_ref.
6102 ///
6103 /// This call is for assisting with admission control de-duplication, and
6104 /// with debugging.
6105 ///
6106 /// The node_ref must be obtained using GetNodeRef() of a
6107 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6108 ///
6109 /// The node_ref can be a duplicated handle; it's not necessary to call
6110 /// GetNodeRef() for every call to IsAlternateFor().
6111 ///
6112 /// If a calling token may not actually be a valid token at all due to
6113 /// a potentially hostile/untrusted provider of the token, call
6114 /// ValidateBufferCollectionToken() first instead of potentially getting
6115 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6116 /// token not being a real token (not really talking to sysmem). Another
6117 /// option is to call BindSharedCollection with this token first which also
6118 /// validates the token along with converting it to a BufferCollection, then
6119 /// call BufferCollection IsAlternateFor().
6120 ///
6121 /// error values:
6122 ///
6123 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6124 /// buffer collection as the calling Node. Before logical allocation and
6125 /// within the same logical allocation sub-tree, this essentially means that
6126 /// the node_ref was never part of this logical buffer collection, since
6127 /// before logical allocation all node_refs that come into existence remain
6128 /// in existence at least until logical allocation (including Node(s) that
6129 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6130 /// to be returned, this Node's channel needs to still be connected server
6131 /// side, which won't be the case if the whole logical allocation has
6132 /// failed. After logical allocation or in a different logical allocation
6133 /// sub-tree there are additional potential reasons for this error. For
6134 /// example a different logical allocation (separated from this Node(s)
6135 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6136 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6137 /// exist and may select a different child sub-tree than the sub-tree the
6138 /// node_ref is in causing deletion of the node_ref Node. The only time
6139 /// sysmem keeps a Node around after that Node has no corresponding channel
6140 /// is when Close() is used and the Node's sub-tree has not yet failed.
6141 /// Another reason for this error is if the node_ref is an eventpair handle
6142 /// with sufficient rights, but isn't actually a real node_ref obtained from
6143 /// GetNodeRef().
6144 ///
6145 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6146 /// eventpair handle, or doesn't have the needed rights expected on a real
6147 /// node_ref.
6148 ///
6149 /// No other failing status codes are returned by this call. However,
6150 /// sysmem may add additional codes in future, so the client should have
6151 /// sensible default handling for any failing status code.
6152 ///
6153 /// On success, is_alternate has the following meaning:
6154 /// * true - The first parent node in common between the calling node and
6155 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
6156 /// the calling Node and the node_ref Node will _not_ have both their
6157 /// constraints apply - rather sysmem will choose one or the other of
6158 /// the constraints - never both. This is because only one child of
6159 /// a BufferCollectionTokenGroup is selected during logical allocation,
6160 /// with only that one child's sub-tree contributing to constraints
6161 /// aggregation.
6162 /// * false - The first parent node in common between the calling Node and
6163 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
6164 /// this means the first parent node in common is a
6165 /// BufferCollectionToken or BufferCollection (regardless of not
6166 /// Close()ed or Close()ed). This means that the calling Node and the
6167 /// node_ref Node _may_ have both their constraints apply during
6168 /// constraints aggregation of the logical allocation, if both Node(s)
6169 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
6170 /// In this case, there is no BufferCollectionTokenGroup that will
6171 /// directly prevent the two Node(s) from both being selected and their
6172 /// constraints both aggregated, but even when false, one or both
6173 /// Node(s) may still be eliminated from consideration if one or both
6174 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
6175 /// which selects a child sub-tree other than the sub-tree containing
6176 /// the calling Node or node_ref Node.
6177 IsAlternateFor {
6178 node_ref: fdomain_client::Event,
6179 responder: BufferCollectionTokenGroupIsAlternateForResponder,
6180 },
6181 /// Create a child token. Before passing the client end of this token to
6182 /// BindSharedCollection(), completion of Sync() after CreateChild() is
6183 /// required. Or the client can use CreateChildrenSync() which essentially
6184 /// includes the Sync().
6185 ///
6186 /// token_request - the server end of the new token channel.
6187 ///
6188 /// rights_attenuation_mask - If ZX_RIGHT_SAME_RIGHTS, the created token
6189 /// allows the holder to get the same rights to buffers as the parent token
6190 /// (of the group) had.
6191 CreateChild {
6192 payload: BufferCollectionTokenGroupCreateChildRequest,
6193 control_handle: BufferCollectionTokenGroupControlHandle,
6194 },
6195 /// Create 1 or more child tokens at once, synchronously. In contrast to
6196 /// CreateChild(), no Sync() completion is required before passing the
6197 /// client end of a returned token to BindSharedCollection().
6198 ///
6199 /// The size of the rights_attentuation_mask determines the number of
6200 /// created child tokens.
6201 ///
6202 /// The lower-index child tokens are higher priority (attempted sooner) than
6203 /// higher-index child tokens.
6204 ///
6205 /// As per all child tokens, successful aggregation will choose exactly one
6206 /// child among all created children (across all children created across
6207 /// potentially multiple calls to CreateChild() and CreateChildrenSync()).
6208 ///
6209 /// The maximum permissible total number of children per group, and total
6210 /// number of nodes in an overall tree (from the root) are capped to limits
6211 /// which are not configurable via these protocols.
6212 CreateChildrenSync {
6213 rights_attenuation_masks: Vec<fidl::Rights>,
6214 responder: BufferCollectionTokenGroupCreateChildrenSyncResponder,
6215 },
6216 /// AllChildrenPresent()
6217 ///
6218 /// After creating all children, the client must call AllChildrenPresent()
6219 /// to inform sysmem that no more children will be created, so that sysmem
6220 /// can know when it's ok to start aggregating constraints.
6221 ///
6222 /// If Close() is to be sent, it should be sent _after_
6223 /// AllChildrenPresent(), else failure of the group and propagation of the
6224 /// failure to the group's parent will still be triggered.
6225 AllChildrenPresent { control_handle: BufferCollectionTokenGroupControlHandle },
6226}
6227
6228impl BufferCollectionTokenGroupRequest {
6229 #[allow(irrefutable_let_patterns)]
6230 pub fn into_sync(self) -> Option<(BufferCollectionTokenGroupSyncResponder)> {
6231 if let BufferCollectionTokenGroupRequest::Sync { responder } = self {
6232 Some((responder))
6233 } else {
6234 None
6235 }
6236 }
6237
6238 #[allow(irrefutable_let_patterns)]
6239 pub fn into_close(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
6240 if let BufferCollectionTokenGroupRequest::Close { control_handle } = self {
6241 Some((control_handle))
6242 } else {
6243 None
6244 }
6245 }
6246
6247 #[allow(irrefutable_let_patterns)]
6248 pub fn into_set_name(self) -> Option<(u32, String, BufferCollectionTokenGroupControlHandle)> {
6249 if let BufferCollectionTokenGroupRequest::SetName { priority, name, control_handle } = self
6250 {
6251 Some((priority, name, control_handle))
6252 } else {
6253 None
6254 }
6255 }
6256
6257 #[allow(irrefutable_let_patterns)]
6258 pub fn into_set_debug_client_info(
6259 self,
6260 ) -> Option<(String, u64, BufferCollectionTokenGroupControlHandle)> {
6261 if let BufferCollectionTokenGroupRequest::SetDebugClientInfo { name, id, control_handle } =
6262 self
6263 {
6264 Some((name, id, control_handle))
6265 } else {
6266 None
6267 }
6268 }
6269
6270 #[allow(irrefutable_let_patterns)]
6271 pub fn into_set_debug_timeout_log_deadline(
6272 self,
6273 ) -> Option<(i64, BufferCollectionTokenGroupControlHandle)> {
6274 if let BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline {
6275 deadline,
6276 control_handle,
6277 } = self
6278 {
6279 Some((deadline, control_handle))
6280 } else {
6281 None
6282 }
6283 }
6284
6285 #[allow(irrefutable_let_patterns)]
6286 pub fn into_set_verbose_logging(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
6287 if let BufferCollectionTokenGroupRequest::SetVerboseLogging { control_handle } = self {
6288 Some((control_handle))
6289 } else {
6290 None
6291 }
6292 }
6293
6294 #[allow(irrefutable_let_patterns)]
6295 pub fn into_get_node_ref(self) -> Option<(BufferCollectionTokenGroupGetNodeRefResponder)> {
6296 if let BufferCollectionTokenGroupRequest::GetNodeRef { responder } = self {
6297 Some((responder))
6298 } else {
6299 None
6300 }
6301 }
6302
6303 #[allow(irrefutable_let_patterns)]
6304 pub fn into_is_alternate_for(
6305 self,
6306 ) -> Option<(fdomain_client::Event, BufferCollectionTokenGroupIsAlternateForResponder)> {
6307 if let BufferCollectionTokenGroupRequest::IsAlternateFor { node_ref, responder } = self {
6308 Some((node_ref, responder))
6309 } else {
6310 None
6311 }
6312 }
6313
6314 #[allow(irrefutable_let_patterns)]
6315 pub fn into_create_child(
6316 self,
6317 ) -> Option<(
6318 BufferCollectionTokenGroupCreateChildRequest,
6319 BufferCollectionTokenGroupControlHandle,
6320 )> {
6321 if let BufferCollectionTokenGroupRequest::CreateChild { payload, control_handle } = self {
6322 Some((payload, control_handle))
6323 } else {
6324 None
6325 }
6326 }
6327
6328 #[allow(irrefutable_let_patterns)]
6329 pub fn into_create_children_sync(
6330 self,
6331 ) -> Option<(Vec<fidl::Rights>, BufferCollectionTokenGroupCreateChildrenSyncResponder)> {
6332 if let BufferCollectionTokenGroupRequest::CreateChildrenSync {
6333 rights_attenuation_masks,
6334 responder,
6335 } = self
6336 {
6337 Some((rights_attenuation_masks, responder))
6338 } else {
6339 None
6340 }
6341 }
6342
6343 #[allow(irrefutable_let_patterns)]
6344 pub fn into_all_children_present(self) -> Option<(BufferCollectionTokenGroupControlHandle)> {
6345 if let BufferCollectionTokenGroupRequest::AllChildrenPresent { control_handle } = self {
6346 Some((control_handle))
6347 } else {
6348 None
6349 }
6350 }
6351
6352 /// Name of the method defined in FIDL
6353 pub fn method_name(&self) -> &'static str {
6354 match *self {
6355 BufferCollectionTokenGroupRequest::Sync { .. } => "sync",
6356 BufferCollectionTokenGroupRequest::Close { .. } => "close",
6357 BufferCollectionTokenGroupRequest::SetName { .. } => "set_name",
6358 BufferCollectionTokenGroupRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
6359 BufferCollectionTokenGroupRequest::SetDebugTimeoutLogDeadline { .. } => {
6360 "set_debug_timeout_log_deadline"
6361 }
6362 BufferCollectionTokenGroupRequest::SetVerboseLogging { .. } => "set_verbose_logging",
6363 BufferCollectionTokenGroupRequest::GetNodeRef { .. } => "get_node_ref",
6364 BufferCollectionTokenGroupRequest::IsAlternateFor { .. } => "is_alternate_for",
6365 BufferCollectionTokenGroupRequest::CreateChild { .. } => "create_child",
6366 BufferCollectionTokenGroupRequest::CreateChildrenSync { .. } => "create_children_sync",
6367 BufferCollectionTokenGroupRequest::AllChildrenPresent { .. } => "all_children_present",
6368 }
6369 }
6370}
6371
6372#[derive(Debug, Clone)]
6373pub struct BufferCollectionTokenGroupControlHandle {
6374 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6375}
6376
6377impl fdomain_client::fidl::ControlHandle for BufferCollectionTokenGroupControlHandle {
6378 fn shutdown(&self) {
6379 self.inner.shutdown()
6380 }
6381
6382 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6383 self.inner.shutdown_with_epitaph(status)
6384 }
6385
6386 fn is_closed(&self) -> bool {
6387 self.inner.channel().is_closed()
6388 }
6389 fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6390 self.inner.channel().on_closed()
6391 }
6392}
6393
6394impl BufferCollectionTokenGroupControlHandle {}
6395
6396#[must_use = "FIDL methods require a response to be sent"]
6397#[derive(Debug)]
6398pub struct BufferCollectionTokenGroupSyncResponder {
6399 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6400 tx_id: u32,
6401}
6402
6403/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6404/// if the responder is dropped without sending a response, so that the client
6405/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6406impl std::ops::Drop for BufferCollectionTokenGroupSyncResponder {
6407 fn drop(&mut self) {
6408 self.control_handle.shutdown();
6409 // Safety: drops once, never accessed again
6410 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6411 }
6412}
6413
6414impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupSyncResponder {
6415 type ControlHandle = BufferCollectionTokenGroupControlHandle;
6416
6417 fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6418 &self.control_handle
6419 }
6420
6421 fn drop_without_shutdown(mut self) {
6422 // Safety: drops once, never accessed again due to mem::forget
6423 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6424 // Prevent Drop from running (which would shut down the channel)
6425 std::mem::forget(self);
6426 }
6427}
6428
6429impl BufferCollectionTokenGroupSyncResponder {
6430 /// Sends a response to the FIDL transaction.
6431 ///
6432 /// Sets the channel to shutdown if an error occurs.
6433 pub fn send(self) -> Result<(), fidl::Error> {
6434 let _result = self.send_raw();
6435 if _result.is_err() {
6436 self.control_handle.shutdown();
6437 }
6438 self.drop_without_shutdown();
6439 _result
6440 }
6441
6442 /// Similar to "send" but does not shutdown the channel if an error occurs.
6443 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
6444 let _result = self.send_raw();
6445 self.drop_without_shutdown();
6446 _result
6447 }
6448
6449 fn send_raw(&self) -> Result<(), fidl::Error> {
6450 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
6451 (),
6452 self.tx_id,
6453 0x4577e238ae26291,
6454 fidl::encoding::DynamicFlags::empty(),
6455 )
6456 }
6457}
6458
6459#[must_use = "FIDL methods require a response to be sent"]
6460#[derive(Debug)]
6461pub struct BufferCollectionTokenGroupGetNodeRefResponder {
6462 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6463 tx_id: u32,
6464}
6465
6466/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6467/// if the responder is dropped without sending a response, so that the client
6468/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6469impl std::ops::Drop for BufferCollectionTokenGroupGetNodeRefResponder {
6470 fn drop(&mut self) {
6471 self.control_handle.shutdown();
6472 // Safety: drops once, never accessed again
6473 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6474 }
6475}
6476
6477impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupGetNodeRefResponder {
6478 type ControlHandle = BufferCollectionTokenGroupControlHandle;
6479
6480 fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6481 &self.control_handle
6482 }
6483
6484 fn drop_without_shutdown(mut self) {
6485 // Safety: drops once, never accessed again due to mem::forget
6486 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6487 // Prevent Drop from running (which would shut down the channel)
6488 std::mem::forget(self);
6489 }
6490}
6491
6492impl BufferCollectionTokenGroupGetNodeRefResponder {
6493 /// Sends a response to the FIDL transaction.
6494 ///
6495 /// Sets the channel to shutdown if an error occurs.
6496 pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
6497 let _result = self.send_raw(node_ref);
6498 if _result.is_err() {
6499 self.control_handle.shutdown();
6500 }
6501 self.drop_without_shutdown();
6502 _result
6503 }
6504
6505 /// Similar to "send" but does not shutdown the channel if an error occurs.
6506 pub fn send_no_shutdown_on_err(
6507 self,
6508 mut node_ref: fdomain_client::Event,
6509 ) -> Result<(), fidl::Error> {
6510 let _result = self.send_raw(node_ref);
6511 self.drop_without_shutdown();
6512 _result
6513 }
6514
6515 fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
6516 self.control_handle.inner.send::<NodeGetNodeRefResponse>(
6517 (node_ref,),
6518 self.tx_id,
6519 0x467b7c75c35c3b84,
6520 fidl::encoding::DynamicFlags::empty(),
6521 )
6522 }
6523}
6524
6525#[must_use = "FIDL methods require a response to be sent"]
6526#[derive(Debug)]
6527pub struct BufferCollectionTokenGroupIsAlternateForResponder {
6528 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6529 tx_id: u32,
6530}
6531
6532/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6533/// if the responder is dropped without sending a response, so that the client
6534/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6535impl std::ops::Drop for BufferCollectionTokenGroupIsAlternateForResponder {
6536 fn drop(&mut self) {
6537 self.control_handle.shutdown();
6538 // Safety: drops once, never accessed again
6539 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6540 }
6541}
6542
6543impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupIsAlternateForResponder {
6544 type ControlHandle = BufferCollectionTokenGroupControlHandle;
6545
6546 fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6547 &self.control_handle
6548 }
6549
6550 fn drop_without_shutdown(mut self) {
6551 // Safety: drops once, never accessed again due to mem::forget
6552 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6553 // Prevent Drop from running (which would shut down the channel)
6554 std::mem::forget(self);
6555 }
6556}
6557
6558impl BufferCollectionTokenGroupIsAlternateForResponder {
6559 /// Sends a response to the FIDL transaction.
6560 ///
6561 /// Sets the channel to shutdown if an error occurs.
6562 pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6563 let _result = self.send_raw(result);
6564 if _result.is_err() {
6565 self.control_handle.shutdown();
6566 }
6567 self.drop_without_shutdown();
6568 _result
6569 }
6570
6571 /// Similar to "send" but does not shutdown the channel if an error occurs.
6572 pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6573 let _result = self.send_raw(result);
6574 self.drop_without_shutdown();
6575 _result
6576 }
6577
6578 fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
6579 self.control_handle
6580 .inner
6581 .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
6582 result.map(|is_alternate| (is_alternate,)),
6583 self.tx_id,
6584 0x33a2a7aff2776c07,
6585 fidl::encoding::DynamicFlags::empty(),
6586 )
6587 }
6588}
6589
6590#[must_use = "FIDL methods require a response to be sent"]
6591#[derive(Debug)]
6592pub struct BufferCollectionTokenGroupCreateChildrenSyncResponder {
6593 control_handle: std::mem::ManuallyDrop<BufferCollectionTokenGroupControlHandle>,
6594 tx_id: u32,
6595}
6596
6597/// Set the the channel to be shutdown (see [`BufferCollectionTokenGroupControlHandle::shutdown`])
6598/// if the responder is dropped without sending a response, so that the client
6599/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6600impl std::ops::Drop for BufferCollectionTokenGroupCreateChildrenSyncResponder {
6601 fn drop(&mut self) {
6602 self.control_handle.shutdown();
6603 // Safety: drops once, never accessed again
6604 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6605 }
6606}
6607
6608impl fdomain_client::fidl::Responder for BufferCollectionTokenGroupCreateChildrenSyncResponder {
6609 type ControlHandle = BufferCollectionTokenGroupControlHandle;
6610
6611 fn control_handle(&self) -> &BufferCollectionTokenGroupControlHandle {
6612 &self.control_handle
6613 }
6614
6615 fn drop_without_shutdown(mut self) {
6616 // Safety: drops once, never accessed again due to mem::forget
6617 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6618 // Prevent Drop from running (which would shut down the channel)
6619 std::mem::forget(self);
6620 }
6621}
6622
6623impl BufferCollectionTokenGroupCreateChildrenSyncResponder {
6624 /// Sends a response to the FIDL transaction.
6625 ///
6626 /// Sets the channel to shutdown if an error occurs.
6627 pub fn send(
6628 self,
6629 mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
6630 ) -> Result<(), fidl::Error> {
6631 let _result = self.send_raw(tokens);
6632 if _result.is_err() {
6633 self.control_handle.shutdown();
6634 }
6635 self.drop_without_shutdown();
6636 _result
6637 }
6638
6639 /// Similar to "send" but does not shutdown the channel if an error occurs.
6640 pub fn send_no_shutdown_on_err(
6641 self,
6642 mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
6643 ) -> Result<(), fidl::Error> {
6644 let _result = self.send_raw(tokens);
6645 self.drop_without_shutdown();
6646 _result
6647 }
6648
6649 fn send_raw(
6650 &self,
6651 mut tokens: Vec<fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>>,
6652 ) -> Result<(), fidl::Error> {
6653 self.control_handle.inner.send::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(
6654 (tokens.as_mut(),),
6655 self.tx_id,
6656 0x569dc3ca2a98f535,
6657 fidl::encoding::DynamicFlags::empty(),
6658 )
6659 }
6660}
6661
6662#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6663pub struct NodeMarker;
6664
6665impl fdomain_client::fidl::ProtocolMarker for NodeMarker {
6666 type Proxy = NodeProxy;
6667 type RequestStream = NodeRequestStream;
6668
6669 const DEBUG_NAME: &'static str = "(anonymous) Node";
6670}
6671pub type NodeIsAlternateForResult = Result<bool, i32>;
6672
6673pub trait NodeProxyInterface: Send + Sync {
6674 type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6675 fn r#sync(&self) -> Self::SyncResponseFut;
6676 fn r#close(&self) -> Result<(), fidl::Error>;
6677 fn r#set_name(&self, priority: u32, name: &str) -> Result<(), fidl::Error>;
6678 fn r#set_debug_client_info(&self, name: &str, id: u64) -> Result<(), fidl::Error>;
6679 fn r#set_debug_timeout_log_deadline(&self, deadline: i64) -> Result<(), fidl::Error>;
6680 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error>;
6681 type GetNodeRefResponseFut: std::future::Future<Output = Result<fdomain_client::Event, fidl::Error>>
6682 + Send;
6683 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut;
6684 type IsAlternateForResponseFut: std::future::Future<Output = Result<NodeIsAlternateForResult, fidl::Error>>
6685 + Send;
6686 fn r#is_alternate_for(
6687 &self,
6688 node_ref: fdomain_client::Event,
6689 ) -> Self::IsAlternateForResponseFut;
6690}
6691
6692#[derive(Debug, Clone)]
6693pub struct NodeProxy {
6694 client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
6695}
6696
6697impl fdomain_client::fidl::Proxy for NodeProxy {
6698 type Protocol = NodeMarker;
6699
6700 fn from_channel(inner: fdomain_client::Channel) -> Self {
6701 Self::new(inner)
6702 }
6703
6704 fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6705 self.client.into_channel().map_err(|client| Self { client })
6706 }
6707
6708 fn as_channel(&self) -> &fdomain_client::Channel {
6709 self.client.as_channel()
6710 }
6711}
6712
6713impl NodeProxy {
6714 /// Create a new Proxy for fuchsia.sysmem/Node.
6715 pub fn new(channel: fdomain_client::Channel) -> Self {
6716 let protocol_name = <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6717 Self { client: fidl::client::Client::new(channel, protocol_name) }
6718 }
6719
6720 /// Get a Stream of events from the remote end of the protocol.
6721 ///
6722 /// # Panics
6723 ///
6724 /// Panics if the event stream was already taken.
6725 pub fn take_event_stream(&self) -> NodeEventStream {
6726 NodeEventStream { event_receiver: self.client.take_event_receiver() }
6727 }
6728
6729 /// Ensure that previous messages, including Duplicate() messages on a
6730 /// token, collection, or group, have been received server side.
6731 ///
6732 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
6733 /// valid sysmem token risks the Sync() hanging forever. See
6734 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
6735 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
6736 /// Another way is to pass the token to BindSharedCollection(), which also
6737 /// validates the token as part of exchanging it for a BufferCollection
6738 /// channel, and BufferCollection Sync() can then be used.
6739 ///
6740 /// After a Sync(), it's then safe to send the client end of token_request
6741 /// to another participant knowing the server will recognize the token when
6742 /// it's sent into BindSharedCollection() by the other participant.
6743 ///
6744 /// Other options include waiting for each token.Duplicate() to complete
6745 /// individually (using separate call to token.Sync() after each), or
6746 /// calling Sync() on BufferCollection after the token has been turned in
6747 /// via BindSharedCollection().
6748 ///
6749 /// Another way to mitigate is to avoid calling Sync() on the token, and
6750 /// instead later deal with potential failure of BufferCollection.Sync() if
6751 /// the original token was invalid. This option can be preferable from a
6752 /// performance point of view, but requires client code to delay sending
6753 /// tokens duplicated from this token until after client code has converted
6754 /// the duplicating token to a BufferCollection and received successful
6755 /// response from BufferCollection.Sync().
6756 ///
6757 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
6758 /// When BufferCollection.Sync() isn't feasible, the caller must already
6759 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
6760 /// hang forever. See ValidateBufferCollectionToken() to check token
6761 /// validity first if the token isn't already known to be (is/was) valid.
6762 pub fn r#sync(
6763 &self,
6764 ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6765 NodeProxyInterface::r#sync(self)
6766 }
6767
6768 /// On a BufferCollectionToken channel:
6769 ///
6770 /// Normally a participant will convert a BufferCollectionToken into a
6771 /// BufferCollection view, but a participant is also free to Close() the
6772 /// token (and then close the channel immediately or shortly later in
6773 /// response to server closing its end), which avoids causing logical buffer
6774 /// collection failure. Â Normally an unexpected token channel close will
6775 /// cause logical buffer collection failure (the only exceptions being
6776 /// certain cases involving AttachToken() or SetDispensable()).
6777 ///
6778 /// On a BufferCollection channel:
6779 ///
6780 /// By default the server handles unexpected failure of a BufferCollection
6781 /// by failing the whole logical buffer collection. Partly this is to
6782 /// expedite closing VMO handles to reclaim memory when any participant
6783 /// fails. If a participant would like to cleanly close a BufferCollection
6784 /// view without causing logical buffer collection failure, the participant
6785 /// can send Close() before closing the client end of the BufferCollection
6786 /// channel. If this is the last BufferCollection view, the logical buffer
6787 /// collection will still go away. The Close() can occur before or after
6788 /// SetConstraints(). If before SetConstraints(), the buffer collection
6789 /// won't require constraints from this node in order to allocate. If
6790 /// after SetConstraints(), the constraints are retained and aggregated
6791 /// along with any subsequent logical allocation(s), despite the lack of
6792 /// channel connection.
6793 ///
6794 /// On a BufferCollectionTokenGroup channel:
6795 ///
6796 /// By default, unexpected failure of a BufferCollectionTokenGroup will
6797 /// trigger failure of the logical BufferCollectionTokenGroup and will
6798 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
6799 /// channel without failing the logical group or propagating failure, send
6800 /// Close() before closing the channel client endpoint.
6801 ///
6802 /// If Close() occurs before AllChildrenPresent(), the logical buffer
6803 /// collection will still fail despite the Close() (because sysmem can't be
6804 /// sure whether all relevant children were created, so it's ambiguous
6805 /// whether all relevant constraints will be provided to sysmem). If
6806 /// Close() occurs after AllChildrenPresent(), the children and all their
6807 /// constraints remain intact (just as they would if the
6808 /// BufferCollectionTokenGroup channel had remained open), and the close
6809 /// doesn't trigger or propagate failure.
6810 pub fn r#close(&self) -> Result<(), fidl::Error> {
6811 NodeProxyInterface::r#close(self)
6812 }
6813
6814 /// Set a name for VMOs in this buffer collection. The name may be truncated
6815 /// shorter. The name only affects VMOs allocated after it's set - this call
6816 /// does not rename existing VMOs. If multiple clients set different names
6817 /// then the larger priority value will win.
6818 pub fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
6819 NodeProxyInterface::r#set_name(self, priority, name)
6820 }
6821
6822 /// Set information about the current client that can be used by sysmem to
6823 /// help debug leaking memory and hangs waiting for constraints. |name| can
6824 /// be an arbitrary string, but the current process name (see
6825 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
6826 /// arbitrary id, but the current process ID (see
6827 /// fsl::GetCurrentProcessKoid()) is a good default.
6828 ///
6829 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
6830 /// indicate which client is closing their channel first, leading to
6831 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
6832 /// over, but if happening earlier than expected, the
6833 /// client-channel-specific name can help diagnose where the failure is
6834 /// first coming from, from sysmem's point of view).
6835 ///
6836 /// By default (unless overriden by this message or using
6837 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
6838 /// parent Node at the time the child Node is created. While this can be
6839 /// better than nothing, it's often better for each participant to use
6840 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
6841 /// info directly relevant to the current client. Also, SetVerboseLogging()
6842 /// can be used to help disambiguate if a Node is suspected of having info
6843 /// that was copied from its parent.
6844 pub fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
6845 NodeProxyInterface::r#set_debug_client_info(self, name, id)
6846 }
6847
6848 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
6849 /// after creating a collection. Clients can call this method to change
6850 /// when the log is printed. If multiple client set the deadline, it's
6851 /// unspecified which deadline will take effect.
6852 pub fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
6853 NodeProxyInterface::r#set_debug_timeout_log_deadline(self, deadline)
6854 }
6855
6856 /// Verbose logging includes constraints set via SetConstraints() from each
6857 /// client along with info set via SetDebugClientInfo() and the structure of
6858 /// the tree of Node(s).
6859 ///
6860 /// Normally sysmem prints only a single line complaint when aggregation
6861 /// fails, with just the specific detailed reason that aggregation failed,
6862 /// with minimal context. While this is often enough to diagnose a problem
6863 /// if only a small change was made and the system had been working before
6864 /// the small change, it's often not particularly helpful for getting a new
6865 /// buffer collection to work for the first time. Especially with more
6866 /// complex trees of nodes, involving things like AttachToken(),
6867 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
6868 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
6869 /// looks like and why it's failing a logical allocation, or why a tree or
6870 /// sub-tree is failing sooner than expected.
6871 ///
6872 /// The intent of the extra logging is to be acceptable from a performance
6873 /// point of view, if only enabled on a low number of buffer collections.
6874 /// If we're not tracking down a bug, we shouldn't send this message.
6875 ///
6876 /// If too many participants leave verbose logging enabled, we may end up
6877 /// needing to require that system-wide sysmem verbose logging be permitted
6878 /// via some other setting, to avoid sysmem spamming the log too much due to
6879 /// this message.
6880 ///
6881 /// This may be a NOP for some nodes due to intentional policy associated
6882 /// with the node, if we don't trust a node enough to let it turn on verbose
6883 /// logging.
6884 pub fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
6885 NodeProxyInterface::r#set_verbose_logging(self)
6886 }
6887
6888 /// This gets an event handle that can be used as a parameter to
6889 /// IsAlternateFor() called on any Node. The client will not be granted the
6890 /// right to signal this event, as this handle should only be used as proof
6891 /// that the client obtained this handle from this Node.
6892 ///
6893 /// Because this is a get not a set, no Sync() is needed between the
6894 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
6895 /// potentially being on different channels.
6896 ///
6897 /// See also IsAlternateFor().
6898 pub fn r#get_node_ref(
6899 &self,
6900 ) -> fidl::client::QueryResponseFut<
6901 fdomain_client::Event,
6902 fdomain_client::fidl::FDomainResourceDialect,
6903 > {
6904 NodeProxyInterface::r#get_node_ref(self)
6905 }
6906
6907 /// This checks whether the calling node is in a subtree rooted at a
6908 /// different child token of a common parent BufferCollectionTokenGroup, in
6909 /// relation to the passed-in node_ref.
6910 ///
6911 /// This call is for assisting with admission control de-duplication, and
6912 /// with debugging.
6913 ///
6914 /// The node_ref must be obtained using GetNodeRef() of a
6915 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
6916 ///
6917 /// The node_ref can be a duplicated handle; it's not necessary to call
6918 /// GetNodeRef() for every call to IsAlternateFor().
6919 ///
6920 /// If a calling token may not actually be a valid token at all due to
6921 /// a potentially hostile/untrusted provider of the token, call
6922 /// ValidateBufferCollectionToken() first instead of potentially getting
6923 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
6924 /// token not being a real token (not really talking to sysmem). Another
6925 /// option is to call BindSharedCollection with this token first which also
6926 /// validates the token along with converting it to a BufferCollection, then
6927 /// call BufferCollection IsAlternateFor().
6928 ///
6929 /// error values:
6930 ///
6931 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
6932 /// buffer collection as the calling Node. Before logical allocation and
6933 /// within the same logical allocation sub-tree, this essentially means that
6934 /// the node_ref was never part of this logical buffer collection, since
6935 /// before logical allocation all node_refs that come into existence remain
6936 /// in existence at least until logical allocation (including Node(s) that
6937 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
6938 /// to be returned, this Node's channel needs to still be connected server
6939 /// side, which won't be the case if the whole logical allocation has
6940 /// failed. After logical allocation or in a different logical allocation
6941 /// sub-tree there are additional potential reasons for this error. For
6942 /// example a different logical allocation (separated from this Node(s)
6943 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
6944 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
6945 /// exist and may select a different child sub-tree than the sub-tree the
6946 /// node_ref is in causing deletion of the node_ref Node. The only time
6947 /// sysmem keeps a Node around after that Node has no corresponding channel
6948 /// is when Close() is used and the Node's sub-tree has not yet failed.
6949 /// Another reason for this error is if the node_ref is an eventpair handle
6950 /// with sufficient rights, but isn't actually a real node_ref obtained from
6951 /// GetNodeRef().
6952 ///
6953 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
6954 /// eventpair handle, or doesn't have the needed rights expected on a real
6955 /// node_ref.
6956 ///
6957 /// No other failing status codes are returned by this call. However,
6958 /// sysmem may add additional codes in future, so the client should have
6959 /// sensible default handling for any failing status code.
6960 ///
6961 /// On success, is_alternate has the following meaning:
6962 /// * true - The first parent node in common between the calling node and
6963 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
6964 /// the calling Node and the node_ref Node will _not_ have both their
6965 /// constraints apply - rather sysmem will choose one or the other of
6966 /// the constraints - never both. This is because only one child of
6967 /// a BufferCollectionTokenGroup is selected during logical allocation,
6968 /// with only that one child's sub-tree contributing to constraints
6969 /// aggregation.
6970 /// * false - The first parent node in common between the calling Node and
6971 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
6972 /// this means the first parent node in common is a
6973 /// BufferCollectionToken or BufferCollection (regardless of not
6974 /// Close()ed or Close()ed). This means that the calling Node and the
6975 /// node_ref Node _may_ have both their constraints apply during
6976 /// constraints aggregation of the logical allocation, if both Node(s)
6977 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
6978 /// In this case, there is no BufferCollectionTokenGroup that will
6979 /// directly prevent the two Node(s) from both being selected and their
6980 /// constraints both aggregated, but even when false, one or both
6981 /// Node(s) may still be eliminated from consideration if one or both
6982 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
6983 /// which selects a child sub-tree other than the sub-tree containing
6984 /// the calling Node or node_ref Node.
6985 pub fn r#is_alternate_for(
6986 &self,
6987 mut node_ref: fdomain_client::Event,
6988 ) -> fidl::client::QueryResponseFut<
6989 NodeIsAlternateForResult,
6990 fdomain_client::fidl::FDomainResourceDialect,
6991 > {
6992 NodeProxyInterface::r#is_alternate_for(self, node_ref)
6993 }
6994}
6995
6996impl NodeProxyInterface for NodeProxy {
6997 type SyncResponseFut =
6998 fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
6999 fn r#sync(&self) -> Self::SyncResponseFut {
7000 fn _decode(
7001 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7002 ) -> Result<(), fidl::Error> {
7003 let _response = fidl::client::decode_transaction_body::<
7004 fidl::encoding::EmptyPayload,
7005 fdomain_client::fidl::FDomainResourceDialect,
7006 0x4577e238ae26291,
7007 >(_buf?)?;
7008 Ok(_response)
7009 }
7010 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7011 (),
7012 0x4577e238ae26291,
7013 fidl::encoding::DynamicFlags::empty(),
7014 _decode,
7015 )
7016 }
7017
7018 fn r#close(&self) -> Result<(), fidl::Error> {
7019 self.client.send::<fidl::encoding::EmptyPayload>(
7020 (),
7021 0x5b1d7a4f5681fca7,
7022 fidl::encoding::DynamicFlags::empty(),
7023 )
7024 }
7025
7026 fn r#set_name(&self, mut priority: u32, mut name: &str) -> Result<(), fidl::Error> {
7027 self.client.send::<NodeSetNameRequest>(
7028 (priority, name),
7029 0x77a41bb6217e2443,
7030 fidl::encoding::DynamicFlags::empty(),
7031 )
7032 }
7033
7034 fn r#set_debug_client_info(&self, mut name: &str, mut id: u64) -> Result<(), fidl::Error> {
7035 self.client.send::<NodeSetDebugClientInfoRequest>(
7036 (name, id),
7037 0x7275759070eb5ee2,
7038 fidl::encoding::DynamicFlags::empty(),
7039 )
7040 }
7041
7042 fn r#set_debug_timeout_log_deadline(&self, mut deadline: i64) -> Result<(), fidl::Error> {
7043 self.client.send::<NodeSetDebugTimeoutLogDeadlineRequest>(
7044 (deadline,),
7045 0x46d38f4772638867,
7046 fidl::encoding::DynamicFlags::empty(),
7047 )
7048 }
7049
7050 fn r#set_verbose_logging(&self) -> Result<(), fidl::Error> {
7051 self.client.send::<fidl::encoding::EmptyPayload>(
7052 (),
7053 0x6bfbe2cf1701d288,
7054 fidl::encoding::DynamicFlags::empty(),
7055 )
7056 }
7057
7058 type GetNodeRefResponseFut = fidl::client::QueryResponseFut<
7059 fdomain_client::Event,
7060 fdomain_client::fidl::FDomainResourceDialect,
7061 >;
7062 fn r#get_node_ref(&self) -> Self::GetNodeRefResponseFut {
7063 fn _decode(
7064 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7065 ) -> Result<fdomain_client::Event, fidl::Error> {
7066 let _response = fidl::client::decode_transaction_body::<
7067 NodeGetNodeRefResponse,
7068 fdomain_client::fidl::FDomainResourceDialect,
7069 0x467b7c75c35c3b84,
7070 >(_buf?)?;
7071 Ok(_response.node_ref)
7072 }
7073 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Event>(
7074 (),
7075 0x467b7c75c35c3b84,
7076 fidl::encoding::DynamicFlags::empty(),
7077 _decode,
7078 )
7079 }
7080
7081 type IsAlternateForResponseFut = fidl::client::QueryResponseFut<
7082 NodeIsAlternateForResult,
7083 fdomain_client::fidl::FDomainResourceDialect,
7084 >;
7085 fn r#is_alternate_for(
7086 &self,
7087 mut node_ref: fdomain_client::Event,
7088 ) -> Self::IsAlternateForResponseFut {
7089 fn _decode(
7090 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7091 ) -> Result<NodeIsAlternateForResult, fidl::Error> {
7092 let _response = fidl::client::decode_transaction_body::<
7093 fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>,
7094 fdomain_client::fidl::FDomainResourceDialect,
7095 0x33a2a7aff2776c07,
7096 >(_buf?)?;
7097 Ok(_response.map(|x| x.is_alternate))
7098 }
7099 self.client.send_query_and_decode::<NodeIsAlternateForRequest, NodeIsAlternateForResult>(
7100 (node_ref,),
7101 0x33a2a7aff2776c07,
7102 fidl::encoding::DynamicFlags::empty(),
7103 _decode,
7104 )
7105 }
7106}
7107
7108pub struct NodeEventStream {
7109 event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
7110}
7111
7112impl std::marker::Unpin for NodeEventStream {}
7113
7114impl futures::stream::FusedStream for NodeEventStream {
7115 fn is_terminated(&self) -> bool {
7116 self.event_receiver.is_terminated()
7117 }
7118}
7119
7120impl futures::Stream for NodeEventStream {
7121 type Item = Result<NodeEvent, fidl::Error>;
7122
7123 fn poll_next(
7124 mut self: std::pin::Pin<&mut Self>,
7125 cx: &mut std::task::Context<'_>,
7126 ) -> std::task::Poll<Option<Self::Item>> {
7127 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7128 &mut self.event_receiver,
7129 cx
7130 )?) {
7131 Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
7132 None => std::task::Poll::Ready(None),
7133 }
7134 }
7135}
7136
7137#[derive(Debug)]
7138pub enum NodeEvent {}
7139
7140impl NodeEvent {
7141 /// Decodes a message buffer as a [`NodeEvent`].
7142 fn decode(
7143 mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7144 ) -> Result<NodeEvent, fidl::Error> {
7145 let (bytes, _handles) = buf.split_mut();
7146 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7147 debug_assert_eq!(tx_header.tx_id, 0);
7148 match tx_header.ordinal {
7149 _ => Err(fidl::Error::UnknownOrdinal {
7150 ordinal: tx_header.ordinal,
7151 protocol_name: <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7152 }),
7153 }
7154 }
7155}
7156
7157/// A Stream of incoming requests for fuchsia.sysmem/Node.
7158pub struct NodeRequestStream {
7159 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7160 is_terminated: bool,
7161}
7162
7163impl std::marker::Unpin for NodeRequestStream {}
7164
7165impl futures::stream::FusedStream for NodeRequestStream {
7166 fn is_terminated(&self) -> bool {
7167 self.is_terminated
7168 }
7169}
7170
7171impl fdomain_client::fidl::RequestStream for NodeRequestStream {
7172 type Protocol = NodeMarker;
7173 type ControlHandle = NodeControlHandle;
7174
7175 fn from_channel(channel: fdomain_client::Channel) -> Self {
7176 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7177 }
7178
7179 fn control_handle(&self) -> Self::ControlHandle {
7180 NodeControlHandle { inner: self.inner.clone() }
7181 }
7182
7183 fn into_inner(
7184 self,
7185 ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
7186 {
7187 (self.inner, self.is_terminated)
7188 }
7189
7190 fn from_inner(
7191 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7192 is_terminated: bool,
7193 ) -> Self {
7194 Self { inner, is_terminated }
7195 }
7196}
7197
7198impl futures::Stream for NodeRequestStream {
7199 type Item = Result<NodeRequest, fidl::Error>;
7200
7201 fn poll_next(
7202 mut self: std::pin::Pin<&mut Self>,
7203 cx: &mut std::task::Context<'_>,
7204 ) -> std::task::Poll<Option<Self::Item>> {
7205 let this = &mut *self;
7206 if this.inner.check_shutdown(cx) {
7207 this.is_terminated = true;
7208 return std::task::Poll::Ready(None);
7209 }
7210 if this.is_terminated {
7211 panic!("polled NodeRequestStream after completion");
7212 }
7213 fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
7214 |bytes, handles| {
7215 match this.inner.channel().read_etc(cx, bytes, handles) {
7216 std::task::Poll::Ready(Ok(())) => {}
7217 std::task::Poll::Pending => return std::task::Poll::Pending,
7218 std::task::Poll::Ready(Err(None)) => {
7219 this.is_terminated = true;
7220 return std::task::Poll::Ready(None);
7221 }
7222 std::task::Poll::Ready(Err(Some(e))) => {
7223 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7224 e.into(),
7225 ))));
7226 }
7227 }
7228
7229 // A message has been received from the channel
7230 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7231
7232 std::task::Poll::Ready(Some(match header.ordinal {
7233 0x4577e238ae26291 => {
7234 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7235 let mut req = fidl::new_empty!(
7236 fidl::encoding::EmptyPayload,
7237 fdomain_client::fidl::FDomainResourceDialect
7238 );
7239 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7240 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7241 Ok(NodeRequest::Sync {
7242 responder: NodeSyncResponder {
7243 control_handle: std::mem::ManuallyDrop::new(control_handle),
7244 tx_id: header.tx_id,
7245 },
7246 })
7247 }
7248 0x5b1d7a4f5681fca7 => {
7249 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7250 let mut req = fidl::new_empty!(
7251 fidl::encoding::EmptyPayload,
7252 fdomain_client::fidl::FDomainResourceDialect
7253 );
7254 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7255 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7256 Ok(NodeRequest::Close { control_handle })
7257 }
7258 0x77a41bb6217e2443 => {
7259 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7260 let mut req = fidl::new_empty!(
7261 NodeSetNameRequest,
7262 fdomain_client::fidl::FDomainResourceDialect
7263 );
7264 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetNameRequest>(&header, _body_bytes, handles, &mut req)?;
7265 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7266 Ok(NodeRequest::SetName {
7267 priority: req.priority,
7268 name: req.name,
7269
7270 control_handle,
7271 })
7272 }
7273 0x7275759070eb5ee2 => {
7274 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7275 let mut req = fidl::new_empty!(
7276 NodeSetDebugClientInfoRequest,
7277 fdomain_client::fidl::FDomainResourceDialect
7278 );
7279 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugClientInfoRequest>(&header, _body_bytes, handles, &mut req)?;
7280 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7281 Ok(NodeRequest::SetDebugClientInfo {
7282 name: req.name,
7283 id: req.id,
7284
7285 control_handle,
7286 })
7287 }
7288 0x46d38f4772638867 => {
7289 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7290 let mut req = fidl::new_empty!(
7291 NodeSetDebugTimeoutLogDeadlineRequest,
7292 fdomain_client::fidl::FDomainResourceDialect
7293 );
7294 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeSetDebugTimeoutLogDeadlineRequest>(&header, _body_bytes, handles, &mut req)?;
7295 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7296 Ok(NodeRequest::SetDebugTimeoutLogDeadline {
7297 deadline: req.deadline,
7298
7299 control_handle,
7300 })
7301 }
7302 0x6bfbe2cf1701d288 => {
7303 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7304 let mut req = fidl::new_empty!(
7305 fidl::encoding::EmptyPayload,
7306 fdomain_client::fidl::FDomainResourceDialect
7307 );
7308 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7309 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7310 Ok(NodeRequest::SetVerboseLogging { control_handle })
7311 }
7312 0x467b7c75c35c3b84 => {
7313 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7314 let mut req = fidl::new_empty!(
7315 fidl::encoding::EmptyPayload,
7316 fdomain_client::fidl::FDomainResourceDialect
7317 );
7318 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7319 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7320 Ok(NodeRequest::GetNodeRef {
7321 responder: NodeGetNodeRefResponder {
7322 control_handle: std::mem::ManuallyDrop::new(control_handle),
7323 tx_id: header.tx_id,
7324 },
7325 })
7326 }
7327 0x33a2a7aff2776c07 => {
7328 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7329 let mut req = fidl::new_empty!(
7330 NodeIsAlternateForRequest,
7331 fdomain_client::fidl::FDomainResourceDialect
7332 );
7333 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<NodeIsAlternateForRequest>(&header, _body_bytes, handles, &mut req)?;
7334 let control_handle = NodeControlHandle { inner: this.inner.clone() };
7335 Ok(NodeRequest::IsAlternateFor {
7336 node_ref: req.node_ref,
7337
7338 responder: NodeIsAlternateForResponder {
7339 control_handle: std::mem::ManuallyDrop::new(control_handle),
7340 tx_id: header.tx_id,
7341 },
7342 })
7343 }
7344 _ => Err(fidl::Error::UnknownOrdinal {
7345 ordinal: header.ordinal,
7346 protocol_name:
7347 <NodeMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7348 }),
7349 }))
7350 },
7351 )
7352 }
7353}
7354
7355#[derive(Debug)]
7356pub enum NodeRequest {
7357 /// Ensure that previous messages, including Duplicate() messages on a
7358 /// token, collection, or group, have been received server side.
7359 ///
7360 /// Calling BufferCollectionToken.Sync() on a token that isn't/wasn't a
7361 /// valid sysmem token risks the Sync() hanging forever. See
7362 /// ValidateBufferCollectionToken() for one way to mitigate the possibility
7363 /// of a hostile/fake BufferCollectionToken at the cost of one round trip.
7364 /// Another way is to pass the token to BindSharedCollection(), which also
7365 /// validates the token as part of exchanging it for a BufferCollection
7366 /// channel, and BufferCollection Sync() can then be used.
7367 ///
7368 /// After a Sync(), it's then safe to send the client end of token_request
7369 /// to another participant knowing the server will recognize the token when
7370 /// it's sent into BindSharedCollection() by the other participant.
7371 ///
7372 /// Other options include waiting for each token.Duplicate() to complete
7373 /// individually (using separate call to token.Sync() after each), or
7374 /// calling Sync() on BufferCollection after the token has been turned in
7375 /// via BindSharedCollection().
7376 ///
7377 /// Another way to mitigate is to avoid calling Sync() on the token, and
7378 /// instead later deal with potential failure of BufferCollection.Sync() if
7379 /// the original token was invalid. This option can be preferable from a
7380 /// performance point of view, but requires client code to delay sending
7381 /// tokens duplicated from this token until after client code has converted
7382 /// the duplicating token to a BufferCollection and received successful
7383 /// response from BufferCollection.Sync().
7384 ///
7385 /// Prefer using BufferCollection.Sync() instead, when feasible (see above).
7386 /// When BufferCollection.Sync() isn't feasible, the caller must already
7387 /// know that this token is/was valid, or BufferCollectionToken.Sync() may
7388 /// hang forever. See ValidateBufferCollectionToken() to check token
7389 /// validity first if the token isn't already known to be (is/was) valid.
7390 Sync { responder: NodeSyncResponder },
7391 /// On a BufferCollectionToken channel:
7392 ///
7393 /// Normally a participant will convert a BufferCollectionToken into a
7394 /// BufferCollection view, but a participant is also free to Close() the
7395 /// token (and then close the channel immediately or shortly later in
7396 /// response to server closing its end), which avoids causing logical buffer
7397 /// collection failure. Â Normally an unexpected token channel close will
7398 /// cause logical buffer collection failure (the only exceptions being
7399 /// certain cases involving AttachToken() or SetDispensable()).
7400 ///
7401 /// On a BufferCollection channel:
7402 ///
7403 /// By default the server handles unexpected failure of a BufferCollection
7404 /// by failing the whole logical buffer collection. Partly this is to
7405 /// expedite closing VMO handles to reclaim memory when any participant
7406 /// fails. If a participant would like to cleanly close a BufferCollection
7407 /// view without causing logical buffer collection failure, the participant
7408 /// can send Close() before closing the client end of the BufferCollection
7409 /// channel. If this is the last BufferCollection view, the logical buffer
7410 /// collection will still go away. The Close() can occur before or after
7411 /// SetConstraints(). If before SetConstraints(), the buffer collection
7412 /// won't require constraints from this node in order to allocate. If
7413 /// after SetConstraints(), the constraints are retained and aggregated
7414 /// along with any subsequent logical allocation(s), despite the lack of
7415 /// channel connection.
7416 ///
7417 /// On a BufferCollectionTokenGroup channel:
7418 ///
7419 /// By default, unexpected failure of a BufferCollectionTokenGroup will
7420 /// trigger failure of the logical BufferCollectionTokenGroup and will
7421 /// propagate failure to its parent. To close a BufferCollectionTokenGroup
7422 /// channel without failing the logical group or propagating failure, send
7423 /// Close() before closing the channel client endpoint.
7424 ///
7425 /// If Close() occurs before AllChildrenPresent(), the logical buffer
7426 /// collection will still fail despite the Close() (because sysmem can't be
7427 /// sure whether all relevant children were created, so it's ambiguous
7428 /// whether all relevant constraints will be provided to sysmem). If
7429 /// Close() occurs after AllChildrenPresent(), the children and all their
7430 /// constraints remain intact (just as they would if the
7431 /// BufferCollectionTokenGroup channel had remained open), and the close
7432 /// doesn't trigger or propagate failure.
7433 Close { control_handle: NodeControlHandle },
7434 /// Set a name for VMOs in this buffer collection. The name may be truncated
7435 /// shorter. The name only affects VMOs allocated after it's set - this call
7436 /// does not rename existing VMOs. If multiple clients set different names
7437 /// then the larger priority value will win.
7438 SetName { priority: u32, name: String, control_handle: NodeControlHandle },
7439 /// Set information about the current client that can be used by sysmem to
7440 /// help debug leaking memory and hangs waiting for constraints. |name| can
7441 /// be an arbitrary string, but the current process name (see
7442 /// fsl::GetCurrentProcessName()) is a good default. |id| can be an
7443 /// arbitrary id, but the current process ID (see
7444 /// fsl::GetCurrentProcessKoid()) is a good default.
7445 ///
7446 /// Also used when verbose logging is enabled (see SetVerboseLogging()) to
7447 /// indicate which client is closing their channel first, leading to
7448 /// sub-tree failure (which can be normal if the purpose of the sub-tree is
7449 /// over, but if happening earlier than expected, the
7450 /// client-channel-specific name can help diagnose where the failure is
7451 /// first coming from, from sysmem's point of view).
7452 ///
7453 /// By default (unless overriden by this message or using
7454 /// Allocator.SetDebugClientInfo()), a Node will copy info from its
7455 /// parent Node at the time the child Node is created. While this can be
7456 /// better than nothing, it's often better for each participant to use
7457 /// Node.SetDebugClientInfo() or Allocator.SetDebugClientInfo() to keep the
7458 /// info directly relevant to the current client. Also, SetVerboseLogging()
7459 /// can be used to help disambiguate if a Node is suspected of having info
7460 /// that was copied from its parent.
7461 SetDebugClientInfo { name: String, id: u64, control_handle: NodeControlHandle },
7462 /// Sysmem logs a warning if not all clients have set constraints 5 seconds
7463 /// after creating a collection. Clients can call this method to change
7464 /// when the log is printed. If multiple client set the deadline, it's
7465 /// unspecified which deadline will take effect.
7466 SetDebugTimeoutLogDeadline { deadline: i64, control_handle: NodeControlHandle },
7467 /// Verbose logging includes constraints set via SetConstraints() from each
7468 /// client along with info set via SetDebugClientInfo() and the structure of
7469 /// the tree of Node(s).
7470 ///
7471 /// Normally sysmem prints only a single line complaint when aggregation
7472 /// fails, with just the specific detailed reason that aggregation failed,
7473 /// with minimal context. While this is often enough to diagnose a problem
7474 /// if only a small change was made and the system had been working before
7475 /// the small change, it's often not particularly helpful for getting a new
7476 /// buffer collection to work for the first time. Especially with more
7477 /// complex trees of nodes, involving things like AttachToken(),
7478 /// SetDispensable(), BufferCollectionTokenGroup nodes, and associated
7479 /// sub-trees of nodes, verbose logging may help in diagnosing what the tree
7480 /// looks like and why it's failing a logical allocation, or why a tree or
7481 /// sub-tree is failing sooner than expected.
7482 ///
7483 /// The intent of the extra logging is to be acceptable from a performance
7484 /// point of view, if only enabled on a low number of buffer collections.
7485 /// If we're not tracking down a bug, we shouldn't send this message.
7486 ///
7487 /// If too many participants leave verbose logging enabled, we may end up
7488 /// needing to require that system-wide sysmem verbose logging be permitted
7489 /// via some other setting, to avoid sysmem spamming the log too much due to
7490 /// this message.
7491 ///
7492 /// This may be a NOP for some nodes due to intentional policy associated
7493 /// with the node, if we don't trust a node enough to let it turn on verbose
7494 /// logging.
7495 SetVerboseLogging { control_handle: NodeControlHandle },
7496 /// This gets an event handle that can be used as a parameter to
7497 /// IsAlternateFor() called on any Node. The client will not be granted the
7498 /// right to signal this event, as this handle should only be used as proof
7499 /// that the client obtained this handle from this Node.
7500 ///
7501 /// Because this is a get not a set, no Sync() is needed between the
7502 /// GetNodeRef() and the call to IsAlternateFor(), despite the two calls
7503 /// potentially being on different channels.
7504 ///
7505 /// See also IsAlternateFor().
7506 GetNodeRef { responder: NodeGetNodeRefResponder },
7507 /// This checks whether the calling node is in a subtree rooted at a
7508 /// different child token of a common parent BufferCollectionTokenGroup, in
7509 /// relation to the passed-in node_ref.
7510 ///
7511 /// This call is for assisting with admission control de-duplication, and
7512 /// with debugging.
7513 ///
7514 /// The node_ref must be obtained using GetNodeRef() of a
7515 /// BufferCollectionToken, BufferCollection, or BufferCollectionTokenGroup.
7516 ///
7517 /// The node_ref can be a duplicated handle; it's not necessary to call
7518 /// GetNodeRef() for every call to IsAlternateFor().
7519 ///
7520 /// If a calling token may not actually be a valid token at all due to
7521 /// a potentially hostile/untrusted provider of the token, call
7522 /// ValidateBufferCollectionToken() first instead of potentially getting
7523 /// stuck indefinitely if IsAlternateFor() never responds due to a calling
7524 /// token not being a real token (not really talking to sysmem). Another
7525 /// option is to call BindSharedCollection with this token first which also
7526 /// validates the token along with converting it to a BufferCollection, then
7527 /// call BufferCollection IsAlternateFor().
7528 ///
7529 /// error values:
7530 ///
7531 /// ZX_ERR_NOT_FOUND means the node_ref wasn't found within the same logical
7532 /// buffer collection as the calling Node. Before logical allocation and
7533 /// within the same logical allocation sub-tree, this essentially means that
7534 /// the node_ref was never part of this logical buffer collection, since
7535 /// before logical allocation all node_refs that come into existence remain
7536 /// in existence at least until logical allocation (including Node(s) that
7537 /// have done a Close() and closed their channel), and for ZX_ERR_NOT_FOUND
7538 /// to be returned, this Node's channel needs to still be connected server
7539 /// side, which won't be the case if the whole logical allocation has
7540 /// failed. After logical allocation or in a different logical allocation
7541 /// sub-tree there are additional potential reasons for this error. For
7542 /// example a different logical allocation (separated from this Node(s)
7543 /// logical allocation by an AttachToken() or SetDispensable()) can fail its
7544 /// sub-tree deleting those Node(s), or a BufferCollectionTokenGroup may
7545 /// exist and may select a different child sub-tree than the sub-tree the
7546 /// node_ref is in causing deletion of the node_ref Node. The only time
7547 /// sysmem keeps a Node around after that Node has no corresponding channel
7548 /// is when Close() is used and the Node's sub-tree has not yet failed.
7549 /// Another reason for this error is if the node_ref is an eventpair handle
7550 /// with sufficient rights, but isn't actually a real node_ref obtained from
7551 /// GetNodeRef().
7552 ///
7553 /// ZX_ERR_INVALID_ARGS means the caller passed a node_ref that isn't an
7554 /// eventpair handle, or doesn't have the needed rights expected on a real
7555 /// node_ref.
7556 ///
7557 /// No other failing status codes are returned by this call. However,
7558 /// sysmem may add additional codes in future, so the client should have
7559 /// sensible default handling for any failing status code.
7560 ///
7561 /// On success, is_alternate has the following meaning:
7562 /// * true - The first parent node in common between the calling node and
7563 /// the node_ref Node is a BufferCollectionTokenGroup. This means that
7564 /// the calling Node and the node_ref Node will _not_ have both their
7565 /// constraints apply - rather sysmem will choose one or the other of
7566 /// the constraints - never both. This is because only one child of
7567 /// a BufferCollectionTokenGroup is selected during logical allocation,
7568 /// with only that one child's sub-tree contributing to constraints
7569 /// aggregation.
7570 /// * false - The first parent node in common between the calling Node and
7571 /// the node_ref Node is not a BufferCollectionTokenGroup. Currently,
7572 /// this means the first parent node in common is a
7573 /// BufferCollectionToken or BufferCollection (regardless of not
7574 /// Close()ed or Close()ed). This means that the calling Node and the
7575 /// node_ref Node _may_ have both their constraints apply during
7576 /// constraints aggregation of the logical allocation, if both Node(s)
7577 /// are selected by any parent BufferCollectionTokenGroup(s) involved.
7578 /// In this case, there is no BufferCollectionTokenGroup that will
7579 /// directly prevent the two Node(s) from both being selected and their
7580 /// constraints both aggregated, but even when false, one or both
7581 /// Node(s) may still be eliminated from consideration if one or both
7582 /// Node(s) has a direct or indirect parent BufferCollectionTokenGroup
7583 /// which selects a child sub-tree other than the sub-tree containing
7584 /// the calling Node or node_ref Node.
7585 IsAlternateFor { node_ref: fdomain_client::Event, responder: NodeIsAlternateForResponder },
7586}
7587
7588impl NodeRequest {
7589 #[allow(irrefutable_let_patterns)]
7590 pub fn into_sync(self) -> Option<(NodeSyncResponder)> {
7591 if let NodeRequest::Sync { responder } = self { Some((responder)) } else { None }
7592 }
7593
7594 #[allow(irrefutable_let_patterns)]
7595 pub fn into_close(self) -> Option<(NodeControlHandle)> {
7596 if let NodeRequest::Close { control_handle } = self { Some((control_handle)) } else { None }
7597 }
7598
7599 #[allow(irrefutable_let_patterns)]
7600 pub fn into_set_name(self) -> Option<(u32, String, NodeControlHandle)> {
7601 if let NodeRequest::SetName { priority, name, control_handle } = self {
7602 Some((priority, name, control_handle))
7603 } else {
7604 None
7605 }
7606 }
7607
7608 #[allow(irrefutable_let_patterns)]
7609 pub fn into_set_debug_client_info(self) -> Option<(String, u64, NodeControlHandle)> {
7610 if let NodeRequest::SetDebugClientInfo { name, id, control_handle } = self {
7611 Some((name, id, control_handle))
7612 } else {
7613 None
7614 }
7615 }
7616
7617 #[allow(irrefutable_let_patterns)]
7618 pub fn into_set_debug_timeout_log_deadline(self) -> Option<(i64, NodeControlHandle)> {
7619 if let NodeRequest::SetDebugTimeoutLogDeadline { deadline, control_handle } = self {
7620 Some((deadline, control_handle))
7621 } else {
7622 None
7623 }
7624 }
7625
7626 #[allow(irrefutable_let_patterns)]
7627 pub fn into_set_verbose_logging(self) -> Option<(NodeControlHandle)> {
7628 if let NodeRequest::SetVerboseLogging { control_handle } = self {
7629 Some((control_handle))
7630 } else {
7631 None
7632 }
7633 }
7634
7635 #[allow(irrefutable_let_patterns)]
7636 pub fn into_get_node_ref(self) -> Option<(NodeGetNodeRefResponder)> {
7637 if let NodeRequest::GetNodeRef { responder } = self { Some((responder)) } else { None }
7638 }
7639
7640 #[allow(irrefutable_let_patterns)]
7641 pub fn into_is_alternate_for(
7642 self,
7643 ) -> Option<(fdomain_client::Event, NodeIsAlternateForResponder)> {
7644 if let NodeRequest::IsAlternateFor { node_ref, responder } = self {
7645 Some((node_ref, responder))
7646 } else {
7647 None
7648 }
7649 }
7650
7651 /// Name of the method defined in FIDL
7652 pub fn method_name(&self) -> &'static str {
7653 match *self {
7654 NodeRequest::Sync { .. } => "sync",
7655 NodeRequest::Close { .. } => "close",
7656 NodeRequest::SetName { .. } => "set_name",
7657 NodeRequest::SetDebugClientInfo { .. } => "set_debug_client_info",
7658 NodeRequest::SetDebugTimeoutLogDeadline { .. } => "set_debug_timeout_log_deadline",
7659 NodeRequest::SetVerboseLogging { .. } => "set_verbose_logging",
7660 NodeRequest::GetNodeRef { .. } => "get_node_ref",
7661 NodeRequest::IsAlternateFor { .. } => "is_alternate_for",
7662 }
7663 }
7664}
7665
7666#[derive(Debug, Clone)]
7667pub struct NodeControlHandle {
7668 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7669}
7670
7671impl fdomain_client::fidl::ControlHandle for NodeControlHandle {
7672 fn shutdown(&self) {
7673 self.inner.shutdown()
7674 }
7675
7676 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7677 self.inner.shutdown_with_epitaph(status)
7678 }
7679
7680 fn is_closed(&self) -> bool {
7681 self.inner.channel().is_closed()
7682 }
7683 fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
7684 self.inner.channel().on_closed()
7685 }
7686}
7687
7688impl NodeControlHandle {}
7689
7690#[must_use = "FIDL methods require a response to be sent"]
7691#[derive(Debug)]
7692pub struct NodeSyncResponder {
7693 control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
7694 tx_id: u32,
7695}
7696
7697/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
7698/// if the responder is dropped without sending a response, so that the client
7699/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7700impl std::ops::Drop for NodeSyncResponder {
7701 fn drop(&mut self) {
7702 self.control_handle.shutdown();
7703 // Safety: drops once, never accessed again
7704 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7705 }
7706}
7707
7708impl fdomain_client::fidl::Responder for NodeSyncResponder {
7709 type ControlHandle = NodeControlHandle;
7710
7711 fn control_handle(&self) -> &NodeControlHandle {
7712 &self.control_handle
7713 }
7714
7715 fn drop_without_shutdown(mut self) {
7716 // Safety: drops once, never accessed again due to mem::forget
7717 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7718 // Prevent Drop from running (which would shut down the channel)
7719 std::mem::forget(self);
7720 }
7721}
7722
7723impl NodeSyncResponder {
7724 /// Sends a response to the FIDL transaction.
7725 ///
7726 /// Sets the channel to shutdown if an error occurs.
7727 pub fn send(self) -> Result<(), fidl::Error> {
7728 let _result = self.send_raw();
7729 if _result.is_err() {
7730 self.control_handle.shutdown();
7731 }
7732 self.drop_without_shutdown();
7733 _result
7734 }
7735
7736 /// Similar to "send" but does not shutdown the channel if an error occurs.
7737 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
7738 let _result = self.send_raw();
7739 self.drop_without_shutdown();
7740 _result
7741 }
7742
7743 fn send_raw(&self) -> Result<(), fidl::Error> {
7744 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
7745 (),
7746 self.tx_id,
7747 0x4577e238ae26291,
7748 fidl::encoding::DynamicFlags::empty(),
7749 )
7750 }
7751}
7752
7753#[must_use = "FIDL methods require a response to be sent"]
7754#[derive(Debug)]
7755pub struct NodeGetNodeRefResponder {
7756 control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
7757 tx_id: u32,
7758}
7759
7760/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
7761/// if the responder is dropped without sending a response, so that the client
7762/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7763impl std::ops::Drop for NodeGetNodeRefResponder {
7764 fn drop(&mut self) {
7765 self.control_handle.shutdown();
7766 // Safety: drops once, never accessed again
7767 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7768 }
7769}
7770
7771impl fdomain_client::fidl::Responder for NodeGetNodeRefResponder {
7772 type ControlHandle = NodeControlHandle;
7773
7774 fn control_handle(&self) -> &NodeControlHandle {
7775 &self.control_handle
7776 }
7777
7778 fn drop_without_shutdown(mut self) {
7779 // Safety: drops once, never accessed again due to mem::forget
7780 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7781 // Prevent Drop from running (which would shut down the channel)
7782 std::mem::forget(self);
7783 }
7784}
7785
7786impl NodeGetNodeRefResponder {
7787 /// Sends a response to the FIDL transaction.
7788 ///
7789 /// Sets the channel to shutdown if an error occurs.
7790 pub fn send(self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
7791 let _result = self.send_raw(node_ref);
7792 if _result.is_err() {
7793 self.control_handle.shutdown();
7794 }
7795 self.drop_without_shutdown();
7796 _result
7797 }
7798
7799 /// Similar to "send" but does not shutdown the channel if an error occurs.
7800 pub fn send_no_shutdown_on_err(
7801 self,
7802 mut node_ref: fdomain_client::Event,
7803 ) -> Result<(), fidl::Error> {
7804 let _result = self.send_raw(node_ref);
7805 self.drop_without_shutdown();
7806 _result
7807 }
7808
7809 fn send_raw(&self, mut node_ref: fdomain_client::Event) -> Result<(), fidl::Error> {
7810 self.control_handle.inner.send::<NodeGetNodeRefResponse>(
7811 (node_ref,),
7812 self.tx_id,
7813 0x467b7c75c35c3b84,
7814 fidl::encoding::DynamicFlags::empty(),
7815 )
7816 }
7817}
7818
7819#[must_use = "FIDL methods require a response to be sent"]
7820#[derive(Debug)]
7821pub struct NodeIsAlternateForResponder {
7822 control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
7823 tx_id: u32,
7824}
7825
7826/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
7827/// if the responder is dropped without sending a response, so that the client
7828/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7829impl std::ops::Drop for NodeIsAlternateForResponder {
7830 fn drop(&mut self) {
7831 self.control_handle.shutdown();
7832 // Safety: drops once, never accessed again
7833 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7834 }
7835}
7836
7837impl fdomain_client::fidl::Responder for NodeIsAlternateForResponder {
7838 type ControlHandle = NodeControlHandle;
7839
7840 fn control_handle(&self) -> &NodeControlHandle {
7841 &self.control_handle
7842 }
7843
7844 fn drop_without_shutdown(mut self) {
7845 // Safety: drops once, never accessed again due to mem::forget
7846 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7847 // Prevent Drop from running (which would shut down the channel)
7848 std::mem::forget(self);
7849 }
7850}
7851
7852impl NodeIsAlternateForResponder {
7853 /// Sends a response to the FIDL transaction.
7854 ///
7855 /// Sets the channel to shutdown if an error occurs.
7856 pub fn send(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
7857 let _result = self.send_raw(result);
7858 if _result.is_err() {
7859 self.control_handle.shutdown();
7860 }
7861 self.drop_without_shutdown();
7862 _result
7863 }
7864
7865 /// Similar to "send" but does not shutdown the channel if an error occurs.
7866 pub fn send_no_shutdown_on_err(self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
7867 let _result = self.send_raw(result);
7868 self.drop_without_shutdown();
7869 _result
7870 }
7871
7872 fn send_raw(&self, mut result: Result<bool, i32>) -> Result<(), fidl::Error> {
7873 self.control_handle
7874 .inner
7875 .send::<fidl::encoding::ResultType<NodeIsAlternateForResponse, i32>>(
7876 result.map(|is_alternate| (is_alternate,)),
7877 self.tx_id,
7878 0x33a2a7aff2776c07,
7879 fidl::encoding::DynamicFlags::empty(),
7880 )
7881 }
7882}
7883
7884#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7885pub struct SecureMemMarker;
7886
7887impl fdomain_client::fidl::ProtocolMarker for SecureMemMarker {
7888 type Proxy = SecureMemProxy;
7889 type RequestStream = SecureMemRequestStream;
7890
7891 const DEBUG_NAME: &'static str = "(anonymous) SecureMem";
7892}
7893pub type SecureMemGetPhysicalSecureHeapsResult = Result<SecureHeapsAndRanges, i32>;
7894pub type SecureMemGetPhysicalSecureHeapPropertiesResult = Result<SecureHeapProperties, i32>;
7895pub type SecureMemAddSecureHeapPhysicalRangeResult = Result<(), i32>;
7896pub type SecureMemDeleteSecureHeapPhysicalRangeResult = Result<(), i32>;
7897pub type SecureMemModifySecureHeapPhysicalRangeResult = Result<(), i32>;
7898pub type SecureMemZeroSubRangeResult = Result<(), i32>;
7899
7900pub trait SecureMemProxyInterface: Send + Sync {
7901 type GetPhysicalSecureHeapsResponseFut: std::future::Future<Output = Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error>>
7902 + Send;
7903 fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut;
7904 type GetPhysicalSecureHeapPropertiesResponseFut: std::future::Future<
7905 Output = Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error>,
7906 > + Send;
7907 fn r#get_physical_secure_heap_properties(
7908 &self,
7909 entire_heap: &SecureHeapAndRange,
7910 ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut;
7911 type AddSecureHeapPhysicalRangeResponseFut: std::future::Future<Output = Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error>>
7912 + Send;
7913 fn r#add_secure_heap_physical_range(
7914 &self,
7915 heap_range: &SecureHeapAndRange,
7916 ) -> Self::AddSecureHeapPhysicalRangeResponseFut;
7917 type DeleteSecureHeapPhysicalRangeResponseFut: std::future::Future<
7918 Output = Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error>,
7919 > + Send;
7920 fn r#delete_secure_heap_physical_range(
7921 &self,
7922 heap_range: &SecureHeapAndRange,
7923 ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut;
7924 type ModifySecureHeapPhysicalRangeResponseFut: std::future::Future<
7925 Output = Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error>,
7926 > + Send;
7927 fn r#modify_secure_heap_physical_range(
7928 &self,
7929 range_modification: &SecureHeapAndRangeModification,
7930 ) -> Self::ModifySecureHeapPhysicalRangeResponseFut;
7931 type ZeroSubRangeResponseFut: std::future::Future<Output = Result<SecureMemZeroSubRangeResult, fidl::Error>>
7932 + Send;
7933 fn r#zero_sub_range(
7934 &self,
7935 is_covering_range_explicit: bool,
7936 heap_range: &SecureHeapAndRange,
7937 ) -> Self::ZeroSubRangeResponseFut;
7938}
7939
7940#[derive(Debug, Clone)]
7941pub struct SecureMemProxy {
7942 client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
7943}
7944
7945impl fdomain_client::fidl::Proxy for SecureMemProxy {
7946 type Protocol = SecureMemMarker;
7947
7948 fn from_channel(inner: fdomain_client::Channel) -> Self {
7949 Self::new(inner)
7950 }
7951
7952 fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
7953 self.client.into_channel().map_err(|client| Self { client })
7954 }
7955
7956 fn as_channel(&self) -> &fdomain_client::Channel {
7957 self.client.as_channel()
7958 }
7959}
7960
7961impl SecureMemProxy {
7962 /// Create a new Proxy for fuchsia.sysmem/SecureMem.
7963 pub fn new(channel: fdomain_client::Channel) -> Self {
7964 let protocol_name = <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
7965 Self { client: fidl::client::Client::new(channel, protocol_name) }
7966 }
7967
7968 /// Get a Stream of events from the remote end of the protocol.
7969 ///
7970 /// # Panics
7971 ///
7972 /// Panics if the event stream was already taken.
7973 pub fn take_event_stream(&self) -> SecureMemEventStream {
7974 SecureMemEventStream { event_receiver: self.client.take_event_receiver() }
7975 }
7976
7977 /// Gets the physical address and length of any secure heap whose physical
7978 /// range is configured via the TEE.
7979 ///
7980 /// Presently, these will be fixed physical addresses and lengths, with the
7981 /// location plumbed via the TEE.
7982 ///
7983 /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
7984 /// when there isn't any special heap-specific per-VMO setup or teardown
7985 /// required.
7986 ///
7987 /// The physical range must be secured/protected by the TEE before the
7988 /// securemem driver responds to this request with success.
7989 ///
7990 /// Sysmem should only call this once. Returning zero heaps is not a
7991 /// failure.
7992 ///
7993 /// Errors:
7994 /// * ZX_ERR_BAD_STATE - called more than once.
7995 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
7996 /// with TEE which doesn't generate zx_status_t errors).
7997 /// * other errors are allowed; any other errors should be treated the same
7998 /// as ZX_ERR_INTERNAL.
7999 pub fn r#get_physical_secure_heaps(
8000 &self,
8001 ) -> fidl::client::QueryResponseFut<
8002 SecureMemGetPhysicalSecureHeapsResult,
8003 fdomain_client::fidl::FDomainResourceDialect,
8004 > {
8005 SecureMemProxyInterface::r#get_physical_secure_heaps(self)
8006 }
8007
8008 /// This request from sysmem to the securemem driver gets the properties of
8009 /// a protected/secure heap.
8010 ///
8011 /// This only handles heaps with a single contiguous physical extent.
8012 ///
8013 /// The heap's entire physical range is indicated in case this request needs
8014 /// some physical space to auto-detect how many ranges are REE-usable. Any
8015 /// temporary HW protection ranges will be deleted before this request
8016 /// completes.
8017 pub fn r#get_physical_secure_heap_properties(
8018 &self,
8019 mut entire_heap: &SecureHeapAndRange,
8020 ) -> fidl::client::QueryResponseFut<
8021 SecureMemGetPhysicalSecureHeapPropertiesResult,
8022 fdomain_client::fidl::FDomainResourceDialect,
8023 > {
8024 SecureMemProxyInterface::r#get_physical_secure_heap_properties(self, entire_heap)
8025 }
8026
8027 /// This request from sysmem to the securemem driver conveys a physical
8028 /// range to add, for a heap whose physical range(s) are set up via
8029 /// sysmem.
8030 ///
8031 /// Only sysmem can call this because only sysmem is handed the client end
8032 /// of a FIDL channel serving this protocol, via RegisterSecureMem(). The
8033 /// securemem driver is the server end of this protocol.
8034 ///
8035 /// The securemem driver must configure all the covered offsets as protected
8036 /// before responding to this message with success.
8037 ///
8038 /// On failure, the securemem driver must ensure the protected range was not
8039 /// created.
8040 ///
8041 /// Sysmem must only call this up to once if dynamic_protection_ranges
8042 /// false.
8043 ///
8044 /// If dynamic_protection_ranges is true, sysmem can call this multiple
8045 /// times as long as the current number of ranges never exceeds
8046 /// max_protected_range_count.
8047 ///
8048 /// The caller must not attempt to add a range that matches an
8049 /// already-existing range. Added ranges can overlap each other as long as
8050 /// no two ranges match exactly.
8051 ///
8052 /// Errors:
8053 /// * ZX_ERR_BAD_STATE - called more than once when
8054 /// !dynamic_protection_ranges. Adding a heap that would cause overall
8055 /// heap count to exceed max_protected_range_count.
8056 /// * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8057 /// to protected_range_granularity.
8058 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8059 /// with TEE which doesn't generate zx_status_t errors).
8060 /// * other errors are possible, such as from communication failures or
8061 /// server propagation of zx_status_t failures.
8062 pub fn r#add_secure_heap_physical_range(
8063 &self,
8064 mut heap_range: &SecureHeapAndRange,
8065 ) -> fidl::client::QueryResponseFut<
8066 SecureMemAddSecureHeapPhysicalRangeResult,
8067 fdomain_client::fidl::FDomainResourceDialect,
8068 > {
8069 SecureMemProxyInterface::r#add_secure_heap_physical_range(self, heap_range)
8070 }
8071
8072 /// This request from sysmem to the securemem driver conveys a physical
8073 /// range to delete, for a heap whose physical range(s) are set up via
8074 /// sysmem.
8075 ///
8076 /// Only sysmem can call this because only sysmem is handed the client end
8077 /// of a FIDL channel serving this protocol, via RegisterSecureMem(). The
8078 /// securemem driver is the server end of this protocol.
8079 ///
8080 /// The securemem driver must configure all the covered offsets as not
8081 /// protected before responding to this message with success.
8082 ///
8083 /// On failure, the securemem driver must ensure the protected range was not
8084 /// deleted.
8085 ///
8086 /// Sysmem must not call this if dynamic_protection_ranges false.
8087 ///
8088 /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8089 /// on various ranges that exist at the time of the call.
8090 ///
8091 /// If any portion of the range being deleted is not also covered by another
8092 /// protected range, then any ongoing DMA to any part of the entire range
8093 /// may be interrupted / may fail, potentially in a way that's disruptive to
8094 /// the entire system (bus lockup or similar, depending on device details).
8095 /// Therefore, the caller must ensure that no ongoing DMA is occurring to
8096 /// any portion of the range being deleted, unless the caller has other
8097 /// active ranges covering every block of the range being deleted. Ongoing
8098 /// DMA to/from blocks outside the range being deleted is never impacted by
8099 /// the deletion.
8100 ///
8101 /// Errors:
8102 /// * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8103 /// * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8104 /// to protected_range_granularity.
8105 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8106 /// with TEE which doesn't generate zx_status_t errors).
8107 /// * ZX_ERR_NOT_FOUND - the specified range is not found.
8108 /// * other errors are possible, such as from communication failures or
8109 /// server propagation of zx_status_t failures.
8110 pub fn r#delete_secure_heap_physical_range(
8111 &self,
8112 mut heap_range: &SecureHeapAndRange,
8113 ) -> fidl::client::QueryResponseFut<
8114 SecureMemDeleteSecureHeapPhysicalRangeResult,
8115 fdomain_client::fidl::FDomainResourceDialect,
8116 > {
8117 SecureMemProxyInterface::r#delete_secure_heap_physical_range(self, heap_range)
8118 }
8119
8120 /// This request from sysmem to the securemem driver conveys a physical
8121 /// range to modify and its new base and length, for a heap whose physical
8122 /// range(s) are set up via sysmem.
8123 ///
8124 /// Only sysmem can call this because only sysmem is handed the client end
8125 /// of a FIDL channel serving this protocol, via RegisterSecureMem(). The
8126 /// securemem driver is the server end of this protocol.
8127 ///
8128 /// The securemem driver must configure the range to cover only the new
8129 /// offsets before responding to this message with success.
8130 ///
8131 /// On failure, the securemem driver must ensure the range was not changed.
8132 ///
8133 /// Sysmem must not call this if dynamic_protection_ranges false. Sysmem
8134 /// must not call this if !is_mod_protected_range_available.
8135 ///
8136 /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8137 /// on various ranges that exist at the time of the call.
8138 ///
8139 /// The range must only be modified at one end or the other, but not both.
8140 /// If the range is getting shorter, and the un-covered blocks are not
8141 /// covered by other active ranges, any ongoing DMA to the entire range
8142 /// that's geting shorter may fail in a way that disrupts the entire system
8143 /// (bus lockup or similar), so the caller must ensure that no DMA is
8144 /// ongoing to any portion of a range that is getting shorter, unless the
8145 /// blocks being un-covered by the modification to this range are all
8146 /// covered by other active ranges, in which case no disruption to ongoing
8147 /// DMA will occur.
8148 ///
8149 /// If a range is modified to become <= zero length, the range is deleted.
8150 ///
8151 /// Errors:
8152 /// * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8153 /// * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
8154 /// that doesn't conform to protected_range_granularity, or old_range
8155 /// and new_range differ in both begin and end (disallowed).
8156 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8157 /// with TEE which doesn't generate zx_status_t errors).
8158 /// * ZX_ERR_NOT_FOUND - the specified range is not found.
8159 /// * other errors are possible, such as from communication failures or
8160 /// server propagation of zx_status_t failures.
8161 pub fn r#modify_secure_heap_physical_range(
8162 &self,
8163 mut range_modification: &SecureHeapAndRangeModification,
8164 ) -> fidl::client::QueryResponseFut<
8165 SecureMemModifySecureHeapPhysicalRangeResult,
8166 fdomain_client::fidl::FDomainResourceDialect,
8167 > {
8168 SecureMemProxyInterface::r#modify_secure_heap_physical_range(self, range_modification)
8169 }
8170
8171 /// Zero a sub-range of a currently-existing physical range added via
8172 /// AddSecureHeapPhysicalRange(). The sub-range must be fully covered by
8173 /// exactly one physical range, and must not overlap with any other
8174 /// physical range.
8175 ///
8176 /// is_covering_range_explicit - When true, the covering range must be one
8177 /// of the ranges explicitly created via AddSecureHeapPhysicalRange(),
8178 /// possibly modified since. When false, the covering range must not
8179 /// be one of the ranges explicitly created via
8180 /// AddSecureHeapPhysicalRange(), but the covering range must exist as
8181 /// a covering range not created via AddSecureHeapPhysicalRange(). The
8182 /// covering range is typically the entire physical range (or a range
8183 /// which covers even more) of a heap configured by the TEE and whose
8184 /// configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
8185 ///
8186 /// Ongoing DMA is not disrupted by this request.
8187 pub fn r#zero_sub_range(
8188 &self,
8189 mut is_covering_range_explicit: bool,
8190 mut heap_range: &SecureHeapAndRange,
8191 ) -> fidl::client::QueryResponseFut<
8192 SecureMemZeroSubRangeResult,
8193 fdomain_client::fidl::FDomainResourceDialect,
8194 > {
8195 SecureMemProxyInterface::r#zero_sub_range(self, is_covering_range_explicit, heap_range)
8196 }
8197}
8198
8199impl SecureMemProxyInterface for SecureMemProxy {
8200 type GetPhysicalSecureHeapsResponseFut = fidl::client::QueryResponseFut<
8201 SecureMemGetPhysicalSecureHeapsResult,
8202 fdomain_client::fidl::FDomainResourceDialect,
8203 >;
8204 fn r#get_physical_secure_heaps(&self) -> Self::GetPhysicalSecureHeapsResponseFut {
8205 fn _decode(
8206 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8207 ) -> Result<SecureMemGetPhysicalSecureHeapsResult, fidl::Error> {
8208 let _response = fidl::client::decode_transaction_body::<
8209 fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapsResponse, i32>,
8210 fdomain_client::fidl::FDomainResourceDialect,
8211 0x782319d6ce7fa05,
8212 >(_buf?)?;
8213 Ok(_response.map(|x| x.heaps))
8214 }
8215 self.client.send_query_and_decode::<
8216 fidl::encoding::EmptyPayload,
8217 SecureMemGetPhysicalSecureHeapsResult,
8218 >(
8219 (),
8220 0x782319d6ce7fa05,
8221 fidl::encoding::DynamicFlags::empty(),
8222 _decode,
8223 )
8224 }
8225
8226 type GetPhysicalSecureHeapPropertiesResponseFut = fidl::client::QueryResponseFut<
8227 SecureMemGetPhysicalSecureHeapPropertiesResult,
8228 fdomain_client::fidl::FDomainResourceDialect,
8229 >;
8230 fn r#get_physical_secure_heap_properties(
8231 &self,
8232 mut entire_heap: &SecureHeapAndRange,
8233 ) -> Self::GetPhysicalSecureHeapPropertiesResponseFut {
8234 fn _decode(
8235 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8236 ) -> Result<SecureMemGetPhysicalSecureHeapPropertiesResult, fidl::Error> {
8237 let _response = fidl::client::decode_transaction_body::<
8238 fidl::encoding::ResultType<SecureMemGetPhysicalSecureHeapPropertiesResponse, i32>,
8239 fdomain_client::fidl::FDomainResourceDialect,
8240 0x26404e23f1271214,
8241 >(_buf?)?;
8242 Ok(_response.map(|x| x.properties))
8243 }
8244 self.client.send_query_and_decode::<
8245 SecureMemGetPhysicalSecureHeapPropertiesRequest,
8246 SecureMemGetPhysicalSecureHeapPropertiesResult,
8247 >(
8248 (entire_heap,),
8249 0x26404e23f1271214,
8250 fidl::encoding::DynamicFlags::empty(),
8251 _decode,
8252 )
8253 }
8254
8255 type AddSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
8256 SecureMemAddSecureHeapPhysicalRangeResult,
8257 fdomain_client::fidl::FDomainResourceDialect,
8258 >;
8259 fn r#add_secure_heap_physical_range(
8260 &self,
8261 mut heap_range: &SecureHeapAndRange,
8262 ) -> Self::AddSecureHeapPhysicalRangeResponseFut {
8263 fn _decode(
8264 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8265 ) -> Result<SecureMemAddSecureHeapPhysicalRangeResult, fidl::Error> {
8266 let _response = fidl::client::decode_transaction_body::<
8267 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8268 fdomain_client::fidl::FDomainResourceDialect,
8269 0x1ca1abcee8a0b33e,
8270 >(_buf?)?;
8271 Ok(_response.map(|x| x))
8272 }
8273 self.client.send_query_and_decode::<
8274 SecureMemAddSecureHeapPhysicalRangeRequest,
8275 SecureMemAddSecureHeapPhysicalRangeResult,
8276 >(
8277 (heap_range,),
8278 0x1ca1abcee8a0b33e,
8279 fidl::encoding::DynamicFlags::empty(),
8280 _decode,
8281 )
8282 }
8283
8284 type DeleteSecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
8285 SecureMemDeleteSecureHeapPhysicalRangeResult,
8286 fdomain_client::fidl::FDomainResourceDialect,
8287 >;
8288 fn r#delete_secure_heap_physical_range(
8289 &self,
8290 mut heap_range: &SecureHeapAndRange,
8291 ) -> Self::DeleteSecureHeapPhysicalRangeResponseFut {
8292 fn _decode(
8293 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8294 ) -> Result<SecureMemDeleteSecureHeapPhysicalRangeResult, fidl::Error> {
8295 let _response = fidl::client::decode_transaction_body::<
8296 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8297 fdomain_client::fidl::FDomainResourceDialect,
8298 0x728a953e56df92ee,
8299 >(_buf?)?;
8300 Ok(_response.map(|x| x))
8301 }
8302 self.client.send_query_and_decode::<
8303 SecureMemDeleteSecureHeapPhysicalRangeRequest,
8304 SecureMemDeleteSecureHeapPhysicalRangeResult,
8305 >(
8306 (heap_range,),
8307 0x728a953e56df92ee,
8308 fidl::encoding::DynamicFlags::empty(),
8309 _decode,
8310 )
8311 }
8312
8313 type ModifySecureHeapPhysicalRangeResponseFut = fidl::client::QueryResponseFut<
8314 SecureMemModifySecureHeapPhysicalRangeResult,
8315 fdomain_client::fidl::FDomainResourceDialect,
8316 >;
8317 fn r#modify_secure_heap_physical_range(
8318 &self,
8319 mut range_modification: &SecureHeapAndRangeModification,
8320 ) -> Self::ModifySecureHeapPhysicalRangeResponseFut {
8321 fn _decode(
8322 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8323 ) -> Result<SecureMemModifySecureHeapPhysicalRangeResult, fidl::Error> {
8324 let _response = fidl::client::decode_transaction_body::<
8325 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8326 fdomain_client::fidl::FDomainResourceDialect,
8327 0x154fbfa3646a890d,
8328 >(_buf?)?;
8329 Ok(_response.map(|x| x))
8330 }
8331 self.client.send_query_and_decode::<
8332 SecureMemModifySecureHeapPhysicalRangeRequest,
8333 SecureMemModifySecureHeapPhysicalRangeResult,
8334 >(
8335 (range_modification,),
8336 0x154fbfa3646a890d,
8337 fidl::encoding::DynamicFlags::empty(),
8338 _decode,
8339 )
8340 }
8341
8342 type ZeroSubRangeResponseFut = fidl::client::QueryResponseFut<
8343 SecureMemZeroSubRangeResult,
8344 fdomain_client::fidl::FDomainResourceDialect,
8345 >;
8346 fn r#zero_sub_range(
8347 &self,
8348 mut is_covering_range_explicit: bool,
8349 mut heap_range: &SecureHeapAndRange,
8350 ) -> Self::ZeroSubRangeResponseFut {
8351 fn _decode(
8352 mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
8353 ) -> Result<SecureMemZeroSubRangeResult, fidl::Error> {
8354 let _response = fidl::client::decode_transaction_body::<
8355 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
8356 fdomain_client::fidl::FDomainResourceDialect,
8357 0x7480f72bb5bc7e5b,
8358 >(_buf?)?;
8359 Ok(_response.map(|x| x))
8360 }
8361 self.client
8362 .send_query_and_decode::<SecureMemZeroSubRangeRequest, SecureMemZeroSubRangeResult>(
8363 (is_covering_range_explicit, heap_range),
8364 0x7480f72bb5bc7e5b,
8365 fidl::encoding::DynamicFlags::empty(),
8366 _decode,
8367 )
8368 }
8369}
8370
8371pub struct SecureMemEventStream {
8372 event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
8373}
8374
8375impl std::marker::Unpin for SecureMemEventStream {}
8376
8377impl futures::stream::FusedStream for SecureMemEventStream {
8378 fn is_terminated(&self) -> bool {
8379 self.event_receiver.is_terminated()
8380 }
8381}
8382
8383impl futures::Stream for SecureMemEventStream {
8384 type Item = Result<SecureMemEvent, fidl::Error>;
8385
8386 fn poll_next(
8387 mut self: std::pin::Pin<&mut Self>,
8388 cx: &mut std::task::Context<'_>,
8389 ) -> std::task::Poll<Option<Self::Item>> {
8390 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
8391 &mut self.event_receiver,
8392 cx
8393 )?) {
8394 Some(buf) => std::task::Poll::Ready(Some(SecureMemEvent::decode(buf))),
8395 None => std::task::Poll::Ready(None),
8396 }
8397 }
8398}
8399
8400#[derive(Debug)]
8401pub enum SecureMemEvent {}
8402
8403impl SecureMemEvent {
8404 /// Decodes a message buffer as a [`SecureMemEvent`].
8405 fn decode(
8406 mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
8407 ) -> Result<SecureMemEvent, fidl::Error> {
8408 let (bytes, _handles) = buf.split_mut();
8409 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8410 debug_assert_eq!(tx_header.tx_id, 0);
8411 match tx_header.ordinal {
8412 _ => Err(fidl::Error::UnknownOrdinal {
8413 ordinal: tx_header.ordinal,
8414 protocol_name:
8415 <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8416 }),
8417 }
8418 }
8419}
8420
8421/// A Stream of incoming requests for fuchsia.sysmem/SecureMem.
8422pub struct SecureMemRequestStream {
8423 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8424 is_terminated: bool,
8425}
8426
8427impl std::marker::Unpin for SecureMemRequestStream {}
8428
8429impl futures::stream::FusedStream for SecureMemRequestStream {
8430 fn is_terminated(&self) -> bool {
8431 self.is_terminated
8432 }
8433}
8434
8435impl fdomain_client::fidl::RequestStream for SecureMemRequestStream {
8436 type Protocol = SecureMemMarker;
8437 type ControlHandle = SecureMemControlHandle;
8438
8439 fn from_channel(channel: fdomain_client::Channel) -> Self {
8440 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
8441 }
8442
8443 fn control_handle(&self) -> Self::ControlHandle {
8444 SecureMemControlHandle { inner: self.inner.clone() }
8445 }
8446
8447 fn into_inner(
8448 self,
8449 ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
8450 {
8451 (self.inner, self.is_terminated)
8452 }
8453
8454 fn from_inner(
8455 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8456 is_terminated: bool,
8457 ) -> Self {
8458 Self { inner, is_terminated }
8459 }
8460}
8461
8462impl futures::Stream for SecureMemRequestStream {
8463 type Item = Result<SecureMemRequest, fidl::Error>;
8464
8465 fn poll_next(
8466 mut self: std::pin::Pin<&mut Self>,
8467 cx: &mut std::task::Context<'_>,
8468 ) -> std::task::Poll<Option<Self::Item>> {
8469 let this = &mut *self;
8470 if this.inner.check_shutdown(cx) {
8471 this.is_terminated = true;
8472 return std::task::Poll::Ready(None);
8473 }
8474 if this.is_terminated {
8475 panic!("polled SecureMemRequestStream after completion");
8476 }
8477 fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
8478 |bytes, handles| {
8479 match this.inner.channel().read_etc(cx, bytes, handles) {
8480 std::task::Poll::Ready(Ok(())) => {}
8481 std::task::Poll::Pending => return std::task::Poll::Pending,
8482 std::task::Poll::Ready(Err(None)) => {
8483 this.is_terminated = true;
8484 return std::task::Poll::Ready(None);
8485 }
8486 std::task::Poll::Ready(Err(Some(e))) => {
8487 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
8488 e.into(),
8489 ))));
8490 }
8491 }
8492
8493 // A message has been received from the channel
8494 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
8495
8496 std::task::Poll::Ready(Some(match header.ordinal {
8497 0x782319d6ce7fa05 => {
8498 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8499 let mut req = fidl::new_empty!(
8500 fidl::encoding::EmptyPayload,
8501 fdomain_client::fidl::FDomainResourceDialect
8502 );
8503 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8504 let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8505 Ok(SecureMemRequest::GetPhysicalSecureHeaps {
8506 responder: SecureMemGetPhysicalSecureHeapsResponder {
8507 control_handle: std::mem::ManuallyDrop::new(control_handle),
8508 tx_id: header.tx_id,
8509 },
8510 })
8511 }
8512 0x26404e23f1271214 => {
8513 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8514 let mut req = fidl::new_empty!(
8515 SecureMemGetPhysicalSecureHeapPropertiesRequest,
8516 fdomain_client::fidl::FDomainResourceDialect
8517 );
8518 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemGetPhysicalSecureHeapPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
8519 let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8520 Ok(SecureMemRequest::GetPhysicalSecureHeapProperties {
8521 entire_heap: req.entire_heap,
8522
8523 responder: SecureMemGetPhysicalSecureHeapPropertiesResponder {
8524 control_handle: std::mem::ManuallyDrop::new(control_handle),
8525 tx_id: header.tx_id,
8526 },
8527 })
8528 }
8529 0x1ca1abcee8a0b33e => {
8530 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8531 let mut req = fidl::new_empty!(
8532 SecureMemAddSecureHeapPhysicalRangeRequest,
8533 fdomain_client::fidl::FDomainResourceDialect
8534 );
8535 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemAddSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8536 let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8537 Ok(SecureMemRequest::AddSecureHeapPhysicalRange {
8538 heap_range: req.heap_range,
8539
8540 responder: SecureMemAddSecureHeapPhysicalRangeResponder {
8541 control_handle: std::mem::ManuallyDrop::new(control_handle),
8542 tx_id: header.tx_id,
8543 },
8544 })
8545 }
8546 0x728a953e56df92ee => {
8547 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8548 let mut req = fidl::new_empty!(
8549 SecureMemDeleteSecureHeapPhysicalRangeRequest,
8550 fdomain_client::fidl::FDomainResourceDialect
8551 );
8552 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemDeleteSecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8553 let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8554 Ok(SecureMemRequest::DeleteSecureHeapPhysicalRange {
8555 heap_range: req.heap_range,
8556
8557 responder: SecureMemDeleteSecureHeapPhysicalRangeResponder {
8558 control_handle: std::mem::ManuallyDrop::new(control_handle),
8559 tx_id: header.tx_id,
8560 },
8561 })
8562 }
8563 0x154fbfa3646a890d => {
8564 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8565 let mut req = fidl::new_empty!(
8566 SecureMemModifySecureHeapPhysicalRangeRequest,
8567 fdomain_client::fidl::FDomainResourceDialect
8568 );
8569 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemModifySecureHeapPhysicalRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8570 let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8571 Ok(SecureMemRequest::ModifySecureHeapPhysicalRange {
8572 range_modification: req.range_modification,
8573
8574 responder: SecureMemModifySecureHeapPhysicalRangeResponder {
8575 control_handle: std::mem::ManuallyDrop::new(control_handle),
8576 tx_id: header.tx_id,
8577 },
8578 })
8579 }
8580 0x7480f72bb5bc7e5b => {
8581 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
8582 let mut req = fidl::new_empty!(
8583 SecureMemZeroSubRangeRequest,
8584 fdomain_client::fidl::FDomainResourceDialect
8585 );
8586 fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SecureMemZeroSubRangeRequest>(&header, _body_bytes, handles, &mut req)?;
8587 let control_handle = SecureMemControlHandle { inner: this.inner.clone() };
8588 Ok(SecureMemRequest::ZeroSubRange {
8589 is_covering_range_explicit: req.is_covering_range_explicit,
8590 heap_range: req.heap_range,
8591
8592 responder: SecureMemZeroSubRangeResponder {
8593 control_handle: std::mem::ManuallyDrop::new(control_handle),
8594 tx_id: header.tx_id,
8595 },
8596 })
8597 }
8598 _ => Err(fidl::Error::UnknownOrdinal {
8599 ordinal: header.ordinal,
8600 protocol_name:
8601 <SecureMemMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8602 }),
8603 }))
8604 },
8605 )
8606 }
8607}
8608
8609/// SecureMem
8610///
8611/// The client is sysmem. The server is securemem driver.
8612///
8613/// TEE - Trusted Execution Environment.
8614///
8615/// REE - Rich Execution Environment.
8616///
8617/// Enables sysmem to call the securemem driver to get any secure heaps
8618/// configured via the TEE (or via the securemem driver), and set any physical
8619/// secure heaps configured via sysmem.
8620///
8621/// Presently, dynamically-allocated secure heaps are configured via sysmem, as
8622/// it starts quite early during boot and can successfully reserve contiguous
8623/// physical memory. Presently, fixed-location secure heaps are configured via
8624/// TEE, as the plumbing goes from the bootloader to the TEE. However, this
8625/// protocol intentionally doesn't care which heaps are dynamically-allocated
8626/// and which are fixed-location.
8627#[derive(Debug)]
8628pub enum SecureMemRequest {
8629 /// Gets the physical address and length of any secure heap whose physical
8630 /// range is configured via the TEE.
8631 ///
8632 /// Presently, these will be fixed physical addresses and lengths, with the
8633 /// location plumbed via the TEE.
8634 ///
8635 /// This is preferred over ['fuchsia.hardware.sysmem.Sysmem/RegisterHeap']
8636 /// when there isn't any special heap-specific per-VMO setup or teardown
8637 /// required.
8638 ///
8639 /// The physical range must be secured/protected by the TEE before the
8640 /// securemem driver responds to this request with success.
8641 ///
8642 /// Sysmem should only call this once. Returning zero heaps is not a
8643 /// failure.
8644 ///
8645 /// Errors:
8646 /// * ZX_ERR_BAD_STATE - called more than once.
8647 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8648 /// with TEE which doesn't generate zx_status_t errors).
8649 /// * other errors are allowed; any other errors should be treated the same
8650 /// as ZX_ERR_INTERNAL.
8651 GetPhysicalSecureHeaps { responder: SecureMemGetPhysicalSecureHeapsResponder },
8652 /// This request from sysmem to the securemem driver gets the properties of
8653 /// a protected/secure heap.
8654 ///
8655 /// This only handles heaps with a single contiguous physical extent.
8656 ///
8657 /// The heap's entire physical range is indicated in case this request needs
8658 /// some physical space to auto-detect how many ranges are REE-usable. Any
8659 /// temporary HW protection ranges will be deleted before this request
8660 /// completes.
8661 GetPhysicalSecureHeapProperties {
8662 entire_heap: SecureHeapAndRange,
8663 responder: SecureMemGetPhysicalSecureHeapPropertiesResponder,
8664 },
8665 /// This request from sysmem to the securemem driver conveys a physical
8666 /// range to add, for a heap whose physical range(s) are set up via
8667 /// sysmem.
8668 ///
8669 /// Only sysmem can call this because only sysmem is handed the client end
8670 /// of a FIDL channel serving this protocol, via RegisterSecureMem(). The
8671 /// securemem driver is the server end of this protocol.
8672 ///
8673 /// The securemem driver must configure all the covered offsets as protected
8674 /// before responding to this message with success.
8675 ///
8676 /// On failure, the securemem driver must ensure the protected range was not
8677 /// created.
8678 ///
8679 /// Sysmem must only call this up to once if dynamic_protection_ranges
8680 /// false.
8681 ///
8682 /// If dynamic_protection_ranges is true, sysmem can call this multiple
8683 /// times as long as the current number of ranges never exceeds
8684 /// max_protected_range_count.
8685 ///
8686 /// The caller must not attempt to add a range that matches an
8687 /// already-existing range. Added ranges can overlap each other as long as
8688 /// no two ranges match exactly.
8689 ///
8690 /// Errors:
8691 /// * ZX_ERR_BAD_STATE - called more than once when
8692 /// !dynamic_protection_ranges. Adding a heap that would cause overall
8693 /// heap count to exceed max_protected_range_count.
8694 /// * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8695 /// to protected_range_granularity.
8696 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8697 /// with TEE which doesn't generate zx_status_t errors).
8698 /// * other errors are possible, such as from communication failures or
8699 /// server propagation of zx_status_t failures.
8700 AddSecureHeapPhysicalRange {
8701 heap_range: SecureHeapAndRange,
8702 responder: SecureMemAddSecureHeapPhysicalRangeResponder,
8703 },
8704 /// This request from sysmem to the securemem driver conveys a physical
8705 /// range to delete, for a heap whose physical range(s) are set up via
8706 /// sysmem.
8707 ///
8708 /// Only sysmem can call this because only sysmem is handed the client end
8709 /// of a FIDL channel serving this protocol, via RegisterSecureMem(). The
8710 /// securemem driver is the server end of this protocol.
8711 ///
8712 /// The securemem driver must configure all the covered offsets as not
8713 /// protected before responding to this message with success.
8714 ///
8715 /// On failure, the securemem driver must ensure the protected range was not
8716 /// deleted.
8717 ///
8718 /// Sysmem must not call this if dynamic_protection_ranges false.
8719 ///
8720 /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8721 /// on various ranges that exist at the time of the call.
8722 ///
8723 /// If any portion of the range being deleted is not also covered by another
8724 /// protected range, then any ongoing DMA to any part of the entire range
8725 /// may be interrupted / may fail, potentially in a way that's disruptive to
8726 /// the entire system (bus lockup or similar, depending on device details).
8727 /// Therefore, the caller must ensure that no ongoing DMA is occurring to
8728 /// any portion of the range being deleted, unless the caller has other
8729 /// active ranges covering every block of the range being deleted. Ongoing
8730 /// DMA to/from blocks outside the range being deleted is never impacted by
8731 /// the deletion.
8732 ///
8733 /// Errors:
8734 /// * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8735 /// * ZX_ERR_INVALID_ARGS - unexpected heap, or range that doesn't conform
8736 /// to protected_range_granularity.
8737 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8738 /// with TEE which doesn't generate zx_status_t errors).
8739 /// * ZX_ERR_NOT_FOUND - the specified range is not found.
8740 /// * other errors are possible, such as from communication failures or
8741 /// server propagation of zx_status_t failures.
8742 DeleteSecureHeapPhysicalRange {
8743 heap_range: SecureHeapAndRange,
8744 responder: SecureMemDeleteSecureHeapPhysicalRangeResponder,
8745 },
8746 /// This request from sysmem to the securemem driver conveys a physical
8747 /// range to modify and its new base and length, for a heap whose physical
8748 /// range(s) are set up via sysmem.
8749 ///
8750 /// Only sysmem can call this because only sysmem is handed the client end
8751 /// of a FIDL channel serving this protocol, via RegisterSecureMem(). The
8752 /// securemem driver is the server end of this protocol.
8753 ///
8754 /// The securemem driver must configure the range to cover only the new
8755 /// offsets before responding to this message with success.
8756 ///
8757 /// On failure, the securemem driver must ensure the range was not changed.
8758 ///
8759 /// Sysmem must not call this if dynamic_protection_ranges false. Sysmem
8760 /// must not call this if !is_mod_protected_range_available.
8761 ///
8762 /// If dynamic_protection_ranges is true, sysmem can call this repeatedly,
8763 /// on various ranges that exist at the time of the call.
8764 ///
8765 /// The range must only be modified at one end or the other, but not both.
8766 /// If the range is getting shorter, and the un-covered blocks are not
8767 /// covered by other active ranges, any ongoing DMA to the entire range
8768 /// that's geting shorter may fail in a way that disrupts the entire system
8769 /// (bus lockup or similar), so the caller must ensure that no DMA is
8770 /// ongoing to any portion of a range that is getting shorter, unless the
8771 /// blocks being un-covered by the modification to this range are all
8772 /// covered by other active ranges, in which case no disruption to ongoing
8773 /// DMA will occur.
8774 ///
8775 /// If a range is modified to become <= zero length, the range is deleted.
8776 ///
8777 /// Errors:
8778 /// * ZX_ERR_BAD_STATE - called when !dynamic_protection_ranges.
8779 /// * ZX_ERR_INVALID_ARGS - unexpected heap, or old_range or new_range
8780 /// that doesn't conform to protected_range_granularity, or old_range
8781 /// and new_range differ in both begin and end (disallowed).
8782 /// * ZX_ERR_INTERNAL - generic internal error (such as in communication
8783 /// with TEE which doesn't generate zx_status_t errors).
8784 /// * ZX_ERR_NOT_FOUND - the specified range is not found.
8785 /// * other errors are possible, such as from communication failures or
8786 /// server propagation of zx_status_t failures.
8787 ModifySecureHeapPhysicalRange {
8788 range_modification: SecureHeapAndRangeModification,
8789 responder: SecureMemModifySecureHeapPhysicalRangeResponder,
8790 },
8791 /// Zero a sub-range of a currently-existing physical range added via
8792 /// AddSecureHeapPhysicalRange(). The sub-range must be fully covered by
8793 /// exactly one physical range, and must not overlap with any other
8794 /// physical range.
8795 ///
8796 /// is_covering_range_explicit - When true, the covering range must be one
8797 /// of the ranges explicitly created via AddSecureHeapPhysicalRange(),
8798 /// possibly modified since. When false, the covering range must not
8799 /// be one of the ranges explicitly created via
8800 /// AddSecureHeapPhysicalRange(), but the covering range must exist as
8801 /// a covering range not created via AddSecureHeapPhysicalRange(). The
8802 /// covering range is typically the entire physical range (or a range
8803 /// which covers even more) of a heap configured by the TEE and whose
8804 /// configuration is conveyed to sysmem via GetPhysicalSecureHeaps().
8805 ///
8806 /// Ongoing DMA is not disrupted by this request.
8807 ZeroSubRange {
8808 is_covering_range_explicit: bool,
8809 heap_range: SecureHeapAndRange,
8810 responder: SecureMemZeroSubRangeResponder,
8811 },
8812}
8813
8814impl SecureMemRequest {
8815 #[allow(irrefutable_let_patterns)]
8816 pub fn into_get_physical_secure_heaps(
8817 self,
8818 ) -> Option<(SecureMemGetPhysicalSecureHeapsResponder)> {
8819 if let SecureMemRequest::GetPhysicalSecureHeaps { responder } = self {
8820 Some((responder))
8821 } else {
8822 None
8823 }
8824 }
8825
8826 #[allow(irrefutable_let_patterns)]
8827 pub fn into_get_physical_secure_heap_properties(
8828 self,
8829 ) -> Option<(SecureHeapAndRange, SecureMemGetPhysicalSecureHeapPropertiesResponder)> {
8830 if let SecureMemRequest::GetPhysicalSecureHeapProperties { entire_heap, responder } = self {
8831 Some((entire_heap, responder))
8832 } else {
8833 None
8834 }
8835 }
8836
8837 #[allow(irrefutable_let_patterns)]
8838 pub fn into_add_secure_heap_physical_range(
8839 self,
8840 ) -> Option<(SecureHeapAndRange, SecureMemAddSecureHeapPhysicalRangeResponder)> {
8841 if let SecureMemRequest::AddSecureHeapPhysicalRange { heap_range, responder } = self {
8842 Some((heap_range, responder))
8843 } else {
8844 None
8845 }
8846 }
8847
8848 #[allow(irrefutable_let_patterns)]
8849 pub fn into_delete_secure_heap_physical_range(
8850 self,
8851 ) -> Option<(SecureHeapAndRange, SecureMemDeleteSecureHeapPhysicalRangeResponder)> {
8852 if let SecureMemRequest::DeleteSecureHeapPhysicalRange { heap_range, responder } = self {
8853 Some((heap_range, responder))
8854 } else {
8855 None
8856 }
8857 }
8858
8859 #[allow(irrefutable_let_patterns)]
8860 pub fn into_modify_secure_heap_physical_range(
8861 self,
8862 ) -> Option<(SecureHeapAndRangeModification, SecureMemModifySecureHeapPhysicalRangeResponder)>
8863 {
8864 if let SecureMemRequest::ModifySecureHeapPhysicalRange { range_modification, responder } =
8865 self
8866 {
8867 Some((range_modification, responder))
8868 } else {
8869 None
8870 }
8871 }
8872
8873 #[allow(irrefutable_let_patterns)]
8874 pub fn into_zero_sub_range(
8875 self,
8876 ) -> Option<(bool, SecureHeapAndRange, SecureMemZeroSubRangeResponder)> {
8877 if let SecureMemRequest::ZeroSubRange {
8878 is_covering_range_explicit,
8879 heap_range,
8880 responder,
8881 } = self
8882 {
8883 Some((is_covering_range_explicit, heap_range, responder))
8884 } else {
8885 None
8886 }
8887 }
8888
8889 /// Name of the method defined in FIDL
8890 pub fn method_name(&self) -> &'static str {
8891 match *self {
8892 SecureMemRequest::GetPhysicalSecureHeaps { .. } => "get_physical_secure_heaps",
8893 SecureMemRequest::GetPhysicalSecureHeapProperties { .. } => {
8894 "get_physical_secure_heap_properties"
8895 }
8896 SecureMemRequest::AddSecureHeapPhysicalRange { .. } => "add_secure_heap_physical_range",
8897 SecureMemRequest::DeleteSecureHeapPhysicalRange { .. } => {
8898 "delete_secure_heap_physical_range"
8899 }
8900 SecureMemRequest::ModifySecureHeapPhysicalRange { .. } => {
8901 "modify_secure_heap_physical_range"
8902 }
8903 SecureMemRequest::ZeroSubRange { .. } => "zero_sub_range",
8904 }
8905 }
8906}
8907
8908#[derive(Debug, Clone)]
8909pub struct SecureMemControlHandle {
8910 inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8911}
8912
8913impl fdomain_client::fidl::ControlHandle for SecureMemControlHandle {
8914 fn shutdown(&self) {
8915 self.inner.shutdown()
8916 }
8917
8918 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
8919 self.inner.shutdown_with_epitaph(status)
8920 }
8921
8922 fn is_closed(&self) -> bool {
8923 self.inner.channel().is_closed()
8924 }
8925 fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
8926 self.inner.channel().on_closed()
8927 }
8928}
8929
8930impl SecureMemControlHandle {}
8931
8932#[must_use = "FIDL methods require a response to be sent"]
8933#[derive(Debug)]
8934pub struct SecureMemGetPhysicalSecureHeapsResponder {
8935 control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
8936 tx_id: u32,
8937}
8938
8939/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
8940/// if the responder is dropped without sending a response, so that the client
8941/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8942impl std::ops::Drop for SecureMemGetPhysicalSecureHeapsResponder {
8943 fn drop(&mut self) {
8944 self.control_handle.shutdown();
8945 // Safety: drops once, never accessed again
8946 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8947 }
8948}
8949
8950impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapsResponder {
8951 type ControlHandle = SecureMemControlHandle;
8952
8953 fn control_handle(&self) -> &SecureMemControlHandle {
8954 &self.control_handle
8955 }
8956
8957 fn drop_without_shutdown(mut self) {
8958 // Safety: drops once, never accessed again due to mem::forget
8959 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8960 // Prevent Drop from running (which would shut down the channel)
8961 std::mem::forget(self);
8962 }
8963}
8964
8965impl SecureMemGetPhysicalSecureHeapsResponder {
8966 /// Sends a response to the FIDL transaction.
8967 ///
8968 /// Sets the channel to shutdown if an error occurs.
8969 pub fn send(self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
8970 let _result = self.send_raw(result);
8971 if _result.is_err() {
8972 self.control_handle.shutdown();
8973 }
8974 self.drop_without_shutdown();
8975 _result
8976 }
8977
8978 /// Similar to "send" but does not shutdown the channel if an error occurs.
8979 pub fn send_no_shutdown_on_err(
8980 self,
8981 mut result: Result<&SecureHeapsAndRanges, i32>,
8982 ) -> Result<(), fidl::Error> {
8983 let _result = self.send_raw(result);
8984 self.drop_without_shutdown();
8985 _result
8986 }
8987
8988 fn send_raw(&self, mut result: Result<&SecureHeapsAndRanges, i32>) -> Result<(), fidl::Error> {
8989 self.control_handle.inner.send::<fidl::encoding::ResultType<
8990 SecureMemGetPhysicalSecureHeapsResponse,
8991 i32,
8992 >>(
8993 result.map(|heaps| (heaps,)),
8994 self.tx_id,
8995 0x782319d6ce7fa05,
8996 fidl::encoding::DynamicFlags::empty(),
8997 )
8998 }
8999}
9000
9001#[must_use = "FIDL methods require a response to be sent"]
9002#[derive(Debug)]
9003pub struct SecureMemGetPhysicalSecureHeapPropertiesResponder {
9004 control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9005 tx_id: u32,
9006}
9007
9008/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9009/// if the responder is dropped without sending a response, so that the client
9010/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9011impl std::ops::Drop for SecureMemGetPhysicalSecureHeapPropertiesResponder {
9012 fn drop(&mut self) {
9013 self.control_handle.shutdown();
9014 // Safety: drops once, never accessed again
9015 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9016 }
9017}
9018
9019impl fdomain_client::fidl::Responder for SecureMemGetPhysicalSecureHeapPropertiesResponder {
9020 type ControlHandle = SecureMemControlHandle;
9021
9022 fn control_handle(&self) -> &SecureMemControlHandle {
9023 &self.control_handle
9024 }
9025
9026 fn drop_without_shutdown(mut self) {
9027 // Safety: drops once, never accessed again due to mem::forget
9028 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9029 // Prevent Drop from running (which would shut down the channel)
9030 std::mem::forget(self);
9031 }
9032}
9033
9034impl SecureMemGetPhysicalSecureHeapPropertiesResponder {
9035 /// Sends a response to the FIDL transaction.
9036 ///
9037 /// Sets the channel to shutdown if an error occurs.
9038 pub fn send(self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
9039 let _result = self.send_raw(result);
9040 if _result.is_err() {
9041 self.control_handle.shutdown();
9042 }
9043 self.drop_without_shutdown();
9044 _result
9045 }
9046
9047 /// Similar to "send" but does not shutdown the channel if an error occurs.
9048 pub fn send_no_shutdown_on_err(
9049 self,
9050 mut result: Result<&SecureHeapProperties, i32>,
9051 ) -> Result<(), fidl::Error> {
9052 let _result = self.send_raw(result);
9053 self.drop_without_shutdown();
9054 _result
9055 }
9056
9057 fn send_raw(&self, mut result: Result<&SecureHeapProperties, i32>) -> Result<(), fidl::Error> {
9058 self.control_handle.inner.send::<fidl::encoding::ResultType<
9059 SecureMemGetPhysicalSecureHeapPropertiesResponse,
9060 i32,
9061 >>(
9062 result.map(|properties| (properties,)),
9063 self.tx_id,
9064 0x26404e23f1271214,
9065 fidl::encoding::DynamicFlags::empty(),
9066 )
9067 }
9068}
9069
9070#[must_use = "FIDL methods require a response to be sent"]
9071#[derive(Debug)]
9072pub struct SecureMemAddSecureHeapPhysicalRangeResponder {
9073 control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9074 tx_id: u32,
9075}
9076
9077/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9078/// if the responder is dropped without sending a response, so that the client
9079/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9080impl std::ops::Drop for SecureMemAddSecureHeapPhysicalRangeResponder {
9081 fn drop(&mut self) {
9082 self.control_handle.shutdown();
9083 // Safety: drops once, never accessed again
9084 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9085 }
9086}
9087
9088impl fdomain_client::fidl::Responder for SecureMemAddSecureHeapPhysicalRangeResponder {
9089 type ControlHandle = SecureMemControlHandle;
9090
9091 fn control_handle(&self) -> &SecureMemControlHandle {
9092 &self.control_handle
9093 }
9094
9095 fn drop_without_shutdown(mut self) {
9096 // Safety: drops once, never accessed again due to mem::forget
9097 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9098 // Prevent Drop from running (which would shut down the channel)
9099 std::mem::forget(self);
9100 }
9101}
9102
9103impl SecureMemAddSecureHeapPhysicalRangeResponder {
9104 /// Sends a response to the FIDL transaction.
9105 ///
9106 /// Sets the channel to shutdown if an error occurs.
9107 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9108 let _result = self.send_raw(result);
9109 if _result.is_err() {
9110 self.control_handle.shutdown();
9111 }
9112 self.drop_without_shutdown();
9113 _result
9114 }
9115
9116 /// Similar to "send" but does not shutdown the channel if an error occurs.
9117 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9118 let _result = self.send_raw(result);
9119 self.drop_without_shutdown();
9120 _result
9121 }
9122
9123 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9124 self.control_handle
9125 .inner
9126 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9127 result,
9128 self.tx_id,
9129 0x1ca1abcee8a0b33e,
9130 fidl::encoding::DynamicFlags::empty(),
9131 )
9132 }
9133}
9134
9135#[must_use = "FIDL methods require a response to be sent"]
9136#[derive(Debug)]
9137pub struct SecureMemDeleteSecureHeapPhysicalRangeResponder {
9138 control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9139 tx_id: u32,
9140}
9141
9142/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9143/// if the responder is dropped without sending a response, so that the client
9144/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9145impl std::ops::Drop for SecureMemDeleteSecureHeapPhysicalRangeResponder {
9146 fn drop(&mut self) {
9147 self.control_handle.shutdown();
9148 // Safety: drops once, never accessed again
9149 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9150 }
9151}
9152
9153impl fdomain_client::fidl::Responder for SecureMemDeleteSecureHeapPhysicalRangeResponder {
9154 type ControlHandle = SecureMemControlHandle;
9155
9156 fn control_handle(&self) -> &SecureMemControlHandle {
9157 &self.control_handle
9158 }
9159
9160 fn drop_without_shutdown(mut self) {
9161 // Safety: drops once, never accessed again due to mem::forget
9162 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9163 // Prevent Drop from running (which would shut down the channel)
9164 std::mem::forget(self);
9165 }
9166}
9167
9168impl SecureMemDeleteSecureHeapPhysicalRangeResponder {
9169 /// Sends a response to the FIDL transaction.
9170 ///
9171 /// Sets the channel to shutdown if an error occurs.
9172 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9173 let _result = self.send_raw(result);
9174 if _result.is_err() {
9175 self.control_handle.shutdown();
9176 }
9177 self.drop_without_shutdown();
9178 _result
9179 }
9180
9181 /// Similar to "send" but does not shutdown the channel if an error occurs.
9182 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9183 let _result = self.send_raw(result);
9184 self.drop_without_shutdown();
9185 _result
9186 }
9187
9188 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9189 self.control_handle
9190 .inner
9191 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9192 result,
9193 self.tx_id,
9194 0x728a953e56df92ee,
9195 fidl::encoding::DynamicFlags::empty(),
9196 )
9197 }
9198}
9199
9200#[must_use = "FIDL methods require a response to be sent"]
9201#[derive(Debug)]
9202pub struct SecureMemModifySecureHeapPhysicalRangeResponder {
9203 control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9204 tx_id: u32,
9205}
9206
9207/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9208/// if the responder is dropped without sending a response, so that the client
9209/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9210impl std::ops::Drop for SecureMemModifySecureHeapPhysicalRangeResponder {
9211 fn drop(&mut self) {
9212 self.control_handle.shutdown();
9213 // Safety: drops once, never accessed again
9214 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9215 }
9216}
9217
9218impl fdomain_client::fidl::Responder for SecureMemModifySecureHeapPhysicalRangeResponder {
9219 type ControlHandle = SecureMemControlHandle;
9220
9221 fn control_handle(&self) -> &SecureMemControlHandle {
9222 &self.control_handle
9223 }
9224
9225 fn drop_without_shutdown(mut self) {
9226 // Safety: drops once, never accessed again due to mem::forget
9227 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9228 // Prevent Drop from running (which would shut down the channel)
9229 std::mem::forget(self);
9230 }
9231}
9232
9233impl SecureMemModifySecureHeapPhysicalRangeResponder {
9234 /// Sends a response to the FIDL transaction.
9235 ///
9236 /// Sets the channel to shutdown if an error occurs.
9237 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9238 let _result = self.send_raw(result);
9239 if _result.is_err() {
9240 self.control_handle.shutdown();
9241 }
9242 self.drop_without_shutdown();
9243 _result
9244 }
9245
9246 /// Similar to "send" but does not shutdown the channel if an error occurs.
9247 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9248 let _result = self.send_raw(result);
9249 self.drop_without_shutdown();
9250 _result
9251 }
9252
9253 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9254 self.control_handle
9255 .inner
9256 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9257 result,
9258 self.tx_id,
9259 0x154fbfa3646a890d,
9260 fidl::encoding::DynamicFlags::empty(),
9261 )
9262 }
9263}
9264
9265#[must_use = "FIDL methods require a response to be sent"]
9266#[derive(Debug)]
9267pub struct SecureMemZeroSubRangeResponder {
9268 control_handle: std::mem::ManuallyDrop<SecureMemControlHandle>,
9269 tx_id: u32,
9270}
9271
9272/// Set the the channel to be shutdown (see [`SecureMemControlHandle::shutdown`])
9273/// if the responder is dropped without sending a response, so that the client
9274/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9275impl std::ops::Drop for SecureMemZeroSubRangeResponder {
9276 fn drop(&mut self) {
9277 self.control_handle.shutdown();
9278 // Safety: drops once, never accessed again
9279 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9280 }
9281}
9282
9283impl fdomain_client::fidl::Responder for SecureMemZeroSubRangeResponder {
9284 type ControlHandle = SecureMemControlHandle;
9285
9286 fn control_handle(&self) -> &SecureMemControlHandle {
9287 &self.control_handle
9288 }
9289
9290 fn drop_without_shutdown(mut self) {
9291 // Safety: drops once, never accessed again due to mem::forget
9292 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9293 // Prevent Drop from running (which would shut down the channel)
9294 std::mem::forget(self);
9295 }
9296}
9297
9298impl SecureMemZeroSubRangeResponder {
9299 /// Sends a response to the FIDL transaction.
9300 ///
9301 /// Sets the channel to shutdown if an error occurs.
9302 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9303 let _result = self.send_raw(result);
9304 if _result.is_err() {
9305 self.control_handle.shutdown();
9306 }
9307 self.drop_without_shutdown();
9308 _result
9309 }
9310
9311 /// Similar to "send" but does not shutdown the channel if an error occurs.
9312 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9313 let _result = self.send_raw(result);
9314 self.drop_without_shutdown();
9315 _result
9316 }
9317
9318 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
9319 self.control_handle
9320 .inner
9321 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
9322 result,
9323 self.tx_id,
9324 0x7480f72bb5bc7e5b,
9325 fidl::encoding::DynamicFlags::empty(),
9326 )
9327 }
9328}
9329
9330mod internal {
9331 use super::*;
9332
9333 impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateNonSharedCollectionRequest {
9334 type Borrowed<'a> = &'a mut Self;
9335 fn take_or_borrow<'a>(
9336 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9337 ) -> Self::Borrowed<'a> {
9338 value
9339 }
9340 }
9341
9342 unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateNonSharedCollectionRequest {
9343 type Owned = Self;
9344
9345 #[inline(always)]
9346 fn inline_align(_context: fidl::encoding::Context) -> usize {
9347 4
9348 }
9349
9350 #[inline(always)]
9351 fn inline_size(_context: fidl::encoding::Context) -> usize {
9352 4
9353 }
9354 }
9355
9356 unsafe impl
9357 fidl::encoding::Encode<
9358 AllocatorAllocateNonSharedCollectionRequest,
9359 fdomain_client::fidl::FDomainResourceDialect,
9360 > for &mut AllocatorAllocateNonSharedCollectionRequest
9361 {
9362 #[inline]
9363 unsafe fn encode(
9364 self,
9365 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9366 offset: usize,
9367 _depth: fidl::encoding::Depth,
9368 ) -> fidl::Result<()> {
9369 encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
9370 // Delegate to tuple encoding.
9371 fidl::encoding::Encode::<
9372 AllocatorAllocateNonSharedCollectionRequest,
9373 fdomain_client::fidl::FDomainResourceDialect,
9374 >::encode(
9375 (
9376 <fidl::encoding::Endpoint<
9377 fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9378 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9379 &mut self.collection_request,
9380 ),
9381 ),
9382 encoder,
9383 offset,
9384 _depth,
9385 )
9386 }
9387 }
9388 unsafe impl<
9389 T0: fidl::encoding::Encode<
9390 fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9391 fdomain_client::fidl::FDomainResourceDialect,
9392 >,
9393 >
9394 fidl::encoding::Encode<
9395 AllocatorAllocateNonSharedCollectionRequest,
9396 fdomain_client::fidl::FDomainResourceDialect,
9397 > for (T0,)
9398 {
9399 #[inline]
9400 unsafe fn encode(
9401 self,
9402 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9403 offset: usize,
9404 depth: fidl::encoding::Depth,
9405 ) -> fidl::Result<()> {
9406 encoder.debug_check_bounds::<AllocatorAllocateNonSharedCollectionRequest>(offset);
9407 // Zero out padding regions. There's no need to apply masks
9408 // because the unmasked parts will be overwritten by fields.
9409 // Write the fields.
9410 self.0.encode(encoder, offset + 0, depth)?;
9411 Ok(())
9412 }
9413 }
9414
9415 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9416 for AllocatorAllocateNonSharedCollectionRequest
9417 {
9418 #[inline(always)]
9419 fn new_empty() -> Self {
9420 Self {
9421 collection_request: fidl::new_empty!(
9422 fidl::encoding::Endpoint<
9423 fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9424 >,
9425 fdomain_client::fidl::FDomainResourceDialect
9426 ),
9427 }
9428 }
9429
9430 #[inline]
9431 unsafe fn decode(
9432 &mut self,
9433 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9434 offset: usize,
9435 _depth: fidl::encoding::Depth,
9436 ) -> fidl::Result<()> {
9437 decoder.debug_check_bounds::<Self>(offset);
9438 // Verify that padding bytes are zero.
9439 fidl::decode!(
9440 fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9441 fdomain_client::fidl::FDomainResourceDialect,
9442 &mut self.collection_request,
9443 decoder,
9444 offset + 0,
9445 _depth
9446 )?;
9447 Ok(())
9448 }
9449 }
9450
9451 impl fidl::encoding::ResourceTypeMarker for AllocatorAllocateSharedCollectionRequest {
9452 type Borrowed<'a> = &'a mut Self;
9453 fn take_or_borrow<'a>(
9454 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9455 ) -> Self::Borrowed<'a> {
9456 value
9457 }
9458 }
9459
9460 unsafe impl fidl::encoding::TypeMarker for AllocatorAllocateSharedCollectionRequest {
9461 type Owned = Self;
9462
9463 #[inline(always)]
9464 fn inline_align(_context: fidl::encoding::Context) -> usize {
9465 4
9466 }
9467
9468 #[inline(always)]
9469 fn inline_size(_context: fidl::encoding::Context) -> usize {
9470 4
9471 }
9472 }
9473
9474 unsafe impl
9475 fidl::encoding::Encode<
9476 AllocatorAllocateSharedCollectionRequest,
9477 fdomain_client::fidl::FDomainResourceDialect,
9478 > for &mut AllocatorAllocateSharedCollectionRequest
9479 {
9480 #[inline]
9481 unsafe fn encode(
9482 self,
9483 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9484 offset: usize,
9485 _depth: fidl::encoding::Depth,
9486 ) -> fidl::Result<()> {
9487 encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
9488 // Delegate to tuple encoding.
9489 fidl::encoding::Encode::<
9490 AllocatorAllocateSharedCollectionRequest,
9491 fdomain_client::fidl::FDomainResourceDialect,
9492 >::encode(
9493 (<fidl::encoding::Endpoint<
9494 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9495 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9496 &mut self.token_request
9497 ),),
9498 encoder,
9499 offset,
9500 _depth,
9501 )
9502 }
9503 }
9504 unsafe impl<
9505 T0: fidl::encoding::Encode<
9506 fidl::encoding::Endpoint<
9507 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9508 >,
9509 fdomain_client::fidl::FDomainResourceDialect,
9510 >,
9511 >
9512 fidl::encoding::Encode<
9513 AllocatorAllocateSharedCollectionRequest,
9514 fdomain_client::fidl::FDomainResourceDialect,
9515 > for (T0,)
9516 {
9517 #[inline]
9518 unsafe fn encode(
9519 self,
9520 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9521 offset: usize,
9522 depth: fidl::encoding::Depth,
9523 ) -> fidl::Result<()> {
9524 encoder.debug_check_bounds::<AllocatorAllocateSharedCollectionRequest>(offset);
9525 // Zero out padding regions. There's no need to apply masks
9526 // because the unmasked parts will be overwritten by fields.
9527 // Write the fields.
9528 self.0.encode(encoder, offset + 0, depth)?;
9529 Ok(())
9530 }
9531 }
9532
9533 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9534 for AllocatorAllocateSharedCollectionRequest
9535 {
9536 #[inline(always)]
9537 fn new_empty() -> Self {
9538 Self {
9539 token_request: fidl::new_empty!(
9540 fidl::encoding::Endpoint<
9541 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9542 >,
9543 fdomain_client::fidl::FDomainResourceDialect
9544 ),
9545 }
9546 }
9547
9548 #[inline]
9549 unsafe fn decode(
9550 &mut self,
9551 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9552 offset: usize,
9553 _depth: fidl::encoding::Depth,
9554 ) -> fidl::Result<()> {
9555 decoder.debug_check_bounds::<Self>(offset);
9556 // Verify that padding bytes are zero.
9557 fidl::decode!(
9558 fidl::encoding::Endpoint<
9559 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
9560 >,
9561 fdomain_client::fidl::FDomainResourceDialect,
9562 &mut self.token_request,
9563 decoder,
9564 offset + 0,
9565 _depth
9566 )?;
9567 Ok(())
9568 }
9569 }
9570
9571 impl fidl::encoding::ResourceTypeMarker for AllocatorBindSharedCollectionRequest {
9572 type Borrowed<'a> = &'a mut Self;
9573 fn take_or_borrow<'a>(
9574 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9575 ) -> Self::Borrowed<'a> {
9576 value
9577 }
9578 }
9579
9580 unsafe impl fidl::encoding::TypeMarker for AllocatorBindSharedCollectionRequest {
9581 type Owned = Self;
9582
9583 #[inline(always)]
9584 fn inline_align(_context: fidl::encoding::Context) -> usize {
9585 4
9586 }
9587
9588 #[inline(always)]
9589 fn inline_size(_context: fidl::encoding::Context) -> usize {
9590 8
9591 }
9592 }
9593
9594 unsafe impl
9595 fidl::encoding::Encode<
9596 AllocatorBindSharedCollectionRequest,
9597 fdomain_client::fidl::FDomainResourceDialect,
9598 > for &mut AllocatorBindSharedCollectionRequest
9599 {
9600 #[inline]
9601 unsafe fn encode(
9602 self,
9603 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9604 offset: usize,
9605 _depth: fidl::encoding::Depth,
9606 ) -> fidl::Result<()> {
9607 encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
9608 // Delegate to tuple encoding.
9609 fidl::encoding::Encode::<
9610 AllocatorBindSharedCollectionRequest,
9611 fdomain_client::fidl::FDomainResourceDialect,
9612 >::encode(
9613 (
9614 <fidl::encoding::Endpoint<
9615 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9616 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9617 &mut self.token
9618 ),
9619 <fidl::encoding::Endpoint<
9620 fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9621 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9622 &mut self.buffer_collection_request,
9623 ),
9624 ),
9625 encoder,
9626 offset,
9627 _depth,
9628 )
9629 }
9630 }
9631 unsafe impl<
9632 T0: fidl::encoding::Encode<
9633 fidl::encoding::Endpoint<
9634 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9635 >,
9636 fdomain_client::fidl::FDomainResourceDialect,
9637 >,
9638 T1: fidl::encoding::Encode<
9639 fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9640 fdomain_client::fidl::FDomainResourceDialect,
9641 >,
9642 >
9643 fidl::encoding::Encode<
9644 AllocatorBindSharedCollectionRequest,
9645 fdomain_client::fidl::FDomainResourceDialect,
9646 > for (T0, T1)
9647 {
9648 #[inline]
9649 unsafe fn encode(
9650 self,
9651 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9652 offset: usize,
9653 depth: fidl::encoding::Depth,
9654 ) -> fidl::Result<()> {
9655 encoder.debug_check_bounds::<AllocatorBindSharedCollectionRequest>(offset);
9656 // Zero out padding regions. There's no need to apply masks
9657 // because the unmasked parts will be overwritten by fields.
9658 // Write the fields.
9659 self.0.encode(encoder, offset + 0, depth)?;
9660 self.1.encode(encoder, offset + 4, depth)?;
9661 Ok(())
9662 }
9663 }
9664
9665 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9666 for AllocatorBindSharedCollectionRequest
9667 {
9668 #[inline(always)]
9669 fn new_empty() -> Self {
9670 Self {
9671 token: fidl::new_empty!(
9672 fidl::encoding::Endpoint<
9673 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9674 >,
9675 fdomain_client::fidl::FDomainResourceDialect
9676 ),
9677 buffer_collection_request: fidl::new_empty!(
9678 fidl::encoding::Endpoint<
9679 fdomain_client::fidl::ServerEnd<BufferCollectionMarker>,
9680 >,
9681 fdomain_client::fidl::FDomainResourceDialect
9682 ),
9683 }
9684 }
9685
9686 #[inline]
9687 unsafe fn decode(
9688 &mut self,
9689 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9690 offset: usize,
9691 _depth: fidl::encoding::Depth,
9692 ) -> fidl::Result<()> {
9693 decoder.debug_check_bounds::<Self>(offset);
9694 // Verify that padding bytes are zero.
9695 fidl::decode!(
9696 fidl::encoding::Endpoint<
9697 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
9698 >,
9699 fdomain_client::fidl::FDomainResourceDialect,
9700 &mut self.token,
9701 decoder,
9702 offset + 0,
9703 _depth
9704 )?;
9705 fidl::decode!(
9706 fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<BufferCollectionMarker>>,
9707 fdomain_client::fidl::FDomainResourceDialect,
9708 &mut self.buffer_collection_request,
9709 decoder,
9710 offset + 4,
9711 _depth
9712 )?;
9713 Ok(())
9714 }
9715 }
9716
9717 impl fidl::encoding::ResourceTypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
9718 type Borrowed<'a> = &'a mut Self;
9719 fn take_or_borrow<'a>(
9720 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9721 ) -> Self::Borrowed<'a> {
9722 value
9723 }
9724 }
9725
9726 unsafe impl fidl::encoding::TypeMarker for AllocatorConnectToSysmem2AllocatorRequest {
9727 type Owned = Self;
9728
9729 #[inline(always)]
9730 fn inline_align(_context: fidl::encoding::Context) -> usize {
9731 4
9732 }
9733
9734 #[inline(always)]
9735 fn inline_size(_context: fidl::encoding::Context) -> usize {
9736 4
9737 }
9738 }
9739
9740 unsafe impl
9741 fidl::encoding::Encode<
9742 AllocatorConnectToSysmem2AllocatorRequest,
9743 fdomain_client::fidl::FDomainResourceDialect,
9744 > for &mut AllocatorConnectToSysmem2AllocatorRequest
9745 {
9746 #[inline]
9747 unsafe fn encode(
9748 self,
9749 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9750 offset: usize,
9751 _depth: fidl::encoding::Depth,
9752 ) -> fidl::Result<()> {
9753 encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
9754 // Delegate to tuple encoding.
9755 fidl::encoding::Encode::<
9756 AllocatorConnectToSysmem2AllocatorRequest,
9757 fdomain_client::fidl::FDomainResourceDialect,
9758 >::encode(
9759 (<fidl::encoding::Endpoint<
9760 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9761 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9762 &mut self.allocator_request,
9763 ),),
9764 encoder,
9765 offset,
9766 _depth,
9767 )
9768 }
9769 }
9770 unsafe impl<
9771 T0: fidl::encoding::Encode<
9772 fidl::encoding::Endpoint<
9773 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9774 >,
9775 fdomain_client::fidl::FDomainResourceDialect,
9776 >,
9777 >
9778 fidl::encoding::Encode<
9779 AllocatorConnectToSysmem2AllocatorRequest,
9780 fdomain_client::fidl::FDomainResourceDialect,
9781 > for (T0,)
9782 {
9783 #[inline]
9784 unsafe fn encode(
9785 self,
9786 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9787 offset: usize,
9788 depth: fidl::encoding::Depth,
9789 ) -> fidl::Result<()> {
9790 encoder.debug_check_bounds::<AllocatorConnectToSysmem2AllocatorRequest>(offset);
9791 // Zero out padding regions. There's no need to apply masks
9792 // because the unmasked parts will be overwritten by fields.
9793 // Write the fields.
9794 self.0.encode(encoder, offset + 0, depth)?;
9795 Ok(())
9796 }
9797 }
9798
9799 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9800 for AllocatorConnectToSysmem2AllocatorRequest
9801 {
9802 #[inline(always)]
9803 fn new_empty() -> Self {
9804 Self {
9805 allocator_request: fidl::new_empty!(
9806 fidl::encoding::Endpoint<
9807 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9808 >,
9809 fdomain_client::fidl::FDomainResourceDialect
9810 ),
9811 }
9812 }
9813
9814 #[inline]
9815 unsafe fn decode(
9816 &mut self,
9817 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9818 offset: usize,
9819 _depth: fidl::encoding::Depth,
9820 ) -> fidl::Result<()> {
9821 decoder.debug_check_bounds::<Self>(offset);
9822 // Verify that padding bytes are zero.
9823 fidl::decode!(
9824 fidl::encoding::Endpoint<
9825 fdomain_client::fidl::ServerEnd<fdomain_fuchsia_sysmem2::AllocatorMarker>,
9826 >,
9827 fdomain_client::fidl::FDomainResourceDialect,
9828 &mut self.allocator_request,
9829 decoder,
9830 offset + 0,
9831 _depth
9832 )?;
9833 Ok(())
9834 }
9835 }
9836
9837 impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
9838 type Borrowed<'a> = &'a mut Self;
9839 fn take_or_borrow<'a>(
9840 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9841 ) -> Self::Borrowed<'a> {
9842 value
9843 }
9844 }
9845
9846 unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachLifetimeTrackingRequest {
9847 type Owned = Self;
9848
9849 #[inline(always)]
9850 fn inline_align(_context: fidl::encoding::Context) -> usize {
9851 4
9852 }
9853
9854 #[inline(always)]
9855 fn inline_size(_context: fidl::encoding::Context) -> usize {
9856 8
9857 }
9858 }
9859
9860 unsafe impl
9861 fidl::encoding::Encode<
9862 BufferCollectionAttachLifetimeTrackingRequest,
9863 fdomain_client::fidl::FDomainResourceDialect,
9864 > for &mut BufferCollectionAttachLifetimeTrackingRequest
9865 {
9866 #[inline]
9867 unsafe fn encode(
9868 self,
9869 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9870 offset: usize,
9871 _depth: fidl::encoding::Depth,
9872 ) -> fidl::Result<()> {
9873 encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
9874 // Delegate to tuple encoding.
9875 fidl::encoding::Encode::<
9876 BufferCollectionAttachLifetimeTrackingRequest,
9877 fdomain_client::fidl::FDomainResourceDialect,
9878 >::encode(
9879 (
9880 <fidl::encoding::HandleType<
9881 fdomain_client::EventPair,
9882 { fidl::ObjectType::EVENTPAIR.into_raw() },
9883 2147483648,
9884 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9885 &mut self.server_end
9886 ),
9887 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffers_remaining),
9888 ),
9889 encoder,
9890 offset,
9891 _depth,
9892 )
9893 }
9894 }
9895 unsafe impl<
9896 T0: fidl::encoding::Encode<
9897 fidl::encoding::HandleType<
9898 fdomain_client::EventPair,
9899 { fidl::ObjectType::EVENTPAIR.into_raw() },
9900 2147483648,
9901 >,
9902 fdomain_client::fidl::FDomainResourceDialect,
9903 >,
9904 T1: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
9905 >
9906 fidl::encoding::Encode<
9907 BufferCollectionAttachLifetimeTrackingRequest,
9908 fdomain_client::fidl::FDomainResourceDialect,
9909 > for (T0, T1)
9910 {
9911 #[inline]
9912 unsafe fn encode(
9913 self,
9914 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9915 offset: usize,
9916 depth: fidl::encoding::Depth,
9917 ) -> fidl::Result<()> {
9918 encoder.debug_check_bounds::<BufferCollectionAttachLifetimeTrackingRequest>(offset);
9919 // Zero out padding regions. There's no need to apply masks
9920 // because the unmasked parts will be overwritten by fields.
9921 // Write the fields.
9922 self.0.encode(encoder, offset + 0, depth)?;
9923 self.1.encode(encoder, offset + 4, depth)?;
9924 Ok(())
9925 }
9926 }
9927
9928 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
9929 for BufferCollectionAttachLifetimeTrackingRequest
9930 {
9931 #[inline(always)]
9932 fn new_empty() -> Self {
9933 Self {
9934 server_end: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
9935 buffers_remaining: fidl::new_empty!(
9936 u32,
9937 fdomain_client::fidl::FDomainResourceDialect
9938 ),
9939 }
9940 }
9941
9942 #[inline]
9943 unsafe fn decode(
9944 &mut self,
9945 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9946 offset: usize,
9947 _depth: fidl::encoding::Depth,
9948 ) -> fidl::Result<()> {
9949 decoder.debug_check_bounds::<Self>(offset);
9950 // Verify that padding bytes are zero.
9951 fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.server_end, decoder, offset + 0, _depth)?;
9952 fidl::decode!(
9953 u32,
9954 fdomain_client::fidl::FDomainResourceDialect,
9955 &mut self.buffers_remaining,
9956 decoder,
9957 offset + 4,
9958 _depth
9959 )?;
9960 Ok(())
9961 }
9962 }
9963
9964 impl fidl::encoding::ResourceTypeMarker for BufferCollectionAttachTokenRequest {
9965 type Borrowed<'a> = &'a mut Self;
9966 fn take_or_borrow<'a>(
9967 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9968 ) -> Self::Borrowed<'a> {
9969 value
9970 }
9971 }
9972
9973 unsafe impl fidl::encoding::TypeMarker for BufferCollectionAttachTokenRequest {
9974 type Owned = Self;
9975
9976 #[inline(always)]
9977 fn inline_align(_context: fidl::encoding::Context) -> usize {
9978 4
9979 }
9980
9981 #[inline(always)]
9982 fn inline_size(_context: fidl::encoding::Context) -> usize {
9983 8
9984 }
9985 }
9986
9987 unsafe impl
9988 fidl::encoding::Encode<
9989 BufferCollectionAttachTokenRequest,
9990 fdomain_client::fidl::FDomainResourceDialect,
9991 > for &mut BufferCollectionAttachTokenRequest
9992 {
9993 #[inline]
9994 unsafe fn encode(
9995 self,
9996 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
9997 offset: usize,
9998 _depth: fidl::encoding::Depth,
9999 ) -> fidl::Result<()> {
10000 encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
10001 // Delegate to tuple encoding.
10002 fidl::encoding::Encode::<
10003 BufferCollectionAttachTokenRequest,
10004 fdomain_client::fidl::FDomainResourceDialect,
10005 >::encode(
10006 (
10007 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
10008 <fidl::encoding::Endpoint<
10009 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10010 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10011 &mut self.token_request,
10012 ),
10013 ),
10014 encoder,
10015 offset,
10016 _depth,
10017 )
10018 }
10019 }
10020 unsafe impl<
10021 T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10022 T1: fidl::encoding::Encode<
10023 fidl::encoding::Endpoint<
10024 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10025 >,
10026 fdomain_client::fidl::FDomainResourceDialect,
10027 >,
10028 >
10029 fidl::encoding::Encode<
10030 BufferCollectionAttachTokenRequest,
10031 fdomain_client::fidl::FDomainResourceDialect,
10032 > for (T0, T1)
10033 {
10034 #[inline]
10035 unsafe fn encode(
10036 self,
10037 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10038 offset: usize,
10039 depth: fidl::encoding::Depth,
10040 ) -> fidl::Result<()> {
10041 encoder.debug_check_bounds::<BufferCollectionAttachTokenRequest>(offset);
10042 // Zero out padding regions. There's no need to apply masks
10043 // because the unmasked parts will be overwritten by fields.
10044 // Write the fields.
10045 self.0.encode(encoder, offset + 0, depth)?;
10046 self.1.encode(encoder, offset + 4, depth)?;
10047 Ok(())
10048 }
10049 }
10050
10051 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10052 for BufferCollectionAttachTokenRequest
10053 {
10054 #[inline(always)]
10055 fn new_empty() -> Self {
10056 Self {
10057 rights_attenuation_mask: fidl::new_empty!(
10058 u32,
10059 fdomain_client::fidl::FDomainResourceDialect
10060 ),
10061 token_request: fidl::new_empty!(
10062 fidl::encoding::Endpoint<
10063 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10064 >,
10065 fdomain_client::fidl::FDomainResourceDialect
10066 ),
10067 }
10068 }
10069
10070 #[inline]
10071 unsafe fn decode(
10072 &mut self,
10073 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10074 offset: usize,
10075 _depth: fidl::encoding::Depth,
10076 ) -> fidl::Result<()> {
10077 decoder.debug_check_bounds::<Self>(offset);
10078 // Verify that padding bytes are zero.
10079 fidl::decode!(
10080 u32,
10081 fdomain_client::fidl::FDomainResourceDialect,
10082 &mut self.rights_attenuation_mask,
10083 decoder,
10084 offset + 0,
10085 _depth
10086 )?;
10087 fidl::decode!(
10088 fidl::encoding::Endpoint<
10089 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10090 >,
10091 fdomain_client::fidl::FDomainResourceDialect,
10092 &mut self.token_request,
10093 decoder,
10094 offset + 4,
10095 _depth
10096 )?;
10097 Ok(())
10098 }
10099 }
10100
10101 impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo {
10102 type Borrowed<'a> = &'a mut Self;
10103 fn take_or_borrow<'a>(
10104 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10105 ) -> Self::Borrowed<'a> {
10106 value
10107 }
10108 }
10109
10110 unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo {
10111 type Owned = Self;
10112
10113 #[inline(always)]
10114 fn inline_align(_context: fidl::encoding::Context) -> usize {
10115 8
10116 }
10117
10118 #[inline(always)]
10119 fn inline_size(_context: fidl::encoding::Context) -> usize {
10120 352
10121 }
10122 }
10123
10124 unsafe impl
10125 fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
10126 for &mut BufferCollectionInfo
10127 {
10128 #[inline]
10129 unsafe fn encode(
10130 self,
10131 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10132 offset: usize,
10133 _depth: fidl::encoding::Depth,
10134 ) -> fidl::Result<()> {
10135 encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
10136 // Delegate to tuple encoding.
10137 fidl::encoding::Encode::<
10138 BufferCollectionInfo,
10139 fdomain_client::fidl::FDomainResourceDialect,
10140 >::encode(
10141 (
10142 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
10143 <BufferFormat as fidl::encoding::ValueTypeMarker>::borrow(&self.format),
10144 <fidl::encoding::Array<
10145 fidl::encoding::Optional<
10146 fidl::encoding::HandleType<
10147 fdomain_client::Vmo,
10148 { fidl::ObjectType::VMO.into_raw() },
10149 2147483648,
10150 >,
10151 >,
10152 64,
10153 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10154 &mut self.vmos
10155 ),
10156 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_size),
10157 ),
10158 encoder,
10159 offset,
10160 _depth,
10161 )
10162 }
10163 }
10164 unsafe impl<
10165 T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10166 T1: fidl::encoding::Encode<BufferFormat, fdomain_client::fidl::FDomainResourceDialect>,
10167 T2: fidl::encoding::Encode<
10168 fidl::encoding::Array<
10169 fidl::encoding::Optional<
10170 fidl::encoding::HandleType<
10171 fdomain_client::Vmo,
10172 { fidl::ObjectType::VMO.into_raw() },
10173 2147483648,
10174 >,
10175 >,
10176 64,
10177 >,
10178 fdomain_client::fidl::FDomainResourceDialect,
10179 >,
10180 T3: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
10181 > fidl::encoding::Encode<BufferCollectionInfo, fdomain_client::fidl::FDomainResourceDialect>
10182 for (T0, T1, T2, T3)
10183 {
10184 #[inline]
10185 unsafe fn encode(
10186 self,
10187 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10188 offset: usize,
10189 depth: fidl::encoding::Depth,
10190 ) -> fidl::Result<()> {
10191 encoder.debug_check_bounds::<BufferCollectionInfo>(offset);
10192 // Zero out padding regions. There's no need to apply masks
10193 // because the unmasked parts will be overwritten by fields.
10194 unsafe {
10195 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
10196 (ptr as *mut u64).write_unaligned(0);
10197 }
10198 // Write the fields.
10199 self.0.encode(encoder, offset + 0, depth)?;
10200 self.1.encode(encoder, offset + 8, depth)?;
10201 self.2.encode(encoder, offset + 88, depth)?;
10202 self.3.encode(encoder, offset + 344, depth)?;
10203 Ok(())
10204 }
10205 }
10206
10207 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10208 for BufferCollectionInfo
10209 {
10210 #[inline(always)]
10211 fn new_empty() -> Self {
10212 Self {
10213 buffer_count: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
10214 format: fidl::new_empty!(
10215 BufferFormat,
10216 fdomain_client::fidl::FDomainResourceDialect
10217 ),
10218 vmos: fidl::new_empty!(
10219 fidl::encoding::Array<
10220 fidl::encoding::Optional<
10221 fidl::encoding::HandleType<
10222 fdomain_client::Vmo,
10223 { fidl::ObjectType::VMO.into_raw() },
10224 2147483648,
10225 >,
10226 >,
10227 64,
10228 >,
10229 fdomain_client::fidl::FDomainResourceDialect
10230 ),
10231 vmo_size: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
10232 }
10233 }
10234
10235 #[inline]
10236 unsafe fn decode(
10237 &mut self,
10238 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10239 offset: usize,
10240 _depth: fidl::encoding::Depth,
10241 ) -> fidl::Result<()> {
10242 decoder.debug_check_bounds::<Self>(offset);
10243 // Verify that padding bytes are zero.
10244 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
10245 let padval = unsafe { (ptr as *const u64).read_unaligned() };
10246 let mask = 0xffffffff00000000u64;
10247 let maskedval = padval & mask;
10248 if maskedval != 0 {
10249 return Err(fidl::Error::NonZeroPadding {
10250 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
10251 });
10252 }
10253 fidl::decode!(
10254 u32,
10255 fdomain_client::fidl::FDomainResourceDialect,
10256 &mut self.buffer_count,
10257 decoder,
10258 offset + 0,
10259 _depth
10260 )?;
10261 fidl::decode!(
10262 BufferFormat,
10263 fdomain_client::fidl::FDomainResourceDialect,
10264 &mut self.format,
10265 decoder,
10266 offset + 8,
10267 _depth
10268 )?;
10269 fidl::decode!(
10270 fidl::encoding::Array<
10271 fidl::encoding::Optional<
10272 fidl::encoding::HandleType<
10273 fdomain_client::Vmo,
10274 { fidl::ObjectType::VMO.into_raw() },
10275 2147483648,
10276 >,
10277 >,
10278 64,
10279 >,
10280 fdomain_client::fidl::FDomainResourceDialect,
10281 &mut self.vmos,
10282 decoder,
10283 offset + 88,
10284 _depth
10285 )?;
10286 fidl::decode!(
10287 u64,
10288 fdomain_client::fidl::FDomainResourceDialect,
10289 &mut self.vmo_size,
10290 decoder,
10291 offset + 344,
10292 _depth
10293 )?;
10294 Ok(())
10295 }
10296 }
10297
10298 impl fidl::encoding::ResourceTypeMarker for BufferCollectionInfo2 {
10299 type Borrowed<'a> = &'a mut Self;
10300 fn take_or_borrow<'a>(
10301 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10302 ) -> Self::Borrowed<'a> {
10303 value
10304 }
10305 }
10306
10307 unsafe impl fidl::encoding::TypeMarker for BufferCollectionInfo2 {
10308 type Owned = Self;
10309
10310 #[inline(always)]
10311 fn inline_align(_context: fidl::encoding::Context) -> usize {
10312 8
10313 }
10314
10315 #[inline(always)]
10316 fn inline_size(_context: fidl::encoding::Context) -> usize {
10317 1296
10318 }
10319 }
10320
10321 unsafe impl
10322 fidl::encoding::Encode<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>
10323 for &mut BufferCollectionInfo2
10324 {
10325 #[inline]
10326 unsafe fn encode(
10327 self,
10328 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10329 offset: usize,
10330 _depth: fidl::encoding::Depth,
10331 ) -> fidl::Result<()> {
10332 encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
10333 // Delegate to tuple encoding.
10334 fidl::encoding::Encode::<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>::encode(
10335 (
10336 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_count),
10337 <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
10338 <fidl::encoding::Array<VmoBuffer, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
10339 ),
10340 encoder, offset, _depth
10341 )
10342 }
10343 }
10344 unsafe impl<
10345 T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10346 T1: fidl::encoding::Encode<SingleBufferSettings, fdomain_client::fidl::FDomainResourceDialect>,
10347 T2: fidl::encoding::Encode<
10348 fidl::encoding::Array<VmoBuffer, 64>,
10349 fdomain_client::fidl::FDomainResourceDialect,
10350 >,
10351 >
10352 fidl::encoding::Encode<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>
10353 for (T0, T1, T2)
10354 {
10355 #[inline]
10356 unsafe fn encode(
10357 self,
10358 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10359 offset: usize,
10360 depth: fidl::encoding::Depth,
10361 ) -> fidl::Result<()> {
10362 encoder.debug_check_bounds::<BufferCollectionInfo2>(offset);
10363 // Zero out padding regions. There's no need to apply masks
10364 // because the unmasked parts will be overwritten by fields.
10365 unsafe {
10366 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
10367 (ptr as *mut u64).write_unaligned(0);
10368 }
10369 // Write the fields.
10370 self.0.encode(encoder, offset + 0, depth)?;
10371 self.1.encode(encoder, offset + 8, depth)?;
10372 self.2.encode(encoder, offset + 272, depth)?;
10373 Ok(())
10374 }
10375 }
10376
10377 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10378 for BufferCollectionInfo2
10379 {
10380 #[inline(always)]
10381 fn new_empty() -> Self {
10382 Self {
10383 buffer_count: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
10384 settings: fidl::new_empty!(
10385 SingleBufferSettings,
10386 fdomain_client::fidl::FDomainResourceDialect
10387 ),
10388 buffers: fidl::new_empty!(fidl::encoding::Array<VmoBuffer, 64>, fdomain_client::fidl::FDomainResourceDialect),
10389 }
10390 }
10391
10392 #[inline]
10393 unsafe fn decode(
10394 &mut self,
10395 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10396 offset: usize,
10397 _depth: fidl::encoding::Depth,
10398 ) -> fidl::Result<()> {
10399 decoder.debug_check_bounds::<Self>(offset);
10400 // Verify that padding bytes are zero.
10401 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
10402 let padval = unsafe { (ptr as *const u64).read_unaligned() };
10403 let mask = 0xffffffff00000000u64;
10404 let maskedval = padval & mask;
10405 if maskedval != 0 {
10406 return Err(fidl::Error::NonZeroPadding {
10407 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
10408 });
10409 }
10410 fidl::decode!(
10411 u32,
10412 fdomain_client::fidl::FDomainResourceDialect,
10413 &mut self.buffer_count,
10414 decoder,
10415 offset + 0,
10416 _depth
10417 )?;
10418 fidl::decode!(
10419 SingleBufferSettings,
10420 fdomain_client::fidl::FDomainResourceDialect,
10421 &mut self.settings,
10422 decoder,
10423 offset + 8,
10424 _depth
10425 )?;
10426 fidl::decode!(fidl::encoding::Array<VmoBuffer, 64>, fdomain_client::fidl::FDomainResourceDialect, &mut self.buffers, decoder, offset + 272, _depth)?;
10427 Ok(())
10428 }
10429 }
10430
10431 impl fidl::encoding::ResourceTypeMarker
10432 for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10433 {
10434 type Borrowed<'a> = &'a mut Self;
10435 fn take_or_borrow<'a>(
10436 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10437 ) -> Self::Borrowed<'a> {
10438 value
10439 }
10440 }
10441
10442 unsafe impl fidl::encoding::TypeMarker
10443 for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10444 {
10445 type Owned = Self;
10446
10447 #[inline(always)]
10448 fn inline_align(_context: fidl::encoding::Context) -> usize {
10449 4
10450 }
10451
10452 #[inline(always)]
10453 fn inline_size(_context: fidl::encoding::Context) -> usize {
10454 4
10455 }
10456 }
10457
10458 unsafe impl
10459 fidl::encoding::Encode<
10460 BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
10461 fdomain_client::fidl::FDomainResourceDialect,
10462 > for &mut BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10463 {
10464 #[inline]
10465 unsafe fn encode(
10466 self,
10467 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10468 offset: usize,
10469 _depth: fidl::encoding::Depth,
10470 ) -> fidl::Result<()> {
10471 encoder
10472 .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
10473 offset,
10474 );
10475 // Delegate to tuple encoding.
10476 fidl::encoding::Encode::<
10477 BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
10478 fdomain_client::fidl::FDomainResourceDialect,
10479 >::encode(
10480 (<fidl::encoding::Endpoint<
10481 fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10482 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10483 &mut self.group_request
10484 ),),
10485 encoder,
10486 offset,
10487 _depth,
10488 )
10489 }
10490 }
10491 unsafe impl<
10492 T0: fidl::encoding::Encode<
10493 fidl::encoding::Endpoint<
10494 fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10495 >,
10496 fdomain_client::fidl::FDomainResourceDialect,
10497 >,
10498 >
10499 fidl::encoding::Encode<
10500 BufferCollectionTokenCreateBufferCollectionTokenGroupRequest,
10501 fdomain_client::fidl::FDomainResourceDialect,
10502 > for (T0,)
10503 {
10504 #[inline]
10505 unsafe fn encode(
10506 self,
10507 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10508 offset: usize,
10509 depth: fidl::encoding::Depth,
10510 ) -> fidl::Result<()> {
10511 encoder
10512 .debug_check_bounds::<BufferCollectionTokenCreateBufferCollectionTokenGroupRequest>(
10513 offset,
10514 );
10515 // Zero out padding regions. There's no need to apply masks
10516 // because the unmasked parts will be overwritten by fields.
10517 // Write the fields.
10518 self.0.encode(encoder, offset + 0, depth)?;
10519 Ok(())
10520 }
10521 }
10522
10523 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10524 for BufferCollectionTokenCreateBufferCollectionTokenGroupRequest
10525 {
10526 #[inline(always)]
10527 fn new_empty() -> Self {
10528 Self {
10529 group_request: fidl::new_empty!(
10530 fidl::encoding::Endpoint<
10531 fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10532 >,
10533 fdomain_client::fidl::FDomainResourceDialect
10534 ),
10535 }
10536 }
10537
10538 #[inline]
10539 unsafe fn decode(
10540 &mut self,
10541 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10542 offset: usize,
10543 _depth: fidl::encoding::Depth,
10544 ) -> fidl::Result<()> {
10545 decoder.debug_check_bounds::<Self>(offset);
10546 // Verify that padding bytes are zero.
10547 fidl::decode!(
10548 fidl::encoding::Endpoint<
10549 fdomain_client::fidl::ServerEnd<BufferCollectionTokenGroupMarker>,
10550 >,
10551 fdomain_client::fidl::FDomainResourceDialect,
10552 &mut self.group_request,
10553 decoder,
10554 offset + 0,
10555 _depth
10556 )?;
10557 Ok(())
10558 }
10559 }
10560
10561 impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateRequest {
10562 type Borrowed<'a> = &'a mut Self;
10563 fn take_or_borrow<'a>(
10564 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10565 ) -> Self::Borrowed<'a> {
10566 value
10567 }
10568 }
10569
10570 unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateRequest {
10571 type Owned = Self;
10572
10573 #[inline(always)]
10574 fn inline_align(_context: fidl::encoding::Context) -> usize {
10575 4
10576 }
10577
10578 #[inline(always)]
10579 fn inline_size(_context: fidl::encoding::Context) -> usize {
10580 8
10581 }
10582 }
10583
10584 unsafe impl
10585 fidl::encoding::Encode<
10586 BufferCollectionTokenDuplicateRequest,
10587 fdomain_client::fidl::FDomainResourceDialect,
10588 > for &mut BufferCollectionTokenDuplicateRequest
10589 {
10590 #[inline]
10591 unsafe fn encode(
10592 self,
10593 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10594 offset: usize,
10595 _depth: fidl::encoding::Depth,
10596 ) -> fidl::Result<()> {
10597 encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
10598 // Delegate to tuple encoding.
10599 fidl::encoding::Encode::<
10600 BufferCollectionTokenDuplicateRequest,
10601 fdomain_client::fidl::FDomainResourceDialect,
10602 >::encode(
10603 (
10604 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rights_attenuation_mask),
10605 <fidl::encoding::Endpoint<
10606 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10607 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10608 &mut self.token_request,
10609 ),
10610 ),
10611 encoder,
10612 offset,
10613 _depth,
10614 )
10615 }
10616 }
10617 unsafe impl<
10618 T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
10619 T1: fidl::encoding::Encode<
10620 fidl::encoding::Endpoint<
10621 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10622 >,
10623 fdomain_client::fidl::FDomainResourceDialect,
10624 >,
10625 >
10626 fidl::encoding::Encode<
10627 BufferCollectionTokenDuplicateRequest,
10628 fdomain_client::fidl::FDomainResourceDialect,
10629 > for (T0, T1)
10630 {
10631 #[inline]
10632 unsafe fn encode(
10633 self,
10634 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10635 offset: usize,
10636 depth: fidl::encoding::Depth,
10637 ) -> fidl::Result<()> {
10638 encoder.debug_check_bounds::<BufferCollectionTokenDuplicateRequest>(offset);
10639 // Zero out padding regions. There's no need to apply masks
10640 // because the unmasked parts will be overwritten by fields.
10641 // Write the fields.
10642 self.0.encode(encoder, offset + 0, depth)?;
10643 self.1.encode(encoder, offset + 4, depth)?;
10644 Ok(())
10645 }
10646 }
10647
10648 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10649 for BufferCollectionTokenDuplicateRequest
10650 {
10651 #[inline(always)]
10652 fn new_empty() -> Self {
10653 Self {
10654 rights_attenuation_mask: fidl::new_empty!(
10655 u32,
10656 fdomain_client::fidl::FDomainResourceDialect
10657 ),
10658 token_request: fidl::new_empty!(
10659 fidl::encoding::Endpoint<
10660 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10661 >,
10662 fdomain_client::fidl::FDomainResourceDialect
10663 ),
10664 }
10665 }
10666
10667 #[inline]
10668 unsafe fn decode(
10669 &mut self,
10670 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10671 offset: usize,
10672 _depth: fidl::encoding::Depth,
10673 ) -> fidl::Result<()> {
10674 decoder.debug_check_bounds::<Self>(offset);
10675 // Verify that padding bytes are zero.
10676 fidl::decode!(
10677 u32,
10678 fdomain_client::fidl::FDomainResourceDialect,
10679 &mut self.rights_attenuation_mask,
10680 decoder,
10681 offset + 0,
10682 _depth
10683 )?;
10684 fidl::decode!(
10685 fidl::encoding::Endpoint<
10686 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
10687 >,
10688 fdomain_client::fidl::FDomainResourceDialect,
10689 &mut self.token_request,
10690 decoder,
10691 offset + 4,
10692 _depth
10693 )?;
10694 Ok(())
10695 }
10696 }
10697
10698 impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenDuplicateSyncResponse {
10699 type Borrowed<'a> = &'a mut Self;
10700 fn take_or_borrow<'a>(
10701 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10702 ) -> Self::Borrowed<'a> {
10703 value
10704 }
10705 }
10706
10707 unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenDuplicateSyncResponse {
10708 type Owned = Self;
10709
10710 #[inline(always)]
10711 fn inline_align(_context: fidl::encoding::Context) -> usize {
10712 8
10713 }
10714
10715 #[inline(always)]
10716 fn inline_size(_context: fidl::encoding::Context) -> usize {
10717 16
10718 }
10719 }
10720
10721 unsafe impl
10722 fidl::encoding::Encode<
10723 BufferCollectionTokenDuplicateSyncResponse,
10724 fdomain_client::fidl::FDomainResourceDialect,
10725 > for &mut BufferCollectionTokenDuplicateSyncResponse
10726 {
10727 #[inline]
10728 unsafe fn encode(
10729 self,
10730 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10731 offset: usize,
10732 _depth: fidl::encoding::Depth,
10733 ) -> fidl::Result<()> {
10734 encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
10735 // Delegate to tuple encoding.
10736 fidl::encoding::Encode::<
10737 BufferCollectionTokenDuplicateSyncResponse,
10738 fdomain_client::fidl::FDomainResourceDialect,
10739 >::encode(
10740 (<fidl::encoding::Vector<
10741 fidl::encoding::Endpoint<
10742 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10743 >,
10744 64,
10745 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10746 &mut self.tokens
10747 ),),
10748 encoder,
10749 offset,
10750 _depth,
10751 )
10752 }
10753 }
10754 unsafe impl<
10755 T0: fidl::encoding::Encode<
10756 fidl::encoding::Vector<
10757 fidl::encoding::Endpoint<
10758 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10759 >,
10760 64,
10761 >,
10762 fdomain_client::fidl::FDomainResourceDialect,
10763 >,
10764 >
10765 fidl::encoding::Encode<
10766 BufferCollectionTokenDuplicateSyncResponse,
10767 fdomain_client::fidl::FDomainResourceDialect,
10768 > for (T0,)
10769 {
10770 #[inline]
10771 unsafe fn encode(
10772 self,
10773 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10774 offset: usize,
10775 depth: fidl::encoding::Depth,
10776 ) -> fidl::Result<()> {
10777 encoder.debug_check_bounds::<BufferCollectionTokenDuplicateSyncResponse>(offset);
10778 // Zero out padding regions. There's no need to apply masks
10779 // because the unmasked parts will be overwritten by fields.
10780 // Write the fields.
10781 self.0.encode(encoder, offset + 0, depth)?;
10782 Ok(())
10783 }
10784 }
10785
10786 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10787 for BufferCollectionTokenDuplicateSyncResponse
10788 {
10789 #[inline(always)]
10790 fn new_empty() -> Self {
10791 Self {
10792 tokens: fidl::new_empty!(
10793 fidl::encoding::Vector<
10794 fidl::encoding::Endpoint<
10795 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10796 >,
10797 64,
10798 >,
10799 fdomain_client::fidl::FDomainResourceDialect
10800 ),
10801 }
10802 }
10803
10804 #[inline]
10805 unsafe fn decode(
10806 &mut self,
10807 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10808 offset: usize,
10809 _depth: fidl::encoding::Depth,
10810 ) -> fidl::Result<()> {
10811 decoder.debug_check_bounds::<Self>(offset);
10812 // Verify that padding bytes are zero.
10813 fidl::decode!(
10814 fidl::encoding::Vector<
10815 fidl::encoding::Endpoint<
10816 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10817 >,
10818 64,
10819 >,
10820 fdomain_client::fidl::FDomainResourceDialect,
10821 &mut self.tokens,
10822 decoder,
10823 offset + 0,
10824 _depth
10825 )?;
10826 Ok(())
10827 }
10828 }
10829
10830 impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
10831 type Borrowed<'a> = &'a mut Self;
10832 fn take_or_borrow<'a>(
10833 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10834 ) -> Self::Borrowed<'a> {
10835 value
10836 }
10837 }
10838
10839 unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildrenSyncResponse {
10840 type Owned = Self;
10841
10842 #[inline(always)]
10843 fn inline_align(_context: fidl::encoding::Context) -> usize {
10844 8
10845 }
10846
10847 #[inline(always)]
10848 fn inline_size(_context: fidl::encoding::Context) -> usize {
10849 16
10850 }
10851 }
10852
10853 unsafe impl
10854 fidl::encoding::Encode<
10855 BufferCollectionTokenGroupCreateChildrenSyncResponse,
10856 fdomain_client::fidl::FDomainResourceDialect,
10857 > for &mut BufferCollectionTokenGroupCreateChildrenSyncResponse
10858 {
10859 #[inline]
10860 unsafe fn encode(
10861 self,
10862 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10863 offset: usize,
10864 _depth: fidl::encoding::Depth,
10865 ) -> fidl::Result<()> {
10866 encoder
10867 .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
10868 // Delegate to tuple encoding.
10869 fidl::encoding::Encode::<
10870 BufferCollectionTokenGroupCreateChildrenSyncResponse,
10871 fdomain_client::fidl::FDomainResourceDialect,
10872 >::encode(
10873 (<fidl::encoding::Vector<
10874 fidl::encoding::Endpoint<
10875 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10876 >,
10877 64,
10878 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
10879 &mut self.tokens
10880 ),),
10881 encoder,
10882 offset,
10883 _depth,
10884 )
10885 }
10886 }
10887 unsafe impl<
10888 T0: fidl::encoding::Encode<
10889 fidl::encoding::Vector<
10890 fidl::encoding::Endpoint<
10891 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10892 >,
10893 64,
10894 >,
10895 fdomain_client::fidl::FDomainResourceDialect,
10896 >,
10897 >
10898 fidl::encoding::Encode<
10899 BufferCollectionTokenGroupCreateChildrenSyncResponse,
10900 fdomain_client::fidl::FDomainResourceDialect,
10901 > for (T0,)
10902 {
10903 #[inline]
10904 unsafe fn encode(
10905 self,
10906 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10907 offset: usize,
10908 depth: fidl::encoding::Depth,
10909 ) -> fidl::Result<()> {
10910 encoder
10911 .debug_check_bounds::<BufferCollectionTokenGroupCreateChildrenSyncResponse>(offset);
10912 // Zero out padding regions. There's no need to apply masks
10913 // because the unmasked parts will be overwritten by fields.
10914 // Write the fields.
10915 self.0.encode(encoder, offset + 0, depth)?;
10916 Ok(())
10917 }
10918 }
10919
10920 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
10921 for BufferCollectionTokenGroupCreateChildrenSyncResponse
10922 {
10923 #[inline(always)]
10924 fn new_empty() -> Self {
10925 Self {
10926 tokens: fidl::new_empty!(
10927 fidl::encoding::Vector<
10928 fidl::encoding::Endpoint<
10929 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10930 >,
10931 64,
10932 >,
10933 fdomain_client::fidl::FDomainResourceDialect
10934 ),
10935 }
10936 }
10937
10938 #[inline]
10939 unsafe fn decode(
10940 &mut self,
10941 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10942 offset: usize,
10943 _depth: fidl::encoding::Depth,
10944 ) -> fidl::Result<()> {
10945 decoder.debug_check_bounds::<Self>(offset);
10946 // Verify that padding bytes are zero.
10947 fidl::decode!(
10948 fidl::encoding::Vector<
10949 fidl::encoding::Endpoint<
10950 fdomain_client::fidl::ClientEnd<BufferCollectionTokenMarker>,
10951 >,
10952 64,
10953 >,
10954 fdomain_client::fidl::FDomainResourceDialect,
10955 &mut self.tokens,
10956 decoder,
10957 offset + 0,
10958 _depth
10959 )?;
10960 Ok(())
10961 }
10962 }
10963
10964 impl fidl::encoding::ResourceTypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
10965 type Borrowed<'a> = &'a mut Self;
10966 fn take_or_borrow<'a>(
10967 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10968 ) -> Self::Borrowed<'a> {
10969 value
10970 }
10971 }
10972
10973 unsafe impl fidl::encoding::TypeMarker for BufferCollectionWaitForBuffersAllocatedResponse {
10974 type Owned = Self;
10975
10976 #[inline(always)]
10977 fn inline_align(_context: fidl::encoding::Context) -> usize {
10978 8
10979 }
10980
10981 #[inline(always)]
10982 fn inline_size(_context: fidl::encoding::Context) -> usize {
10983 1304
10984 }
10985 }
10986
10987 unsafe impl
10988 fidl::encoding::Encode<
10989 BufferCollectionWaitForBuffersAllocatedResponse,
10990 fdomain_client::fidl::FDomainResourceDialect,
10991 > for &mut BufferCollectionWaitForBuffersAllocatedResponse
10992 {
10993 #[inline]
10994 unsafe fn encode(
10995 self,
10996 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
10997 offset: usize,
10998 _depth: fidl::encoding::Depth,
10999 ) -> fidl::Result<()> {
11000 encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
11001 // Delegate to tuple encoding.
11002 fidl::encoding::Encode::<
11003 BufferCollectionWaitForBuffersAllocatedResponse,
11004 fdomain_client::fidl::FDomainResourceDialect,
11005 >::encode(
11006 (
11007 <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
11008 <BufferCollectionInfo2 as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11009 &mut self.buffer_collection_info,
11010 ),
11011 ),
11012 encoder,
11013 offset,
11014 _depth,
11015 )
11016 }
11017 }
11018 unsafe impl<
11019 T0: fidl::encoding::Encode<i32, fdomain_client::fidl::FDomainResourceDialect>,
11020 T1: fidl::encoding::Encode<BufferCollectionInfo2, fdomain_client::fidl::FDomainResourceDialect>,
11021 >
11022 fidl::encoding::Encode<
11023 BufferCollectionWaitForBuffersAllocatedResponse,
11024 fdomain_client::fidl::FDomainResourceDialect,
11025 > for (T0, T1)
11026 {
11027 #[inline]
11028 unsafe fn encode(
11029 self,
11030 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11031 offset: usize,
11032 depth: fidl::encoding::Depth,
11033 ) -> fidl::Result<()> {
11034 encoder.debug_check_bounds::<BufferCollectionWaitForBuffersAllocatedResponse>(offset);
11035 // Zero out padding regions. There's no need to apply masks
11036 // because the unmasked parts will be overwritten by fields.
11037 unsafe {
11038 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
11039 (ptr as *mut u64).write_unaligned(0);
11040 }
11041 // Write the fields.
11042 self.0.encode(encoder, offset + 0, depth)?;
11043 self.1.encode(encoder, offset + 8, depth)?;
11044 Ok(())
11045 }
11046 }
11047
11048 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11049 for BufferCollectionWaitForBuffersAllocatedResponse
11050 {
11051 #[inline(always)]
11052 fn new_empty() -> Self {
11053 Self {
11054 status: fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect),
11055 buffer_collection_info: fidl::new_empty!(
11056 BufferCollectionInfo2,
11057 fdomain_client::fidl::FDomainResourceDialect
11058 ),
11059 }
11060 }
11061
11062 #[inline]
11063 unsafe fn decode(
11064 &mut self,
11065 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11066 offset: usize,
11067 _depth: fidl::encoding::Depth,
11068 ) -> fidl::Result<()> {
11069 decoder.debug_check_bounds::<Self>(offset);
11070 // Verify that padding bytes are zero.
11071 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
11072 let padval = unsafe { (ptr as *const u64).read_unaligned() };
11073 let mask = 0xffffffff00000000u64;
11074 let maskedval = padval & mask;
11075 if maskedval != 0 {
11076 return Err(fidl::Error::NonZeroPadding {
11077 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
11078 });
11079 }
11080 fidl::decode!(
11081 i32,
11082 fdomain_client::fidl::FDomainResourceDialect,
11083 &mut self.status,
11084 decoder,
11085 offset + 0,
11086 _depth
11087 )?;
11088 fidl::decode!(
11089 BufferCollectionInfo2,
11090 fdomain_client::fidl::FDomainResourceDialect,
11091 &mut self.buffer_collection_info,
11092 decoder,
11093 offset + 8,
11094 _depth
11095 )?;
11096 Ok(())
11097 }
11098 }
11099
11100 impl fidl::encoding::ResourceTypeMarker for NodeGetNodeRefResponse {
11101 type Borrowed<'a> = &'a mut Self;
11102 fn take_or_borrow<'a>(
11103 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11104 ) -> Self::Borrowed<'a> {
11105 value
11106 }
11107 }
11108
11109 unsafe impl fidl::encoding::TypeMarker for NodeGetNodeRefResponse {
11110 type Owned = Self;
11111
11112 #[inline(always)]
11113 fn inline_align(_context: fidl::encoding::Context) -> usize {
11114 4
11115 }
11116
11117 #[inline(always)]
11118 fn inline_size(_context: fidl::encoding::Context) -> usize {
11119 4
11120 }
11121 }
11122
11123 unsafe impl
11124 fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
11125 for &mut NodeGetNodeRefResponse
11126 {
11127 #[inline]
11128 unsafe fn encode(
11129 self,
11130 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11131 offset: usize,
11132 _depth: fidl::encoding::Depth,
11133 ) -> fidl::Result<()> {
11134 encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
11135 // Delegate to tuple encoding.
11136 fidl::encoding::Encode::<
11137 NodeGetNodeRefResponse,
11138 fdomain_client::fidl::FDomainResourceDialect,
11139 >::encode(
11140 (<fidl::encoding::HandleType<
11141 fdomain_client::Event,
11142 { fidl::ObjectType::EVENT.into_raw() },
11143 2147483648,
11144 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11145 &mut self.node_ref
11146 ),),
11147 encoder,
11148 offset,
11149 _depth,
11150 )
11151 }
11152 }
11153 unsafe impl<
11154 T0: fidl::encoding::Encode<
11155 fidl::encoding::HandleType<
11156 fdomain_client::Event,
11157 { fidl::ObjectType::EVENT.into_raw() },
11158 2147483648,
11159 >,
11160 fdomain_client::fidl::FDomainResourceDialect,
11161 >,
11162 >
11163 fidl::encoding::Encode<NodeGetNodeRefResponse, fdomain_client::fidl::FDomainResourceDialect>
11164 for (T0,)
11165 {
11166 #[inline]
11167 unsafe fn encode(
11168 self,
11169 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11170 offset: usize,
11171 depth: fidl::encoding::Depth,
11172 ) -> fidl::Result<()> {
11173 encoder.debug_check_bounds::<NodeGetNodeRefResponse>(offset);
11174 // Zero out padding regions. There's no need to apply masks
11175 // because the unmasked parts will be overwritten by fields.
11176 // Write the fields.
11177 self.0.encode(encoder, offset + 0, depth)?;
11178 Ok(())
11179 }
11180 }
11181
11182 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11183 for NodeGetNodeRefResponse
11184 {
11185 #[inline(always)]
11186 fn new_empty() -> Self {
11187 Self {
11188 node_ref: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
11189 }
11190 }
11191
11192 #[inline]
11193 unsafe fn decode(
11194 &mut self,
11195 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11196 offset: usize,
11197 _depth: fidl::encoding::Depth,
11198 ) -> fidl::Result<()> {
11199 decoder.debug_check_bounds::<Self>(offset);
11200 // Verify that padding bytes are zero.
11201 fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
11202 Ok(())
11203 }
11204 }
11205
11206 impl fidl::encoding::ResourceTypeMarker for NodeIsAlternateForRequest {
11207 type Borrowed<'a> = &'a mut Self;
11208 fn take_or_borrow<'a>(
11209 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11210 ) -> Self::Borrowed<'a> {
11211 value
11212 }
11213 }
11214
11215 unsafe impl fidl::encoding::TypeMarker for NodeIsAlternateForRequest {
11216 type Owned = Self;
11217
11218 #[inline(always)]
11219 fn inline_align(_context: fidl::encoding::Context) -> usize {
11220 4
11221 }
11222
11223 #[inline(always)]
11224 fn inline_size(_context: fidl::encoding::Context) -> usize {
11225 4
11226 }
11227 }
11228
11229 unsafe impl
11230 fidl::encoding::Encode<
11231 NodeIsAlternateForRequest,
11232 fdomain_client::fidl::FDomainResourceDialect,
11233 > for &mut NodeIsAlternateForRequest
11234 {
11235 #[inline]
11236 unsafe fn encode(
11237 self,
11238 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11239 offset: usize,
11240 _depth: fidl::encoding::Depth,
11241 ) -> fidl::Result<()> {
11242 encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
11243 // Delegate to tuple encoding.
11244 fidl::encoding::Encode::<
11245 NodeIsAlternateForRequest,
11246 fdomain_client::fidl::FDomainResourceDialect,
11247 >::encode(
11248 (<fidl::encoding::HandleType<
11249 fdomain_client::Event,
11250 { fidl::ObjectType::EVENT.into_raw() },
11251 2147483648,
11252 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
11253 &mut self.node_ref
11254 ),),
11255 encoder,
11256 offset,
11257 _depth,
11258 )
11259 }
11260 }
11261 unsafe impl<
11262 T0: fidl::encoding::Encode<
11263 fidl::encoding::HandleType<
11264 fdomain_client::Event,
11265 { fidl::ObjectType::EVENT.into_raw() },
11266 2147483648,
11267 >,
11268 fdomain_client::fidl::FDomainResourceDialect,
11269 >,
11270 >
11271 fidl::encoding::Encode<
11272 NodeIsAlternateForRequest,
11273 fdomain_client::fidl::FDomainResourceDialect,
11274 > for (T0,)
11275 {
11276 #[inline]
11277 unsafe fn encode(
11278 self,
11279 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11280 offset: usize,
11281 depth: fidl::encoding::Depth,
11282 ) -> fidl::Result<()> {
11283 encoder.debug_check_bounds::<NodeIsAlternateForRequest>(offset);
11284 // Zero out padding regions. There's no need to apply masks
11285 // because the unmasked parts will be overwritten by fields.
11286 // Write the fields.
11287 self.0.encode(encoder, offset + 0, depth)?;
11288 Ok(())
11289 }
11290 }
11291
11292 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11293 for NodeIsAlternateForRequest
11294 {
11295 #[inline(always)]
11296 fn new_empty() -> Self {
11297 Self {
11298 node_ref: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
11299 }
11300 }
11301
11302 #[inline]
11303 unsafe fn decode(
11304 &mut self,
11305 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11306 offset: usize,
11307 _depth: fidl::encoding::Depth,
11308 ) -> fidl::Result<()> {
11309 decoder.debug_check_bounds::<Self>(offset);
11310 // Verify that padding bytes are zero.
11311 fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.node_ref, decoder, offset + 0, _depth)?;
11312 Ok(())
11313 }
11314 }
11315
11316 impl fidl::encoding::ResourceTypeMarker for SingleBufferInfo {
11317 type Borrowed<'a> = &'a mut Self;
11318 fn take_or_borrow<'a>(
11319 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11320 ) -> Self::Borrowed<'a> {
11321 value
11322 }
11323 }
11324
11325 unsafe impl fidl::encoding::TypeMarker for SingleBufferInfo {
11326 type Owned = Self;
11327
11328 #[inline(always)]
11329 fn inline_align(_context: fidl::encoding::Context) -> usize {
11330 8
11331 }
11332
11333 #[inline(always)]
11334 fn inline_size(_context: fidl::encoding::Context) -> usize {
11335 280
11336 }
11337 }
11338
11339 unsafe impl
11340 fidl::encoding::Encode<SingleBufferInfo, fdomain_client::fidl::FDomainResourceDialect>
11341 for &mut SingleBufferInfo
11342 {
11343 #[inline]
11344 unsafe fn encode(
11345 self,
11346 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11347 offset: usize,
11348 _depth: fidl::encoding::Depth,
11349 ) -> fidl::Result<()> {
11350 encoder.debug_check_bounds::<SingleBufferInfo>(offset);
11351 // Delegate to tuple encoding.
11352 fidl::encoding::Encode::<SingleBufferInfo, fdomain_client::fidl::FDomainResourceDialect>::encode(
11353 (
11354 <SingleBufferSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),
11355 <VmoBuffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffer),
11356 ),
11357 encoder, offset, _depth
11358 )
11359 }
11360 }
11361 unsafe impl<
11362 T0: fidl::encoding::Encode<SingleBufferSettings, fdomain_client::fidl::FDomainResourceDialect>,
11363 T1: fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>,
11364 > fidl::encoding::Encode<SingleBufferInfo, fdomain_client::fidl::FDomainResourceDialect>
11365 for (T0, T1)
11366 {
11367 #[inline]
11368 unsafe fn encode(
11369 self,
11370 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11371 offset: usize,
11372 depth: fidl::encoding::Depth,
11373 ) -> fidl::Result<()> {
11374 encoder.debug_check_bounds::<SingleBufferInfo>(offset);
11375 // Zero out padding regions. There's no need to apply masks
11376 // because the unmasked parts will be overwritten by fields.
11377 // Write the fields.
11378 self.0.encode(encoder, offset + 0, depth)?;
11379 self.1.encode(encoder, offset + 264, depth)?;
11380 Ok(())
11381 }
11382 }
11383
11384 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11385 for SingleBufferInfo
11386 {
11387 #[inline(always)]
11388 fn new_empty() -> Self {
11389 Self {
11390 settings: fidl::new_empty!(
11391 SingleBufferSettings,
11392 fdomain_client::fidl::FDomainResourceDialect
11393 ),
11394 buffer: fidl::new_empty!(VmoBuffer, fdomain_client::fidl::FDomainResourceDialect),
11395 }
11396 }
11397
11398 #[inline]
11399 unsafe fn decode(
11400 &mut self,
11401 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11402 offset: usize,
11403 _depth: fidl::encoding::Depth,
11404 ) -> fidl::Result<()> {
11405 decoder.debug_check_bounds::<Self>(offset);
11406 // Verify that padding bytes are zero.
11407 fidl::decode!(
11408 SingleBufferSettings,
11409 fdomain_client::fidl::FDomainResourceDialect,
11410 &mut self.settings,
11411 decoder,
11412 offset + 0,
11413 _depth
11414 )?;
11415 fidl::decode!(
11416 VmoBuffer,
11417 fdomain_client::fidl::FDomainResourceDialect,
11418 &mut self.buffer,
11419 decoder,
11420 offset + 264,
11421 _depth
11422 )?;
11423 Ok(())
11424 }
11425 }
11426
11427 impl fidl::encoding::ResourceTypeMarker for VmoBuffer {
11428 type Borrowed<'a> = &'a mut Self;
11429 fn take_or_borrow<'a>(
11430 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11431 ) -> Self::Borrowed<'a> {
11432 value
11433 }
11434 }
11435
11436 unsafe impl fidl::encoding::TypeMarker for VmoBuffer {
11437 type Owned = Self;
11438
11439 #[inline(always)]
11440 fn inline_align(_context: fidl::encoding::Context) -> usize {
11441 8
11442 }
11443
11444 #[inline(always)]
11445 fn inline_size(_context: fidl::encoding::Context) -> usize {
11446 16
11447 }
11448 }
11449
11450 unsafe impl fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>
11451 for &mut VmoBuffer
11452 {
11453 #[inline]
11454 unsafe fn encode(
11455 self,
11456 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11457 offset: usize,
11458 _depth: fidl::encoding::Depth,
11459 ) -> fidl::Result<()> {
11460 encoder.debug_check_bounds::<VmoBuffer>(offset);
11461 // Delegate to tuple encoding.
11462 fidl::encoding::Encode::<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect>::encode(
11463 (
11464 <fidl::encoding::Optional<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
11465 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_usable_start),
11466 ),
11467 encoder, offset, _depth
11468 )
11469 }
11470 }
11471 unsafe impl<
11472 T0: fidl::encoding::Encode<
11473 fidl::encoding::Optional<
11474 fidl::encoding::HandleType<
11475 fdomain_client::Vmo,
11476 { fidl::ObjectType::VMO.into_raw() },
11477 2147483648,
11478 >,
11479 >,
11480 fdomain_client::fidl::FDomainResourceDialect,
11481 >,
11482 T1: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
11483 > fidl::encoding::Encode<VmoBuffer, fdomain_client::fidl::FDomainResourceDialect> for (T0, T1)
11484 {
11485 #[inline]
11486 unsafe fn encode(
11487 self,
11488 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11489 offset: usize,
11490 depth: fidl::encoding::Depth,
11491 ) -> fidl::Result<()> {
11492 encoder.debug_check_bounds::<VmoBuffer>(offset);
11493 // Zero out padding regions. There's no need to apply masks
11494 // because the unmasked parts will be overwritten by fields.
11495 unsafe {
11496 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
11497 (ptr as *mut u64).write_unaligned(0);
11498 }
11499 // Write the fields.
11500 self.0.encode(encoder, offset + 0, depth)?;
11501 self.1.encode(encoder, offset + 8, depth)?;
11502 Ok(())
11503 }
11504 }
11505
11506 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for VmoBuffer {
11507 #[inline(always)]
11508 fn new_empty() -> Self {
11509 Self {
11510 vmo: fidl::new_empty!(
11511 fidl::encoding::Optional<
11512 fidl::encoding::HandleType<
11513 fdomain_client::Vmo,
11514 { fidl::ObjectType::VMO.into_raw() },
11515 2147483648,
11516 >,
11517 >,
11518 fdomain_client::fidl::FDomainResourceDialect
11519 ),
11520 vmo_usable_start: fidl::new_empty!(
11521 u64,
11522 fdomain_client::fidl::FDomainResourceDialect
11523 ),
11524 }
11525 }
11526
11527 #[inline]
11528 unsafe fn decode(
11529 &mut self,
11530 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11531 offset: usize,
11532 _depth: fidl::encoding::Depth,
11533 ) -> fidl::Result<()> {
11534 decoder.debug_check_bounds::<Self>(offset);
11535 // Verify that padding bytes are zero.
11536 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
11537 let padval = unsafe { (ptr as *const u64).read_unaligned() };
11538 let mask = 0xffffffff00000000u64;
11539 let maskedval = padval & mask;
11540 if maskedval != 0 {
11541 return Err(fidl::Error::NonZeroPadding {
11542 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
11543 });
11544 }
11545 fidl::decode!(
11546 fidl::encoding::Optional<
11547 fidl::encoding::HandleType<
11548 fdomain_client::Vmo,
11549 { fidl::ObjectType::VMO.into_raw() },
11550 2147483648,
11551 >,
11552 >,
11553 fdomain_client::fidl::FDomainResourceDialect,
11554 &mut self.vmo,
11555 decoder,
11556 offset + 0,
11557 _depth
11558 )?;
11559 fidl::decode!(
11560 u64,
11561 fdomain_client::fidl::FDomainResourceDialect,
11562 &mut self.vmo_usable_start,
11563 decoder,
11564 offset + 8,
11565 _depth
11566 )?;
11567 Ok(())
11568 }
11569 }
11570
11571 impl BufferCollectionTokenGroupCreateChildRequest {
11572 #[inline(always)]
11573 fn max_ordinal_present(&self) -> u64 {
11574 if let Some(_) = self.rights_attenuation_mask {
11575 return 2;
11576 }
11577 if let Some(_) = self.token_request {
11578 return 1;
11579 }
11580 0
11581 }
11582 }
11583
11584 impl fidl::encoding::ResourceTypeMarker for BufferCollectionTokenGroupCreateChildRequest {
11585 type Borrowed<'a> = &'a mut Self;
11586 fn take_or_borrow<'a>(
11587 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11588 ) -> Self::Borrowed<'a> {
11589 value
11590 }
11591 }
11592
11593 unsafe impl fidl::encoding::TypeMarker for BufferCollectionTokenGroupCreateChildRequest {
11594 type Owned = Self;
11595
11596 #[inline(always)]
11597 fn inline_align(_context: fidl::encoding::Context) -> usize {
11598 8
11599 }
11600
11601 #[inline(always)]
11602 fn inline_size(_context: fidl::encoding::Context) -> usize {
11603 16
11604 }
11605 }
11606
11607 unsafe impl
11608 fidl::encoding::Encode<
11609 BufferCollectionTokenGroupCreateChildRequest,
11610 fdomain_client::fidl::FDomainResourceDialect,
11611 > for &mut BufferCollectionTokenGroupCreateChildRequest
11612 {
11613 unsafe fn encode(
11614 self,
11615 encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11616 offset: usize,
11617 mut depth: fidl::encoding::Depth,
11618 ) -> fidl::Result<()> {
11619 encoder.debug_check_bounds::<BufferCollectionTokenGroupCreateChildRequest>(offset);
11620 // Vector header
11621 let max_ordinal: u64 = self.max_ordinal_present();
11622 encoder.write_num(max_ordinal, offset);
11623 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11624 // Calling encoder.out_of_line_offset(0) is not allowed.
11625 if max_ordinal == 0 {
11626 return Ok(());
11627 }
11628 depth.increment()?;
11629 let envelope_size = 8;
11630 let bytes_len = max_ordinal as usize * envelope_size;
11631 #[allow(unused_variables)]
11632 let offset = encoder.out_of_line_offset(bytes_len);
11633 let mut _prev_end_offset: usize = 0;
11634 if 1 > max_ordinal {
11635 return Ok(());
11636 }
11637
11638 // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11639 // are envelope_size bytes.
11640 let cur_offset: usize = (1 - 1) * envelope_size;
11641
11642 // Zero reserved fields.
11643 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11644
11645 // Safety:
11646 // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11647 // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11648 // envelope_size bytes, there is always sufficient room.
11649 fidl::encoding::encode_in_envelope_optional::<
11650 fidl::encoding::Endpoint<
11651 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11652 >,
11653 fdomain_client::fidl::FDomainResourceDialect,
11654 >(
11655 self.token_request.as_mut().map(
11656 <fidl::encoding::Endpoint<
11657 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11658 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11659 ),
11660 encoder,
11661 offset + cur_offset,
11662 depth,
11663 )?;
11664
11665 _prev_end_offset = cur_offset + envelope_size;
11666 if 2 > max_ordinal {
11667 return Ok(());
11668 }
11669
11670 // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11671 // are envelope_size bytes.
11672 let cur_offset: usize = (2 - 1) * envelope_size;
11673
11674 // Zero reserved fields.
11675 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11676
11677 // Safety:
11678 // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11679 // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11680 // envelope_size bytes, there is always sufficient room.
11681 fidl::encoding::encode_in_envelope_optional::<
11682 u32,
11683 fdomain_client::fidl::FDomainResourceDialect,
11684 >(
11685 self.rights_attenuation_mask
11686 .as_ref()
11687 .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
11688 encoder,
11689 offset + cur_offset,
11690 depth,
11691 )?;
11692
11693 _prev_end_offset = cur_offset + envelope_size;
11694
11695 Ok(())
11696 }
11697 }
11698
11699 impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
11700 for BufferCollectionTokenGroupCreateChildRequest
11701 {
11702 #[inline(always)]
11703 fn new_empty() -> Self {
11704 Self::default()
11705 }
11706
11707 unsafe fn decode(
11708 &mut self,
11709 decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
11710 offset: usize,
11711 mut depth: fidl::encoding::Depth,
11712 ) -> fidl::Result<()> {
11713 decoder.debug_check_bounds::<Self>(offset);
11714 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11715 None => return Err(fidl::Error::NotNullable),
11716 Some(len) => len,
11717 };
11718 // Calling decoder.out_of_line_offset(0) is not allowed.
11719 if len == 0 {
11720 return Ok(());
11721 };
11722 depth.increment()?;
11723 let envelope_size = 8;
11724 let bytes_len = len * envelope_size;
11725 let offset = decoder.out_of_line_offset(bytes_len)?;
11726 // Decode the envelope for each type.
11727 let mut _next_ordinal_to_read = 0;
11728 let mut next_offset = offset;
11729 let end_offset = offset + bytes_len;
11730 _next_ordinal_to_read += 1;
11731 if next_offset >= end_offset {
11732 return Ok(());
11733 }
11734
11735 // Decode unknown envelopes for gaps in ordinals.
11736 while _next_ordinal_to_read < 1 {
11737 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11738 _next_ordinal_to_read += 1;
11739 next_offset += envelope_size;
11740 }
11741
11742 let next_out_of_line = decoder.next_out_of_line();
11743 let handles_before = decoder.remaining_handles();
11744 if let Some((inlined, num_bytes, num_handles)) =
11745 fidl::encoding::decode_envelope_header(decoder, next_offset)?
11746 {
11747 let member_inline_size = <fidl::encoding::Endpoint<
11748 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11749 > as fidl::encoding::TypeMarker>::inline_size(
11750 decoder.context
11751 );
11752 if inlined != (member_inline_size <= 4) {
11753 return Err(fidl::Error::InvalidInlineBitInEnvelope);
11754 }
11755 let inner_offset;
11756 let mut inner_depth = depth.clone();
11757 if inlined {
11758 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11759 inner_offset = next_offset;
11760 } else {
11761 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11762 inner_depth.increment()?;
11763 }
11764 let val_ref = self.token_request.get_or_insert_with(|| {
11765 fidl::new_empty!(
11766 fidl::encoding::Endpoint<
11767 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11768 >,
11769 fdomain_client::fidl::FDomainResourceDialect
11770 )
11771 });
11772 fidl::decode!(
11773 fidl::encoding::Endpoint<
11774 fdomain_client::fidl::ServerEnd<BufferCollectionTokenMarker>,
11775 >,
11776 fdomain_client::fidl::FDomainResourceDialect,
11777 val_ref,
11778 decoder,
11779 inner_offset,
11780 inner_depth
11781 )?;
11782 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11783 {
11784 return Err(fidl::Error::InvalidNumBytesInEnvelope);
11785 }
11786 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11787 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11788 }
11789 }
11790
11791 next_offset += envelope_size;
11792 _next_ordinal_to_read += 1;
11793 if next_offset >= end_offset {
11794 return Ok(());
11795 }
11796
11797 // Decode unknown envelopes for gaps in ordinals.
11798 while _next_ordinal_to_read < 2 {
11799 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11800 _next_ordinal_to_read += 1;
11801 next_offset += envelope_size;
11802 }
11803
11804 let next_out_of_line = decoder.next_out_of_line();
11805 let handles_before = decoder.remaining_handles();
11806 if let Some((inlined, num_bytes, num_handles)) =
11807 fidl::encoding::decode_envelope_header(decoder, next_offset)?
11808 {
11809 let member_inline_size =
11810 <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11811 if inlined != (member_inline_size <= 4) {
11812 return Err(fidl::Error::InvalidInlineBitInEnvelope);
11813 }
11814 let inner_offset;
11815 let mut inner_depth = depth.clone();
11816 if inlined {
11817 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11818 inner_offset = next_offset;
11819 } else {
11820 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11821 inner_depth.increment()?;
11822 }
11823 let val_ref = self.rights_attenuation_mask.get_or_insert_with(|| {
11824 fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
11825 });
11826 fidl::decode!(
11827 u32,
11828 fdomain_client::fidl::FDomainResourceDialect,
11829 val_ref,
11830 decoder,
11831 inner_offset,
11832 inner_depth
11833 )?;
11834 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11835 {
11836 return Err(fidl::Error::InvalidNumBytesInEnvelope);
11837 }
11838 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11839 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11840 }
11841 }
11842
11843 next_offset += envelope_size;
11844
11845 // Decode the remaining unknown envelopes.
11846 while next_offset < end_offset {
11847 _next_ordinal_to_read += 1;
11848 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11849 next_offset += envelope_size;
11850 }
11851
11852 Ok(())
11853 }
11854 }
11855}