Skip to main content

fdomain_fuchsia_media/
fdomain_fuchsia_media.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_media_common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct AudioCapturerBindGainControlRequest {
15    pub gain_control_request:
16        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
17}
18
19impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
20    for AudioCapturerBindGainControlRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct AudioCapturerGetReferenceClockResponse {
26    pub reference_clock: fdomain_client::Clock,
27}
28
29impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
30    for AudioCapturerGetReferenceClockResponse
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct AudioCapturerSetReferenceClockRequest {
36    pub reference_clock: Option<fdomain_client::Clock>,
37}
38
39impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
40    for AudioCapturerSetReferenceClockRequest
41{
42}
43
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct AudioConsumerBindVolumeControlRequest {
46    pub volume_control_request:
47        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
48}
49
50impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
51    for AudioConsumerBindVolumeControlRequest
52{
53}
54
55#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
56pub struct AudioConsumerCreateStreamSinkRequest {
57    pub buffers: Vec<fdomain_client::Vmo>,
58    pub stream_type: AudioStreamType,
59    pub compression: Option<Box<Compression>>,
60    pub stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
61}
62
63impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
64    for AudioConsumerCreateStreamSinkRequest
65{
66}
67
68#[derive(Debug, PartialEq)]
69pub struct AudioCoreBindUsageVolumeControl2Request {
70    pub usage: Usage2,
71    pub volume_control:
72        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
73}
74
75impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
76    for AudioCoreBindUsageVolumeControl2Request
77{
78}
79
80#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct AudioCoreBindUsageVolumeControlRequest {
82    pub usage: Usage,
83    pub volume_control:
84        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
85}
86
87impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
88    for AudioCoreBindUsageVolumeControlRequest
89{
90}
91
92#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
93pub struct AudioCoreCreateAudioCapturerRequest {
94    pub loopback: bool,
95    pub audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
96}
97
98impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
99    for AudioCoreCreateAudioCapturerRequest
100{
101}
102
103#[derive(Debug, PartialEq)]
104pub struct AudioCoreCreateAudioCapturerWithConfigurationRequest {
105    pub stream_type: AudioStreamType,
106    pub configuration: AudioCapturerConfiguration,
107    pub audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
108}
109
110impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
111    for AudioCoreCreateAudioCapturerWithConfigurationRequest
112{
113}
114
115#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
116pub struct AudioCoreCreateAudioRendererRequest {
117    pub audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
118}
119
120impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
121    for AudioCoreCreateAudioRendererRequest
122{
123}
124
125#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
126pub struct AudioCreateAudioCapturerRequest {
127    pub audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
128    pub loopback: bool,
129}
130
131impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
132    for AudioCreateAudioCapturerRequest
133{
134}
135
136#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
137pub struct AudioCreateAudioRendererRequest {
138    pub audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
139}
140
141impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
142    for AudioCreateAudioRendererRequest
143{
144}
145
146#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
147pub struct AudioDeviceEnumeratorAddDeviceByChannelRequest {
148    pub device_name: String,
149    pub is_input: bool,
150    pub channel:
151        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
152}
153
154impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
155    for AudioDeviceEnumeratorAddDeviceByChannelRequest
156{
157}
158
159#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
160pub struct AudioRendererBindGainControlRequest {
161    pub gain_control_request:
162        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
163}
164
165impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
166    for AudioRendererBindGainControlRequest
167{
168}
169
170#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
171pub struct AudioRendererGetReferenceClockResponse {
172    pub reference_clock: fdomain_client::Clock,
173}
174
175impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
176    for AudioRendererGetReferenceClockResponse
177{
178}
179
180#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
181pub struct AudioRendererSetReferenceClockRequest {
182    pub reference_clock: Option<fdomain_client::Clock>,
183}
184
185impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
186    for AudioRendererSetReferenceClockRequest
187{
188}
189
190#[derive(Debug, PartialEq, PartialOrd)]
191pub struct ProfileProviderRegisterHandlerWithCapacityRequest {
192    pub thread_handle: fdomain_client::Thread,
193    pub name: String,
194    pub period: i64,
195    pub capacity: f32,
196}
197
198impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
199    for ProfileProviderRegisterHandlerWithCapacityRequest
200{
201}
202
203#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
204pub struct ProfileProviderRegisterMemoryRangeRequest {
205    pub vmar_handle: fdomain_client::Vmar,
206    pub name: String,
207}
208
209impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
210    for ProfileProviderRegisterMemoryRangeRequest
211{
212}
213
214#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
215pub struct ProfileProviderUnregisterHandlerRequest {
216    pub thread_handle: fdomain_client::Thread,
217    pub name: String,
218}
219
220impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
221    for ProfileProviderUnregisterHandlerRequest
222{
223}
224
225#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
226pub struct ProfileProviderUnregisterMemoryRangeRequest {
227    pub vmar_handle: fdomain_client::Vmar,
228}
229
230impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
231    for ProfileProviderUnregisterMemoryRangeRequest
232{
233}
234
235#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
236pub struct SessionAudioConsumerFactoryCreateAudioConsumerRequest {
237    pub session_id: u64,
238    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
239}
240
241impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
242    for SessionAudioConsumerFactoryCreateAudioConsumerRequest
243{
244}
245
246#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
247pub struct StreamBufferSetAddPayloadBufferRequest {
248    pub id: u32,
249    pub payload_buffer: fdomain_client::Vmo,
250}
251
252impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
253    for StreamBufferSetAddPayloadBufferRequest
254{
255}
256
257#[derive(Debug, PartialEq)]
258pub struct StreamProcessorSetInputBufferPartialSettingsRequest {
259    pub input_settings: StreamBufferPartialSettings,
260}
261
262impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
263    for StreamProcessorSetInputBufferPartialSettingsRequest
264{
265}
266
267#[derive(Debug, PartialEq)]
268pub struct StreamProcessorSetOutputBufferPartialSettingsRequest {
269    pub output_settings: StreamBufferPartialSettings,
270}
271
272impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
273    for StreamProcessorSetOutputBufferPartialSettingsRequest
274{
275}
276
277#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
278pub struct Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
279    pub usage: AudioRenderUsage2,
280    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
281}
282
283impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
284    for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
285{
286}
287
288#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
289pub struct UsageAudioConsumerFactoryCreateAudioConsumerRequest {
290    pub usage: AudioRenderUsage,
291    pub audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
292}
293
294impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
295    for UsageAudioConsumerFactoryCreateAudioConsumerRequest
296{
297}
298
299#[derive(Debug, PartialEq)]
300pub struct UsageGainReporterRegisterListener2Request {
301    pub device_unique_id: String,
302    pub usage: Usage2,
303    pub usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
304}
305
306impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
307    for UsageGainReporterRegisterListener2Request
308{
309}
310
311#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
312pub struct UsageGainReporterRegisterListenerRequest {
313    pub device_unique_id: String,
314    pub usage: Usage,
315    pub usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
316}
317
318impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
319    for UsageGainReporterRegisterListenerRequest
320{
321}
322
323#[derive(Debug, PartialEq)]
324pub struct UsageReporterWatch2Request {
325    pub usage: Usage2,
326    pub usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
327}
328
329impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for UsageReporterWatch2Request {}
330
331#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
332pub struct UsageReporterWatchRequest {
333    pub usage: Usage,
334    pub usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
335}
336
337impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for UsageReporterWatchRequest {}
338
339#[derive(Debug, Default, PartialEq)]
340pub struct StreamBufferPartialSettings {
341    /// Each buffer is associated with a `buffer_lifetime_ordinal` value.
342    ///
343    /// There is a separate buffer_lifetime_ordinal for input vs. output.
344    ///
345    /// Values must be odd. Values must only increase (increasing by more than 2
346    /// is permitted).
347    ///
348    /// When using `SetInputBufferPartialSettings` or
349    /// `SetOutputBufferPartialSettings`, re-use of the same value (considering
350    /// input and output separately) for the new message is not allowed. Using
351    /// these messages, all the buffers of a given buffer_lifetime_ordinal value
352    /// are allocated as one sysmem buffer collection.
353    ///
354    /// When a new buffer_lifetime_ordinal starts, that also automatically
355    /// starts un-registering and releasing any buffers associated with prior
356    /// buffer_lifetime_ordinal values, but does not force them to complete
357    /// un-registration (or release) if they're still used by the codec for
358    /// reference purposes (VP9 can do this across a mid-stream dimensions
359    /// switch). A buffer can still be output by the server (as indicated by an
360    /// output packet) until un-registration completes.
361    ///
362    /// If the client wants the server to drop all buffers quickly, the client
363    /// can send `CloseCurrentStream` with `release_input_buffers` and/or
364    /// `release_output_buffers` set. This of course also stops decode of the
365    /// current stream. Closing the `StreamProcessor` client end is another
366    /// option.
367    pub buffer_lifetime_ordinal: Option<u64>,
368    /// This value indicates which version of constraints the client is/was
369    /// aware of so far.
370    ///
371    /// For input, this must always be 0 because constraints don't change for
372    /// input (settings can change, but there's no settings vs current
373    /// constraints synchronization issue on input).
374    ///
375    /// For output, this allows the server to know when the client is
376    /// sufficiently caught up before the server will generate any more output.
377    ///
378    /// When there is no active stream, a client is permitted to re-configure
379    /// buffers again using the same buffer_constraints_version_ordinal.
380    pub buffer_constraints_version_ordinal: Option<u64>,
381    pub single_buffer_mode: Option<bool>,
382    pub packet_count_for_server: Option<u32>,
383    pub packet_count_for_client: Option<u32>,
384    pub sysmem_token: Option<
385        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem::BufferCollectionTokenMarker>,
386    >,
387    /// The client end of a BufferCollectionToken channel, which the
388    /// StreamProcessor will use to deliver constraints to sysmem and learn of
389    /// buffers allocated by sysmem.
390    ///
391    /// The client guarantees that the token is already known to sysmem (via
392    /// BufferCollectionToken.Sync(), BufferCollection.Sync(), or
393    /// BufferCollectionEvents.OnDuplicatedTokensKnownByServer()).
394    pub sysmem2_token: Option<
395        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
396    >,
397    #[doc(hidden)]
398    pub __source_breaking: fidl::marker::SourceBreaking,
399}
400
401impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
402    for StreamBufferPartialSettings
403{
404}
405
406#[derive(Debug, Default, PartialEq)]
407pub struct StreamProcessorAddBufferRequest {
408    /// Must be set. Which port (input or output) the buffer is for.
409    pub port: Option<Port>,
410    /// Typically this is the latest buffer_constraints_version_ordinal
411    /// known to the client based on OnInputConstraints/OnOutputConstraints.
412    /// Older values are not harmful to correctness.
413    ///
414    /// The server will ignore this message if the server has already
415    /// created a later buffer_constraints_version_ordinal value that has
416    /// action_required true. If the server ignores this message, a later
417    /// RemoveBuffer for this buffer will complete quickly and without
418    /// creating an error.
419    ///
420    /// A client is not required to ensure that every call to AddBuffer with
421    /// the same buffer_lifetime_ordinal uses the same
422    /// buffer_constraints_version_ordinal, but the client must ensure that
423    /// all buffer_constraints_version_ordinal values which share the same
424    /// buffer_lifetime_ordinal are within the same action_required true
425    /// interval. Each such interval starts with a value that has
426    /// action_required true, and lasts until but not including the next
427    /// value with action_required true, or until the current value if there
428    /// is not yet a next value with action_required true. If this would
429    /// create a problem for a server, that server should set
430    /// action_required true instead of false.
431    pub buffer_constraints_version_ordinal: Option<u64>,
432    /// These values are scoped to input/output separately.
433    ///
434    /// The first message from the client with a new (higher)
435    /// buffer_lifetime_ordinal value begins removing all buffers on the
436    /// same port with lower buffer_lifetime_ordinal. However, until removal
437    /// is complete, the older buffers can still be used by the codec.
438    ///
439    /// The AddBuffer message adds the buffer to this
440    /// buffer_lifetime_ordinal.
441    pub buffer_lifetime_ordinal: Option<u64>,
442    /// The buffer_index values under a buffer_lifetime_ordinal must be
443    /// unique among all added but not yet fully removed buffers. This value
444    /// is initially allocated/specified by the client using this field, and
445    /// then both the client and the server will then refer to a this added
446    /// buffer uniquely using input vs output, buffer_lifetime_ordinal, and
447    /// the buffer_index (all three parts are needed to unambiguously
448    /// specify this buffer).
449    ///
450    /// See RemoveBuffer doc comments for how to safely remove a buffer and
451    /// potentially re-use a buffer_index value.
452    ///
453    /// In contrast to using
454    /// SetInputBufferPartialSettings/SetOutputBufferPartialSettings, when
455    /// using AddBuffer and RemoveBuffer, the StreamProcessor buffer_index
456    /// value has no relation to the sysmem buffer_index (under the sysmem
457    /// buffer_collection_id). Instead, the StreamProcessor buffer_index is
458    /// specified by this field, not by using sysmem's buffer_index. This
459    /// way, two buffers from two sysmem collections having the same sysmem
460    /// buffer_index (under separate buffer_collection_id(s)) can be
461    /// specified unambiguously in StreamProcessor messages.
462    pub buffer_index: Option<u32>,
463    /// This is a VMO handle that the server can use to access the sysmem
464    /// buffer.
465    ///
466    /// This VMO is required to have been provided by sysmem, and required
467    /// to be compatible with the server's sysmem constraints.
468    ///
469    /// The buffer_constraints_version_ordinal check occurs first, and
470    /// failure of that check just silently ignores the remainder of this
471    /// message without checking the buffer field (buffer is just dropped).
472    ///
473    /// If the buffer_constraints_version_ordinal check passes, but `buffer`
474    /// isn't a sysmem-provided VMO or isn't consistent with the server's
475    /// sysmem constraints, the server will close the StreamProcessor
476    /// server_end. The client can avoid triggering this failure case by
477    /// allocating the buffers per the following.
478    ///
479    /// For video decoder input buffers, the client can allocate the buffer
480    /// using sysmem, with participation of this or another instance of the
481    /// same codec implementation, using ParticipateInBufferAllocation with
482    /// Port.INPUT. The same StreamProcessor instance isn't required
483    /// in this case, only the same codec implementation. If using a
484    /// different StreamProcessor instance (but still from the same codec
485    /// implementation), the client should take care to create the two
486    /// StreamProcessor instances with the same requirements specified to
487    /// CodecFactory (for example with secure_input_mode and
488    /// secure_output_mode set the same way). Video decoder server
489    /// implementations with supports_dynamic_buffers true are required to
490    /// support allocating input buffers using one StreamProcessor instance
491    /// then using them with a different StreamProcessor instance (in
492    /// contrast, for output buffers, this is not required).
493    ///
494    /// For video decoder output buffers, this can be achieved by allocating
495    /// the buffer using sysmem, with participation of the same
496    /// StreamProcessor instance, using ParticipateInBufferAllocation with
497    /// Port.OUTPUT.
498    ///
499    /// Servers should verify that this VMO is (a) provided by sysmem, and
500    /// (b) meets the server's current sysmem constraints. The server can
501    /// verify both (a) and (b) by checking the result of sysmem's
502    /// CheckVmoConstraints before using this VMO. If that check fails, the
503    /// server can close the StreamProcessor server_end.
504    pub buffer: Option<fdomain_client::Vmo>,
505    #[doc(hidden)]
506    pub __source_breaking: fidl::marker::SourceBreaking,
507}
508
509impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
510    for StreamProcessorAddBufferRequest
511{
512}
513
514#[derive(Debug, Default, PartialEq)]
515pub struct StreamProcessorParticipateInBufferAllocationRequest {
516    /// Which port (input or output) the buffer(s) are for.
517    ///
518    /// Must be set.
519    pub port: Option<Port>,
520    /// For input, this field must be set to 1, at least for now.
521    ///
522    /// For output, this field must set to the latest known (to the client)
523    /// buffer_constraints_version_ordinal value from the server. If the
524    /// value is less than the latest buffer_constraints_version_ordinal
525    /// created by the server which had action_reqiured true, then the
526    /// server will set generic sysmem constraints (just min_buffer_count 1)
527    /// and otherwise ignore this message. This is intended to allow
528    /// allocation to succeed (to allow simpler client error handling for
529    /// some clients); in this case a new buffer_constraints_version_ordinal
530    /// will reach the client and the client can catch up to the latest.
531    ///
532    /// If this value is a future value, the server will drop the
533    /// sysmem2_token which will cause allocation failure.
534    ///
535    /// Must be set.
536    pub buffer_constraints_version_ordinal: Option<u64>,
537    /// This sysmem token is used by the server to inform sysmem directly of
538    /// any applicable buffer constraints. These constraints are allowed to
539    /// (and in some cases must) depend on how this StreamProcessor instance
540    /// was created. For example, secure_input_mode/secure_output_mode
541    /// during StreamProcessor creation causes the server to set
542    /// secure_required for input/output respectively (as specified by
543    /// Port.INPUT or Port.OUTPUT respectively).
544    ///
545    /// Must be set.
546    pub sysmem2_token: Option<
547        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker>,
548    >,
549    /// If set, and there's been at least one AddBuffer previously sent with
550    /// this buffer_lifetime_ordinal on the same StreamProcessor instance
551    /// which hasn't yet been removed server-side, the new buffer(s) will be
552    /// allocated with identical SingleBufferSettings, or fail allocation.
553    /// If any of the conditions in this paragraph aren't met, the effect is
554    /// the same as if this field is not set.
555    ///
556    /// If this field is not set, the sysmem constraints set by the server
557    /// will be suitable for a buffer of a new buffer_lifetime_ordinal, and
558    /// the new buffer's SingleBufferSettings might not match any previous
559    /// buffer's SingleBufferSettings.
560    ///
561    /// If the server has a current stream and `port` indicates the output
562    /// port, the constraints set will allow the stream to be correctly
563    /// processed across the switch to new buffer_lifetime_ordinal (assuming
564    /// the client is using a new buffer_lifetime_ordinal and adds the new
565    /// buffer(s) subsequently etc). If port indicates the input port, the
566    /// constraints set will be generic for the input port regardless of any
567    /// current stream.
568    ///
569    /// If this mechanism isn't used, the client must still ensure that all
570    /// AddBuffer with a given StreamProcessor instance, port, and
571    /// buffer_lifetime_ordinal have identical SingleBufferSettings. One way
572    /// to do this is to allocate all the buffers of a
573    /// buffer_lifetime_ordinal under a single sysmem buffer collection.
574    /// Another way is for the client to tell sysmem directly that a new
575    /// buffer collection must match the SingleBufferSettings of a prior
576    /// collection using
577    /// `[fuchsia.sysmem2/BufferCollectionConstraints.must_match_vmo]`
578    /// client-side.
579    ///
580    /// It's not recommended for a client to attempt to force a new
581    /// collecton's SingleBufferSettings to match an old collection's
582    /// SingleBufferSettings without sysmem's help and without
583    /// StreamProcessor's help via this field, because sysmem intentionally
584    /// allows clients participating in the same collection to be using
585    /// different versions of the sysmem interfaces, so the client may not
586    /// have enough information to successfully force the
587    /// SingleBufferSettings to match without using `must_match_vmo`, for
588    /// example if the client is unaware of a new SingleBufferSettings field
589    /// (or similar). The most common StreamProcessor server implementation
590    /// (CodecImpl) will handle this field using `must_match_vmo` on behalf
591    /// of the client as long as there's still at least one buffer of the
592    /// buffer_lifetime_ordinal active in the server. The ability to
593    /// dynamically add more buffers to an existing sysmem collection may be
594    /// added to sysmem at some point; that would give the client another
595    /// way to ensure identical SingleBufferSettings within a
596    /// buffer_lifetime_ordinal, but only if/when all sysmem collection
597    /// participants indicate support for a dynamic sysmem buffer
598    /// collection.
599    ///
600    /// For output, setting this field is strongly recommended if a client
601    /// is adding additional output buffers to an existing
602    /// buffer_lifetime_ordinal using a new/different sysmem buffer
603    /// collection, and setting this field is recommended for all output
604    /// buffer allocations.
605    ///
606    /// For input, if a client is using the same StreamProcessor instance
607    /// for this message and AddBuffer (which is itself recommended when
608    /// feasible), use of this field is recommended for those input buffers.
609    ///
610    /// If set, this value must match the buffer_lifetime_ordinal later sent
611    /// in AddBuffer.
612    ///
613    /// Clients should set this when feasible; see above.
614    pub buffer_lifetime_ordinal: Option<u64>,
615    /// If set to true, the server will leave all `buffer_count_*` fields
616    /// un-set when sending SetConstraints to sysmem, and will set
617    /// `min_buffer_count` to 1.
618    ///
619    /// If un-set or set to false, the server will fill out buffer count
620    /// fields when sending SetConstraints to sysmem based on the current
621    /// value of `buffer_count_for_server_current`, without any extra slack.
622    /// The client can add slack as desired via its own retained token.
623    ///
624    /// Regardless of whether this field is set to true, it's up to the
625    /// client to `AddBuffer` at least `buffer_count_for_server_current`
626    /// buffers so that processing can make progress.
627    pub allow_single_buffer: Option<bool>,
628    #[doc(hidden)]
629    pub __source_breaking: fidl::marker::SourceBreaking,
630}
631
632impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
633    for StreamProcessorParticipateInBufferAllocationRequest
634{
635}
636
637#[derive(Debug, Default, PartialEq)]
638pub struct StreamProcessorRemoveBufferRequest {
639    /// Must be set. Which port (input or output) the buffer is for.
640    pub port: Option<Port>,
641    /// Scoped to input or output, this is the buffer_lifetime_ordinal under
642    /// which the buffer_index is meaningful.
643    pub buffer_lifetime_ordinal: Option<u64>,
644    /// The buffer_index of the buffer previously established (and most
645    /// recently established) by AddBuffer, or by
646    /// SetInputBufferPartialSettings / SetOutputBufferPartialSettings. The
647    /// scope of this value is under input vs. output and under the
648    /// buffer_lifetime_ordinal value.
649    ///
650    /// When using dynamic buffers, the buffer_index values that are between
651    /// AddBuffer starting and RemoveBuffer completing (the active
652    /// buffer_index values) must be unique for a given Port value and
653    /// buffer_lifetime_ordinal value.
654    ///
655    /// Clients using dynamic buffers may wish to not re-use a buffer_index
656    /// value quickly upon completion of RemoveBuffer just to make
657    /// debugging/diagnosing easier, but technically re-use of buffer_index
658    /// in a subsequent AddBuffer is permitted as soon as RemoveBuffer
659    /// completes (from the StreamProcessor point of view - the client may
660    /// have its own reasons to not re-use that quickly). AddBuffer under an
661    /// old (not current) buffer_lifetime_ordinal is never allowed.
662    pub buffer_index: Option<u32>,
663    #[doc(hidden)]
664    pub __source_breaking: fidl::marker::SourceBreaking,
665}
666
667impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
668    for StreamProcessorRemoveBufferRequest
669{
670}
671
672#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
673pub struct ActivityReporterMarker;
674
675impl fdomain_client::fidl::ProtocolMarker for ActivityReporterMarker {
676    type Proxy = ActivityReporterProxy;
677    type RequestStream = ActivityReporterRequestStream;
678
679    const DEBUG_NAME: &'static str = "fuchsia.media.ActivityReporter";
680}
681impl fdomain_client::fidl::DiscoverableProtocolMarker for ActivityReporterMarker {}
682
683pub trait ActivityReporterProxyInterface: Send + Sync {
684    type WatchRenderActivityResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage>, fidl::Error>>
685        + Send;
686    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut;
687    type WatchRenderActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioRenderUsage2>, fidl::Error>>
688        + Send;
689    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut;
690    type WatchCaptureActivityResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage>, fidl::Error>>
691        + Send;
692    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut;
693    type WatchCaptureActivity2ResponseFut: std::future::Future<Output = Result<Vec<AudioCaptureUsage2>, fidl::Error>>
694        + Send;
695    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut;
696}
697
698#[derive(Debug, Clone)]
699pub struct ActivityReporterProxy {
700    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
701}
702
703impl fdomain_client::fidl::Proxy for ActivityReporterProxy {
704    type Protocol = ActivityReporterMarker;
705
706    fn from_channel(inner: fdomain_client::Channel) -> Self {
707        Self::new(inner)
708    }
709
710    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
711        self.client.into_channel().map_err(|client| Self { client })
712    }
713
714    fn as_channel(&self) -> &fdomain_client::Channel {
715        self.client.as_channel()
716    }
717}
718
719impl ActivityReporterProxy {
720    /// Create a new Proxy for fuchsia.media/ActivityReporter.
721    pub fn new(channel: fdomain_client::Channel) -> Self {
722        let protocol_name =
723            <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
724        Self { client: fidl::client::Client::new(channel, protocol_name) }
725    }
726
727    /// Get a Stream of events from the remote end of the protocol.
728    ///
729    /// # Panics
730    ///
731    /// Panics if the event stream was already taken.
732    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
733        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
734    }
735
736    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
737    /// It returns immediately the first time that it is called.
738    pub fn r#watch_render_activity(
739        &self,
740    ) -> fidl::client::QueryResponseFut<
741        Vec<AudioRenderUsage>,
742        fdomain_client::fidl::FDomainResourceDialect,
743    > {
744        ActivityReporterProxyInterface::r#watch_render_activity(self)
745    }
746
747    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
748    /// It returns immediately the first time that it is called.
749    pub fn r#watch_render_activity2(
750        &self,
751    ) -> fidl::client::QueryResponseFut<
752        Vec<AudioRenderUsage2>,
753        fdomain_client::fidl::FDomainResourceDialect,
754    > {
755        ActivityReporterProxyInterface::r#watch_render_activity2(self)
756    }
757
758    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
759    /// It returns immediately the first time that it is called.
760    pub fn r#watch_capture_activity(
761        &self,
762    ) -> fidl::client::QueryResponseFut<
763        Vec<AudioCaptureUsage>,
764        fdomain_client::fidl::FDomainResourceDialect,
765    > {
766        ActivityReporterProxyInterface::r#watch_capture_activity(self)
767    }
768
769    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
770    /// It returns immediately the first time that it is called.
771    pub fn r#watch_capture_activity2(
772        &self,
773    ) -> fidl::client::QueryResponseFut<
774        Vec<AudioCaptureUsage2>,
775        fdomain_client::fidl::FDomainResourceDialect,
776    > {
777        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
778    }
779}
780
781impl ActivityReporterProxyInterface for ActivityReporterProxy {
782    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
783        Vec<AudioRenderUsage>,
784        fdomain_client::fidl::FDomainResourceDialect,
785    >;
786    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
787        fn _decode(
788            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
789        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
790            let _response = fidl::client::decode_transaction_body::<
791                ActivityReporterWatchRenderActivityResponse,
792                fdomain_client::fidl::FDomainResourceDialect,
793                0x2974e9f5880b2f1f,
794            >(_buf?)?;
795            Ok(_response.active_usages)
796        }
797        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
798            (),
799            0x2974e9f5880b2f1f,
800            fidl::encoding::DynamicFlags::empty(),
801            _decode,
802        )
803    }
804
805    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
806        Vec<AudioRenderUsage2>,
807        fdomain_client::fidl::FDomainResourceDialect,
808    >;
809    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
810        fn _decode(
811            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
812        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
813            let _response = fidl::client::decode_transaction_body::<
814                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
815                fdomain_client::fidl::FDomainResourceDialect,
816                0x484236fc11b363e6,
817            >(_buf?)?
818            .into_result_fdomain::<ActivityReporterMarker>("watch_render_activity2")?;
819            Ok(_response.active_usages)
820        }
821        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
822            (),
823            0x484236fc11b363e6,
824            fidl::encoding::DynamicFlags::FLEXIBLE,
825            _decode,
826        )
827    }
828
829    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
830        Vec<AudioCaptureUsage>,
831        fdomain_client::fidl::FDomainResourceDialect,
832    >;
833    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
834        fn _decode(
835            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
836        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
837            let _response = fidl::client::decode_transaction_body::<
838                ActivityReporterWatchCaptureActivityResponse,
839                fdomain_client::fidl::FDomainResourceDialect,
840                0x70e7038e9658e128,
841            >(_buf?)?;
842            Ok(_response.active_usages)
843        }
844        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
845            (),
846            0x70e7038e9658e128,
847            fidl::encoding::DynamicFlags::empty(),
848            _decode,
849        )
850    }
851
852    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
853        Vec<AudioCaptureUsage2>,
854        fdomain_client::fidl::FDomainResourceDialect,
855    >;
856    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
857        fn _decode(
858            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
859        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
860            let _response = fidl::client::decode_transaction_body::<
861                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
862                fdomain_client::fidl::FDomainResourceDialect,
863                0x3d137e0364f9d550,
864            >(_buf?)?
865            .into_result_fdomain::<ActivityReporterMarker>("watch_capture_activity2")?;
866            Ok(_response.active_usages)
867        }
868        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
869            (),
870            0x3d137e0364f9d550,
871            fidl::encoding::DynamicFlags::FLEXIBLE,
872            _decode,
873        )
874    }
875}
876
877pub struct ActivityReporterEventStream {
878    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
879}
880
881impl std::marker::Unpin for ActivityReporterEventStream {}
882
883impl futures::stream::FusedStream for ActivityReporterEventStream {
884    fn is_terminated(&self) -> bool {
885        self.event_receiver.is_terminated()
886    }
887}
888
889impl futures::Stream for ActivityReporterEventStream {
890    type Item = Result<ActivityReporterEvent, fidl::Error>;
891
892    fn poll_next(
893        mut self: std::pin::Pin<&mut Self>,
894        cx: &mut std::task::Context<'_>,
895    ) -> std::task::Poll<Option<Self::Item>> {
896        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
897            &mut self.event_receiver,
898            cx
899        )?) {
900            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
901            None => std::task::Poll::Ready(None),
902        }
903    }
904}
905
906#[derive(Debug)]
907pub enum ActivityReporterEvent {
908    #[non_exhaustive]
909    _UnknownEvent {
910        /// Ordinal of the event that was sent.
911        ordinal: u64,
912    },
913}
914
915impl ActivityReporterEvent {
916    /// Decodes a message buffer as a [`ActivityReporterEvent`].
917    fn decode(
918        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
919    ) -> Result<ActivityReporterEvent, fidl::Error> {
920        let (bytes, _handles) = buf.split_mut();
921        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
922        debug_assert_eq!(tx_header.tx_id, 0);
923        match tx_header.ordinal {
924            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
925                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
926            }
927            _ => Err(fidl::Error::UnknownOrdinal {
928                ordinal: tx_header.ordinal,
929                protocol_name:
930                    <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
931            }),
932        }
933    }
934}
935
936/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
937pub struct ActivityReporterRequestStream {
938    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
939    is_terminated: bool,
940}
941
942impl std::marker::Unpin for ActivityReporterRequestStream {}
943
944impl futures::stream::FusedStream for ActivityReporterRequestStream {
945    fn is_terminated(&self) -> bool {
946        self.is_terminated
947    }
948}
949
950impl fdomain_client::fidl::RequestStream for ActivityReporterRequestStream {
951    type Protocol = ActivityReporterMarker;
952    type ControlHandle = ActivityReporterControlHandle;
953
954    fn from_channel(channel: fdomain_client::Channel) -> Self {
955        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
956    }
957
958    fn control_handle(&self) -> Self::ControlHandle {
959        ActivityReporterControlHandle { inner: self.inner.clone() }
960    }
961
962    fn into_inner(
963        self,
964    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
965    {
966        (self.inner, self.is_terminated)
967    }
968
969    fn from_inner(
970        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
971        is_terminated: bool,
972    ) -> Self {
973        Self { inner, is_terminated }
974    }
975}
976
977impl futures::Stream for ActivityReporterRequestStream {
978    type Item = Result<ActivityReporterRequest, fidl::Error>;
979
980    fn poll_next(
981        mut self: std::pin::Pin<&mut Self>,
982        cx: &mut std::task::Context<'_>,
983    ) -> std::task::Poll<Option<Self::Item>> {
984        let this = &mut *self;
985        if this.inner.check_shutdown(cx) {
986            this.is_terminated = true;
987            return std::task::Poll::Ready(None);
988        }
989        if this.is_terminated {
990            panic!("polled ActivityReporterRequestStream after completion");
991        }
992        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
993            |bytes, handles| {
994                match this.inner.channel().read_etc(cx, bytes, handles) {
995                    std::task::Poll::Ready(Ok(())) => {}
996                    std::task::Poll::Pending => return std::task::Poll::Pending,
997                    std::task::Poll::Ready(Err(None)) => {
998                        this.is_terminated = true;
999                        return std::task::Poll::Ready(None);
1000                    }
1001                    std::task::Poll::Ready(Err(Some(e))) => {
1002                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1003                            e.into(),
1004                        ))));
1005                    }
1006                }
1007
1008                // A message has been received from the channel
1009                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1010
1011                std::task::Poll::Ready(Some(match header.ordinal {
1012                0x2974e9f5880b2f1f => {
1013                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1014                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1015                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1016                    let control_handle = ActivityReporterControlHandle {
1017                        inner: this.inner.clone(),
1018                    };
1019                    Ok(ActivityReporterRequest::WatchRenderActivity {
1020                        responder: ActivityReporterWatchRenderActivityResponder {
1021                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1022                            tx_id: header.tx_id,
1023                        },
1024                    })
1025                }
1026                0x484236fc11b363e6 => {
1027                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1028                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1029                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1030                    let control_handle = ActivityReporterControlHandle {
1031                        inner: this.inner.clone(),
1032                    };
1033                    Ok(ActivityReporterRequest::WatchRenderActivity2 {
1034                        responder: ActivityReporterWatchRenderActivity2Responder {
1035                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1036                            tx_id: header.tx_id,
1037                        },
1038                    })
1039                }
1040                0x70e7038e9658e128 => {
1041                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1042                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1043                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1044                    let control_handle = ActivityReporterControlHandle {
1045                        inner: this.inner.clone(),
1046                    };
1047                    Ok(ActivityReporterRequest::WatchCaptureActivity {
1048                        responder: ActivityReporterWatchCaptureActivityResponder {
1049                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1050                            tx_id: header.tx_id,
1051                        },
1052                    })
1053                }
1054                0x3d137e0364f9d550 => {
1055                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1056                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
1057                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1058                    let control_handle = ActivityReporterControlHandle {
1059                        inner: this.inner.clone(),
1060                    };
1061                    Ok(ActivityReporterRequest::WatchCaptureActivity2 {
1062                        responder: ActivityReporterWatchCaptureActivity2Responder {
1063                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1064                            tx_id: header.tx_id,
1065                        },
1066                    })
1067                }
1068                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1069                    Ok(ActivityReporterRequest::_UnknownMethod {
1070                        ordinal: header.ordinal,
1071                        control_handle: ActivityReporterControlHandle { inner: this.inner.clone() },
1072                        method_type: fidl::MethodType::OneWay,
1073                    })
1074                }
1075                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1076                    this.inner.send_framework_err(
1077                        fidl::encoding::FrameworkErr::UnknownMethod,
1078                        header.tx_id,
1079                        header.ordinal,
1080                        header.dynamic_flags(),
1081                        (bytes, handles),
1082                    )?;
1083                    Ok(ActivityReporterRequest::_UnknownMethod {
1084                        ordinal: header.ordinal,
1085                        control_handle: ActivityReporterControlHandle { inner: this.inner.clone() },
1086                        method_type: fidl::MethodType::TwoWay,
1087                    })
1088                }
1089                _ => Err(fidl::Error::UnknownOrdinal {
1090                    ordinal: header.ordinal,
1091                    protocol_name: <ActivityReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1092                }),
1093            }))
1094            },
1095        )
1096    }
1097}
1098
1099/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
1100#[derive(Debug)]
1101pub enum ActivityReporterRequest {
1102    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1103    /// It returns immediately the first time that it is called.
1104    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
1105    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1106    /// It returns immediately the first time that it is called.
1107    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
1108    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1109    /// It returns immediately the first time that it is called.
1110    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
1111    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1112    /// It returns immediately the first time that it is called.
1113    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
1114    /// An interaction was received which does not match any known method.
1115    #[non_exhaustive]
1116    _UnknownMethod {
1117        /// Ordinal of the method that was called.
1118        ordinal: u64,
1119        control_handle: ActivityReporterControlHandle,
1120        method_type: fidl::MethodType,
1121    },
1122}
1123
1124impl ActivityReporterRequest {
1125    #[allow(irrefutable_let_patterns)]
1126    pub fn into_watch_render_activity(
1127        self,
1128    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
1129        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
1130            Some((responder))
1131        } else {
1132            None
1133        }
1134    }
1135
1136    #[allow(irrefutable_let_patterns)]
1137    pub fn into_watch_render_activity2(
1138        self,
1139    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
1140        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
1141            Some((responder))
1142        } else {
1143            None
1144        }
1145    }
1146
1147    #[allow(irrefutable_let_patterns)]
1148    pub fn into_watch_capture_activity(
1149        self,
1150    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
1151        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
1152            Some((responder))
1153        } else {
1154            None
1155        }
1156    }
1157
1158    #[allow(irrefutable_let_patterns)]
1159    pub fn into_watch_capture_activity2(
1160        self,
1161    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
1162        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
1163            Some((responder))
1164        } else {
1165            None
1166        }
1167    }
1168
1169    /// Name of the method defined in FIDL
1170    pub fn method_name(&self) -> &'static str {
1171        match *self {
1172            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
1173            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
1174            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
1175            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
1176            ActivityReporterRequest::_UnknownMethod {
1177                method_type: fidl::MethodType::OneWay,
1178                ..
1179            } => "unknown one-way method",
1180            ActivityReporterRequest::_UnknownMethod {
1181                method_type: fidl::MethodType::TwoWay,
1182                ..
1183            } => "unknown two-way method",
1184        }
1185    }
1186}
1187
1188#[derive(Debug, Clone)]
1189pub struct ActivityReporterControlHandle {
1190    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1191}
1192
1193impl ActivityReporterControlHandle {
1194    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1195        self.inner.shutdown_with_epitaph(status.into())
1196    }
1197}
1198
1199impl fdomain_client::fidl::ControlHandle for ActivityReporterControlHandle {
1200    fn shutdown(&self) {
1201        self.inner.shutdown()
1202    }
1203
1204    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1205        self.inner.shutdown_with_epitaph(status)
1206    }
1207
1208    fn is_closed(&self) -> bool {
1209        self.inner.channel().is_closed()
1210    }
1211    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1212        self.inner.channel().on_closed()
1213    }
1214}
1215
1216impl ActivityReporterControlHandle {}
1217
1218#[must_use = "FIDL methods require a response to be sent"]
1219#[derive(Debug)]
1220pub struct ActivityReporterWatchRenderActivityResponder {
1221    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1222    tx_id: u32,
1223}
1224
1225/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1226/// if the responder is dropped without sending a response, so that the client
1227/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1228impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1229    fn drop(&mut self) {
1230        self.control_handle.shutdown();
1231        // Safety: drops once, never accessed again
1232        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1233    }
1234}
1235
1236impl fdomain_client::fidl::Responder for ActivityReporterWatchRenderActivityResponder {
1237    type ControlHandle = ActivityReporterControlHandle;
1238
1239    fn control_handle(&self) -> &ActivityReporterControlHandle {
1240        &self.control_handle
1241    }
1242
1243    fn drop_without_shutdown(mut self) {
1244        // Safety: drops once, never accessed again due to mem::forget
1245        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1246        // Prevent Drop from running (which would shut down the channel)
1247        std::mem::forget(self);
1248    }
1249}
1250
1251impl ActivityReporterWatchRenderActivityResponder {
1252    /// Sends a response to the FIDL transaction.
1253    ///
1254    /// Sets the channel to shutdown if an error occurs.
1255    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1256        let _result = self.send_raw(active_usages);
1257        if _result.is_err() {
1258            self.control_handle.shutdown();
1259        }
1260        self.drop_without_shutdown();
1261        _result
1262    }
1263
1264    /// Similar to "send" but does not shutdown the channel if an error occurs.
1265    pub fn send_no_shutdown_on_err(
1266        self,
1267        mut active_usages: &[AudioRenderUsage],
1268    ) -> Result<(), fidl::Error> {
1269        let _result = self.send_raw(active_usages);
1270        self.drop_without_shutdown();
1271        _result
1272    }
1273
1274    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1275        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1276            (active_usages,),
1277            self.tx_id,
1278            0x2974e9f5880b2f1f,
1279            fidl::encoding::DynamicFlags::empty(),
1280        )
1281    }
1282}
1283
1284#[must_use = "FIDL methods require a response to be sent"]
1285#[derive(Debug)]
1286pub struct ActivityReporterWatchRenderActivity2Responder {
1287    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1288    tx_id: u32,
1289}
1290
1291/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1292/// if the responder is dropped without sending a response, so that the client
1293/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1294impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1295    fn drop(&mut self) {
1296        self.control_handle.shutdown();
1297        // Safety: drops once, never accessed again
1298        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1299    }
1300}
1301
1302impl fdomain_client::fidl::Responder for ActivityReporterWatchRenderActivity2Responder {
1303    type ControlHandle = ActivityReporterControlHandle;
1304
1305    fn control_handle(&self) -> &ActivityReporterControlHandle {
1306        &self.control_handle
1307    }
1308
1309    fn drop_without_shutdown(mut self) {
1310        // Safety: drops once, never accessed again due to mem::forget
1311        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1312        // Prevent Drop from running (which would shut down the channel)
1313        std::mem::forget(self);
1314    }
1315}
1316
1317impl ActivityReporterWatchRenderActivity2Responder {
1318    /// Sends a response to the FIDL transaction.
1319    ///
1320    /// Sets the channel to shutdown if an error occurs.
1321    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1322        let _result = self.send_raw(active_usages);
1323        if _result.is_err() {
1324            self.control_handle.shutdown();
1325        }
1326        self.drop_without_shutdown();
1327        _result
1328    }
1329
1330    /// Similar to "send" but does not shutdown the channel if an error occurs.
1331    pub fn send_no_shutdown_on_err(
1332        self,
1333        mut active_usages: &[AudioRenderUsage2],
1334    ) -> Result<(), fidl::Error> {
1335        let _result = self.send_raw(active_usages);
1336        self.drop_without_shutdown();
1337        _result
1338    }
1339
1340    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1341        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1342            ActivityReporterWatchRenderActivity2Response,
1343        >>(
1344            fidl::encoding::Flexible::new((active_usages,)),
1345            self.tx_id,
1346            0x484236fc11b363e6,
1347            fidl::encoding::DynamicFlags::FLEXIBLE,
1348        )
1349    }
1350}
1351
1352#[must_use = "FIDL methods require a response to be sent"]
1353#[derive(Debug)]
1354pub struct ActivityReporterWatchCaptureActivityResponder {
1355    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1356    tx_id: u32,
1357}
1358
1359/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1360/// if the responder is dropped without sending a response, so that the client
1361/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1362impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1363    fn drop(&mut self) {
1364        self.control_handle.shutdown();
1365        // Safety: drops once, never accessed again
1366        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1367    }
1368}
1369
1370impl fdomain_client::fidl::Responder for ActivityReporterWatchCaptureActivityResponder {
1371    type ControlHandle = ActivityReporterControlHandle;
1372
1373    fn control_handle(&self) -> &ActivityReporterControlHandle {
1374        &self.control_handle
1375    }
1376
1377    fn drop_without_shutdown(mut self) {
1378        // Safety: drops once, never accessed again due to mem::forget
1379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1380        // Prevent Drop from running (which would shut down the channel)
1381        std::mem::forget(self);
1382    }
1383}
1384
1385impl ActivityReporterWatchCaptureActivityResponder {
1386    /// Sends a response to the FIDL transaction.
1387    ///
1388    /// Sets the channel to shutdown if an error occurs.
1389    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1390        let _result = self.send_raw(active_usages);
1391        if _result.is_err() {
1392            self.control_handle.shutdown();
1393        }
1394        self.drop_without_shutdown();
1395        _result
1396    }
1397
1398    /// Similar to "send" but does not shutdown the channel if an error occurs.
1399    pub fn send_no_shutdown_on_err(
1400        self,
1401        mut active_usages: &[AudioCaptureUsage],
1402    ) -> Result<(), fidl::Error> {
1403        let _result = self.send_raw(active_usages);
1404        self.drop_without_shutdown();
1405        _result
1406    }
1407
1408    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1409        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1410            (active_usages,),
1411            self.tx_id,
1412            0x70e7038e9658e128,
1413            fidl::encoding::DynamicFlags::empty(),
1414        )
1415    }
1416}
1417
1418#[must_use = "FIDL methods require a response to be sent"]
1419#[derive(Debug)]
1420pub struct ActivityReporterWatchCaptureActivity2Responder {
1421    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1422    tx_id: u32,
1423}
1424
1425/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1426/// if the responder is dropped without sending a response, so that the client
1427/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1428impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1429    fn drop(&mut self) {
1430        self.control_handle.shutdown();
1431        // Safety: drops once, never accessed again
1432        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1433    }
1434}
1435
1436impl fdomain_client::fidl::Responder for ActivityReporterWatchCaptureActivity2Responder {
1437    type ControlHandle = ActivityReporterControlHandle;
1438
1439    fn control_handle(&self) -> &ActivityReporterControlHandle {
1440        &self.control_handle
1441    }
1442
1443    fn drop_without_shutdown(mut self) {
1444        // Safety: drops once, never accessed again due to mem::forget
1445        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1446        // Prevent Drop from running (which would shut down the channel)
1447        std::mem::forget(self);
1448    }
1449}
1450
1451impl ActivityReporterWatchCaptureActivity2Responder {
1452    /// Sends a response to the FIDL transaction.
1453    ///
1454    /// Sets the channel to shutdown if an error occurs.
1455    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1456        let _result = self.send_raw(active_usages);
1457        if _result.is_err() {
1458            self.control_handle.shutdown();
1459        }
1460        self.drop_without_shutdown();
1461        _result
1462    }
1463
1464    /// Similar to "send" but does not shutdown the channel if an error occurs.
1465    pub fn send_no_shutdown_on_err(
1466        self,
1467        mut active_usages: &[AudioCaptureUsage2],
1468    ) -> Result<(), fidl::Error> {
1469        let _result = self.send_raw(active_usages);
1470        self.drop_without_shutdown();
1471        _result
1472    }
1473
1474    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1475        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1476            ActivityReporterWatchCaptureActivity2Response,
1477        >>(
1478            fidl::encoding::Flexible::new((active_usages,)),
1479            self.tx_id,
1480            0x3d137e0364f9d550,
1481            fidl::encoding::DynamicFlags::FLEXIBLE,
1482        )
1483    }
1484}
1485
1486#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1487pub struct AudioMarker;
1488
1489impl fdomain_client::fidl::ProtocolMarker for AudioMarker {
1490    type Proxy = AudioProxy;
1491    type RequestStream = AudioRequestStream;
1492
1493    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1494}
1495impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioMarker {}
1496
1497pub trait AudioProxyInterface: Send + Sync {
1498    fn r#create_audio_renderer(
1499        &self,
1500        audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1501    ) -> Result<(), fidl::Error>;
1502    fn r#create_audio_capturer(
1503        &self,
1504        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1505        loopback: bool,
1506    ) -> Result<(), fidl::Error>;
1507}
1508
1509#[derive(Debug, Clone)]
1510pub struct AudioProxy {
1511    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1512}
1513
1514impl fdomain_client::fidl::Proxy for AudioProxy {
1515    type Protocol = AudioMarker;
1516
1517    fn from_channel(inner: fdomain_client::Channel) -> Self {
1518        Self::new(inner)
1519    }
1520
1521    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1522        self.client.into_channel().map_err(|client| Self { client })
1523    }
1524
1525    fn as_channel(&self) -> &fdomain_client::Channel {
1526        self.client.as_channel()
1527    }
1528}
1529
1530impl AudioProxy {
1531    /// Create a new Proxy for fuchsia.media/Audio.
1532    pub fn new(channel: fdomain_client::Channel) -> Self {
1533        let protocol_name = <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1534        Self { client: fidl::client::Client::new(channel, protocol_name) }
1535    }
1536
1537    /// Get a Stream of events from the remote end of the protocol.
1538    ///
1539    /// # Panics
1540    ///
1541    /// Panics if the event stream was already taken.
1542    pub fn take_event_stream(&self) -> AudioEventStream {
1543        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1544    }
1545
1546    pub fn r#create_audio_renderer(
1547        &self,
1548        mut audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1549    ) -> Result<(), fidl::Error> {
1550        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1551    }
1552
1553    /// Creates an AudioCapturer which either captures from the current default
1554    /// audio input device, or loops-back from the current default audio output
1555    /// device based on value passed for the loopback flag.
1556    pub fn r#create_audio_capturer(
1557        &self,
1558        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1559        mut loopback: bool,
1560    ) -> Result<(), fidl::Error> {
1561        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1562    }
1563}
1564
1565impl AudioProxyInterface for AudioProxy {
1566    fn r#create_audio_renderer(
1567        &self,
1568        mut audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1569    ) -> Result<(), fidl::Error> {
1570        self.client.send::<AudioCreateAudioRendererRequest>(
1571            (audio_renderer_request,),
1572            0x572f413566fd58f1,
1573            fidl::encoding::DynamicFlags::empty(),
1574        )
1575    }
1576
1577    fn r#create_audio_capturer(
1578        &self,
1579        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1580        mut loopback: bool,
1581    ) -> Result<(), fidl::Error> {
1582        self.client.send::<AudioCreateAudioCapturerRequest>(
1583            (audio_capturer_request, loopback),
1584            0x44660fc63a6202f,
1585            fidl::encoding::DynamicFlags::empty(),
1586        )
1587    }
1588}
1589
1590pub struct AudioEventStream {
1591    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1592}
1593
1594impl std::marker::Unpin for AudioEventStream {}
1595
1596impl futures::stream::FusedStream for AudioEventStream {
1597    fn is_terminated(&self) -> bool {
1598        self.event_receiver.is_terminated()
1599    }
1600}
1601
1602impl futures::Stream for AudioEventStream {
1603    type Item = Result<AudioEvent, fidl::Error>;
1604
1605    fn poll_next(
1606        mut self: std::pin::Pin<&mut Self>,
1607        cx: &mut std::task::Context<'_>,
1608    ) -> std::task::Poll<Option<Self::Item>> {
1609        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1610            &mut self.event_receiver,
1611            cx
1612        )?) {
1613            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1614            None => std::task::Poll::Ready(None),
1615        }
1616    }
1617}
1618
1619#[derive(Debug)]
1620pub enum AudioEvent {}
1621
1622impl AudioEvent {
1623    /// Decodes a message buffer as a [`AudioEvent`].
1624    fn decode(
1625        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1626    ) -> Result<AudioEvent, fidl::Error> {
1627        let (bytes, _handles) = buf.split_mut();
1628        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1629        debug_assert_eq!(tx_header.tx_id, 0);
1630        match tx_header.ordinal {
1631            _ => Err(fidl::Error::UnknownOrdinal {
1632                ordinal: tx_header.ordinal,
1633                protocol_name: <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1634            }),
1635        }
1636    }
1637}
1638
1639/// A Stream of incoming requests for fuchsia.media/Audio.
1640pub struct AudioRequestStream {
1641    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1642    is_terminated: bool,
1643}
1644
1645impl std::marker::Unpin for AudioRequestStream {}
1646
1647impl futures::stream::FusedStream for AudioRequestStream {
1648    fn is_terminated(&self) -> bool {
1649        self.is_terminated
1650    }
1651}
1652
1653impl fdomain_client::fidl::RequestStream for AudioRequestStream {
1654    type Protocol = AudioMarker;
1655    type ControlHandle = AudioControlHandle;
1656
1657    fn from_channel(channel: fdomain_client::Channel) -> Self {
1658        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1659    }
1660
1661    fn control_handle(&self) -> Self::ControlHandle {
1662        AudioControlHandle { inner: self.inner.clone() }
1663    }
1664
1665    fn into_inner(
1666        self,
1667    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1668    {
1669        (self.inner, self.is_terminated)
1670    }
1671
1672    fn from_inner(
1673        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1674        is_terminated: bool,
1675    ) -> Self {
1676        Self { inner, is_terminated }
1677    }
1678}
1679
1680impl futures::Stream for AudioRequestStream {
1681    type Item = Result<AudioRequest, fidl::Error>;
1682
1683    fn poll_next(
1684        mut self: std::pin::Pin<&mut Self>,
1685        cx: &mut std::task::Context<'_>,
1686    ) -> std::task::Poll<Option<Self::Item>> {
1687        let this = &mut *self;
1688        if this.inner.check_shutdown(cx) {
1689            this.is_terminated = true;
1690            return std::task::Poll::Ready(None);
1691        }
1692        if this.is_terminated {
1693            panic!("polled AudioRequestStream after completion");
1694        }
1695        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1696            |bytes, handles| {
1697                match this.inner.channel().read_etc(cx, bytes, handles) {
1698                    std::task::Poll::Ready(Ok(())) => {}
1699                    std::task::Poll::Pending => return std::task::Poll::Pending,
1700                    std::task::Poll::Ready(Err(None)) => {
1701                        this.is_terminated = true;
1702                        return std::task::Poll::Ready(None);
1703                    }
1704                    std::task::Poll::Ready(Err(Some(e))) => {
1705                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1706                            e.into(),
1707                        ))));
1708                    }
1709                }
1710
1711                // A message has been received from the channel
1712                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1713
1714                std::task::Poll::Ready(Some(match header.ordinal {
1715                    0x572f413566fd58f1 => {
1716                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1717                        let mut req = fidl::new_empty!(
1718                            AudioCreateAudioRendererRequest,
1719                            fdomain_client::fidl::FDomainResourceDialect
1720                        );
1721                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1722                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1723                        Ok(AudioRequest::CreateAudioRenderer {
1724                            audio_renderer_request: req.audio_renderer_request,
1725
1726                            control_handle,
1727                        })
1728                    }
1729                    0x44660fc63a6202f => {
1730                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1731                        let mut req = fidl::new_empty!(
1732                            AudioCreateAudioCapturerRequest,
1733                            fdomain_client::fidl::FDomainResourceDialect
1734                        );
1735                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
1736                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1737                        Ok(AudioRequest::CreateAudioCapturer {
1738                            audio_capturer_request: req.audio_capturer_request,
1739                            loopback: req.loopback,
1740
1741                            control_handle,
1742                        })
1743                    }
1744                    _ => Err(fidl::Error::UnknownOrdinal {
1745                        ordinal: header.ordinal,
1746                        protocol_name:
1747                            <AudioMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1748                    }),
1749                }))
1750            },
1751        )
1752    }
1753}
1754
1755#[derive(Debug)]
1756pub enum AudioRequest {
1757    CreateAudioRenderer {
1758        audio_renderer_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
1759        control_handle: AudioControlHandle,
1760    },
1761    /// Creates an AudioCapturer which either captures from the current default
1762    /// audio input device, or loops-back from the current default audio output
1763    /// device based on value passed for the loopback flag.
1764    CreateAudioCapturer {
1765        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
1766        loopback: bool,
1767        control_handle: AudioControlHandle,
1768    },
1769}
1770
1771impl AudioRequest {
1772    #[allow(irrefutable_let_patterns)]
1773    pub fn into_create_audio_renderer(
1774        self,
1775    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
1776        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
1777            Some((audio_renderer_request, control_handle))
1778        } else {
1779            None
1780        }
1781    }
1782
1783    #[allow(irrefutable_let_patterns)]
1784    pub fn into_create_audio_capturer(
1785        self,
1786    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)>
1787    {
1788        if let AudioRequest::CreateAudioCapturer {
1789            audio_capturer_request,
1790            loopback,
1791            control_handle,
1792        } = self
1793        {
1794            Some((audio_capturer_request, loopback, control_handle))
1795        } else {
1796            None
1797        }
1798    }
1799
1800    /// Name of the method defined in FIDL
1801    pub fn method_name(&self) -> &'static str {
1802        match *self {
1803            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
1804            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
1805        }
1806    }
1807}
1808
1809#[derive(Debug, Clone)]
1810pub struct AudioControlHandle {
1811    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1812}
1813
1814impl AudioControlHandle {
1815    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1816        self.inner.shutdown_with_epitaph(status.into())
1817    }
1818}
1819
1820impl fdomain_client::fidl::ControlHandle for AudioControlHandle {
1821    fn shutdown(&self) {
1822        self.inner.shutdown()
1823    }
1824
1825    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1826        self.inner.shutdown_with_epitaph(status)
1827    }
1828
1829    fn is_closed(&self) -> bool {
1830        self.inner.channel().is_closed()
1831    }
1832    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1833        self.inner.channel().on_closed()
1834    }
1835}
1836
1837impl AudioControlHandle {}
1838
1839#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1840pub struct AudioCapturerMarker;
1841
1842impl fdomain_client::fidl::ProtocolMarker for AudioCapturerMarker {
1843    type Proxy = AudioCapturerProxy;
1844    type RequestStream = AudioCapturerRequestStream;
1845
1846    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
1847}
1848impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioCapturerMarker {}
1849
1850pub trait AudioCapturerProxyInterface: Send + Sync {
1851    fn r#add_payload_buffer(
1852        &self,
1853        id: u32,
1854        payload_buffer: fdomain_client::Vmo,
1855    ) -> Result<(), fidl::Error>;
1856    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
1857    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
1858    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1859    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
1860    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
1861    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
1862    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
1863        + Send;
1864    fn r#capture_at(
1865        &self,
1866        payload_buffer_id: u32,
1867        payload_offset: u32,
1868        frames: u32,
1869    ) -> Self::CaptureAtResponseFut;
1870    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
1871    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1872    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
1873    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
1874    fn r#bind_gain_control(
1875        &self,
1876        gain_control_request: fdomain_client::fidl::ServerEnd<
1877            fdomain_fuchsia_media_audio::GainControlMarker,
1878        >,
1879    ) -> Result<(), fidl::Error>;
1880    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fdomain_client::Clock, fidl::Error>>
1881        + Send;
1882    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
1883    fn r#set_reference_clock(
1884        &self,
1885        reference_clock: Option<fdomain_client::Clock>,
1886    ) -> Result<(), fidl::Error>;
1887    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
1888    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
1889    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
1890        + Send;
1891    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
1892}
1893
1894#[derive(Debug, Clone)]
1895pub struct AudioCapturerProxy {
1896    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1897}
1898
1899impl fdomain_client::fidl::Proxy for AudioCapturerProxy {
1900    type Protocol = AudioCapturerMarker;
1901
1902    fn from_channel(inner: fdomain_client::Channel) -> Self {
1903        Self::new(inner)
1904    }
1905
1906    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1907        self.client.into_channel().map_err(|client| Self { client })
1908    }
1909
1910    fn as_channel(&self) -> &fdomain_client::Channel {
1911        self.client.as_channel()
1912    }
1913}
1914
1915impl AudioCapturerProxy {
1916    /// Create a new Proxy for fuchsia.media/AudioCapturer.
1917    pub fn new(channel: fdomain_client::Channel) -> Self {
1918        let protocol_name =
1919            <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1920        Self { client: fidl::client::Client::new(channel, protocol_name) }
1921    }
1922
1923    /// Get a Stream of events from the remote end of the protocol.
1924    ///
1925    /// # Panics
1926    ///
1927    /// Panics if the event stream was already taken.
1928    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
1929        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
1930    }
1931
1932    /// Adds a payload buffer to the current buffer set associated with the
1933    /// connection. A `StreamPacket` struct reference a payload buffer in the
1934    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
1935    ///
1936    /// A buffer with ID `id` must not be in the current set when this method is
1937    /// invoked, otherwise the service will close the connection.
1938    pub fn r#add_payload_buffer(
1939        &self,
1940        mut id: u32,
1941        mut payload_buffer: fdomain_client::Vmo,
1942    ) -> Result<(), fidl::Error> {
1943        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
1944    }
1945
1946    /// Removes a payload buffer from the current buffer set associated with the
1947    /// connection.
1948    ///
1949    /// A buffer with ID `id` must exist in the current set when this method is
1950    /// invoked, otherwise the service will will close the connection.
1951    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
1952        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
1953    }
1954
1955    /// Releases payload memory associated with a packet previously delivered
1956    /// via `OnPacketProduced`.
1957    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
1958        AudioCapturerProxyInterface::r#release_packet(self, packet)
1959    }
1960
1961    pub fn r#discard_all_packets(
1962        &self,
1963    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
1964        AudioCapturerProxyInterface::r#discard_all_packets(self)
1965    }
1966
1967    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
1968        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
1969    }
1970
1971    /// Sets the stream type of the stream to be delivered. Causes the source
1972    /// material to be reformatted/resampled if needed in order to produce the
1973    /// requested stream type. Must be called before the payload buffer is
1974    /// established.
1975    pub fn r#set_pcm_stream_type(
1976        &self,
1977        mut stream_type: &AudioStreamType,
1978    ) -> Result<(), fidl::Error> {
1979        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
1980    }
1981
1982    /// Explicitly specifies a region of the shared payload buffer for the audio
1983    /// input to capture into.
1984    pub fn r#capture_at(
1985        &self,
1986        mut payload_buffer_id: u32,
1987        mut payload_offset: u32,
1988        mut frames: u32,
1989    ) -> fidl::client::QueryResponseFut<StreamPacket, fdomain_client::fidl::FDomainResourceDialect>
1990    {
1991        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
1992    }
1993
1994    /// Places the AudioCapturer into 'async' capture mode and begin to produce
1995    /// packets of exactly 'frames_per_packet' number of frames each. The
1996    /// OnPacketProduced event (of StreamSink) will be used to inform the client
1997    /// of produced packets.
1998    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
1999        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
2000    }
2001
2002    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2003    /// that may be used by the client if explicit synchronization is needed.
2004    pub fn r#stop_async_capture(
2005        &self,
2006    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
2007        AudioCapturerProxyInterface::r#stop_async_capture(self)
2008    }
2009
2010    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2011        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2012    }
2013
2014    /// Binds to the gain control for this AudioCapturer.
2015    pub fn r#bind_gain_control(
2016        &self,
2017        mut gain_control_request: fdomain_client::fidl::ServerEnd<
2018            fdomain_fuchsia_media_audio::GainControlMarker,
2019        >,
2020    ) -> Result<(), fidl::Error> {
2021        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2022    }
2023
2024    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2025    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2026    pub fn r#get_reference_clock(
2027        &self,
2028    ) -> fidl::client::QueryResponseFut<
2029        fdomain_client::Clock,
2030        fdomain_client::fidl::FDomainResourceDialect,
2031    > {
2032        AudioCapturerProxyInterface::r#get_reference_clock(self)
2033    }
2034
2035    /// Sets the reference clock that controls this capturer's playback rate. If the input
2036    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2037    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2038    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2039    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2040    ///
2041    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2042    /// added. It also cannot be called a second time (even before capture).
2043    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2044    /// diverge at some later time, they should create a clone of the monotonic clock, set
2045    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2046    pub fn r#set_reference_clock(
2047        &self,
2048        mut reference_clock: Option<fdomain_client::Clock>,
2049    ) -> Result<(), fidl::Error> {
2050        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2051    }
2052
2053    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2054    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2055    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2056        AudioCapturerProxyInterface::r#set_usage(self, usage)
2057    }
2058
2059    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2060    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2061    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2062        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2063    }
2064
2065    /// Gets the currently configured stream type. Note: for an AudioCapturer
2066    /// which was just created and has not yet had its stream type explicitly
2067    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2068    /// was created -- of the source (input or looped-back output) to which the
2069    /// AudioCapturer is bound. Even if this matches the client's desired format,
2070    /// `SetPcmStreamType` must still be called.
2071    pub fn r#get_stream_type(
2072        &self,
2073    ) -> fidl::client::QueryResponseFut<StreamType, fdomain_client::fidl::FDomainResourceDialect>
2074    {
2075        AudioCapturerProxyInterface::r#get_stream_type(self)
2076    }
2077}
2078
2079impl AudioCapturerProxyInterface for AudioCapturerProxy {
2080    fn r#add_payload_buffer(
2081        &self,
2082        mut id: u32,
2083        mut payload_buffer: fdomain_client::Vmo,
2084    ) -> Result<(), fidl::Error> {
2085        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2086            (id, payload_buffer),
2087            0x3b3a37fc34fe5b56,
2088            fidl::encoding::DynamicFlags::empty(),
2089        )
2090    }
2091
2092    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2093        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2094            (id,),
2095            0x5d1e4f74c3658262,
2096            fidl::encoding::DynamicFlags::empty(),
2097        )
2098    }
2099
2100    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2101        self.client.send::<StreamSourceReleasePacketRequest>(
2102            (packet,),
2103            0x7a7b57f0f7d9e4bb,
2104            fidl::encoding::DynamicFlags::empty(),
2105        )
2106    }
2107
2108    type DiscardAllPacketsResponseFut =
2109        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2110    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2111        fn _decode(
2112            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2113        ) -> Result<(), fidl::Error> {
2114            let _response = fidl::client::decode_transaction_body::<
2115                fidl::encoding::EmptyPayload,
2116                fdomain_client::fidl::FDomainResourceDialect,
2117                0x27afd605e97b09d2,
2118            >(_buf?)?;
2119            Ok(_response)
2120        }
2121        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2122            (),
2123            0x27afd605e97b09d2,
2124            fidl::encoding::DynamicFlags::empty(),
2125            _decode,
2126        )
2127    }
2128
2129    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2130        self.client.send::<fidl::encoding::EmptyPayload>(
2131            (),
2132            0x35f9d721e905b831,
2133            fidl::encoding::DynamicFlags::empty(),
2134        )
2135    }
2136
2137    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2138        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2139            (stream_type,),
2140            0x1531ea9ea2c852cd,
2141            fidl::encoding::DynamicFlags::empty(),
2142        )
2143    }
2144
2145    type CaptureAtResponseFut =
2146        fidl::client::QueryResponseFut<StreamPacket, fdomain_client::fidl::FDomainResourceDialect>;
2147    fn r#capture_at(
2148        &self,
2149        mut payload_buffer_id: u32,
2150        mut payload_offset: u32,
2151        mut frames: u32,
2152    ) -> Self::CaptureAtResponseFut {
2153        fn _decode(
2154            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2155        ) -> Result<StreamPacket, fidl::Error> {
2156            let _response = fidl::client::decode_transaction_body::<
2157                AudioCapturerCaptureAtResponse,
2158                fdomain_client::fidl::FDomainResourceDialect,
2159                0x784e25df72cea780,
2160            >(_buf?)?;
2161            Ok(_response.captured_packet)
2162        }
2163        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2164            (payload_buffer_id, payload_offset, frames),
2165            0x784e25df72cea780,
2166            fidl::encoding::DynamicFlags::empty(),
2167            _decode,
2168        )
2169    }
2170
2171    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2172        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2173            (frames_per_packet,),
2174            0x7768adbb1ccfd7a6,
2175            fidl::encoding::DynamicFlags::empty(),
2176        )
2177    }
2178
2179    type StopAsyncCaptureResponseFut =
2180        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
2181    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2182        fn _decode(
2183            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2184        ) -> Result<(), fidl::Error> {
2185            let _response = fidl::client::decode_transaction_body::<
2186                fidl::encoding::EmptyPayload,
2187                fdomain_client::fidl::FDomainResourceDialect,
2188                0x5bfc8790a8cef8cb,
2189            >(_buf?)?;
2190            Ok(_response)
2191        }
2192        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2193            (),
2194            0x5bfc8790a8cef8cb,
2195            fidl::encoding::DynamicFlags::empty(),
2196            _decode,
2197        )
2198    }
2199
2200    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2201        self.client.send::<fidl::encoding::EmptyPayload>(
2202            (),
2203            0x33223cb2962c95e3,
2204            fidl::encoding::DynamicFlags::empty(),
2205        )
2206    }
2207
2208    fn r#bind_gain_control(
2209        &self,
2210        mut gain_control_request: fdomain_client::fidl::ServerEnd<
2211            fdomain_fuchsia_media_audio::GainControlMarker,
2212        >,
2213    ) -> Result<(), fidl::Error> {
2214        self.client.send::<AudioCapturerBindGainControlRequest>(
2215            (gain_control_request,),
2216            0x658a6a17ddb3a8e0,
2217            fidl::encoding::DynamicFlags::empty(),
2218        )
2219    }
2220
2221    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
2222        fdomain_client::Clock,
2223        fdomain_client::fidl::FDomainResourceDialect,
2224    >;
2225    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2226        fn _decode(
2227            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2228        ) -> Result<fdomain_client::Clock, fidl::Error> {
2229            let _response = fidl::client::decode_transaction_body::<
2230                AudioCapturerGetReferenceClockResponse,
2231                fdomain_client::fidl::FDomainResourceDialect,
2232                0x50d037aa5a4b4d71,
2233            >(_buf?)?;
2234            Ok(_response.reference_clock)
2235        }
2236        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Clock>(
2237            (),
2238            0x50d037aa5a4b4d71,
2239            fidl::encoding::DynamicFlags::empty(),
2240            _decode,
2241        )
2242    }
2243
2244    fn r#set_reference_clock(
2245        &self,
2246        mut reference_clock: Option<fdomain_client::Clock>,
2247    ) -> Result<(), fidl::Error> {
2248        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2249            (reference_clock,),
2250            0x732b2c496d521bcf,
2251            fidl::encoding::DynamicFlags::empty(),
2252        )
2253    }
2254
2255    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2256        self.client.send::<AudioCapturerSetUsageRequest>(
2257            (usage,),
2258            0x42a16f392bd21b25,
2259            fidl::encoding::DynamicFlags::empty(),
2260        )
2261    }
2262
2263    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2264        self.client.send::<AudioCapturerSetUsage2Request>(
2265            (usage,),
2266            0x7a73e251b8d2382b,
2267            fidl::encoding::DynamicFlags::FLEXIBLE,
2268        )
2269    }
2270
2271    type GetStreamTypeResponseFut =
2272        fidl::client::QueryResponseFut<StreamType, fdomain_client::fidl::FDomainResourceDialect>;
2273    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2274        fn _decode(
2275            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2276        ) -> Result<StreamType, fidl::Error> {
2277            let _response = fidl::client::decode_transaction_body::<
2278                AudioCapturerGetStreamTypeResponse,
2279                fdomain_client::fidl::FDomainResourceDialect,
2280                0x5dcaaa670b433088,
2281            >(_buf?)?;
2282            Ok(_response.stream_type)
2283        }
2284        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2285            (),
2286            0x5dcaaa670b433088,
2287            fidl::encoding::DynamicFlags::empty(),
2288            _decode,
2289        )
2290    }
2291}
2292
2293pub struct AudioCapturerEventStream {
2294    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
2295}
2296
2297impl std::marker::Unpin for AudioCapturerEventStream {}
2298
2299impl futures::stream::FusedStream for AudioCapturerEventStream {
2300    fn is_terminated(&self) -> bool {
2301        self.event_receiver.is_terminated()
2302    }
2303}
2304
2305impl futures::Stream for AudioCapturerEventStream {
2306    type Item = Result<AudioCapturerEvent, fidl::Error>;
2307
2308    fn poll_next(
2309        mut self: std::pin::Pin<&mut Self>,
2310        cx: &mut std::task::Context<'_>,
2311    ) -> std::task::Poll<Option<Self::Item>> {
2312        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2313            &mut self.event_receiver,
2314            cx
2315        )?) {
2316            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2317            None => std::task::Poll::Ready(None),
2318        }
2319    }
2320}
2321
2322#[derive(Debug)]
2323pub enum AudioCapturerEvent {
2324    OnPacketProduced {
2325        packet: StreamPacket,
2326    },
2327    OnEndOfStream {},
2328    #[non_exhaustive]
2329    _UnknownEvent {
2330        /// Ordinal of the event that was sent.
2331        ordinal: u64,
2332    },
2333}
2334
2335impl AudioCapturerEvent {
2336    #[allow(irrefutable_let_patterns)]
2337    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2338        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2339            Some((packet))
2340        } else {
2341            None
2342        }
2343    }
2344    #[allow(irrefutable_let_patterns)]
2345    pub fn into_on_end_of_stream(self) -> Option<()> {
2346        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2347    }
2348
2349    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2350    fn decode(
2351        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2352    ) -> Result<AudioCapturerEvent, fidl::Error> {
2353        let (bytes, _handles) = buf.split_mut();
2354        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2355        debug_assert_eq!(tx_header.tx_id, 0);
2356        match tx_header.ordinal {
2357            0x6bbe69746a3c8bd9 => {
2358                let mut out = fidl::new_empty!(
2359                    StreamSourceOnPacketProducedRequest,
2360                    fdomain_client::fidl::FDomainResourceDialect
2361                );
2362                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2363                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2364            }
2365            0x550e69b41d03e2c2 => {
2366                let mut out = fidl::new_empty!(
2367                    fidl::encoding::EmptyPayload,
2368                    fdomain_client::fidl::FDomainResourceDialect
2369                );
2370                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2371                Ok((AudioCapturerEvent::OnEndOfStream {}))
2372            }
2373            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2374                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2375            }
2376            _ => Err(fidl::Error::UnknownOrdinal {
2377                ordinal: tx_header.ordinal,
2378                protocol_name:
2379                    <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2380            }),
2381        }
2382    }
2383}
2384
2385/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2386pub struct AudioCapturerRequestStream {
2387    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2388    is_terminated: bool,
2389}
2390
2391impl std::marker::Unpin for AudioCapturerRequestStream {}
2392
2393impl futures::stream::FusedStream for AudioCapturerRequestStream {
2394    fn is_terminated(&self) -> bool {
2395        self.is_terminated
2396    }
2397}
2398
2399impl fdomain_client::fidl::RequestStream for AudioCapturerRequestStream {
2400    type Protocol = AudioCapturerMarker;
2401    type ControlHandle = AudioCapturerControlHandle;
2402
2403    fn from_channel(channel: fdomain_client::Channel) -> Self {
2404        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2405    }
2406
2407    fn control_handle(&self) -> Self::ControlHandle {
2408        AudioCapturerControlHandle { inner: self.inner.clone() }
2409    }
2410
2411    fn into_inner(
2412        self,
2413    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
2414    {
2415        (self.inner, self.is_terminated)
2416    }
2417
2418    fn from_inner(
2419        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
2420        is_terminated: bool,
2421    ) -> Self {
2422        Self { inner, is_terminated }
2423    }
2424}
2425
2426impl futures::Stream for AudioCapturerRequestStream {
2427    type Item = Result<AudioCapturerRequest, fidl::Error>;
2428
2429    fn poll_next(
2430        mut self: std::pin::Pin<&mut Self>,
2431        cx: &mut std::task::Context<'_>,
2432    ) -> std::task::Poll<Option<Self::Item>> {
2433        let this = &mut *self;
2434        if this.inner.check_shutdown(cx) {
2435            this.is_terminated = true;
2436            return std::task::Poll::Ready(None);
2437        }
2438        if this.is_terminated {
2439            panic!("polled AudioCapturerRequestStream after completion");
2440        }
2441        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
2442            |bytes, handles| {
2443                match this.inner.channel().read_etc(cx, bytes, handles) {
2444                    std::task::Poll::Ready(Ok(())) => {}
2445                    std::task::Poll::Pending => return std::task::Poll::Pending,
2446                    std::task::Poll::Ready(Err(None)) => {
2447                        this.is_terminated = true;
2448                        return std::task::Poll::Ready(None);
2449                    }
2450                    std::task::Poll::Ready(Err(Some(e))) => {
2451                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2452                            e.into(),
2453                        ))));
2454                    }
2455                }
2456
2457                // A message has been received from the channel
2458                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2459
2460                std::task::Poll::Ready(Some(match header.ordinal {
2461                0x3b3a37fc34fe5b56 => {
2462                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2463                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
2464                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2465                    let control_handle = AudioCapturerControlHandle {
2466                        inner: this.inner.clone(),
2467                    };
2468                    Ok(AudioCapturerRequest::AddPayloadBuffer {id: req.id,
2469payload_buffer: req.payload_buffer,
2470
2471                        control_handle,
2472                    })
2473                }
2474                0x5d1e4f74c3658262 => {
2475                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2476                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
2477                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
2478                    let control_handle = AudioCapturerControlHandle {
2479                        inner: this.inner.clone(),
2480                    };
2481                    Ok(AudioCapturerRequest::RemovePayloadBuffer {id: req.id,
2482
2483                        control_handle,
2484                    })
2485                }
2486                0x7a7b57f0f7d9e4bb => {
2487                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2488                    let mut req = fidl::new_empty!(StreamSourceReleasePacketRequest, fdomain_client::fidl::FDomainResourceDialect);
2489                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
2490                    let control_handle = AudioCapturerControlHandle {
2491                        inner: this.inner.clone(),
2492                    };
2493                    Ok(AudioCapturerRequest::ReleasePacket {packet: req.packet,
2494
2495                        control_handle,
2496                    })
2497                }
2498                0x27afd605e97b09d2 => {
2499                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2500                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2501                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2502                    let control_handle = AudioCapturerControlHandle {
2503                        inner: this.inner.clone(),
2504                    };
2505                    Ok(AudioCapturerRequest::DiscardAllPackets {
2506                        responder: AudioCapturerDiscardAllPacketsResponder {
2507                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2508                            tx_id: header.tx_id,
2509                        },
2510                    })
2511                }
2512                0x35f9d721e905b831 => {
2513                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2514                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2515                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2516                    let control_handle = AudioCapturerControlHandle {
2517                        inner: this.inner.clone(),
2518                    };
2519                    Ok(AudioCapturerRequest::DiscardAllPacketsNoReply {
2520                        control_handle,
2521                    })
2522                }
2523                0x1531ea9ea2c852cd => {
2524                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2525                    let mut req = fidl::new_empty!(AudioCapturerSetPcmStreamTypeRequest, fdomain_client::fidl::FDomainResourceDialect);
2526                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
2527                    let control_handle = AudioCapturerControlHandle {
2528                        inner: this.inner.clone(),
2529                    };
2530                    Ok(AudioCapturerRequest::SetPcmStreamType {stream_type: req.stream_type,
2531
2532                        control_handle,
2533                    })
2534                }
2535                0x784e25df72cea780 => {
2536                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2537                    let mut req = fidl::new_empty!(AudioCapturerCaptureAtRequest, fdomain_client::fidl::FDomainResourceDialect);
2538                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
2539                    let control_handle = AudioCapturerControlHandle {
2540                        inner: this.inner.clone(),
2541                    };
2542                    Ok(AudioCapturerRequest::CaptureAt {payload_buffer_id: req.payload_buffer_id,
2543payload_offset: req.payload_offset,
2544frames: req.frames,
2545
2546                        responder: AudioCapturerCaptureAtResponder {
2547                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2548                            tx_id: header.tx_id,
2549                        },
2550                    })
2551                }
2552                0x7768adbb1ccfd7a6 => {
2553                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2554                    let mut req = fidl::new_empty!(AudioCapturerStartAsyncCaptureRequest, fdomain_client::fidl::FDomainResourceDialect);
2555                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
2556                    let control_handle = AudioCapturerControlHandle {
2557                        inner: this.inner.clone(),
2558                    };
2559                    Ok(AudioCapturerRequest::StartAsyncCapture {frames_per_packet: req.frames_per_packet,
2560
2561                        control_handle,
2562                    })
2563                }
2564                0x5bfc8790a8cef8cb => {
2565                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2566                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2567                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2568                    let control_handle = AudioCapturerControlHandle {
2569                        inner: this.inner.clone(),
2570                    };
2571                    Ok(AudioCapturerRequest::StopAsyncCapture {
2572                        responder: AudioCapturerStopAsyncCaptureResponder {
2573                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2574                            tx_id: header.tx_id,
2575                        },
2576                    })
2577                }
2578                0x33223cb2962c95e3 => {
2579                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2580                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2581                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2582                    let control_handle = AudioCapturerControlHandle {
2583                        inner: this.inner.clone(),
2584                    };
2585                    Ok(AudioCapturerRequest::StopAsyncCaptureNoReply {
2586                        control_handle,
2587                    })
2588                }
2589                0x658a6a17ddb3a8e0 => {
2590                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2591                    let mut req = fidl::new_empty!(AudioCapturerBindGainControlRequest, fdomain_client::fidl::FDomainResourceDialect);
2592                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
2593                    let control_handle = AudioCapturerControlHandle {
2594                        inner: this.inner.clone(),
2595                    };
2596                    Ok(AudioCapturerRequest::BindGainControl {gain_control_request: req.gain_control_request,
2597
2598                        control_handle,
2599                    })
2600                }
2601                0x50d037aa5a4b4d71 => {
2602                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2603                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2604                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2605                    let control_handle = AudioCapturerControlHandle {
2606                        inner: this.inner.clone(),
2607                    };
2608                    Ok(AudioCapturerRequest::GetReferenceClock {
2609                        responder: AudioCapturerGetReferenceClockResponder {
2610                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2611                            tx_id: header.tx_id,
2612                        },
2613                    })
2614                }
2615                0x732b2c496d521bcf => {
2616                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2617                    let mut req = fidl::new_empty!(AudioCapturerSetReferenceClockRequest, fdomain_client::fidl::FDomainResourceDialect);
2618                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
2619                    let control_handle = AudioCapturerControlHandle {
2620                        inner: this.inner.clone(),
2621                    };
2622                    Ok(AudioCapturerRequest::SetReferenceClock {reference_clock: req.reference_clock,
2623
2624                        control_handle,
2625                    })
2626                }
2627                0x42a16f392bd21b25 => {
2628                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2629                    let mut req = fidl::new_empty!(AudioCapturerSetUsageRequest, fdomain_client::fidl::FDomainResourceDialect);
2630                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
2631                    let control_handle = AudioCapturerControlHandle {
2632                        inner: this.inner.clone(),
2633                    };
2634                    Ok(AudioCapturerRequest::SetUsage {usage: req.usage,
2635
2636                        control_handle,
2637                    })
2638                }
2639                0x7a73e251b8d2382b => {
2640                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2641                    let mut req = fidl::new_empty!(AudioCapturerSetUsage2Request, fdomain_client::fidl::FDomainResourceDialect);
2642                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
2643                    let control_handle = AudioCapturerControlHandle {
2644                        inner: this.inner.clone(),
2645                    };
2646                    Ok(AudioCapturerRequest::SetUsage2 {usage: req.usage,
2647
2648                        control_handle,
2649                    })
2650                }
2651                0x5dcaaa670b433088 => {
2652                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2653                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
2654                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2655                    let control_handle = AudioCapturerControlHandle {
2656                        inner: this.inner.clone(),
2657                    };
2658                    Ok(AudioCapturerRequest::GetStreamType {
2659                        responder: AudioCapturerGetStreamTypeResponder {
2660                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2661                            tx_id: header.tx_id,
2662                        },
2663                    })
2664                }
2665                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2666                    Ok(AudioCapturerRequest::_UnknownMethod {
2667                        ordinal: header.ordinal,
2668                        control_handle: AudioCapturerControlHandle { inner: this.inner.clone() },
2669                        method_type: fidl::MethodType::OneWay,
2670                    })
2671                }
2672                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2673                    this.inner.send_framework_err(
2674                        fidl::encoding::FrameworkErr::UnknownMethod,
2675                        header.tx_id,
2676                        header.ordinal,
2677                        header.dynamic_flags(),
2678                        (bytes, handles),
2679                    )?;
2680                    Ok(AudioCapturerRequest::_UnknownMethod {
2681                        ordinal: header.ordinal,
2682                        control_handle: AudioCapturerControlHandle { inner: this.inner.clone() },
2683                        method_type: fidl::MethodType::TwoWay,
2684                    })
2685                }
2686                _ => Err(fidl::Error::UnknownOrdinal {
2687                    ordinal: header.ordinal,
2688                    protocol_name: <AudioCapturerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
2689                }),
2690            }))
2691            },
2692        )
2693    }
2694}
2695
2696/// AudioCapturer
2697///
2698/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
2699/// CreateAudioCapturer method, which may be used by clients to capture audio
2700/// from either the current default audio input device, or the current default
2701/// audio output device depending on the flags passed during creation.
2702///
2703/// **Format support**
2704///
2705/// See (Get|Set)StreamType below. By default, the captured stream type will be
2706/// initially determined by the currently configured stream type of the source
2707/// that the AudioCapturer was bound to at creation time. Users may either fetch
2708/// this type using GetStreamType, or they may choose to have the media
2709/// resampled or converted to a type of their choosing by calling SetStreamType.
2710/// Note: the stream type may only be set while the system is not running,
2711/// meaning that there are no pending capture regions (specified using CaptureAt)
2712/// and that the system is not currently running in 'async' capture mode.
2713///
2714/// **Buffers and memory management**
2715///
2716/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
2717/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
2718/// following requirements related to the management of the payload buffer.
2719///
2720/// + The payload buffer must be supplied before any capture operation may
2721///   start. Any attempt to start capture (via either CaptureAt or
2722///   StartAsyncCapture) before a payload buffer has been established is an
2723///   error.
2724/// + The payload buffer may not be changed while there are any capture
2725///   operations pending.
2726/// + The stream type may not be changed after the payload buffer has been set.
2727/// + The payload buffer must be an integral number of audio frame sizes (in
2728///   bytes)
2729/// + When running in 'async' mode (see below), the payload buffer must be at
2730///   least as large as twice the frames_per_packet size specified during
2731///   StartAsyncCapture.
2732/// + The handle to the payload buffer supplied by the user must be readable,
2733///   writable, mappable and transferable.
2734/// + Users should always treat the payload buffer as read-only.
2735///
2736/// **Synchronous vs. Asynchronous capture mode**
2737///
2738/// The AudioCapturer interface can be used in one of two mutually exclusive
2739/// modes: Synchronous and Asynchronous. A description of each mode and their
2740/// tradeoffs is given below.
2741///
2742/// **Synchronous mode**
2743///
2744/// By default, AudioCapturer instances are running in 'sync' mode. They will
2745/// only capture data when a user supplies at least one region to capture into
2746/// using the CaptureAt method. Regions supplied in this way will be filled in
2747/// the order that they are received and returned to the client as StreamPackets
2748/// via the return value of the CaptureAt method. If an AudioCapturer instance
2749/// has data to capture, but no place to put it (because there are no more
2750/// pending regions to fill), the next payload generated will indicate that their
2751/// has been an overflow by setting the Discontinuity flag on the next produced
2752/// StreamPacket. Synchronous mode may not be used in conjunction with
2753/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
2754/// the system still regions supplied by CaptureAt waiting to be filled.
2755///
2756/// If a user has supplied regions to be filled by the AudioCapturer instance in
2757/// the past, but wishes to reclaim those regions, they may do so using the
2758/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
2759/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
2760/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
2761/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
2762/// an OnEndOfStream event will be produced. While an AudioCapturer will never
2763/// overwrite any region of the payload buffer after a completed region is
2764/// returned, it may overwrite the unfilled portions of a partially filled
2765/// buffer which has been returned as a result of a DiscardAllPackets operation.
2766///
2767/// **Asynchronous mode**
2768///
2769/// While running in 'async' mode, clients do not need to explicitly supply
2770/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
2771/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
2772/// callback interface and the number of frames to capture per-callback. Once
2773/// running in async mode, the AudioCapturer instance will identify which
2774/// payload buffer regions to capture into, capture the specified number of
2775/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
2776/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
2777/// 'sync' mode using the StopAsyncCapture method.
2778///
2779/// It is considered an error to attempt any of the following operations.
2780///
2781/// + To attempt to enter 'async' capture mode when no payload buffer has been
2782///   established.
2783/// + To specify a number of frames to capture per payload which does not permit
2784///   at least two contiguous capture payloads to exist in the established
2785///   shared payload buffer simultaneously.
2786/// + To send a region to capture into using the CaptureAt method while the
2787///   AudioCapturer instance is running in 'async' mode.
2788/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
2789///   running in 'async' mode.
2790/// + To attempt to re-start 'async' mode capturing without having first
2791///   stopped.
2792/// + To attempt any operation except for SetGain while in the process of
2793///   stopping.
2794///
2795/// **Synchronizing with a StopAsyncCapture operation**
2796///
2797/// Stopping asynchronous capture mode and returning to synchronous capture mode
2798/// is an operation which takes time. Aside from SetGain, users may not call any
2799/// other methods on the AudioCapturer interface after calling StopAsyncCapture
2800/// (including calling StopAsyncCapture again) until after the stop operation has
2801/// completed. Because of this, it is important for users to be able to
2802/// synchronize with the stop operation. Two mechanisms are provided for doing
2803/// so.
2804///
2805/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
2806/// callback has been called, they can be certain that stop operation is complete
2807/// and that the AudioCapturer instance has returned to synchronous operation
2808/// mode.
2809///
2810/// The second way to determine that a stop operation has completed is to use the
2811/// flags on the packets which get delivered via the user-supplied
2812/// AudioCapturerCallback interface after calling StopAsyncCapture. When
2813/// asked to stop, any partially filled packet will be returned to the user, and
2814/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
2815/// set on it to indicate that this is the final frame in the sequence. If
2816/// there is no partially filled packet to return, the AudioCapturer will
2817/// synthesize an empty packet with no timestamp, and offset/length set to zero,
2818/// in order to deliver a packet with the end-of-stream flag set on it. Once
2819/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
2820/// has finished the stop operation and returned to synchronous operating mode.
2821///
2822/// **Timing and Overflows**
2823///
2824/// All media packets produced by an AudioCapturer instance will have their PTS
2825/// field filled out with the capture time of the audio expressed as a timestamp
2826/// given by the reference clock timeline. Note: this timestamp is actually a
2827/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
2828/// PTS) and is meant to represent the underlying system's best estimate of the
2829/// capture time of the first frame of audio, including all outboard and hardware
2830/// introduced buffering delay. As a result, all timestamps produced by an
2831/// AudioCapturer should be expected to be in the past relative to 'now' on the
2832/// stream's reference clock timeline.
2833///
2834/// The one exception to the "everything has an explicit timestamp" rule is when
2835/// discarding submitted regions while operating in synchronous mode. Discarded
2836/// packets have no data in them, but FIDL demands that all pending
2837/// method-return-value callbacks be executed. Because of this, the regions will
2838/// be returned to the user, but their timestamps will be set to
2839/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
2840/// partially filled payload will have a valid timestamp, but a payload size
2841/// smaller than originally requested. The final discarded payload (if there
2842/// were any to discard) will be followed by an OnEndOfStream event.
2843///
2844/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
2845/// the first frame of audio contained in the second packet was captured exactly
2846/// one nominal frame time after the final frame of audio in the first packet.
2847/// If this relationship does not hold, the second StreamPacket will have the
2848/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
2849///
2850/// Even though explicit timestamps are provided on every StreamPacket produced,
2851/// users who have very precise timing requirements are encouraged to always
2852/// reason about time by counting frames delivered since the last discontinuity,
2853/// rather than simply using the raw capture timestamps. This is because the
2854/// explicit timestamps written on continuous packets may have a small amount of
2855/// rounding error based on whether or not the units of the capture timeline
2856/// reference clock are divisible by the chosen audio frame rate.
2857///
2858/// Users should always expect the first StreamPacket produced by an
2859/// AudioCapturer to have the discontinuous flag set on it (as there is no
2860/// previous packet to be continuous with). Similarly, the first StreamPacket
2861/// after a DiscardAllPackets or a Stop/Start cycle will always be
2862/// discontinuous. After that, there are only two reasons that a StreamPacket
2863/// will ever be discontinuous:
2864///
2865/// 1. The user is operating in synchronous mode and does not supply regions to
2866///    be filled quickly enough. If the next continuous frame of data has not
2867///    been captured by the time it needs to be purged from the source buffers,
2868///    an overflow has occurred and the AudioCapturer will flag the next captured
2869///    region as discontinuous.
2870/// 2. The user is operating in asynchronous mode and some internal error
2871///    prevents the AudioCapturer instance from capturing the next frame of audio
2872///    in a continuous fashion. This might be high system load or a hardware
2873///    error, but in general it is something which should never normally happen.
2874///    In practice, however, if it does, the next produced packet will be flagged
2875///    as being discontinuous.
2876///
2877/// **Synchronous vs. Asynchronous Trade-offs**
2878///
2879/// The choice of operating in synchronous vs. asynchronous mode is up to the
2880/// user, and depending on the user's requirements, there are some advantages and
2881/// disadvantages to each choice.
2882///
2883/// Synchronous mode requires only a single Zircon channel under the hood and can
2884/// achieve some small savings because of this. In addition, the user has
2885/// complete control over the buffer management. Users specify exactly where
2886/// audio will be captured to and in what order. Because of this, if users do
2887/// not need to always be capturing, it is simple to stop and restart the capture
2888/// later (just by ceasing to supply packets, then resuming later on). Payloads
2889/// do not need to be uniform in size either, clients may specify payloads of
2890/// whatever granularity is appropriate.
2891///
2892/// The primary downside of operating in synchronous mode is that two messages
2893/// will need to be sent for every packet to be captured. One to inform the
2894/// AudioCapturer of the instance to capture into, and one to inform the user
2895/// that the packet has been captured. This may end up increasing overhead and
2896/// potentially complicating client designs.
2897///
2898/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
2899/// however, when operating in 'async' mode, AudioCapturer instances have no way
2900/// of knowing if a user is processing the StreamPackets being sent in a timely
2901/// fashion, and no way of automatically detecting an overflow condition. Users
2902/// of 'async' mode should be careful to use a buffer large enough to ensure that
2903/// they will be able to process their data before an AudioCapturer will be
2904/// forced to overwrite it.
2905#[derive(Debug)]
2906pub enum AudioCapturerRequest {
2907    /// Adds a payload buffer to the current buffer set associated with the
2908    /// connection. A `StreamPacket` struct reference a payload buffer in the
2909    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2910    ///
2911    /// A buffer with ID `id` must not be in the current set when this method is
2912    /// invoked, otherwise the service will close the connection.
2913    AddPayloadBuffer {
2914        id: u32,
2915        payload_buffer: fdomain_client::Vmo,
2916        control_handle: AudioCapturerControlHandle,
2917    },
2918    /// Removes a payload buffer from the current buffer set associated with the
2919    /// connection.
2920    ///
2921    /// A buffer with ID `id` must exist in the current set when this method is
2922    /// invoked, otherwise the service will will close the connection.
2923    RemovePayloadBuffer {
2924        id: u32,
2925        control_handle: AudioCapturerControlHandle,
2926    },
2927    /// Releases payload memory associated with a packet previously delivered
2928    /// via `OnPacketProduced`.
2929    ReleasePacket {
2930        packet: StreamPacket,
2931        control_handle: AudioCapturerControlHandle,
2932    },
2933    DiscardAllPackets {
2934        responder: AudioCapturerDiscardAllPacketsResponder,
2935    },
2936    DiscardAllPacketsNoReply {
2937        control_handle: AudioCapturerControlHandle,
2938    },
2939    /// Sets the stream type of the stream to be delivered. Causes the source
2940    /// material to be reformatted/resampled if needed in order to produce the
2941    /// requested stream type. Must be called before the payload buffer is
2942    /// established.
2943    SetPcmStreamType {
2944        stream_type: AudioStreamType,
2945        control_handle: AudioCapturerControlHandle,
2946    },
2947    /// Explicitly specifies a region of the shared payload buffer for the audio
2948    /// input to capture into.
2949    CaptureAt {
2950        payload_buffer_id: u32,
2951        payload_offset: u32,
2952        frames: u32,
2953        responder: AudioCapturerCaptureAtResponder,
2954    },
2955    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2956    /// packets of exactly 'frames_per_packet' number of frames each. The
2957    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2958    /// of produced packets.
2959    StartAsyncCapture {
2960        frames_per_packet: u32,
2961        control_handle: AudioCapturerControlHandle,
2962    },
2963    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2964    /// that may be used by the client if explicit synchronization is needed.
2965    StopAsyncCapture {
2966        responder: AudioCapturerStopAsyncCaptureResponder,
2967    },
2968    StopAsyncCaptureNoReply {
2969        control_handle: AudioCapturerControlHandle,
2970    },
2971    /// Binds to the gain control for this AudioCapturer.
2972    BindGainControl {
2973        gain_control_request:
2974            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
2975        control_handle: AudioCapturerControlHandle,
2976    },
2977    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2978    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2979    GetReferenceClock {
2980        responder: AudioCapturerGetReferenceClockResponder,
2981    },
2982    /// Sets the reference clock that controls this capturer's playback rate. If the input
2983    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2984    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2985    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2986    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2987    ///
2988    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2989    /// added. It also cannot be called a second time (even before capture).
2990    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2991    /// diverge at some later time, they should create a clone of the monotonic clock, set
2992    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2993    SetReferenceClock {
2994        reference_clock: Option<fdomain_client::Clock>,
2995        control_handle: AudioCapturerControlHandle,
2996    },
2997    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2998    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2999    SetUsage {
3000        usage: AudioCaptureUsage,
3001        control_handle: AudioCapturerControlHandle,
3002    },
3003    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3004    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3005    SetUsage2 {
3006        usage: AudioCaptureUsage2,
3007        control_handle: AudioCapturerControlHandle,
3008    },
3009    /// Gets the currently configured stream type. Note: for an AudioCapturer
3010    /// which was just created and has not yet had its stream type explicitly
3011    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3012    /// was created -- of the source (input or looped-back output) to which the
3013    /// AudioCapturer is bound. Even if this matches the client's desired format,
3014    /// `SetPcmStreamType` must still be called.
3015    GetStreamType {
3016        responder: AudioCapturerGetStreamTypeResponder,
3017    },
3018    /// An interaction was received which does not match any known method.
3019    #[non_exhaustive]
3020    _UnknownMethod {
3021        /// Ordinal of the method that was called.
3022        ordinal: u64,
3023        control_handle: AudioCapturerControlHandle,
3024        method_type: fidl::MethodType,
3025    },
3026}
3027
3028impl AudioCapturerRequest {
3029    #[allow(irrefutable_let_patterns)]
3030    pub fn into_add_payload_buffer(
3031        self,
3032    ) -> Option<(u32, fdomain_client::Vmo, AudioCapturerControlHandle)> {
3033        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3034        {
3035            Some((id, payload_buffer, control_handle))
3036        } else {
3037            None
3038        }
3039    }
3040
3041    #[allow(irrefutable_let_patterns)]
3042    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3043        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3044            Some((id, control_handle))
3045        } else {
3046            None
3047        }
3048    }
3049
3050    #[allow(irrefutable_let_patterns)]
3051    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3052        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3053            Some((packet, control_handle))
3054        } else {
3055            None
3056        }
3057    }
3058
3059    #[allow(irrefutable_let_patterns)]
3060    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3061        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3062            Some((responder))
3063        } else {
3064            None
3065        }
3066    }
3067
3068    #[allow(irrefutable_let_patterns)]
3069    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3070        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3071            Some((control_handle))
3072        } else {
3073            None
3074        }
3075    }
3076
3077    #[allow(irrefutable_let_patterns)]
3078    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3079        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3080            Some((stream_type, control_handle))
3081        } else {
3082            None
3083        }
3084    }
3085
3086    #[allow(irrefutable_let_patterns)]
3087    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3088        if let AudioCapturerRequest::CaptureAt {
3089            payload_buffer_id,
3090            payload_offset,
3091            frames,
3092            responder,
3093        } = self
3094        {
3095            Some((payload_buffer_id, payload_offset, frames, responder))
3096        } else {
3097            None
3098        }
3099    }
3100
3101    #[allow(irrefutable_let_patterns)]
3102    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3103        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3104        {
3105            Some((frames_per_packet, control_handle))
3106        } else {
3107            None
3108        }
3109    }
3110
3111    #[allow(irrefutable_let_patterns)]
3112    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3113        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3114            Some((responder))
3115        } else {
3116            None
3117        }
3118    }
3119
3120    #[allow(irrefutable_let_patterns)]
3121    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3122        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3123            Some((control_handle))
3124        } else {
3125            None
3126        }
3127    }
3128
3129    #[allow(irrefutable_let_patterns)]
3130    pub fn into_bind_gain_control(
3131        self,
3132    ) -> Option<(
3133        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
3134        AudioCapturerControlHandle,
3135    )> {
3136        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3137        {
3138            Some((gain_control_request, control_handle))
3139        } else {
3140            None
3141        }
3142    }
3143
3144    #[allow(irrefutable_let_patterns)]
3145    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3146        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3147            Some((responder))
3148        } else {
3149            None
3150        }
3151    }
3152
3153    #[allow(irrefutable_let_patterns)]
3154    pub fn into_set_reference_clock(
3155        self,
3156    ) -> Option<(Option<fdomain_client::Clock>, AudioCapturerControlHandle)> {
3157        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3158            Some((reference_clock, control_handle))
3159        } else {
3160            None
3161        }
3162    }
3163
3164    #[allow(irrefutable_let_patterns)]
3165    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3166        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3167            Some((usage, control_handle))
3168        } else {
3169            None
3170        }
3171    }
3172
3173    #[allow(irrefutable_let_patterns)]
3174    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3175        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3176            Some((usage, control_handle))
3177        } else {
3178            None
3179        }
3180    }
3181
3182    #[allow(irrefutable_let_patterns)]
3183    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3184        if let AudioCapturerRequest::GetStreamType { responder } = self {
3185            Some((responder))
3186        } else {
3187            None
3188        }
3189    }
3190
3191    /// Name of the method defined in FIDL
3192    pub fn method_name(&self) -> &'static str {
3193        match *self {
3194            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3195            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3196            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3197            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3198            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3199            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3200            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3201            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3202            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3203            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3204            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3205            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3206            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3207            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3208            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3209            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3210            AudioCapturerRequest::_UnknownMethod {
3211                method_type: fidl::MethodType::OneWay, ..
3212            } => "unknown one-way method",
3213            AudioCapturerRequest::_UnknownMethod {
3214                method_type: fidl::MethodType::TwoWay, ..
3215            } => "unknown two-way method",
3216        }
3217    }
3218}
3219
3220#[derive(Debug, Clone)]
3221pub struct AudioCapturerControlHandle {
3222    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3223}
3224
3225impl AudioCapturerControlHandle {
3226    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3227        self.inner.shutdown_with_epitaph(status.into())
3228    }
3229}
3230
3231impl fdomain_client::fidl::ControlHandle for AudioCapturerControlHandle {
3232    fn shutdown(&self) {
3233        self.inner.shutdown()
3234    }
3235
3236    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3237        self.inner.shutdown_with_epitaph(status)
3238    }
3239
3240    fn is_closed(&self) -> bool {
3241        self.inner.channel().is_closed()
3242    }
3243    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
3244        self.inner.channel().on_closed()
3245    }
3246}
3247
3248impl AudioCapturerControlHandle {
3249    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3250        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3251            (packet,),
3252            0,
3253            0x6bbe69746a3c8bd9,
3254            fidl::encoding::DynamicFlags::empty(),
3255        )
3256    }
3257
3258    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3259        self.inner.send::<fidl::encoding::EmptyPayload>(
3260            (),
3261            0,
3262            0x550e69b41d03e2c2,
3263            fidl::encoding::DynamicFlags::empty(),
3264        )
3265    }
3266}
3267
3268#[must_use = "FIDL methods require a response to be sent"]
3269#[derive(Debug)]
3270pub struct AudioCapturerDiscardAllPacketsResponder {
3271    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3272    tx_id: u32,
3273}
3274
3275/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3276/// if the responder is dropped without sending a response, so that the client
3277/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3278impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3279    fn drop(&mut self) {
3280        self.control_handle.shutdown();
3281        // Safety: drops once, never accessed again
3282        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3283    }
3284}
3285
3286impl fdomain_client::fidl::Responder for AudioCapturerDiscardAllPacketsResponder {
3287    type ControlHandle = AudioCapturerControlHandle;
3288
3289    fn control_handle(&self) -> &AudioCapturerControlHandle {
3290        &self.control_handle
3291    }
3292
3293    fn drop_without_shutdown(mut self) {
3294        // Safety: drops once, never accessed again due to mem::forget
3295        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3296        // Prevent Drop from running (which would shut down the channel)
3297        std::mem::forget(self);
3298    }
3299}
3300
3301impl AudioCapturerDiscardAllPacketsResponder {
3302    /// Sends a response to the FIDL transaction.
3303    ///
3304    /// Sets the channel to shutdown if an error occurs.
3305    pub fn send(self) -> Result<(), fidl::Error> {
3306        let _result = self.send_raw();
3307        if _result.is_err() {
3308            self.control_handle.shutdown();
3309        }
3310        self.drop_without_shutdown();
3311        _result
3312    }
3313
3314    /// Similar to "send" but does not shutdown the channel if an error occurs.
3315    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3316        let _result = self.send_raw();
3317        self.drop_without_shutdown();
3318        _result
3319    }
3320
3321    fn send_raw(&self) -> Result<(), fidl::Error> {
3322        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3323            (),
3324            self.tx_id,
3325            0x27afd605e97b09d2,
3326            fidl::encoding::DynamicFlags::empty(),
3327        )
3328    }
3329}
3330
3331#[must_use = "FIDL methods require a response to be sent"]
3332#[derive(Debug)]
3333pub struct AudioCapturerCaptureAtResponder {
3334    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3335    tx_id: u32,
3336}
3337
3338/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3339/// if the responder is dropped without sending a response, so that the client
3340/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3341impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3342    fn drop(&mut self) {
3343        self.control_handle.shutdown();
3344        // Safety: drops once, never accessed again
3345        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3346    }
3347}
3348
3349impl fdomain_client::fidl::Responder for AudioCapturerCaptureAtResponder {
3350    type ControlHandle = AudioCapturerControlHandle;
3351
3352    fn control_handle(&self) -> &AudioCapturerControlHandle {
3353        &self.control_handle
3354    }
3355
3356    fn drop_without_shutdown(mut self) {
3357        // Safety: drops once, never accessed again due to mem::forget
3358        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3359        // Prevent Drop from running (which would shut down the channel)
3360        std::mem::forget(self);
3361    }
3362}
3363
3364impl AudioCapturerCaptureAtResponder {
3365    /// Sends a response to the FIDL transaction.
3366    ///
3367    /// Sets the channel to shutdown if an error occurs.
3368    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3369        let _result = self.send_raw(captured_packet);
3370        if _result.is_err() {
3371            self.control_handle.shutdown();
3372        }
3373        self.drop_without_shutdown();
3374        _result
3375    }
3376
3377    /// Similar to "send" but does not shutdown the channel if an error occurs.
3378    pub fn send_no_shutdown_on_err(
3379        self,
3380        mut captured_packet: &StreamPacket,
3381    ) -> Result<(), fidl::Error> {
3382        let _result = self.send_raw(captured_packet);
3383        self.drop_without_shutdown();
3384        _result
3385    }
3386
3387    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3388        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
3389            (captured_packet,),
3390            self.tx_id,
3391            0x784e25df72cea780,
3392            fidl::encoding::DynamicFlags::empty(),
3393        )
3394    }
3395}
3396
3397#[must_use = "FIDL methods require a response to be sent"]
3398#[derive(Debug)]
3399pub struct AudioCapturerStopAsyncCaptureResponder {
3400    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3401    tx_id: u32,
3402}
3403
3404/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3405/// if the responder is dropped without sending a response, so that the client
3406/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3407impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
3408    fn drop(&mut self) {
3409        self.control_handle.shutdown();
3410        // Safety: drops once, never accessed again
3411        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3412    }
3413}
3414
3415impl fdomain_client::fidl::Responder for AudioCapturerStopAsyncCaptureResponder {
3416    type ControlHandle = AudioCapturerControlHandle;
3417
3418    fn control_handle(&self) -> &AudioCapturerControlHandle {
3419        &self.control_handle
3420    }
3421
3422    fn drop_without_shutdown(mut self) {
3423        // Safety: drops once, never accessed again due to mem::forget
3424        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3425        // Prevent Drop from running (which would shut down the channel)
3426        std::mem::forget(self);
3427    }
3428}
3429
3430impl AudioCapturerStopAsyncCaptureResponder {
3431    /// Sends a response to the FIDL transaction.
3432    ///
3433    /// Sets the channel to shutdown if an error occurs.
3434    pub fn send(self) -> Result<(), fidl::Error> {
3435        let _result = self.send_raw();
3436        if _result.is_err() {
3437            self.control_handle.shutdown();
3438        }
3439        self.drop_without_shutdown();
3440        _result
3441    }
3442
3443    /// Similar to "send" but does not shutdown the channel if an error occurs.
3444    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3445        let _result = self.send_raw();
3446        self.drop_without_shutdown();
3447        _result
3448    }
3449
3450    fn send_raw(&self) -> Result<(), fidl::Error> {
3451        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3452            (),
3453            self.tx_id,
3454            0x5bfc8790a8cef8cb,
3455            fidl::encoding::DynamicFlags::empty(),
3456        )
3457    }
3458}
3459
3460#[must_use = "FIDL methods require a response to be sent"]
3461#[derive(Debug)]
3462pub struct AudioCapturerGetReferenceClockResponder {
3463    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3464    tx_id: u32,
3465}
3466
3467/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3468/// if the responder is dropped without sending a response, so that the client
3469/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3470impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
3471    fn drop(&mut self) {
3472        self.control_handle.shutdown();
3473        // Safety: drops once, never accessed again
3474        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3475    }
3476}
3477
3478impl fdomain_client::fidl::Responder for AudioCapturerGetReferenceClockResponder {
3479    type ControlHandle = AudioCapturerControlHandle;
3480
3481    fn control_handle(&self) -> &AudioCapturerControlHandle {
3482        &self.control_handle
3483    }
3484
3485    fn drop_without_shutdown(mut self) {
3486        // Safety: drops once, never accessed again due to mem::forget
3487        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3488        // Prevent Drop from running (which would shut down the channel)
3489        std::mem::forget(self);
3490    }
3491}
3492
3493impl AudioCapturerGetReferenceClockResponder {
3494    /// Sends a response to the FIDL transaction.
3495    ///
3496    /// Sets the channel to shutdown if an error occurs.
3497    pub fn send(self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
3498        let _result = self.send_raw(reference_clock);
3499        if _result.is_err() {
3500            self.control_handle.shutdown();
3501        }
3502        self.drop_without_shutdown();
3503        _result
3504    }
3505
3506    /// Similar to "send" but does not shutdown the channel if an error occurs.
3507    pub fn send_no_shutdown_on_err(
3508        self,
3509        mut reference_clock: fdomain_client::Clock,
3510    ) -> Result<(), fidl::Error> {
3511        let _result = self.send_raw(reference_clock);
3512        self.drop_without_shutdown();
3513        _result
3514    }
3515
3516    fn send_raw(&self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
3517        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
3518            (reference_clock,),
3519            self.tx_id,
3520            0x50d037aa5a4b4d71,
3521            fidl::encoding::DynamicFlags::empty(),
3522        )
3523    }
3524}
3525
3526#[must_use = "FIDL methods require a response to be sent"]
3527#[derive(Debug)]
3528pub struct AudioCapturerGetStreamTypeResponder {
3529    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3530    tx_id: u32,
3531}
3532
3533/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3534/// if the responder is dropped without sending a response, so that the client
3535/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3536impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
3537    fn drop(&mut self) {
3538        self.control_handle.shutdown();
3539        // Safety: drops once, never accessed again
3540        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3541    }
3542}
3543
3544impl fdomain_client::fidl::Responder for AudioCapturerGetStreamTypeResponder {
3545    type ControlHandle = AudioCapturerControlHandle;
3546
3547    fn control_handle(&self) -> &AudioCapturerControlHandle {
3548        &self.control_handle
3549    }
3550
3551    fn drop_without_shutdown(mut self) {
3552        // Safety: drops once, never accessed again due to mem::forget
3553        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3554        // Prevent Drop from running (which would shut down the channel)
3555        std::mem::forget(self);
3556    }
3557}
3558
3559impl AudioCapturerGetStreamTypeResponder {
3560    /// Sends a response to the FIDL transaction.
3561    ///
3562    /// Sets the channel to shutdown if an error occurs.
3563    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3564        let _result = self.send_raw(stream_type);
3565        if _result.is_err() {
3566            self.control_handle.shutdown();
3567        }
3568        self.drop_without_shutdown();
3569        _result
3570    }
3571
3572    /// Similar to "send" but does not shutdown the channel if an error occurs.
3573    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3574        let _result = self.send_raw(stream_type);
3575        self.drop_without_shutdown();
3576        _result
3577    }
3578
3579    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
3580        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
3581            (stream_type,),
3582            self.tx_id,
3583            0x5dcaaa670b433088,
3584            fidl::encoding::DynamicFlags::empty(),
3585        )
3586    }
3587}
3588
3589#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3590pub struct AudioConsumerMarker;
3591
3592impl fdomain_client::fidl::ProtocolMarker for AudioConsumerMarker {
3593    type Proxy = AudioConsumerProxy;
3594    type RequestStream = AudioConsumerRequestStream;
3595
3596    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
3597}
3598
3599pub trait AudioConsumerProxyInterface: Send + Sync {
3600    fn r#create_stream_sink(
3601        &self,
3602        buffers: Vec<fdomain_client::Vmo>,
3603        stream_type: &AudioStreamType,
3604        compression: Option<&Compression>,
3605        stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3606    ) -> Result<(), fidl::Error>;
3607    fn r#start(
3608        &self,
3609        flags: AudioConsumerStartFlags,
3610        reference_time: i64,
3611        media_time: i64,
3612    ) -> Result<(), fidl::Error>;
3613    fn r#stop(&self) -> Result<(), fidl::Error>;
3614    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
3615    fn r#bind_volume_control(
3616        &self,
3617        volume_control_request: fdomain_client::fidl::ServerEnd<
3618            fdomain_fuchsia_media_audio::VolumeControlMarker,
3619        >,
3620    ) -> Result<(), fidl::Error>;
3621    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
3622        + Send;
3623    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
3624}
3625
3626#[derive(Debug, Clone)]
3627pub struct AudioConsumerProxy {
3628    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
3629}
3630
3631impl fdomain_client::fidl::Proxy for AudioConsumerProxy {
3632    type Protocol = AudioConsumerMarker;
3633
3634    fn from_channel(inner: fdomain_client::Channel) -> Self {
3635        Self::new(inner)
3636    }
3637
3638    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
3639        self.client.into_channel().map_err(|client| Self { client })
3640    }
3641
3642    fn as_channel(&self) -> &fdomain_client::Channel {
3643        self.client.as_channel()
3644    }
3645}
3646
3647impl AudioConsumerProxy {
3648    /// Create a new Proxy for fuchsia.media/AudioConsumer.
3649    pub fn new(channel: fdomain_client::Channel) -> Self {
3650        let protocol_name =
3651            <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
3652        Self { client: fidl::client::Client::new(channel, protocol_name) }
3653    }
3654
3655    /// Get a Stream of events from the remote end of the protocol.
3656    ///
3657    /// # Panics
3658    ///
3659    /// Panics if the event stream was already taken.
3660    pub fn take_event_stream(&self) -> AudioConsumerEventStream {
3661        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
3662    }
3663
3664    /// Creates a `StreamSink` for the consumer with the indicated properties.
3665    ///
3666    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
3667    /// sequentially rather than concurrently. The first stream sink that's created using this
3668    /// method is used as the sole source of packets incoming to the logical consumer until that
3669    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
3670    /// the second stream sink is used, and so on.
3671    ///
3672    /// If an unsupported compression type is supplied, the
3673    /// `stream_sink_request` request will be closed with an epitaph value of
3674    /// `ZX_ERR_INVALID_ARGS`.
3675    pub fn r#create_stream_sink(
3676        &self,
3677        mut buffers: Vec<fdomain_client::Vmo>,
3678        mut stream_type: &AudioStreamType,
3679        mut compression: Option<&Compression>,
3680        mut stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3681    ) -> Result<(), fidl::Error> {
3682        AudioConsumerProxyInterface::r#create_stream_sink(
3683            self,
3684            buffers,
3685            stream_type,
3686            compression,
3687            stream_sink_request,
3688        )
3689    }
3690
3691    /// Starts rendering as indicated by `flags`.
3692    ///
3693    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
3694    /// Typically, this is the timestamp of the first packet that will be
3695    /// rendered. If packets will be supplied with no timestamps, this value
3696    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
3697    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
3698    ///     1. When starting for the first time, the default media time is the
3699    ///        timestamp on the first packet sent to the stream sink.
3700    ///     2. When resuming after stop, the default media time is the media
3701    ///        time at which the stream stopped.
3702    ///
3703    /// `reference_time` is the monotonic system time at which rendering should
3704    /// be started. For supply-driven sources, this must be the time at which
3705    /// the first packet was (or will be) sent plus a lead time, which must be
3706    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
3707    /// sources, the client must ensure that the lead time requirement is met at
3708    /// the start time.  Passing the default value of 0 for `reference_time`
3709    /// causes the consumer to choose a start time based on the availability of
3710    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
3711    /// specified.
3712    ///
3713    /// The actual start time will be reflected in the updated status.
3714    pub fn r#start(
3715        &self,
3716        mut flags: AudioConsumerStartFlags,
3717        mut reference_time: i64,
3718        mut media_time: i64,
3719    ) -> Result<(), fidl::Error> {
3720        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
3721    }
3722
3723    /// Stops rendering as soon as possible after this method is called. The actual stop time will
3724    /// be reflected in the updated status.
3725    pub fn r#stop(&self) -> Result<(), fidl::Error> {
3726        AudioConsumerProxyInterface::r#stop(self)
3727    }
3728
3729    /// Requests to change the playback rate of the renderer. 1.0 means normal
3730    /// playback. Negative rates are not supported. The new rate will be
3731    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
3732    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
3733        AudioConsumerProxyInterface::r#set_rate(self, rate)
3734    }
3735
3736    /// Binds to this `AudioConsumer` volume control for control and notifications.
3737    pub fn r#bind_volume_control(
3738        &self,
3739        mut volume_control_request: fdomain_client::fidl::ServerEnd<
3740            fdomain_fuchsia_media_audio::VolumeControlMarker,
3741        >,
3742    ) -> Result<(), fidl::Error> {
3743        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
3744    }
3745
3746    /// Gets the current status of the consumer using the long get pattern. The consumer responds
3747    /// to this method when the status changes - initially with respect to the initial status value
3748    /// and thereafter with respect to the previously-reported status value.
3749    pub fn r#watch_status(
3750        &self,
3751    ) -> fidl::client::QueryResponseFut<
3752        AudioConsumerStatus,
3753        fdomain_client::fidl::FDomainResourceDialect,
3754    > {
3755        AudioConsumerProxyInterface::r#watch_status(self)
3756    }
3757}
3758
3759impl AudioConsumerProxyInterface for AudioConsumerProxy {
3760    fn r#create_stream_sink(
3761        &self,
3762        mut buffers: Vec<fdomain_client::Vmo>,
3763        mut stream_type: &AudioStreamType,
3764        mut compression: Option<&Compression>,
3765        mut stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
3766    ) -> Result<(), fidl::Error> {
3767        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
3768            (buffers.as_mut(), stream_type, compression, stream_sink_request),
3769            0x525b3b97fdf7d884,
3770            fidl::encoding::DynamicFlags::empty(),
3771        )
3772    }
3773
3774    fn r#start(
3775        &self,
3776        mut flags: AudioConsumerStartFlags,
3777        mut reference_time: i64,
3778        mut media_time: i64,
3779    ) -> Result<(), fidl::Error> {
3780        self.client.send::<AudioConsumerStartRequest>(
3781            (flags, reference_time, media_time),
3782            0x4fdbd44b3f2a3a3c,
3783            fidl::encoding::DynamicFlags::empty(),
3784        )
3785    }
3786
3787    fn r#stop(&self) -> Result<(), fidl::Error> {
3788        self.client.send::<fidl::encoding::EmptyPayload>(
3789            (),
3790            0x3d46c3741686c40d,
3791            fidl::encoding::DynamicFlags::empty(),
3792        )
3793    }
3794
3795    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
3796        self.client.send::<AudioConsumerSetRateRequest>(
3797            (rate,),
3798            0x45342b73968bfafe,
3799            fidl::encoding::DynamicFlags::empty(),
3800        )
3801    }
3802
3803    fn r#bind_volume_control(
3804        &self,
3805        mut volume_control_request: fdomain_client::fidl::ServerEnd<
3806            fdomain_fuchsia_media_audio::VolumeControlMarker,
3807        >,
3808    ) -> Result<(), fidl::Error> {
3809        self.client.send::<AudioConsumerBindVolumeControlRequest>(
3810            (volume_control_request,),
3811            0x6f1b01fd887f5748,
3812            fidl::encoding::DynamicFlags::empty(),
3813        )
3814    }
3815
3816    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
3817        AudioConsumerStatus,
3818        fdomain_client::fidl::FDomainResourceDialect,
3819    >;
3820    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
3821        fn _decode(
3822            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3823        ) -> Result<AudioConsumerStatus, fidl::Error> {
3824            let _response = fidl::client::decode_transaction_body::<
3825                AudioConsumerWatchStatusResponse,
3826                fdomain_client::fidl::FDomainResourceDialect,
3827                0x35cf702c721e2cc6,
3828            >(_buf?)?;
3829            Ok(_response.status)
3830        }
3831        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
3832            (),
3833            0x35cf702c721e2cc6,
3834            fidl::encoding::DynamicFlags::empty(),
3835            _decode,
3836        )
3837    }
3838}
3839
3840pub struct AudioConsumerEventStream {
3841    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
3842}
3843
3844impl std::marker::Unpin for AudioConsumerEventStream {}
3845
3846impl futures::stream::FusedStream for AudioConsumerEventStream {
3847    fn is_terminated(&self) -> bool {
3848        self.event_receiver.is_terminated()
3849    }
3850}
3851
3852impl futures::Stream for AudioConsumerEventStream {
3853    type Item = Result<AudioConsumerEvent, fidl::Error>;
3854
3855    fn poll_next(
3856        mut self: std::pin::Pin<&mut Self>,
3857        cx: &mut std::task::Context<'_>,
3858    ) -> std::task::Poll<Option<Self::Item>> {
3859        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3860            &mut self.event_receiver,
3861            cx
3862        )?) {
3863            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
3864            None => std::task::Poll::Ready(None),
3865        }
3866    }
3867}
3868
3869#[derive(Debug)]
3870pub enum AudioConsumerEvent {
3871    OnEndOfStream {},
3872}
3873
3874impl AudioConsumerEvent {
3875    #[allow(irrefutable_let_patterns)]
3876    pub fn into_on_end_of_stream(self) -> Option<()> {
3877        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
3878    }
3879
3880    /// Decodes a message buffer as a [`AudioConsumerEvent`].
3881    fn decode(
3882        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3883    ) -> Result<AudioConsumerEvent, fidl::Error> {
3884        let (bytes, _handles) = buf.split_mut();
3885        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3886        debug_assert_eq!(tx_header.tx_id, 0);
3887        match tx_header.ordinal {
3888            0x53a64e6d0e8f8a20 => {
3889                let mut out = fidl::new_empty!(
3890                    fidl::encoding::EmptyPayload,
3891                    fdomain_client::fidl::FDomainResourceDialect
3892                );
3893                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
3894                Ok((AudioConsumerEvent::OnEndOfStream {}))
3895            }
3896            _ => Err(fidl::Error::UnknownOrdinal {
3897                ordinal: tx_header.ordinal,
3898                protocol_name:
3899                    <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
3900            }),
3901        }
3902    }
3903}
3904
3905/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
3906pub struct AudioConsumerRequestStream {
3907    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3908    is_terminated: bool,
3909}
3910
3911impl std::marker::Unpin for AudioConsumerRequestStream {}
3912
3913impl futures::stream::FusedStream for AudioConsumerRequestStream {
3914    fn is_terminated(&self) -> bool {
3915        self.is_terminated
3916    }
3917}
3918
3919impl fdomain_client::fidl::RequestStream for AudioConsumerRequestStream {
3920    type Protocol = AudioConsumerMarker;
3921    type ControlHandle = AudioConsumerControlHandle;
3922
3923    fn from_channel(channel: fdomain_client::Channel) -> Self {
3924        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3925    }
3926
3927    fn control_handle(&self) -> Self::ControlHandle {
3928        AudioConsumerControlHandle { inner: self.inner.clone() }
3929    }
3930
3931    fn into_inner(
3932        self,
3933    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
3934    {
3935        (self.inner, self.is_terminated)
3936    }
3937
3938    fn from_inner(
3939        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
3940        is_terminated: bool,
3941    ) -> Self {
3942        Self { inner, is_terminated }
3943    }
3944}
3945
3946impl futures::Stream for AudioConsumerRequestStream {
3947    type Item = Result<AudioConsumerRequest, fidl::Error>;
3948
3949    fn poll_next(
3950        mut self: std::pin::Pin<&mut Self>,
3951        cx: &mut std::task::Context<'_>,
3952    ) -> std::task::Poll<Option<Self::Item>> {
3953        let this = &mut *self;
3954        if this.inner.check_shutdown(cx) {
3955            this.is_terminated = true;
3956            return std::task::Poll::Ready(None);
3957        }
3958        if this.is_terminated {
3959            panic!("polled AudioConsumerRequestStream after completion");
3960        }
3961        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
3962            |bytes, handles| {
3963                match this.inner.channel().read_etc(cx, bytes, handles) {
3964                    std::task::Poll::Ready(Ok(())) => {}
3965                    std::task::Poll::Pending => return std::task::Poll::Pending,
3966                    std::task::Poll::Ready(Err(None)) => {
3967                        this.is_terminated = true;
3968                        return std::task::Poll::Ready(None);
3969                    }
3970                    std::task::Poll::Ready(Err(Some(e))) => {
3971                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3972                            e.into(),
3973                        ))));
3974                    }
3975                }
3976
3977                // A message has been received from the channel
3978                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3979
3980                std::task::Poll::Ready(Some(match header.ordinal {
3981                0x525b3b97fdf7d884 => {
3982                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3983                    let mut req = fidl::new_empty!(AudioConsumerCreateStreamSinkRequest, fdomain_client::fidl::FDomainResourceDialect);
3984                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
3985                    let control_handle = AudioConsumerControlHandle {
3986                        inner: this.inner.clone(),
3987                    };
3988                    Ok(AudioConsumerRequest::CreateStreamSink {buffers: req.buffers,
3989stream_type: req.stream_type,
3990compression: req.compression,
3991stream_sink_request: req.stream_sink_request,
3992
3993                        control_handle,
3994                    })
3995                }
3996                0x4fdbd44b3f2a3a3c => {
3997                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3998                    let mut req = fidl::new_empty!(AudioConsumerStartRequest, fdomain_client::fidl::FDomainResourceDialect);
3999                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4000                    let control_handle = AudioConsumerControlHandle {
4001                        inner: this.inner.clone(),
4002                    };
4003                    Ok(AudioConsumerRequest::Start {flags: req.flags,
4004reference_time: req.reference_time,
4005media_time: req.media_time,
4006
4007                        control_handle,
4008                    })
4009                }
4010                0x3d46c3741686c40d => {
4011                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4012                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4013                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4014                    let control_handle = AudioConsumerControlHandle {
4015                        inner: this.inner.clone(),
4016                    };
4017                    Ok(AudioConsumerRequest::Stop {
4018                        control_handle,
4019                    })
4020                }
4021                0x45342b73968bfafe => {
4022                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4023                    let mut req = fidl::new_empty!(AudioConsumerSetRateRequest, fdomain_client::fidl::FDomainResourceDialect);
4024                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4025                    let control_handle = AudioConsumerControlHandle {
4026                        inner: this.inner.clone(),
4027                    };
4028                    Ok(AudioConsumerRequest::SetRate {rate: req.rate,
4029
4030                        control_handle,
4031                    })
4032                }
4033                0x6f1b01fd887f5748 => {
4034                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4035                    let mut req = fidl::new_empty!(AudioConsumerBindVolumeControlRequest, fdomain_client::fidl::FDomainResourceDialect);
4036                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4037                    let control_handle = AudioConsumerControlHandle {
4038                        inner: this.inner.clone(),
4039                    };
4040                    Ok(AudioConsumerRequest::BindVolumeControl {volume_control_request: req.volume_control_request,
4041
4042                        control_handle,
4043                    })
4044                }
4045                0x35cf702c721e2cc6 => {
4046                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4047                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
4048                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4049                    let control_handle = AudioConsumerControlHandle {
4050                        inner: this.inner.clone(),
4051                    };
4052                    Ok(AudioConsumerRequest::WatchStatus {
4053                        responder: AudioConsumerWatchStatusResponder {
4054                            control_handle: std::mem::ManuallyDrop::new(control_handle),
4055                            tx_id: header.tx_id,
4056                        },
4057                    })
4058                }
4059                _ => Err(fidl::Error::UnknownOrdinal {
4060                    ordinal: header.ordinal,
4061                    protocol_name: <AudioConsumerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4062                }),
4063            }))
4064            },
4065        )
4066    }
4067}
4068
4069/// Interface for playing and controlling audio.
4070#[derive(Debug)]
4071pub enum AudioConsumerRequest {
4072    /// Creates a `StreamSink` for the consumer with the indicated properties.
4073    ///
4074    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4075    /// sequentially rather than concurrently. The first stream sink that's created using this
4076    /// method is used as the sole source of packets incoming to the logical consumer until that
4077    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4078    /// the second stream sink is used, and so on.
4079    ///
4080    /// If an unsupported compression type is supplied, the
4081    /// `stream_sink_request` request will be closed with an epitaph value of
4082    /// `ZX_ERR_INVALID_ARGS`.
4083    CreateStreamSink {
4084        buffers: Vec<fdomain_client::Vmo>,
4085        stream_type: AudioStreamType,
4086        compression: Option<Box<Compression>>,
4087        stream_sink_request: fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
4088        control_handle: AudioConsumerControlHandle,
4089    },
4090    /// Starts rendering as indicated by `flags`.
4091    ///
4092    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4093    /// Typically, this is the timestamp of the first packet that will be
4094    /// rendered. If packets will be supplied with no timestamps, this value
4095    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4096    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4097    ///     1. When starting for the first time, the default media time is the
4098    ///        timestamp on the first packet sent to the stream sink.
4099    ///     2. When resuming after stop, the default media time is the media
4100    ///        time at which the stream stopped.
4101    ///
4102    /// `reference_time` is the monotonic system time at which rendering should
4103    /// be started. For supply-driven sources, this must be the time at which
4104    /// the first packet was (or will be) sent plus a lead time, which must be
4105    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4106    /// sources, the client must ensure that the lead time requirement is met at
4107    /// the start time.  Passing the default value of 0 for `reference_time`
4108    /// causes the consumer to choose a start time based on the availability of
4109    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4110    /// specified.
4111    ///
4112    /// The actual start time will be reflected in the updated status.
4113    Start {
4114        flags: AudioConsumerStartFlags,
4115        reference_time: i64,
4116        media_time: i64,
4117        control_handle: AudioConsumerControlHandle,
4118    },
4119    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4120    /// be reflected in the updated status.
4121    Stop { control_handle: AudioConsumerControlHandle },
4122    /// Requests to change the playback rate of the renderer. 1.0 means normal
4123    /// playback. Negative rates are not supported. The new rate will be
4124    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4125    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4126    /// Binds to this `AudioConsumer` volume control for control and notifications.
4127    BindVolumeControl {
4128        volume_control_request:
4129            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
4130        control_handle: AudioConsumerControlHandle,
4131    },
4132    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4133    /// to this method when the status changes - initially with respect to the initial status value
4134    /// and thereafter with respect to the previously-reported status value.
4135    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4136}
4137
4138impl AudioConsumerRequest {
4139    #[allow(irrefutable_let_patterns)]
4140    pub fn into_create_stream_sink(
4141        self,
4142    ) -> Option<(
4143        Vec<fdomain_client::Vmo>,
4144        AudioStreamType,
4145        Option<Box<Compression>>,
4146        fdomain_client::fidl::ServerEnd<StreamSinkMarker>,
4147        AudioConsumerControlHandle,
4148    )> {
4149        if let AudioConsumerRequest::CreateStreamSink {
4150            buffers,
4151            stream_type,
4152            compression,
4153            stream_sink_request,
4154            control_handle,
4155        } = self
4156        {
4157            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4158        } else {
4159            None
4160        }
4161    }
4162
4163    #[allow(irrefutable_let_patterns)]
4164    pub fn into_start(
4165        self,
4166    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4167        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4168            self
4169        {
4170            Some((flags, reference_time, media_time, control_handle))
4171        } else {
4172            None
4173        }
4174    }
4175
4176    #[allow(irrefutable_let_patterns)]
4177    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4178        if let AudioConsumerRequest::Stop { control_handle } = self {
4179            Some((control_handle))
4180        } else {
4181            None
4182        }
4183    }
4184
4185    #[allow(irrefutable_let_patterns)]
4186    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
4187        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
4188            Some((rate, control_handle))
4189        } else {
4190            None
4191        }
4192    }
4193
4194    #[allow(irrefutable_let_patterns)]
4195    pub fn into_bind_volume_control(
4196        self,
4197    ) -> Option<(
4198        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
4199        AudioConsumerControlHandle,
4200    )> {
4201        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
4202            self
4203        {
4204            Some((volume_control_request, control_handle))
4205        } else {
4206            None
4207        }
4208    }
4209
4210    #[allow(irrefutable_let_patterns)]
4211    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
4212        if let AudioConsumerRequest::WatchStatus { responder } = self {
4213            Some((responder))
4214        } else {
4215            None
4216        }
4217    }
4218
4219    /// Name of the method defined in FIDL
4220    pub fn method_name(&self) -> &'static str {
4221        match *self {
4222            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
4223            AudioConsumerRequest::Start { .. } => "start",
4224            AudioConsumerRequest::Stop { .. } => "stop",
4225            AudioConsumerRequest::SetRate { .. } => "set_rate",
4226            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
4227            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
4228        }
4229    }
4230}
4231
4232#[derive(Debug, Clone)]
4233pub struct AudioConsumerControlHandle {
4234    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4235}
4236
4237impl AudioConsumerControlHandle {
4238    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4239        self.inner.shutdown_with_epitaph(status.into())
4240    }
4241}
4242
4243impl fdomain_client::fidl::ControlHandle for AudioConsumerControlHandle {
4244    fn shutdown(&self) {
4245        self.inner.shutdown()
4246    }
4247
4248    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4249        self.inner.shutdown_with_epitaph(status)
4250    }
4251
4252    fn is_closed(&self) -> bool {
4253        self.inner.channel().is_closed()
4254    }
4255    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
4256        self.inner.channel().on_closed()
4257    }
4258}
4259
4260impl AudioConsumerControlHandle {
4261    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
4262        self.inner.send::<fidl::encoding::EmptyPayload>(
4263            (),
4264            0,
4265            0x53a64e6d0e8f8a20,
4266            fidl::encoding::DynamicFlags::empty(),
4267        )
4268    }
4269}
4270
4271#[must_use = "FIDL methods require a response to be sent"]
4272#[derive(Debug)]
4273pub struct AudioConsumerWatchStatusResponder {
4274    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
4275    tx_id: u32,
4276}
4277
4278/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
4279/// if the responder is dropped without sending a response, so that the client
4280/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4281impl std::ops::Drop for AudioConsumerWatchStatusResponder {
4282    fn drop(&mut self) {
4283        self.control_handle.shutdown();
4284        // Safety: drops once, never accessed again
4285        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4286    }
4287}
4288
4289impl fdomain_client::fidl::Responder for AudioConsumerWatchStatusResponder {
4290    type ControlHandle = AudioConsumerControlHandle;
4291
4292    fn control_handle(&self) -> &AudioConsumerControlHandle {
4293        &self.control_handle
4294    }
4295
4296    fn drop_without_shutdown(mut self) {
4297        // Safety: drops once, never accessed again due to mem::forget
4298        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4299        // Prevent Drop from running (which would shut down the channel)
4300        std::mem::forget(self);
4301    }
4302}
4303
4304impl AudioConsumerWatchStatusResponder {
4305    /// Sends a response to the FIDL transaction.
4306    ///
4307    /// Sets the channel to shutdown if an error occurs.
4308    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4309        let _result = self.send_raw(status);
4310        if _result.is_err() {
4311            self.control_handle.shutdown();
4312        }
4313        self.drop_without_shutdown();
4314        _result
4315    }
4316
4317    /// Similar to "send" but does not shutdown the channel if an error occurs.
4318    pub fn send_no_shutdown_on_err(
4319        self,
4320        mut status: &AudioConsumerStatus,
4321    ) -> Result<(), fidl::Error> {
4322        let _result = self.send_raw(status);
4323        self.drop_without_shutdown();
4324        _result
4325    }
4326
4327    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
4328        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
4329            (status,),
4330            self.tx_id,
4331            0x35cf702c721e2cc6,
4332            fidl::encoding::DynamicFlags::empty(),
4333        )
4334    }
4335}
4336
4337#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4338pub struct AudioCoreMarker;
4339
4340impl fdomain_client::fidl::ProtocolMarker for AudioCoreMarker {
4341    type Proxy = AudioCoreProxy;
4342    type RequestStream = AudioCoreRequestStream;
4343
4344    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
4345}
4346impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioCoreMarker {}
4347
4348pub trait AudioCoreProxyInterface: Send + Sync {
4349    fn r#create_audio_renderer(
4350        &self,
4351        audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4352    ) -> Result<(), fidl::Error>;
4353    fn r#create_audio_capturer_with_configuration(
4354        &self,
4355        stream_type: &AudioStreamType,
4356        configuration: &AudioCapturerConfiguration,
4357        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4358    ) -> Result<(), fidl::Error>;
4359    fn r#create_audio_capturer(
4360        &self,
4361        loopback: bool,
4362        audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4363    ) -> Result<(), fidl::Error>;
4364    fn r#set_render_usage_gain(
4365        &self,
4366        usage: AudioRenderUsage,
4367        gain_db: f32,
4368    ) -> Result<(), fidl::Error>;
4369    fn r#set_render_usage_gain2(
4370        &self,
4371        usage: AudioRenderUsage2,
4372        gain_db: f32,
4373    ) -> Result<(), fidl::Error>;
4374    fn r#set_capture_usage_gain(
4375        &self,
4376        usage: AudioCaptureUsage,
4377        gain_db: f32,
4378    ) -> Result<(), fidl::Error>;
4379    fn r#set_capture_usage_gain2(
4380        &self,
4381        usage: AudioCaptureUsage2,
4382        gain_db: f32,
4383    ) -> Result<(), fidl::Error>;
4384    fn r#bind_usage_volume_control(
4385        &self,
4386        usage: &Usage,
4387        volume_control: fdomain_client::fidl::ServerEnd<
4388            fdomain_fuchsia_media_audio::VolumeControlMarker,
4389        >,
4390    ) -> Result<(), fidl::Error>;
4391    fn r#bind_usage_volume_control2(
4392        &self,
4393        usage: &Usage2,
4394        volume_control: fdomain_client::fidl::ServerEnd<
4395            fdomain_fuchsia_media_audio::VolumeControlMarker,
4396        >,
4397    ) -> Result<(), fidl::Error>;
4398    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4399    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
4400    -> Self::GetVolumeFromDbResponseFut;
4401    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4402    fn r#get_volume_from_db2(
4403        &self,
4404        usage: &Usage2,
4405        gain_db: f32,
4406    ) -> Self::GetVolumeFromDb2ResponseFut;
4407    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4408    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
4409    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
4410    fn r#get_db_from_volume2(
4411        &self,
4412        usage: &Usage2,
4413        volume: f32,
4414    ) -> Self::GetDbFromVolume2ResponseFut;
4415    fn r#set_interaction(
4416        &self,
4417        active: &Usage,
4418        affected: &Usage,
4419        behavior: Behavior,
4420    ) -> Result<(), fidl::Error>;
4421    fn r#set_interaction2(
4422        &self,
4423        active: &Usage2,
4424        affected: &Usage2,
4425        behavior: Behavior,
4426    ) -> Result<(), fidl::Error>;
4427    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
4428    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
4429}
4430
4431#[derive(Debug, Clone)]
4432pub struct AudioCoreProxy {
4433    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
4434}
4435
4436impl fdomain_client::fidl::Proxy for AudioCoreProxy {
4437    type Protocol = AudioCoreMarker;
4438
4439    fn from_channel(inner: fdomain_client::Channel) -> Self {
4440        Self::new(inner)
4441    }
4442
4443    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
4444        self.client.into_channel().map_err(|client| Self { client })
4445    }
4446
4447    fn as_channel(&self) -> &fdomain_client::Channel {
4448        self.client.as_channel()
4449    }
4450}
4451
4452impl AudioCoreProxy {
4453    /// Create a new Proxy for fuchsia.media/AudioCore.
4454    pub fn new(channel: fdomain_client::Channel) -> Self {
4455        let protocol_name = <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
4456        Self { client: fidl::client::Client::new(channel, protocol_name) }
4457    }
4458
4459    /// Get a Stream of events from the remote end of the protocol.
4460    ///
4461    /// # Panics
4462    ///
4463    /// Panics if the event stream was already taken.
4464    pub fn take_event_stream(&self) -> AudioCoreEventStream {
4465        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
4466    }
4467
4468    /// Creates an AudioRenderer which outputs audio to the default device.
4469    pub fn r#create_audio_renderer(
4470        &self,
4471        mut audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4472    ) -> Result<(), fidl::Error> {
4473        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
4474    }
4475
4476    /// Creates an AudioCapturer according to the given requirements.
4477    ///
4478    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
4479    /// It causes the source material to be reformatted/resampled if needed
4480    /// in order to produce the requested stream type.
4481    ///
4482    /// `usage` is used by Fuchsia to make decisions about user experience.
4483    /// See `AudioCaptureUsage` for more details.
4484    ///
4485    /// `configuration` must be initialized to a variant, or no capturer
4486    /// can be created.
4487    pub fn r#create_audio_capturer_with_configuration(
4488        &self,
4489        mut stream_type: &AudioStreamType,
4490        mut configuration: &AudioCapturerConfiguration,
4491        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4492    ) -> Result<(), fidl::Error> {
4493        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
4494            self,
4495            stream_type,
4496            configuration,
4497            audio_capturer_request,
4498        )
4499    }
4500
4501    /// Creates an AudioCapturer which either captures from the current default
4502    /// audio input device, or loops-back from the current default audio output
4503    /// device based on value passed for the loopback flag.
4504    pub fn r#create_audio_capturer(
4505        &self,
4506        mut loopback: bool,
4507        mut audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4508    ) -> Result<(), fidl::Error> {
4509        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
4510    }
4511
4512    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
4513    pub fn r#set_render_usage_gain(
4514        &self,
4515        mut usage: AudioRenderUsage,
4516        mut gain_db: f32,
4517    ) -> Result<(), fidl::Error> {
4518        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
4519    }
4520
4521    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
4522    pub fn r#set_render_usage_gain2(
4523        &self,
4524        mut usage: AudioRenderUsage2,
4525        mut gain_db: f32,
4526    ) -> Result<(), fidl::Error> {
4527        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
4528    }
4529
4530    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
4531    pub fn r#set_capture_usage_gain(
4532        &self,
4533        mut usage: AudioCaptureUsage,
4534        mut gain_db: f32,
4535    ) -> Result<(), fidl::Error> {
4536        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
4537    }
4538
4539    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
4540    pub fn r#set_capture_usage_gain2(
4541        &self,
4542        mut usage: AudioCaptureUsage2,
4543        mut gain_db: f32,
4544    ) -> Result<(), fidl::Error> {
4545        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
4546    }
4547
4548    /// Binds to a volume control protocol for the given usage.
4549    pub fn r#bind_usage_volume_control(
4550        &self,
4551        mut usage: &Usage,
4552        mut volume_control: fdomain_client::fidl::ServerEnd<
4553            fdomain_fuchsia_media_audio::VolumeControlMarker,
4554        >,
4555    ) -> Result<(), fidl::Error> {
4556        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
4557    }
4558
4559    /// Binds to a volume control protocol for the given usage.
4560    pub fn r#bind_usage_volume_control2(
4561        &self,
4562        mut usage: &Usage2,
4563        mut volume_control: fdomain_client::fidl::ServerEnd<
4564            fdomain_fuchsia_media_audio::VolumeControlMarker,
4565        >,
4566    ) -> Result<(), fidl::Error> {
4567        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
4568    }
4569
4570    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
4571    /// `usage`. This is the same mapping as used by the VolumeControl from
4572    /// `BindUsageVolumeControl`.
4573    pub fn r#get_volume_from_db(
4574        &self,
4575        mut usage: &Usage,
4576        mut gain_db: f32,
4577    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4578        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
4579    }
4580
4581    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
4582    /// `usage`. This is the same mapping as used by the VolumeControl from
4583    /// `BindUsageVolumeControl`.
4584    pub fn r#get_volume_from_db2(
4585        &self,
4586        mut usage: &Usage2,
4587        mut gain_db: f32,
4588    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4589        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
4590    }
4591
4592    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
4593    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
4594    pub fn r#get_db_from_volume(
4595        &self,
4596        mut usage: &Usage,
4597        mut volume: f32,
4598    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4599        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
4600    }
4601
4602    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
4603    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
4604    pub fn r#get_db_from_volume2(
4605        &self,
4606        mut usage: &Usage2,
4607        mut volume: f32,
4608    ) -> fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect> {
4609        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
4610    }
4611
4612    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
4613    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
4614    /// the Behavior specified will be applied to the streams of Usage `affected`.
4615    pub fn r#set_interaction(
4616        &self,
4617        mut active: &Usage,
4618        mut affected: &Usage,
4619        mut behavior: Behavior,
4620    ) -> Result<(), fidl::Error> {
4621        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
4622    }
4623
4624    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
4625    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
4626    /// the Behavior specified will be applied to the streams of Usage `affected`.
4627    pub fn r#set_interaction2(
4628        &self,
4629        mut active: &Usage2,
4630        mut affected: &Usage2,
4631        mut behavior: Behavior,
4632    ) -> Result<(), fidl::Error> {
4633        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
4634    }
4635
4636    /// Re-initializes the set of rules that are currently governing the interaction of streams in
4637    /// audio_core. The default behavior is 'NONE'.
4638    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
4639        AudioCoreProxyInterface::r#reset_interactions(self)
4640    }
4641
4642    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
4643    /// does not provide a config.
4644    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
4645        AudioCoreProxyInterface::r#load_defaults(self)
4646    }
4647}
4648
4649impl AudioCoreProxyInterface for AudioCoreProxy {
4650    fn r#create_audio_renderer(
4651        &self,
4652        mut audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
4653    ) -> Result<(), fidl::Error> {
4654        self.client.send::<AudioCoreCreateAudioRendererRequest>(
4655            (audio_out_request,),
4656            0x2ac9beba47f83435,
4657            fidl::encoding::DynamicFlags::empty(),
4658        )
4659    }
4660
4661    fn r#create_audio_capturer_with_configuration(
4662        &self,
4663        mut stream_type: &AudioStreamType,
4664        mut configuration: &AudioCapturerConfiguration,
4665        mut audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4666    ) -> Result<(), fidl::Error> {
4667        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
4668            (stream_type, configuration, audio_capturer_request),
4669            0x459de383b0d76d97,
4670            fidl::encoding::DynamicFlags::empty(),
4671        )
4672    }
4673
4674    fn r#create_audio_capturer(
4675        &self,
4676        mut loopback: bool,
4677        mut audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
4678    ) -> Result<(), fidl::Error> {
4679        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
4680            (loopback, audio_in_request),
4681            0x787db169df99aed0,
4682            fidl::encoding::DynamicFlags::empty(),
4683        )
4684    }
4685
4686    fn r#set_render_usage_gain(
4687        &self,
4688        mut usage: AudioRenderUsage,
4689        mut gain_db: f32,
4690    ) -> Result<(), fidl::Error> {
4691        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
4692            (usage, gain_db),
4693            0x48097f45f6e2b8e7,
4694            fidl::encoding::DynamicFlags::empty(),
4695        )
4696    }
4697
4698    fn r#set_render_usage_gain2(
4699        &self,
4700        mut usage: AudioRenderUsage2,
4701        mut gain_db: f32,
4702    ) -> Result<(), fidl::Error> {
4703        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
4704            (usage, gain_db),
4705            0x779b1531dc9e64f4,
4706            fidl::encoding::DynamicFlags::FLEXIBLE,
4707        )
4708    }
4709
4710    fn r#set_capture_usage_gain(
4711        &self,
4712        mut usage: AudioCaptureUsage,
4713        mut gain_db: f32,
4714    ) -> Result<(), fidl::Error> {
4715        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
4716            (usage, gain_db),
4717            0x457d29217d4ea248,
4718            fidl::encoding::DynamicFlags::empty(),
4719        )
4720    }
4721
4722    fn r#set_capture_usage_gain2(
4723        &self,
4724        mut usage: AudioCaptureUsage2,
4725        mut gain_db: f32,
4726    ) -> Result<(), fidl::Error> {
4727        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
4728            (usage, gain_db),
4729            0x15065ee308f44af0,
4730            fidl::encoding::DynamicFlags::FLEXIBLE,
4731        )
4732    }
4733
4734    fn r#bind_usage_volume_control(
4735        &self,
4736        mut usage: &Usage,
4737        mut volume_control: fdomain_client::fidl::ServerEnd<
4738            fdomain_fuchsia_media_audio::VolumeControlMarker,
4739        >,
4740    ) -> Result<(), fidl::Error> {
4741        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
4742            (usage, volume_control),
4743            0x7225be116aadc137,
4744            fidl::encoding::DynamicFlags::empty(),
4745        )
4746    }
4747
4748    fn r#bind_usage_volume_control2(
4749        &self,
4750        mut usage: &Usage2,
4751        mut volume_control: fdomain_client::fidl::ServerEnd<
4752            fdomain_fuchsia_media_audio::VolumeControlMarker,
4753        >,
4754    ) -> Result<(), fidl::Error> {
4755        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
4756            (usage, volume_control),
4757            0x729dff93019d055,
4758            fidl::encoding::DynamicFlags::FLEXIBLE,
4759        )
4760    }
4761
4762    type GetVolumeFromDbResponseFut =
4763        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4764    fn r#get_volume_from_db(
4765        &self,
4766        mut usage: &Usage,
4767        mut gain_db: f32,
4768    ) -> Self::GetVolumeFromDbResponseFut {
4769        fn _decode(
4770            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4771        ) -> Result<f32, fidl::Error> {
4772            let _response = fidl::client::decode_transaction_body::<
4773                AudioCoreGetVolumeFromDbResponse,
4774                fdomain_client::fidl::FDomainResourceDialect,
4775                0x50e3ca45509770bf,
4776            >(_buf?)?;
4777            Ok(_response.volume)
4778        }
4779        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
4780            (usage, gain_db),
4781            0x50e3ca45509770bf,
4782            fidl::encoding::DynamicFlags::empty(),
4783            _decode,
4784        )
4785    }
4786
4787    type GetVolumeFromDb2ResponseFut =
4788        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4789    fn r#get_volume_from_db2(
4790        &self,
4791        mut usage: &Usage2,
4792        mut gain_db: f32,
4793    ) -> Self::GetVolumeFromDb2ResponseFut {
4794        fn _decode(
4795            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4796        ) -> Result<f32, fidl::Error> {
4797            let _response = fidl::client::decode_transaction_body::<
4798                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
4799                fdomain_client::fidl::FDomainResourceDialect,
4800                0x165c811091ef99da,
4801            >(_buf?)?
4802            .into_result_fdomain::<AudioCoreMarker>("get_volume_from_db2")?;
4803            Ok(_response.volume)
4804        }
4805        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
4806            (usage, gain_db),
4807            0x165c811091ef99da,
4808            fidl::encoding::DynamicFlags::FLEXIBLE,
4809            _decode,
4810        )
4811    }
4812
4813    type GetDbFromVolumeResponseFut =
4814        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4815    fn r#get_db_from_volume(
4816        &self,
4817        mut usage: &Usage,
4818        mut volume: f32,
4819    ) -> Self::GetDbFromVolumeResponseFut {
4820        fn _decode(
4821            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4822        ) -> Result<f32, fidl::Error> {
4823            let _response = fidl::client::decode_transaction_body::<
4824                AudioCoreGetDbFromVolumeResponse,
4825                fdomain_client::fidl::FDomainResourceDialect,
4826                0x3e8eec27dd5a8bda,
4827            >(_buf?)?;
4828            Ok(_response.gain_db)
4829        }
4830        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
4831            (usage, volume),
4832            0x3e8eec27dd5a8bda,
4833            fidl::encoding::DynamicFlags::empty(),
4834            _decode,
4835        )
4836    }
4837
4838    type GetDbFromVolume2ResponseFut =
4839        fidl::client::QueryResponseFut<f32, fdomain_client::fidl::FDomainResourceDialect>;
4840    fn r#get_db_from_volume2(
4841        &self,
4842        mut usage: &Usage2,
4843        mut volume: f32,
4844    ) -> Self::GetDbFromVolume2ResponseFut {
4845        fn _decode(
4846            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4847        ) -> Result<f32, fidl::Error> {
4848            let _response = fidl::client::decode_transaction_body::<
4849                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
4850                fdomain_client::fidl::FDomainResourceDialect,
4851                0x5f421a8ebf265bf3,
4852            >(_buf?)?
4853            .into_result_fdomain::<AudioCoreMarker>("get_db_from_volume2")?;
4854            Ok(_response.gain_db)
4855        }
4856        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
4857            (usage, volume),
4858            0x5f421a8ebf265bf3,
4859            fidl::encoding::DynamicFlags::FLEXIBLE,
4860            _decode,
4861        )
4862    }
4863
4864    fn r#set_interaction(
4865        &self,
4866        mut active: &Usage,
4867        mut affected: &Usage,
4868        mut behavior: Behavior,
4869    ) -> Result<(), fidl::Error> {
4870        self.client.send::<AudioCoreSetInteractionRequest>(
4871            (active, affected, behavior),
4872            0x7bfed14345ece7b7,
4873            fidl::encoding::DynamicFlags::empty(),
4874        )
4875    }
4876
4877    fn r#set_interaction2(
4878        &self,
4879        mut active: &Usage2,
4880        mut affected: &Usage2,
4881        mut behavior: Behavior,
4882    ) -> Result<(), fidl::Error> {
4883        self.client.send::<AudioCoreSetInteraction2Request>(
4884            (active, affected, behavior),
4885            0x7226c7c6e6edc62f,
4886            fidl::encoding::DynamicFlags::FLEXIBLE,
4887        )
4888    }
4889
4890    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
4891        self.client.send::<fidl::encoding::EmptyPayload>(
4892            (),
4893            0x65bd94d9d0a28b5e,
4894            fidl::encoding::DynamicFlags::empty(),
4895        )
4896    }
4897
4898    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
4899        self.client.send::<fidl::encoding::EmptyPayload>(
4900            (),
4901            0x54a0bebca85f6b31,
4902            fidl::encoding::DynamicFlags::empty(),
4903        )
4904    }
4905}
4906
4907pub struct AudioCoreEventStream {
4908    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
4909}
4910
4911impl std::marker::Unpin for AudioCoreEventStream {}
4912
4913impl futures::stream::FusedStream for AudioCoreEventStream {
4914    fn is_terminated(&self) -> bool {
4915        self.event_receiver.is_terminated()
4916    }
4917}
4918
4919impl futures::Stream for AudioCoreEventStream {
4920    type Item = Result<AudioCoreEvent, fidl::Error>;
4921
4922    fn poll_next(
4923        mut self: std::pin::Pin<&mut Self>,
4924        cx: &mut std::task::Context<'_>,
4925    ) -> std::task::Poll<Option<Self::Item>> {
4926        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4927            &mut self.event_receiver,
4928            cx
4929        )?) {
4930            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
4931            None => std::task::Poll::Ready(None),
4932        }
4933    }
4934}
4935
4936#[derive(Debug)]
4937pub enum AudioCoreEvent {
4938    #[non_exhaustive]
4939    _UnknownEvent {
4940        /// Ordinal of the event that was sent.
4941        ordinal: u64,
4942    },
4943}
4944
4945impl AudioCoreEvent {
4946    /// Decodes a message buffer as a [`AudioCoreEvent`].
4947    fn decode(
4948        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4949    ) -> Result<AudioCoreEvent, fidl::Error> {
4950        let (bytes, _handles) = buf.split_mut();
4951        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4952        debug_assert_eq!(tx_header.tx_id, 0);
4953        match tx_header.ordinal {
4954            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4955                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4956            }
4957            _ => Err(fidl::Error::UnknownOrdinal {
4958                ordinal: tx_header.ordinal,
4959                protocol_name:
4960                    <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
4961            }),
4962        }
4963    }
4964}
4965
4966/// A Stream of incoming requests for fuchsia.media/AudioCore.
4967pub struct AudioCoreRequestStream {
4968    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
4969    is_terminated: bool,
4970}
4971
4972impl std::marker::Unpin for AudioCoreRequestStream {}
4973
4974impl futures::stream::FusedStream for AudioCoreRequestStream {
4975    fn is_terminated(&self) -> bool {
4976        self.is_terminated
4977    }
4978}
4979
4980impl fdomain_client::fidl::RequestStream for AudioCoreRequestStream {
4981    type Protocol = AudioCoreMarker;
4982    type ControlHandle = AudioCoreControlHandle;
4983
4984    fn from_channel(channel: fdomain_client::Channel) -> Self {
4985        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4986    }
4987
4988    fn control_handle(&self) -> Self::ControlHandle {
4989        AudioCoreControlHandle { inner: self.inner.clone() }
4990    }
4991
4992    fn into_inner(
4993        self,
4994    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
4995    {
4996        (self.inner, self.is_terminated)
4997    }
4998
4999    fn from_inner(
5000        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5001        is_terminated: bool,
5002    ) -> Self {
5003        Self { inner, is_terminated }
5004    }
5005}
5006
5007impl futures::Stream for AudioCoreRequestStream {
5008    type Item = Result<AudioCoreRequest, fidl::Error>;
5009
5010    fn poll_next(
5011        mut self: std::pin::Pin<&mut Self>,
5012        cx: &mut std::task::Context<'_>,
5013    ) -> std::task::Poll<Option<Self::Item>> {
5014        let this = &mut *self;
5015        if this.inner.check_shutdown(cx) {
5016            this.is_terminated = true;
5017            return std::task::Poll::Ready(None);
5018        }
5019        if this.is_terminated {
5020            panic!("polled AudioCoreRequestStream after completion");
5021        }
5022        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
5023            |bytes, handles| {
5024                match this.inner.channel().read_etc(cx, bytes, handles) {
5025                    std::task::Poll::Ready(Ok(())) => {}
5026                    std::task::Poll::Pending => return std::task::Poll::Pending,
5027                    std::task::Poll::Ready(Err(None)) => {
5028                        this.is_terminated = true;
5029                        return std::task::Poll::Ready(None);
5030                    }
5031                    std::task::Poll::Ready(Err(Some(e))) => {
5032                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5033                            e.into(),
5034                        ))));
5035                    }
5036                }
5037
5038                // A message has been received from the channel
5039                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5040
5041                std::task::Poll::Ready(Some(match header.ordinal {
5042                    0x2ac9beba47f83435 => {
5043                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5044                        let mut req = fidl::new_empty!(
5045                            AudioCoreCreateAudioRendererRequest,
5046                            fdomain_client::fidl::FDomainResourceDialect
5047                        );
5048                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
5049                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5050                        Ok(AudioCoreRequest::CreateAudioRenderer {
5051                            audio_out_request: req.audio_out_request,
5052
5053                            control_handle,
5054                        })
5055                    }
5056                    0x459de383b0d76d97 => {
5057                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5058                        let mut req = fidl::new_empty!(
5059                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
5060                            fdomain_client::fidl::FDomainResourceDialect
5061                        );
5062                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
5063                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5064                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5065                            stream_type: req.stream_type,
5066                            configuration: req.configuration,
5067                            audio_capturer_request: req.audio_capturer_request,
5068
5069                            control_handle,
5070                        })
5071                    }
5072                    0x787db169df99aed0 => {
5073                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5074                        let mut req = fidl::new_empty!(
5075                            AudioCoreCreateAudioCapturerRequest,
5076                            fdomain_client::fidl::FDomainResourceDialect
5077                        );
5078                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
5079                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5080                        Ok(AudioCoreRequest::CreateAudioCapturer {
5081                            loopback: req.loopback,
5082                            audio_in_request: req.audio_in_request,
5083
5084                            control_handle,
5085                        })
5086                    }
5087                    0x48097f45f6e2b8e7 => {
5088                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5089                        let mut req = fidl::new_empty!(
5090                            AudioCoreSetRenderUsageGainRequest,
5091                            fdomain_client::fidl::FDomainResourceDialect
5092                        );
5093                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5094                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5095                        Ok(AudioCoreRequest::SetRenderUsageGain {
5096                            usage: req.usage,
5097                            gain_db: req.gain_db,
5098
5099                            control_handle,
5100                        })
5101                    }
5102                    0x779b1531dc9e64f4 => {
5103                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5104                        let mut req = fidl::new_empty!(
5105                            AudioCoreSetRenderUsageGain2Request,
5106                            fdomain_client::fidl::FDomainResourceDialect
5107                        );
5108                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5109                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5110                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
5111                            usage: req.usage,
5112                            gain_db: req.gain_db,
5113
5114                            control_handle,
5115                        })
5116                    }
5117                    0x457d29217d4ea248 => {
5118                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5119                        let mut req = fidl::new_empty!(
5120                            AudioCoreSetCaptureUsageGainRequest,
5121                            fdomain_client::fidl::FDomainResourceDialect
5122                        );
5123                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
5124                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5125                        Ok(AudioCoreRequest::SetCaptureUsageGain {
5126                            usage: req.usage,
5127                            gain_db: req.gain_db,
5128
5129                            control_handle,
5130                        })
5131                    }
5132                    0x15065ee308f44af0 => {
5133                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5134                        let mut req = fidl::new_empty!(
5135                            AudioCoreSetCaptureUsageGain2Request,
5136                            fdomain_client::fidl::FDomainResourceDialect
5137                        );
5138                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
5139                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5140                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
5141                            usage: req.usage,
5142                            gain_db: req.gain_db,
5143
5144                            control_handle,
5145                        })
5146                    }
5147                    0x7225be116aadc137 => {
5148                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5149                        let mut req = fidl::new_empty!(
5150                            AudioCoreBindUsageVolumeControlRequest,
5151                            fdomain_client::fidl::FDomainResourceDialect
5152                        );
5153                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
5154                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5155                        Ok(AudioCoreRequest::BindUsageVolumeControl {
5156                            usage: req.usage,
5157                            volume_control: req.volume_control,
5158
5159                            control_handle,
5160                        })
5161                    }
5162                    0x729dff93019d055 => {
5163                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5164                        let mut req = fidl::new_empty!(
5165                            AudioCoreBindUsageVolumeControl2Request,
5166                            fdomain_client::fidl::FDomainResourceDialect
5167                        );
5168                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
5169                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5170                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
5171                            usage: req.usage,
5172                            volume_control: req.volume_control,
5173
5174                            control_handle,
5175                        })
5176                    }
5177                    0x50e3ca45509770bf => {
5178                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5179                        let mut req = fidl::new_empty!(
5180                            AudioCoreGetVolumeFromDbRequest,
5181                            fdomain_client::fidl::FDomainResourceDialect
5182                        );
5183                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
5184                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5185                        Ok(AudioCoreRequest::GetVolumeFromDb {
5186                            usage: req.usage,
5187                            gain_db: req.gain_db,
5188
5189                            responder: AudioCoreGetVolumeFromDbResponder {
5190                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5191                                tx_id: header.tx_id,
5192                            },
5193                        })
5194                    }
5195                    0x165c811091ef99da => {
5196                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5197                        let mut req = fidl::new_empty!(
5198                            AudioCoreGetVolumeFromDb2Request,
5199                            fdomain_client::fidl::FDomainResourceDialect
5200                        );
5201                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
5202                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5203                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
5204                            usage: req.usage,
5205                            gain_db: req.gain_db,
5206
5207                            responder: AudioCoreGetVolumeFromDb2Responder {
5208                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5209                                tx_id: header.tx_id,
5210                            },
5211                        })
5212                    }
5213                    0x3e8eec27dd5a8bda => {
5214                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5215                        let mut req = fidl::new_empty!(
5216                            AudioCoreGetDbFromVolumeRequest,
5217                            fdomain_client::fidl::FDomainResourceDialect
5218                        );
5219                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
5220                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5221                        Ok(AudioCoreRequest::GetDbFromVolume {
5222                            usage: req.usage,
5223                            volume: req.volume,
5224
5225                            responder: AudioCoreGetDbFromVolumeResponder {
5226                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5227                                tx_id: header.tx_id,
5228                            },
5229                        })
5230                    }
5231                    0x5f421a8ebf265bf3 => {
5232                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5233                        let mut req = fidl::new_empty!(
5234                            AudioCoreGetDbFromVolume2Request,
5235                            fdomain_client::fidl::FDomainResourceDialect
5236                        );
5237                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
5238                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5239                        Ok(AudioCoreRequest::GetDbFromVolume2 {
5240                            usage: req.usage,
5241                            volume: req.volume,
5242
5243                            responder: AudioCoreGetDbFromVolume2Responder {
5244                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5245                                tx_id: header.tx_id,
5246                            },
5247                        })
5248                    }
5249                    0x7bfed14345ece7b7 => {
5250                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5251                        let mut req = fidl::new_empty!(
5252                            AudioCoreSetInteractionRequest,
5253                            fdomain_client::fidl::FDomainResourceDialect
5254                        );
5255                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
5256                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5257                        Ok(AudioCoreRequest::SetInteraction {
5258                            active: req.active,
5259                            affected: req.affected,
5260                            behavior: req.behavior,
5261
5262                            control_handle,
5263                        })
5264                    }
5265                    0x7226c7c6e6edc62f => {
5266                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5267                        let mut req = fidl::new_empty!(
5268                            AudioCoreSetInteraction2Request,
5269                            fdomain_client::fidl::FDomainResourceDialect
5270                        );
5271                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
5272                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5273                        Ok(AudioCoreRequest::SetInteraction2 {
5274                            active: req.active,
5275                            affected: req.affected,
5276                            behavior: req.behavior,
5277
5278                            control_handle,
5279                        })
5280                    }
5281                    0x65bd94d9d0a28b5e => {
5282                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5283                        let mut req = fidl::new_empty!(
5284                            fidl::encoding::EmptyPayload,
5285                            fdomain_client::fidl::FDomainResourceDialect
5286                        );
5287                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5288                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5289                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
5290                    }
5291                    0x54a0bebca85f6b31 => {
5292                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5293                        let mut req = fidl::new_empty!(
5294                            fidl::encoding::EmptyPayload,
5295                            fdomain_client::fidl::FDomainResourceDialect
5296                        );
5297                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5298                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
5299                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
5300                    }
5301                    _ if header.tx_id == 0
5302                        && header
5303                            .dynamic_flags()
5304                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5305                    {
5306                        Ok(AudioCoreRequest::_UnknownMethod {
5307                            ordinal: header.ordinal,
5308                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
5309                            method_type: fidl::MethodType::OneWay,
5310                        })
5311                    }
5312                    _ if header
5313                        .dynamic_flags()
5314                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5315                    {
5316                        this.inner.send_framework_err(
5317                            fidl::encoding::FrameworkErr::UnknownMethod,
5318                            header.tx_id,
5319                            header.ordinal,
5320                            header.dynamic_flags(),
5321                            (bytes, handles),
5322                        )?;
5323                        Ok(AudioCoreRequest::_UnknownMethod {
5324                            ordinal: header.ordinal,
5325                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
5326                            method_type: fidl::MethodType::TwoWay,
5327                        })
5328                    }
5329                    _ => Err(fidl::Error::UnknownOrdinal {
5330                        ordinal: header.ordinal,
5331                        protocol_name:
5332                            <AudioCoreMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
5333                    }),
5334                }))
5335            },
5336        )
5337    }
5338}
5339
5340#[derive(Debug)]
5341pub enum AudioCoreRequest {
5342    /// Creates an AudioRenderer which outputs audio to the default device.
5343    CreateAudioRenderer {
5344        audio_out_request: fdomain_client::fidl::ServerEnd<AudioRendererMarker>,
5345        control_handle: AudioCoreControlHandle,
5346    },
5347    /// Creates an AudioCapturer according to the given requirements.
5348    ///
5349    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5350    /// It causes the source material to be reformatted/resampled if needed
5351    /// in order to produce the requested stream type.
5352    ///
5353    /// `usage` is used by Fuchsia to make decisions about user experience.
5354    /// See `AudioCaptureUsage` for more details.
5355    ///
5356    /// `configuration` must be initialized to a variant, or no capturer
5357    /// can be created.
5358    CreateAudioCapturerWithConfiguration {
5359        stream_type: AudioStreamType,
5360        configuration: AudioCapturerConfiguration,
5361        audio_capturer_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5362        control_handle: AudioCoreControlHandle,
5363    },
5364    /// Creates an AudioCapturer which either captures from the current default
5365    /// audio input device, or loops-back from the current default audio output
5366    /// device based on value passed for the loopback flag.
5367    CreateAudioCapturer {
5368        loopback: bool,
5369        audio_in_request: fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5370        control_handle: AudioCoreControlHandle,
5371    },
5372    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5373    SetRenderUsageGain {
5374        usage: AudioRenderUsage,
5375        gain_db: f32,
5376        control_handle: AudioCoreControlHandle,
5377    },
5378    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5379    SetRenderUsageGain2 {
5380        usage: AudioRenderUsage2,
5381        gain_db: f32,
5382        control_handle: AudioCoreControlHandle,
5383    },
5384    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5385    SetCaptureUsageGain {
5386        usage: AudioCaptureUsage,
5387        gain_db: f32,
5388        control_handle: AudioCoreControlHandle,
5389    },
5390    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5391    SetCaptureUsageGain2 {
5392        usage: AudioCaptureUsage2,
5393        gain_db: f32,
5394        control_handle: AudioCoreControlHandle,
5395    },
5396    /// Binds to a volume control protocol for the given usage.
5397    BindUsageVolumeControl {
5398        usage: Usage,
5399        volume_control:
5400            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5401        control_handle: AudioCoreControlHandle,
5402    },
5403    /// Binds to a volume control protocol for the given usage.
5404    BindUsageVolumeControl2 {
5405        usage: Usage2,
5406        volume_control:
5407            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5408        control_handle: AudioCoreControlHandle,
5409    },
5410    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5411    /// `usage`. This is the same mapping as used by the VolumeControl from
5412    /// `BindUsageVolumeControl`.
5413    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
5414    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5415    /// `usage`. This is the same mapping as used by the VolumeControl from
5416    /// `BindUsageVolumeControl`.
5417    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
5418    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5419    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5420    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
5421    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5422    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5423    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
5424    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5425    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5426    /// the Behavior specified will be applied to the streams of Usage `affected`.
5427    SetInteraction {
5428        active: Usage,
5429        affected: Usage,
5430        behavior: Behavior,
5431        control_handle: AudioCoreControlHandle,
5432    },
5433    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5434    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5435    /// the Behavior specified will be applied to the streams of Usage `affected`.
5436    SetInteraction2 {
5437        active: Usage2,
5438        affected: Usage2,
5439        behavior: Behavior,
5440        control_handle: AudioCoreControlHandle,
5441    },
5442    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5443    /// audio_core. The default behavior is 'NONE'.
5444    ResetInteractions { control_handle: AudioCoreControlHandle },
5445    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5446    /// does not provide a config.
5447    LoadDefaults { control_handle: AudioCoreControlHandle },
5448    /// An interaction was received which does not match any known method.
5449    #[non_exhaustive]
5450    _UnknownMethod {
5451        /// Ordinal of the method that was called.
5452        ordinal: u64,
5453        control_handle: AudioCoreControlHandle,
5454        method_type: fidl::MethodType,
5455    },
5456}
5457
5458impl AudioCoreRequest {
5459    #[allow(irrefutable_let_patterns)]
5460    pub fn into_create_audio_renderer(
5461        self,
5462    ) -> Option<(fdomain_client::fidl::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)>
5463    {
5464        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
5465            Some((audio_out_request, control_handle))
5466        } else {
5467            None
5468        }
5469    }
5470
5471    #[allow(irrefutable_let_patterns)]
5472    pub fn into_create_audio_capturer_with_configuration(
5473        self,
5474    ) -> Option<(
5475        AudioStreamType,
5476        AudioCapturerConfiguration,
5477        fdomain_client::fidl::ServerEnd<AudioCapturerMarker>,
5478        AudioCoreControlHandle,
5479    )> {
5480        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
5481            stream_type,
5482            configuration,
5483            audio_capturer_request,
5484            control_handle,
5485        } = self
5486        {
5487            Some((stream_type, configuration, audio_capturer_request, control_handle))
5488        } else {
5489            None
5490        }
5491    }
5492
5493    #[allow(irrefutable_let_patterns)]
5494    pub fn into_create_audio_capturer(
5495        self,
5496    ) -> Option<(bool, fdomain_client::fidl::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
5497    {
5498        if let AudioCoreRequest::CreateAudioCapturer {
5499            loopback,
5500            audio_in_request,
5501            control_handle,
5502        } = self
5503        {
5504            Some((loopback, audio_in_request, control_handle))
5505        } else {
5506            None
5507        }
5508    }
5509
5510    #[allow(irrefutable_let_patterns)]
5511    pub fn into_set_render_usage_gain(
5512        self,
5513    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
5514        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
5515            Some((usage, gain_db, control_handle))
5516        } else {
5517            None
5518        }
5519    }
5520
5521    #[allow(irrefutable_let_patterns)]
5522    pub fn into_set_render_usage_gain2(
5523        self,
5524    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
5525        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
5526            Some((usage, gain_db, control_handle))
5527        } else {
5528            None
5529        }
5530    }
5531
5532    #[allow(irrefutable_let_patterns)]
5533    pub fn into_set_capture_usage_gain(
5534        self,
5535    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
5536        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
5537            Some((usage, gain_db, control_handle))
5538        } else {
5539            None
5540        }
5541    }
5542
5543    #[allow(irrefutable_let_patterns)]
5544    pub fn into_set_capture_usage_gain2(
5545        self,
5546    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
5547        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
5548            Some((usage, gain_db, control_handle))
5549        } else {
5550            None
5551        }
5552    }
5553
5554    #[allow(irrefutable_let_patterns)]
5555    pub fn into_bind_usage_volume_control(
5556        self,
5557    ) -> Option<(
5558        Usage,
5559        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5560        AudioCoreControlHandle,
5561    )> {
5562        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
5563            self
5564        {
5565            Some((usage, volume_control, control_handle))
5566        } else {
5567            None
5568        }
5569    }
5570
5571    #[allow(irrefutable_let_patterns)]
5572    pub fn into_bind_usage_volume_control2(
5573        self,
5574    ) -> Option<(
5575        Usage2,
5576        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::VolumeControlMarker>,
5577        AudioCoreControlHandle,
5578    )> {
5579        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
5580            self
5581        {
5582            Some((usage, volume_control, control_handle))
5583        } else {
5584            None
5585        }
5586    }
5587
5588    #[allow(irrefutable_let_patterns)]
5589    pub fn into_get_volume_from_db(
5590        self,
5591    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
5592        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
5593            Some((usage, gain_db, responder))
5594        } else {
5595            None
5596        }
5597    }
5598
5599    #[allow(irrefutable_let_patterns)]
5600    pub fn into_get_volume_from_db2(
5601        self,
5602    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
5603        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
5604            Some((usage, gain_db, responder))
5605        } else {
5606            None
5607        }
5608    }
5609
5610    #[allow(irrefutable_let_patterns)]
5611    pub fn into_get_db_from_volume(
5612        self,
5613    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
5614        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
5615            Some((usage, volume, responder))
5616        } else {
5617            None
5618        }
5619    }
5620
5621    #[allow(irrefutable_let_patterns)]
5622    pub fn into_get_db_from_volume2(
5623        self,
5624    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
5625        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
5626            Some((usage, volume, responder))
5627        } else {
5628            None
5629        }
5630    }
5631
5632    #[allow(irrefutable_let_patterns)]
5633    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
5634        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
5635            self
5636        {
5637            Some((active, affected, behavior, control_handle))
5638        } else {
5639            None
5640        }
5641    }
5642
5643    #[allow(irrefutable_let_patterns)]
5644    pub fn into_set_interaction2(
5645        self,
5646    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
5647        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
5648            self
5649        {
5650            Some((active, affected, behavior, control_handle))
5651        } else {
5652            None
5653        }
5654    }
5655
5656    #[allow(irrefutable_let_patterns)]
5657    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
5658        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
5659            Some((control_handle))
5660        } else {
5661            None
5662        }
5663    }
5664
5665    #[allow(irrefutable_let_patterns)]
5666    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
5667        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
5668            Some((control_handle))
5669        } else {
5670            None
5671        }
5672    }
5673
5674    /// Name of the method defined in FIDL
5675    pub fn method_name(&self) -> &'static str {
5676        match *self {
5677            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
5678            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
5679                "create_audio_capturer_with_configuration"
5680            }
5681            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
5682            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
5683            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
5684            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
5685            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
5686            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
5687            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
5688            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
5689            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
5690            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
5691            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
5692            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
5693            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
5694            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
5695            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
5696            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
5697                "unknown one-way method"
5698            }
5699            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
5700                "unknown two-way method"
5701            }
5702        }
5703    }
5704}
5705
5706#[derive(Debug, Clone)]
5707pub struct AudioCoreControlHandle {
5708    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
5709}
5710
5711impl AudioCoreControlHandle {
5712    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5713        self.inner.shutdown_with_epitaph(status.into())
5714    }
5715}
5716
5717impl fdomain_client::fidl::ControlHandle for AudioCoreControlHandle {
5718    fn shutdown(&self) {
5719        self.inner.shutdown()
5720    }
5721
5722    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5723        self.inner.shutdown_with_epitaph(status)
5724    }
5725
5726    fn is_closed(&self) -> bool {
5727        self.inner.channel().is_closed()
5728    }
5729    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
5730        self.inner.channel().on_closed()
5731    }
5732}
5733
5734impl AudioCoreControlHandle {}
5735
5736#[must_use = "FIDL methods require a response to be sent"]
5737#[derive(Debug)]
5738pub struct AudioCoreGetVolumeFromDbResponder {
5739    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5740    tx_id: u32,
5741}
5742
5743/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5744/// if the responder is dropped without sending a response, so that the client
5745/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5746impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
5747    fn drop(&mut self) {
5748        self.control_handle.shutdown();
5749        // Safety: drops once, never accessed again
5750        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5751    }
5752}
5753
5754impl fdomain_client::fidl::Responder for AudioCoreGetVolumeFromDbResponder {
5755    type ControlHandle = AudioCoreControlHandle;
5756
5757    fn control_handle(&self) -> &AudioCoreControlHandle {
5758        &self.control_handle
5759    }
5760
5761    fn drop_without_shutdown(mut self) {
5762        // Safety: drops once, never accessed again due to mem::forget
5763        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5764        // Prevent Drop from running (which would shut down the channel)
5765        std::mem::forget(self);
5766    }
5767}
5768
5769impl AudioCoreGetVolumeFromDbResponder {
5770    /// Sends a response to the FIDL transaction.
5771    ///
5772    /// Sets the channel to shutdown if an error occurs.
5773    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
5774        let _result = self.send_raw(volume);
5775        if _result.is_err() {
5776            self.control_handle.shutdown();
5777        }
5778        self.drop_without_shutdown();
5779        _result
5780    }
5781
5782    /// Similar to "send" but does not shutdown the channel if an error occurs.
5783    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
5784        let _result = self.send_raw(volume);
5785        self.drop_without_shutdown();
5786        _result
5787    }
5788
5789    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
5790        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
5791            (volume,),
5792            self.tx_id,
5793            0x50e3ca45509770bf,
5794            fidl::encoding::DynamicFlags::empty(),
5795        )
5796    }
5797}
5798
5799#[must_use = "FIDL methods require a response to be sent"]
5800#[derive(Debug)]
5801pub struct AudioCoreGetVolumeFromDb2Responder {
5802    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5803    tx_id: u32,
5804}
5805
5806/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5807/// if the responder is dropped without sending a response, so that the client
5808/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5809impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
5810    fn drop(&mut self) {
5811        self.control_handle.shutdown();
5812        // Safety: drops once, never accessed again
5813        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5814    }
5815}
5816
5817impl fdomain_client::fidl::Responder for AudioCoreGetVolumeFromDb2Responder {
5818    type ControlHandle = AudioCoreControlHandle;
5819
5820    fn control_handle(&self) -> &AudioCoreControlHandle {
5821        &self.control_handle
5822    }
5823
5824    fn drop_without_shutdown(mut self) {
5825        // Safety: drops once, never accessed again due to mem::forget
5826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5827        // Prevent Drop from running (which would shut down the channel)
5828        std::mem::forget(self);
5829    }
5830}
5831
5832impl AudioCoreGetVolumeFromDb2Responder {
5833    /// Sends a response to the FIDL transaction.
5834    ///
5835    /// Sets the channel to shutdown if an error occurs.
5836    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
5837        let _result = self.send_raw(volume);
5838        if _result.is_err() {
5839            self.control_handle.shutdown();
5840        }
5841        self.drop_without_shutdown();
5842        _result
5843    }
5844
5845    /// Similar to "send" but does not shutdown the channel if an error occurs.
5846    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
5847        let _result = self.send_raw(volume);
5848        self.drop_without_shutdown();
5849        _result
5850    }
5851
5852    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
5853        self.control_handle
5854            .inner
5855            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
5856                fidl::encoding::Flexible::new((volume,)),
5857                self.tx_id,
5858                0x165c811091ef99da,
5859                fidl::encoding::DynamicFlags::FLEXIBLE,
5860            )
5861    }
5862}
5863
5864#[must_use = "FIDL methods require a response to be sent"]
5865#[derive(Debug)]
5866pub struct AudioCoreGetDbFromVolumeResponder {
5867    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5868    tx_id: u32,
5869}
5870
5871/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5872/// if the responder is dropped without sending a response, so that the client
5873/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5874impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
5875    fn drop(&mut self) {
5876        self.control_handle.shutdown();
5877        // Safety: drops once, never accessed again
5878        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5879    }
5880}
5881
5882impl fdomain_client::fidl::Responder for AudioCoreGetDbFromVolumeResponder {
5883    type ControlHandle = AudioCoreControlHandle;
5884
5885    fn control_handle(&self) -> &AudioCoreControlHandle {
5886        &self.control_handle
5887    }
5888
5889    fn drop_without_shutdown(mut self) {
5890        // Safety: drops once, never accessed again due to mem::forget
5891        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5892        // Prevent Drop from running (which would shut down the channel)
5893        std::mem::forget(self);
5894    }
5895}
5896
5897impl AudioCoreGetDbFromVolumeResponder {
5898    /// Sends a response to the FIDL transaction.
5899    ///
5900    /// Sets the channel to shutdown if an error occurs.
5901    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5902        let _result = self.send_raw(gain_db);
5903        if _result.is_err() {
5904            self.control_handle.shutdown();
5905        }
5906        self.drop_without_shutdown();
5907        _result
5908    }
5909
5910    /// Similar to "send" but does not shutdown the channel if an error occurs.
5911    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5912        let _result = self.send_raw(gain_db);
5913        self.drop_without_shutdown();
5914        _result
5915    }
5916
5917    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
5918        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
5919            (gain_db,),
5920            self.tx_id,
5921            0x3e8eec27dd5a8bda,
5922            fidl::encoding::DynamicFlags::empty(),
5923        )
5924    }
5925}
5926
5927#[must_use = "FIDL methods require a response to be sent"]
5928#[derive(Debug)]
5929pub struct AudioCoreGetDbFromVolume2Responder {
5930    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
5931    tx_id: u32,
5932}
5933
5934/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
5935/// if the responder is dropped without sending a response, so that the client
5936/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5937impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
5938    fn drop(&mut self) {
5939        self.control_handle.shutdown();
5940        // Safety: drops once, never accessed again
5941        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5942    }
5943}
5944
5945impl fdomain_client::fidl::Responder for AudioCoreGetDbFromVolume2Responder {
5946    type ControlHandle = AudioCoreControlHandle;
5947
5948    fn control_handle(&self) -> &AudioCoreControlHandle {
5949        &self.control_handle
5950    }
5951
5952    fn drop_without_shutdown(mut self) {
5953        // Safety: drops once, never accessed again due to mem::forget
5954        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5955        // Prevent Drop from running (which would shut down the channel)
5956        std::mem::forget(self);
5957    }
5958}
5959
5960impl AudioCoreGetDbFromVolume2Responder {
5961    /// Sends a response to the FIDL transaction.
5962    ///
5963    /// Sets the channel to shutdown if an error occurs.
5964    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5965        let _result = self.send_raw(gain_db);
5966        if _result.is_err() {
5967            self.control_handle.shutdown();
5968        }
5969        self.drop_without_shutdown();
5970        _result
5971    }
5972
5973    /// Similar to "send" but does not shutdown the channel if an error occurs.
5974    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
5975        let _result = self.send_raw(gain_db);
5976        self.drop_without_shutdown();
5977        _result
5978    }
5979
5980    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
5981        self.control_handle
5982            .inner
5983            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
5984                fidl::encoding::Flexible::new((gain_db,)),
5985                self.tx_id,
5986                0x5f421a8ebf265bf3,
5987                fidl::encoding::DynamicFlags::FLEXIBLE,
5988            )
5989    }
5990}
5991
5992#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5993pub struct AudioDeviceEnumeratorMarker;
5994
5995impl fdomain_client::fidl::ProtocolMarker for AudioDeviceEnumeratorMarker {
5996    type Proxy = AudioDeviceEnumeratorProxy;
5997    type RequestStream = AudioDeviceEnumeratorRequestStream;
5998
5999    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
6000}
6001impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
6002
6003pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
6004    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
6005        + Send;
6006    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
6007    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
6008        + Send;
6009    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
6010    fn r#set_device_gain(
6011        &self,
6012        device_token: u64,
6013        gain_info: &AudioGainInfo,
6014        valid_flags: AudioGainValidFlags,
6015    ) -> Result<(), fidl::Error>;
6016    fn r#add_device_by_channel(
6017        &self,
6018        device_name: &str,
6019        is_input: bool,
6020        channel: fdomain_client::fidl::ClientEnd<
6021            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
6022        >,
6023    ) -> Result<(), fidl::Error>;
6024}
6025
6026#[derive(Debug, Clone)]
6027pub struct AudioDeviceEnumeratorProxy {
6028    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
6029}
6030
6031impl fdomain_client::fidl::Proxy for AudioDeviceEnumeratorProxy {
6032    type Protocol = AudioDeviceEnumeratorMarker;
6033
6034    fn from_channel(inner: fdomain_client::Channel) -> Self {
6035        Self::new(inner)
6036    }
6037
6038    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6039        self.client.into_channel().map_err(|client| Self { client })
6040    }
6041
6042    fn as_channel(&self) -> &fdomain_client::Channel {
6043        self.client.as_channel()
6044    }
6045}
6046
6047impl AudioDeviceEnumeratorProxy {
6048    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
6049    pub fn new(channel: fdomain_client::Channel) -> Self {
6050        let protocol_name =
6051            <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6052        Self { client: fidl::client::Client::new(channel, protocol_name) }
6053    }
6054
6055    /// Get a Stream of events from the remote end of the protocol.
6056    ///
6057    /// # Panics
6058    ///
6059    /// Panics if the event stream was already taken.
6060    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
6061        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
6062    }
6063
6064    /// Obtain the list of currently active audio devices.
6065    pub fn r#get_devices(
6066        &self,
6067    ) -> fidl::client::QueryResponseFut<
6068        Vec<AudioDeviceInfo>,
6069        fdomain_client::fidl::FDomainResourceDialect,
6070    > {
6071        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
6072    }
6073
6074    /// Gain/Mute/AGC control
6075    ///
6076    /// Note that each of these operations requires a device_token in order to
6077    /// target the proper input/output.
6078    ///
6079    /// The Get command returns the device_token of the device whose gain is
6080    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6081    /// device_token was invalid or the device had been removed from the system
6082    /// before the Get command could be processed.
6083    ///
6084    /// Set commands which are given an invalid device token are ignored and
6085    /// have no effect on the system. In addition, users do not need to control
6086    /// all of the gain settings for an audio device with each call. Only the
6087    /// settings with a corresponding flag set in the set_flags parameter will
6088    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6089    /// a SetDeviceGain call to care only about the mute setting in the
6090    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6091    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6092    /// status to be changed simultaneously.
6093    pub fn r#get_device_gain(
6094        &self,
6095        mut device_token: u64,
6096    ) -> fidl::client::QueryResponseFut<
6097        (u64, AudioGainInfo),
6098        fdomain_client::fidl::FDomainResourceDialect,
6099    > {
6100        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
6101    }
6102
6103    pub fn r#set_device_gain(
6104        &self,
6105        mut device_token: u64,
6106        mut gain_info: &AudioGainInfo,
6107        mut valid_flags: AudioGainValidFlags,
6108    ) -> Result<(), fidl::Error> {
6109        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
6110            self,
6111            device_token,
6112            gain_info,
6113            valid_flags,
6114        )
6115    }
6116
6117    /// # Deprecation
6118    ///
6119    /// StreamConfig is not supported anymore, instead use an
6120    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6121    /// , see
6122    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6123    pub fn r#add_device_by_channel(
6124        &self,
6125        mut device_name: &str,
6126        mut is_input: bool,
6127        mut channel: fdomain_client::fidl::ClientEnd<
6128            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
6129        >,
6130    ) -> Result<(), fidl::Error> {
6131        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
6132            self,
6133            device_name,
6134            is_input,
6135            channel,
6136        )
6137    }
6138}
6139
6140impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
6141    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
6142        Vec<AudioDeviceInfo>,
6143        fdomain_client::fidl::FDomainResourceDialect,
6144    >;
6145    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
6146        fn _decode(
6147            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6148        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
6149            let _response = fidl::client::decode_transaction_body::<
6150                AudioDeviceEnumeratorGetDevicesResponse,
6151                fdomain_client::fidl::FDomainResourceDialect,
6152                0x4ce1aa218aeb12a6,
6153            >(_buf?)?;
6154            Ok(_response.devices)
6155        }
6156        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
6157            (),
6158            0x4ce1aa218aeb12a6,
6159            fidl::encoding::DynamicFlags::empty(),
6160            _decode,
6161        )
6162    }
6163
6164    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
6165        (u64, AudioGainInfo),
6166        fdomain_client::fidl::FDomainResourceDialect,
6167    >;
6168    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
6169        fn _decode(
6170            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6171        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
6172            let _response = fidl::client::decode_transaction_body::<
6173                AudioDeviceEnumeratorGetDeviceGainResponse,
6174                fdomain_client::fidl::FDomainResourceDialect,
6175                0x25dd4723403c414b,
6176            >(_buf?)?;
6177            Ok((_response.device_token, _response.gain_info))
6178        }
6179        self.client.send_query_and_decode::<
6180            AudioDeviceEnumeratorGetDeviceGainRequest,
6181            (u64, AudioGainInfo),
6182        >(
6183            (device_token,),
6184            0x25dd4723403c414b,
6185            fidl::encoding::DynamicFlags::empty(),
6186            _decode,
6187        )
6188    }
6189
6190    fn r#set_device_gain(
6191        &self,
6192        mut device_token: u64,
6193        mut gain_info: &AudioGainInfo,
6194        mut valid_flags: AudioGainValidFlags,
6195    ) -> Result<(), fidl::Error> {
6196        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
6197            (device_token, gain_info, valid_flags),
6198            0x5bdabc8ebe83591,
6199            fidl::encoding::DynamicFlags::empty(),
6200        )
6201    }
6202
6203    fn r#add_device_by_channel(
6204        &self,
6205        mut device_name: &str,
6206        mut is_input: bool,
6207        mut channel: fdomain_client::fidl::ClientEnd<
6208            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
6209        >,
6210    ) -> Result<(), fidl::Error> {
6211        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
6212            (device_name, is_input, channel),
6213            0x72cdbada4d70ed67,
6214            fidl::encoding::DynamicFlags::empty(),
6215        )
6216    }
6217}
6218
6219pub struct AudioDeviceEnumeratorEventStream {
6220    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
6221}
6222
6223impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
6224
6225impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
6226    fn is_terminated(&self) -> bool {
6227        self.event_receiver.is_terminated()
6228    }
6229}
6230
6231impl futures::Stream for AudioDeviceEnumeratorEventStream {
6232    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
6233
6234    fn poll_next(
6235        mut self: std::pin::Pin<&mut Self>,
6236        cx: &mut std::task::Context<'_>,
6237    ) -> std::task::Poll<Option<Self::Item>> {
6238        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6239            &mut self.event_receiver,
6240            cx
6241        )?) {
6242            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
6243            None => std::task::Poll::Ready(None),
6244        }
6245    }
6246}
6247
6248#[derive(Debug)]
6249pub enum AudioDeviceEnumeratorEvent {
6250    OnDeviceAdded { device: AudioDeviceInfo },
6251    OnDeviceRemoved { device_token: u64 },
6252    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
6253    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
6254}
6255
6256impl AudioDeviceEnumeratorEvent {
6257    #[allow(irrefutable_let_patterns)]
6258    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
6259        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
6260            Some((device))
6261        } else {
6262            None
6263        }
6264    }
6265    #[allow(irrefutable_let_patterns)]
6266    pub fn into_on_device_removed(self) -> Option<u64> {
6267        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
6268            Some((device_token))
6269        } else {
6270            None
6271        }
6272    }
6273    #[allow(irrefutable_let_patterns)]
6274    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
6275        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
6276            Some((device_token, gain_info))
6277        } else {
6278            None
6279        }
6280    }
6281    #[allow(irrefutable_let_patterns)]
6282    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
6283        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
6284            old_default_token,
6285            new_default_token,
6286        } = self
6287        {
6288            Some((old_default_token, new_default_token))
6289        } else {
6290            None
6291        }
6292    }
6293
6294    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
6295    fn decode(
6296        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6297    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
6298        let (bytes, _handles) = buf.split_mut();
6299        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6300        debug_assert_eq!(tx_header.tx_id, 0);
6301        match tx_header.ordinal {
6302            0xe0fbe40057c4b44 => {
6303                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceAddedRequest, fdomain_client::fidl::FDomainResourceDialect);
6304                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6305                Ok((
6306                    AudioDeviceEnumeratorEvent::OnDeviceAdded {device: out.device,
6307
6308                    }
6309                ))
6310            }
6311            0x6f3b7574463d9ff8 => {
6312                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceRemovedRequest, fdomain_client::fidl::FDomainResourceDialect);
6313                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6314                Ok((
6315                    AudioDeviceEnumeratorEvent::OnDeviceRemoved {device_token: out.device_token,
6316
6317                    }
6318                ))
6319            }
6320            0x14aefcbbb076b0e9 => {
6321                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDeviceGainChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
6322                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6323                Ok((
6324                    AudioDeviceEnumeratorEvent::OnDeviceGainChanged {device_token: out.device_token,
6325gain_info: out.gain_info,
6326
6327                    }
6328                ))
6329            }
6330            0x16357b42d4c16e11 => {
6331                let mut out = fidl::new_empty!(AudioDeviceEnumeratorOnDefaultDeviceChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
6332                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
6333                Ok((
6334                    AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {old_default_token: out.old_default_token,
6335new_default_token: out.new_default_token,
6336
6337                    }
6338                ))
6339            }
6340            _ => Err(fidl::Error::UnknownOrdinal {
6341                ordinal: tx_header.ordinal,
6342                protocol_name: <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
6343            })
6344        }
6345    }
6346}
6347
6348/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
6349pub struct AudioDeviceEnumeratorRequestStream {
6350    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6351    is_terminated: bool,
6352}
6353
6354impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
6355
6356impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
6357    fn is_terminated(&self) -> bool {
6358        self.is_terminated
6359    }
6360}
6361
6362impl fdomain_client::fidl::RequestStream for AudioDeviceEnumeratorRequestStream {
6363    type Protocol = AudioDeviceEnumeratorMarker;
6364    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6365
6366    fn from_channel(channel: fdomain_client::Channel) -> Self {
6367        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6368    }
6369
6370    fn control_handle(&self) -> Self::ControlHandle {
6371        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
6372    }
6373
6374    fn into_inner(
6375        self,
6376    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
6377    {
6378        (self.inner, self.is_terminated)
6379    }
6380
6381    fn from_inner(
6382        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6383        is_terminated: bool,
6384    ) -> Self {
6385        Self { inner, is_terminated }
6386    }
6387}
6388
6389impl futures::Stream for AudioDeviceEnumeratorRequestStream {
6390    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
6391
6392    fn poll_next(
6393        mut self: std::pin::Pin<&mut Self>,
6394        cx: &mut std::task::Context<'_>,
6395    ) -> std::task::Poll<Option<Self::Item>> {
6396        let this = &mut *self;
6397        if this.inner.check_shutdown(cx) {
6398            this.is_terminated = true;
6399            return std::task::Poll::Ready(None);
6400        }
6401        if this.is_terminated {
6402            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
6403        }
6404        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
6405            |bytes, handles| {
6406                match this.inner.channel().read_etc(cx, bytes, handles) {
6407                    std::task::Poll::Ready(Ok(())) => {}
6408                    std::task::Poll::Pending => return std::task::Poll::Pending,
6409                    std::task::Poll::Ready(Err(None)) => {
6410                        this.is_terminated = true;
6411                        return std::task::Poll::Ready(None);
6412                    }
6413                    std::task::Poll::Ready(Err(Some(e))) => {
6414                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6415                            e.into(),
6416                        ))));
6417                    }
6418                }
6419
6420                // A message has been received from the channel
6421                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6422
6423                std::task::Poll::Ready(Some(match header.ordinal {
6424                0x4ce1aa218aeb12a6 => {
6425                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6426                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
6427                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6428                    let control_handle = AudioDeviceEnumeratorControlHandle {
6429                        inner: this.inner.clone(),
6430                    };
6431                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
6432                        responder: AudioDeviceEnumeratorGetDevicesResponder {
6433                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6434                            tx_id: header.tx_id,
6435                        },
6436                    })
6437                }
6438                0x25dd4723403c414b => {
6439                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6440                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fdomain_client::fidl::FDomainResourceDialect);
6441                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
6442                    let control_handle = AudioDeviceEnumeratorControlHandle {
6443                        inner: this.inner.clone(),
6444                    };
6445                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
6446
6447                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
6448                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6449                            tx_id: header.tx_id,
6450                        },
6451                    })
6452                }
6453                0x5bdabc8ebe83591 => {
6454                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6455                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fdomain_client::fidl::FDomainResourceDialect);
6456                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
6457                    let control_handle = AudioDeviceEnumeratorControlHandle {
6458                        inner: this.inner.clone(),
6459                    };
6460                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
6461gain_info: req.gain_info,
6462valid_flags: req.valid_flags,
6463
6464                        control_handle,
6465                    })
6466                }
6467                0x72cdbada4d70ed67 => {
6468                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6469                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fdomain_client::fidl::FDomainResourceDialect);
6470                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
6471                    let control_handle = AudioDeviceEnumeratorControlHandle {
6472                        inner: this.inner.clone(),
6473                    };
6474                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
6475is_input: req.is_input,
6476channel: req.channel,
6477
6478                        control_handle,
6479                    })
6480                }
6481                _ => Err(fidl::Error::UnknownOrdinal {
6482                    ordinal: header.ordinal,
6483                    protocol_name: <AudioDeviceEnumeratorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
6484                }),
6485            }))
6486            },
6487        )
6488    }
6489}
6490
6491#[derive(Debug)]
6492pub enum AudioDeviceEnumeratorRequest {
6493    /// Obtain the list of currently active audio devices.
6494    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
6495    /// Gain/Mute/AGC control
6496    ///
6497    /// Note that each of these operations requires a device_token in order to
6498    /// target the proper input/output.
6499    ///
6500    /// The Get command returns the device_token of the device whose gain is
6501    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
6502    /// device_token was invalid or the device had been removed from the system
6503    /// before the Get command could be processed.
6504    ///
6505    /// Set commands which are given an invalid device token are ignored and
6506    /// have no effect on the system. In addition, users do not need to control
6507    /// all of the gain settings for an audio device with each call. Only the
6508    /// settings with a corresponding flag set in the set_flags parameter will
6509    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
6510    /// a SetDeviceGain call to care only about the mute setting in the
6511    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
6512    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
6513    /// status to be changed simultaneously.
6514    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
6515    SetDeviceGain {
6516        device_token: u64,
6517        gain_info: AudioGainInfo,
6518        valid_flags: AudioGainValidFlags,
6519        control_handle: AudioDeviceEnumeratorControlHandle,
6520    },
6521    /// # Deprecation
6522    ///
6523    /// StreamConfig is not supported anymore, instead use an
6524    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
6525    /// , see
6526    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
6527    AddDeviceByChannel {
6528        device_name: String,
6529        is_input: bool,
6530        channel:
6531            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
6532        control_handle: AudioDeviceEnumeratorControlHandle,
6533    },
6534}
6535
6536impl AudioDeviceEnumeratorRequest {
6537    #[allow(irrefutable_let_patterns)]
6538    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
6539        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
6540            Some((responder))
6541        } else {
6542            None
6543        }
6544    }
6545
6546    #[allow(irrefutable_let_patterns)]
6547    pub fn into_get_device_gain(
6548        self,
6549    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
6550        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
6551            Some((device_token, responder))
6552        } else {
6553            None
6554        }
6555    }
6556
6557    #[allow(irrefutable_let_patterns)]
6558    pub fn into_set_device_gain(
6559        self,
6560    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
6561        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
6562            device_token,
6563            gain_info,
6564            valid_flags,
6565            control_handle,
6566        } = self
6567        {
6568            Some((device_token, gain_info, valid_flags, control_handle))
6569        } else {
6570            None
6571        }
6572    }
6573
6574    #[allow(irrefutable_let_patterns)]
6575    pub fn into_add_device_by_channel(
6576        self,
6577    ) -> Option<(
6578        String,
6579        bool,
6580        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_hardware_audio::StreamConfigMarker>,
6581        AudioDeviceEnumeratorControlHandle,
6582    )> {
6583        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
6584            device_name,
6585            is_input,
6586            channel,
6587            control_handle,
6588        } = self
6589        {
6590            Some((device_name, is_input, channel, control_handle))
6591        } else {
6592            None
6593        }
6594    }
6595
6596    /// Name of the method defined in FIDL
6597    pub fn method_name(&self) -> &'static str {
6598        match *self {
6599            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
6600            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
6601            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
6602            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
6603        }
6604    }
6605}
6606
6607#[derive(Debug, Clone)]
6608pub struct AudioDeviceEnumeratorControlHandle {
6609    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
6610}
6611
6612impl AudioDeviceEnumeratorControlHandle {
6613    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6614        self.inner.shutdown_with_epitaph(status.into())
6615    }
6616}
6617
6618impl fdomain_client::fidl::ControlHandle for AudioDeviceEnumeratorControlHandle {
6619    fn shutdown(&self) {
6620        self.inner.shutdown()
6621    }
6622
6623    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6624        self.inner.shutdown_with_epitaph(status)
6625    }
6626
6627    fn is_closed(&self) -> bool {
6628        self.inner.channel().is_closed()
6629    }
6630    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
6631        self.inner.channel().on_closed()
6632    }
6633}
6634
6635impl AudioDeviceEnumeratorControlHandle {
6636    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
6637        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
6638            (device,),
6639            0,
6640            0xe0fbe40057c4b44,
6641            fidl::encoding::DynamicFlags::empty(),
6642        )
6643    }
6644
6645    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
6646        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
6647            (device_token,),
6648            0,
6649            0x6f3b7574463d9ff8,
6650            fidl::encoding::DynamicFlags::empty(),
6651        )
6652    }
6653
6654    pub fn send_on_device_gain_changed(
6655        &self,
6656        mut device_token: u64,
6657        mut gain_info: &AudioGainInfo,
6658    ) -> Result<(), fidl::Error> {
6659        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
6660            (device_token, gain_info),
6661            0,
6662            0x14aefcbbb076b0e9,
6663            fidl::encoding::DynamicFlags::empty(),
6664        )
6665    }
6666
6667    pub fn send_on_default_device_changed(
6668        &self,
6669        mut old_default_token: u64,
6670        mut new_default_token: u64,
6671    ) -> Result<(), fidl::Error> {
6672        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
6673            (old_default_token, new_default_token),
6674            0,
6675            0x16357b42d4c16e11,
6676            fidl::encoding::DynamicFlags::empty(),
6677        )
6678    }
6679}
6680
6681#[must_use = "FIDL methods require a response to be sent"]
6682#[derive(Debug)]
6683pub struct AudioDeviceEnumeratorGetDevicesResponder {
6684    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
6685    tx_id: u32,
6686}
6687
6688/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
6689/// if the responder is dropped without sending a response, so that the client
6690/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6691impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
6692    fn drop(&mut self) {
6693        self.control_handle.shutdown();
6694        // Safety: drops once, never accessed again
6695        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6696    }
6697}
6698
6699impl fdomain_client::fidl::Responder for AudioDeviceEnumeratorGetDevicesResponder {
6700    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6701
6702    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
6703        &self.control_handle
6704    }
6705
6706    fn drop_without_shutdown(mut self) {
6707        // Safety: drops once, never accessed again due to mem::forget
6708        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6709        // Prevent Drop from running (which would shut down the channel)
6710        std::mem::forget(self);
6711    }
6712}
6713
6714impl AudioDeviceEnumeratorGetDevicesResponder {
6715    /// Sends a response to the FIDL transaction.
6716    ///
6717    /// Sets the channel to shutdown if an error occurs.
6718    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
6719        let _result = self.send_raw(devices);
6720        if _result.is_err() {
6721            self.control_handle.shutdown();
6722        }
6723        self.drop_without_shutdown();
6724        _result
6725    }
6726
6727    /// Similar to "send" but does not shutdown the channel if an error occurs.
6728    pub fn send_no_shutdown_on_err(
6729        self,
6730        mut devices: &[AudioDeviceInfo],
6731    ) -> Result<(), fidl::Error> {
6732        let _result = self.send_raw(devices);
6733        self.drop_without_shutdown();
6734        _result
6735    }
6736
6737    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
6738        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
6739            (devices,),
6740            self.tx_id,
6741            0x4ce1aa218aeb12a6,
6742            fidl::encoding::DynamicFlags::empty(),
6743        )
6744    }
6745}
6746
6747#[must_use = "FIDL methods require a response to be sent"]
6748#[derive(Debug)]
6749pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
6750    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
6751    tx_id: u32,
6752}
6753
6754/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
6755/// if the responder is dropped without sending a response, so that the client
6756/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6757impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
6758    fn drop(&mut self) {
6759        self.control_handle.shutdown();
6760        // Safety: drops once, never accessed again
6761        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6762    }
6763}
6764
6765impl fdomain_client::fidl::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
6766    type ControlHandle = AudioDeviceEnumeratorControlHandle;
6767
6768    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
6769        &self.control_handle
6770    }
6771
6772    fn drop_without_shutdown(mut self) {
6773        // Safety: drops once, never accessed again due to mem::forget
6774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6775        // Prevent Drop from running (which would shut down the channel)
6776        std::mem::forget(self);
6777    }
6778}
6779
6780impl AudioDeviceEnumeratorGetDeviceGainResponder {
6781    /// Sends a response to the FIDL transaction.
6782    ///
6783    /// Sets the channel to shutdown if an error occurs.
6784    pub fn send(
6785        self,
6786        mut device_token: u64,
6787        mut gain_info: &AudioGainInfo,
6788    ) -> Result<(), fidl::Error> {
6789        let _result = self.send_raw(device_token, gain_info);
6790        if _result.is_err() {
6791            self.control_handle.shutdown();
6792        }
6793        self.drop_without_shutdown();
6794        _result
6795    }
6796
6797    /// Similar to "send" but does not shutdown the channel if an error occurs.
6798    pub fn send_no_shutdown_on_err(
6799        self,
6800        mut device_token: u64,
6801        mut gain_info: &AudioGainInfo,
6802    ) -> Result<(), fidl::Error> {
6803        let _result = self.send_raw(device_token, gain_info);
6804        self.drop_without_shutdown();
6805        _result
6806    }
6807
6808    fn send_raw(
6809        &self,
6810        mut device_token: u64,
6811        mut gain_info: &AudioGainInfo,
6812    ) -> Result<(), fidl::Error> {
6813        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
6814            (device_token, gain_info),
6815            self.tx_id,
6816            0x25dd4723403c414b,
6817            fidl::encoding::DynamicFlags::empty(),
6818        )
6819    }
6820}
6821
6822#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6823pub struct AudioRendererMarker;
6824
6825impl fdomain_client::fidl::ProtocolMarker for AudioRendererMarker {
6826    type Proxy = AudioRendererProxy;
6827    type RequestStream = AudioRendererRequestStream;
6828
6829    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
6830}
6831impl fdomain_client::fidl::DiscoverableProtocolMarker for AudioRendererMarker {}
6832
6833pub trait AudioRendererProxyInterface: Send + Sync {
6834    fn r#add_payload_buffer(
6835        &self,
6836        id: u32,
6837        payload_buffer: fdomain_client::Vmo,
6838    ) -> Result<(), fidl::Error>;
6839    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
6840    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6841    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
6842    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
6843    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
6844    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
6845    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
6846    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
6847    fn r#bind_gain_control(
6848        &self,
6849        gain_control_request: fdomain_client::fidl::ServerEnd<
6850            fdomain_fuchsia_media_audio::GainControlMarker,
6851        >,
6852    ) -> Result<(), fidl::Error>;
6853    fn r#set_pts_units(
6854        &self,
6855        tick_per_second_numerator: u32,
6856        tick_per_second_denominator: u32,
6857    ) -> Result<(), fidl::Error>;
6858    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
6859    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fdomain_client::Clock, fidl::Error>>
6860        + Send;
6861    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
6862    fn r#set_reference_clock(
6863        &self,
6864        reference_clock: Option<fdomain_client::Clock>,
6865    ) -> Result<(), fidl::Error>;
6866    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
6867    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
6868    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
6869    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
6870    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
6871    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
6872    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
6873    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
6874    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
6875    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
6876    fn r#pause(&self) -> Self::PauseResponseFut;
6877    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
6878}
6879
6880#[derive(Debug, Clone)]
6881pub struct AudioRendererProxy {
6882    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
6883}
6884
6885impl fdomain_client::fidl::Proxy for AudioRendererProxy {
6886    type Protocol = AudioRendererMarker;
6887
6888    fn from_channel(inner: fdomain_client::Channel) -> Self {
6889        Self::new(inner)
6890    }
6891
6892    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
6893        self.client.into_channel().map_err(|client| Self { client })
6894    }
6895
6896    fn as_channel(&self) -> &fdomain_client::Channel {
6897        self.client.as_channel()
6898    }
6899}
6900
6901impl AudioRendererProxy {
6902    /// Create a new Proxy for fuchsia.media/AudioRenderer.
6903    pub fn new(channel: fdomain_client::Channel) -> Self {
6904        let protocol_name =
6905            <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
6906        Self { client: fidl::client::Client::new(channel, protocol_name) }
6907    }
6908
6909    /// Get a Stream of events from the remote end of the protocol.
6910    ///
6911    /// # Panics
6912    ///
6913    /// Panics if the event stream was already taken.
6914    pub fn take_event_stream(&self) -> AudioRendererEventStream {
6915        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
6916    }
6917
6918    /// Adds a payload buffer to the current buffer set associated with the
6919    /// connection. A `StreamPacket` struct reference a payload buffer in the
6920    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
6921    ///
6922    /// A buffer with ID `id` must not be in the current set when this method is
6923    /// invoked, otherwise the service will close the connection.
6924    pub fn r#add_payload_buffer(
6925        &self,
6926        mut id: u32,
6927        mut payload_buffer: fdomain_client::Vmo,
6928    ) -> Result<(), fidl::Error> {
6929        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
6930    }
6931
6932    /// Removes a payload buffer from the current buffer set associated with the
6933    /// connection.
6934    ///
6935    /// A buffer with ID `id` must exist in the current set when this method is
6936    /// invoked, otherwise the service will will close the connection.
6937    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
6938        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
6939    }
6940
6941    /// Sends a packet to the service. The response is sent when the service is
6942    /// done with the associated payload memory.
6943    ///
6944    /// `packet` must be valid for the current buffer set, otherwise the service
6945    /// will close the connection.
6946    pub fn r#send_packet(
6947        &self,
6948        mut packet: &StreamPacket,
6949    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6950        AudioRendererProxyInterface::r#send_packet(self, packet)
6951    }
6952
6953    /// Sends a packet to the service. This interface doesn't define how the
6954    /// client knows when the sink is done with the associated payload memory.
6955    /// The inheriting interface must define that.
6956    ///
6957    /// `packet` must be valid for the current buffer set, otherwise the service
6958    /// will close the connection.
6959    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
6960        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
6961    }
6962
6963    /// Indicates the stream has ended. The precise semantics of this method are
6964    /// determined by the inheriting interface.
6965    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
6966        AudioRendererProxyInterface::r#end_of_stream(self)
6967    }
6968
6969    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
6970    /// and not yet released. The response is sent after all packets have been
6971    /// released.
6972    pub fn r#discard_all_packets(
6973        &self,
6974    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
6975        AudioRendererProxyInterface::r#discard_all_packets(self)
6976    }
6977
6978    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
6979    /// and not yet released.
6980    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
6981        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
6982    }
6983
6984    /// Binds to the gain control for this AudioRenderer.
6985    pub fn r#bind_gain_control(
6986        &self,
6987        mut gain_control_request: fdomain_client::fidl::ServerEnd<
6988            fdomain_fuchsia_media_audio::GainControlMarker,
6989        >,
6990    ) -> Result<(), fidl::Error> {
6991        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
6992    }
6993
6994    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
6995    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
6996    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
6997    pub fn r#set_pts_units(
6998        &self,
6999        mut tick_per_second_numerator: u32,
7000        mut tick_per_second_denominator: u32,
7001    ) -> Result<(), fidl::Error> {
7002        AudioRendererProxyInterface::r#set_pts_units(
7003            self,
7004            tick_per_second_numerator,
7005            tick_per_second_denominator,
7006        )
7007    }
7008
7009    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
7010    /// and expected PTS (determined using interpolation). Beyond this threshold,
7011    /// a stream is no longer considered 'continuous' by the renderer.
7012    ///
7013    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
7014    /// Most users should not need to change this value from its default.
7015    ///
7016    /// Example:
7017    /// A user is playing back 48KHz audio from a container, which also contains
7018    /// video and needs to be synchronized with the audio. The timestamps are
7019    /// provided explicitly per packet by the container, and expressed in mSec
7020    /// units. This means that a single tick of the media timeline (1 mSec)
7021    /// represents exactly 48 frames of audio. The application in this scenario
7022    /// delivers packets of audio to the AudioRenderer, each with exactly 470
7023    /// frames of audio, and each with an explicit timestamp set to the best
7024    /// possible representation of the presentation time (given this media
7025    /// clock's resolution). So, starting from zero, the timestamps would be..
7026    ///
7027    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
7028    ///
7029    /// In this example, attempting to use the presentation time to compute the
7030    /// starting frame number of the audio in the packet would be wrong the
7031    /// majority of the time. The first timestamp is correct (by definition), but
7032    /// it will be 24 packets before the timestamps and frame numbers come back
7033    /// into alignment (the 24th packet would start with the 11280th audio frame
7034    /// and have a PTS of exactly 235).
7035    ///
7036    /// One way to fix this situation is to set the PTS continuity threshold
7037    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
7038    /// the number of frames contained within a single tick of the media clock,
7039    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
7040    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
7041    /// explicitly provided PTS would be considered to be a continuation of the
7042    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
7043    /// would work well.
7044    ///
7045    /// Other possible uses:
7046    /// Users who are scheduling audio explicitly, relative to a clock which has
7047    /// not been configured as the reference clock, can use this value to control
7048    /// the maximum acceptable synchronization error before a discontinuity is
7049    /// introduced. E.g., if a user is scheduling audio based on a recovered
7050    /// common media clock, and has not published that clock as the reference
7051    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
7052    /// can accumulate before the AudioRenderer deliberately inserts a
7053    /// presentation discontinuity to account for the error.
7054    ///
7055    /// Users whose need to deal with a container where their timestamps may be
7056    /// even less correct than +/- 1/2 of a PTS tick may set this value to
7057    /// something larger. This should be the maximum level of inaccuracy present
7058    /// in the container timestamps, if known. Failing that, it could be set to
7059    /// the maximum tolerable level of drift error before absolute timestamps are
7060    /// explicitly obeyed. Finally, a user could set this number to a very large
7061    /// value (86400.0 seconds, for example) to effectively cause *all*
7062    /// timestamps to be ignored after the first, thus treating all audio as
7063    /// continuous with previously delivered packets. Conversely, users who wish
7064    /// to *always* explicitly schedule their audio packets exactly may specify
7065    /// a CT of 0.
7066    ///
7067    /// Note: explicitly specifying high-frequency PTS units reduces the default
7068    /// continuity threshold accordingly. Internally, this threshold is stored as an
7069    /// integer of 1/8192 subframes. The default threshold is computed as follows:
7070    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
7071    /// For this reason, specifying PTS units with a frequency greater than 8192x
7072    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
7073    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
7074    pub fn r#set_pts_continuity_threshold(
7075        &self,
7076        mut threshold_seconds: f32,
7077    ) -> Result<(), fidl::Error> {
7078        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
7079    }
7080
7081    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
7082    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
7083    pub fn r#get_reference_clock(
7084        &self,
7085    ) -> fidl::client::QueryResponseFut<
7086        fdomain_client::Clock,
7087        fdomain_client::fidl::FDomainResourceDialect,
7088    > {
7089        AudioRendererProxyInterface::r#get_reference_clock(self)
7090    }
7091
7092    /// Sets the reference clock that controls this renderer's playback rate. If the input
7093    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
7094    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
7095    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
7096    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
7097    ///
7098    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
7099    /// cannot be called a second time (even if the renderer format has not yet been set).
7100    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
7101    /// diverge at some later time, they should create a clone of the monotonic clock, set
7102    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
7103    pub fn r#set_reference_clock(
7104        &self,
7105        mut reference_clock: Option<fdomain_client::Clock>,
7106    ) -> Result<(), fidl::Error> {
7107        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
7108    }
7109
7110    /// Sets the usage of the render stream. This method may not be called after
7111    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
7112    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
7113        AudioRendererProxyInterface::r#set_usage(self, usage)
7114    }
7115
7116    /// Sets the usage of the render stream. This method may not be called after
7117    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
7118    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
7119        AudioRendererProxyInterface::r#set_usage2(self, usage2)
7120    }
7121
7122    /// Sets the type of the stream to be delivered by the client. Using this method implies
7123    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
7124    ///
7125    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
7126    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
7127    /// methods such as `SendPacket`/`SendPacketNoReply`.
7128    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
7129        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
7130    }
7131
7132    /// Enables or disables notifications about changes to the minimum clock lead
7133    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
7134    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
7135    /// event with the current minimum lead time for the AudioRenderer. If the
7136    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
7137    /// new value. This behavior will continue until the user calls
7138    /// `EnableMinLeadTimeEvents(false)`.
7139    ///
7140    /// The minimum clock lead time is the amount of time ahead of the reference
7141    /// clock's understanding of "now" that packets needs to arrive (relative to
7142    /// the playback clock transformation) in order for the mixer to be able to
7143    /// mix packet. For example...
7144    ///
7145    /// + Let the PTS of packet X be P(X)
7146    /// + Let the function which transforms PTS -> RefClock be R(p) (this
7147    ///   function is determined by the call to Play(...)
7148    /// + Let the minimum lead time be MLT
7149    ///
7150    /// If R(P(X)) < RefClock.Now() + MLT
7151    /// Then the packet is late, and some (or all) of the packet's payload will
7152    /// need to be skipped in order to present the packet at the scheduled time.
7153    ///
7154    /// The value `min_lead_time_nsec = 0` is a special value which indicates
7155    /// that the AudioRenderer is not yet routed to an output device. If `Play`
7156    /// is called before the AudioRenderer is routed, any played packets will be
7157    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
7158    /// calling `Play`.
7159    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
7160        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
7161    }
7162
7163    ///
7164    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
7165    /// there's little reason to do so. This is because lead time is a function
7166    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
7167    /// If min lead time events are enabled before `SetPcmStreamType` (with
7168    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
7169    /// response to `SetPcmStreamType`.
7170    pub fn r#get_min_lead_time(
7171        &self,
7172    ) -> fidl::client::QueryResponseFut<i64, fdomain_client::fidl::FDomainResourceDialect> {
7173        AudioRendererProxyInterface::r#get_min_lead_time(self)
7174    }
7175
7176    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
7177    /// of the media timeline, using specific values provided by the caller (or
7178    /// default values if not specified). In an optional callback, returns the
7179    /// timestamp values ultimately used -- these set the ongoing relationship
7180    /// between the media and reference timelines (i.e., how to translate between
7181    /// the domain of presentation timestamps, and the realm of local system
7182    /// time).
7183    ///
7184    /// Local system time is specified in units of nanoseconds; media_time is
7185    /// specified in the units defined by the user in the `SetPtsUnits` function,
7186    /// or nanoseconds if `SetPtsUnits` is not called.
7187    ///
7188    /// The act of placing an AudioRenderer into the playback state establishes a
7189    /// relationship between 1) the user-defined media (or presentation) timeline
7190    /// for this particular AudioRenderer, and 2) the real-world system reference
7191    /// timeline. To communicate how to translate between timelines, the Play()
7192    /// callback provides an equivalent timestamp in each time domain. The first
7193    /// value ('reference_time') is given in terms of this renderer's reference
7194    /// clock; the second value ('media_time') is what media instant exactly
7195    /// corresponds to that local time. Restated, the frame at 'media_time' in
7196    /// the audio stream should be presented at 'reference_time' according to
7197    /// the reference clock.
7198    ///
7199    /// Note: on calling this API, media_time immediately starts advancing. It is
7200    /// possible (if uncommon) for a caller to specify a system time that is
7201    /// far in the past, or far into the future. This, along with the specified
7202    /// media time, is simply used to determine what media time corresponds to
7203    /// 'now', and THAT media time is then intersected with presentation
7204    /// timestamps of packets already submitted, to determine which media frames
7205    /// should be presented next.
7206    ///
7207    /// With the corresponding reference_time and media_time values, a user can
7208    /// translate arbitrary time values from one timeline into the other. After
7209    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
7210    /// given the 'ref_start' and 'media_start' values from `Play`, then for
7211    /// any 'ref_time':
7212    ///
7213    /// media_time = ( (ref_time - ref_start) / 1e9
7214    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
7215    ///              + media_start
7216    ///
7217    /// Conversely, for any presentation timestamp 'media_time':
7218    ///
7219    /// ref_time = ( (media_time - media_start)
7220    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
7221    ///              * 1e9 )
7222    ///            + ref_start
7223    ///
7224    /// Users, depending on their use case, may optionally choose not to specify
7225    /// one or both of these timestamps. A timestamp may be omitted by supplying
7226    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
7227    /// any omitted timestamp value using the following rules:
7228    ///
7229    /// Reference Time
7230    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
7231    /// reference time to begin presentation, based on the minimum lead times for
7232    /// the output devices that are currently bound to this AudioRenderer. For
7233    /// example, if an AudioRenderer is bound to an internal audio output
7234    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
7235    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
7236    /// is omitted) select a reference time 80 mSec from now.
7237    ///
7238    /// Media Time
7239    /// If media_time is omitted, the AudioRenderer will select one of two
7240    /// values.
7241    /// - If the AudioRenderer is resuming from the paused state, and packets
7242    /// have not been discarded since being paused, then the AudioRenderer will
7243    /// use a media_time corresponding to the instant at which the presentation
7244    /// became paused.
7245    /// - If the AudioRenderer is being placed into a playing state for the first
7246    /// time following startup or a 'discard packets' operation, the initial
7247    /// media_time will be set to the PTS of the first payload in the pending
7248    /// packet queue. If the pending queue is empty, initial media_time will be
7249    /// set to zero.
7250    ///
7251    /// Return Value
7252    /// When requested, the AudioRenderer will return the 'reference_time' and
7253    /// 'media_time' which were selected and used (whether they were explicitly
7254    /// specified or not) in the return value of the play call.
7255    ///
7256    /// Examples
7257    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
7258    /// to start playing as soon as possible. The user may call Play without
7259    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
7260    ///
7261    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
7262    /// playback at a specified 'reference_time', in sync with some other media
7263    /// stream, either initially or after discarding packets. The user would call
7264    /// `Play(reference_time, NO_TIMESTAMP)`.
7265    ///
7266    /// 3. A user has queued some audio using `SendPacket`. The first of these
7267    /// packets has a PTS of zero, and the user wishes playback to begin as soon
7268    /// as possible, but wishes to skip all of the audio content between PTS 0
7269    /// and PTS 'media_time'. The user would call
7270    /// `Play(NO_TIMESTAMP, media_time)`.
7271    ///
7272    /// 4. A user has queued some audio using `SendPacket` and want to present
7273    /// this media in synch with another player in a different device. The
7274    /// coordinator of the group of distributed players sends an explicit
7275    /// message to each player telling them to begin presentation of audio at
7276    /// PTS 'media_time', at the time (based on the group's shared reference
7277    /// clock) 'reference_time'. Here the user would call
7278    /// `Play(reference_time, media_time)`.
7279    pub fn r#play(
7280        &self,
7281        mut reference_time: i64,
7282        mut media_time: i64,
7283    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
7284    {
7285        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
7286    }
7287
7288    pub fn r#play_no_reply(
7289        &self,
7290        mut reference_time: i64,
7291        mut media_time: i64,
7292    ) -> Result<(), fidl::Error> {
7293        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
7294    }
7295
7296    /// Immediately puts the AudioRenderer into the paused state and then report
7297    /// the relationship between the media and reference timelines which was
7298    /// established (if requested).
7299    ///
7300    /// If the AudioRenderer is already in the paused state when this called,
7301    /// the previously-established timeline values are returned (if requested).
7302    pub fn r#pause(
7303        &self,
7304    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
7305    {
7306        AudioRendererProxyInterface::r#pause(self)
7307    }
7308
7309    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
7310        AudioRendererProxyInterface::r#pause_no_reply(self)
7311    }
7312}
7313
7314impl AudioRendererProxyInterface for AudioRendererProxy {
7315    fn r#add_payload_buffer(
7316        &self,
7317        mut id: u32,
7318        mut payload_buffer: fdomain_client::Vmo,
7319    ) -> Result<(), fidl::Error> {
7320        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
7321            (id, payload_buffer),
7322            0x3b3a37fc34fe5b56,
7323            fidl::encoding::DynamicFlags::empty(),
7324        )
7325    }
7326
7327    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
7328        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
7329            (id,),
7330            0x5d1e4f74c3658262,
7331            fidl::encoding::DynamicFlags::empty(),
7332        )
7333    }
7334
7335    type SendPacketResponseFut =
7336        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7337    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
7338        fn _decode(
7339            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7340        ) -> Result<(), fidl::Error> {
7341            let _response = fidl::client::decode_transaction_body::<
7342                fidl::encoding::EmptyPayload,
7343                fdomain_client::fidl::FDomainResourceDialect,
7344                0x67cddd607442775f,
7345            >(_buf?)?;
7346            Ok(_response)
7347        }
7348        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
7349            (packet,),
7350            0x67cddd607442775f,
7351            fidl::encoding::DynamicFlags::empty(),
7352            _decode,
7353        )
7354    }
7355
7356    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
7357        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
7358            (packet,),
7359            0x8d9b8b413ceba9d,
7360            fidl::encoding::DynamicFlags::empty(),
7361        )
7362    }
7363
7364    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
7365        self.client.send::<fidl::encoding::EmptyPayload>(
7366            (),
7367            0x6180fd6f7e793b71,
7368            fidl::encoding::DynamicFlags::empty(),
7369        )
7370    }
7371
7372    type DiscardAllPacketsResponseFut =
7373        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
7374    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
7375        fn _decode(
7376            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7377        ) -> Result<(), fidl::Error> {
7378            let _response = fidl::client::decode_transaction_body::<
7379                fidl::encoding::EmptyPayload,
7380                fdomain_client::fidl::FDomainResourceDialect,
7381                0x6f4dad7af2917665,
7382            >(_buf?)?;
7383            Ok(_response)
7384        }
7385        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
7386            (),
7387            0x6f4dad7af2917665,
7388            fidl::encoding::DynamicFlags::empty(),
7389            _decode,
7390        )
7391    }
7392
7393    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
7394        self.client.send::<fidl::encoding::EmptyPayload>(
7395            (),
7396            0x50d36d0d23081bc4,
7397            fidl::encoding::DynamicFlags::empty(),
7398        )
7399    }
7400
7401    fn r#bind_gain_control(
7402        &self,
7403        mut gain_control_request: fdomain_client::fidl::ServerEnd<
7404            fdomain_fuchsia_media_audio::GainControlMarker,
7405        >,
7406    ) -> Result<(), fidl::Error> {
7407        self.client.send::<AudioRendererBindGainControlRequest>(
7408            (gain_control_request,),
7409            0x293f5c7f8fba2bdc,
7410            fidl::encoding::DynamicFlags::empty(),
7411        )
7412    }
7413
7414    fn r#set_pts_units(
7415        &self,
7416        mut tick_per_second_numerator: u32,
7417        mut tick_per_second_denominator: u32,
7418    ) -> Result<(), fidl::Error> {
7419        self.client.send::<AudioRendererSetPtsUnitsRequest>(
7420            (tick_per_second_numerator, tick_per_second_denominator),
7421            0xf68cd108785a27c,
7422            fidl::encoding::DynamicFlags::empty(),
7423        )
7424    }
7425
7426    fn r#set_pts_continuity_threshold(
7427        &self,
7428        mut threshold_seconds: f32,
7429    ) -> Result<(), fidl::Error> {
7430        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
7431            (threshold_seconds,),
7432            0x2849ba571d1971ba,
7433            fidl::encoding::DynamicFlags::empty(),
7434        )
7435    }
7436
7437    type GetReferenceClockResponseFut = fidl::client::QueryResponseFut<
7438        fdomain_client::Clock,
7439        fdomain_client::fidl::FDomainResourceDialect,
7440    >;
7441    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
7442        fn _decode(
7443            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7444        ) -> Result<fdomain_client::Clock, fidl::Error> {
7445            let _response = fidl::client::decode_transaction_body::<
7446                AudioRendererGetReferenceClockResponse,
7447                fdomain_client::fidl::FDomainResourceDialect,
7448                0x2f7a7f011a172f7e,
7449            >(_buf?)?;
7450            Ok(_response.reference_clock)
7451        }
7452        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fdomain_client::Clock>(
7453            (),
7454            0x2f7a7f011a172f7e,
7455            fidl::encoding::DynamicFlags::empty(),
7456            _decode,
7457        )
7458    }
7459
7460    fn r#set_reference_clock(
7461        &self,
7462        mut reference_clock: Option<fdomain_client::Clock>,
7463    ) -> Result<(), fidl::Error> {
7464        self.client.send::<AudioRendererSetReferenceClockRequest>(
7465            (reference_clock,),
7466            0x39acd05d832b5fed,
7467            fidl::encoding::DynamicFlags::empty(),
7468        )
7469    }
7470
7471    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
7472        self.client.send::<AudioRendererSetUsageRequest>(
7473            (usage,),
7474            0x3994bd23b55a733e,
7475            fidl::encoding::DynamicFlags::empty(),
7476        )
7477    }
7478
7479    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
7480        self.client.send::<AudioRendererSetUsage2Request>(
7481            (usage2,),
7482            0x2904035c7132b103,
7483            fidl::encoding::DynamicFlags::FLEXIBLE,
7484        )
7485    }
7486
7487    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
7488        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
7489            (type_,),
7490            0x27aa715d8901fa19,
7491            fidl::encoding::DynamicFlags::empty(),
7492        )
7493    }
7494
7495    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
7496        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
7497            (enabled,),
7498            0x62808dfad72bf890,
7499            fidl::encoding::DynamicFlags::empty(),
7500        )
7501    }
7502
7503    type GetMinLeadTimeResponseFut =
7504        fidl::client::QueryResponseFut<i64, fdomain_client::fidl::FDomainResourceDialect>;
7505    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
7506        fn _decode(
7507            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7508        ) -> Result<i64, fidl::Error> {
7509            let _response = fidl::client::decode_transaction_body::<
7510                AudioRendererGetMinLeadTimeResponse,
7511                fdomain_client::fidl::FDomainResourceDialect,
7512                0x1cf3c3ecd8fec26b,
7513            >(_buf?)?;
7514            Ok(_response.min_lead_time_nsec)
7515        }
7516        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
7517            (),
7518            0x1cf3c3ecd8fec26b,
7519            fidl::encoding::DynamicFlags::empty(),
7520            _decode,
7521        )
7522    }
7523
7524    type PlayResponseFut =
7525        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
7526    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
7527        fn _decode(
7528            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7529        ) -> Result<(i64, i64), fidl::Error> {
7530            let _response = fidl::client::decode_transaction_body::<
7531                AudioRendererPlayResponse,
7532                fdomain_client::fidl::FDomainResourceDialect,
7533                0x3c0162db084f74a3,
7534            >(_buf?)?;
7535            Ok((_response.reference_time, _response.media_time))
7536        }
7537        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
7538            (reference_time, media_time),
7539            0x3c0162db084f74a3,
7540            fidl::encoding::DynamicFlags::empty(),
7541            _decode,
7542        )
7543    }
7544
7545    fn r#play_no_reply(
7546        &self,
7547        mut reference_time: i64,
7548        mut media_time: i64,
7549    ) -> Result<(), fidl::Error> {
7550        self.client.send::<AudioRendererPlayNoReplyRequest>(
7551            (reference_time, media_time),
7552            0x1b7fe832b68c22ef,
7553            fidl::encoding::DynamicFlags::empty(),
7554        )
7555    }
7556
7557    type PauseResponseFut =
7558        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
7559    fn r#pause(&self) -> Self::PauseResponseFut {
7560        fn _decode(
7561            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7562        ) -> Result<(i64, i64), fidl::Error> {
7563            let _response = fidl::client::decode_transaction_body::<
7564                AudioRendererPauseResponse,
7565                fdomain_client::fidl::FDomainResourceDialect,
7566                0x41d557588d93d153,
7567            >(_buf?)?;
7568            Ok((_response.reference_time, _response.media_time))
7569        }
7570        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
7571            (),
7572            0x41d557588d93d153,
7573            fidl::encoding::DynamicFlags::empty(),
7574            _decode,
7575        )
7576    }
7577
7578    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
7579        self.client.send::<fidl::encoding::EmptyPayload>(
7580            (),
7581            0x24cc45d4f3855ab,
7582            fidl::encoding::DynamicFlags::empty(),
7583        )
7584    }
7585}
7586
7587pub struct AudioRendererEventStream {
7588    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
7589}
7590
7591impl std::marker::Unpin for AudioRendererEventStream {}
7592
7593impl futures::stream::FusedStream for AudioRendererEventStream {
7594    fn is_terminated(&self) -> bool {
7595        self.event_receiver.is_terminated()
7596    }
7597}
7598
7599impl futures::Stream for AudioRendererEventStream {
7600    type Item = Result<AudioRendererEvent, fidl::Error>;
7601
7602    fn poll_next(
7603        mut self: std::pin::Pin<&mut Self>,
7604        cx: &mut std::task::Context<'_>,
7605    ) -> std::task::Poll<Option<Self::Item>> {
7606        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7607            &mut self.event_receiver,
7608            cx
7609        )?) {
7610            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
7611            None => std::task::Poll::Ready(None),
7612        }
7613    }
7614}
7615
7616#[derive(Debug)]
7617pub enum AudioRendererEvent {
7618    OnMinLeadTimeChanged {
7619        min_lead_time_nsec: i64,
7620    },
7621    #[non_exhaustive]
7622    _UnknownEvent {
7623        /// Ordinal of the event that was sent.
7624        ordinal: u64,
7625    },
7626}
7627
7628impl AudioRendererEvent {
7629    #[allow(irrefutable_let_patterns)]
7630    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
7631        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
7632            Some((min_lead_time_nsec))
7633        } else {
7634            None
7635        }
7636    }
7637
7638    /// Decodes a message buffer as a [`AudioRendererEvent`].
7639    fn decode(
7640        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7641    ) -> Result<AudioRendererEvent, fidl::Error> {
7642        let (bytes, _handles) = buf.split_mut();
7643        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7644        debug_assert_eq!(tx_header.tx_id, 0);
7645        match tx_header.ordinal {
7646            0x4feff7d278978c4e => {
7647                let mut out = fidl::new_empty!(
7648                    AudioRendererOnMinLeadTimeChangedRequest,
7649                    fdomain_client::fidl::FDomainResourceDialect
7650                );
7651                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7652                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
7653                    min_lead_time_nsec: out.min_lead_time_nsec,
7654                }))
7655            }
7656            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
7657                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
7658            }
7659            _ => Err(fidl::Error::UnknownOrdinal {
7660                ordinal: tx_header.ordinal,
7661                protocol_name:
7662                    <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
7663            }),
7664        }
7665    }
7666}
7667
7668/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
7669pub struct AudioRendererRequestStream {
7670    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7671    is_terminated: bool,
7672}
7673
7674impl std::marker::Unpin for AudioRendererRequestStream {}
7675
7676impl futures::stream::FusedStream for AudioRendererRequestStream {
7677    fn is_terminated(&self) -> bool {
7678        self.is_terminated
7679    }
7680}
7681
7682impl fdomain_client::fidl::RequestStream for AudioRendererRequestStream {
7683    type Protocol = AudioRendererMarker;
7684    type ControlHandle = AudioRendererControlHandle;
7685
7686    fn from_channel(channel: fdomain_client::Channel) -> Self {
7687        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7688    }
7689
7690    fn control_handle(&self) -> Self::ControlHandle {
7691        AudioRendererControlHandle { inner: self.inner.clone() }
7692    }
7693
7694    fn into_inner(
7695        self,
7696    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
7697    {
7698        (self.inner, self.is_terminated)
7699    }
7700
7701    fn from_inner(
7702        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
7703        is_terminated: bool,
7704    ) -> Self {
7705        Self { inner, is_terminated }
7706    }
7707}
7708
7709impl futures::Stream for AudioRendererRequestStream {
7710    type Item = Result<AudioRendererRequest, fidl::Error>;
7711
7712    fn poll_next(
7713        mut self: std::pin::Pin<&mut Self>,
7714        cx: &mut std::task::Context<'_>,
7715    ) -> std::task::Poll<Option<Self::Item>> {
7716        let this = &mut *self;
7717        if this.inner.check_shutdown(cx) {
7718            this.is_terminated = true;
7719            return std::task::Poll::Ready(None);
7720        }
7721        if this.is_terminated {
7722            panic!("polled AudioRendererRequestStream after completion");
7723        }
7724        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
7725            |bytes, handles| {
7726                match this.inner.channel().read_etc(cx, bytes, handles) {
7727                    std::task::Poll::Ready(Ok(())) => {}
7728                    std::task::Poll::Pending => return std::task::Poll::Pending,
7729                    std::task::Poll::Ready(Err(None)) => {
7730                        this.is_terminated = true;
7731                        return std::task::Poll::Ready(None);
7732                    }
7733                    std::task::Poll::Ready(Err(Some(e))) => {
7734                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7735                            e.into(),
7736                        ))));
7737                    }
7738                }
7739
7740                // A message has been received from the channel
7741                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7742
7743                std::task::Poll::Ready(Some(match header.ordinal {
7744                0x3b3a37fc34fe5b56 => {
7745                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7746                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
7747                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
7748                    let control_handle = AudioRendererControlHandle {
7749                        inner: this.inner.clone(),
7750                    };
7751                    Ok(AudioRendererRequest::AddPayloadBuffer {id: req.id,
7752payload_buffer: req.payload_buffer,
7753
7754                        control_handle,
7755                    })
7756                }
7757                0x5d1e4f74c3658262 => {
7758                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7759                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
7760                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
7761                    let control_handle = AudioRendererControlHandle {
7762                        inner: this.inner.clone(),
7763                    };
7764                    Ok(AudioRendererRequest::RemovePayloadBuffer {id: req.id,
7765
7766                        control_handle,
7767                    })
7768                }
7769                0x67cddd607442775f => {
7770                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7771                    let mut req = fidl::new_empty!(StreamSinkSendPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
7772                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
7773                    let control_handle = AudioRendererControlHandle {
7774                        inner: this.inner.clone(),
7775                    };
7776                    Ok(AudioRendererRequest::SendPacket {packet: req.packet,
7777
7778                        responder: AudioRendererSendPacketResponder {
7779                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7780                            tx_id: header.tx_id,
7781                        },
7782                    })
7783                }
7784                0x8d9b8b413ceba9d => {
7785                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7786                    let mut req = fidl::new_empty!(StreamSinkSendPacketNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
7787                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
7788                    let control_handle = AudioRendererControlHandle {
7789                        inner: this.inner.clone(),
7790                    };
7791                    Ok(AudioRendererRequest::SendPacketNoReply {packet: req.packet,
7792
7793                        control_handle,
7794                    })
7795                }
7796                0x6180fd6f7e793b71 => {
7797                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7798                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7799                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7800                    let control_handle = AudioRendererControlHandle {
7801                        inner: this.inner.clone(),
7802                    };
7803                    Ok(AudioRendererRequest::EndOfStream {
7804                        control_handle,
7805                    })
7806                }
7807                0x6f4dad7af2917665 => {
7808                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7809                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7810                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7811                    let control_handle = AudioRendererControlHandle {
7812                        inner: this.inner.clone(),
7813                    };
7814                    Ok(AudioRendererRequest::DiscardAllPackets {
7815                        responder: AudioRendererDiscardAllPacketsResponder {
7816                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7817                            tx_id: header.tx_id,
7818                        },
7819                    })
7820                }
7821                0x50d36d0d23081bc4 => {
7822                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7823                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7824                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7825                    let control_handle = AudioRendererControlHandle {
7826                        inner: this.inner.clone(),
7827                    };
7828                    Ok(AudioRendererRequest::DiscardAllPacketsNoReply {
7829                        control_handle,
7830                    })
7831                }
7832                0x293f5c7f8fba2bdc => {
7833                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7834                    let mut req = fidl::new_empty!(AudioRendererBindGainControlRequest, fdomain_client::fidl::FDomainResourceDialect);
7835                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
7836                    let control_handle = AudioRendererControlHandle {
7837                        inner: this.inner.clone(),
7838                    };
7839                    Ok(AudioRendererRequest::BindGainControl {gain_control_request: req.gain_control_request,
7840
7841                        control_handle,
7842                    })
7843                }
7844                0xf68cd108785a27c => {
7845                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7846                    let mut req = fidl::new_empty!(AudioRendererSetPtsUnitsRequest, fdomain_client::fidl::FDomainResourceDialect);
7847                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
7848                    let control_handle = AudioRendererControlHandle {
7849                        inner: this.inner.clone(),
7850                    };
7851                    Ok(AudioRendererRequest::SetPtsUnits {tick_per_second_numerator: req.tick_per_second_numerator,
7852tick_per_second_denominator: req.tick_per_second_denominator,
7853
7854                        control_handle,
7855                    })
7856                }
7857                0x2849ba571d1971ba => {
7858                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7859                    let mut req = fidl::new_empty!(AudioRendererSetPtsContinuityThresholdRequest, fdomain_client::fidl::FDomainResourceDialect);
7860                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
7861                    let control_handle = AudioRendererControlHandle {
7862                        inner: this.inner.clone(),
7863                    };
7864                    Ok(AudioRendererRequest::SetPtsContinuityThreshold {threshold_seconds: req.threshold_seconds,
7865
7866                        control_handle,
7867                    })
7868                }
7869                0x2f7a7f011a172f7e => {
7870                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7871                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7872                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7873                    let control_handle = AudioRendererControlHandle {
7874                        inner: this.inner.clone(),
7875                    };
7876                    Ok(AudioRendererRequest::GetReferenceClock {
7877                        responder: AudioRendererGetReferenceClockResponder {
7878                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7879                            tx_id: header.tx_id,
7880                        },
7881                    })
7882                }
7883                0x39acd05d832b5fed => {
7884                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7885                    let mut req = fidl::new_empty!(AudioRendererSetReferenceClockRequest, fdomain_client::fidl::FDomainResourceDialect);
7886                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
7887                    let control_handle = AudioRendererControlHandle {
7888                        inner: this.inner.clone(),
7889                    };
7890                    Ok(AudioRendererRequest::SetReferenceClock {reference_clock: req.reference_clock,
7891
7892                        control_handle,
7893                    })
7894                }
7895                0x3994bd23b55a733e => {
7896                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7897                    let mut req = fidl::new_empty!(AudioRendererSetUsageRequest, fdomain_client::fidl::FDomainResourceDialect);
7898                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
7899                    let control_handle = AudioRendererControlHandle {
7900                        inner: this.inner.clone(),
7901                    };
7902                    Ok(AudioRendererRequest::SetUsage {usage: req.usage,
7903
7904                        control_handle,
7905                    })
7906                }
7907                0x2904035c7132b103 => {
7908                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7909                    let mut req = fidl::new_empty!(AudioRendererSetUsage2Request, fdomain_client::fidl::FDomainResourceDialect);
7910                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
7911                    let control_handle = AudioRendererControlHandle {
7912                        inner: this.inner.clone(),
7913                    };
7914                    Ok(AudioRendererRequest::SetUsage2 {usage2: req.usage2,
7915
7916                        control_handle,
7917                    })
7918                }
7919                0x27aa715d8901fa19 => {
7920                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7921                    let mut req = fidl::new_empty!(AudioRendererSetPcmStreamTypeRequest, fdomain_client::fidl::FDomainResourceDialect);
7922                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
7923                    let control_handle = AudioRendererControlHandle {
7924                        inner: this.inner.clone(),
7925                    };
7926                    Ok(AudioRendererRequest::SetPcmStreamType {type_: req.type_,
7927
7928                        control_handle,
7929                    })
7930                }
7931                0x62808dfad72bf890 => {
7932                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7933                    let mut req = fidl::new_empty!(AudioRendererEnableMinLeadTimeEventsRequest, fdomain_client::fidl::FDomainResourceDialect);
7934                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
7935                    let control_handle = AudioRendererControlHandle {
7936                        inner: this.inner.clone(),
7937                    };
7938                    Ok(AudioRendererRequest::EnableMinLeadTimeEvents {enabled: req.enabled,
7939
7940                        control_handle,
7941                    })
7942                }
7943                0x1cf3c3ecd8fec26b => {
7944                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7945                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7946                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7947                    let control_handle = AudioRendererControlHandle {
7948                        inner: this.inner.clone(),
7949                    };
7950                    Ok(AudioRendererRequest::GetMinLeadTime {
7951                        responder: AudioRendererGetMinLeadTimeResponder {
7952                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7953                            tx_id: header.tx_id,
7954                        },
7955                    })
7956                }
7957                0x3c0162db084f74a3 => {
7958                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7959                    let mut req = fidl::new_empty!(AudioRendererPlayRequest, fdomain_client::fidl::FDomainResourceDialect);
7960                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
7961                    let control_handle = AudioRendererControlHandle {
7962                        inner: this.inner.clone(),
7963                    };
7964                    Ok(AudioRendererRequest::Play {reference_time: req.reference_time,
7965media_time: req.media_time,
7966
7967                        responder: AudioRendererPlayResponder {
7968                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7969                            tx_id: header.tx_id,
7970                        },
7971                    })
7972                }
7973                0x1b7fe832b68c22ef => {
7974                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7975                    let mut req = fidl::new_empty!(AudioRendererPlayNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
7976                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
7977                    let control_handle = AudioRendererControlHandle {
7978                        inner: this.inner.clone(),
7979                    };
7980                    Ok(AudioRendererRequest::PlayNoReply {reference_time: req.reference_time,
7981media_time: req.media_time,
7982
7983                        control_handle,
7984                    })
7985                }
7986                0x41d557588d93d153 => {
7987                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7988                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
7989                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7990                    let control_handle = AudioRendererControlHandle {
7991                        inner: this.inner.clone(),
7992                    };
7993                    Ok(AudioRendererRequest::Pause {
7994                        responder: AudioRendererPauseResponder {
7995                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7996                            tx_id: header.tx_id,
7997                        },
7998                    })
7999                }
8000                0x24cc45d4f3855ab => {
8001                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
8002                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
8003                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
8004                    let control_handle = AudioRendererControlHandle {
8005                        inner: this.inner.clone(),
8006                    };
8007                    Ok(AudioRendererRequest::PauseNoReply {
8008                        control_handle,
8009                    })
8010                }
8011                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8012                    Ok(AudioRendererRequest::_UnknownMethod {
8013                        ordinal: header.ordinal,
8014                        control_handle: AudioRendererControlHandle { inner: this.inner.clone() },
8015                        method_type: fidl::MethodType::OneWay,
8016                    })
8017                }
8018                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
8019                    this.inner.send_framework_err(
8020                        fidl::encoding::FrameworkErr::UnknownMethod,
8021                        header.tx_id,
8022                        header.ordinal,
8023                        header.dynamic_flags(),
8024                        (bytes, handles),
8025                    )?;
8026                    Ok(AudioRendererRequest::_UnknownMethod {
8027                        ordinal: header.ordinal,
8028                        control_handle: AudioRendererControlHandle { inner: this.inner.clone() },
8029                        method_type: fidl::MethodType::TwoWay,
8030                    })
8031                }
8032                _ => Err(fidl::Error::UnknownOrdinal {
8033                    ordinal: header.ordinal,
8034                    protocol_name: <AudioRendererMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
8035                }),
8036            }))
8037            },
8038        )
8039    }
8040}
8041
8042/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
8043/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
8044/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
8045/// methods are disallowed and will cause the audio service to disconnect the client's connection.
8046/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
8047/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
8048///
8049/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
8050/// enqueued when these "configuring" methods are called. Thus it is best practice to call
8051/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
8052/// to reconfiguring the renderer.
8053#[derive(Debug)]
8054pub enum AudioRendererRequest {
8055    /// Adds a payload buffer to the current buffer set associated with the
8056    /// connection. A `StreamPacket` struct reference a payload buffer in the
8057    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8058    ///
8059    /// A buffer with ID `id` must not be in the current set when this method is
8060    /// invoked, otherwise the service will close the connection.
8061    AddPayloadBuffer {
8062        id: u32,
8063        payload_buffer: fdomain_client::Vmo,
8064        control_handle: AudioRendererControlHandle,
8065    },
8066    /// Removes a payload buffer from the current buffer set associated with the
8067    /// connection.
8068    ///
8069    /// A buffer with ID `id` must exist in the current set when this method is
8070    /// invoked, otherwise the service will will close the connection.
8071    RemovePayloadBuffer {
8072        id: u32,
8073        control_handle: AudioRendererControlHandle,
8074    },
8075    /// Sends a packet to the service. The response is sent when the service is
8076    /// done with the associated payload memory.
8077    ///
8078    /// `packet` must be valid for the current buffer set, otherwise the service
8079    /// will close the connection.
8080    SendPacket {
8081        packet: StreamPacket,
8082        responder: AudioRendererSendPacketResponder,
8083    },
8084    /// Sends a packet to the service. This interface doesn't define how the
8085    /// client knows when the sink is done with the associated payload memory.
8086    /// The inheriting interface must define that.
8087    ///
8088    /// `packet` must be valid for the current buffer set, otherwise the service
8089    /// will close the connection.
8090    SendPacketNoReply {
8091        packet: StreamPacket,
8092        control_handle: AudioRendererControlHandle,
8093    },
8094    /// Indicates the stream has ended. The precise semantics of this method are
8095    /// determined by the inheriting interface.
8096    EndOfStream {
8097        control_handle: AudioRendererControlHandle,
8098    },
8099    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8100    /// and not yet released. The response is sent after all packets have been
8101    /// released.
8102    DiscardAllPackets {
8103        responder: AudioRendererDiscardAllPacketsResponder,
8104    },
8105    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8106    /// and not yet released.
8107    DiscardAllPacketsNoReply {
8108        control_handle: AudioRendererControlHandle,
8109    },
8110    /// Binds to the gain control for this AudioRenderer.
8111    BindGainControl {
8112        gain_control_request:
8113            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
8114        control_handle: AudioRendererControlHandle,
8115    },
8116    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8117    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8118    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8119    SetPtsUnits {
8120        tick_per_second_numerator: u32,
8121        tick_per_second_denominator: u32,
8122        control_handle: AudioRendererControlHandle,
8123    },
8124    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8125    /// and expected PTS (determined using interpolation). Beyond this threshold,
8126    /// a stream is no longer considered 'continuous' by the renderer.
8127    ///
8128    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8129    /// Most users should not need to change this value from its default.
8130    ///
8131    /// Example:
8132    /// A user is playing back 48KHz audio from a container, which also contains
8133    /// video and needs to be synchronized with the audio. The timestamps are
8134    /// provided explicitly per packet by the container, and expressed in mSec
8135    /// units. This means that a single tick of the media timeline (1 mSec)
8136    /// represents exactly 48 frames of audio. The application in this scenario
8137    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8138    /// frames of audio, and each with an explicit timestamp set to the best
8139    /// possible representation of the presentation time (given this media
8140    /// clock's resolution). So, starting from zero, the timestamps would be..
8141    ///
8142    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8143    ///
8144    /// In this example, attempting to use the presentation time to compute the
8145    /// starting frame number of the audio in the packet would be wrong the
8146    /// majority of the time. The first timestamp is correct (by definition), but
8147    /// it will be 24 packets before the timestamps and frame numbers come back
8148    /// into alignment (the 24th packet would start with the 11280th audio frame
8149    /// and have a PTS of exactly 235).
8150    ///
8151    /// One way to fix this situation is to set the PTS continuity threshold
8152    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8153    /// the number of frames contained within a single tick of the media clock,
8154    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8155    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8156    /// explicitly provided PTS would be considered to be a continuation of the
8157    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8158    /// would work well.
8159    ///
8160    /// Other possible uses:
8161    /// Users who are scheduling audio explicitly, relative to a clock which has
8162    /// not been configured as the reference clock, can use this value to control
8163    /// the maximum acceptable synchronization error before a discontinuity is
8164    /// introduced. E.g., if a user is scheduling audio based on a recovered
8165    /// common media clock, and has not published that clock as the reference
8166    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8167    /// can accumulate before the AudioRenderer deliberately inserts a
8168    /// presentation discontinuity to account for the error.
8169    ///
8170    /// Users whose need to deal with a container where their timestamps may be
8171    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8172    /// something larger. This should be the maximum level of inaccuracy present
8173    /// in the container timestamps, if known. Failing that, it could be set to
8174    /// the maximum tolerable level of drift error before absolute timestamps are
8175    /// explicitly obeyed. Finally, a user could set this number to a very large
8176    /// value (86400.0 seconds, for example) to effectively cause *all*
8177    /// timestamps to be ignored after the first, thus treating all audio as
8178    /// continuous with previously delivered packets. Conversely, users who wish
8179    /// to *always* explicitly schedule their audio packets exactly may specify
8180    /// a CT of 0.
8181    ///
8182    /// Note: explicitly specifying high-frequency PTS units reduces the default
8183    /// continuity threshold accordingly. Internally, this threshold is stored as an
8184    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8185    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8186    /// For this reason, specifying PTS units with a frequency greater than 8192x
8187    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8188    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8189    SetPtsContinuityThreshold {
8190        threshold_seconds: f32,
8191        control_handle: AudioRendererControlHandle,
8192    },
8193    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8194    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8195    GetReferenceClock {
8196        responder: AudioRendererGetReferenceClockResponder,
8197    },
8198    /// Sets the reference clock that controls this renderer's playback rate. If the input
8199    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8200    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8201    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8202    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8203    ///
8204    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8205    /// cannot be called a second time (even if the renderer format has not yet been set).
8206    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8207    /// diverge at some later time, they should create a clone of the monotonic clock, set
8208    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8209    SetReferenceClock {
8210        reference_clock: Option<fdomain_client::Clock>,
8211        control_handle: AudioRendererControlHandle,
8212    },
8213    /// Sets the usage of the render stream. This method may not be called after
8214    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8215    SetUsage {
8216        usage: AudioRenderUsage,
8217        control_handle: AudioRendererControlHandle,
8218    },
8219    /// Sets the usage of the render stream. This method may not be called after
8220    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8221    SetUsage2 {
8222        usage2: AudioRenderUsage2,
8223        control_handle: AudioRendererControlHandle,
8224    },
8225    /// Sets the type of the stream to be delivered by the client. Using this method implies
8226    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8227    ///
8228    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8229    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8230    /// methods such as `SendPacket`/`SendPacketNoReply`.
8231    SetPcmStreamType {
8232        type_: AudioStreamType,
8233        control_handle: AudioRendererControlHandle,
8234    },
8235    /// Enables or disables notifications about changes to the minimum clock lead
8236    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8237    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8238    /// event with the current minimum lead time for the AudioRenderer. If the
8239    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8240    /// new value. This behavior will continue until the user calls
8241    /// `EnableMinLeadTimeEvents(false)`.
8242    ///
8243    /// The minimum clock lead time is the amount of time ahead of the reference
8244    /// clock's understanding of "now" that packets needs to arrive (relative to
8245    /// the playback clock transformation) in order for the mixer to be able to
8246    /// mix packet. For example...
8247    ///
8248    /// + Let the PTS of packet X be P(X)
8249    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8250    ///   function is determined by the call to Play(...)
8251    /// + Let the minimum lead time be MLT
8252    ///
8253    /// If R(P(X)) < RefClock.Now() + MLT
8254    /// Then the packet is late, and some (or all) of the packet's payload will
8255    /// need to be skipped in order to present the packet at the scheduled time.
8256    ///
8257    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8258    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8259    /// is called before the AudioRenderer is routed, any played packets will be
8260    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8261    /// calling `Play`.
8262    EnableMinLeadTimeEvents {
8263        enabled: bool,
8264        control_handle: AudioRendererControlHandle,
8265    },
8266    ///
8267    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8268    /// there's little reason to do so. This is because lead time is a function
8269    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8270    /// If min lead time events are enabled before `SetPcmStreamType` (with
8271    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8272    /// response to `SetPcmStreamType`.
8273    GetMinLeadTime {
8274        responder: AudioRendererGetMinLeadTimeResponder,
8275    },
8276    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8277    /// of the media timeline, using specific values provided by the caller (or
8278    /// default values if not specified). In an optional callback, returns the
8279    /// timestamp values ultimately used -- these set the ongoing relationship
8280    /// between the media and reference timelines (i.e., how to translate between
8281    /// the domain of presentation timestamps, and the realm of local system
8282    /// time).
8283    ///
8284    /// Local system time is specified in units of nanoseconds; media_time is
8285    /// specified in the units defined by the user in the `SetPtsUnits` function,
8286    /// or nanoseconds if `SetPtsUnits` is not called.
8287    ///
8288    /// The act of placing an AudioRenderer into the playback state establishes a
8289    /// relationship between 1) the user-defined media (or presentation) timeline
8290    /// for this particular AudioRenderer, and 2) the real-world system reference
8291    /// timeline. To communicate how to translate between timelines, the Play()
8292    /// callback provides an equivalent timestamp in each time domain. The first
8293    /// value ('reference_time') is given in terms of this renderer's reference
8294    /// clock; the second value ('media_time') is what media instant exactly
8295    /// corresponds to that local time. Restated, the frame at 'media_time' in
8296    /// the audio stream should be presented at 'reference_time' according to
8297    /// the reference clock.
8298    ///
8299    /// Note: on calling this API, media_time immediately starts advancing. It is
8300    /// possible (if uncommon) for a caller to specify a system time that is
8301    /// far in the past, or far into the future. This, along with the specified
8302    /// media time, is simply used to determine what media time corresponds to
8303    /// 'now', and THAT media time is then intersected with presentation
8304    /// timestamps of packets already submitted, to determine which media frames
8305    /// should be presented next.
8306    ///
8307    /// With the corresponding reference_time and media_time values, a user can
8308    /// translate arbitrary time values from one timeline into the other. After
8309    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8310    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8311    /// any 'ref_time':
8312    ///
8313    /// media_time = ( (ref_time - ref_start) / 1e9
8314    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8315    ///              + media_start
8316    ///
8317    /// Conversely, for any presentation timestamp 'media_time':
8318    ///
8319    /// ref_time = ( (media_time - media_start)
8320    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8321    ///              * 1e9 )
8322    ///            + ref_start
8323    ///
8324    /// Users, depending on their use case, may optionally choose not to specify
8325    /// one or both of these timestamps. A timestamp may be omitted by supplying
8326    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8327    /// any omitted timestamp value using the following rules:
8328    ///
8329    /// Reference Time
8330    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8331    /// reference time to begin presentation, based on the minimum lead times for
8332    /// the output devices that are currently bound to this AudioRenderer. For
8333    /// example, if an AudioRenderer is bound to an internal audio output
8334    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8335    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8336    /// is omitted) select a reference time 80 mSec from now.
8337    ///
8338    /// Media Time
8339    /// If media_time is omitted, the AudioRenderer will select one of two
8340    /// values.
8341    /// - If the AudioRenderer is resuming from the paused state, and packets
8342    /// have not been discarded since being paused, then the AudioRenderer will
8343    /// use a media_time corresponding to the instant at which the presentation
8344    /// became paused.
8345    /// - If the AudioRenderer is being placed into a playing state for the first
8346    /// time following startup or a 'discard packets' operation, the initial
8347    /// media_time will be set to the PTS of the first payload in the pending
8348    /// packet queue. If the pending queue is empty, initial media_time will be
8349    /// set to zero.
8350    ///
8351    /// Return Value
8352    /// When requested, the AudioRenderer will return the 'reference_time' and
8353    /// 'media_time' which were selected and used (whether they were explicitly
8354    /// specified or not) in the return value of the play call.
8355    ///
8356    /// Examples
8357    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8358    /// to start playing as soon as possible. The user may call Play without
8359    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8360    ///
8361    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8362    /// playback at a specified 'reference_time', in sync with some other media
8363    /// stream, either initially or after discarding packets. The user would call
8364    /// `Play(reference_time, NO_TIMESTAMP)`.
8365    ///
8366    /// 3. A user has queued some audio using `SendPacket`. The first of these
8367    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8368    /// as possible, but wishes to skip all of the audio content between PTS 0
8369    /// and PTS 'media_time'. The user would call
8370    /// `Play(NO_TIMESTAMP, media_time)`.
8371    ///
8372    /// 4. A user has queued some audio using `SendPacket` and want to present
8373    /// this media in synch with another player in a different device. The
8374    /// coordinator of the group of distributed players sends an explicit
8375    /// message to each player telling them to begin presentation of audio at
8376    /// PTS 'media_time', at the time (based on the group's shared reference
8377    /// clock) 'reference_time'. Here the user would call
8378    /// `Play(reference_time, media_time)`.
8379    Play {
8380        reference_time: i64,
8381        media_time: i64,
8382        responder: AudioRendererPlayResponder,
8383    },
8384    PlayNoReply {
8385        reference_time: i64,
8386        media_time: i64,
8387        control_handle: AudioRendererControlHandle,
8388    },
8389    /// Immediately puts the AudioRenderer into the paused state and then report
8390    /// the relationship between the media and reference timelines which was
8391    /// established (if requested).
8392    ///
8393    /// If the AudioRenderer is already in the paused state when this called,
8394    /// the previously-established timeline values are returned (if requested).
8395    Pause {
8396        responder: AudioRendererPauseResponder,
8397    },
8398    PauseNoReply {
8399        control_handle: AudioRendererControlHandle,
8400    },
8401    /// An interaction was received which does not match any known method.
8402    #[non_exhaustive]
8403    _UnknownMethod {
8404        /// Ordinal of the method that was called.
8405        ordinal: u64,
8406        control_handle: AudioRendererControlHandle,
8407        method_type: fidl::MethodType,
8408    },
8409}
8410
8411impl AudioRendererRequest {
8412    #[allow(irrefutable_let_patterns)]
8413    pub fn into_add_payload_buffer(
8414        self,
8415    ) -> Option<(u32, fdomain_client::Vmo, AudioRendererControlHandle)> {
8416        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
8417        {
8418            Some((id, payload_buffer, control_handle))
8419        } else {
8420            None
8421        }
8422    }
8423
8424    #[allow(irrefutable_let_patterns)]
8425    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
8426        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
8427            Some((id, control_handle))
8428        } else {
8429            None
8430        }
8431    }
8432
8433    #[allow(irrefutable_let_patterns)]
8434    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
8435        if let AudioRendererRequest::SendPacket { packet, responder } = self {
8436            Some((packet, responder))
8437        } else {
8438            None
8439        }
8440    }
8441
8442    #[allow(irrefutable_let_patterns)]
8443    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
8444        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
8445            Some((packet, control_handle))
8446        } else {
8447            None
8448        }
8449    }
8450
8451    #[allow(irrefutable_let_patterns)]
8452    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
8453        if let AudioRendererRequest::EndOfStream { control_handle } = self {
8454            Some((control_handle))
8455        } else {
8456            None
8457        }
8458    }
8459
8460    #[allow(irrefutable_let_patterns)]
8461    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
8462        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
8463            Some((responder))
8464        } else {
8465            None
8466        }
8467    }
8468
8469    #[allow(irrefutable_let_patterns)]
8470    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
8471        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
8472            Some((control_handle))
8473        } else {
8474            None
8475        }
8476    }
8477
8478    #[allow(irrefutable_let_patterns)]
8479    pub fn into_bind_gain_control(
8480        self,
8481    ) -> Option<(
8482        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
8483        AudioRendererControlHandle,
8484    )> {
8485        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
8486        {
8487            Some((gain_control_request, control_handle))
8488        } else {
8489            None
8490        }
8491    }
8492
8493    #[allow(irrefutable_let_patterns)]
8494    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
8495        if let AudioRendererRequest::SetPtsUnits {
8496            tick_per_second_numerator,
8497            tick_per_second_denominator,
8498            control_handle,
8499        } = self
8500        {
8501            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
8502        } else {
8503            None
8504        }
8505    }
8506
8507    #[allow(irrefutable_let_patterns)]
8508    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
8509        if let AudioRendererRequest::SetPtsContinuityThreshold {
8510            threshold_seconds,
8511            control_handle,
8512        } = self
8513        {
8514            Some((threshold_seconds, control_handle))
8515        } else {
8516            None
8517        }
8518    }
8519
8520    #[allow(irrefutable_let_patterns)]
8521    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
8522        if let AudioRendererRequest::GetReferenceClock { responder } = self {
8523            Some((responder))
8524        } else {
8525            None
8526        }
8527    }
8528
8529    #[allow(irrefutable_let_patterns)]
8530    pub fn into_set_reference_clock(
8531        self,
8532    ) -> Option<(Option<fdomain_client::Clock>, AudioRendererControlHandle)> {
8533        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
8534            Some((reference_clock, control_handle))
8535        } else {
8536            None
8537        }
8538    }
8539
8540    #[allow(irrefutable_let_patterns)]
8541    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
8542        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
8543            Some((usage, control_handle))
8544        } else {
8545            None
8546        }
8547    }
8548
8549    #[allow(irrefutable_let_patterns)]
8550    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
8551        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
8552            Some((usage2, control_handle))
8553        } else {
8554            None
8555        }
8556    }
8557
8558    #[allow(irrefutable_let_patterns)]
8559    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
8560        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
8561            Some((type_, control_handle))
8562        } else {
8563            None
8564        }
8565    }
8566
8567    #[allow(irrefutable_let_patterns)]
8568    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
8569        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
8570            Some((enabled, control_handle))
8571        } else {
8572            None
8573        }
8574    }
8575
8576    #[allow(irrefutable_let_patterns)]
8577    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
8578        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
8579            Some((responder))
8580        } else {
8581            None
8582        }
8583    }
8584
8585    #[allow(irrefutable_let_patterns)]
8586    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
8587        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
8588            Some((reference_time, media_time, responder))
8589        } else {
8590            None
8591        }
8592    }
8593
8594    #[allow(irrefutable_let_patterns)]
8595    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
8596        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
8597            self
8598        {
8599            Some((reference_time, media_time, control_handle))
8600        } else {
8601            None
8602        }
8603    }
8604
8605    #[allow(irrefutable_let_patterns)]
8606    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
8607        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
8608    }
8609
8610    #[allow(irrefutable_let_patterns)]
8611    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
8612        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
8613            Some((control_handle))
8614        } else {
8615            None
8616        }
8617    }
8618
8619    /// Name of the method defined in FIDL
8620    pub fn method_name(&self) -> &'static str {
8621        match *self {
8622            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
8623            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
8624            AudioRendererRequest::SendPacket { .. } => "send_packet",
8625            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
8626            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
8627            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
8628            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
8629            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
8630            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
8631            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
8632                "set_pts_continuity_threshold"
8633            }
8634            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
8635            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
8636            AudioRendererRequest::SetUsage { .. } => "set_usage",
8637            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
8638            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
8639            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
8640            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
8641            AudioRendererRequest::Play { .. } => "play",
8642            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
8643            AudioRendererRequest::Pause { .. } => "pause",
8644            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
8645            AudioRendererRequest::_UnknownMethod {
8646                method_type: fidl::MethodType::OneWay, ..
8647            } => "unknown one-way method",
8648            AudioRendererRequest::_UnknownMethod {
8649                method_type: fidl::MethodType::TwoWay, ..
8650            } => "unknown two-way method",
8651        }
8652    }
8653}
8654
8655#[derive(Debug, Clone)]
8656pub struct AudioRendererControlHandle {
8657    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
8658}
8659
8660impl AudioRendererControlHandle {
8661    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
8662        self.inner.shutdown_with_epitaph(status.into())
8663    }
8664}
8665
8666impl fdomain_client::fidl::ControlHandle for AudioRendererControlHandle {
8667    fn shutdown(&self) {
8668        self.inner.shutdown()
8669    }
8670
8671    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
8672        self.inner.shutdown_with_epitaph(status)
8673    }
8674
8675    fn is_closed(&self) -> bool {
8676        self.inner.channel().is_closed()
8677    }
8678    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
8679        self.inner.channel().on_closed()
8680    }
8681}
8682
8683impl AudioRendererControlHandle {
8684    pub fn send_on_min_lead_time_changed(
8685        &self,
8686        mut min_lead_time_nsec: i64,
8687    ) -> Result<(), fidl::Error> {
8688        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
8689            (min_lead_time_nsec,),
8690            0,
8691            0x4feff7d278978c4e,
8692            fidl::encoding::DynamicFlags::empty(),
8693        )
8694    }
8695}
8696
8697#[must_use = "FIDL methods require a response to be sent"]
8698#[derive(Debug)]
8699pub struct AudioRendererSendPacketResponder {
8700    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8701    tx_id: u32,
8702}
8703
8704/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8705/// if the responder is dropped without sending a response, so that the client
8706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8707impl std::ops::Drop for AudioRendererSendPacketResponder {
8708    fn drop(&mut self) {
8709        self.control_handle.shutdown();
8710        // Safety: drops once, never accessed again
8711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8712    }
8713}
8714
8715impl fdomain_client::fidl::Responder for AudioRendererSendPacketResponder {
8716    type ControlHandle = AudioRendererControlHandle;
8717
8718    fn control_handle(&self) -> &AudioRendererControlHandle {
8719        &self.control_handle
8720    }
8721
8722    fn drop_without_shutdown(mut self) {
8723        // Safety: drops once, never accessed again due to mem::forget
8724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8725        // Prevent Drop from running (which would shut down the channel)
8726        std::mem::forget(self);
8727    }
8728}
8729
8730impl AudioRendererSendPacketResponder {
8731    /// Sends a response to the FIDL transaction.
8732    ///
8733    /// Sets the channel to shutdown if an error occurs.
8734    pub fn send(self) -> Result<(), fidl::Error> {
8735        let _result = self.send_raw();
8736        if _result.is_err() {
8737            self.control_handle.shutdown();
8738        }
8739        self.drop_without_shutdown();
8740        _result
8741    }
8742
8743    /// Similar to "send" but does not shutdown the channel if an error occurs.
8744    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8745        let _result = self.send_raw();
8746        self.drop_without_shutdown();
8747        _result
8748    }
8749
8750    fn send_raw(&self) -> Result<(), fidl::Error> {
8751        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8752            (),
8753            self.tx_id,
8754            0x67cddd607442775f,
8755            fidl::encoding::DynamicFlags::empty(),
8756        )
8757    }
8758}
8759
8760#[must_use = "FIDL methods require a response to be sent"]
8761#[derive(Debug)]
8762pub struct AudioRendererDiscardAllPacketsResponder {
8763    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8764    tx_id: u32,
8765}
8766
8767/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8768/// if the responder is dropped without sending a response, so that the client
8769/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8770impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
8771    fn drop(&mut self) {
8772        self.control_handle.shutdown();
8773        // Safety: drops once, never accessed again
8774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8775    }
8776}
8777
8778impl fdomain_client::fidl::Responder for AudioRendererDiscardAllPacketsResponder {
8779    type ControlHandle = AudioRendererControlHandle;
8780
8781    fn control_handle(&self) -> &AudioRendererControlHandle {
8782        &self.control_handle
8783    }
8784
8785    fn drop_without_shutdown(mut self) {
8786        // Safety: drops once, never accessed again due to mem::forget
8787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8788        // Prevent Drop from running (which would shut down the channel)
8789        std::mem::forget(self);
8790    }
8791}
8792
8793impl AudioRendererDiscardAllPacketsResponder {
8794    /// Sends a response to the FIDL transaction.
8795    ///
8796    /// Sets the channel to shutdown if an error occurs.
8797    pub fn send(self) -> Result<(), fidl::Error> {
8798        let _result = self.send_raw();
8799        if _result.is_err() {
8800            self.control_handle.shutdown();
8801        }
8802        self.drop_without_shutdown();
8803        _result
8804    }
8805
8806    /// Similar to "send" but does not shutdown the channel if an error occurs.
8807    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
8808        let _result = self.send_raw();
8809        self.drop_without_shutdown();
8810        _result
8811    }
8812
8813    fn send_raw(&self) -> Result<(), fidl::Error> {
8814        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
8815            (),
8816            self.tx_id,
8817            0x6f4dad7af2917665,
8818            fidl::encoding::DynamicFlags::empty(),
8819        )
8820    }
8821}
8822
8823#[must_use = "FIDL methods require a response to be sent"]
8824#[derive(Debug)]
8825pub struct AudioRendererGetReferenceClockResponder {
8826    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8827    tx_id: u32,
8828}
8829
8830/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8831/// if the responder is dropped without sending a response, so that the client
8832/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8833impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
8834    fn drop(&mut self) {
8835        self.control_handle.shutdown();
8836        // Safety: drops once, never accessed again
8837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8838    }
8839}
8840
8841impl fdomain_client::fidl::Responder for AudioRendererGetReferenceClockResponder {
8842    type ControlHandle = AudioRendererControlHandle;
8843
8844    fn control_handle(&self) -> &AudioRendererControlHandle {
8845        &self.control_handle
8846    }
8847
8848    fn drop_without_shutdown(mut self) {
8849        // Safety: drops once, never accessed again due to mem::forget
8850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8851        // Prevent Drop from running (which would shut down the channel)
8852        std::mem::forget(self);
8853    }
8854}
8855
8856impl AudioRendererGetReferenceClockResponder {
8857    /// Sends a response to the FIDL transaction.
8858    ///
8859    /// Sets the channel to shutdown if an error occurs.
8860    pub fn send(self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
8861        let _result = self.send_raw(reference_clock);
8862        if _result.is_err() {
8863            self.control_handle.shutdown();
8864        }
8865        self.drop_without_shutdown();
8866        _result
8867    }
8868
8869    /// Similar to "send" but does not shutdown the channel if an error occurs.
8870    pub fn send_no_shutdown_on_err(
8871        self,
8872        mut reference_clock: fdomain_client::Clock,
8873    ) -> Result<(), fidl::Error> {
8874        let _result = self.send_raw(reference_clock);
8875        self.drop_without_shutdown();
8876        _result
8877    }
8878
8879    fn send_raw(&self, mut reference_clock: fdomain_client::Clock) -> Result<(), fidl::Error> {
8880        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
8881            (reference_clock,),
8882            self.tx_id,
8883            0x2f7a7f011a172f7e,
8884            fidl::encoding::DynamicFlags::empty(),
8885        )
8886    }
8887}
8888
8889#[must_use = "FIDL methods require a response to be sent"]
8890#[derive(Debug)]
8891pub struct AudioRendererGetMinLeadTimeResponder {
8892    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8893    tx_id: u32,
8894}
8895
8896/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8897/// if the responder is dropped without sending a response, so that the client
8898/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8899impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
8900    fn drop(&mut self) {
8901        self.control_handle.shutdown();
8902        // Safety: drops once, never accessed again
8903        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8904    }
8905}
8906
8907impl fdomain_client::fidl::Responder for AudioRendererGetMinLeadTimeResponder {
8908    type ControlHandle = AudioRendererControlHandle;
8909
8910    fn control_handle(&self) -> &AudioRendererControlHandle {
8911        &self.control_handle
8912    }
8913
8914    fn drop_without_shutdown(mut self) {
8915        // Safety: drops once, never accessed again due to mem::forget
8916        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8917        // Prevent Drop from running (which would shut down the channel)
8918        std::mem::forget(self);
8919    }
8920}
8921
8922impl AudioRendererGetMinLeadTimeResponder {
8923    /// Sends a response to the FIDL transaction.
8924    ///
8925    /// Sets the channel to shutdown if an error occurs.
8926    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8927        let _result = self.send_raw(min_lead_time_nsec);
8928        if _result.is_err() {
8929            self.control_handle.shutdown();
8930        }
8931        self.drop_without_shutdown();
8932        _result
8933    }
8934
8935    /// Similar to "send" but does not shutdown the channel if an error occurs.
8936    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8937        let _result = self.send_raw(min_lead_time_nsec);
8938        self.drop_without_shutdown();
8939        _result
8940    }
8941
8942    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
8943        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
8944            (min_lead_time_nsec,),
8945            self.tx_id,
8946            0x1cf3c3ecd8fec26b,
8947            fidl::encoding::DynamicFlags::empty(),
8948        )
8949    }
8950}
8951
8952#[must_use = "FIDL methods require a response to be sent"]
8953#[derive(Debug)]
8954pub struct AudioRendererPlayResponder {
8955    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
8956    tx_id: u32,
8957}
8958
8959/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
8960/// if the responder is dropped without sending a response, so that the client
8961/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8962impl std::ops::Drop for AudioRendererPlayResponder {
8963    fn drop(&mut self) {
8964        self.control_handle.shutdown();
8965        // Safety: drops once, never accessed again
8966        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8967    }
8968}
8969
8970impl fdomain_client::fidl::Responder for AudioRendererPlayResponder {
8971    type ControlHandle = AudioRendererControlHandle;
8972
8973    fn control_handle(&self) -> &AudioRendererControlHandle {
8974        &self.control_handle
8975    }
8976
8977    fn drop_without_shutdown(mut self) {
8978        // Safety: drops once, never accessed again due to mem::forget
8979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8980        // Prevent Drop from running (which would shut down the channel)
8981        std::mem::forget(self);
8982    }
8983}
8984
8985impl AudioRendererPlayResponder {
8986    /// Sends a response to the FIDL transaction.
8987    ///
8988    /// Sets the channel to shutdown if an error occurs.
8989    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
8990        let _result = self.send_raw(reference_time, media_time);
8991        if _result.is_err() {
8992            self.control_handle.shutdown();
8993        }
8994        self.drop_without_shutdown();
8995        _result
8996    }
8997
8998    /// Similar to "send" but does not shutdown the channel if an error occurs.
8999    pub fn send_no_shutdown_on_err(
9000        self,
9001        mut reference_time: i64,
9002        mut media_time: i64,
9003    ) -> Result<(), fidl::Error> {
9004        let _result = self.send_raw(reference_time, media_time);
9005        self.drop_without_shutdown();
9006        _result
9007    }
9008
9009    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
9010        self.control_handle.inner.send::<AudioRendererPlayResponse>(
9011            (reference_time, media_time),
9012            self.tx_id,
9013            0x3c0162db084f74a3,
9014            fidl::encoding::DynamicFlags::empty(),
9015        )
9016    }
9017}
9018
9019#[must_use = "FIDL methods require a response to be sent"]
9020#[derive(Debug)]
9021pub struct AudioRendererPauseResponder {
9022    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
9023    tx_id: u32,
9024}
9025
9026/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
9027/// if the responder is dropped without sending a response, so that the client
9028/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9029impl std::ops::Drop for AudioRendererPauseResponder {
9030    fn drop(&mut self) {
9031        self.control_handle.shutdown();
9032        // Safety: drops once, never accessed again
9033        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9034    }
9035}
9036
9037impl fdomain_client::fidl::Responder for AudioRendererPauseResponder {
9038    type ControlHandle = AudioRendererControlHandle;
9039
9040    fn control_handle(&self) -> &AudioRendererControlHandle {
9041        &self.control_handle
9042    }
9043
9044    fn drop_without_shutdown(mut self) {
9045        // Safety: drops once, never accessed again due to mem::forget
9046        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9047        // Prevent Drop from running (which would shut down the channel)
9048        std::mem::forget(self);
9049    }
9050}
9051
9052impl AudioRendererPauseResponder {
9053    /// Sends a response to the FIDL transaction.
9054    ///
9055    /// Sets the channel to shutdown if an error occurs.
9056    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
9057        let _result = self.send_raw(reference_time, media_time);
9058        if _result.is_err() {
9059            self.control_handle.shutdown();
9060        }
9061        self.drop_without_shutdown();
9062        _result
9063    }
9064
9065    /// Similar to "send" but does not shutdown the channel if an error occurs.
9066    pub fn send_no_shutdown_on_err(
9067        self,
9068        mut reference_time: i64,
9069        mut media_time: i64,
9070    ) -> Result<(), fidl::Error> {
9071        let _result = self.send_raw(reference_time, media_time);
9072        self.drop_without_shutdown();
9073        _result
9074    }
9075
9076    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
9077        self.control_handle.inner.send::<AudioRendererPauseResponse>(
9078            (reference_time, media_time),
9079            self.tx_id,
9080            0x41d557588d93d153,
9081            fidl::encoding::DynamicFlags::empty(),
9082        )
9083    }
9084}
9085
9086#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9087pub struct ProfileProviderMarker;
9088
9089impl fdomain_client::fidl::ProtocolMarker for ProfileProviderMarker {
9090    type Proxy = ProfileProviderProxy;
9091    type RequestStream = ProfileProviderRequestStream;
9092
9093    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
9094}
9095impl fdomain_client::fidl::DiscoverableProtocolMarker for ProfileProviderMarker {}
9096
9097pub trait ProfileProviderProxyInterface: Send + Sync {
9098    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
9099        + Send;
9100    fn r#register_handler_with_capacity(
9101        &self,
9102        thread_handle: fdomain_client::Thread,
9103        name: &str,
9104        period: i64,
9105        capacity: f32,
9106    ) -> Self::RegisterHandlerWithCapacityResponseFut;
9107    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
9108    fn r#unregister_handler(
9109        &self,
9110        thread_handle: fdomain_client::Thread,
9111        name: &str,
9112    ) -> Self::UnregisterHandlerResponseFut;
9113    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
9114        + Send;
9115    fn r#register_memory_range(
9116        &self,
9117        vmar_handle: fdomain_client::Vmar,
9118        name: &str,
9119    ) -> Self::RegisterMemoryRangeResponseFut;
9120    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
9121        + Send;
9122    fn r#unregister_memory_range(
9123        &self,
9124        vmar_handle: fdomain_client::Vmar,
9125    ) -> Self::UnregisterMemoryRangeResponseFut;
9126}
9127
9128#[derive(Debug, Clone)]
9129pub struct ProfileProviderProxy {
9130    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9131}
9132
9133impl fdomain_client::fidl::Proxy for ProfileProviderProxy {
9134    type Protocol = ProfileProviderMarker;
9135
9136    fn from_channel(inner: fdomain_client::Channel) -> Self {
9137        Self::new(inner)
9138    }
9139
9140    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
9141        self.client.into_channel().map_err(|client| Self { client })
9142    }
9143
9144    fn as_channel(&self) -> &fdomain_client::Channel {
9145        self.client.as_channel()
9146    }
9147}
9148
9149impl ProfileProviderProxy {
9150    /// Create a new Proxy for fuchsia.media/ProfileProvider.
9151    pub fn new(channel: fdomain_client::Channel) -> Self {
9152        let protocol_name =
9153            <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
9154        Self { client: fidl::client::Client::new(channel, protocol_name) }
9155    }
9156
9157    /// Get a Stream of events from the remote end of the protocol.
9158    ///
9159    /// # Panics
9160    ///
9161    /// Panics if the event stream was already taken.
9162    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
9163        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
9164    }
9165
9166    /// Register a thread as a media thread. This notifies the media subsystem that this thread
9167    /// should have an elevated scheduling profile applied to it in order to meet audio or video
9168    /// deadlines.
9169    ///
9170    /// `name` is the name of a system scheduling role to apply to the thread given by
9171    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
9172    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
9173    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
9174    /// the scheduling interval the thread needs to be running to achieve good performance or to
9175    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
9176    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
9177    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
9178    /// be rejected or result in scaling back the performance of other threads to fit resource
9179    /// limits.
9180    ///
9181    /// Capacity, max runtime, and period have the following relationship:
9182    ///
9183    ///   capacity = max runtime / period
9184    ///
9185    /// Where:
9186    ///
9187    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
9188    ///
9189    /// For heterogeneous systems, the capacity should be planned / measured against the highest
9190    /// performance processor(s) in the system. The system will automatically adjust the effective
9191    /// capacity to account for slower processors and operating points and will avoid processors and
9192    /// operating points that are too slow to meet the requested scheduling parameters (provided
9193    /// they are reasonable).
9194    ///
9195    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
9196    /// may be zero to indicate not applicable.
9197    pub fn r#register_handler_with_capacity(
9198        &self,
9199        mut thread_handle: fdomain_client::Thread,
9200        mut name: &str,
9201        mut period: i64,
9202        mut capacity: f32,
9203    ) -> fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>
9204    {
9205        ProfileProviderProxyInterface::r#register_handler_with_capacity(
9206            self,
9207            thread_handle,
9208            name,
9209            period,
9210            capacity,
9211        )
9212    }
9213
9214    /// Reset a thread's scheduling profile to the default.
9215    pub fn r#unregister_handler(
9216        &self,
9217        mut thread_handle: fdomain_client::Thread,
9218        mut name: &str,
9219    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9220        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
9221    }
9222
9223    /// Register a memory range as being used for media processing. This notifies the media
9224    /// subsystem that this memory should have an elevated memory profile applied to it in order to
9225    /// meet audio or video deadlines.
9226    ///
9227    /// `name` is the name of a system memory role to apply to the memory given by
9228    /// `vmar_handle` -- different products may customize the underlying memory strategy based
9229    /// on the requested role.
9230    pub fn r#register_memory_range(
9231        &self,
9232        mut vmar_handle: fdomain_client::Vmar,
9233        mut name: &str,
9234    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9235        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
9236    }
9237
9238    /// Reset a memory range's memory profile.
9239    pub fn r#unregister_memory_range(
9240        &self,
9241        mut vmar_handle: fdomain_client::Vmar,
9242    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
9243        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
9244    }
9245}
9246
9247impl ProfileProviderProxyInterface for ProfileProviderProxy {
9248    type RegisterHandlerWithCapacityResponseFut =
9249        fidl::client::QueryResponseFut<(i64, i64), fdomain_client::fidl::FDomainResourceDialect>;
9250    fn r#register_handler_with_capacity(
9251        &self,
9252        mut thread_handle: fdomain_client::Thread,
9253        mut name: &str,
9254        mut period: i64,
9255        mut capacity: f32,
9256    ) -> Self::RegisterHandlerWithCapacityResponseFut {
9257        fn _decode(
9258            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9259        ) -> Result<(i64, i64), fidl::Error> {
9260            let _response = fidl::client::decode_transaction_body::<
9261                ProfileProviderRegisterHandlerWithCapacityResponse,
9262                fdomain_client::fidl::FDomainResourceDialect,
9263                0x60459ecef7458176,
9264            >(_buf?)?;
9265            Ok((_response.period, _response.capacity))
9266        }
9267        self.client
9268            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
9269                (thread_handle, name, period, capacity),
9270                0x60459ecef7458176,
9271                fidl::encoding::DynamicFlags::empty(),
9272                _decode,
9273            )
9274    }
9275
9276    type UnregisterHandlerResponseFut =
9277        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9278    fn r#unregister_handler(
9279        &self,
9280        mut thread_handle: fdomain_client::Thread,
9281        mut name: &str,
9282    ) -> Self::UnregisterHandlerResponseFut {
9283        fn _decode(
9284            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9285        ) -> Result<(), fidl::Error> {
9286            let _response = fidl::client::decode_transaction_body::<
9287                fidl::encoding::EmptyPayload,
9288                fdomain_client::fidl::FDomainResourceDialect,
9289                0x724d9d5fd8ef544c,
9290            >(_buf?)?;
9291            Ok(_response)
9292        }
9293        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
9294            (thread_handle, name),
9295            0x724d9d5fd8ef544c,
9296            fidl::encoding::DynamicFlags::empty(),
9297            _decode,
9298        )
9299    }
9300
9301    type RegisterMemoryRangeResponseFut =
9302        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9303    fn r#register_memory_range(
9304        &self,
9305        mut vmar_handle: fdomain_client::Vmar,
9306        mut name: &str,
9307    ) -> Self::RegisterMemoryRangeResponseFut {
9308        fn _decode(
9309            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9310        ) -> Result<(), fidl::Error> {
9311            let _response = fidl::client::decode_transaction_body::<
9312                fidl::encoding::EmptyPayload,
9313                fdomain_client::fidl::FDomainResourceDialect,
9314                0x2f509d3523e9562d,
9315            >(_buf?)?;
9316            Ok(_response)
9317        }
9318        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
9319            (vmar_handle, name),
9320            0x2f509d3523e9562d,
9321            fidl::encoding::DynamicFlags::empty(),
9322            _decode,
9323        )
9324    }
9325
9326    type UnregisterMemoryRangeResponseFut =
9327        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
9328    fn r#unregister_memory_range(
9329        &self,
9330        mut vmar_handle: fdomain_client::Vmar,
9331    ) -> Self::UnregisterMemoryRangeResponseFut {
9332        fn _decode(
9333            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9334        ) -> Result<(), fidl::Error> {
9335            let _response = fidl::client::decode_transaction_body::<
9336                fidl::encoding::EmptyPayload,
9337                fdomain_client::fidl::FDomainResourceDialect,
9338                0x2dc313d6aa81ad27,
9339            >(_buf?)?;
9340            Ok(_response)
9341        }
9342        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
9343            (vmar_handle,),
9344            0x2dc313d6aa81ad27,
9345            fidl::encoding::DynamicFlags::empty(),
9346            _decode,
9347        )
9348    }
9349}
9350
9351pub struct ProfileProviderEventStream {
9352    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
9353}
9354
9355impl std::marker::Unpin for ProfileProviderEventStream {}
9356
9357impl futures::stream::FusedStream for ProfileProviderEventStream {
9358    fn is_terminated(&self) -> bool {
9359        self.event_receiver.is_terminated()
9360    }
9361}
9362
9363impl futures::Stream for ProfileProviderEventStream {
9364    type Item = Result<ProfileProviderEvent, fidl::Error>;
9365
9366    fn poll_next(
9367        mut self: std::pin::Pin<&mut Self>,
9368        cx: &mut std::task::Context<'_>,
9369    ) -> std::task::Poll<Option<Self::Item>> {
9370        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9371            &mut self.event_receiver,
9372            cx
9373        )?) {
9374            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
9375            None => std::task::Poll::Ready(None),
9376        }
9377    }
9378}
9379
9380#[derive(Debug)]
9381pub enum ProfileProviderEvent {}
9382
9383impl ProfileProviderEvent {
9384    /// Decodes a message buffer as a [`ProfileProviderEvent`].
9385    fn decode(
9386        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9387    ) -> Result<ProfileProviderEvent, fidl::Error> {
9388        let (bytes, _handles) = buf.split_mut();
9389        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9390        debug_assert_eq!(tx_header.tx_id, 0);
9391        match tx_header.ordinal {
9392            _ => Err(fidl::Error::UnknownOrdinal {
9393                ordinal: tx_header.ordinal,
9394                protocol_name:
9395                    <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9396            }),
9397        }
9398    }
9399}
9400
9401/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
9402pub struct ProfileProviderRequestStream {
9403    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9404    is_terminated: bool,
9405}
9406
9407impl std::marker::Unpin for ProfileProviderRequestStream {}
9408
9409impl futures::stream::FusedStream for ProfileProviderRequestStream {
9410    fn is_terminated(&self) -> bool {
9411        self.is_terminated
9412    }
9413}
9414
9415impl fdomain_client::fidl::RequestStream for ProfileProviderRequestStream {
9416    type Protocol = ProfileProviderMarker;
9417    type ControlHandle = ProfileProviderControlHandle;
9418
9419    fn from_channel(channel: fdomain_client::Channel) -> Self {
9420        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9421    }
9422
9423    fn control_handle(&self) -> Self::ControlHandle {
9424        ProfileProviderControlHandle { inner: self.inner.clone() }
9425    }
9426
9427    fn into_inner(
9428        self,
9429    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
9430    {
9431        (self.inner, self.is_terminated)
9432    }
9433
9434    fn from_inner(
9435        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9436        is_terminated: bool,
9437    ) -> Self {
9438        Self { inner, is_terminated }
9439    }
9440}
9441
9442impl futures::Stream for ProfileProviderRequestStream {
9443    type Item = Result<ProfileProviderRequest, fidl::Error>;
9444
9445    fn poll_next(
9446        mut self: std::pin::Pin<&mut Self>,
9447        cx: &mut std::task::Context<'_>,
9448    ) -> std::task::Poll<Option<Self::Item>> {
9449        let this = &mut *self;
9450        if this.inner.check_shutdown(cx) {
9451            this.is_terminated = true;
9452            return std::task::Poll::Ready(None);
9453        }
9454        if this.is_terminated {
9455            panic!("polled ProfileProviderRequestStream after completion");
9456        }
9457        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
9458            |bytes, handles| {
9459                match this.inner.channel().read_etc(cx, bytes, handles) {
9460                    std::task::Poll::Ready(Ok(())) => {}
9461                    std::task::Poll::Pending => return std::task::Poll::Pending,
9462                    std::task::Poll::Ready(Err(None)) => {
9463                        this.is_terminated = true;
9464                        return std::task::Poll::Ready(None);
9465                    }
9466                    std::task::Poll::Ready(Err(Some(e))) => {
9467                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9468                            e.into(),
9469                        ))));
9470                    }
9471                }
9472
9473                // A message has been received from the channel
9474                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9475
9476                std::task::Poll::Ready(Some(match header.ordinal {
9477                0x60459ecef7458176 => {
9478                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9479                    let mut req = fidl::new_empty!(ProfileProviderRegisterHandlerWithCapacityRequest, fdomain_client::fidl::FDomainResourceDialect);
9480                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
9481                    let control_handle = ProfileProviderControlHandle {
9482                        inner: this.inner.clone(),
9483                    };
9484                    Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {thread_handle: req.thread_handle,
9485name: req.name,
9486period: req.period,
9487capacity: req.capacity,
9488
9489                        responder: ProfileProviderRegisterHandlerWithCapacityResponder {
9490                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9491                            tx_id: header.tx_id,
9492                        },
9493                    })
9494                }
9495                0x724d9d5fd8ef544c => {
9496                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9497                    let mut req = fidl::new_empty!(ProfileProviderUnregisterHandlerRequest, fdomain_client::fidl::FDomainResourceDialect);
9498                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
9499                    let control_handle = ProfileProviderControlHandle {
9500                        inner: this.inner.clone(),
9501                    };
9502                    Ok(ProfileProviderRequest::UnregisterHandler {thread_handle: req.thread_handle,
9503name: req.name,
9504
9505                        responder: ProfileProviderUnregisterHandlerResponder {
9506                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9507                            tx_id: header.tx_id,
9508                        },
9509                    })
9510                }
9511                0x2f509d3523e9562d => {
9512                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9513                    let mut req = fidl::new_empty!(ProfileProviderRegisterMemoryRangeRequest, fdomain_client::fidl::FDomainResourceDialect);
9514                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
9515                    let control_handle = ProfileProviderControlHandle {
9516                        inner: this.inner.clone(),
9517                    };
9518                    Ok(ProfileProviderRequest::RegisterMemoryRange {vmar_handle: req.vmar_handle,
9519name: req.name,
9520
9521                        responder: ProfileProviderRegisterMemoryRangeResponder {
9522                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9523                            tx_id: header.tx_id,
9524                        },
9525                    })
9526                }
9527                0x2dc313d6aa81ad27 => {
9528                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9529                    let mut req = fidl::new_empty!(ProfileProviderUnregisterMemoryRangeRequest, fdomain_client::fidl::FDomainResourceDialect);
9530                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
9531                    let control_handle = ProfileProviderControlHandle {
9532                        inner: this.inner.clone(),
9533                    };
9534                    Ok(ProfileProviderRequest::UnregisterMemoryRange {vmar_handle: req.vmar_handle,
9535
9536                        responder: ProfileProviderUnregisterMemoryRangeResponder {
9537                            control_handle: std::mem::ManuallyDrop::new(control_handle),
9538                            tx_id: header.tx_id,
9539                        },
9540                    })
9541                }
9542                _ => Err(fidl::Error::UnknownOrdinal {
9543                    ordinal: header.ordinal,
9544                    protocol_name: <ProfileProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
9545                }),
9546            }))
9547            },
9548        )
9549    }
9550}
9551
9552#[derive(Debug)]
9553pub enum ProfileProviderRequest {
9554    /// Register a thread as a media thread. This notifies the media subsystem that this thread
9555    /// should have an elevated scheduling profile applied to it in order to meet audio or video
9556    /// deadlines.
9557    ///
9558    /// `name` is the name of a system scheduling role to apply to the thread given by
9559    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
9560    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
9561    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
9562    /// the scheduling interval the thread needs to be running to achieve good performance or to
9563    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
9564    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
9565    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
9566    /// be rejected or result in scaling back the performance of other threads to fit resource
9567    /// limits.
9568    ///
9569    /// Capacity, max runtime, and period have the following relationship:
9570    ///
9571    ///   capacity = max runtime / period
9572    ///
9573    /// Where:
9574    ///
9575    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
9576    ///
9577    /// For heterogeneous systems, the capacity should be planned / measured against the highest
9578    /// performance processor(s) in the system. The system will automatically adjust the effective
9579    /// capacity to account for slower processors and operating points and will avoid processors and
9580    /// operating points that are too slow to meet the requested scheduling parameters (provided
9581    /// they are reasonable).
9582    ///
9583    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
9584    /// may be zero to indicate not applicable.
9585    RegisterHandlerWithCapacity {
9586        thread_handle: fdomain_client::Thread,
9587        name: String,
9588        period: i64,
9589        capacity: f32,
9590        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
9591    },
9592    /// Reset a thread's scheduling profile to the default.
9593    UnregisterHandler {
9594        thread_handle: fdomain_client::Thread,
9595        name: String,
9596        responder: ProfileProviderUnregisterHandlerResponder,
9597    },
9598    /// Register a memory range as being used for media processing. This notifies the media
9599    /// subsystem that this memory should have an elevated memory profile applied to it in order to
9600    /// meet audio or video deadlines.
9601    ///
9602    /// `name` is the name of a system memory role to apply to the memory given by
9603    /// `vmar_handle` -- different products may customize the underlying memory strategy based
9604    /// on the requested role.
9605    RegisterMemoryRange {
9606        vmar_handle: fdomain_client::Vmar,
9607        name: String,
9608        responder: ProfileProviderRegisterMemoryRangeResponder,
9609    },
9610    /// Reset a memory range's memory profile.
9611    UnregisterMemoryRange {
9612        vmar_handle: fdomain_client::Vmar,
9613        responder: ProfileProviderUnregisterMemoryRangeResponder,
9614    },
9615}
9616
9617impl ProfileProviderRequest {
9618    #[allow(irrefutable_let_patterns)]
9619    pub fn into_register_handler_with_capacity(
9620        self,
9621    ) -> Option<(
9622        fdomain_client::Thread,
9623        String,
9624        i64,
9625        f32,
9626        ProfileProviderRegisterHandlerWithCapacityResponder,
9627    )> {
9628        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
9629            thread_handle,
9630            name,
9631            period,
9632            capacity,
9633            responder,
9634        } = self
9635        {
9636            Some((thread_handle, name, period, capacity, responder))
9637        } else {
9638            None
9639        }
9640    }
9641
9642    #[allow(irrefutable_let_patterns)]
9643    pub fn into_unregister_handler(
9644        self,
9645    ) -> Option<(fdomain_client::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
9646        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
9647            Some((thread_handle, name, responder))
9648        } else {
9649            None
9650        }
9651    }
9652
9653    #[allow(irrefutable_let_patterns)]
9654    pub fn into_register_memory_range(
9655        self,
9656    ) -> Option<(fdomain_client::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
9657        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
9658            Some((vmar_handle, name, responder))
9659        } else {
9660            None
9661        }
9662    }
9663
9664    #[allow(irrefutable_let_patterns)]
9665    pub fn into_unregister_memory_range(
9666        self,
9667    ) -> Option<(fdomain_client::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
9668        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
9669            Some((vmar_handle, responder))
9670        } else {
9671            None
9672        }
9673    }
9674
9675    /// Name of the method defined in FIDL
9676    pub fn method_name(&self) -> &'static str {
9677        match *self {
9678            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
9679                "register_handler_with_capacity"
9680            }
9681            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
9682            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
9683            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
9684        }
9685    }
9686}
9687
9688#[derive(Debug, Clone)]
9689pub struct ProfileProviderControlHandle {
9690    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
9691}
9692
9693impl ProfileProviderControlHandle {
9694    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
9695        self.inner.shutdown_with_epitaph(status.into())
9696    }
9697}
9698
9699impl fdomain_client::fidl::ControlHandle for ProfileProviderControlHandle {
9700    fn shutdown(&self) {
9701        self.inner.shutdown()
9702    }
9703
9704    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
9705        self.inner.shutdown_with_epitaph(status)
9706    }
9707
9708    fn is_closed(&self) -> bool {
9709        self.inner.channel().is_closed()
9710    }
9711    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
9712        self.inner.channel().on_closed()
9713    }
9714}
9715
9716impl ProfileProviderControlHandle {}
9717
9718#[must_use = "FIDL methods require a response to be sent"]
9719#[derive(Debug)]
9720pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
9721    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9722    tx_id: u32,
9723}
9724
9725/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9726/// if the responder is dropped without sending a response, so that the client
9727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9728impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
9729    fn drop(&mut self) {
9730        self.control_handle.shutdown();
9731        // Safety: drops once, never accessed again
9732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9733    }
9734}
9735
9736impl fdomain_client::fidl::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
9737    type ControlHandle = ProfileProviderControlHandle;
9738
9739    fn control_handle(&self) -> &ProfileProviderControlHandle {
9740        &self.control_handle
9741    }
9742
9743    fn drop_without_shutdown(mut self) {
9744        // Safety: drops once, never accessed again due to mem::forget
9745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9746        // Prevent Drop from running (which would shut down the channel)
9747        std::mem::forget(self);
9748    }
9749}
9750
9751impl ProfileProviderRegisterHandlerWithCapacityResponder {
9752    /// Sends a response to the FIDL transaction.
9753    ///
9754    /// Sets the channel to shutdown if an error occurs.
9755    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
9756        let _result = self.send_raw(period, capacity);
9757        if _result.is_err() {
9758            self.control_handle.shutdown();
9759        }
9760        self.drop_without_shutdown();
9761        _result
9762    }
9763
9764    /// Similar to "send" but does not shutdown the channel if an error occurs.
9765    pub fn send_no_shutdown_on_err(
9766        self,
9767        mut period: i64,
9768        mut capacity: i64,
9769    ) -> Result<(), fidl::Error> {
9770        let _result = self.send_raw(period, capacity);
9771        self.drop_without_shutdown();
9772        _result
9773    }
9774
9775    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
9776        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
9777            (period, capacity),
9778            self.tx_id,
9779            0x60459ecef7458176,
9780            fidl::encoding::DynamicFlags::empty(),
9781        )
9782    }
9783}
9784
9785#[must_use = "FIDL methods require a response to be sent"]
9786#[derive(Debug)]
9787pub struct ProfileProviderUnregisterHandlerResponder {
9788    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9789    tx_id: u32,
9790}
9791
9792/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9793/// if the responder is dropped without sending a response, so that the client
9794/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9795impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
9796    fn drop(&mut self) {
9797        self.control_handle.shutdown();
9798        // Safety: drops once, never accessed again
9799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9800    }
9801}
9802
9803impl fdomain_client::fidl::Responder for ProfileProviderUnregisterHandlerResponder {
9804    type ControlHandle = ProfileProviderControlHandle;
9805
9806    fn control_handle(&self) -> &ProfileProviderControlHandle {
9807        &self.control_handle
9808    }
9809
9810    fn drop_without_shutdown(mut self) {
9811        // Safety: drops once, never accessed again due to mem::forget
9812        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9813        // Prevent Drop from running (which would shut down the channel)
9814        std::mem::forget(self);
9815    }
9816}
9817
9818impl ProfileProviderUnregisterHandlerResponder {
9819    /// Sends a response to the FIDL transaction.
9820    ///
9821    /// Sets the channel to shutdown if an error occurs.
9822    pub fn send(self) -> Result<(), fidl::Error> {
9823        let _result = self.send_raw();
9824        if _result.is_err() {
9825            self.control_handle.shutdown();
9826        }
9827        self.drop_without_shutdown();
9828        _result
9829    }
9830
9831    /// Similar to "send" but does not shutdown the channel if an error occurs.
9832    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9833        let _result = self.send_raw();
9834        self.drop_without_shutdown();
9835        _result
9836    }
9837
9838    fn send_raw(&self) -> Result<(), fidl::Error> {
9839        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9840            (),
9841            self.tx_id,
9842            0x724d9d5fd8ef544c,
9843            fidl::encoding::DynamicFlags::empty(),
9844        )
9845    }
9846}
9847
9848#[must_use = "FIDL methods require a response to be sent"]
9849#[derive(Debug)]
9850pub struct ProfileProviderRegisterMemoryRangeResponder {
9851    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9852    tx_id: u32,
9853}
9854
9855/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9856/// if the responder is dropped without sending a response, so that the client
9857/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9858impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
9859    fn drop(&mut self) {
9860        self.control_handle.shutdown();
9861        // Safety: drops once, never accessed again
9862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9863    }
9864}
9865
9866impl fdomain_client::fidl::Responder for ProfileProviderRegisterMemoryRangeResponder {
9867    type ControlHandle = ProfileProviderControlHandle;
9868
9869    fn control_handle(&self) -> &ProfileProviderControlHandle {
9870        &self.control_handle
9871    }
9872
9873    fn drop_without_shutdown(mut self) {
9874        // Safety: drops once, never accessed again due to mem::forget
9875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9876        // Prevent Drop from running (which would shut down the channel)
9877        std::mem::forget(self);
9878    }
9879}
9880
9881impl ProfileProviderRegisterMemoryRangeResponder {
9882    /// Sends a response to the FIDL transaction.
9883    ///
9884    /// Sets the channel to shutdown if an error occurs.
9885    pub fn send(self) -> Result<(), fidl::Error> {
9886        let _result = self.send_raw();
9887        if _result.is_err() {
9888            self.control_handle.shutdown();
9889        }
9890        self.drop_without_shutdown();
9891        _result
9892    }
9893
9894    /// Similar to "send" but does not shutdown the channel if an error occurs.
9895    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9896        let _result = self.send_raw();
9897        self.drop_without_shutdown();
9898        _result
9899    }
9900
9901    fn send_raw(&self) -> Result<(), fidl::Error> {
9902        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9903            (),
9904            self.tx_id,
9905            0x2f509d3523e9562d,
9906            fidl::encoding::DynamicFlags::empty(),
9907        )
9908    }
9909}
9910
9911#[must_use = "FIDL methods require a response to be sent"]
9912#[derive(Debug)]
9913pub struct ProfileProviderUnregisterMemoryRangeResponder {
9914    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
9915    tx_id: u32,
9916}
9917
9918/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
9919/// if the responder is dropped without sending a response, so that the client
9920/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
9921impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
9922    fn drop(&mut self) {
9923        self.control_handle.shutdown();
9924        // Safety: drops once, never accessed again
9925        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9926    }
9927}
9928
9929impl fdomain_client::fidl::Responder for ProfileProviderUnregisterMemoryRangeResponder {
9930    type ControlHandle = ProfileProviderControlHandle;
9931
9932    fn control_handle(&self) -> &ProfileProviderControlHandle {
9933        &self.control_handle
9934    }
9935
9936    fn drop_without_shutdown(mut self) {
9937        // Safety: drops once, never accessed again due to mem::forget
9938        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
9939        // Prevent Drop from running (which would shut down the channel)
9940        std::mem::forget(self);
9941    }
9942}
9943
9944impl ProfileProviderUnregisterMemoryRangeResponder {
9945    /// Sends a response to the FIDL transaction.
9946    ///
9947    /// Sets the channel to shutdown if an error occurs.
9948    pub fn send(self) -> Result<(), fidl::Error> {
9949        let _result = self.send_raw();
9950        if _result.is_err() {
9951            self.control_handle.shutdown();
9952        }
9953        self.drop_without_shutdown();
9954        _result
9955    }
9956
9957    /// Similar to "send" but does not shutdown the channel if an error occurs.
9958    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
9959        let _result = self.send_raw();
9960        self.drop_without_shutdown();
9961        _result
9962    }
9963
9964    fn send_raw(&self) -> Result<(), fidl::Error> {
9965        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
9966            (),
9967            self.tx_id,
9968            0x2dc313d6aa81ad27,
9969            fidl::encoding::DynamicFlags::empty(),
9970        )
9971    }
9972}
9973
9974#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
9975pub struct SessionAudioConsumerFactoryMarker;
9976
9977impl fdomain_client::fidl::ProtocolMarker for SessionAudioConsumerFactoryMarker {
9978    type Proxy = SessionAudioConsumerFactoryProxy;
9979    type RequestStream = SessionAudioConsumerFactoryRequestStream;
9980
9981    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
9982}
9983impl fdomain_client::fidl::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
9984
9985pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
9986    fn r#create_audio_consumer(
9987        &self,
9988        session_id: u64,
9989        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
9990    ) -> Result<(), fidl::Error>;
9991}
9992
9993#[derive(Debug, Clone)]
9994pub struct SessionAudioConsumerFactoryProxy {
9995    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
9996}
9997
9998impl fdomain_client::fidl::Proxy for SessionAudioConsumerFactoryProxy {
9999    type Protocol = SessionAudioConsumerFactoryMarker;
10000
10001    fn from_channel(inner: fdomain_client::Channel) -> Self {
10002        Self::new(inner)
10003    }
10004
10005    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
10006        self.client.into_channel().map_err(|client| Self { client })
10007    }
10008
10009    fn as_channel(&self) -> &fdomain_client::Channel {
10010        self.client.as_channel()
10011    }
10012}
10013
10014impl SessionAudioConsumerFactoryProxy {
10015    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
10016    pub fn new(channel: fdomain_client::Channel) -> Self {
10017        let protocol_name =
10018            <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
10019        Self { client: fidl::client::Client::new(channel, protocol_name) }
10020    }
10021
10022    /// Get a Stream of events from the remote end of the protocol.
10023    ///
10024    /// # Panics
10025    ///
10026    /// Panics if the event stream was already taken.
10027    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
10028        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
10029    }
10030
10031    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
10032    /// to a particular session. `session_id` is the identifier of the media session
10033    /// for which audio is to be rendered.
10034    pub fn r#create_audio_consumer(
10035        &self,
10036        mut session_id: u64,
10037        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10038    ) -> Result<(), fidl::Error> {
10039        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
10040            self,
10041            session_id,
10042            audio_consumer_request,
10043        )
10044    }
10045}
10046
10047impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
10048    fn r#create_audio_consumer(
10049        &self,
10050        mut session_id: u64,
10051        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10052    ) -> Result<(), fidl::Error> {
10053        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
10054            (session_id, audio_consumer_request),
10055            0x6fab96f988e7d7fb,
10056            fidl::encoding::DynamicFlags::empty(),
10057        )
10058    }
10059}
10060
10061pub struct SessionAudioConsumerFactoryEventStream {
10062    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10063}
10064
10065impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
10066
10067impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
10068    fn is_terminated(&self) -> bool {
10069        self.event_receiver.is_terminated()
10070    }
10071}
10072
10073impl futures::Stream for SessionAudioConsumerFactoryEventStream {
10074    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
10075
10076    fn poll_next(
10077        mut self: std::pin::Pin<&mut Self>,
10078        cx: &mut std::task::Context<'_>,
10079    ) -> std::task::Poll<Option<Self::Item>> {
10080        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10081            &mut self.event_receiver,
10082            cx
10083        )?) {
10084            Some(buf) => {
10085                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
10086            }
10087            None => std::task::Poll::Ready(None),
10088        }
10089    }
10090}
10091
10092#[derive(Debug)]
10093pub enum SessionAudioConsumerFactoryEvent {}
10094
10095impl SessionAudioConsumerFactoryEvent {
10096    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
10097    fn decode(
10098        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10099    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
10100        let (bytes, _handles) = buf.split_mut();
10101        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10102        debug_assert_eq!(tx_header.tx_id, 0);
10103        match tx_header.ordinal {
10104            _ => Err(fidl::Error::UnknownOrdinal {
10105                ordinal: tx_header.ordinal,
10106                protocol_name: <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10107            })
10108        }
10109    }
10110}
10111
10112/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
10113pub struct SessionAudioConsumerFactoryRequestStream {
10114    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10115    is_terminated: bool,
10116}
10117
10118impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
10119
10120impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
10121    fn is_terminated(&self) -> bool {
10122        self.is_terminated
10123    }
10124}
10125
10126impl fdomain_client::fidl::RequestStream for SessionAudioConsumerFactoryRequestStream {
10127    type Protocol = SessionAudioConsumerFactoryMarker;
10128    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
10129
10130    fn from_channel(channel: fdomain_client::Channel) -> Self {
10131        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10132    }
10133
10134    fn control_handle(&self) -> Self::ControlHandle {
10135        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
10136    }
10137
10138    fn into_inner(
10139        self,
10140    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10141    {
10142        (self.inner, self.is_terminated)
10143    }
10144
10145    fn from_inner(
10146        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10147        is_terminated: bool,
10148    ) -> Self {
10149        Self { inner, is_terminated }
10150    }
10151}
10152
10153impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
10154    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
10155
10156    fn poll_next(
10157        mut self: std::pin::Pin<&mut Self>,
10158        cx: &mut std::task::Context<'_>,
10159    ) -> std::task::Poll<Option<Self::Item>> {
10160        let this = &mut *self;
10161        if this.inner.check_shutdown(cx) {
10162            this.is_terminated = true;
10163            return std::task::Poll::Ready(None);
10164        }
10165        if this.is_terminated {
10166            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
10167        }
10168        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10169            |bytes, handles| {
10170                match this.inner.channel().read_etc(cx, bytes, handles) {
10171                    std::task::Poll::Ready(Ok(())) => {}
10172                    std::task::Poll::Pending => return std::task::Poll::Pending,
10173                    std::task::Poll::Ready(Err(None)) => {
10174                        this.is_terminated = true;
10175                        return std::task::Poll::Ready(None);
10176                    }
10177                    std::task::Poll::Ready(Err(Some(e))) => {
10178                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10179                            e.into(),
10180                        ))));
10181                    }
10182                }
10183
10184                // A message has been received from the channel
10185                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10186
10187                std::task::Poll::Ready(Some(match header.ordinal {
10188                0x6fab96f988e7d7fb => {
10189                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10190                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
10191                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
10192                    let control_handle = SessionAudioConsumerFactoryControlHandle {
10193                        inner: this.inner.clone(),
10194                    };
10195                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
10196audio_consumer_request: req.audio_consumer_request,
10197
10198                        control_handle,
10199                    })
10200                }
10201                _ => Err(fidl::Error::UnknownOrdinal {
10202                    ordinal: header.ordinal,
10203                    protocol_name: <SessionAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10204                }),
10205            }))
10206            },
10207        )
10208    }
10209}
10210
10211/// Interface for creating audio consumers bound to a session.
10212#[derive(Debug)]
10213pub enum SessionAudioConsumerFactoryRequest {
10214    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
10215    /// to a particular session. `session_id` is the identifier of the media session
10216    /// for which audio is to be rendered.
10217    CreateAudioConsumer {
10218        session_id: u64,
10219        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10220        control_handle: SessionAudioConsumerFactoryControlHandle,
10221    },
10222}
10223
10224impl SessionAudioConsumerFactoryRequest {
10225    #[allow(irrefutable_let_patterns)]
10226    pub fn into_create_audio_consumer(
10227        self,
10228    ) -> Option<(
10229        u64,
10230        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
10231        SessionAudioConsumerFactoryControlHandle,
10232    )> {
10233        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
10234            session_id,
10235            audio_consumer_request,
10236            control_handle,
10237        } = self
10238        {
10239            Some((session_id, audio_consumer_request, control_handle))
10240        } else {
10241            None
10242        }
10243    }
10244
10245    /// Name of the method defined in FIDL
10246    pub fn method_name(&self) -> &'static str {
10247        match *self {
10248            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
10249                "create_audio_consumer"
10250            }
10251        }
10252    }
10253}
10254
10255#[derive(Debug, Clone)]
10256pub struct SessionAudioConsumerFactoryControlHandle {
10257    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10258}
10259
10260impl SessionAudioConsumerFactoryControlHandle {
10261    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
10262        self.inner.shutdown_with_epitaph(status.into())
10263    }
10264}
10265
10266impl fdomain_client::fidl::ControlHandle for SessionAudioConsumerFactoryControlHandle {
10267    fn shutdown(&self) {
10268        self.inner.shutdown()
10269    }
10270
10271    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
10272        self.inner.shutdown_with_epitaph(status)
10273    }
10274
10275    fn is_closed(&self) -> bool {
10276        self.inner.channel().is_closed()
10277    }
10278    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
10279        self.inner.channel().on_closed()
10280    }
10281}
10282
10283impl SessionAudioConsumerFactoryControlHandle {}
10284
10285#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
10286pub struct SimpleStreamSinkMarker;
10287
10288impl fdomain_client::fidl::ProtocolMarker for SimpleStreamSinkMarker {
10289    type Proxy = SimpleStreamSinkProxy;
10290    type RequestStream = SimpleStreamSinkRequestStream;
10291
10292    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
10293}
10294
10295pub trait SimpleStreamSinkProxyInterface: Send + Sync {
10296    fn r#add_payload_buffer(
10297        &self,
10298        id: u32,
10299        payload_buffer: fdomain_client::Vmo,
10300    ) -> Result<(), fidl::Error>;
10301    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
10302    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10303    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
10304    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
10305    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
10306    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
10307    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
10308    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
10309}
10310
10311#[derive(Debug, Clone)]
10312pub struct SimpleStreamSinkProxy {
10313    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
10314}
10315
10316impl fdomain_client::fidl::Proxy for SimpleStreamSinkProxy {
10317    type Protocol = SimpleStreamSinkMarker;
10318
10319    fn from_channel(inner: fdomain_client::Channel) -> Self {
10320        Self::new(inner)
10321    }
10322
10323    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
10324        self.client.into_channel().map_err(|client| Self { client })
10325    }
10326
10327    fn as_channel(&self) -> &fdomain_client::Channel {
10328        self.client.as_channel()
10329    }
10330}
10331
10332impl SimpleStreamSinkProxy {
10333    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
10334    pub fn new(channel: fdomain_client::Channel) -> Self {
10335        let protocol_name =
10336            <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
10337        Self { client: fidl::client::Client::new(channel, protocol_name) }
10338    }
10339
10340    /// Get a Stream of events from the remote end of the protocol.
10341    ///
10342    /// # Panics
10343    ///
10344    /// Panics if the event stream was already taken.
10345    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
10346        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
10347    }
10348
10349    /// Adds a payload buffer to the current buffer set associated with the
10350    /// connection. A `StreamPacket` struct reference a payload buffer in the
10351    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10352    ///
10353    /// A buffer with ID `id` must not be in the current set when this method is
10354    /// invoked, otherwise the service will close the connection.
10355    pub fn r#add_payload_buffer(
10356        &self,
10357        mut id: u32,
10358        mut payload_buffer: fdomain_client::Vmo,
10359    ) -> Result<(), fidl::Error> {
10360        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
10361    }
10362
10363    /// Removes a payload buffer from the current buffer set associated with the
10364    /// connection.
10365    ///
10366    /// A buffer with ID `id` must exist in the current set when this method is
10367    /// invoked, otherwise the service will will close the connection.
10368    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10369        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
10370    }
10371
10372    /// Sends a packet to the service. The response is sent when the service is
10373    /// done with the associated payload memory.
10374    ///
10375    /// `packet` must be valid for the current buffer set, otherwise the service
10376    /// will close the connection.
10377    pub fn r#send_packet(
10378        &self,
10379        mut packet: &StreamPacket,
10380    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
10381        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
10382    }
10383
10384    /// Sends a packet to the service. This interface doesn't define how the
10385    /// client knows when the sink is done with the associated payload memory.
10386    /// The inheriting interface must define that.
10387    ///
10388    /// `packet` must be valid for the current buffer set, otherwise the service
10389    /// will close the connection.
10390    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
10391        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
10392    }
10393
10394    /// Indicates the stream has ended. The precise semantics of this method are
10395    /// determined by the inheriting interface.
10396    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
10397        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
10398    }
10399
10400    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10401    /// and not yet released. The response is sent after all packets have been
10402    /// released.
10403    pub fn r#discard_all_packets(
10404        &self,
10405    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
10406        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
10407    }
10408
10409    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10410    /// and not yet released.
10411    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
10412        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
10413    }
10414}
10415
10416impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
10417    fn r#add_payload_buffer(
10418        &self,
10419        mut id: u32,
10420        mut payload_buffer: fdomain_client::Vmo,
10421    ) -> Result<(), fidl::Error> {
10422        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
10423            (id, payload_buffer),
10424            0x3b3a37fc34fe5b56,
10425            fidl::encoding::DynamicFlags::empty(),
10426        )
10427    }
10428
10429    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
10430        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
10431            (id,),
10432            0x5d1e4f74c3658262,
10433            fidl::encoding::DynamicFlags::empty(),
10434        )
10435    }
10436
10437    type SendPacketResponseFut =
10438        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10439    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
10440        fn _decode(
10441            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10442        ) -> Result<(), fidl::Error> {
10443            let _response = fidl::client::decode_transaction_body::<
10444                fidl::encoding::EmptyPayload,
10445                fdomain_client::fidl::FDomainResourceDialect,
10446                0x67cddd607442775f,
10447            >(_buf?)?;
10448            Ok(_response)
10449        }
10450        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
10451            (packet,),
10452            0x67cddd607442775f,
10453            fidl::encoding::DynamicFlags::empty(),
10454            _decode,
10455        )
10456    }
10457
10458    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
10459        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
10460            (packet,),
10461            0x8d9b8b413ceba9d,
10462            fidl::encoding::DynamicFlags::empty(),
10463        )
10464    }
10465
10466    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
10467        self.client.send::<fidl::encoding::EmptyPayload>(
10468            (),
10469            0x6180fd6f7e793b71,
10470            fidl::encoding::DynamicFlags::empty(),
10471        )
10472    }
10473
10474    type DiscardAllPacketsResponseFut =
10475        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
10476    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
10477        fn _decode(
10478            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
10479        ) -> Result<(), fidl::Error> {
10480            let _response = fidl::client::decode_transaction_body::<
10481                fidl::encoding::EmptyPayload,
10482                fdomain_client::fidl::FDomainResourceDialect,
10483                0x6f4dad7af2917665,
10484            >(_buf?)?;
10485            Ok(_response)
10486        }
10487        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
10488            (),
10489            0x6f4dad7af2917665,
10490            fidl::encoding::DynamicFlags::empty(),
10491            _decode,
10492        )
10493    }
10494
10495    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
10496        self.client.send::<fidl::encoding::EmptyPayload>(
10497            (),
10498            0x50d36d0d23081bc4,
10499            fidl::encoding::DynamicFlags::empty(),
10500        )
10501    }
10502}
10503
10504pub struct SimpleStreamSinkEventStream {
10505    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
10506}
10507
10508impl std::marker::Unpin for SimpleStreamSinkEventStream {}
10509
10510impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
10511    fn is_terminated(&self) -> bool {
10512        self.event_receiver.is_terminated()
10513    }
10514}
10515
10516impl futures::Stream for SimpleStreamSinkEventStream {
10517    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
10518
10519    fn poll_next(
10520        mut self: std::pin::Pin<&mut Self>,
10521        cx: &mut std::task::Context<'_>,
10522    ) -> std::task::Poll<Option<Self::Item>> {
10523        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
10524            &mut self.event_receiver,
10525            cx
10526        )?) {
10527            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
10528            None => std::task::Poll::Ready(None),
10529        }
10530    }
10531}
10532
10533#[derive(Debug)]
10534pub enum SimpleStreamSinkEvent {}
10535
10536impl SimpleStreamSinkEvent {
10537    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
10538    fn decode(
10539        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
10540    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
10541        let (bytes, _handles) = buf.split_mut();
10542        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10543        debug_assert_eq!(tx_header.tx_id, 0);
10544        match tx_header.ordinal {
10545            _ => Err(fidl::Error::UnknownOrdinal {
10546                ordinal: tx_header.ordinal,
10547                protocol_name:
10548                    <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10549            }),
10550        }
10551    }
10552}
10553
10554/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
10555pub struct SimpleStreamSinkRequestStream {
10556    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10557    is_terminated: bool,
10558}
10559
10560impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
10561
10562impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
10563    fn is_terminated(&self) -> bool {
10564        self.is_terminated
10565    }
10566}
10567
10568impl fdomain_client::fidl::RequestStream for SimpleStreamSinkRequestStream {
10569    type Protocol = SimpleStreamSinkMarker;
10570    type ControlHandle = SimpleStreamSinkControlHandle;
10571
10572    fn from_channel(channel: fdomain_client::Channel) -> Self {
10573        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
10574    }
10575
10576    fn control_handle(&self) -> Self::ControlHandle {
10577        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
10578    }
10579
10580    fn into_inner(
10581        self,
10582    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
10583    {
10584        (self.inner, self.is_terminated)
10585    }
10586
10587    fn from_inner(
10588        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10589        is_terminated: bool,
10590    ) -> Self {
10591        Self { inner, is_terminated }
10592    }
10593}
10594
10595impl futures::Stream for SimpleStreamSinkRequestStream {
10596    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
10597
10598    fn poll_next(
10599        mut self: std::pin::Pin<&mut Self>,
10600        cx: &mut std::task::Context<'_>,
10601    ) -> std::task::Poll<Option<Self::Item>> {
10602        let this = &mut *self;
10603        if this.inner.check_shutdown(cx) {
10604            this.is_terminated = true;
10605            return std::task::Poll::Ready(None);
10606        }
10607        if this.is_terminated {
10608            panic!("polled SimpleStreamSinkRequestStream after completion");
10609        }
10610        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
10611            |bytes, handles| {
10612                match this.inner.channel().read_etc(cx, bytes, handles) {
10613                    std::task::Poll::Ready(Ok(())) => {}
10614                    std::task::Poll::Pending => return std::task::Poll::Pending,
10615                    std::task::Poll::Ready(Err(None)) => {
10616                        this.is_terminated = true;
10617                        return std::task::Poll::Ready(None);
10618                    }
10619                    std::task::Poll::Ready(Err(Some(e))) => {
10620                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
10621                            e.into(),
10622                        ))));
10623                    }
10624                }
10625
10626                // A message has been received from the channel
10627                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
10628
10629                std::task::Poll::Ready(Some(match header.ordinal {
10630                0x3b3a37fc34fe5b56 => {
10631                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10632                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10633                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10634                    let control_handle = SimpleStreamSinkControlHandle {
10635                        inner: this.inner.clone(),
10636                    };
10637                    Ok(SimpleStreamSinkRequest::AddPayloadBuffer {id: req.id,
10638payload_buffer: req.payload_buffer,
10639
10640                        control_handle,
10641                    })
10642                }
10643                0x5d1e4f74c3658262 => {
10644                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10645                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
10646                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
10647                    let control_handle = SimpleStreamSinkControlHandle {
10648                        inner: this.inner.clone(),
10649                    };
10650                    Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {id: req.id,
10651
10652                        control_handle,
10653                    })
10654                }
10655                0x67cddd607442775f => {
10656                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10657                    let mut req = fidl::new_empty!(StreamSinkSendPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
10658                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
10659                    let control_handle = SimpleStreamSinkControlHandle {
10660                        inner: this.inner.clone(),
10661                    };
10662                    Ok(SimpleStreamSinkRequest::SendPacket {packet: req.packet,
10663
10664                        responder: SimpleStreamSinkSendPacketResponder {
10665                            control_handle: std::mem::ManuallyDrop::new(control_handle),
10666                            tx_id: header.tx_id,
10667                        },
10668                    })
10669                }
10670                0x8d9b8b413ceba9d => {
10671                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10672                    let mut req = fidl::new_empty!(StreamSinkSendPacketNoReplyRequest, fdomain_client::fidl::FDomainResourceDialect);
10673                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
10674                    let control_handle = SimpleStreamSinkControlHandle {
10675                        inner: this.inner.clone(),
10676                    };
10677                    Ok(SimpleStreamSinkRequest::SendPacketNoReply {packet: req.packet,
10678
10679                        control_handle,
10680                    })
10681                }
10682                0x6180fd6f7e793b71 => {
10683                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10684                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10685                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10686                    let control_handle = SimpleStreamSinkControlHandle {
10687                        inner: this.inner.clone(),
10688                    };
10689                    Ok(SimpleStreamSinkRequest::EndOfStream {
10690                        control_handle,
10691                    })
10692                }
10693                0x6f4dad7af2917665 => {
10694                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
10695                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10696                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10697                    let control_handle = SimpleStreamSinkControlHandle {
10698                        inner: this.inner.clone(),
10699                    };
10700                    Ok(SimpleStreamSinkRequest::DiscardAllPackets {
10701                        responder: SimpleStreamSinkDiscardAllPacketsResponder {
10702                            control_handle: std::mem::ManuallyDrop::new(control_handle),
10703                            tx_id: header.tx_id,
10704                        },
10705                    })
10706                }
10707                0x50d36d0d23081bc4 => {
10708                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
10709                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
10710                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
10711                    let control_handle = SimpleStreamSinkControlHandle {
10712                        inner: this.inner.clone(),
10713                    };
10714                    Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply {
10715                        control_handle,
10716                    })
10717                }
10718                _ => Err(fidl::Error::UnknownOrdinal {
10719                    ordinal: header.ordinal,
10720                    protocol_name: <SimpleStreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
10721                }),
10722            }))
10723            },
10724        )
10725    }
10726}
10727
10728/// A StreamSink that uses StreamBufferSet for buffer management.
10729#[derive(Debug)]
10730pub enum SimpleStreamSinkRequest {
10731    /// Adds a payload buffer to the current buffer set associated with the
10732    /// connection. A `StreamPacket` struct reference a payload buffer in the
10733    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10734    ///
10735    /// A buffer with ID `id` must not be in the current set when this method is
10736    /// invoked, otherwise the service will close the connection.
10737    AddPayloadBuffer {
10738        id: u32,
10739        payload_buffer: fdomain_client::Vmo,
10740        control_handle: SimpleStreamSinkControlHandle,
10741    },
10742    /// Removes a payload buffer from the current buffer set associated with the
10743    /// connection.
10744    ///
10745    /// A buffer with ID `id` must exist in the current set when this method is
10746    /// invoked, otherwise the service will will close the connection.
10747    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
10748    /// Sends a packet to the service. The response is sent when the service is
10749    /// done with the associated payload memory.
10750    ///
10751    /// `packet` must be valid for the current buffer set, otherwise the service
10752    /// will close the connection.
10753    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
10754    /// Sends a packet to the service. This interface doesn't define how the
10755    /// client knows when the sink is done with the associated payload memory.
10756    /// The inheriting interface must define that.
10757    ///
10758    /// `packet` must be valid for the current buffer set, otherwise the service
10759    /// will close the connection.
10760    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
10761    /// Indicates the stream has ended. The precise semantics of this method are
10762    /// determined by the inheriting interface.
10763    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
10764    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10765    /// and not yet released. The response is sent after all packets have been
10766    /// released.
10767    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
10768    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10769    /// and not yet released.
10770    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
10771}
10772
10773impl SimpleStreamSinkRequest {
10774    #[allow(irrefutable_let_patterns)]
10775    pub fn into_add_payload_buffer(
10776        self,
10777    ) -> Option<(u32, fdomain_client::Vmo, SimpleStreamSinkControlHandle)> {
10778        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
10779            self
10780        {
10781            Some((id, payload_buffer, control_handle))
10782        } else {
10783            None
10784        }
10785    }
10786
10787    #[allow(irrefutable_let_patterns)]
10788    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
10789        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
10790            Some((id, control_handle))
10791        } else {
10792            None
10793        }
10794    }
10795
10796    #[allow(irrefutable_let_patterns)]
10797    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
10798        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
10799            Some((packet, responder))
10800        } else {
10801            None
10802        }
10803    }
10804
10805    #[allow(irrefutable_let_patterns)]
10806    pub fn into_send_packet_no_reply(
10807        self,
10808    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
10809        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
10810            Some((packet, control_handle))
10811        } else {
10812            None
10813        }
10814    }
10815
10816    #[allow(irrefutable_let_patterns)]
10817    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
10818        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
10819            Some((control_handle))
10820        } else {
10821            None
10822        }
10823    }
10824
10825    #[allow(irrefutable_let_patterns)]
10826    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
10827        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
10828            Some((responder))
10829        } else {
10830            None
10831        }
10832    }
10833
10834    #[allow(irrefutable_let_patterns)]
10835    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
10836        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
10837            Some((control_handle))
10838        } else {
10839            None
10840        }
10841    }
10842
10843    /// Name of the method defined in FIDL
10844    pub fn method_name(&self) -> &'static str {
10845        match *self {
10846            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10847            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10848            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
10849            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10850            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
10851            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
10852            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
10853                "discard_all_packets_no_reply"
10854            }
10855        }
10856    }
10857}
10858
10859#[derive(Debug, Clone)]
10860pub struct SimpleStreamSinkControlHandle {
10861    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
10862}
10863
10864impl SimpleStreamSinkControlHandle {
10865    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
10866        self.inner.shutdown_with_epitaph(status.into())
10867    }
10868}
10869
10870impl fdomain_client::fidl::ControlHandle for SimpleStreamSinkControlHandle {
10871    fn shutdown(&self) {
10872        self.inner.shutdown()
10873    }
10874
10875    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
10876        self.inner.shutdown_with_epitaph(status)
10877    }
10878
10879    fn is_closed(&self) -> bool {
10880        self.inner.channel().is_closed()
10881    }
10882    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
10883        self.inner.channel().on_closed()
10884    }
10885}
10886
10887impl SimpleStreamSinkControlHandle {}
10888
10889#[must_use = "FIDL methods require a response to be sent"]
10890#[derive(Debug)]
10891pub struct SimpleStreamSinkSendPacketResponder {
10892    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
10893    tx_id: u32,
10894}
10895
10896/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
10897/// if the responder is dropped without sending a response, so that the client
10898/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10899impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
10900    fn drop(&mut self) {
10901        self.control_handle.shutdown();
10902        // Safety: drops once, never accessed again
10903        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10904    }
10905}
10906
10907impl fdomain_client::fidl::Responder for SimpleStreamSinkSendPacketResponder {
10908    type ControlHandle = SimpleStreamSinkControlHandle;
10909
10910    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
10911        &self.control_handle
10912    }
10913
10914    fn drop_without_shutdown(mut self) {
10915        // Safety: drops once, never accessed again due to mem::forget
10916        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10917        // Prevent Drop from running (which would shut down the channel)
10918        std::mem::forget(self);
10919    }
10920}
10921
10922impl SimpleStreamSinkSendPacketResponder {
10923    /// Sends a response to the FIDL transaction.
10924    ///
10925    /// Sets the channel to shutdown if an error occurs.
10926    pub fn send(self) -> Result<(), fidl::Error> {
10927        let _result = self.send_raw();
10928        if _result.is_err() {
10929            self.control_handle.shutdown();
10930        }
10931        self.drop_without_shutdown();
10932        _result
10933    }
10934
10935    /// Similar to "send" but does not shutdown the channel if an error occurs.
10936    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10937        let _result = self.send_raw();
10938        self.drop_without_shutdown();
10939        _result
10940    }
10941
10942    fn send_raw(&self) -> Result<(), fidl::Error> {
10943        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10944            (),
10945            self.tx_id,
10946            0x67cddd607442775f,
10947            fidl::encoding::DynamicFlags::empty(),
10948        )
10949    }
10950}
10951
10952#[must_use = "FIDL methods require a response to be sent"]
10953#[derive(Debug)]
10954pub struct SimpleStreamSinkDiscardAllPacketsResponder {
10955    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
10956    tx_id: u32,
10957}
10958
10959/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
10960/// if the responder is dropped without sending a response, so that the client
10961/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10962impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
10963    fn drop(&mut self) {
10964        self.control_handle.shutdown();
10965        // Safety: drops once, never accessed again
10966        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10967    }
10968}
10969
10970impl fdomain_client::fidl::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
10971    type ControlHandle = SimpleStreamSinkControlHandle;
10972
10973    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
10974        &self.control_handle
10975    }
10976
10977    fn drop_without_shutdown(mut self) {
10978        // Safety: drops once, never accessed again due to mem::forget
10979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10980        // Prevent Drop from running (which would shut down the channel)
10981        std::mem::forget(self);
10982    }
10983}
10984
10985impl SimpleStreamSinkDiscardAllPacketsResponder {
10986    /// Sends a response to the FIDL transaction.
10987    ///
10988    /// Sets the channel to shutdown if an error occurs.
10989    pub fn send(self) -> Result<(), fidl::Error> {
10990        let _result = self.send_raw();
10991        if _result.is_err() {
10992            self.control_handle.shutdown();
10993        }
10994        self.drop_without_shutdown();
10995        _result
10996    }
10997
10998    /// Similar to "send" but does not shutdown the channel if an error occurs.
10999    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11000        let _result = self.send_raw();
11001        self.drop_without_shutdown();
11002        _result
11003    }
11004
11005    fn send_raw(&self) -> Result<(), fidl::Error> {
11006        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11007            (),
11008            self.tx_id,
11009            0x6f4dad7af2917665,
11010            fidl::encoding::DynamicFlags::empty(),
11011        )
11012    }
11013}
11014
11015#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11016pub struct StreamBufferSetMarker;
11017
11018impl fdomain_client::fidl::ProtocolMarker for StreamBufferSetMarker {
11019    type Proxy = StreamBufferSetProxy;
11020    type RequestStream = StreamBufferSetRequestStream;
11021
11022    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
11023}
11024
11025pub trait StreamBufferSetProxyInterface: Send + Sync {
11026    fn r#add_payload_buffer(
11027        &self,
11028        id: u32,
11029        payload_buffer: fdomain_client::Vmo,
11030    ) -> Result<(), fidl::Error>;
11031    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
11032}
11033
11034#[derive(Debug, Clone)]
11035pub struct StreamBufferSetProxy {
11036    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11037}
11038
11039impl fdomain_client::fidl::Proxy for StreamBufferSetProxy {
11040    type Protocol = StreamBufferSetMarker;
11041
11042    fn from_channel(inner: fdomain_client::Channel) -> Self {
11043        Self::new(inner)
11044    }
11045
11046    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11047        self.client.into_channel().map_err(|client| Self { client })
11048    }
11049
11050    fn as_channel(&self) -> &fdomain_client::Channel {
11051        self.client.as_channel()
11052    }
11053}
11054
11055impl StreamBufferSetProxy {
11056    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
11057    pub fn new(channel: fdomain_client::Channel) -> Self {
11058        let protocol_name =
11059            <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11060        Self { client: fidl::client::Client::new(channel, protocol_name) }
11061    }
11062
11063    /// Get a Stream of events from the remote end of the protocol.
11064    ///
11065    /// # Panics
11066    ///
11067    /// Panics if the event stream was already taken.
11068    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
11069        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
11070    }
11071
11072    /// Adds a payload buffer to the current buffer set associated with the
11073    /// connection. A `StreamPacket` struct reference a payload buffer in the
11074    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
11075    ///
11076    /// A buffer with ID `id` must not be in the current set when this method is
11077    /// invoked, otherwise the service will close the connection.
11078    pub fn r#add_payload_buffer(
11079        &self,
11080        mut id: u32,
11081        mut payload_buffer: fdomain_client::Vmo,
11082    ) -> Result<(), fidl::Error> {
11083        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
11084    }
11085
11086    /// Removes a payload buffer from the current buffer set associated with the
11087    /// connection.
11088    ///
11089    /// A buffer with ID `id` must exist in the current set when this method is
11090    /// invoked, otherwise the service will will close the connection.
11091    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
11092        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
11093    }
11094}
11095
11096impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
11097    fn r#add_payload_buffer(
11098        &self,
11099        mut id: u32,
11100        mut payload_buffer: fdomain_client::Vmo,
11101    ) -> Result<(), fidl::Error> {
11102        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
11103            (id, payload_buffer),
11104            0x3b3a37fc34fe5b56,
11105            fidl::encoding::DynamicFlags::empty(),
11106        )
11107    }
11108
11109    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
11110        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
11111            (id,),
11112            0x5d1e4f74c3658262,
11113            fidl::encoding::DynamicFlags::empty(),
11114        )
11115    }
11116}
11117
11118pub struct StreamBufferSetEventStream {
11119    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
11120}
11121
11122impl std::marker::Unpin for StreamBufferSetEventStream {}
11123
11124impl futures::stream::FusedStream for StreamBufferSetEventStream {
11125    fn is_terminated(&self) -> bool {
11126        self.event_receiver.is_terminated()
11127    }
11128}
11129
11130impl futures::Stream for StreamBufferSetEventStream {
11131    type Item = Result<StreamBufferSetEvent, fidl::Error>;
11132
11133    fn poll_next(
11134        mut self: std::pin::Pin<&mut Self>,
11135        cx: &mut std::task::Context<'_>,
11136    ) -> std::task::Poll<Option<Self::Item>> {
11137        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11138            &mut self.event_receiver,
11139            cx
11140        )?) {
11141            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
11142            None => std::task::Poll::Ready(None),
11143        }
11144    }
11145}
11146
11147#[derive(Debug)]
11148pub enum StreamBufferSetEvent {}
11149
11150impl StreamBufferSetEvent {
11151    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
11152    fn decode(
11153        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11154    ) -> Result<StreamBufferSetEvent, fidl::Error> {
11155        let (bytes, _handles) = buf.split_mut();
11156        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11157        debug_assert_eq!(tx_header.tx_id, 0);
11158        match tx_header.ordinal {
11159            _ => Err(fidl::Error::UnknownOrdinal {
11160                ordinal: tx_header.ordinal,
11161                protocol_name:
11162                    <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
11163            }),
11164        }
11165    }
11166}
11167
11168/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
11169pub struct StreamBufferSetRequestStream {
11170    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11171    is_terminated: bool,
11172}
11173
11174impl std::marker::Unpin for StreamBufferSetRequestStream {}
11175
11176impl futures::stream::FusedStream for StreamBufferSetRequestStream {
11177    fn is_terminated(&self) -> bool {
11178        self.is_terminated
11179    }
11180}
11181
11182impl fdomain_client::fidl::RequestStream for StreamBufferSetRequestStream {
11183    type Protocol = StreamBufferSetMarker;
11184    type ControlHandle = StreamBufferSetControlHandle;
11185
11186    fn from_channel(channel: fdomain_client::Channel) -> Self {
11187        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11188    }
11189
11190    fn control_handle(&self) -> Self::ControlHandle {
11191        StreamBufferSetControlHandle { inner: self.inner.clone() }
11192    }
11193
11194    fn into_inner(
11195        self,
11196    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
11197    {
11198        (self.inner, self.is_terminated)
11199    }
11200
11201    fn from_inner(
11202        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11203        is_terminated: bool,
11204    ) -> Self {
11205        Self { inner, is_terminated }
11206    }
11207}
11208
11209impl futures::Stream for StreamBufferSetRequestStream {
11210    type Item = Result<StreamBufferSetRequest, fidl::Error>;
11211
11212    fn poll_next(
11213        mut self: std::pin::Pin<&mut Self>,
11214        cx: &mut std::task::Context<'_>,
11215    ) -> std::task::Poll<Option<Self::Item>> {
11216        let this = &mut *self;
11217        if this.inner.check_shutdown(cx) {
11218            this.is_terminated = true;
11219            return std::task::Poll::Ready(None);
11220        }
11221        if this.is_terminated {
11222            panic!("polled StreamBufferSetRequestStream after completion");
11223        }
11224        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
11225            |bytes, handles| {
11226                match this.inner.channel().read_etc(cx, bytes, handles) {
11227                    std::task::Poll::Ready(Ok(())) => {}
11228                    std::task::Poll::Pending => return std::task::Poll::Pending,
11229                    std::task::Poll::Ready(Err(None)) => {
11230                        this.is_terminated = true;
11231                        return std::task::Poll::Ready(None);
11232                    }
11233                    std::task::Poll::Ready(Err(Some(e))) => {
11234                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11235                            e.into(),
11236                        ))));
11237                    }
11238                }
11239
11240                // A message has been received from the channel
11241                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11242
11243                std::task::Poll::Ready(Some(match header.ordinal {
11244                0x3b3a37fc34fe5b56 => {
11245                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11246                    let mut req = fidl::new_empty!(StreamBufferSetAddPayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
11247                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
11248                    let control_handle = StreamBufferSetControlHandle {
11249                        inner: this.inner.clone(),
11250                    };
11251                    Ok(StreamBufferSetRequest::AddPayloadBuffer {id: req.id,
11252payload_buffer: req.payload_buffer,
11253
11254                        control_handle,
11255                    })
11256                }
11257                0x5d1e4f74c3658262 => {
11258                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
11259                    let mut req = fidl::new_empty!(StreamBufferSetRemovePayloadBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
11260                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
11261                    let control_handle = StreamBufferSetControlHandle {
11262                        inner: this.inner.clone(),
11263                    };
11264                    Ok(StreamBufferSetRequest::RemovePayloadBuffer {id: req.id,
11265
11266                        control_handle,
11267                    })
11268                }
11269                _ => Err(fidl::Error::UnknownOrdinal {
11270                    ordinal: header.ordinal,
11271                    protocol_name: <StreamBufferSetMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
11272                }),
11273            }))
11274            },
11275        )
11276    }
11277}
11278
11279/// Manages a set of payload buffers for a stream. This interface is typically
11280/// inherited along with `StreamSink` or `StreamSource` to enable the transport
11281/// of elementary streams between clients and services.
11282#[derive(Debug)]
11283pub enum StreamBufferSetRequest {
11284    /// Adds a payload buffer to the current buffer set associated with the
11285    /// connection. A `StreamPacket` struct reference a payload buffer in the
11286    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
11287    ///
11288    /// A buffer with ID `id` must not be in the current set when this method is
11289    /// invoked, otherwise the service will close the connection.
11290    AddPayloadBuffer {
11291        id: u32,
11292        payload_buffer: fdomain_client::Vmo,
11293        control_handle: StreamBufferSetControlHandle,
11294    },
11295    /// Removes a payload buffer from the current buffer set associated with the
11296    /// connection.
11297    ///
11298    /// A buffer with ID `id` must exist in the current set when this method is
11299    /// invoked, otherwise the service will will close the connection.
11300    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
11301}
11302
11303impl StreamBufferSetRequest {
11304    #[allow(irrefutable_let_patterns)]
11305    pub fn into_add_payload_buffer(
11306        self,
11307    ) -> Option<(u32, fdomain_client::Vmo, StreamBufferSetControlHandle)> {
11308        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
11309            self
11310        {
11311            Some((id, payload_buffer, control_handle))
11312        } else {
11313            None
11314        }
11315    }
11316
11317    #[allow(irrefutable_let_patterns)]
11318    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
11319        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
11320            Some((id, control_handle))
11321        } else {
11322            None
11323        }
11324    }
11325
11326    /// Name of the method defined in FIDL
11327    pub fn method_name(&self) -> &'static str {
11328        match *self {
11329            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
11330            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
11331        }
11332    }
11333}
11334
11335#[derive(Debug, Clone)]
11336pub struct StreamBufferSetControlHandle {
11337    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
11338}
11339
11340impl StreamBufferSetControlHandle {
11341    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
11342        self.inner.shutdown_with_epitaph(status.into())
11343    }
11344}
11345
11346impl fdomain_client::fidl::ControlHandle for StreamBufferSetControlHandle {
11347    fn shutdown(&self) {
11348        self.inner.shutdown()
11349    }
11350
11351    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
11352        self.inner.shutdown_with_epitaph(status)
11353    }
11354
11355    fn is_closed(&self) -> bool {
11356        self.inner.channel().is_closed()
11357    }
11358    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
11359        self.inner.channel().on_closed()
11360    }
11361}
11362
11363impl StreamBufferSetControlHandle {}
11364
11365#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11366pub struct StreamProcessorMarker;
11367
11368impl fdomain_client::fidl::ProtocolMarker for StreamProcessorMarker {
11369    type Proxy = StreamProcessorProxy;
11370    type RequestStream = StreamProcessorRequestStream;
11371
11372    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
11373}
11374
11375pub trait StreamProcessorProxyInterface: Send + Sync {
11376    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
11377    fn r#set_input_buffer_partial_settings(
11378        &self,
11379        input_settings: StreamBufferPartialSettings,
11380    ) -> Result<(), fidl::Error>;
11381    fn r#set_output_buffer_partial_settings(
11382        &self,
11383        output_settings: StreamBufferPartialSettings,
11384    ) -> Result<(), fidl::Error>;
11385    fn r#complete_output_buffer_partial_settings(
11386        &self,
11387        buffer_lifetime_ordinal: u64,
11388    ) -> Result<(), fidl::Error>;
11389    fn r#flush_end_of_stream_and_close_stream(
11390        &self,
11391        stream_lifetime_ordinal: u64,
11392    ) -> Result<(), fidl::Error>;
11393    fn r#close_current_stream(
11394        &self,
11395        stream_lifetime_ordinal: u64,
11396        release_input_buffers: bool,
11397        release_output_buffers: bool,
11398    ) -> Result<(), fidl::Error>;
11399    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11400    fn r#sync(&self) -> Self::SyncResponseFut;
11401    fn r#recycle_output_packet(
11402        &self,
11403        available_output_packet: &PacketHeader,
11404    ) -> Result<(), fidl::Error>;
11405    fn r#queue_input_format_details(
11406        &self,
11407        stream_lifetime_ordinal: u64,
11408        format_details: &FormatDetails,
11409    ) -> Result<(), fidl::Error>;
11410    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
11411    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
11412    fn r#participate_in_buffer_allocation(
11413        &self,
11414        payload: StreamProcessorParticipateInBufferAllocationRequest,
11415    ) -> Result<(), fidl::Error>;
11416    fn r#add_buffer(&self, payload: StreamProcessorAddBufferRequest) -> Result<(), fidl::Error>;
11417    type RemoveBufferResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11418    fn r#remove_buffer(
11419        &self,
11420        payload: StreamProcessorRemoveBufferRequest,
11421    ) -> Self::RemoveBufferResponseFut;
11422    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error>;
11423    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error>;
11424    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error>;
11425}
11426
11427#[derive(Debug, Clone)]
11428pub struct StreamProcessorProxy {
11429    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
11430}
11431
11432impl fdomain_client::fidl::Proxy for StreamProcessorProxy {
11433    type Protocol = StreamProcessorMarker;
11434
11435    fn from_channel(inner: fdomain_client::Channel) -> Self {
11436        Self::new(inner)
11437    }
11438
11439    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
11440        self.client.into_channel().map_err(|client| Self { client })
11441    }
11442
11443    fn as_channel(&self) -> &fdomain_client::Channel {
11444        self.client.as_channel()
11445    }
11446}
11447
11448impl StreamProcessorProxy {
11449    /// Create a new Proxy for fuchsia.media/StreamProcessor.
11450    pub fn new(channel: fdomain_client::Channel) -> Self {
11451        let protocol_name =
11452            <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
11453        Self { client: fidl::client::Client::new(channel, protocol_name) }
11454    }
11455
11456    /// Get a Stream of events from the remote end of the protocol.
11457    ///
11458    /// # Panics
11459    ///
11460    /// Panics if the event stream was already taken.
11461    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
11462        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
11463    }
11464
11465    /// Permit the server to use OnStreamFailed() instead of the server just
11466    /// closing the whole StreamProcessor channel on stream failure.
11467    ///
11468    /// If the server hasn't seen this message by the time a stream fails, the
11469    /// server will close the StreamProcessor channel instead of sending
11470    /// OnStreamFailed().
11471    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
11472        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
11473    }
11474
11475    /// When the client is not using dynamic buffers, a single
11476    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
11477    /// client-specified input settings and a BufferCollectionToken which the
11478    /// StreamProcessor will use to convey constraints to sysmem.  Both the
11479    /// client and the StreamProcessor will be informed of the allocated buffers
11480    /// directly by sysmem via their BufferCollection channel (not via the
11481    /// StreamProcessor channel).
11482    ///
11483    /// The client must not QueueInput...() until after sysmem informs the
11484    /// client that buffer allocation has completed and was successful.
11485    ///
11486    /// The server should be prepared to see QueueInput...() before the server
11487    /// has necessarily heard from sysmem that the buffers are allocated - the
11488    /// server must tolerate either ordering, as the QueueInput...() and
11489    /// notification of sysmem allocation completion arrive on different
11490    /// channels, so the client having heard that allocation is complete doesn't
11491    /// mean the server knows that allocation is complete yet.  However, the
11492    /// server can expect that allocation is in fact complete and can expect to
11493    /// get the allocation information from sysmem immediately upon requesting
11494    /// the information from sysmem.
11495    ///
11496    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
11497    /// while there are any buffers still active on the port. To successfully
11498    /// switch modes for a port, most clients will want to just start over with
11499    /// a new StreamProcessor instance. This can also be done reliably by first
11500    /// ensuring that every added buffer under the port up to "now" (including
11501    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
11502    /// request. Only then is it known ok to switch modes for that port under
11503    /// the same StreamProcessor. Most clients will just use one way or the
11504    /// other to add buffers and never need to switch to the other way,
11505    /// especially within the same StreamProcessor.
11506    pub fn r#set_input_buffer_partial_settings(
11507        &self,
11508        mut input_settings: StreamBufferPartialSettings,
11509    ) -> Result<(), fidl::Error> {
11510        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
11511    }
11512
11513    /// This is the replacement for SetOutputBufferSettings().
11514    ///
11515    /// When the client is using sysmem to allocate buffers, this message is
11516    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
11517    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
11518    /// with the client-specified output settings and a BufferCollectionToken
11519    /// which the StreamProcessor will use to convey constraints to sysmem. Both
11520    /// the client and the StreamProcessor will be informed of the allocated
11521    /// buffers directly by sysmem via their BufferCollection channel (not via
11522    /// the StreamProcessor channel).
11523    ///
11524    /// Configuring output buffers is _required_ after OnOutputConstraints() is
11525    /// received by the client with buffer_constraints_action_required true and
11526    /// stream_lifetime_ordinal equal to the client's current
11527    /// stream_lifetime_ordinal (even if there is an active stream), and is
11528    /// _permitted_ any time there is no current stream.
11529    ///
11530    /// Closing the current stream occurs on the StreamControl ordering domain,
11531    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
11532    /// subsequent Sync() completion must be received by the client before the
11533    /// client knows that there's no longer a current stream.
11534    ///
11535    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
11536    /// while there are any buffers still active on the port. To successfully
11537    /// switch modes for a port, most clients will want to just start over with
11538    /// a new StreamProcessor instance. This can also be done reliably by first
11539    /// ensuring that every added buffer under the port up to "now" (including
11540    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
11541    /// request. Only then is it known ok to switch modes for that port under
11542    /// the same StreamProcessor. Most clients will just use one way or the
11543    /// other to add buffers and never need to switch to the other way,
11544    /// especially not within the same StreamProcessor instance.
11545    ///
11546    /// See also CompleteOutputBufferPartialSettings().
11547    pub fn r#set_output_buffer_partial_settings(
11548        &self,
11549        mut output_settings: StreamBufferPartialSettings,
11550    ) -> Result<(), fidl::Error> {
11551        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
11552    }
11553
11554    /// After SetOutputBufferPartialSettings(), the server won't send
11555    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
11556    /// OnOutputEndOfStream() until after the client sends
11557    /// CompleteOutputBufferPartialSettings().
11558    ///
11559    /// This message isn't permitted after AddBuffer. When using dynamic buffers
11560    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
11561    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
11562    /// the case of OnOutputPacket there must also be at least one output buffer
11563    /// that's been added but not yet fully removed (RemoveBuffer not yet
11564    /// complete).
11565    ///
11566    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
11567    /// immediately after SetOutputBufferPartialSettings() - in that case the
11568    /// client needs to be prepared to receive output without knowing the buffer
11569    /// count or packet count yet - such clients may internally delay processing
11570    /// the received output until the client has heard from sysmem (which is
11571    /// when the client will learn the buffer count and packet count).
11572    ///
11573    /// Other clients may first wait for sysmem to allocate, prepare to receive
11574    /// output, and then send CompleteOutputBufferPartialSettings().
11575    pub fn r#complete_output_buffer_partial_settings(
11576        &self,
11577        mut buffer_lifetime_ordinal: u64,
11578    ) -> Result<(), fidl::Error> {
11579        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
11580            self,
11581            buffer_lifetime_ordinal,
11582        )
11583    }
11584
11585    /// This message is optional; a client isn't required to send this ever.
11586    ///
11587    /// Terminology note: In the name of this message, "flush" means flush
11588    /// through, sometimes called "drain". This messge does not discard. To
11589    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
11590    /// without first waiting for OnOutputEndOfStream of the old stream and
11591    /// without sending FlushEndOfStreamAndCloseStream.
11592    ///
11593    /// There is currently no way to cancel the flush effect of this message
11594    /// short of the client closing the StreamProcessor channel.
11595    ///
11596    /// This message is only valid after QueueInputEndOfStream() for this
11597    /// stream. The stream_lifetime_ordinal input parameter must match the
11598    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
11599    /// will close the channel.
11600    ///
11601    /// A client can use this message to flush through (drain, not discard) the
11602    /// last input data of a stream so that the stream processor server
11603    /// generates corresponding output data for all the input data before the
11604    /// server moves on to the next stream, without forcing the client to wait
11605    /// for OnOutputEndOfStream() before queueing data of another stream.
11606    ///
11607    /// The difference between QueueInputEndOfStream() and
11608    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
11609    /// from the client that there will not be any more input data for the
11610    /// stream (and this info is needed by some stream processors for the stream
11611    /// processor to ever emit the very last output data).  The
11612    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
11613    /// later completely discarding the rest of the current stream by closing
11614    /// the current stream (with or without a stream switch).  In contrast,
11615    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
11616    /// the previously-queued input data be processed including the logical
11617    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
11618    /// before moving on to any newer stream - this essentially changes the
11619    /// close-stream handling from discard to flush-through for this stream
11620    /// only.
11621    ///
11622    /// A client using this message can start providing input data for a new
11623    /// stream without that causing discard of old stream data.  That's the
11624    /// purpose of this message - to allow a client to flush through (not
11625    /// discard) the old stream's last data (instead of the default when closing
11626    /// or switching streams which is discard).
11627    ///
11628    /// Because the old stream is not done processing yet and the old stream's
11629    /// data is not being discarded, the client must be prepared to continue to
11630    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
11631    /// is done. The client will know the stream_lifetime_ordinal is done when
11632    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
11633    /// closes.
11634    pub fn r#flush_end_of_stream_and_close_stream(
11635        &self,
11636        mut stream_lifetime_ordinal: u64,
11637    ) -> Result<(), fidl::Error> {
11638        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
11639            self,
11640            stream_lifetime_ordinal,
11641        )
11642    }
11643
11644    /// This "closes" the current stream, leaving no current stream.  In
11645    /// addition, this message can optionally release (and unregister) input
11646    /// buffers or output buffers.
11647    ///
11648    /// If there has never been any active stream, the stream_lifetime_ordinal
11649    /// must be zero or the server will close the channel.  If there has been an
11650    /// active stream, the stream_lifetime_ordinal must be the most recent
11651    /// active stream whether that stream is still active or not.  Else the
11652    /// server will close the channel.
11653    ///
11654    /// Multiple of this message without any new active stream in between is not
11655    /// to be considered an error, which allows a client to use this message to
11656    /// close the current stream to stop wasting processing power on a stream
11657    /// the user no longer cares about, then later decide that buffers should be
11658    /// released and send this message again with release_input_buffers and/or
11659    /// release_output_buffers true to get the buffers released, if the client
11660    /// is interested in trying to avoid overlap in resource usage between old
11661    /// buffers and new buffers (not all clients are).
11662    ///
11663    /// See also Sync().
11664    pub fn r#close_current_stream(
11665        &self,
11666        mut stream_lifetime_ordinal: u64,
11667        mut release_input_buffers: bool,
11668        mut release_output_buffers: bool,
11669    ) -> Result<(), fidl::Error> {
11670        StreamProcessorProxyInterface::r#close_current_stream(
11671            self,
11672            stream_lifetime_ordinal,
11673            release_input_buffers,
11674            release_output_buffers,
11675        )
11676    }
11677
11678    /// On completion, all previous StreamProcessor calls have done what they're
11679    /// going to do server-side, _except_ for processing of data queued using
11680    /// QueueInputPacket().
11681    ///
11682    /// The main purpose of this call is to enable the client to wait until
11683    /// CloseCurrentStream() with release_input_buffers and/or
11684    /// release_output_buffers set to true to take effect, before the client
11685    /// allocates new buffers and re-sets-up input and/or output buffers.  This
11686    /// de-overlapping of resource usage can be worthwhile for media buffers
11687    /// which can consume resource types whose overall pools aren't necessarily
11688    /// vast in comparison to resources consumed.  Especially if a client is
11689    /// reconfiguring buffers multiple times.
11690    ///
11691    /// Note that Sync() prior to allocating new media buffers is not alone
11692    /// sufficient to achieve non-overlap of media buffer resource usage system
11693    /// wide, but it can be a useful part of achieving that.
11694    ///
11695    /// The Sync() transits the Output ordering domain and the StreamControl
11696    /// ordering domain, but not the InputData ordering domain.
11697    ///
11698    /// This request can be used to avoid hitting kMaxInFlightStreams which is
11699    /// presently 10.  A client that stays <= 8 in-flight streams will
11700    /// comfortably stay under the limit of 10.  While the protocol permits
11701    /// repeated SetInputBufferSettings() and the like, a client that spams the
11702    /// channel can expect that the channel will just close if the server or the
11703    /// channel itself gets too far behind.
11704    pub fn r#sync(
11705        &self,
11706    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
11707        StreamProcessorProxyInterface::r#sync(self)
11708    }
11709
11710    /// After the client is done with an output packet, the client needs to tell
11711    /// the stream processor that the output packet can be re-used for more
11712    /// output, using this message.
11713    ///
11714    /// It's not permitted to recycle an output packet that's already free with
11715    /// the stream processor server.
11716    ///
11717    /// If a client is using EnableOldOutputBuffers, the client must recycle all
11718    /// packets when done with them, even those of old buffer_lifetime_ordinal.
11719    /// This is also permitted behavior for all clients.
11720    ///
11721    /// If a client is not using EnableOldOutputBuffers, the client may
11722    /// optionally omit this message for packets with an old
11723    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
11724    /// or implicit output buffer de-configuration don't need to be recycled if
11725    /// the client isn't using and won't be using EnableOldOutputBuffers.
11726    pub fn r#recycle_output_packet(
11727        &self,
11728        mut available_output_packet: &PacketHeader,
11729    ) -> Result<(), fidl::Error> {
11730        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
11731    }
11732
11733    /// If the input format details are still the same as specified during
11734    /// StreamProcessor creation, this message is unnecessary and does not need
11735    /// to be sent.
11736    ///
11737    /// If the stream doesn't exist yet, this message creates the stream.
11738    ///
11739    /// The server won't send OnOutputConstraints() until after the client has
11740    /// sent at least one QueueInput* message.
11741    ///
11742    /// All servers must permit QueueInputFormatDetails() at the start of a
11743    /// stream without failing, as long as the new format is supported by the
11744    /// StreamProcessor instance. Technically this allows for a server to only
11745    /// support the exact input format set during StreamProcessor creation, and
11746    /// that is by design. A client that tries to switch formats and gets a
11747    /// StreamProcessor channel failure should try again one more time with a
11748    /// fresh StreamProcessor instance created with CodecFactory using the new
11749    /// input format during creation, before giving up.
11750    ///
11751    /// These format details override the format details specified during stream
11752    /// processor creation for this stream only. The next stream will default
11753    /// back to the format details set during stream processor creation.
11754    ///
11755    /// This message is permitted at the start of the first stream (just like at
11756    /// the start of any stream). The format specified need not match what was
11757    /// specified during stream processor creation, but if it doesn't match, the
11758    /// StreamProcessor channel might close as described above.
11759    pub fn r#queue_input_format_details(
11760        &self,
11761        mut stream_lifetime_ordinal: u64,
11762        mut format_details: &FormatDetails,
11763    ) -> Result<(), fidl::Error> {
11764        StreamProcessorProxyInterface::r#queue_input_format_details(
11765            self,
11766            stream_lifetime_ordinal,
11767            format_details,
11768        )
11769    }
11770
11771    /// This message queues input data to the stream processor for processing.
11772    ///
11773    /// If the stream doesn't exist yet, this message creates the new stream.
11774    ///
11775    /// The server won't send OnOutputConstraints() until after the client has
11776    /// sent at least one QueueInput* message.
11777    ///
11778    /// When using dynamic buffers the server can send OnOutputConstraints,
11779    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
11780    /// the first QueueInputPacket. In the case of OnOutputPacket there must
11781    /// also be at least one output buffer that's been added but not yet fully
11782    /// removed (RemoveBuffer not yet complete).
11783    ///
11784    /// The client must continue to deliver input data via this message even if
11785    /// the stream processor has not yet generated the first
11786    /// OnOutputConstraints, and even if the StreamProcessor is generating
11787    /// OnFreeInputPacket for previously-queued input packets.  The input data
11788    /// must continue as long as there are free packets to be assured that the
11789    /// server will ever generate the first OnOutputConstraints.
11790    ///
11791    /// The server will close the channel if this packet refers to an old
11792    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
11793    /// different dimensions to a video encoder can either (a) allocate buffers
11794    /// large enough to contain the range of needed image sizes and use those to
11795    /// deliver all the input images, (b) keep their own sets of buffers used
11796    /// for different image dimensions and re-add old buffers with AddBuffer,
11797    /// moving to a new buffer_lifetime_ordinal each time image dimensions
11798    /// change, or (c) allocate new buffers each time image dimensions change.
11799    /// The (a) option is preferred, for clients that have the flexibiilty to
11800    /// store images of varying dimensions in a single set of buffers. Clients
11801    /// that require each buffer to have a single image size can use option (b)
11802    /// or (c).
11803    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
11804        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
11805    }
11806
11807    /// Inform the server that all QueueInputPacket() messages for this stream
11808    /// have been sent.
11809    ///
11810    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
11811    /// or StreamProcessor channel closing), there will later be a corresponding
11812    /// OnOutputEndOfStream().
11813    ///
11814    /// The corresponding OnOutputEndOfStream() message will be generated only
11815    /// if the server finishes processing the stream before the server sees the
11816    /// client close the stream (such as by starting a new stream). A way to
11817    /// force the server to finish the stream before closing is to use
11818    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
11819    /// any new stream. Another way to force the server to finish the stream
11820    /// before closing is to wait for the OnOutputEndOfStream() before taking
11821    /// any action that closes the stream.
11822    ///
11823    /// In addition to serving as an "EndOfStream" marker to make it obvious
11824    /// client-side when all input data has been processed, if a client never
11825    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
11826    /// result in all input data getting processed through to the output. Some
11827    /// stream processors have some internally-delayed data which only gets
11828    /// drained (pushed through) by additional input data _or_ by this
11829    /// EndOfStream marker. In that sense, this message can be viewed as a drain
11830    /// at InputData domain level, but the drain only takes effect if the stream
11831    /// processor even gets that far before the stream is just closed at
11832    /// StreamControl domain level. This message is not alone sufficient to act
11833    /// as an overall drain at StreamControl level. For that, send this message
11834    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
11835    /// becomes possible to queue input data for a new stream without causing
11836    /// discard of this older stream's data). Alternately, the client can wait
11837    /// for the OnOutputEndOfStream before closing the current stream.
11838    ///
11839    /// After a client sends QueueInputEndOfStream for a stream, if the client
11840    /// then sends for the same stream any of QueueInputPacket,
11841    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
11842    /// the StreamProcessor channel.
11843    pub fn r#queue_input_end_of_stream(
11844        &self,
11845        mut stream_lifetime_ordinal: u64,
11846    ) -> Result<(), fidl::Error> {
11847        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
11848    }
11849
11850    /// This message results in channel closure unless supports_dynamic_buffers
11851    /// is set to true.
11852    ///
11853    /// This participates in allocation of buffers to be used with AddBuffer
11854    /// later. The client can get VMO handles for these buffers by also
11855    /// participating in the sysmem allocation, using the client's own related
11856    /// sysmem token (associated with the same logical buffer collection). It's
11857    /// up to the client to separately set any constraints needed by the client
11858    /// using the client's own related sysmem token, if any.
11859    ///
11860    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
11861    /// SetOutputBufferPartialSettings. Servers must support those messages.
11862    ///
11863    /// In handling this message, if `allow_single_buffer` is set to true, the
11864    /// server must not constrain the number of buffers allocated. The server
11865    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
11866    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
11867    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
11868    /// same value if the intent is to allocate exactly that many buffers. If
11869    /// `allow_single_buffer` is un-set or set to false, the server will
11870    /// indicate needed buffer counts to sysmem.
11871    ///
11872    /// The server's BufferCollection channel (created from the passed-in
11873    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
11874    /// particular, the server shouldn't expect the BufferCollection channel to
11875    /// remain connected to sysmem beyond the server sending SetConstraints. For
11876    /// this reason, the server may not be able to call
11877    /// WaitForAllBuffersAllocated or similar, so the server should just send
11878    /// SetConstraints, Close, then close the server's BufferCollection
11879    /// client_end. This means the server in general shouldn't attempt to get
11880    /// VMO handles for these buffers while processing this message.
11881    ///
11882    /// The server should not assume that these buffers will necessarily ever be
11883    /// added with AddBuffer to this StreamProcessor instance or any other
11884    /// StreamProcessor instance (owned by the server or not). These buffers may
11885    /// instead be dropped, or as a less-common example, possibly added to a
11886    /// different codec served by a different server implementation which also
11887    /// participated in the same sysmem buffer collection allocation.
11888    ///
11889    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
11890    /// StreamProcessor instance of the same codec (same per CodecFactory) is
11891    /// likely to work, but using the same StreamProcessor instance is
11892    /// recommended when feasible.
11893    ///
11894    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
11895    /// a different StreamProcessor instance of the same codec (same per
11896    /// CodecFactory) can't (within reason) be made work in general, especially
11897    /// for video decoders. Therefore, for output buffers, the same
11898    /// StreamProcessor instance must be used for this message and AddBuffer.
11899    /// While a client may currently be able to get away with using different
11900    /// StreamProcessor instances for this message and AddBuffer for output
11901    /// buffers for some codecs, this may break at any time without it being
11902    /// considered a server-side bug.
11903    ///
11904    /// The allocated buffers can later be added using AddBuffer (piecemeal),
11905    /// and can be removed (piecemeal) using RemoveBuffer.
11906    ///
11907    /// Multiple different ParticipateInBufferAllocation messages can have their
11908    /// buffers later added to the same StreamProcessor instance using the same
11909    /// buffer_lifetime_ordinal. This can be useful if the client wants to
11910    /// allocate buffers incrementally, or dynamically adjust the number of
11911    /// buffers, potentially while actively processing. See also the
11912    /// `buffer_lifetime_ordinal` field of this message.
11913    ///
11914    /// Server implementations may use sysmem to help verify buffer
11915    /// compatibility later when buffers are added with AddBuffer.
11916    pub fn r#participate_in_buffer_allocation(
11917        &self,
11918        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
11919    ) -> Result<(), fidl::Error> {
11920        StreamProcessorProxyInterface::r#participate_in_buffer_allocation(self, payload)
11921    }
11922
11923    /// Add buffers previously created with the help of
11924    /// ParticipateInBufferAllocation.
11925    ///
11926    /// For input buffers, the client can send QueueInputFormatDetails or
11927    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
11928    /// buffer must be added before a valid QueueInputPacket can be sent. Most
11929    /// clients will want to continue quickly adding buffers up to at least
11930    /// buffer_count_for_server_current to avoid the codec potentially stalling,
11931    /// and typically a low number of buffers beyond that to keep the pipeline
11932    /// running smoothly. Input buffers beyond the first input buffer can be
11933    /// added after the first QueueInputPacket.
11934    ///
11935    /// Even if buffer_constraints_version_ordinal is current, the server must
11936    /// not close the channel if the buffer isn't consistent with the current
11937    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
11938    /// consistent StreamProcessor constraints). Instead, the server must send a
11939    /// new OnOutputConstraints. This simplifies some edge cases for some
11940    /// clients, particularly when a client can't reliably detect whether a
11941    /// newly-obtained buffer was actually allocated after
11942    /// buffer_constraints_version_ordinal changed, or may have been cached from
11943    /// before.
11944    ///
11945    /// The client can add additional buffers to the same port and
11946    /// buffer_lifetime_ordinal at any time using this message. If the
11947    /// buffer_lifetime_ordinal is no longer the most recent, the message will
11948    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
11949    /// message re. the same buffer will complete immediately.
11950    ///
11951    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
11952    /// by the sum of buffers added by all AddBuffer calls with the same
11953    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
11954    /// required to close the channel in this case if performance degradation or
11955    /// un-tested behavior would result from adding too many buffers.
11956    ///
11957    /// Switching to a new buffer_lifetime_ordinal starts the process of
11958    /// removing buffers associated with an old buffer_lifetime_ordinal.
11959    /// However, until the remove is complete, those buffers can still be used
11960    /// by the codec as normal. See also RemoveBuffer, which can be used to
11961    /// detect when removal is complete, regardless of whether the RemoveBuffer
11962    /// started the removal (including when not using dynamic buffers).
11963    ///
11964    /// The buffer stays added until removal later completes. The buffer remains
11965    /// added across potentially multiple buffer re-uses. Removal can be
11966    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
11967    /// The codec server can unilaterally initiate buffer removal; if the server
11968    /// does this, it must send a new buffer_constraints_version_ordinal with
11969    /// action_required true. Some other client-initiated messages can also
11970    /// begin buffer removal, such as CloseCurrentStream with
11971    /// release_input_buffers and/or release_output_buffers. The buffers are
11972    /// also automatically removed and released if the client closes the
11973    /// StreamProcessor client_end or the server closes the StreamProcessor
11974    /// server_end.
11975    ///
11976    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
11977    /// SetOutputBufferPartialSettings is not allowed while there are any
11978    /// buffers still active on the port. To successfully switch modes for a
11979    /// port, most clients will want to just start over with a new
11980    /// StreamProcessor instance. This can also be done reliably by first
11981    /// ensuring that every added buffer under the port up to "now" (including
11982    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
11983    /// request. Only then is it known ok to switch modes for that port under
11984    /// the same StreamProcessor. Most clients will just use one way or the
11985    /// other to add buffers and never need to switch to the other way,
11986    /// especially within the same StreamProcessor.
11987    ///
11988    /// If a client might plausibly "spam" creation of many new
11989    /// buffer_lifetime_ordinal values without the buffers seeing any actual
11990    /// usage in between, the client should consider starting a Sync every few
11991    /// buffer_lifetime_ordinal(s) to fence cleanup of old
11992    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
11993    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
11994    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
11995    /// getting too far ahead of closing out old ones. The threshold of 16 is
11996    /// well below the enforcement threshold. Clients don't need to Sync if they
11997    /// won't be spamming new buffer_lifetime_ordinal values, or if added
11998    /// buffers will see at least some actual usage visible to the client before
11999    /// being replaced again.
12000    ///
12001    /// All buffers of the same port and buffer_lifetime_ordinal must share the
12002    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
12003    /// this in various ways. One way is to use ParticipateInBufferAllocation
12004    /// then AddBuffer for at least the first buffer, before
12005    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
12006    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
12007    /// and bump to the next odd buffer_lifetime_ordinal value for the
12008    /// AddBuffer.
12009    pub fn r#add_buffer(
12010        &self,
12011        mut payload: StreamProcessorAddBufferRequest,
12012    ) -> Result<(), fidl::Error> {
12013        StreamProcessorProxyInterface::r#add_buffer(self, payload)
12014    }
12015
12016    /// When using dynamic buffers, this call removes a buffer as soon as the
12017    /// buffer can be removed without adversely impacting any ongoing processing
12018    /// or an in-flight output packet referring to the buffer.
12019    ///
12020    /// If a client wants to remove a buffer with an in-flight output packet
12021    /// referring to the buffer, the client must RecycleOutputPacket for that
12022    /// in-flight output packet before the RemoveBuffer will complete.
12023    ///
12024    /// When using SetInputBufferPartialSettings /
12025    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
12026    /// the buffer. This call will complete when the buffer is done removing due
12027    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
12028    ///
12029    /// Until RemoveBuffer completes, the codec is still allowed to send
12030    /// OnOutputPacket messages referencing the buffer, and the codec may still
12031    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
12032    /// codec guarantees that no subsequent output packet will reference the
12033    /// buffer, and that the server holds no VMO handles to the buffer.
12034    ///
12035    /// The client may need to recycle an output packet before the RemoveBuffer
12036    /// call can complete. Clients should take care to avoid blocking packet
12037    /// recycling while the RemoveBuffer request is in progress, since this
12038    /// would create a potential deadlock.
12039    ///
12040    /// The server closing any VMO handles to the buffer prior to completing
12041    /// this call is important for the client's ability to prevent memory usage
12042    /// spikes.
12043    ///
12044    /// If the client has "paused" processing by not providing any more input,
12045    /// the client will potentially need to send CloseCurrentStream before
12046    /// RemoveBuffer will complete. When using dynamic buffers, setting
12047    /// release_input_buffers or release_output_buffers to true is not
12048    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
12049    /// specific buffer. When not using dynamic buffers, the client will need to
12050    /// set release_input_buffers or release_output_buffers to true, since
12051    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
12052    /// buffers. A current "paused" stream needs to be stopped because frames
12053    /// can be held as reference frames, and codecs are never reqiured to copy
12054    /// their output data.
12055    ///
12056    /// For any video decoder output buffers being removed while there's an
12057    /// active stream (being fed input or not), it's typically best for the
12058    /// client to assume that removal of a video decoder output buffer may take
12059    /// a very long duration. This is because bitstreams, especially
12060    /// non-standard-compliant bitstreams, but in some cases potentially even
12061    /// standard-compliant bitstreams, can keep a video decoder output buffer in
12062    /// the set of active reference frames (aka DPB) indefinitely. The server is
12063    /// not required to notice that a stream is not conforming to a bitstream
12064    /// standard in this regard.
12065    ///
12066    /// In the case of h.264 decode, a standard-complient bitstream will limit
12067    /// the reorder delay to no longer than the max DPB occupancy. However, a
12068    /// server is not required to detect or reject non-compliant streams that
12069    /// potentially keep a frame in the DPB for longer.
12070    ///
12071    /// For HEVC, the situation is similar to h.264 (IIUC).
12072    ///
12073    /// In the case of VP9, there is nothing in the bitstream spec that limits
12074    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
12075    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
12076    /// required to detect or mitigate this.
12077    ///
12078    /// Until this call completes, the server may still be using the buffer. For
12079    /// output buffers, the server can still send OnOutputPacket message(s) that
12080    /// references this buffer, but only up until the RemoveBuffer completion
12081    /// message is sent by the server. The client must continue to
12082    /// RecycleOutputPacket for packets that reference the buffer, until
12083    /// RemoveBuffer completes.
12084    ///
12085    /// When using dynamic buffers, upon receiving this message, the server will
12086    /// stop selecting the buffer for any new usage (as in, for any usage that
12087    /// moves the buffer from "free" to "not free" within the server). This
12088    /// applies even if the server has no other buffers available for use (aka
12089    /// no other "free" buffers). Any existing usage of the buffer is not ended
12090    /// early by this call alone.
12091    ///
12092    /// When not using dynamic buffers, upon receiving this message, the server
12093    /// will just remember to complete this call shortly after the buffer has
12094    /// completed removal triggered by some other cause (removal is not
12095    /// triggered/caused by this call).
12096    ///
12097    /// For video decoders, when using dynamic buffers, typically the client
12098    /// should take care to avoid removing too many output buffers for continued
12099    /// decode to be possible. If this occurs, the decoder will wait until the
12100    /// client adds another output buffer with AddBuffer. This can be a deadlock
12101    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
12102    /// frame reordering, sending a single AddBuffer doesn't necessarily
12103    /// guarantee another OnOutputPacket, since additional output buffers can be
12104    /// needed before the server can send OnOutputPacket.
12105    ///
12106    /// The client must not call RemoveBuffer on the same buffer more than once,
12107    /// whether overlapping in time or not. The server should enforce this when
12108    /// not enforcing would require tracking additional concurrent requests. The
12109    /// server is not required to enforce this when enforcing would use more
12110    /// server memory.
12111    ///
12112    /// The server is allowed to complete this request quickly with success for
12113    /// buffer_lifetime_ordinal and buffer_index combinations that were never
12114    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
12115    /// hasn't been started by the client yet (no removing potential future
12116    /// buffers).
12117    ///
12118    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
12119    /// combination may be re-used after completion of RemoveBuffer, but only if
12120    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
12121    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
12122    ///
12123    /// Assuming a valid historical buffer is specified, successful completion
12124    /// of this call means the buffer has been fully released by the server and
12125    /// won't be referenced in any subsequent OnOutputPacket.
12126    pub fn r#remove_buffer(
12127        &self,
12128        mut payload: StreamProcessorRemoveBufferRequest,
12129    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
12130        StreamProcessorProxyInterface::r#remove_buffer(self, payload)
12131    }
12132
12133    /// This informs the StreamProcessor that the client is prepared to handle
12134    /// output packets that specify a buffer with buffer_lifetime_ordinal older
12135    /// than the most recent buffer_lifetime_ordinal.
12136    ///
12137    /// If the client doesn't send this message, the StreamProcessor will omit
12138    /// any such output, even if
12139    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
12140    /// decoders such as VP9 decoders, not sending this message can result in
12141    /// output that isn't bistream spec compliant, and the output can be
12142    /// visually different than intended by the bitstream.
12143    ///
12144    /// Such streams are only possible with some bitstream formats (such as
12145    /// VP9), and are rare, but can happen and can be valid per the bitstream
12146    /// spec. For example, this can be specified by a VP9 bitstream using
12147    /// show_existing_frame to output an old-dimensions buffer after having
12148    /// already output a new-dimensions buffer.
12149    ///
12150    /// Most clients that send this message will also want to use RemoveBuffer
12151    /// to know when it becomes safe to stop tracking an old buffer.
12152    ///
12153    /// Most of the time this makes no difference as most bitstreams don't
12154    /// actually emit old buffers, even if the bitstream spec would allow it.
12155    /// Old output buffers are especially rare for RTC streams which typically
12156    /// don't have any frame reordering in the first place.
12157    ///
12158    /// In most video streaming scenarios that use dimension switching as part
12159    /// of their bitrate control strategy (among those that I've observed), at
12160    /// the StreamProcessor layer the new dimensions are part of a new stream
12161    /// instead of being spliced together as a continuation of the old stream.
12162    /// That said, using a continuation of the old stream is also a completely
12163    /// valid way to implement dimension switching. When a stream switch occurs
12164    /// as part of dimension switching, the decoder state is not retained and
12165    /// there won't be any old buffer(s) emitted after new buffer(s), since the
12166    /// new stream doesn't know anything about old buffers filled by the old
12167    /// stream.
12168    ///
12169    /// Clients which haven't tested their ability to handle old output buffers
12170    /// should not send this message. Clients decoding bitstreams like VP9 for
12171    /// decoder compliance testing purposes should send this message (and use a
12172    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
12173    /// Clients which are required to support old output frames and/or fully
12174    /// comply with a relevant bitstream spec should/must send this message, and
12175    /// should test using a test stream that outputs packets referencing an old
12176    /// output buffer.
12177    ///
12178    /// Sending this message more than once closes the channel. If sent, this
12179    /// message must be sent prior to the client establishing the first output
12180    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
12181    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
12182    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
12183    /// client when this message was not sent by the client.
12184    ///
12185    /// This message is only permitted when
12186    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
12187    /// is true.
12188    pub fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
12189        StreamProcessorProxyInterface::r#enable_old_output_buffers(self)
12190    }
12191
12192    /// This informs the StreamProcessor that the client is prepared to handle
12193    /// output packets that specify the same buffer as another packet that's
12194    /// also concurrently in flight to the client (not yet recycled).
12195    ///
12196    /// Most bitstream formats don't do this. In formats that can do this such
12197    /// as VP9, most actual bitstreams don't do this.
12198    ///
12199    /// As an example, in VP9, a stream can cause the same output buffer to be
12200    /// used by another emitted output packet/frame by using show_existing_frame
12201    /// on the same VP9 reference/held frame slot more than once without
12202    /// decoding a new frame into that slot in between.
12203    ///
12204    /// Clients that need to achieve full bitstream spec compliance for such a
12205    /// bitstream format must send this message.
12206    ///
12207    /// If this message is not in effect, the server will omit any such output,
12208    /// which can result in output that is not compliant to the relevant
12209    /// bitstream spec, and which can be visually different than the stream
12210    /// intended.
12211    ///
12212    /// Sending this message more than once closes the channel. If sent, this
12213    /// message must be sent prior to the client establishing the first output
12214    /// buffer_lifetime_ordinal.
12215    ///
12216    /// This message is only permitted when
12217    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
12218    /// is true.
12219    pub fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
12220        StreamProcessorProxyInterface::r#enable_same_output_buffer_concurrently_in_flight(self)
12221    }
12222
12223    /// For video decoders, this forces the output buffers to be reallocated if
12224    /// the image size needs to change. This is wasteful as it forces extra
12225    /// buffer reallocations given typical video bitrate control strategies
12226    /// (applicable to both streaming and RTC) involving shifting the image
12227    /// dimensions up and down repeatedly as a logical video/stream plays,
12228    /// sometimes even if network conditions remain fairly stable. This extra
12229    /// buffer reallocation cost is incurred vs. baseline whether the dimension
12230    /// switching is achieved within a single StreamProcessor stream or by using
12231    /// a new StreamProcessor stream for new dimensions.
12232    ///
12233    /// A client should not send this message unless the client really must
12234    /// force the output buffers to be reallocated every time the output image
12235    /// size changes.
12236    ///
12237    /// Sending this message more than once closes the channel. If sent, this
12238    /// message must be sent prior to any SetInputBufferPartialSettings,
12239    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
12240    /// AddBuffer.
12241    ///
12242    /// This message is only permitted if this StreamProcessor is a video
12243    /// decoder.
12244    ///
12245    /// This message is only permitted when
12246    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
12247    /// is true.
12248    pub fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
12249        StreamProcessorProxyInterface::r#enable_force_output_buffers_fixed_image_size(self)
12250    }
12251}
12252
12253impl StreamProcessorProxyInterface for StreamProcessorProxy {
12254    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
12255        self.client.send::<fidl::encoding::EmptyPayload>(
12256            (),
12257            0x3940929617dbf02b,
12258            fidl::encoding::DynamicFlags::empty(),
12259        )
12260    }
12261
12262    fn r#set_input_buffer_partial_settings(
12263        &self,
12264        mut input_settings: StreamBufferPartialSettings,
12265    ) -> Result<(), fidl::Error> {
12266        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
12267            (&mut input_settings,),
12268            0xb02e0663a40e4c4,
12269            fidl::encoding::DynamicFlags::empty(),
12270        )
12271    }
12272
12273    fn r#set_output_buffer_partial_settings(
12274        &self,
12275        mut output_settings: StreamBufferPartialSettings,
12276    ) -> Result<(), fidl::Error> {
12277        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
12278            (&mut output_settings,),
12279            0x118bb8c819a7bbbb,
12280            fidl::encoding::DynamicFlags::empty(),
12281        )
12282    }
12283
12284    fn r#complete_output_buffer_partial_settings(
12285        &self,
12286        mut buffer_lifetime_ordinal: u64,
12287    ) -> Result<(), fidl::Error> {
12288        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
12289            (buffer_lifetime_ordinal,),
12290            0x50529e5c680ae3ab,
12291            fidl::encoding::DynamicFlags::empty(),
12292        )
12293    }
12294
12295    fn r#flush_end_of_stream_and_close_stream(
12296        &self,
12297        mut stream_lifetime_ordinal: u64,
12298    ) -> Result<(), fidl::Error> {
12299        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
12300            (stream_lifetime_ordinal,),
12301            0x2b62c3e26d0667e6,
12302            fidl::encoding::DynamicFlags::empty(),
12303        )
12304    }
12305
12306    fn r#close_current_stream(
12307        &self,
12308        mut stream_lifetime_ordinal: u64,
12309        mut release_input_buffers: bool,
12310        mut release_output_buffers: bool,
12311    ) -> Result<(), fidl::Error> {
12312        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
12313            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
12314            0x1d8a67522170ca07,
12315            fidl::encoding::DynamicFlags::empty(),
12316        )
12317    }
12318
12319    type SyncResponseFut =
12320        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
12321    fn r#sync(&self) -> Self::SyncResponseFut {
12322        fn _decode(
12323            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12324        ) -> Result<(), fidl::Error> {
12325            let _response = fidl::client::decode_transaction_body::<
12326                fidl::encoding::EmptyPayload,
12327                fdomain_client::fidl::FDomainResourceDialect,
12328                0x4b3e44300b0ec6aa,
12329            >(_buf?)?;
12330            Ok(_response)
12331        }
12332        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12333            (),
12334            0x4b3e44300b0ec6aa,
12335            fidl::encoding::DynamicFlags::empty(),
12336            _decode,
12337        )
12338    }
12339
12340    fn r#recycle_output_packet(
12341        &self,
12342        mut available_output_packet: &PacketHeader,
12343    ) -> Result<(), fidl::Error> {
12344        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
12345            (available_output_packet,),
12346            0x32763632b94e0bd5,
12347            fidl::encoding::DynamicFlags::empty(),
12348        )
12349    }
12350
12351    fn r#queue_input_format_details(
12352        &self,
12353        mut stream_lifetime_ordinal: u64,
12354        mut format_details: &FormatDetails,
12355    ) -> Result<(), fidl::Error> {
12356        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
12357            (stream_lifetime_ordinal, format_details),
12358            0x170dc0979d52231,
12359            fidl::encoding::DynamicFlags::empty(),
12360        )
12361    }
12362
12363    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
12364        self.client.send::<StreamProcessorQueueInputPacketRequest>(
12365            (packet,),
12366            0x47173d2652d9df3b,
12367            fidl::encoding::DynamicFlags::empty(),
12368        )
12369    }
12370
12371    fn r#queue_input_end_of_stream(
12372        &self,
12373        mut stream_lifetime_ordinal: u64,
12374    ) -> Result<(), fidl::Error> {
12375        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
12376            (stream_lifetime_ordinal,),
12377            0x2051b6ad00f20b37,
12378            fidl::encoding::DynamicFlags::empty(),
12379        )
12380    }
12381
12382    fn r#participate_in_buffer_allocation(
12383        &self,
12384        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
12385    ) -> Result<(), fidl::Error> {
12386        self.client.send::<StreamProcessorParticipateInBufferAllocationRequest>(
12387            &mut payload,
12388            0x122be3b0096183cb,
12389            fidl::encoding::DynamicFlags::FLEXIBLE,
12390        )
12391    }
12392
12393    fn r#add_buffer(
12394        &self,
12395        mut payload: StreamProcessorAddBufferRequest,
12396    ) -> Result<(), fidl::Error> {
12397        self.client.send::<StreamProcessorAddBufferRequest>(
12398            &mut payload,
12399            0x6eca773e923e0ada,
12400            fidl::encoding::DynamicFlags::FLEXIBLE,
12401        )
12402    }
12403
12404    type RemoveBufferResponseFut =
12405        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
12406    fn r#remove_buffer(
12407        &self,
12408        mut payload: StreamProcessorRemoveBufferRequest,
12409    ) -> Self::RemoveBufferResponseFut {
12410        fn _decode(
12411            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12412        ) -> Result<(), fidl::Error> {
12413            let _response = fidl::client::decode_transaction_body::<
12414                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
12415                fdomain_client::fidl::FDomainResourceDialect,
12416                0x40b967ffa6b2da43,
12417            >(_buf?)?
12418            .into_result_fdomain::<StreamProcessorMarker>("remove_buffer")?;
12419            Ok(_response)
12420        }
12421        self.client.send_query_and_decode::<StreamProcessorRemoveBufferRequest, ()>(
12422            &mut payload,
12423            0x40b967ffa6b2da43,
12424            fidl::encoding::DynamicFlags::FLEXIBLE,
12425            _decode,
12426        )
12427    }
12428
12429    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
12430        self.client.send::<fidl::encoding::EmptyPayload>(
12431            (),
12432            0x3aedefeedf3898b0,
12433            fidl::encoding::DynamicFlags::FLEXIBLE,
12434        )
12435    }
12436
12437    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
12438        self.client.send::<fidl::encoding::EmptyPayload>(
12439            (),
12440            0x244e9f43b29709e7,
12441            fidl::encoding::DynamicFlags::FLEXIBLE,
12442        )
12443    }
12444
12445    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
12446        self.client.send::<fidl::encoding::EmptyPayload>(
12447            (),
12448            0x3994b040f91dc1e9,
12449            fidl::encoding::DynamicFlags::FLEXIBLE,
12450        )
12451    }
12452}
12453
12454pub struct StreamProcessorEventStream {
12455    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
12456}
12457
12458impl std::marker::Unpin for StreamProcessorEventStream {}
12459
12460impl futures::stream::FusedStream for StreamProcessorEventStream {
12461    fn is_terminated(&self) -> bool {
12462        self.event_receiver.is_terminated()
12463    }
12464}
12465
12466impl futures::Stream for StreamProcessorEventStream {
12467    type Item = Result<StreamProcessorEvent, fidl::Error>;
12468
12469    fn poll_next(
12470        mut self: std::pin::Pin<&mut Self>,
12471        cx: &mut std::task::Context<'_>,
12472    ) -> std::task::Poll<Option<Self::Item>> {
12473        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12474            &mut self.event_receiver,
12475            cx
12476        )?) {
12477            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
12478            None => std::task::Poll::Ready(None),
12479        }
12480    }
12481}
12482
12483#[derive(Debug)]
12484pub enum StreamProcessorEvent {
12485    OnStreamFailed {
12486        stream_lifetime_ordinal: u64,
12487        error: StreamError,
12488    },
12489    OnInputConstraints {
12490        input_constraints: StreamBufferConstraints,
12491    },
12492    OnOutputConstraints {
12493        output_config: StreamOutputConstraints,
12494    },
12495    OnOutputFormat {
12496        output_format: StreamOutputFormat,
12497    },
12498    OnOutputPacket {
12499        output_packet: Packet,
12500        error_detected_before: bool,
12501        error_detected_during: bool,
12502    },
12503    OnOutputEndOfStream {
12504        stream_lifetime_ordinal: u64,
12505        error_detected_before: bool,
12506    },
12507    OnFreeInputPacket {
12508        free_input_packet: PacketHeader,
12509    },
12510    OnOutputTimestampHasNoOutput {
12511        payload: StreamProcessorOnOutputTimestampHasNoOutputRequest,
12512    },
12513    #[non_exhaustive]
12514    _UnknownEvent {
12515        /// Ordinal of the event that was sent.
12516        ordinal: u64,
12517    },
12518}
12519
12520impl StreamProcessorEvent {
12521    #[allow(irrefutable_let_patterns)]
12522    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
12523        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
12524            Some((stream_lifetime_ordinal, error))
12525        } else {
12526            None
12527        }
12528    }
12529    #[allow(irrefutable_let_patterns)]
12530    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
12531        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
12532            Some((input_constraints))
12533        } else {
12534            None
12535        }
12536    }
12537    #[allow(irrefutable_let_patterns)]
12538    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
12539        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
12540            Some((output_config))
12541        } else {
12542            None
12543        }
12544    }
12545    #[allow(irrefutable_let_patterns)]
12546    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
12547        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
12548            Some((output_format))
12549        } else {
12550            None
12551        }
12552    }
12553    #[allow(irrefutable_let_patterns)]
12554    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
12555        if let StreamProcessorEvent::OnOutputPacket {
12556            output_packet,
12557            error_detected_before,
12558            error_detected_during,
12559        } = self
12560        {
12561            Some((output_packet, error_detected_before, error_detected_during))
12562        } else {
12563            None
12564        }
12565    }
12566    #[allow(irrefutable_let_patterns)]
12567    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
12568        if let StreamProcessorEvent::OnOutputEndOfStream {
12569            stream_lifetime_ordinal,
12570            error_detected_before,
12571        } = self
12572        {
12573            Some((stream_lifetime_ordinal, error_detected_before))
12574        } else {
12575            None
12576        }
12577    }
12578    #[allow(irrefutable_let_patterns)]
12579    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
12580        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
12581            Some((free_input_packet))
12582        } else {
12583            None
12584        }
12585    }
12586    #[allow(irrefutable_let_patterns)]
12587    pub fn into_on_output_timestamp_has_no_output(
12588        self,
12589    ) -> Option<StreamProcessorOnOutputTimestampHasNoOutputRequest> {
12590        if let StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload } = self {
12591            Some((payload))
12592        } else {
12593            None
12594        }
12595    }
12596
12597    /// Decodes a message buffer as a [`StreamProcessorEvent`].
12598    fn decode(
12599        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12600    ) -> Result<StreamProcessorEvent, fidl::Error> {
12601        let (bytes, _handles) = buf.split_mut();
12602        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12603        debug_assert_eq!(tx_header.tx_id, 0);
12604        match tx_header.ordinal {
12605            0x77ccf70bb061cf8e => {
12606                let mut out = fidl::new_empty!(
12607                    StreamProcessorOnStreamFailedRequest,
12608                    fdomain_client::fidl::FDomainResourceDialect
12609                );
12610                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12611                Ok((StreamProcessorEvent::OnStreamFailed {
12612                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
12613                    error: out.error,
12614                }))
12615            }
12616            0x211da9966a8ca0 => {
12617                let mut out = fidl::new_empty!(
12618                    StreamProcessorOnInputConstraintsRequest,
12619                    fdomain_client::fidl::FDomainResourceDialect
12620                );
12621                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12622                Ok((StreamProcessorEvent::OnInputConstraints {
12623                    input_constraints: out.input_constraints,
12624                }))
12625            }
12626            0x40d8234504c170f3 => {
12627                let mut out = fidl::new_empty!(
12628                    StreamProcessorOnOutputConstraintsRequest,
12629                    fdomain_client::fidl::FDomainResourceDialect
12630                );
12631                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12632                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
12633            }
12634            0x131b77ae120360bc => {
12635                let mut out = fidl::new_empty!(
12636                    StreamProcessorOnOutputFormatRequest,
12637                    fdomain_client::fidl::FDomainResourceDialect
12638                );
12639                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12640                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
12641            }
12642            0x5c2029be1090ce93 => {
12643                let mut out = fidl::new_empty!(
12644                    StreamProcessorOnOutputPacketRequest,
12645                    fdomain_client::fidl::FDomainResourceDialect
12646                );
12647                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12648                Ok((StreamProcessorEvent::OnOutputPacket {
12649                    output_packet: out.output_packet,
12650                    error_detected_before: out.error_detected_before,
12651                    error_detected_during: out.error_detected_during,
12652                }))
12653            }
12654            0x3bb65d237cfa50e6 => {
12655                let mut out = fidl::new_empty!(
12656                    StreamProcessorOnOutputEndOfStreamRequest,
12657                    fdomain_client::fidl::FDomainResourceDialect
12658                );
12659                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12660                Ok((StreamProcessorEvent::OnOutputEndOfStream {
12661                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
12662                    error_detected_before: out.error_detected_before,
12663                }))
12664            }
12665            0xeef799b28708bbd => {
12666                let mut out = fidl::new_empty!(
12667                    StreamProcessorOnFreeInputPacketRequest,
12668                    fdomain_client::fidl::FDomainResourceDialect
12669                );
12670                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12671                Ok((StreamProcessorEvent::OnFreeInputPacket {
12672                    free_input_packet: out.free_input_packet,
12673                }))
12674            }
12675            0x7436457799a25cd4 => {
12676                let mut out = fidl::new_empty!(
12677                    StreamProcessorOnOutputTimestampHasNoOutputRequest,
12678                    fdomain_client::fidl::FDomainResourceDialect
12679                );
12680                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
12681                Ok((StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload: out }))
12682            }
12683            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12684                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
12685            }
12686            _ => Err(fidl::Error::UnknownOrdinal {
12687                ordinal: tx_header.ordinal,
12688                protocol_name:
12689                    <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
12690            }),
12691        }
12692    }
12693}
12694
12695/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
12696pub struct StreamProcessorRequestStream {
12697    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12698    is_terminated: bool,
12699}
12700
12701impl std::marker::Unpin for StreamProcessorRequestStream {}
12702
12703impl futures::stream::FusedStream for StreamProcessorRequestStream {
12704    fn is_terminated(&self) -> bool {
12705        self.is_terminated
12706    }
12707}
12708
12709impl fdomain_client::fidl::RequestStream for StreamProcessorRequestStream {
12710    type Protocol = StreamProcessorMarker;
12711    type ControlHandle = StreamProcessorControlHandle;
12712
12713    fn from_channel(channel: fdomain_client::Channel) -> Self {
12714        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12715    }
12716
12717    fn control_handle(&self) -> Self::ControlHandle {
12718        StreamProcessorControlHandle { inner: self.inner.clone() }
12719    }
12720
12721    fn into_inner(
12722        self,
12723    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
12724    {
12725        (self.inner, self.is_terminated)
12726    }
12727
12728    fn from_inner(
12729        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
12730        is_terminated: bool,
12731    ) -> Self {
12732        Self { inner, is_terminated }
12733    }
12734}
12735
12736impl futures::Stream for StreamProcessorRequestStream {
12737    type Item = Result<StreamProcessorRequest, fidl::Error>;
12738
12739    fn poll_next(
12740        mut self: std::pin::Pin<&mut Self>,
12741        cx: &mut std::task::Context<'_>,
12742    ) -> std::task::Poll<Option<Self::Item>> {
12743        let this = &mut *self;
12744        if this.inner.check_shutdown(cx) {
12745            this.is_terminated = true;
12746            return std::task::Poll::Ready(None);
12747        }
12748        if this.is_terminated {
12749            panic!("polled StreamProcessorRequestStream after completion");
12750        }
12751        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
12752            |bytes, handles| {
12753                match this.inner.channel().read_etc(cx, bytes, handles) {
12754                    std::task::Poll::Ready(Ok(())) => {}
12755                    std::task::Poll::Pending => return std::task::Poll::Pending,
12756                    std::task::Poll::Ready(Err(None)) => {
12757                        this.is_terminated = true;
12758                        return std::task::Poll::Ready(None);
12759                    }
12760                    std::task::Poll::Ready(Err(Some(e))) => {
12761                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12762                            e.into(),
12763                        ))));
12764                    }
12765                }
12766
12767                // A message has been received from the channel
12768                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12769
12770                std::task::Poll::Ready(Some(match header.ordinal {
12771                0x3940929617dbf02b => {
12772                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12773                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12774                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12775                    let control_handle = StreamProcessorControlHandle {
12776                        inner: this.inner.clone(),
12777                    };
12778                    Ok(StreamProcessorRequest::EnableOnStreamFailed {
12779                        control_handle,
12780                    })
12781                }
12782                0xb02e0663a40e4c4 => {
12783                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12784                    let mut req = fidl::new_empty!(StreamProcessorSetInputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
12785                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
12786                    let control_handle = StreamProcessorControlHandle {
12787                        inner: this.inner.clone(),
12788                    };
12789                    Ok(StreamProcessorRequest::SetInputBufferPartialSettings {input_settings: req.input_settings,
12790
12791                        control_handle,
12792                    })
12793                }
12794                0x118bb8c819a7bbbb => {
12795                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12796                    let mut req = fidl::new_empty!(StreamProcessorSetOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
12797                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
12798                    let control_handle = StreamProcessorControlHandle {
12799                        inner: this.inner.clone(),
12800                    };
12801                    Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {output_settings: req.output_settings,
12802
12803                        control_handle,
12804                    })
12805                }
12806                0x50529e5c680ae3ab => {
12807                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12808                    let mut req = fidl::new_empty!(StreamProcessorCompleteOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect);
12809                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
12810                    let control_handle = StreamProcessorControlHandle {
12811                        inner: this.inner.clone(),
12812                    };
12813                    Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
12814
12815                        control_handle,
12816                    })
12817                }
12818                0x2b62c3e26d0667e6 => {
12819                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12820                    let mut req = fidl::new_empty!(StreamProcessorFlushEndOfStreamAndCloseStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
12821                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
12822                    let control_handle = StreamProcessorControlHandle {
12823                        inner: this.inner.clone(),
12824                    };
12825                    Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12826
12827                        control_handle,
12828                    })
12829                }
12830                0x1d8a67522170ca07 => {
12831                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12832                    let mut req = fidl::new_empty!(StreamProcessorCloseCurrentStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
12833                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
12834                    let control_handle = StreamProcessorControlHandle {
12835                        inner: this.inner.clone(),
12836                    };
12837                    Ok(StreamProcessorRequest::CloseCurrentStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12838release_input_buffers: req.release_input_buffers,
12839release_output_buffers: req.release_output_buffers,
12840
12841                        control_handle,
12842                    })
12843                }
12844                0x4b3e44300b0ec6aa => {
12845                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12846                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12847                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12848                    let control_handle = StreamProcessorControlHandle {
12849                        inner: this.inner.clone(),
12850                    };
12851                    Ok(StreamProcessorRequest::Sync {
12852                        responder: StreamProcessorSyncResponder {
12853                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12854                            tx_id: header.tx_id,
12855                        },
12856                    })
12857                }
12858                0x32763632b94e0bd5 => {
12859                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12860                    let mut req = fidl::new_empty!(StreamProcessorRecycleOutputPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
12861                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12862                    let control_handle = StreamProcessorControlHandle {
12863                        inner: this.inner.clone(),
12864                    };
12865                    Ok(StreamProcessorRequest::RecycleOutputPacket {available_output_packet: req.available_output_packet,
12866
12867                        control_handle,
12868                    })
12869                }
12870                0x170dc0979d52231 => {
12871                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12872                    let mut req = fidl::new_empty!(StreamProcessorQueueInputFormatDetailsRequest, fdomain_client::fidl::FDomainResourceDialect);
12873                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
12874                    let control_handle = StreamProcessorControlHandle {
12875                        inner: this.inner.clone(),
12876                    };
12877                    Ok(StreamProcessorRequest::QueueInputFormatDetails {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12878format_details: req.format_details,
12879
12880                        control_handle,
12881                    })
12882                }
12883                0x47173d2652d9df3b => {
12884                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12885                    let mut req = fidl::new_empty!(StreamProcessorQueueInputPacketRequest, fdomain_client::fidl::FDomainResourceDialect);
12886                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
12887                    let control_handle = StreamProcessorControlHandle {
12888                        inner: this.inner.clone(),
12889                    };
12890                    Ok(StreamProcessorRequest::QueueInputPacket {packet: req.packet,
12891
12892                        control_handle,
12893                    })
12894                }
12895                0x2051b6ad00f20b37 => {
12896                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12897                    let mut req = fidl::new_empty!(StreamProcessorQueueInputEndOfStreamRequest, fdomain_client::fidl::FDomainResourceDialect);
12898                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
12899                    let control_handle = StreamProcessorControlHandle {
12900                        inner: this.inner.clone(),
12901                    };
12902                    Ok(StreamProcessorRequest::QueueInputEndOfStream {stream_lifetime_ordinal: req.stream_lifetime_ordinal,
12903
12904                        control_handle,
12905                    })
12906                }
12907                0x122be3b0096183cb => {
12908                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12909                    let mut req = fidl::new_empty!(StreamProcessorParticipateInBufferAllocationRequest, fdomain_client::fidl::FDomainResourceDialect);
12910                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorParticipateInBufferAllocationRequest>(&header, _body_bytes, handles, &mut req)?;
12911                    let control_handle = StreamProcessorControlHandle {
12912                        inner: this.inner.clone(),
12913                    };
12914                    Ok(StreamProcessorRequest::ParticipateInBufferAllocation {payload: req,
12915                        control_handle,
12916                    })
12917                }
12918                0x6eca773e923e0ada => {
12919                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12920                    let mut req = fidl::new_empty!(StreamProcessorAddBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
12921                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorAddBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12922                    let control_handle = StreamProcessorControlHandle {
12923                        inner: this.inner.clone(),
12924                    };
12925                    Ok(StreamProcessorRequest::AddBuffer {payload: req,
12926                        control_handle,
12927                    })
12928                }
12929                0x40b967ffa6b2da43 => {
12930                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
12931                    let mut req = fidl::new_empty!(StreamProcessorRemoveBufferRequest, fdomain_client::fidl::FDomainResourceDialect);
12932                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamProcessorRemoveBufferRequest>(&header, _body_bytes, handles, &mut req)?;
12933                    let control_handle = StreamProcessorControlHandle {
12934                        inner: this.inner.clone(),
12935                    };
12936                    Ok(StreamProcessorRequest::RemoveBuffer {payload: req,
12937                        responder: StreamProcessorRemoveBufferResponder {
12938                            control_handle: std::mem::ManuallyDrop::new(control_handle),
12939                            tx_id: header.tx_id,
12940                        },
12941                    })
12942                }
12943                0x3aedefeedf3898b0 => {
12944                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12945                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12946                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12947                    let control_handle = StreamProcessorControlHandle {
12948                        inner: this.inner.clone(),
12949                    };
12950                    Ok(StreamProcessorRequest::EnableOldOutputBuffers {
12951                        control_handle,
12952                    })
12953                }
12954                0x244e9f43b29709e7 => {
12955                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12956                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12957                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12958                    let control_handle = StreamProcessorControlHandle {
12959                        inner: this.inner.clone(),
12960                    };
12961                    Ok(StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
12962                        control_handle,
12963                    })
12964                }
12965                0x3994b040f91dc1e9 => {
12966                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12967                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
12968                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
12969                    let control_handle = StreamProcessorControlHandle {
12970                        inner: this.inner.clone(),
12971                    };
12972                    Ok(StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize {
12973                        control_handle,
12974                    })
12975                }
12976                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12977                    Ok(StreamProcessorRequest::_UnknownMethod {
12978                        ordinal: header.ordinal,
12979                        control_handle: StreamProcessorControlHandle { inner: this.inner.clone() },
12980                        method_type: fidl::MethodType::OneWay,
12981                    })
12982                }
12983                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
12984                    this.inner.send_framework_err(
12985                        fidl::encoding::FrameworkErr::UnknownMethod,
12986                        header.tx_id,
12987                        header.ordinal,
12988                        header.dynamic_flags(),
12989                        (bytes, handles),
12990                    )?;
12991                    Ok(StreamProcessorRequest::_UnknownMethod {
12992                        ordinal: header.ordinal,
12993                        control_handle: StreamProcessorControlHandle { inner: this.inner.clone() },
12994                        method_type: fidl::MethodType::TwoWay,
12995                    })
12996                }
12997                _ => Err(fidl::Error::UnknownOrdinal {
12998                    ordinal: header.ordinal,
12999                    protocol_name: <StreamProcessorMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
13000                }),
13001            }))
13002            },
13003        )
13004    }
13005}
13006
13007/// Overview of operation:
13008///
13009/// 1. Create
13010///   * create via CodecFactory - see CodecFactory
13011///   * create via LicenseSession - see LicenseSession
13012/// 2. Get input constraints
13013///   * OnInputConstraints() - sent unsolicited by stream processor shortly
13014///     after stream processor creation.
13015/// 3. Provide input buffers ()
13016///   * SetInputBufferPartialSettings()
13017///   * or AddBuffer, if StreamProcessor reported support for dynamic buffers
13018///     via CodecFactory - in this case, QueueInputFormatDetails and
13019///     QueueInputEndOfStream do not require a prior AddBuffer, but
13020///     QueueInputPacket still does.
13021/// 4. Deliver input data
13022///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
13023///     possibly working through all input packets repeatedly before...
13024/// 5. Get output constraints and format
13025///   * OnOutputConstraints()
13026///   * This is not sent until after at least one QueueInput* message is sent by
13027///     the client, even if the underlying processor behind the StreamProcessor
13028///     doesn't fundamentally need any input data to determine its output
13029///     constraints.  This server behavior prevents clients taking an incorrect
13030///     dependency on the output constraints showing up before input is
13031///     delivered.
13032///   * A client must tolerate this arriving as late as after substantial input
13033///     data has been delivered, including lots of input packet recycling via
13034///     OnFreeInputPacket().
13035///   * This message can arrive more than once before the first output data.
13036/// 6. Provide output buffers
13037///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
13038/// 7. Data flows, with optional EndOfStream
13039///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
13040///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
13041///
13042/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
13043/// very few capabilities) just in case the decoding SW has a vulnerability
13044/// which could be used to take over the StreamProcessor server.  Clients of the
13045/// stream processor interface using decoders and processing streams of separate
13046/// security contexts, to a greater extent than some other interfaces, need to
13047/// protect themselves against invalid server behavior, such as double-free of a
13048/// packet_index and any other invalid server behavior.  Having fed in
13049/// compressed data of one security context, don't place too much trust in a
13050/// single StreamProcessor instance to not mix data among any buffers that
13051/// StreamProcessor server has ever been told about.  Instead, create separate
13052/// StreamProcessor instances for use by security-separate client-side contexts.
13053/// While the picture for HW-based decoders looks somewhat different and is out
13054/// of scope of this paragraph, the client should always use separate
13055/// StreamProcessor instances for security-separate client-side contexts.
13056///
13057/// Descriptions of actions taken by methods of this protocol and the states of
13058/// things are given as if the methods are synchronously executed by the stream
13059/// processor server, but in reality, as is typical of FIDL interfaces, the
13060/// message processing is async.  The states described are to be read as the
13061/// state from the client's point of view unless otherwise stated.  Events
13062/// coming back from the server are of course delivered async, and a client that
13063/// processes more than one stream per StreamProcessor instance needs to care
13064/// whether a given event is from the current stream vs. some older
13065/// soon-to-be-gone stream.
13066///
13067/// The Sync() method's main purpose is to enable the client to robustly prevent
13068/// having both old and new buffers allocated in the system at the same time,
13069/// since media buffers can be significantly large, depending. The Sync() method
13070/// achieves this by only delivering it's response when all previous calls to
13071/// the StreamProcessor protocol have actually taken effect in the
13072/// StreamControl ordering domain. Sync() can also be used to wait for the
13073/// stream processor server to catch up if there's a possibility that a client
13074/// might otherwise get too far ahead of the StreamProcessor server, by for
13075/// example requesting creation of a large number of streams in a row.  It can
13076/// also be used during debugging to ensure that a stream processor server
13077/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
13078/// for correctness - only potentially required to de-overlap resource usage.
13079///
13080/// It's possible to re-use a StreamProcessor instance for another stream, and
13081/// doing so can sometimes skip over re-allocation of buffers. This can be a
13082/// useful thing to do for cases like seeking to a new location - at the
13083/// StreamProcessor interface that can look like switching to a new stream.
13084#[derive(Debug)]
13085pub enum StreamProcessorRequest {
13086    /// Permit the server to use OnStreamFailed() instead of the server just
13087    /// closing the whole StreamProcessor channel on stream failure.
13088    ///
13089    /// If the server hasn't seen this message by the time a stream fails, the
13090    /// server will close the StreamProcessor channel instead of sending
13091    /// OnStreamFailed().
13092    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
13093    /// When the client is not using dynamic buffers, a single
13094    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
13095    /// client-specified input settings and a BufferCollectionToken which the
13096    /// StreamProcessor will use to convey constraints to sysmem.  Both the
13097    /// client and the StreamProcessor will be informed of the allocated buffers
13098    /// directly by sysmem via their BufferCollection channel (not via the
13099    /// StreamProcessor channel).
13100    ///
13101    /// The client must not QueueInput...() until after sysmem informs the
13102    /// client that buffer allocation has completed and was successful.
13103    ///
13104    /// The server should be prepared to see QueueInput...() before the server
13105    /// has necessarily heard from sysmem that the buffers are allocated - the
13106    /// server must tolerate either ordering, as the QueueInput...() and
13107    /// notification of sysmem allocation completion arrive on different
13108    /// channels, so the client having heard that allocation is complete doesn't
13109    /// mean the server knows that allocation is complete yet.  However, the
13110    /// server can expect that allocation is in fact complete and can expect to
13111    /// get the allocation information from sysmem immediately upon requesting
13112    /// the information from sysmem.
13113    ///
13114    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
13115    /// while there are any buffers still active on the port. To successfully
13116    /// switch modes for a port, most clients will want to just start over with
13117    /// a new StreamProcessor instance. This can also be done reliably by first
13118    /// ensuring that every added buffer under the port up to "now" (including
13119    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
13120    /// request. Only then is it known ok to switch modes for that port under
13121    /// the same StreamProcessor. Most clients will just use one way or the
13122    /// other to add buffers and never need to switch to the other way,
13123    /// especially within the same StreamProcessor.
13124    SetInputBufferPartialSettings {
13125        input_settings: StreamBufferPartialSettings,
13126        control_handle: StreamProcessorControlHandle,
13127    },
13128    /// This is the replacement for SetOutputBufferSettings().
13129    ///
13130    /// When the client is using sysmem to allocate buffers, this message is
13131    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
13132    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
13133    /// with the client-specified output settings and a BufferCollectionToken
13134    /// which the StreamProcessor will use to convey constraints to sysmem. Both
13135    /// the client and the StreamProcessor will be informed of the allocated
13136    /// buffers directly by sysmem via their BufferCollection channel (not via
13137    /// the StreamProcessor channel).
13138    ///
13139    /// Configuring output buffers is _required_ after OnOutputConstraints() is
13140    /// received by the client with buffer_constraints_action_required true and
13141    /// stream_lifetime_ordinal equal to the client's current
13142    /// stream_lifetime_ordinal (even if there is an active stream), and is
13143    /// _permitted_ any time there is no current stream.
13144    ///
13145    /// Closing the current stream occurs on the StreamControl ordering domain,
13146    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
13147    /// subsequent Sync() completion must be received by the client before the
13148    /// client knows that there's no longer a current stream.
13149    ///
13150    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
13151    /// while there are any buffers still active on the port. To successfully
13152    /// switch modes for a port, most clients will want to just start over with
13153    /// a new StreamProcessor instance. This can also be done reliably by first
13154    /// ensuring that every added buffer under the port up to "now" (including
13155    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
13156    /// request. Only then is it known ok to switch modes for that port under
13157    /// the same StreamProcessor. Most clients will just use one way or the
13158    /// other to add buffers and never need to switch to the other way,
13159    /// especially not within the same StreamProcessor instance.
13160    ///
13161    /// See also CompleteOutputBufferPartialSettings().
13162    SetOutputBufferPartialSettings {
13163        output_settings: StreamBufferPartialSettings,
13164        control_handle: StreamProcessorControlHandle,
13165    },
13166    /// After SetOutputBufferPartialSettings(), the server won't send
13167    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
13168    /// OnOutputEndOfStream() until after the client sends
13169    /// CompleteOutputBufferPartialSettings().
13170    ///
13171    /// This message isn't permitted after AddBuffer. When using dynamic buffers
13172    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
13173    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
13174    /// the case of OnOutputPacket there must also be at least one output buffer
13175    /// that's been added but not yet fully removed (RemoveBuffer not yet
13176    /// complete).
13177    ///
13178    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
13179    /// immediately after SetOutputBufferPartialSettings() - in that case the
13180    /// client needs to be prepared to receive output without knowing the buffer
13181    /// count or packet count yet - such clients may internally delay processing
13182    /// the received output until the client has heard from sysmem (which is
13183    /// when the client will learn the buffer count and packet count).
13184    ///
13185    /// Other clients may first wait for sysmem to allocate, prepare to receive
13186    /// output, and then send CompleteOutputBufferPartialSettings().
13187    CompleteOutputBufferPartialSettings {
13188        buffer_lifetime_ordinal: u64,
13189        control_handle: StreamProcessorControlHandle,
13190    },
13191    /// This message is optional; a client isn't required to send this ever.
13192    ///
13193    /// Terminology note: In the name of this message, "flush" means flush
13194    /// through, sometimes called "drain". This messge does not discard. To
13195    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
13196    /// without first waiting for OnOutputEndOfStream of the old stream and
13197    /// without sending FlushEndOfStreamAndCloseStream.
13198    ///
13199    /// There is currently no way to cancel the flush effect of this message
13200    /// short of the client closing the StreamProcessor channel.
13201    ///
13202    /// This message is only valid after QueueInputEndOfStream() for this
13203    /// stream. The stream_lifetime_ordinal input parameter must match the
13204    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
13205    /// will close the channel.
13206    ///
13207    /// A client can use this message to flush through (drain, not discard) the
13208    /// last input data of a stream so that the stream processor server
13209    /// generates corresponding output data for all the input data before the
13210    /// server moves on to the next stream, without forcing the client to wait
13211    /// for OnOutputEndOfStream() before queueing data of another stream.
13212    ///
13213    /// The difference between QueueInputEndOfStream() and
13214    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
13215    /// from the client that there will not be any more input data for the
13216    /// stream (and this info is needed by some stream processors for the stream
13217    /// processor to ever emit the very last output data).  The
13218    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
13219    /// later completely discarding the rest of the current stream by closing
13220    /// the current stream (with or without a stream switch).  In contrast,
13221    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
13222    /// the previously-queued input data be processed including the logical
13223    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
13224    /// before moving on to any newer stream - this essentially changes the
13225    /// close-stream handling from discard to flush-through for this stream
13226    /// only.
13227    ///
13228    /// A client using this message can start providing input data for a new
13229    /// stream without that causing discard of old stream data.  That's the
13230    /// purpose of this message - to allow a client to flush through (not
13231    /// discard) the old stream's last data (instead of the default when closing
13232    /// or switching streams which is discard).
13233    ///
13234    /// Because the old stream is not done processing yet and the old stream's
13235    /// data is not being discarded, the client must be prepared to continue to
13236    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
13237    /// is done. The client will know the stream_lifetime_ordinal is done when
13238    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
13239    /// closes.
13240    FlushEndOfStreamAndCloseStream {
13241        stream_lifetime_ordinal: u64,
13242        control_handle: StreamProcessorControlHandle,
13243    },
13244    /// This "closes" the current stream, leaving no current stream.  In
13245    /// addition, this message can optionally release (and unregister) input
13246    /// buffers or output buffers.
13247    ///
13248    /// If there has never been any active stream, the stream_lifetime_ordinal
13249    /// must be zero or the server will close the channel.  If there has been an
13250    /// active stream, the stream_lifetime_ordinal must be the most recent
13251    /// active stream whether that stream is still active or not.  Else the
13252    /// server will close the channel.
13253    ///
13254    /// Multiple of this message without any new active stream in between is not
13255    /// to be considered an error, which allows a client to use this message to
13256    /// close the current stream to stop wasting processing power on a stream
13257    /// the user no longer cares about, then later decide that buffers should be
13258    /// released and send this message again with release_input_buffers and/or
13259    /// release_output_buffers true to get the buffers released, if the client
13260    /// is interested in trying to avoid overlap in resource usage between old
13261    /// buffers and new buffers (not all clients are).
13262    ///
13263    /// See also Sync().
13264    CloseCurrentStream {
13265        stream_lifetime_ordinal: u64,
13266        release_input_buffers: bool,
13267        release_output_buffers: bool,
13268        control_handle: StreamProcessorControlHandle,
13269    },
13270    /// On completion, all previous StreamProcessor calls have done what they're
13271    /// going to do server-side, _except_ for processing of data queued using
13272    /// QueueInputPacket().
13273    ///
13274    /// The main purpose of this call is to enable the client to wait until
13275    /// CloseCurrentStream() with release_input_buffers and/or
13276    /// release_output_buffers set to true to take effect, before the client
13277    /// allocates new buffers and re-sets-up input and/or output buffers.  This
13278    /// de-overlapping of resource usage can be worthwhile for media buffers
13279    /// which can consume resource types whose overall pools aren't necessarily
13280    /// vast in comparison to resources consumed.  Especially if a client is
13281    /// reconfiguring buffers multiple times.
13282    ///
13283    /// Note that Sync() prior to allocating new media buffers is not alone
13284    /// sufficient to achieve non-overlap of media buffer resource usage system
13285    /// wide, but it can be a useful part of achieving that.
13286    ///
13287    /// The Sync() transits the Output ordering domain and the StreamControl
13288    /// ordering domain, but not the InputData ordering domain.
13289    ///
13290    /// This request can be used to avoid hitting kMaxInFlightStreams which is
13291    /// presently 10.  A client that stays <= 8 in-flight streams will
13292    /// comfortably stay under the limit of 10.  While the protocol permits
13293    /// repeated SetInputBufferSettings() and the like, a client that spams the
13294    /// channel can expect that the channel will just close if the server or the
13295    /// channel itself gets too far behind.
13296    Sync { responder: StreamProcessorSyncResponder },
13297    /// After the client is done with an output packet, the client needs to tell
13298    /// the stream processor that the output packet can be re-used for more
13299    /// output, using this message.
13300    ///
13301    /// It's not permitted to recycle an output packet that's already free with
13302    /// the stream processor server.
13303    ///
13304    /// If a client is using EnableOldOutputBuffers, the client must recycle all
13305    /// packets when done with them, even those of old buffer_lifetime_ordinal.
13306    /// This is also permitted behavior for all clients.
13307    ///
13308    /// If a client is not using EnableOldOutputBuffers, the client may
13309    /// optionally omit this message for packets with an old
13310    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
13311    /// or implicit output buffer de-configuration don't need to be recycled if
13312    /// the client isn't using and won't be using EnableOldOutputBuffers.
13313    RecycleOutputPacket {
13314        available_output_packet: PacketHeader,
13315        control_handle: StreamProcessorControlHandle,
13316    },
13317    /// If the input format details are still the same as specified during
13318    /// StreamProcessor creation, this message is unnecessary and does not need
13319    /// to be sent.
13320    ///
13321    /// If the stream doesn't exist yet, this message creates the stream.
13322    ///
13323    /// The server won't send OnOutputConstraints() until after the client has
13324    /// sent at least one QueueInput* message.
13325    ///
13326    /// All servers must permit QueueInputFormatDetails() at the start of a
13327    /// stream without failing, as long as the new format is supported by the
13328    /// StreamProcessor instance. Technically this allows for a server to only
13329    /// support the exact input format set during StreamProcessor creation, and
13330    /// that is by design. A client that tries to switch formats and gets a
13331    /// StreamProcessor channel failure should try again one more time with a
13332    /// fresh StreamProcessor instance created with CodecFactory using the new
13333    /// input format during creation, before giving up.
13334    ///
13335    /// These format details override the format details specified during stream
13336    /// processor creation for this stream only. The next stream will default
13337    /// back to the format details set during stream processor creation.
13338    ///
13339    /// This message is permitted at the start of the first stream (just like at
13340    /// the start of any stream). The format specified need not match what was
13341    /// specified during stream processor creation, but if it doesn't match, the
13342    /// StreamProcessor channel might close as described above.
13343    QueueInputFormatDetails {
13344        stream_lifetime_ordinal: u64,
13345        format_details: FormatDetails,
13346        control_handle: StreamProcessorControlHandle,
13347    },
13348    /// This message queues input data to the stream processor for processing.
13349    ///
13350    /// If the stream doesn't exist yet, this message creates the new stream.
13351    ///
13352    /// The server won't send OnOutputConstraints() until after the client has
13353    /// sent at least one QueueInput* message.
13354    ///
13355    /// When using dynamic buffers the server can send OnOutputConstraints,
13356    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
13357    /// the first QueueInputPacket. In the case of OnOutputPacket there must
13358    /// also be at least one output buffer that's been added but not yet fully
13359    /// removed (RemoveBuffer not yet complete).
13360    ///
13361    /// The client must continue to deliver input data via this message even if
13362    /// the stream processor has not yet generated the first
13363    /// OnOutputConstraints, and even if the StreamProcessor is generating
13364    /// OnFreeInputPacket for previously-queued input packets.  The input data
13365    /// must continue as long as there are free packets to be assured that the
13366    /// server will ever generate the first OnOutputConstraints.
13367    ///
13368    /// The server will close the channel if this packet refers to an old
13369    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
13370    /// different dimensions to a video encoder can either (a) allocate buffers
13371    /// large enough to contain the range of needed image sizes and use those to
13372    /// deliver all the input images, (b) keep their own sets of buffers used
13373    /// for different image dimensions and re-add old buffers with AddBuffer,
13374    /// moving to a new buffer_lifetime_ordinal each time image dimensions
13375    /// change, or (c) allocate new buffers each time image dimensions change.
13376    /// The (a) option is preferred, for clients that have the flexibiilty to
13377    /// store images of varying dimensions in a single set of buffers. Clients
13378    /// that require each buffer to have a single image size can use option (b)
13379    /// or (c).
13380    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
13381    /// Inform the server that all QueueInputPacket() messages for this stream
13382    /// have been sent.
13383    ///
13384    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
13385    /// or StreamProcessor channel closing), there will later be a corresponding
13386    /// OnOutputEndOfStream().
13387    ///
13388    /// The corresponding OnOutputEndOfStream() message will be generated only
13389    /// if the server finishes processing the stream before the server sees the
13390    /// client close the stream (such as by starting a new stream). A way to
13391    /// force the server to finish the stream before closing is to use
13392    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
13393    /// any new stream. Another way to force the server to finish the stream
13394    /// before closing is to wait for the OnOutputEndOfStream() before taking
13395    /// any action that closes the stream.
13396    ///
13397    /// In addition to serving as an "EndOfStream" marker to make it obvious
13398    /// client-side when all input data has been processed, if a client never
13399    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
13400    /// result in all input data getting processed through to the output. Some
13401    /// stream processors have some internally-delayed data which only gets
13402    /// drained (pushed through) by additional input data _or_ by this
13403    /// EndOfStream marker. In that sense, this message can be viewed as a drain
13404    /// at InputData domain level, but the drain only takes effect if the stream
13405    /// processor even gets that far before the stream is just closed at
13406    /// StreamControl domain level. This message is not alone sufficient to act
13407    /// as an overall drain at StreamControl level. For that, send this message
13408    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
13409    /// becomes possible to queue input data for a new stream without causing
13410    /// discard of this older stream's data). Alternately, the client can wait
13411    /// for the OnOutputEndOfStream before closing the current stream.
13412    ///
13413    /// After a client sends QueueInputEndOfStream for a stream, if the client
13414    /// then sends for the same stream any of QueueInputPacket,
13415    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
13416    /// the StreamProcessor channel.
13417    QueueInputEndOfStream {
13418        stream_lifetime_ordinal: u64,
13419        control_handle: StreamProcessorControlHandle,
13420    },
13421    /// This message results in channel closure unless supports_dynamic_buffers
13422    /// is set to true.
13423    ///
13424    /// This participates in allocation of buffers to be used with AddBuffer
13425    /// later. The client can get VMO handles for these buffers by also
13426    /// participating in the sysmem allocation, using the client's own related
13427    /// sysmem token (associated with the same logical buffer collection). It's
13428    /// up to the client to separately set any constraints needed by the client
13429    /// using the client's own related sysmem token, if any.
13430    ///
13431    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
13432    /// SetOutputBufferPartialSettings. Servers must support those messages.
13433    ///
13434    /// In handling this message, if `allow_single_buffer` is set to true, the
13435    /// server must not constrain the number of buffers allocated. The server
13436    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
13437    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
13438    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
13439    /// same value if the intent is to allocate exactly that many buffers. If
13440    /// `allow_single_buffer` is un-set or set to false, the server will
13441    /// indicate needed buffer counts to sysmem.
13442    ///
13443    /// The server's BufferCollection channel (created from the passed-in
13444    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
13445    /// particular, the server shouldn't expect the BufferCollection channel to
13446    /// remain connected to sysmem beyond the server sending SetConstraints. For
13447    /// this reason, the server may not be able to call
13448    /// WaitForAllBuffersAllocated or similar, so the server should just send
13449    /// SetConstraints, Close, then close the server's BufferCollection
13450    /// client_end. This means the server in general shouldn't attempt to get
13451    /// VMO handles for these buffers while processing this message.
13452    ///
13453    /// The server should not assume that these buffers will necessarily ever be
13454    /// added with AddBuffer to this StreamProcessor instance or any other
13455    /// StreamProcessor instance (owned by the server or not). These buffers may
13456    /// instead be dropped, or as a less-common example, possibly added to a
13457    /// different codec served by a different server implementation which also
13458    /// participated in the same sysmem buffer collection allocation.
13459    ///
13460    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
13461    /// StreamProcessor instance of the same codec (same per CodecFactory) is
13462    /// likely to work, but using the same StreamProcessor instance is
13463    /// recommended when feasible.
13464    ///
13465    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
13466    /// a different StreamProcessor instance of the same codec (same per
13467    /// CodecFactory) can't (within reason) be made work in general, especially
13468    /// for video decoders. Therefore, for output buffers, the same
13469    /// StreamProcessor instance must be used for this message and AddBuffer.
13470    /// While a client may currently be able to get away with using different
13471    /// StreamProcessor instances for this message and AddBuffer for output
13472    /// buffers for some codecs, this may break at any time without it being
13473    /// considered a server-side bug.
13474    ///
13475    /// The allocated buffers can later be added using AddBuffer (piecemeal),
13476    /// and can be removed (piecemeal) using RemoveBuffer.
13477    ///
13478    /// Multiple different ParticipateInBufferAllocation messages can have their
13479    /// buffers later added to the same StreamProcessor instance using the same
13480    /// buffer_lifetime_ordinal. This can be useful if the client wants to
13481    /// allocate buffers incrementally, or dynamically adjust the number of
13482    /// buffers, potentially while actively processing. See also the
13483    /// `buffer_lifetime_ordinal` field of this message.
13484    ///
13485    /// Server implementations may use sysmem to help verify buffer
13486    /// compatibility later when buffers are added with AddBuffer.
13487    ParticipateInBufferAllocation {
13488        payload: StreamProcessorParticipateInBufferAllocationRequest,
13489        control_handle: StreamProcessorControlHandle,
13490    },
13491    /// Add buffers previously created with the help of
13492    /// ParticipateInBufferAllocation.
13493    ///
13494    /// For input buffers, the client can send QueueInputFormatDetails or
13495    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
13496    /// buffer must be added before a valid QueueInputPacket can be sent. Most
13497    /// clients will want to continue quickly adding buffers up to at least
13498    /// buffer_count_for_server_current to avoid the codec potentially stalling,
13499    /// and typically a low number of buffers beyond that to keep the pipeline
13500    /// running smoothly. Input buffers beyond the first input buffer can be
13501    /// added after the first QueueInputPacket.
13502    ///
13503    /// Even if buffer_constraints_version_ordinal is current, the server must
13504    /// not close the channel if the buffer isn't consistent with the current
13505    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
13506    /// consistent StreamProcessor constraints). Instead, the server must send a
13507    /// new OnOutputConstraints. This simplifies some edge cases for some
13508    /// clients, particularly when a client can't reliably detect whether a
13509    /// newly-obtained buffer was actually allocated after
13510    /// buffer_constraints_version_ordinal changed, or may have been cached from
13511    /// before.
13512    ///
13513    /// The client can add additional buffers to the same port and
13514    /// buffer_lifetime_ordinal at any time using this message. If the
13515    /// buffer_lifetime_ordinal is no longer the most recent, the message will
13516    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
13517    /// message re. the same buffer will complete immediately.
13518    ///
13519    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
13520    /// by the sum of buffers added by all AddBuffer calls with the same
13521    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
13522    /// required to close the channel in this case if performance degradation or
13523    /// un-tested behavior would result from adding too many buffers.
13524    ///
13525    /// Switching to a new buffer_lifetime_ordinal starts the process of
13526    /// removing buffers associated with an old buffer_lifetime_ordinal.
13527    /// However, until the remove is complete, those buffers can still be used
13528    /// by the codec as normal. See also RemoveBuffer, which can be used to
13529    /// detect when removal is complete, regardless of whether the RemoveBuffer
13530    /// started the removal (including when not using dynamic buffers).
13531    ///
13532    /// The buffer stays added until removal later completes. The buffer remains
13533    /// added across potentially multiple buffer re-uses. Removal can be
13534    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
13535    /// The codec server can unilaterally initiate buffer removal; if the server
13536    /// does this, it must send a new buffer_constraints_version_ordinal with
13537    /// action_required true. Some other client-initiated messages can also
13538    /// begin buffer removal, such as CloseCurrentStream with
13539    /// release_input_buffers and/or release_output_buffers. The buffers are
13540    /// also automatically removed and released if the client closes the
13541    /// StreamProcessor client_end or the server closes the StreamProcessor
13542    /// server_end.
13543    ///
13544    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
13545    /// SetOutputBufferPartialSettings is not allowed while there are any
13546    /// buffers still active on the port. To successfully switch modes for a
13547    /// port, most clients will want to just start over with a new
13548    /// StreamProcessor instance. This can also be done reliably by first
13549    /// ensuring that every added buffer under the port up to "now" (including
13550    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
13551    /// request. Only then is it known ok to switch modes for that port under
13552    /// the same StreamProcessor. Most clients will just use one way or the
13553    /// other to add buffers and never need to switch to the other way,
13554    /// especially within the same StreamProcessor.
13555    ///
13556    /// If a client might plausibly "spam" creation of many new
13557    /// buffer_lifetime_ordinal values without the buffers seeing any actual
13558    /// usage in between, the client should consider starting a Sync every few
13559    /// buffer_lifetime_ordinal(s) to fence cleanup of old
13560    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
13561    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
13562    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
13563    /// getting too far ahead of closing out old ones. The threshold of 16 is
13564    /// well below the enforcement threshold. Clients don't need to Sync if they
13565    /// won't be spamming new buffer_lifetime_ordinal values, or if added
13566    /// buffers will see at least some actual usage visible to the client before
13567    /// being replaced again.
13568    ///
13569    /// All buffers of the same port and buffer_lifetime_ordinal must share the
13570    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
13571    /// this in various ways. One way is to use ParticipateInBufferAllocation
13572    /// then AddBuffer for at least the first buffer, before
13573    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
13574    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
13575    /// and bump to the next odd buffer_lifetime_ordinal value for the
13576    /// AddBuffer.
13577    AddBuffer {
13578        payload: StreamProcessorAddBufferRequest,
13579        control_handle: StreamProcessorControlHandle,
13580    },
13581    /// When using dynamic buffers, this call removes a buffer as soon as the
13582    /// buffer can be removed without adversely impacting any ongoing processing
13583    /// or an in-flight output packet referring to the buffer.
13584    ///
13585    /// If a client wants to remove a buffer with an in-flight output packet
13586    /// referring to the buffer, the client must RecycleOutputPacket for that
13587    /// in-flight output packet before the RemoveBuffer will complete.
13588    ///
13589    /// When using SetInputBufferPartialSettings /
13590    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
13591    /// the buffer. This call will complete when the buffer is done removing due
13592    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
13593    ///
13594    /// Until RemoveBuffer completes, the codec is still allowed to send
13595    /// OnOutputPacket messages referencing the buffer, and the codec may still
13596    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
13597    /// codec guarantees that no subsequent output packet will reference the
13598    /// buffer, and that the server holds no VMO handles to the buffer.
13599    ///
13600    /// The client may need to recycle an output packet before the RemoveBuffer
13601    /// call can complete. Clients should take care to avoid blocking packet
13602    /// recycling while the RemoveBuffer request is in progress, since this
13603    /// would create a potential deadlock.
13604    ///
13605    /// The server closing any VMO handles to the buffer prior to completing
13606    /// this call is important for the client's ability to prevent memory usage
13607    /// spikes.
13608    ///
13609    /// If the client has "paused" processing by not providing any more input,
13610    /// the client will potentially need to send CloseCurrentStream before
13611    /// RemoveBuffer will complete. When using dynamic buffers, setting
13612    /// release_input_buffers or release_output_buffers to true is not
13613    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
13614    /// specific buffer. When not using dynamic buffers, the client will need to
13615    /// set release_input_buffers or release_output_buffers to true, since
13616    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
13617    /// buffers. A current "paused" stream needs to be stopped because frames
13618    /// can be held as reference frames, and codecs are never reqiured to copy
13619    /// their output data.
13620    ///
13621    /// For any video decoder output buffers being removed while there's an
13622    /// active stream (being fed input or not), it's typically best for the
13623    /// client to assume that removal of a video decoder output buffer may take
13624    /// a very long duration. This is because bitstreams, especially
13625    /// non-standard-compliant bitstreams, but in some cases potentially even
13626    /// standard-compliant bitstreams, can keep a video decoder output buffer in
13627    /// the set of active reference frames (aka DPB) indefinitely. The server is
13628    /// not required to notice that a stream is not conforming to a bitstream
13629    /// standard in this regard.
13630    ///
13631    /// In the case of h.264 decode, a standard-complient bitstream will limit
13632    /// the reorder delay to no longer than the max DPB occupancy. However, a
13633    /// server is not required to detect or reject non-compliant streams that
13634    /// potentially keep a frame in the DPB for longer.
13635    ///
13636    /// For HEVC, the situation is similar to h.264 (IIUC).
13637    ///
13638    /// In the case of VP9, there is nothing in the bitstream spec that limits
13639    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
13640    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
13641    /// required to detect or mitigate this.
13642    ///
13643    /// Until this call completes, the server may still be using the buffer. For
13644    /// output buffers, the server can still send OnOutputPacket message(s) that
13645    /// references this buffer, but only up until the RemoveBuffer completion
13646    /// message is sent by the server. The client must continue to
13647    /// RecycleOutputPacket for packets that reference the buffer, until
13648    /// RemoveBuffer completes.
13649    ///
13650    /// When using dynamic buffers, upon receiving this message, the server will
13651    /// stop selecting the buffer for any new usage (as in, for any usage that
13652    /// moves the buffer from "free" to "not free" within the server). This
13653    /// applies even if the server has no other buffers available for use (aka
13654    /// no other "free" buffers). Any existing usage of the buffer is not ended
13655    /// early by this call alone.
13656    ///
13657    /// When not using dynamic buffers, upon receiving this message, the server
13658    /// will just remember to complete this call shortly after the buffer has
13659    /// completed removal triggered by some other cause (removal is not
13660    /// triggered/caused by this call).
13661    ///
13662    /// For video decoders, when using dynamic buffers, typically the client
13663    /// should take care to avoid removing too many output buffers for continued
13664    /// decode to be possible. If this occurs, the decoder will wait until the
13665    /// client adds another output buffer with AddBuffer. This can be a deadlock
13666    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
13667    /// frame reordering, sending a single AddBuffer doesn't necessarily
13668    /// guarantee another OnOutputPacket, since additional output buffers can be
13669    /// needed before the server can send OnOutputPacket.
13670    ///
13671    /// The client must not call RemoveBuffer on the same buffer more than once,
13672    /// whether overlapping in time or not. The server should enforce this when
13673    /// not enforcing would require tracking additional concurrent requests. The
13674    /// server is not required to enforce this when enforcing would use more
13675    /// server memory.
13676    ///
13677    /// The server is allowed to complete this request quickly with success for
13678    /// buffer_lifetime_ordinal and buffer_index combinations that were never
13679    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
13680    /// hasn't been started by the client yet (no removing potential future
13681    /// buffers).
13682    ///
13683    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
13684    /// combination may be re-used after completion of RemoveBuffer, but only if
13685    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
13686    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
13687    ///
13688    /// Assuming a valid historical buffer is specified, successful completion
13689    /// of this call means the buffer has been fully released by the server and
13690    /// won't be referenced in any subsequent OnOutputPacket.
13691    RemoveBuffer {
13692        payload: StreamProcessorRemoveBufferRequest,
13693        responder: StreamProcessorRemoveBufferResponder,
13694    },
13695    /// This informs the StreamProcessor that the client is prepared to handle
13696    /// output packets that specify a buffer with buffer_lifetime_ordinal older
13697    /// than the most recent buffer_lifetime_ordinal.
13698    ///
13699    /// If the client doesn't send this message, the StreamProcessor will omit
13700    /// any such output, even if
13701    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
13702    /// decoders such as VP9 decoders, not sending this message can result in
13703    /// output that isn't bistream spec compliant, and the output can be
13704    /// visually different than intended by the bitstream.
13705    ///
13706    /// Such streams are only possible with some bitstream formats (such as
13707    /// VP9), and are rare, but can happen and can be valid per the bitstream
13708    /// spec. For example, this can be specified by a VP9 bitstream using
13709    /// show_existing_frame to output an old-dimensions buffer after having
13710    /// already output a new-dimensions buffer.
13711    ///
13712    /// Most clients that send this message will also want to use RemoveBuffer
13713    /// to know when it becomes safe to stop tracking an old buffer.
13714    ///
13715    /// Most of the time this makes no difference as most bitstreams don't
13716    /// actually emit old buffers, even if the bitstream spec would allow it.
13717    /// Old output buffers are especially rare for RTC streams which typically
13718    /// don't have any frame reordering in the first place.
13719    ///
13720    /// In most video streaming scenarios that use dimension switching as part
13721    /// of their bitrate control strategy (among those that I've observed), at
13722    /// the StreamProcessor layer the new dimensions are part of a new stream
13723    /// instead of being spliced together as a continuation of the old stream.
13724    /// That said, using a continuation of the old stream is also a completely
13725    /// valid way to implement dimension switching. When a stream switch occurs
13726    /// as part of dimension switching, the decoder state is not retained and
13727    /// there won't be any old buffer(s) emitted after new buffer(s), since the
13728    /// new stream doesn't know anything about old buffers filled by the old
13729    /// stream.
13730    ///
13731    /// Clients which haven't tested their ability to handle old output buffers
13732    /// should not send this message. Clients decoding bitstreams like VP9 for
13733    /// decoder compliance testing purposes should send this message (and use a
13734    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
13735    /// Clients which are required to support old output frames and/or fully
13736    /// comply with a relevant bitstream spec should/must send this message, and
13737    /// should test using a test stream that outputs packets referencing an old
13738    /// output buffer.
13739    ///
13740    /// Sending this message more than once closes the channel. If sent, this
13741    /// message must be sent prior to the client establishing the first output
13742    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
13743    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
13744    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
13745    /// client when this message was not sent by the client.
13746    ///
13747    /// This message is only permitted when
13748    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
13749    /// is true.
13750    EnableOldOutputBuffers { control_handle: StreamProcessorControlHandle },
13751    /// This informs the StreamProcessor that the client is prepared to handle
13752    /// output packets that specify the same buffer as another packet that's
13753    /// also concurrently in flight to the client (not yet recycled).
13754    ///
13755    /// Most bitstream formats don't do this. In formats that can do this such
13756    /// as VP9, most actual bitstreams don't do this.
13757    ///
13758    /// As an example, in VP9, a stream can cause the same output buffer to be
13759    /// used by another emitted output packet/frame by using show_existing_frame
13760    /// on the same VP9 reference/held frame slot more than once without
13761    /// decoding a new frame into that slot in between.
13762    ///
13763    /// Clients that need to achieve full bitstream spec compliance for such a
13764    /// bitstream format must send this message.
13765    ///
13766    /// If this message is not in effect, the server will omit any such output,
13767    /// which can result in output that is not compliant to the relevant
13768    /// bitstream spec, and which can be visually different than the stream
13769    /// intended.
13770    ///
13771    /// Sending this message more than once closes the channel. If sent, this
13772    /// message must be sent prior to the client establishing the first output
13773    /// buffer_lifetime_ordinal.
13774    ///
13775    /// This message is only permitted when
13776    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
13777    /// is true.
13778    EnableSameOutputBufferConcurrentlyInFlight { control_handle: StreamProcessorControlHandle },
13779    /// For video decoders, this forces the output buffers to be reallocated if
13780    /// the image size needs to change. This is wasteful as it forces extra
13781    /// buffer reallocations given typical video bitrate control strategies
13782    /// (applicable to both streaming and RTC) involving shifting the image
13783    /// dimensions up and down repeatedly as a logical video/stream plays,
13784    /// sometimes even if network conditions remain fairly stable. This extra
13785    /// buffer reallocation cost is incurred vs. baseline whether the dimension
13786    /// switching is achieved within a single StreamProcessor stream or by using
13787    /// a new StreamProcessor stream for new dimensions.
13788    ///
13789    /// A client should not send this message unless the client really must
13790    /// force the output buffers to be reallocated every time the output image
13791    /// size changes.
13792    ///
13793    /// Sending this message more than once closes the channel. If sent, this
13794    /// message must be sent prior to any SetInputBufferPartialSettings,
13795    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
13796    /// AddBuffer.
13797    ///
13798    /// This message is only permitted if this StreamProcessor is a video
13799    /// decoder.
13800    ///
13801    /// This message is only permitted when
13802    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
13803    /// is true.
13804    EnableForceOutputBuffersFixedImageSize { control_handle: StreamProcessorControlHandle },
13805    /// An interaction was received which does not match any known method.
13806    #[non_exhaustive]
13807    _UnknownMethod {
13808        /// Ordinal of the method that was called.
13809        ordinal: u64,
13810        control_handle: StreamProcessorControlHandle,
13811        method_type: fidl::MethodType,
13812    },
13813}
13814
13815impl StreamProcessorRequest {
13816    #[allow(irrefutable_let_patterns)]
13817    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
13818        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
13819            Some((control_handle))
13820        } else {
13821            None
13822        }
13823    }
13824
13825    #[allow(irrefutable_let_patterns)]
13826    pub fn into_set_input_buffer_partial_settings(
13827        self,
13828    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
13829        if let StreamProcessorRequest::SetInputBufferPartialSettings {
13830            input_settings,
13831            control_handle,
13832        } = self
13833        {
13834            Some((input_settings, control_handle))
13835        } else {
13836            None
13837        }
13838    }
13839
13840    #[allow(irrefutable_let_patterns)]
13841    pub fn into_set_output_buffer_partial_settings(
13842        self,
13843    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
13844        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
13845            output_settings,
13846            control_handle,
13847        } = self
13848        {
13849            Some((output_settings, control_handle))
13850        } else {
13851            None
13852        }
13853    }
13854
13855    #[allow(irrefutable_let_patterns)]
13856    pub fn into_complete_output_buffer_partial_settings(
13857        self,
13858    ) -> Option<(u64, StreamProcessorControlHandle)> {
13859        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
13860            buffer_lifetime_ordinal,
13861            control_handle,
13862        } = self
13863        {
13864            Some((buffer_lifetime_ordinal, control_handle))
13865        } else {
13866            None
13867        }
13868    }
13869
13870    #[allow(irrefutable_let_patterns)]
13871    pub fn into_flush_end_of_stream_and_close_stream(
13872        self,
13873    ) -> Option<(u64, StreamProcessorControlHandle)> {
13874        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
13875            stream_lifetime_ordinal,
13876            control_handle,
13877        } = self
13878        {
13879            Some((stream_lifetime_ordinal, control_handle))
13880        } else {
13881            None
13882        }
13883    }
13884
13885    #[allow(irrefutable_let_patterns)]
13886    pub fn into_close_current_stream(
13887        self,
13888    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
13889        if let StreamProcessorRequest::CloseCurrentStream {
13890            stream_lifetime_ordinal,
13891            release_input_buffers,
13892            release_output_buffers,
13893            control_handle,
13894        } = self
13895        {
13896            Some((
13897                stream_lifetime_ordinal,
13898                release_input_buffers,
13899                release_output_buffers,
13900                control_handle,
13901            ))
13902        } else {
13903            None
13904        }
13905    }
13906
13907    #[allow(irrefutable_let_patterns)]
13908    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
13909        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
13910    }
13911
13912    #[allow(irrefutable_let_patterns)]
13913    pub fn into_recycle_output_packet(
13914        self,
13915    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
13916        if let StreamProcessorRequest::RecycleOutputPacket {
13917            available_output_packet,
13918            control_handle,
13919        } = self
13920        {
13921            Some((available_output_packet, control_handle))
13922        } else {
13923            None
13924        }
13925    }
13926
13927    #[allow(irrefutable_let_patterns)]
13928    pub fn into_queue_input_format_details(
13929        self,
13930    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
13931        if let StreamProcessorRequest::QueueInputFormatDetails {
13932            stream_lifetime_ordinal,
13933            format_details,
13934            control_handle,
13935        } = self
13936        {
13937            Some((stream_lifetime_ordinal, format_details, control_handle))
13938        } else {
13939            None
13940        }
13941    }
13942
13943    #[allow(irrefutable_let_patterns)]
13944    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
13945        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
13946            Some((packet, control_handle))
13947        } else {
13948            None
13949        }
13950    }
13951
13952    #[allow(irrefutable_let_patterns)]
13953    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
13954        if let StreamProcessorRequest::QueueInputEndOfStream {
13955            stream_lifetime_ordinal,
13956            control_handle,
13957        } = self
13958        {
13959            Some((stream_lifetime_ordinal, control_handle))
13960        } else {
13961            None
13962        }
13963    }
13964
13965    #[allow(irrefutable_let_patterns)]
13966    pub fn into_participate_in_buffer_allocation(
13967        self,
13968    ) -> Option<(StreamProcessorParticipateInBufferAllocationRequest, StreamProcessorControlHandle)>
13969    {
13970        if let StreamProcessorRequest::ParticipateInBufferAllocation { payload, control_handle } =
13971            self
13972        {
13973            Some((payload, control_handle))
13974        } else {
13975            None
13976        }
13977    }
13978
13979    #[allow(irrefutable_let_patterns)]
13980    pub fn into_add_buffer(
13981        self,
13982    ) -> Option<(StreamProcessorAddBufferRequest, StreamProcessorControlHandle)> {
13983        if let StreamProcessorRequest::AddBuffer { payload, control_handle } = self {
13984            Some((payload, control_handle))
13985        } else {
13986            None
13987        }
13988    }
13989
13990    #[allow(irrefutable_let_patterns)]
13991    pub fn into_remove_buffer(
13992        self,
13993    ) -> Option<(StreamProcessorRemoveBufferRequest, StreamProcessorRemoveBufferResponder)> {
13994        if let StreamProcessorRequest::RemoveBuffer { payload, responder } = self {
13995            Some((payload, responder))
13996        } else {
13997            None
13998        }
13999    }
14000
14001    #[allow(irrefutable_let_patterns)]
14002    pub fn into_enable_old_output_buffers(self) -> Option<(StreamProcessorControlHandle)> {
14003        if let StreamProcessorRequest::EnableOldOutputBuffers { control_handle } = self {
14004            Some((control_handle))
14005        } else {
14006            None
14007        }
14008    }
14009
14010    #[allow(irrefutable_let_patterns)]
14011    pub fn into_enable_same_output_buffer_concurrently_in_flight(
14012        self,
14013    ) -> Option<(StreamProcessorControlHandle)> {
14014        if let StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
14015            control_handle,
14016        } = self
14017        {
14018            Some((control_handle))
14019        } else {
14020            None
14021        }
14022    }
14023
14024    #[allow(irrefutable_let_patterns)]
14025    pub fn into_enable_force_output_buffers_fixed_image_size(
14026        self,
14027    ) -> Option<(StreamProcessorControlHandle)> {
14028        if let StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { control_handle } =
14029            self
14030        {
14031            Some((control_handle))
14032        } else {
14033            None
14034        }
14035    }
14036
14037    /// Name of the method defined in FIDL
14038    pub fn method_name(&self) -> &'static str {
14039        match *self {
14040            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
14041            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
14042                "set_input_buffer_partial_settings"
14043            }
14044            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
14045                "set_output_buffer_partial_settings"
14046            }
14047            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
14048                "complete_output_buffer_partial_settings"
14049            }
14050            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
14051                "flush_end_of_stream_and_close_stream"
14052            }
14053            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
14054            StreamProcessorRequest::Sync { .. } => "sync",
14055            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
14056            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
14057            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
14058            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
14059            StreamProcessorRequest::ParticipateInBufferAllocation { .. } => {
14060                "participate_in_buffer_allocation"
14061            }
14062            StreamProcessorRequest::AddBuffer { .. } => "add_buffer",
14063            StreamProcessorRequest::RemoveBuffer { .. } => "remove_buffer",
14064            StreamProcessorRequest::EnableOldOutputBuffers { .. } => "enable_old_output_buffers",
14065            StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight { .. } => {
14066                "enable_same_output_buffer_concurrently_in_flight"
14067            }
14068            StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { .. } => {
14069                "enable_force_output_buffers_fixed_image_size"
14070            }
14071            StreamProcessorRequest::_UnknownMethod {
14072                method_type: fidl::MethodType::OneWay,
14073                ..
14074            } => "unknown one-way method",
14075            StreamProcessorRequest::_UnknownMethod {
14076                method_type: fidl::MethodType::TwoWay,
14077                ..
14078            } => "unknown two-way method",
14079        }
14080    }
14081}
14082
14083#[derive(Debug, Clone)]
14084pub struct StreamProcessorControlHandle {
14085    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14086}
14087
14088impl StreamProcessorControlHandle {
14089    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
14090        self.inner.shutdown_with_epitaph(status.into())
14091    }
14092}
14093
14094impl fdomain_client::fidl::ControlHandle for StreamProcessorControlHandle {
14095    fn shutdown(&self) {
14096        self.inner.shutdown()
14097    }
14098
14099    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
14100        self.inner.shutdown_with_epitaph(status)
14101    }
14102
14103    fn is_closed(&self) -> bool {
14104        self.inner.channel().is_closed()
14105    }
14106    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14107        self.inner.channel().on_closed()
14108    }
14109}
14110
14111impl StreamProcessorControlHandle {
14112    pub fn send_on_stream_failed(
14113        &self,
14114        mut stream_lifetime_ordinal: u64,
14115        mut error: StreamError,
14116    ) -> Result<(), fidl::Error> {
14117        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
14118            (stream_lifetime_ordinal, error),
14119            0,
14120            0x77ccf70bb061cf8e,
14121            fidl::encoding::DynamicFlags::empty(),
14122        )
14123    }
14124
14125    pub fn send_on_input_constraints(
14126        &self,
14127        mut input_constraints: &StreamBufferConstraints,
14128    ) -> Result<(), fidl::Error> {
14129        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
14130            (input_constraints,),
14131            0,
14132            0x211da9966a8ca0,
14133            fidl::encoding::DynamicFlags::empty(),
14134        )
14135    }
14136
14137    pub fn send_on_output_constraints(
14138        &self,
14139        mut output_config: &StreamOutputConstraints,
14140    ) -> Result<(), fidl::Error> {
14141        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
14142            (output_config,),
14143            0,
14144            0x40d8234504c170f3,
14145            fidl::encoding::DynamicFlags::empty(),
14146        )
14147    }
14148
14149    pub fn send_on_output_format(
14150        &self,
14151        mut output_format: &StreamOutputFormat,
14152    ) -> Result<(), fidl::Error> {
14153        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
14154            (output_format,),
14155            0,
14156            0x131b77ae120360bc,
14157            fidl::encoding::DynamicFlags::empty(),
14158        )
14159    }
14160
14161    pub fn send_on_output_packet(
14162        &self,
14163        mut output_packet: &Packet,
14164        mut error_detected_before: bool,
14165        mut error_detected_during: bool,
14166    ) -> Result<(), fidl::Error> {
14167        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
14168            (output_packet, error_detected_before, error_detected_during),
14169            0,
14170            0x5c2029be1090ce93,
14171            fidl::encoding::DynamicFlags::empty(),
14172        )
14173    }
14174
14175    pub fn send_on_output_end_of_stream(
14176        &self,
14177        mut stream_lifetime_ordinal: u64,
14178        mut error_detected_before: bool,
14179    ) -> Result<(), fidl::Error> {
14180        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
14181            (stream_lifetime_ordinal, error_detected_before),
14182            0,
14183            0x3bb65d237cfa50e6,
14184            fidl::encoding::DynamicFlags::empty(),
14185        )
14186    }
14187
14188    pub fn send_on_free_input_packet(
14189        &self,
14190        mut free_input_packet: &PacketHeader,
14191    ) -> Result<(), fidl::Error> {
14192        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
14193            (free_input_packet,),
14194            0,
14195            0xeef799b28708bbd,
14196            fidl::encoding::DynamicFlags::empty(),
14197        )
14198    }
14199
14200    pub fn send_on_output_timestamp_has_no_output(
14201        &self,
14202        mut payload: &StreamProcessorOnOutputTimestampHasNoOutputRequest,
14203    ) -> Result<(), fidl::Error> {
14204        self.inner.send::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(
14205            payload,
14206            0,
14207            0x7436457799a25cd4,
14208            fidl::encoding::DynamicFlags::FLEXIBLE,
14209        )
14210    }
14211}
14212
14213#[must_use = "FIDL methods require a response to be sent"]
14214#[derive(Debug)]
14215pub struct StreamProcessorSyncResponder {
14216    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
14217    tx_id: u32,
14218}
14219
14220/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
14221/// if the responder is dropped without sending a response, so that the client
14222/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14223impl std::ops::Drop for StreamProcessorSyncResponder {
14224    fn drop(&mut self) {
14225        self.control_handle.shutdown();
14226        // Safety: drops once, never accessed again
14227        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14228    }
14229}
14230
14231impl fdomain_client::fidl::Responder for StreamProcessorSyncResponder {
14232    type ControlHandle = StreamProcessorControlHandle;
14233
14234    fn control_handle(&self) -> &StreamProcessorControlHandle {
14235        &self.control_handle
14236    }
14237
14238    fn drop_without_shutdown(mut self) {
14239        // Safety: drops once, never accessed again due to mem::forget
14240        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14241        // Prevent Drop from running (which would shut down the channel)
14242        std::mem::forget(self);
14243    }
14244}
14245
14246impl StreamProcessorSyncResponder {
14247    /// Sends a response to the FIDL transaction.
14248    ///
14249    /// Sets the channel to shutdown if an error occurs.
14250    pub fn send(self) -> Result<(), fidl::Error> {
14251        let _result = self.send_raw();
14252        if _result.is_err() {
14253            self.control_handle.shutdown();
14254        }
14255        self.drop_without_shutdown();
14256        _result
14257    }
14258
14259    /// Similar to "send" but does not shutdown the channel if an error occurs.
14260    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14261        let _result = self.send_raw();
14262        self.drop_without_shutdown();
14263        _result
14264    }
14265
14266    fn send_raw(&self) -> Result<(), fidl::Error> {
14267        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14268            (),
14269            self.tx_id,
14270            0x4b3e44300b0ec6aa,
14271            fidl::encoding::DynamicFlags::empty(),
14272        )
14273    }
14274}
14275
14276#[must_use = "FIDL methods require a response to be sent"]
14277#[derive(Debug)]
14278pub struct StreamProcessorRemoveBufferResponder {
14279    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
14280    tx_id: u32,
14281}
14282
14283/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
14284/// if the responder is dropped without sending a response, so that the client
14285/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14286impl std::ops::Drop for StreamProcessorRemoveBufferResponder {
14287    fn drop(&mut self) {
14288        self.control_handle.shutdown();
14289        // Safety: drops once, never accessed again
14290        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14291    }
14292}
14293
14294impl fdomain_client::fidl::Responder for StreamProcessorRemoveBufferResponder {
14295    type ControlHandle = StreamProcessorControlHandle;
14296
14297    fn control_handle(&self) -> &StreamProcessorControlHandle {
14298        &self.control_handle
14299    }
14300
14301    fn drop_without_shutdown(mut self) {
14302        // Safety: drops once, never accessed again due to mem::forget
14303        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14304        // Prevent Drop from running (which would shut down the channel)
14305        std::mem::forget(self);
14306    }
14307}
14308
14309impl StreamProcessorRemoveBufferResponder {
14310    /// Sends a response to the FIDL transaction.
14311    ///
14312    /// Sets the channel to shutdown if an error occurs.
14313    pub fn send(self) -> Result<(), fidl::Error> {
14314        let _result = self.send_raw();
14315        if _result.is_err() {
14316            self.control_handle.shutdown();
14317        }
14318        self.drop_without_shutdown();
14319        _result
14320    }
14321
14322    /// Similar to "send" but does not shutdown the channel if an error occurs.
14323    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14324        let _result = self.send_raw();
14325        self.drop_without_shutdown();
14326        _result
14327    }
14328
14329    fn send_raw(&self) -> Result<(), fidl::Error> {
14330        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
14331            fidl::encoding::Flexible::new(()),
14332            self.tx_id,
14333            0x40b967ffa6b2da43,
14334            fidl::encoding::DynamicFlags::FLEXIBLE,
14335        )
14336    }
14337}
14338
14339#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14340pub struct StreamSinkMarker;
14341
14342impl fdomain_client::fidl::ProtocolMarker for StreamSinkMarker {
14343    type Proxy = StreamSinkProxy;
14344    type RequestStream = StreamSinkRequestStream;
14345
14346    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
14347}
14348
14349pub trait StreamSinkProxyInterface: Send + Sync {
14350    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14351    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
14352    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
14353    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
14354    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14355    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
14356    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
14357}
14358
14359#[derive(Debug, Clone)]
14360pub struct StreamSinkProxy {
14361    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14362}
14363
14364impl fdomain_client::fidl::Proxy for StreamSinkProxy {
14365    type Protocol = StreamSinkMarker;
14366
14367    fn from_channel(inner: fdomain_client::Channel) -> Self {
14368        Self::new(inner)
14369    }
14370
14371    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14372        self.client.into_channel().map_err(|client| Self { client })
14373    }
14374
14375    fn as_channel(&self) -> &fdomain_client::Channel {
14376        self.client.as_channel()
14377    }
14378}
14379
14380impl StreamSinkProxy {
14381    /// Create a new Proxy for fuchsia.media/StreamSink.
14382    pub fn new(channel: fdomain_client::Channel) -> Self {
14383        let protocol_name = <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14384        Self { client: fidl::client::Client::new(channel, protocol_name) }
14385    }
14386
14387    /// Get a Stream of events from the remote end of the protocol.
14388    ///
14389    /// # Panics
14390    ///
14391    /// Panics if the event stream was already taken.
14392    pub fn take_event_stream(&self) -> StreamSinkEventStream {
14393        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
14394    }
14395
14396    /// Sends a packet to the service. The response is sent when the service is
14397    /// done with the associated payload memory.
14398    ///
14399    /// `packet` must be valid for the current buffer set, otherwise the service
14400    /// will close the connection.
14401    pub fn r#send_packet(
14402        &self,
14403        mut packet: &StreamPacket,
14404    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
14405        StreamSinkProxyInterface::r#send_packet(self, packet)
14406    }
14407
14408    /// Sends a packet to the service. This interface doesn't define how the
14409    /// client knows when the sink is done with the associated payload memory.
14410    /// The inheriting interface must define that.
14411    ///
14412    /// `packet` must be valid for the current buffer set, otherwise the service
14413    /// will close the connection.
14414    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
14415        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
14416    }
14417
14418    /// Indicates the stream has ended. The precise semantics of this method are
14419    /// determined by the inheriting interface.
14420    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
14421        StreamSinkProxyInterface::r#end_of_stream(self)
14422    }
14423
14424    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14425    /// and not yet released. The response is sent after all packets have been
14426    /// released.
14427    pub fn r#discard_all_packets(
14428        &self,
14429    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
14430        StreamSinkProxyInterface::r#discard_all_packets(self)
14431    }
14432
14433    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14434    /// and not yet released.
14435    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
14436        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
14437    }
14438}
14439
14440impl StreamSinkProxyInterface for StreamSinkProxy {
14441    type SendPacketResponseFut =
14442        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
14443    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
14444        fn _decode(
14445            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14446        ) -> Result<(), fidl::Error> {
14447            let _response = fidl::client::decode_transaction_body::<
14448                fidl::encoding::EmptyPayload,
14449                fdomain_client::fidl::FDomainResourceDialect,
14450                0x67cddd607442775f,
14451            >(_buf?)?;
14452            Ok(_response)
14453        }
14454        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
14455            (packet,),
14456            0x67cddd607442775f,
14457            fidl::encoding::DynamicFlags::empty(),
14458            _decode,
14459        )
14460    }
14461
14462    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
14463        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
14464            (packet,),
14465            0x8d9b8b413ceba9d,
14466            fidl::encoding::DynamicFlags::empty(),
14467        )
14468    }
14469
14470    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
14471        self.client.send::<fidl::encoding::EmptyPayload>(
14472            (),
14473            0x6180fd6f7e793b71,
14474            fidl::encoding::DynamicFlags::empty(),
14475        )
14476    }
14477
14478    type DiscardAllPacketsResponseFut =
14479        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
14480    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
14481        fn _decode(
14482            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
14483        ) -> Result<(), fidl::Error> {
14484            let _response = fidl::client::decode_transaction_body::<
14485                fidl::encoding::EmptyPayload,
14486                fdomain_client::fidl::FDomainResourceDialect,
14487                0x6f4dad7af2917665,
14488            >(_buf?)?;
14489            Ok(_response)
14490        }
14491        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
14492            (),
14493            0x6f4dad7af2917665,
14494            fidl::encoding::DynamicFlags::empty(),
14495            _decode,
14496        )
14497    }
14498
14499    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
14500        self.client.send::<fidl::encoding::EmptyPayload>(
14501            (),
14502            0x50d36d0d23081bc4,
14503            fidl::encoding::DynamicFlags::empty(),
14504        )
14505    }
14506}
14507
14508pub struct StreamSinkEventStream {
14509    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
14510}
14511
14512impl std::marker::Unpin for StreamSinkEventStream {}
14513
14514impl futures::stream::FusedStream for StreamSinkEventStream {
14515    fn is_terminated(&self) -> bool {
14516        self.event_receiver.is_terminated()
14517    }
14518}
14519
14520impl futures::Stream for StreamSinkEventStream {
14521    type Item = Result<StreamSinkEvent, fidl::Error>;
14522
14523    fn poll_next(
14524        mut self: std::pin::Pin<&mut Self>,
14525        cx: &mut std::task::Context<'_>,
14526    ) -> std::task::Poll<Option<Self::Item>> {
14527        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
14528            &mut self.event_receiver,
14529            cx
14530        )?) {
14531            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
14532            None => std::task::Poll::Ready(None),
14533        }
14534    }
14535}
14536
14537#[derive(Debug)]
14538pub enum StreamSinkEvent {}
14539
14540impl StreamSinkEvent {
14541    /// Decodes a message buffer as a [`StreamSinkEvent`].
14542    fn decode(
14543        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
14544    ) -> Result<StreamSinkEvent, fidl::Error> {
14545        let (bytes, _handles) = buf.split_mut();
14546        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14547        debug_assert_eq!(tx_header.tx_id, 0);
14548        match tx_header.ordinal {
14549            _ => Err(fidl::Error::UnknownOrdinal {
14550                ordinal: tx_header.ordinal,
14551                protocol_name:
14552                    <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14553            }),
14554        }
14555    }
14556}
14557
14558/// A Stream of incoming requests for fuchsia.media/StreamSink.
14559pub struct StreamSinkRequestStream {
14560    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14561    is_terminated: bool,
14562}
14563
14564impl std::marker::Unpin for StreamSinkRequestStream {}
14565
14566impl futures::stream::FusedStream for StreamSinkRequestStream {
14567    fn is_terminated(&self) -> bool {
14568        self.is_terminated
14569    }
14570}
14571
14572impl fdomain_client::fidl::RequestStream for StreamSinkRequestStream {
14573    type Protocol = StreamSinkMarker;
14574    type ControlHandle = StreamSinkControlHandle;
14575
14576    fn from_channel(channel: fdomain_client::Channel) -> Self {
14577        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
14578    }
14579
14580    fn control_handle(&self) -> Self::ControlHandle {
14581        StreamSinkControlHandle { inner: self.inner.clone() }
14582    }
14583
14584    fn into_inner(
14585        self,
14586    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
14587    {
14588        (self.inner, self.is_terminated)
14589    }
14590
14591    fn from_inner(
14592        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14593        is_terminated: bool,
14594    ) -> Self {
14595        Self { inner, is_terminated }
14596    }
14597}
14598
14599impl futures::Stream for StreamSinkRequestStream {
14600    type Item = Result<StreamSinkRequest, fidl::Error>;
14601
14602    fn poll_next(
14603        mut self: std::pin::Pin<&mut Self>,
14604        cx: &mut std::task::Context<'_>,
14605    ) -> std::task::Poll<Option<Self::Item>> {
14606        let this = &mut *self;
14607        if this.inner.check_shutdown(cx) {
14608            this.is_terminated = true;
14609            return std::task::Poll::Ready(None);
14610        }
14611        if this.is_terminated {
14612            panic!("polled StreamSinkRequestStream after completion");
14613        }
14614        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
14615            |bytes, handles| {
14616                match this.inner.channel().read_etc(cx, bytes, handles) {
14617                    std::task::Poll::Ready(Ok(())) => {}
14618                    std::task::Poll::Pending => return std::task::Poll::Pending,
14619                    std::task::Poll::Ready(Err(None)) => {
14620                        this.is_terminated = true;
14621                        return std::task::Poll::Ready(None);
14622                    }
14623                    std::task::Poll::Ready(Err(Some(e))) => {
14624                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
14625                            e.into(),
14626                        ))));
14627                    }
14628                }
14629
14630                // A message has been received from the channel
14631                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
14632
14633                std::task::Poll::Ready(Some(match header.ordinal {
14634                    0x67cddd607442775f => {
14635                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14636                        let mut req = fidl::new_empty!(
14637                            StreamSinkSendPacketRequest,
14638                            fdomain_client::fidl::FDomainResourceDialect
14639                        );
14640                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
14641                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14642                        Ok(StreamSinkRequest::SendPacket {
14643                            packet: req.packet,
14644
14645                            responder: StreamSinkSendPacketResponder {
14646                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14647                                tx_id: header.tx_id,
14648                            },
14649                        })
14650                    }
14651                    0x8d9b8b413ceba9d => {
14652                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14653                        let mut req = fidl::new_empty!(
14654                            StreamSinkSendPacketNoReplyRequest,
14655                            fdomain_client::fidl::FDomainResourceDialect
14656                        );
14657                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
14658                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14659                        Ok(StreamSinkRequest::SendPacketNoReply {
14660                            packet: req.packet,
14661
14662                            control_handle,
14663                        })
14664                    }
14665                    0x6180fd6f7e793b71 => {
14666                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14667                        let mut req = fidl::new_empty!(
14668                            fidl::encoding::EmptyPayload,
14669                            fdomain_client::fidl::FDomainResourceDialect
14670                        );
14671                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14672                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14673                        Ok(StreamSinkRequest::EndOfStream { control_handle })
14674                    }
14675                    0x6f4dad7af2917665 => {
14676                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
14677                        let mut req = fidl::new_empty!(
14678                            fidl::encoding::EmptyPayload,
14679                            fdomain_client::fidl::FDomainResourceDialect
14680                        );
14681                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14682                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14683                        Ok(StreamSinkRequest::DiscardAllPackets {
14684                            responder: StreamSinkDiscardAllPacketsResponder {
14685                                control_handle: std::mem::ManuallyDrop::new(control_handle),
14686                                tx_id: header.tx_id,
14687                            },
14688                        })
14689                    }
14690                    0x50d36d0d23081bc4 => {
14691                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
14692                        let mut req = fidl::new_empty!(
14693                            fidl::encoding::EmptyPayload,
14694                            fdomain_client::fidl::FDomainResourceDialect
14695                        );
14696                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
14697                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
14698                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
14699                    }
14700                    _ => Err(fidl::Error::UnknownOrdinal {
14701                        ordinal: header.ordinal,
14702                        protocol_name:
14703                            <StreamSinkMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
14704                    }),
14705                }))
14706            },
14707        )
14708    }
14709}
14710
14711/// Consumes a stream of packets. This interface is typically inherited along
14712/// with `StreamBufferSet` to enable the transport of elementary streams from
14713/// clients to services.
14714#[derive(Debug)]
14715pub enum StreamSinkRequest {
14716    /// Sends a packet to the service. The response is sent when the service is
14717    /// done with the associated payload memory.
14718    ///
14719    /// `packet` must be valid for the current buffer set, otherwise the service
14720    /// will close the connection.
14721    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
14722    /// Sends a packet to the service. This interface doesn't define how the
14723    /// client knows when the sink is done with the associated payload memory.
14724    /// The inheriting interface must define that.
14725    ///
14726    /// `packet` must be valid for the current buffer set, otherwise the service
14727    /// will close the connection.
14728    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
14729    /// Indicates the stream has ended. The precise semantics of this method are
14730    /// determined by the inheriting interface.
14731    EndOfStream { control_handle: StreamSinkControlHandle },
14732    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14733    /// and not yet released. The response is sent after all packets have been
14734    /// released.
14735    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
14736    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
14737    /// and not yet released.
14738    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
14739}
14740
14741impl StreamSinkRequest {
14742    #[allow(irrefutable_let_patterns)]
14743    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
14744        if let StreamSinkRequest::SendPacket { packet, responder } = self {
14745            Some((packet, responder))
14746        } else {
14747            None
14748        }
14749    }
14750
14751    #[allow(irrefutable_let_patterns)]
14752    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
14753        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
14754            Some((packet, control_handle))
14755        } else {
14756            None
14757        }
14758    }
14759
14760    #[allow(irrefutable_let_patterns)]
14761    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
14762        if let StreamSinkRequest::EndOfStream { control_handle } = self {
14763            Some((control_handle))
14764        } else {
14765            None
14766        }
14767    }
14768
14769    #[allow(irrefutable_let_patterns)]
14770    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
14771        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
14772            Some((responder))
14773        } else {
14774            None
14775        }
14776    }
14777
14778    #[allow(irrefutable_let_patterns)]
14779    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
14780        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
14781            Some((control_handle))
14782        } else {
14783            None
14784        }
14785    }
14786
14787    /// Name of the method defined in FIDL
14788    pub fn method_name(&self) -> &'static str {
14789        match *self {
14790            StreamSinkRequest::SendPacket { .. } => "send_packet",
14791            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
14792            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
14793            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
14794            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
14795        }
14796    }
14797}
14798
14799#[derive(Debug, Clone)]
14800pub struct StreamSinkControlHandle {
14801    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
14802}
14803
14804impl StreamSinkControlHandle {
14805    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
14806        self.inner.shutdown_with_epitaph(status.into())
14807    }
14808}
14809
14810impl fdomain_client::fidl::ControlHandle for StreamSinkControlHandle {
14811    fn shutdown(&self) {
14812        self.inner.shutdown()
14813    }
14814
14815    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
14816        self.inner.shutdown_with_epitaph(status)
14817    }
14818
14819    fn is_closed(&self) -> bool {
14820        self.inner.channel().is_closed()
14821    }
14822    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
14823        self.inner.channel().on_closed()
14824    }
14825}
14826
14827impl StreamSinkControlHandle {}
14828
14829#[must_use = "FIDL methods require a response to be sent"]
14830#[derive(Debug)]
14831pub struct StreamSinkSendPacketResponder {
14832    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
14833    tx_id: u32,
14834}
14835
14836/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
14837/// if the responder is dropped without sending a response, so that the client
14838/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14839impl std::ops::Drop for StreamSinkSendPacketResponder {
14840    fn drop(&mut self) {
14841        self.control_handle.shutdown();
14842        // Safety: drops once, never accessed again
14843        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14844    }
14845}
14846
14847impl fdomain_client::fidl::Responder for StreamSinkSendPacketResponder {
14848    type ControlHandle = StreamSinkControlHandle;
14849
14850    fn control_handle(&self) -> &StreamSinkControlHandle {
14851        &self.control_handle
14852    }
14853
14854    fn drop_without_shutdown(mut self) {
14855        // Safety: drops once, never accessed again due to mem::forget
14856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14857        // Prevent Drop from running (which would shut down the channel)
14858        std::mem::forget(self);
14859    }
14860}
14861
14862impl StreamSinkSendPacketResponder {
14863    /// Sends a response to the FIDL transaction.
14864    ///
14865    /// Sets the channel to shutdown if an error occurs.
14866    pub fn send(self) -> Result<(), fidl::Error> {
14867        let _result = self.send_raw();
14868        if _result.is_err() {
14869            self.control_handle.shutdown();
14870        }
14871        self.drop_without_shutdown();
14872        _result
14873    }
14874
14875    /// Similar to "send" but does not shutdown the channel if an error occurs.
14876    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14877        let _result = self.send_raw();
14878        self.drop_without_shutdown();
14879        _result
14880    }
14881
14882    fn send_raw(&self) -> Result<(), fidl::Error> {
14883        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14884            (),
14885            self.tx_id,
14886            0x67cddd607442775f,
14887            fidl::encoding::DynamicFlags::empty(),
14888        )
14889    }
14890}
14891
14892#[must_use = "FIDL methods require a response to be sent"]
14893#[derive(Debug)]
14894pub struct StreamSinkDiscardAllPacketsResponder {
14895    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
14896    tx_id: u32,
14897}
14898
14899/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
14900/// if the responder is dropped without sending a response, so that the client
14901/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
14902impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
14903    fn drop(&mut self) {
14904        self.control_handle.shutdown();
14905        // Safety: drops once, never accessed again
14906        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14907    }
14908}
14909
14910impl fdomain_client::fidl::Responder for StreamSinkDiscardAllPacketsResponder {
14911    type ControlHandle = StreamSinkControlHandle;
14912
14913    fn control_handle(&self) -> &StreamSinkControlHandle {
14914        &self.control_handle
14915    }
14916
14917    fn drop_without_shutdown(mut self) {
14918        // Safety: drops once, never accessed again due to mem::forget
14919        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
14920        // Prevent Drop from running (which would shut down the channel)
14921        std::mem::forget(self);
14922    }
14923}
14924
14925impl StreamSinkDiscardAllPacketsResponder {
14926    /// Sends a response to the FIDL transaction.
14927    ///
14928    /// Sets the channel to shutdown if an error occurs.
14929    pub fn send(self) -> Result<(), fidl::Error> {
14930        let _result = self.send_raw();
14931        if _result.is_err() {
14932            self.control_handle.shutdown();
14933        }
14934        self.drop_without_shutdown();
14935        _result
14936    }
14937
14938    /// Similar to "send" but does not shutdown the channel if an error occurs.
14939    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
14940        let _result = self.send_raw();
14941        self.drop_without_shutdown();
14942        _result
14943    }
14944
14945    fn send_raw(&self) -> Result<(), fidl::Error> {
14946        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
14947            (),
14948            self.tx_id,
14949            0x6f4dad7af2917665,
14950            fidl::encoding::DynamicFlags::empty(),
14951        )
14952    }
14953}
14954
14955#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
14956pub struct StreamSourceMarker;
14957
14958impl fdomain_client::fidl::ProtocolMarker for StreamSourceMarker {
14959    type Proxy = StreamSourceProxy;
14960    type RequestStream = StreamSourceRequestStream;
14961
14962    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
14963}
14964
14965pub trait StreamSourceProxyInterface: Send + Sync {
14966    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
14967    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
14968    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
14969    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
14970}
14971
14972#[derive(Debug, Clone)]
14973pub struct StreamSourceProxy {
14974    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
14975}
14976
14977impl fdomain_client::fidl::Proxy for StreamSourceProxy {
14978    type Protocol = StreamSourceMarker;
14979
14980    fn from_channel(inner: fdomain_client::Channel) -> Self {
14981        Self::new(inner)
14982    }
14983
14984    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
14985        self.client.into_channel().map_err(|client| Self { client })
14986    }
14987
14988    fn as_channel(&self) -> &fdomain_client::Channel {
14989        self.client.as_channel()
14990    }
14991}
14992
14993impl StreamSourceProxy {
14994    /// Create a new Proxy for fuchsia.media/StreamSource.
14995    pub fn new(channel: fdomain_client::Channel) -> Self {
14996        let protocol_name =
14997            <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
14998        Self { client: fidl::client::Client::new(channel, protocol_name) }
14999    }
15000
15001    /// Get a Stream of events from the remote end of the protocol.
15002    ///
15003    /// # Panics
15004    ///
15005    /// Panics if the event stream was already taken.
15006    pub fn take_event_stream(&self) -> StreamSourceEventStream {
15007        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
15008    }
15009
15010    /// Releases payload memory associated with a packet previously delivered
15011    /// via `OnPacketProduced`.
15012    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15013        StreamSourceProxyInterface::r#release_packet(self, packet)
15014    }
15015
15016    pub fn r#discard_all_packets(
15017        &self,
15018    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
15019        StreamSourceProxyInterface::r#discard_all_packets(self)
15020    }
15021
15022    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15023        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
15024    }
15025}
15026
15027impl StreamSourceProxyInterface for StreamSourceProxy {
15028    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15029        self.client.send::<StreamSourceReleasePacketRequest>(
15030            (packet,),
15031            0x7a7b57f0f7d9e4bb,
15032            fidl::encoding::DynamicFlags::empty(),
15033        )
15034    }
15035
15036    type DiscardAllPacketsResponseFut =
15037        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
15038    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
15039        fn _decode(
15040            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15041        ) -> Result<(), fidl::Error> {
15042            let _response = fidl::client::decode_transaction_body::<
15043                fidl::encoding::EmptyPayload,
15044                fdomain_client::fidl::FDomainResourceDialect,
15045                0x27afd605e97b09d2,
15046            >(_buf?)?;
15047            Ok(_response)
15048        }
15049        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
15050            (),
15051            0x27afd605e97b09d2,
15052            fidl::encoding::DynamicFlags::empty(),
15053            _decode,
15054        )
15055    }
15056
15057    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
15058        self.client.send::<fidl::encoding::EmptyPayload>(
15059            (),
15060            0x35f9d721e905b831,
15061            fidl::encoding::DynamicFlags::empty(),
15062        )
15063    }
15064}
15065
15066pub struct StreamSourceEventStream {
15067    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15068}
15069
15070impl std::marker::Unpin for StreamSourceEventStream {}
15071
15072impl futures::stream::FusedStream for StreamSourceEventStream {
15073    fn is_terminated(&self) -> bool {
15074        self.event_receiver.is_terminated()
15075    }
15076}
15077
15078impl futures::Stream for StreamSourceEventStream {
15079    type Item = Result<StreamSourceEvent, fidl::Error>;
15080
15081    fn poll_next(
15082        mut self: std::pin::Pin<&mut Self>,
15083        cx: &mut std::task::Context<'_>,
15084    ) -> std::task::Poll<Option<Self::Item>> {
15085        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15086            &mut self.event_receiver,
15087            cx
15088        )?) {
15089            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
15090            None => std::task::Poll::Ready(None),
15091        }
15092    }
15093}
15094
15095#[derive(Debug)]
15096pub enum StreamSourceEvent {
15097    OnPacketProduced { packet: StreamPacket },
15098    OnEndOfStream {},
15099}
15100
15101impl StreamSourceEvent {
15102    #[allow(irrefutable_let_patterns)]
15103    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
15104        if let StreamSourceEvent::OnPacketProduced { packet } = self {
15105            Some((packet))
15106        } else {
15107            None
15108        }
15109    }
15110    #[allow(irrefutable_let_patterns)]
15111    pub fn into_on_end_of_stream(self) -> Option<()> {
15112        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
15113    }
15114
15115    /// Decodes a message buffer as a [`StreamSourceEvent`].
15116    fn decode(
15117        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15118    ) -> Result<StreamSourceEvent, fidl::Error> {
15119        let (bytes, _handles) = buf.split_mut();
15120        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15121        debug_assert_eq!(tx_header.tx_id, 0);
15122        match tx_header.ordinal {
15123            0x6bbe69746a3c8bd9 => {
15124                let mut out = fidl::new_empty!(
15125                    StreamSourceOnPacketProducedRequest,
15126                    fdomain_client::fidl::FDomainResourceDialect
15127                );
15128                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
15129                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
15130            }
15131            0x550e69b41d03e2c2 => {
15132                let mut out = fidl::new_empty!(
15133                    fidl::encoding::EmptyPayload,
15134                    fdomain_client::fidl::FDomainResourceDialect
15135                );
15136                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
15137                Ok((StreamSourceEvent::OnEndOfStream {}))
15138            }
15139            _ => Err(fidl::Error::UnknownOrdinal {
15140                ordinal: tx_header.ordinal,
15141                protocol_name:
15142                    <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15143            }),
15144        }
15145    }
15146}
15147
15148/// A Stream of incoming requests for fuchsia.media/StreamSource.
15149pub struct StreamSourceRequestStream {
15150    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15151    is_terminated: bool,
15152}
15153
15154impl std::marker::Unpin for StreamSourceRequestStream {}
15155
15156impl futures::stream::FusedStream for StreamSourceRequestStream {
15157    fn is_terminated(&self) -> bool {
15158        self.is_terminated
15159    }
15160}
15161
15162impl fdomain_client::fidl::RequestStream for StreamSourceRequestStream {
15163    type Protocol = StreamSourceMarker;
15164    type ControlHandle = StreamSourceControlHandle;
15165
15166    fn from_channel(channel: fdomain_client::Channel) -> Self {
15167        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15168    }
15169
15170    fn control_handle(&self) -> Self::ControlHandle {
15171        StreamSourceControlHandle { inner: self.inner.clone() }
15172    }
15173
15174    fn into_inner(
15175        self,
15176    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15177    {
15178        (self.inner, self.is_terminated)
15179    }
15180
15181    fn from_inner(
15182        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15183        is_terminated: bool,
15184    ) -> Self {
15185        Self { inner, is_terminated }
15186    }
15187}
15188
15189impl futures::Stream for StreamSourceRequestStream {
15190    type Item = Result<StreamSourceRequest, fidl::Error>;
15191
15192    fn poll_next(
15193        mut self: std::pin::Pin<&mut Self>,
15194        cx: &mut std::task::Context<'_>,
15195    ) -> std::task::Poll<Option<Self::Item>> {
15196        let this = &mut *self;
15197        if this.inner.check_shutdown(cx) {
15198            this.is_terminated = true;
15199            return std::task::Poll::Ready(None);
15200        }
15201        if this.is_terminated {
15202            panic!("polled StreamSourceRequestStream after completion");
15203        }
15204        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15205            |bytes, handles| {
15206                match this.inner.channel().read_etc(cx, bytes, handles) {
15207                    std::task::Poll::Ready(Ok(())) => {}
15208                    std::task::Poll::Pending => return std::task::Poll::Pending,
15209                    std::task::Poll::Ready(Err(None)) => {
15210                        this.is_terminated = true;
15211                        return std::task::Poll::Ready(None);
15212                    }
15213                    std::task::Poll::Ready(Err(Some(e))) => {
15214                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15215                            e.into(),
15216                        ))));
15217                    }
15218                }
15219
15220                // A message has been received from the channel
15221                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15222
15223                std::task::Poll::Ready(Some(match header.ordinal {
15224                    0x7a7b57f0f7d9e4bb => {
15225                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15226                        let mut req = fidl::new_empty!(
15227                            StreamSourceReleasePacketRequest,
15228                            fdomain_client::fidl::FDomainResourceDialect
15229                        );
15230                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
15231                        let control_handle =
15232                            StreamSourceControlHandle { inner: this.inner.clone() };
15233                        Ok(StreamSourceRequest::ReleasePacket {
15234                            packet: req.packet,
15235
15236                            control_handle,
15237                        })
15238                    }
15239                    0x27afd605e97b09d2 => {
15240                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
15241                        let mut req = fidl::new_empty!(
15242                            fidl::encoding::EmptyPayload,
15243                            fdomain_client::fidl::FDomainResourceDialect
15244                        );
15245                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
15246                        let control_handle =
15247                            StreamSourceControlHandle { inner: this.inner.clone() };
15248                        Ok(StreamSourceRequest::DiscardAllPackets {
15249                            responder: StreamSourceDiscardAllPacketsResponder {
15250                                control_handle: std::mem::ManuallyDrop::new(control_handle),
15251                                tx_id: header.tx_id,
15252                            },
15253                        })
15254                    }
15255                    0x35f9d721e905b831 => {
15256                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15257                        let mut req = fidl::new_empty!(
15258                            fidl::encoding::EmptyPayload,
15259                            fdomain_client::fidl::FDomainResourceDialect
15260                        );
15261                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
15262                        let control_handle =
15263                            StreamSourceControlHandle { inner: this.inner.clone() };
15264                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
15265                    }
15266                    _ => Err(fidl::Error::UnknownOrdinal {
15267                        ordinal: header.ordinal,
15268                        protocol_name:
15269                            <StreamSourceMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15270                    }),
15271                }))
15272            },
15273        )
15274    }
15275}
15276
15277/// Produces a stream of packets. This interface is typically inherited along
15278/// with `StreamBufferSet` to enable the transport of elementary streams from
15279/// services to clients.
15280#[derive(Debug)]
15281pub enum StreamSourceRequest {
15282    /// Releases payload memory associated with a packet previously delivered
15283    /// via `OnPacketProduced`.
15284    ReleasePacket {
15285        packet: StreamPacket,
15286        control_handle: StreamSourceControlHandle,
15287    },
15288    DiscardAllPackets {
15289        responder: StreamSourceDiscardAllPacketsResponder,
15290    },
15291    DiscardAllPacketsNoReply {
15292        control_handle: StreamSourceControlHandle,
15293    },
15294}
15295
15296impl StreamSourceRequest {
15297    #[allow(irrefutable_let_patterns)]
15298    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
15299        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
15300            Some((packet, control_handle))
15301        } else {
15302            None
15303        }
15304    }
15305
15306    #[allow(irrefutable_let_patterns)]
15307    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
15308        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
15309            Some((responder))
15310        } else {
15311            None
15312        }
15313    }
15314
15315    #[allow(irrefutable_let_patterns)]
15316    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
15317        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
15318            Some((control_handle))
15319        } else {
15320            None
15321        }
15322    }
15323
15324    /// Name of the method defined in FIDL
15325    pub fn method_name(&self) -> &'static str {
15326        match *self {
15327            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
15328            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
15329            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
15330        }
15331    }
15332}
15333
15334#[derive(Debug, Clone)]
15335pub struct StreamSourceControlHandle {
15336    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15337}
15338
15339impl StreamSourceControlHandle {
15340    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
15341        self.inner.shutdown_with_epitaph(status.into())
15342    }
15343}
15344
15345impl fdomain_client::fidl::ControlHandle for StreamSourceControlHandle {
15346    fn shutdown(&self) {
15347        self.inner.shutdown()
15348    }
15349
15350    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
15351        self.inner.shutdown_with_epitaph(status)
15352    }
15353
15354    fn is_closed(&self) -> bool {
15355        self.inner.channel().is_closed()
15356    }
15357    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15358        self.inner.channel().on_closed()
15359    }
15360}
15361
15362impl StreamSourceControlHandle {
15363    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
15364        self.inner.send::<StreamSourceOnPacketProducedRequest>(
15365            (packet,),
15366            0,
15367            0x6bbe69746a3c8bd9,
15368            fidl::encoding::DynamicFlags::empty(),
15369        )
15370    }
15371
15372    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
15373        self.inner.send::<fidl::encoding::EmptyPayload>(
15374            (),
15375            0,
15376            0x550e69b41d03e2c2,
15377            fidl::encoding::DynamicFlags::empty(),
15378        )
15379    }
15380}
15381
15382#[must_use = "FIDL methods require a response to be sent"]
15383#[derive(Debug)]
15384pub struct StreamSourceDiscardAllPacketsResponder {
15385    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
15386    tx_id: u32,
15387}
15388
15389/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
15390/// if the responder is dropped without sending a response, so that the client
15391/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
15392impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
15393    fn drop(&mut self) {
15394        self.control_handle.shutdown();
15395        // Safety: drops once, never accessed again
15396        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15397    }
15398}
15399
15400impl fdomain_client::fidl::Responder for StreamSourceDiscardAllPacketsResponder {
15401    type ControlHandle = StreamSourceControlHandle;
15402
15403    fn control_handle(&self) -> &StreamSourceControlHandle {
15404        &self.control_handle
15405    }
15406
15407    fn drop_without_shutdown(mut self) {
15408        // Safety: drops once, never accessed again due to mem::forget
15409        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
15410        // Prevent Drop from running (which would shut down the channel)
15411        std::mem::forget(self);
15412    }
15413}
15414
15415impl StreamSourceDiscardAllPacketsResponder {
15416    /// Sends a response to the FIDL transaction.
15417    ///
15418    /// Sets the channel to shutdown if an error occurs.
15419    pub fn send(self) -> Result<(), fidl::Error> {
15420        let _result = self.send_raw();
15421        if _result.is_err() {
15422            self.control_handle.shutdown();
15423        }
15424        self.drop_without_shutdown();
15425        _result
15426    }
15427
15428    /// Similar to "send" but does not shutdown the channel if an error occurs.
15429    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
15430        let _result = self.send_raw();
15431        self.drop_without_shutdown();
15432        _result
15433    }
15434
15435    fn send_raw(&self) -> Result<(), fidl::Error> {
15436        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
15437            (),
15438            self.tx_id,
15439            0x27afd605e97b09d2,
15440            fidl::encoding::DynamicFlags::empty(),
15441        )
15442    }
15443}
15444
15445#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15446pub struct Usage2AudioConsumerFactoryMarker;
15447
15448impl fdomain_client::fidl::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
15449    type Proxy = Usage2AudioConsumerFactoryProxy;
15450    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
15451
15452    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
15453}
15454impl fdomain_client::fidl::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
15455
15456pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
15457    fn r#create_audio_consumer(
15458        &self,
15459        usage: AudioRenderUsage2,
15460        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15461    ) -> Result<(), fidl::Error>;
15462}
15463
15464#[derive(Debug, Clone)]
15465pub struct Usage2AudioConsumerFactoryProxy {
15466    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
15467}
15468
15469impl fdomain_client::fidl::Proxy for Usage2AudioConsumerFactoryProxy {
15470    type Protocol = Usage2AudioConsumerFactoryMarker;
15471
15472    fn from_channel(inner: fdomain_client::Channel) -> Self {
15473        Self::new(inner)
15474    }
15475
15476    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
15477        self.client.into_channel().map_err(|client| Self { client })
15478    }
15479
15480    fn as_channel(&self) -> &fdomain_client::Channel {
15481        self.client.as_channel()
15482    }
15483}
15484
15485impl Usage2AudioConsumerFactoryProxy {
15486    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
15487    pub fn new(channel: fdomain_client::Channel) -> Self {
15488        let protocol_name =
15489            <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
15490        Self { client: fidl::client::Client::new(channel, protocol_name) }
15491    }
15492
15493    /// Get a Stream of events from the remote end of the protocol.
15494    ///
15495    /// # Panics
15496    ///
15497    /// Panics if the event stream was already taken.
15498    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
15499        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
15500    }
15501
15502    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
15503    /// Audio submitted to such a consumer is always rendered locally.
15504    pub fn r#create_audio_consumer(
15505        &self,
15506        mut usage: AudioRenderUsage2,
15507        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15508    ) -> Result<(), fidl::Error> {
15509        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
15510            self,
15511            usage,
15512            audio_consumer_request,
15513        )
15514    }
15515}
15516
15517impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
15518    fn r#create_audio_consumer(
15519        &self,
15520        mut usage: AudioRenderUsage2,
15521        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15522    ) -> Result<(), fidl::Error> {
15523        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
15524            (usage, audio_consumer_request),
15525            0x767722302a171873,
15526            fidl::encoding::DynamicFlags::FLEXIBLE,
15527        )
15528    }
15529}
15530
15531pub struct Usage2AudioConsumerFactoryEventStream {
15532    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15533}
15534
15535impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
15536
15537impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
15538    fn is_terminated(&self) -> bool {
15539        self.event_receiver.is_terminated()
15540    }
15541}
15542
15543impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
15544    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
15545
15546    fn poll_next(
15547        mut self: std::pin::Pin<&mut Self>,
15548        cx: &mut std::task::Context<'_>,
15549    ) -> std::task::Poll<Option<Self::Item>> {
15550        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15551            &mut self.event_receiver,
15552            cx
15553        )?) {
15554            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
15555            None => std::task::Poll::Ready(None),
15556        }
15557    }
15558}
15559
15560#[derive(Debug)]
15561pub enum Usage2AudioConsumerFactoryEvent {
15562    #[non_exhaustive]
15563    _UnknownEvent {
15564        /// Ordinal of the event that was sent.
15565        ordinal: u64,
15566    },
15567}
15568
15569impl Usage2AudioConsumerFactoryEvent {
15570    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
15571    fn decode(
15572        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15573    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
15574        let (bytes, _handles) = buf.split_mut();
15575        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15576        debug_assert_eq!(tx_header.tx_id, 0);
15577        match tx_header.ordinal {
15578            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15579                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
15580                    ordinal: tx_header.ordinal,
15581                })
15582            }
15583            _ => Err(fidl::Error::UnknownOrdinal {
15584                ordinal: tx_header.ordinal,
15585                protocol_name: <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15586            })
15587        }
15588    }
15589}
15590
15591/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
15592pub struct Usage2AudioConsumerFactoryRequestStream {
15593    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15594    is_terminated: bool,
15595}
15596
15597impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
15598
15599impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
15600    fn is_terminated(&self) -> bool {
15601        self.is_terminated
15602    }
15603}
15604
15605impl fdomain_client::fidl::RequestStream for Usage2AudioConsumerFactoryRequestStream {
15606    type Protocol = Usage2AudioConsumerFactoryMarker;
15607    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
15608
15609    fn from_channel(channel: fdomain_client::Channel) -> Self {
15610        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15611    }
15612
15613    fn control_handle(&self) -> Self::ControlHandle {
15614        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
15615    }
15616
15617    fn into_inner(
15618        self,
15619    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15620    {
15621        (self.inner, self.is_terminated)
15622    }
15623
15624    fn from_inner(
15625        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15626        is_terminated: bool,
15627    ) -> Self {
15628        Self { inner, is_terminated }
15629    }
15630}
15631
15632impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
15633    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
15634
15635    fn poll_next(
15636        mut self: std::pin::Pin<&mut Self>,
15637        cx: &mut std::task::Context<'_>,
15638    ) -> std::task::Poll<Option<Self::Item>> {
15639        let this = &mut *self;
15640        if this.inner.check_shutdown(cx) {
15641            this.is_terminated = true;
15642            return std::task::Poll::Ready(None);
15643        }
15644        if this.is_terminated {
15645            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
15646        }
15647        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15648            |bytes, handles| {
15649                match this.inner.channel().read_etc(cx, bytes, handles) {
15650                    std::task::Poll::Ready(Ok(())) => {}
15651                    std::task::Poll::Pending => return std::task::Poll::Pending,
15652                    std::task::Poll::Ready(Err(None)) => {
15653                        this.is_terminated = true;
15654                        return std::task::Poll::Ready(None);
15655                    }
15656                    std::task::Poll::Ready(Err(Some(e))) => {
15657                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
15658                            e.into(),
15659                        ))));
15660                    }
15661                }
15662
15663                // A message has been received from the channel
15664                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15665
15666                std::task::Poll::Ready(Some(match header.ordinal {
15667                0x767722302a171873 => {
15668                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
15669                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
15670                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
15671                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
15672                        inner: this.inner.clone(),
15673                    };
15674                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
15675audio_consumer_request: req.audio_consumer_request,
15676
15677                        control_handle,
15678                    })
15679                }
15680                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15681                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15682                        ordinal: header.ordinal,
15683                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
15684                        method_type: fidl::MethodType::OneWay,
15685                    })
15686                }
15687                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
15688                    this.inner.send_framework_err(
15689                        fidl::encoding::FrameworkErr::UnknownMethod,
15690                        header.tx_id,
15691                        header.ordinal,
15692                        header.dynamic_flags(),
15693                        (bytes, handles),
15694                    )?;
15695                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15696                        ordinal: header.ordinal,
15697                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
15698                        method_type: fidl::MethodType::TwoWay,
15699                    })
15700                }
15701                _ => Err(fidl::Error::UnknownOrdinal {
15702                    ordinal: header.ordinal,
15703                    protocol_name: <Usage2AudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15704                }),
15705            }))
15706            },
15707        )
15708    }
15709}
15710
15711/// Interface for creating audio consumers for local rendering.
15712#[derive(Debug)]
15713pub enum Usage2AudioConsumerFactoryRequest {
15714    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
15715    /// Audio submitted to such a consumer is always rendered locally.
15716    CreateAudioConsumer {
15717        usage: AudioRenderUsage2,
15718        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15719        control_handle: Usage2AudioConsumerFactoryControlHandle,
15720    },
15721    /// An interaction was received which does not match any known method.
15722    #[non_exhaustive]
15723    _UnknownMethod {
15724        /// Ordinal of the method that was called.
15725        ordinal: u64,
15726        control_handle: Usage2AudioConsumerFactoryControlHandle,
15727        method_type: fidl::MethodType,
15728    },
15729}
15730
15731impl Usage2AudioConsumerFactoryRequest {
15732    #[allow(irrefutable_let_patterns)]
15733    pub fn into_create_audio_consumer(
15734        self,
15735    ) -> Option<(
15736        AudioRenderUsage2,
15737        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15738        Usage2AudioConsumerFactoryControlHandle,
15739    )> {
15740        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
15741            usage,
15742            audio_consumer_request,
15743            control_handle,
15744        } = self
15745        {
15746            Some((usage, audio_consumer_request, control_handle))
15747        } else {
15748            None
15749        }
15750    }
15751
15752    /// Name of the method defined in FIDL
15753    pub fn method_name(&self) -> &'static str {
15754        match *self {
15755            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
15756                "create_audio_consumer"
15757            }
15758            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15759                method_type: fidl::MethodType::OneWay,
15760                ..
15761            } => "unknown one-way method",
15762            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
15763                method_type: fidl::MethodType::TwoWay,
15764                ..
15765            } => "unknown two-way method",
15766        }
15767    }
15768}
15769
15770#[derive(Debug, Clone)]
15771pub struct Usage2AudioConsumerFactoryControlHandle {
15772    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15773}
15774
15775impl Usage2AudioConsumerFactoryControlHandle {
15776    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
15777        self.inner.shutdown_with_epitaph(status.into())
15778    }
15779}
15780
15781impl fdomain_client::fidl::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
15782    fn shutdown(&self) {
15783        self.inner.shutdown()
15784    }
15785
15786    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
15787        self.inner.shutdown_with_epitaph(status)
15788    }
15789
15790    fn is_closed(&self) -> bool {
15791        self.inner.channel().is_closed()
15792    }
15793    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
15794        self.inner.channel().on_closed()
15795    }
15796}
15797
15798impl Usage2AudioConsumerFactoryControlHandle {}
15799
15800#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15801pub struct UsageAudioConsumerFactoryMarker;
15802
15803impl fdomain_client::fidl::ProtocolMarker for UsageAudioConsumerFactoryMarker {
15804    type Proxy = UsageAudioConsumerFactoryProxy;
15805    type RequestStream = UsageAudioConsumerFactoryRequestStream;
15806
15807    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
15808}
15809impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
15810
15811pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
15812    fn r#create_audio_consumer(
15813        &self,
15814        usage: AudioRenderUsage,
15815        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15816    ) -> Result<(), fidl::Error>;
15817}
15818
15819#[derive(Debug, Clone)]
15820pub struct UsageAudioConsumerFactoryProxy {
15821    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
15822}
15823
15824impl fdomain_client::fidl::Proxy for UsageAudioConsumerFactoryProxy {
15825    type Protocol = UsageAudioConsumerFactoryMarker;
15826
15827    fn from_channel(inner: fdomain_client::Channel) -> Self {
15828        Self::new(inner)
15829    }
15830
15831    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
15832        self.client.into_channel().map_err(|client| Self { client })
15833    }
15834
15835    fn as_channel(&self) -> &fdomain_client::Channel {
15836        self.client.as_channel()
15837    }
15838}
15839
15840impl UsageAudioConsumerFactoryProxy {
15841    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
15842    pub fn new(channel: fdomain_client::Channel) -> Self {
15843        let protocol_name =
15844            <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
15845        Self { client: fidl::client::Client::new(channel, protocol_name) }
15846    }
15847
15848    /// Get a Stream of events from the remote end of the protocol.
15849    ///
15850    /// # Panics
15851    ///
15852    /// Panics if the event stream was already taken.
15853    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
15854        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
15855    }
15856
15857    pub fn r#create_audio_consumer(
15858        &self,
15859        mut usage: AudioRenderUsage,
15860        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15861    ) -> Result<(), fidl::Error> {
15862        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
15863            self,
15864            usage,
15865            audio_consumer_request,
15866        )
15867    }
15868}
15869
15870impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
15871    fn r#create_audio_consumer(
15872        &self,
15873        mut usage: AudioRenderUsage,
15874        mut audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
15875    ) -> Result<(), fidl::Error> {
15876        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
15877            (usage, audio_consumer_request),
15878            0x4d975ca9b8f625a3,
15879            fidl::encoding::DynamicFlags::empty(),
15880        )
15881    }
15882}
15883
15884pub struct UsageAudioConsumerFactoryEventStream {
15885    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
15886}
15887
15888impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
15889
15890impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
15891    fn is_terminated(&self) -> bool {
15892        self.event_receiver.is_terminated()
15893    }
15894}
15895
15896impl futures::Stream for UsageAudioConsumerFactoryEventStream {
15897    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
15898
15899    fn poll_next(
15900        mut self: std::pin::Pin<&mut Self>,
15901        cx: &mut std::task::Context<'_>,
15902    ) -> std::task::Poll<Option<Self::Item>> {
15903        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15904            &mut self.event_receiver,
15905            cx
15906        )?) {
15907            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
15908            None => std::task::Poll::Ready(None),
15909        }
15910    }
15911}
15912
15913#[derive(Debug)]
15914pub enum UsageAudioConsumerFactoryEvent {}
15915
15916impl UsageAudioConsumerFactoryEvent {
15917    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
15918    fn decode(
15919        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
15920    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
15921        let (bytes, _handles) = buf.split_mut();
15922        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
15923        debug_assert_eq!(tx_header.tx_id, 0);
15924        match tx_header.ordinal {
15925            _ => Err(fidl::Error::UnknownOrdinal {
15926                ordinal: tx_header.ordinal,
15927                protocol_name: <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
15928            })
15929        }
15930    }
15931}
15932
15933/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
15934pub struct UsageAudioConsumerFactoryRequestStream {
15935    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15936    is_terminated: bool,
15937}
15938
15939impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
15940
15941impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
15942    fn is_terminated(&self) -> bool {
15943        self.is_terminated
15944    }
15945}
15946
15947impl fdomain_client::fidl::RequestStream for UsageAudioConsumerFactoryRequestStream {
15948    type Protocol = UsageAudioConsumerFactoryMarker;
15949    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
15950
15951    fn from_channel(channel: fdomain_client::Channel) -> Self {
15952        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
15953    }
15954
15955    fn control_handle(&self) -> Self::ControlHandle {
15956        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
15957    }
15958
15959    fn into_inner(
15960        self,
15961    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
15962    {
15963        (self.inner, self.is_terminated)
15964    }
15965
15966    fn from_inner(
15967        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
15968        is_terminated: bool,
15969    ) -> Self {
15970        Self { inner, is_terminated }
15971    }
15972}
15973
15974impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
15975    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
15976
15977    fn poll_next(
15978        mut self: std::pin::Pin<&mut Self>,
15979        cx: &mut std::task::Context<'_>,
15980    ) -> std::task::Poll<Option<Self::Item>> {
15981        let this = &mut *self;
15982        if this.inner.check_shutdown(cx) {
15983            this.is_terminated = true;
15984            return std::task::Poll::Ready(None);
15985        }
15986        if this.is_terminated {
15987            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
15988        }
15989        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
15990            |bytes, handles| {
15991                match this.inner.channel().read_etc(cx, bytes, handles) {
15992                    std::task::Poll::Ready(Ok(())) => {}
15993                    std::task::Poll::Pending => return std::task::Poll::Pending,
15994                    std::task::Poll::Ready(Err(None)) => {
15995                        this.is_terminated = true;
15996                        return std::task::Poll::Ready(None);
15997                    }
15998                    std::task::Poll::Ready(Err(Some(e))) => {
15999                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16000                            e.into(),
16001                        ))));
16002                    }
16003                }
16004
16005                // A message has been received from the channel
16006                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16007
16008                std::task::Poll::Ready(Some(match header.ordinal {
16009                0x4d975ca9b8f625a3 => {
16010                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16011                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect);
16012                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
16013                    let control_handle = UsageAudioConsumerFactoryControlHandle {
16014                        inner: this.inner.clone(),
16015                    };
16016                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
16017audio_consumer_request: req.audio_consumer_request,
16018
16019                        control_handle,
16020                    })
16021                }
16022                _ => Err(fidl::Error::UnknownOrdinal {
16023                    ordinal: header.ordinal,
16024                    protocol_name: <UsageAudioConsumerFactoryMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16025                }),
16026            }))
16027            },
16028        )
16029    }
16030}
16031
16032/// Interface for creating audio consumers for local rendering.
16033#[derive(Debug)]
16034pub enum UsageAudioConsumerFactoryRequest {
16035    CreateAudioConsumer {
16036        usage: AudioRenderUsage,
16037        audio_consumer_request: fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
16038        control_handle: UsageAudioConsumerFactoryControlHandle,
16039    },
16040}
16041
16042impl UsageAudioConsumerFactoryRequest {
16043    #[allow(irrefutable_let_patterns)]
16044    pub fn into_create_audio_consumer(
16045        self,
16046    ) -> Option<(
16047        AudioRenderUsage,
16048        fdomain_client::fidl::ServerEnd<AudioConsumerMarker>,
16049        UsageAudioConsumerFactoryControlHandle,
16050    )> {
16051        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
16052            usage,
16053            audio_consumer_request,
16054            control_handle,
16055        } = self
16056        {
16057            Some((usage, audio_consumer_request, control_handle))
16058        } else {
16059            None
16060        }
16061    }
16062
16063    /// Name of the method defined in FIDL
16064    pub fn method_name(&self) -> &'static str {
16065        match *self {
16066            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
16067        }
16068    }
16069}
16070
16071#[derive(Debug, Clone)]
16072pub struct UsageAudioConsumerFactoryControlHandle {
16073    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16074}
16075
16076impl UsageAudioConsumerFactoryControlHandle {
16077    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
16078        self.inner.shutdown_with_epitaph(status.into())
16079    }
16080}
16081
16082impl fdomain_client::fidl::ControlHandle for UsageAudioConsumerFactoryControlHandle {
16083    fn shutdown(&self) {
16084        self.inner.shutdown()
16085    }
16086
16087    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
16088        self.inner.shutdown_with_epitaph(status)
16089    }
16090
16091    fn is_closed(&self) -> bool {
16092        self.inner.channel().is_closed()
16093    }
16094    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16095        self.inner.channel().on_closed()
16096    }
16097}
16098
16099impl UsageAudioConsumerFactoryControlHandle {}
16100
16101#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16102pub struct UsageGainListenerMarker;
16103
16104impl fdomain_client::fidl::ProtocolMarker for UsageGainListenerMarker {
16105    type Proxy = UsageGainListenerProxy;
16106    type RequestStream = UsageGainListenerRequestStream;
16107
16108    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
16109}
16110
16111pub trait UsageGainListenerProxyInterface: Send + Sync {
16112    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
16113    fn r#on_gain_mute_changed(
16114        &self,
16115        muted: bool,
16116        gain_dbfs: f32,
16117    ) -> Self::OnGainMuteChangedResponseFut;
16118}
16119
16120#[derive(Debug, Clone)]
16121pub struct UsageGainListenerProxy {
16122    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16123}
16124
16125impl fdomain_client::fidl::Proxy for UsageGainListenerProxy {
16126    type Protocol = UsageGainListenerMarker;
16127
16128    fn from_channel(inner: fdomain_client::Channel) -> Self {
16129        Self::new(inner)
16130    }
16131
16132    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
16133        self.client.into_channel().map_err(|client| Self { client })
16134    }
16135
16136    fn as_channel(&self) -> &fdomain_client::Channel {
16137        self.client.as_channel()
16138    }
16139}
16140
16141impl UsageGainListenerProxy {
16142    /// Create a new Proxy for fuchsia.media/UsageGainListener.
16143    pub fn new(channel: fdomain_client::Channel) -> Self {
16144        let protocol_name =
16145            <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
16146        Self { client: fidl::client::Client::new(channel, protocol_name) }
16147    }
16148
16149    /// Get a Stream of events from the remote end of the protocol.
16150    ///
16151    /// # Panics
16152    ///
16153    /// Panics if the event stream was already taken.
16154    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
16155        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
16156    }
16157
16158    /// Called immediately on connection and afterward any time
16159    /// the usage gain setting changes.
16160    ///
16161    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
16162    /// events will eventually be disconnected.
16163    ///
16164    /// Note: This API does not have mute reporting implemented; `muted` is always false.
16165    pub fn r#on_gain_mute_changed(
16166        &self,
16167        mut muted: bool,
16168        mut gain_dbfs: f32,
16169    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
16170        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
16171    }
16172}
16173
16174impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
16175    type OnGainMuteChangedResponseFut =
16176        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
16177    fn r#on_gain_mute_changed(
16178        &self,
16179        mut muted: bool,
16180        mut gain_dbfs: f32,
16181    ) -> Self::OnGainMuteChangedResponseFut {
16182        fn _decode(
16183            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
16184        ) -> Result<(), fidl::Error> {
16185            let _response = fidl::client::decode_transaction_body::<
16186                fidl::encoding::EmptyPayload,
16187                fdomain_client::fidl::FDomainResourceDialect,
16188                0x681570258eac3a8d,
16189            >(_buf?)?;
16190            Ok(_response)
16191        }
16192        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
16193            (muted, gain_dbfs),
16194            0x681570258eac3a8d,
16195            fidl::encoding::DynamicFlags::empty(),
16196            _decode,
16197        )
16198    }
16199}
16200
16201pub struct UsageGainListenerEventStream {
16202    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
16203}
16204
16205impl std::marker::Unpin for UsageGainListenerEventStream {}
16206
16207impl futures::stream::FusedStream for UsageGainListenerEventStream {
16208    fn is_terminated(&self) -> bool {
16209        self.event_receiver.is_terminated()
16210    }
16211}
16212
16213impl futures::Stream for UsageGainListenerEventStream {
16214    type Item = Result<UsageGainListenerEvent, fidl::Error>;
16215
16216    fn poll_next(
16217        mut self: std::pin::Pin<&mut Self>,
16218        cx: &mut std::task::Context<'_>,
16219    ) -> std::task::Poll<Option<Self::Item>> {
16220        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16221            &mut self.event_receiver,
16222            cx
16223        )?) {
16224            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
16225            None => std::task::Poll::Ready(None),
16226        }
16227    }
16228}
16229
16230#[derive(Debug)]
16231pub enum UsageGainListenerEvent {}
16232
16233impl UsageGainListenerEvent {
16234    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
16235    fn decode(
16236        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16237    ) -> Result<UsageGainListenerEvent, fidl::Error> {
16238        let (bytes, _handles) = buf.split_mut();
16239        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16240        debug_assert_eq!(tx_header.tx_id, 0);
16241        match tx_header.ordinal {
16242            _ => Err(fidl::Error::UnknownOrdinal {
16243                ordinal: tx_header.ordinal,
16244                protocol_name:
16245                    <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16246            }),
16247        }
16248    }
16249}
16250
16251/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
16252pub struct UsageGainListenerRequestStream {
16253    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16254    is_terminated: bool,
16255}
16256
16257impl std::marker::Unpin for UsageGainListenerRequestStream {}
16258
16259impl futures::stream::FusedStream for UsageGainListenerRequestStream {
16260    fn is_terminated(&self) -> bool {
16261        self.is_terminated
16262    }
16263}
16264
16265impl fdomain_client::fidl::RequestStream for UsageGainListenerRequestStream {
16266    type Protocol = UsageGainListenerMarker;
16267    type ControlHandle = UsageGainListenerControlHandle;
16268
16269    fn from_channel(channel: fdomain_client::Channel) -> Self {
16270        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16271    }
16272
16273    fn control_handle(&self) -> Self::ControlHandle {
16274        UsageGainListenerControlHandle { inner: self.inner.clone() }
16275    }
16276
16277    fn into_inner(
16278        self,
16279    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
16280    {
16281        (self.inner, self.is_terminated)
16282    }
16283
16284    fn from_inner(
16285        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16286        is_terminated: bool,
16287    ) -> Self {
16288        Self { inner, is_terminated }
16289    }
16290}
16291
16292impl futures::Stream for UsageGainListenerRequestStream {
16293    type Item = Result<UsageGainListenerRequest, fidl::Error>;
16294
16295    fn poll_next(
16296        mut self: std::pin::Pin<&mut Self>,
16297        cx: &mut std::task::Context<'_>,
16298    ) -> std::task::Poll<Option<Self::Item>> {
16299        let this = &mut *self;
16300        if this.inner.check_shutdown(cx) {
16301            this.is_terminated = true;
16302            return std::task::Poll::Ready(None);
16303        }
16304        if this.is_terminated {
16305            panic!("polled UsageGainListenerRequestStream after completion");
16306        }
16307        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
16308            |bytes, handles| {
16309                match this.inner.channel().read_etc(cx, bytes, handles) {
16310                    std::task::Poll::Ready(Ok(())) => {}
16311                    std::task::Poll::Pending => return std::task::Poll::Pending,
16312                    std::task::Poll::Ready(Err(None)) => {
16313                        this.is_terminated = true;
16314                        return std::task::Poll::Ready(None);
16315                    }
16316                    std::task::Poll::Ready(Err(Some(e))) => {
16317                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16318                            e.into(),
16319                        ))));
16320                    }
16321                }
16322
16323                // A message has been received from the channel
16324                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16325
16326                std::task::Poll::Ready(Some(match header.ordinal {
16327                0x681570258eac3a8d => {
16328                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16329                    let mut req = fidl::new_empty!(UsageGainListenerOnGainMuteChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
16330                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
16331                    let control_handle = UsageGainListenerControlHandle {
16332                        inner: this.inner.clone(),
16333                    };
16334                    Ok(UsageGainListenerRequest::OnGainMuteChanged {muted: req.muted,
16335gain_dbfs: req.gain_dbfs,
16336
16337                        responder: UsageGainListenerOnGainMuteChangedResponder {
16338                            control_handle: std::mem::ManuallyDrop::new(control_handle),
16339                            tx_id: header.tx_id,
16340                        },
16341                    })
16342                }
16343                _ => Err(fidl::Error::UnknownOrdinal {
16344                    ordinal: header.ordinal,
16345                    protocol_name: <UsageGainListenerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16346                }),
16347            }))
16348            },
16349        )
16350    }
16351}
16352
16353/// A protocol for watching changes to usage gain settings.
16354///
16355/// The channel will close when the device is not present.
16356#[derive(Debug)]
16357pub enum UsageGainListenerRequest {
16358    /// Called immediately on connection and afterward any time
16359    /// the usage gain setting changes.
16360    ///
16361    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
16362    /// events will eventually be disconnected.
16363    ///
16364    /// Note: This API does not have mute reporting implemented; `muted` is always false.
16365    OnGainMuteChanged {
16366        muted: bool,
16367        gain_dbfs: f32,
16368        responder: UsageGainListenerOnGainMuteChangedResponder,
16369    },
16370}
16371
16372impl UsageGainListenerRequest {
16373    #[allow(irrefutable_let_patterns)]
16374    pub fn into_on_gain_mute_changed(
16375        self,
16376    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
16377        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
16378            Some((muted, gain_dbfs, responder))
16379        } else {
16380            None
16381        }
16382    }
16383
16384    /// Name of the method defined in FIDL
16385    pub fn method_name(&self) -> &'static str {
16386        match *self {
16387            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
16388        }
16389    }
16390}
16391
16392#[derive(Debug, Clone)]
16393pub struct UsageGainListenerControlHandle {
16394    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16395}
16396
16397impl UsageGainListenerControlHandle {
16398    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
16399        self.inner.shutdown_with_epitaph(status.into())
16400    }
16401}
16402
16403impl fdomain_client::fidl::ControlHandle for UsageGainListenerControlHandle {
16404    fn shutdown(&self) {
16405        self.inner.shutdown()
16406    }
16407
16408    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
16409        self.inner.shutdown_with_epitaph(status)
16410    }
16411
16412    fn is_closed(&self) -> bool {
16413        self.inner.channel().is_closed()
16414    }
16415    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16416        self.inner.channel().on_closed()
16417    }
16418}
16419
16420impl UsageGainListenerControlHandle {}
16421
16422#[must_use = "FIDL methods require a response to be sent"]
16423#[derive(Debug)]
16424pub struct UsageGainListenerOnGainMuteChangedResponder {
16425    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
16426    tx_id: u32,
16427}
16428
16429/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
16430/// if the responder is dropped without sending a response, so that the client
16431/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
16432impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
16433    fn drop(&mut self) {
16434        self.control_handle.shutdown();
16435        // Safety: drops once, never accessed again
16436        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16437    }
16438}
16439
16440impl fdomain_client::fidl::Responder for UsageGainListenerOnGainMuteChangedResponder {
16441    type ControlHandle = UsageGainListenerControlHandle;
16442
16443    fn control_handle(&self) -> &UsageGainListenerControlHandle {
16444        &self.control_handle
16445    }
16446
16447    fn drop_without_shutdown(mut self) {
16448        // Safety: drops once, never accessed again due to mem::forget
16449        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
16450        // Prevent Drop from running (which would shut down the channel)
16451        std::mem::forget(self);
16452    }
16453}
16454
16455impl UsageGainListenerOnGainMuteChangedResponder {
16456    /// Sends a response to the FIDL transaction.
16457    ///
16458    /// Sets the channel to shutdown if an error occurs.
16459    pub fn send(self) -> Result<(), fidl::Error> {
16460        let _result = self.send_raw();
16461        if _result.is_err() {
16462            self.control_handle.shutdown();
16463        }
16464        self.drop_without_shutdown();
16465        _result
16466    }
16467
16468    /// Similar to "send" but does not shutdown the channel if an error occurs.
16469    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
16470        let _result = self.send_raw();
16471        self.drop_without_shutdown();
16472        _result
16473    }
16474
16475    fn send_raw(&self) -> Result<(), fidl::Error> {
16476        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
16477            (),
16478            self.tx_id,
16479            0x681570258eac3a8d,
16480            fidl::encoding::DynamicFlags::empty(),
16481        )
16482    }
16483}
16484
16485#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16486pub struct UsageGainReporterMarker;
16487
16488impl fdomain_client::fidl::ProtocolMarker for UsageGainReporterMarker {
16489    type Proxy = UsageGainReporterProxy;
16490    type RequestStream = UsageGainReporterRequestStream;
16491
16492    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
16493}
16494impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageGainReporterMarker {}
16495
16496pub trait UsageGainReporterProxyInterface: Send + Sync {
16497    fn r#register_listener(
16498        &self,
16499        device_unique_id: &str,
16500        usage: &Usage,
16501        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16502    ) -> Result<(), fidl::Error>;
16503    fn r#register_listener2(
16504        &self,
16505        device_unique_id: &str,
16506        usage: &Usage2,
16507        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16508    ) -> Result<(), fidl::Error>;
16509}
16510
16511#[derive(Debug, Clone)]
16512pub struct UsageGainReporterProxy {
16513    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16514}
16515
16516impl fdomain_client::fidl::Proxy for UsageGainReporterProxy {
16517    type Protocol = UsageGainReporterMarker;
16518
16519    fn from_channel(inner: fdomain_client::Channel) -> Self {
16520        Self::new(inner)
16521    }
16522
16523    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
16524        self.client.into_channel().map_err(|client| Self { client })
16525    }
16526
16527    fn as_channel(&self) -> &fdomain_client::Channel {
16528        self.client.as_channel()
16529    }
16530}
16531
16532impl UsageGainReporterProxy {
16533    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
16534    pub fn new(channel: fdomain_client::Channel) -> Self {
16535        let protocol_name =
16536            <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
16537        Self { client: fidl::client::Client::new(channel, protocol_name) }
16538    }
16539
16540    /// Get a Stream of events from the remote end of the protocol.
16541    ///
16542    /// # Panics
16543    ///
16544    /// Panics if the event stream was already taken.
16545    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
16546        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
16547    }
16548
16549    /// Connects a listener to a stream of usage gain setting changes
16550    /// for `usage` on the device identified by `device_token`. Usage
16551    /// Gain is not set directly by any client; it is a translation of
16552    /// the usage volume setting for each device, summed with active
16553    /// muting/ducking gain adjustments.
16554    ///
16555    /// Devices may map the same volume level to different dbfs, so
16556    /// a `device_unique_id` is needed to identify the device.
16557    ///
16558    /// `AudioDeviceEnumerator` provides programmatic access to devices
16559    /// and their unique ids if it is necessary for a client to select
16560    /// an id at runtime.
16561    pub fn r#register_listener(
16562        &self,
16563        mut device_unique_id: &str,
16564        mut usage: &Usage,
16565        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16566    ) -> Result<(), fidl::Error> {
16567        UsageGainReporterProxyInterface::r#register_listener(
16568            self,
16569            device_unique_id,
16570            usage,
16571            usage_gain_listener,
16572        )
16573    }
16574
16575    /// Connects a listener to a stream of usage gain setting changes
16576    /// for `usage` on the device identified by `device_token`. Usage
16577    /// Gain is not set directly by any client; it is a translation of
16578    /// the usage volume setting for each device, summed with active
16579    /// muting/ducking gain adjustments.
16580    ///
16581    /// Devices may map the same volume level to different dbfs, so
16582    /// a `device_unique_id` is needed to identify the device.
16583    ///
16584    /// `AudioDeviceEnumerator` provides programmatic access to devices
16585    /// and their unique ids if it is necessary for a client to select
16586    /// an id at runtime.
16587    pub fn r#register_listener2(
16588        &self,
16589        mut device_unique_id: &str,
16590        mut usage: &Usage2,
16591        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16592    ) -> Result<(), fidl::Error> {
16593        UsageGainReporterProxyInterface::r#register_listener2(
16594            self,
16595            device_unique_id,
16596            usage,
16597            usage_gain_listener,
16598        )
16599    }
16600}
16601
16602impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
16603    fn r#register_listener(
16604        &self,
16605        mut device_unique_id: &str,
16606        mut usage: &Usage,
16607        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16608    ) -> Result<(), fidl::Error> {
16609        self.client.send::<UsageGainReporterRegisterListenerRequest>(
16610            (device_unique_id, usage, usage_gain_listener),
16611            0x767107c168c226af,
16612            fidl::encoding::DynamicFlags::empty(),
16613        )
16614    }
16615
16616    fn r#register_listener2(
16617        &self,
16618        mut device_unique_id: &str,
16619        mut usage: &Usage2,
16620        mut usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16621    ) -> Result<(), fidl::Error> {
16622        self.client.send::<UsageGainReporterRegisterListener2Request>(
16623            (device_unique_id, usage, usage_gain_listener),
16624            0x760a8e1c5873629c,
16625            fidl::encoding::DynamicFlags::FLEXIBLE,
16626        )
16627    }
16628}
16629
16630pub struct UsageGainReporterEventStream {
16631    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
16632}
16633
16634impl std::marker::Unpin for UsageGainReporterEventStream {}
16635
16636impl futures::stream::FusedStream for UsageGainReporterEventStream {
16637    fn is_terminated(&self) -> bool {
16638        self.event_receiver.is_terminated()
16639    }
16640}
16641
16642impl futures::Stream for UsageGainReporterEventStream {
16643    type Item = Result<UsageGainReporterEvent, fidl::Error>;
16644
16645    fn poll_next(
16646        mut self: std::pin::Pin<&mut Self>,
16647        cx: &mut std::task::Context<'_>,
16648    ) -> std::task::Poll<Option<Self::Item>> {
16649        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
16650            &mut self.event_receiver,
16651            cx
16652        )?) {
16653            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
16654            None => std::task::Poll::Ready(None),
16655        }
16656    }
16657}
16658
16659#[derive(Debug)]
16660pub enum UsageGainReporterEvent {
16661    #[non_exhaustive]
16662    _UnknownEvent {
16663        /// Ordinal of the event that was sent.
16664        ordinal: u64,
16665    },
16666}
16667
16668impl UsageGainReporterEvent {
16669    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
16670    fn decode(
16671        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16672    ) -> Result<UsageGainReporterEvent, fidl::Error> {
16673        let (bytes, _handles) = buf.split_mut();
16674        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16675        debug_assert_eq!(tx_header.tx_id, 0);
16676        match tx_header.ordinal {
16677            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16678                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
16679            }
16680            _ => Err(fidl::Error::UnknownOrdinal {
16681                ordinal: tx_header.ordinal,
16682                protocol_name:
16683                    <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16684            }),
16685        }
16686    }
16687}
16688
16689/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
16690pub struct UsageGainReporterRequestStream {
16691    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16692    is_terminated: bool,
16693}
16694
16695impl std::marker::Unpin for UsageGainReporterRequestStream {}
16696
16697impl futures::stream::FusedStream for UsageGainReporterRequestStream {
16698    fn is_terminated(&self) -> bool {
16699        self.is_terminated
16700    }
16701}
16702
16703impl fdomain_client::fidl::RequestStream for UsageGainReporterRequestStream {
16704    type Protocol = UsageGainReporterMarker;
16705    type ControlHandle = UsageGainReporterControlHandle;
16706
16707    fn from_channel(channel: fdomain_client::Channel) -> Self {
16708        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16709    }
16710
16711    fn control_handle(&self) -> Self::ControlHandle {
16712        UsageGainReporterControlHandle { inner: self.inner.clone() }
16713    }
16714
16715    fn into_inner(
16716        self,
16717    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
16718    {
16719        (self.inner, self.is_terminated)
16720    }
16721
16722    fn from_inner(
16723        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16724        is_terminated: bool,
16725    ) -> Self {
16726        Self { inner, is_terminated }
16727    }
16728}
16729
16730impl futures::Stream for UsageGainReporterRequestStream {
16731    type Item = Result<UsageGainReporterRequest, fidl::Error>;
16732
16733    fn poll_next(
16734        mut self: std::pin::Pin<&mut Self>,
16735        cx: &mut std::task::Context<'_>,
16736    ) -> std::task::Poll<Option<Self::Item>> {
16737        let this = &mut *self;
16738        if this.inner.check_shutdown(cx) {
16739            this.is_terminated = true;
16740            return std::task::Poll::Ready(None);
16741        }
16742        if this.is_terminated {
16743            panic!("polled UsageGainReporterRequestStream after completion");
16744        }
16745        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
16746            |bytes, handles| {
16747                match this.inner.channel().read_etc(cx, bytes, handles) {
16748                    std::task::Poll::Ready(Ok(())) => {}
16749                    std::task::Poll::Pending => return std::task::Poll::Pending,
16750                    std::task::Poll::Ready(Err(None)) => {
16751                        this.is_terminated = true;
16752                        return std::task::Poll::Ready(None);
16753                    }
16754                    std::task::Poll::Ready(Err(Some(e))) => {
16755                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16756                            e.into(),
16757                        ))));
16758                    }
16759                }
16760
16761                // A message has been received from the channel
16762                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16763
16764                std::task::Poll::Ready(Some(match header.ordinal {
16765                0x767107c168c226af => {
16766                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16767                    let mut req = fidl::new_empty!(UsageGainReporterRegisterListenerRequest, fdomain_client::fidl::FDomainResourceDialect);
16768                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
16769                    let control_handle = UsageGainReporterControlHandle {
16770                        inner: this.inner.clone(),
16771                    };
16772                    Ok(UsageGainReporterRequest::RegisterListener {device_unique_id: req.device_unique_id,
16773usage: req.usage,
16774usage_gain_listener: req.usage_gain_listener,
16775
16776                        control_handle,
16777                    })
16778                }
16779                0x760a8e1c5873629c => {
16780                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16781                    let mut req = fidl::new_empty!(UsageGainReporterRegisterListener2Request, fdomain_client::fidl::FDomainResourceDialect);
16782                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
16783                    let control_handle = UsageGainReporterControlHandle {
16784                        inner: this.inner.clone(),
16785                    };
16786                    Ok(UsageGainReporterRequest::RegisterListener2 {device_unique_id: req.device_unique_id,
16787usage: req.usage,
16788usage_gain_listener: req.usage_gain_listener,
16789
16790                        control_handle,
16791                    })
16792                }
16793                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16794                    Ok(UsageGainReporterRequest::_UnknownMethod {
16795                        ordinal: header.ordinal,
16796                        control_handle: UsageGainReporterControlHandle { inner: this.inner.clone() },
16797                        method_type: fidl::MethodType::OneWay,
16798                    })
16799                }
16800                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16801                    this.inner.send_framework_err(
16802                        fidl::encoding::FrameworkErr::UnknownMethod,
16803                        header.tx_id,
16804                        header.ordinal,
16805                        header.dynamic_flags(),
16806                        (bytes, handles),
16807                    )?;
16808                    Ok(UsageGainReporterRequest::_UnknownMethod {
16809                        ordinal: header.ordinal,
16810                        control_handle: UsageGainReporterControlHandle { inner: this.inner.clone() },
16811                        method_type: fidl::MethodType::TwoWay,
16812                    })
16813                }
16814                _ => Err(fidl::Error::UnknownOrdinal {
16815                    ordinal: header.ordinal,
16816                    protocol_name: <UsageGainReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
16817                }),
16818            }))
16819            },
16820        )
16821    }
16822}
16823
16824/// A protocol for setting up watchers of usage gain.
16825#[derive(Debug)]
16826pub enum UsageGainReporterRequest {
16827    /// Connects a listener to a stream of usage gain setting changes
16828    /// for `usage` on the device identified by `device_token`. Usage
16829    /// Gain is not set directly by any client; it is a translation of
16830    /// the usage volume setting for each device, summed with active
16831    /// muting/ducking gain adjustments.
16832    ///
16833    /// Devices may map the same volume level to different dbfs, so
16834    /// a `device_unique_id` is needed to identify the device.
16835    ///
16836    /// `AudioDeviceEnumerator` provides programmatic access to devices
16837    /// and their unique ids if it is necessary for a client to select
16838    /// an id at runtime.
16839    RegisterListener {
16840        device_unique_id: String,
16841        usage: Usage,
16842        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16843        control_handle: UsageGainReporterControlHandle,
16844    },
16845    /// Connects a listener to a stream of usage gain setting changes
16846    /// for `usage` on the device identified by `device_token`. Usage
16847    /// Gain is not set directly by any client; it is a translation of
16848    /// the usage volume setting for each device, summed with active
16849    /// muting/ducking gain adjustments.
16850    ///
16851    /// Devices may map the same volume level to different dbfs, so
16852    /// a `device_unique_id` is needed to identify the device.
16853    ///
16854    /// `AudioDeviceEnumerator` provides programmatic access to devices
16855    /// and their unique ids if it is necessary for a client to select
16856    /// an id at runtime.
16857    RegisterListener2 {
16858        device_unique_id: String,
16859        usage: Usage2,
16860        usage_gain_listener: fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16861        control_handle: UsageGainReporterControlHandle,
16862    },
16863    /// An interaction was received which does not match any known method.
16864    #[non_exhaustive]
16865    _UnknownMethod {
16866        /// Ordinal of the method that was called.
16867        ordinal: u64,
16868        control_handle: UsageGainReporterControlHandle,
16869        method_type: fidl::MethodType,
16870    },
16871}
16872
16873impl UsageGainReporterRequest {
16874    #[allow(irrefutable_let_patterns)]
16875    pub fn into_register_listener(
16876        self,
16877    ) -> Option<(
16878        String,
16879        Usage,
16880        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16881        UsageGainReporterControlHandle,
16882    )> {
16883        if let UsageGainReporterRequest::RegisterListener {
16884            device_unique_id,
16885            usage,
16886            usage_gain_listener,
16887            control_handle,
16888        } = self
16889        {
16890            Some((device_unique_id, usage, usage_gain_listener, control_handle))
16891        } else {
16892            None
16893        }
16894    }
16895
16896    #[allow(irrefutable_let_patterns)]
16897    pub fn into_register_listener2(
16898        self,
16899    ) -> Option<(
16900        String,
16901        Usage2,
16902        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
16903        UsageGainReporterControlHandle,
16904    )> {
16905        if let UsageGainReporterRequest::RegisterListener2 {
16906            device_unique_id,
16907            usage,
16908            usage_gain_listener,
16909            control_handle,
16910        } = self
16911        {
16912            Some((device_unique_id, usage, usage_gain_listener, control_handle))
16913        } else {
16914            None
16915        }
16916    }
16917
16918    /// Name of the method defined in FIDL
16919    pub fn method_name(&self) -> &'static str {
16920        match *self {
16921            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
16922            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
16923            UsageGainReporterRequest::_UnknownMethod {
16924                method_type: fidl::MethodType::OneWay,
16925                ..
16926            } => "unknown one-way method",
16927            UsageGainReporterRequest::_UnknownMethod {
16928                method_type: fidl::MethodType::TwoWay,
16929                ..
16930            } => "unknown two-way method",
16931        }
16932    }
16933}
16934
16935#[derive(Debug, Clone)]
16936pub struct UsageGainReporterControlHandle {
16937    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
16938}
16939
16940impl UsageGainReporterControlHandle {
16941    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
16942        self.inner.shutdown_with_epitaph(status.into())
16943    }
16944}
16945
16946impl fdomain_client::fidl::ControlHandle for UsageGainReporterControlHandle {
16947    fn shutdown(&self) {
16948        self.inner.shutdown()
16949    }
16950
16951    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
16952        self.inner.shutdown_with_epitaph(status)
16953    }
16954
16955    fn is_closed(&self) -> bool {
16956        self.inner.channel().is_closed()
16957    }
16958    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
16959        self.inner.channel().on_closed()
16960    }
16961}
16962
16963impl UsageGainReporterControlHandle {}
16964
16965#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
16966pub struct UsageReporterMarker;
16967
16968impl fdomain_client::fidl::ProtocolMarker for UsageReporterMarker {
16969    type Proxy = UsageReporterProxy;
16970    type RequestStream = UsageReporterRequestStream;
16971
16972    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
16973}
16974impl fdomain_client::fidl::DiscoverableProtocolMarker for UsageReporterMarker {}
16975
16976pub trait UsageReporterProxyInterface: Send + Sync {
16977    fn r#watch(
16978        &self,
16979        usage: &Usage,
16980        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
16981    ) -> Result<(), fidl::Error>;
16982    fn r#watch2(
16983        &self,
16984        usage: &Usage2,
16985        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
16986    ) -> Result<(), fidl::Error>;
16987}
16988
16989#[derive(Debug, Clone)]
16990pub struct UsageReporterProxy {
16991    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
16992}
16993
16994impl fdomain_client::fidl::Proxy for UsageReporterProxy {
16995    type Protocol = UsageReporterMarker;
16996
16997    fn from_channel(inner: fdomain_client::Channel) -> Self {
16998        Self::new(inner)
16999    }
17000
17001    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
17002        self.client.into_channel().map_err(|client| Self { client })
17003    }
17004
17005    fn as_channel(&self) -> &fdomain_client::Channel {
17006        self.client.as_channel()
17007    }
17008}
17009
17010impl UsageReporterProxy {
17011    /// Create a new Proxy for fuchsia.media/UsageReporter.
17012    pub fn new(channel: fdomain_client::Channel) -> Self {
17013        let protocol_name =
17014            <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
17015        Self { client: fidl::client::Client::new(channel, protocol_name) }
17016    }
17017
17018    /// Get a Stream of events from the remote end of the protocol.
17019    ///
17020    /// # Panics
17021    ///
17022    /// Panics if the event stream was already taken.
17023    pub fn take_event_stream(&self) -> UsageReporterEventStream {
17024        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
17025    }
17026
17027    pub fn r#watch(
17028        &self,
17029        mut usage: &Usage,
17030        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
17031    ) -> Result<(), fidl::Error> {
17032        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
17033    }
17034
17035    pub fn r#watch2(
17036        &self,
17037        mut usage: &Usage2,
17038        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
17039    ) -> Result<(), fidl::Error> {
17040        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
17041    }
17042}
17043
17044impl UsageReporterProxyInterface for UsageReporterProxy {
17045    fn r#watch(
17046        &self,
17047        mut usage: &Usage,
17048        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
17049    ) -> Result<(), fidl::Error> {
17050        self.client.send::<UsageReporterWatchRequest>(
17051            (usage, usage_watcher),
17052            0x769e6fb17075c959,
17053            fidl::encoding::DynamicFlags::empty(),
17054        )
17055    }
17056
17057    fn r#watch2(
17058        &self,
17059        mut usage: &Usage2,
17060        mut usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
17061    ) -> Result<(), fidl::Error> {
17062        self.client.send::<UsageReporterWatch2Request>(
17063            (usage, usage_watcher),
17064            0x4a43c4c82f5d8ce8,
17065            fidl::encoding::DynamicFlags::FLEXIBLE,
17066        )
17067    }
17068}
17069
17070pub struct UsageReporterEventStream {
17071    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
17072}
17073
17074impl std::marker::Unpin for UsageReporterEventStream {}
17075
17076impl futures::stream::FusedStream for UsageReporterEventStream {
17077    fn is_terminated(&self) -> bool {
17078        self.event_receiver.is_terminated()
17079    }
17080}
17081
17082impl futures::Stream for UsageReporterEventStream {
17083    type Item = Result<UsageReporterEvent, fidl::Error>;
17084
17085    fn poll_next(
17086        mut self: std::pin::Pin<&mut Self>,
17087        cx: &mut std::task::Context<'_>,
17088    ) -> std::task::Poll<Option<Self::Item>> {
17089        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17090            &mut self.event_receiver,
17091            cx
17092        )?) {
17093            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
17094            None => std::task::Poll::Ready(None),
17095        }
17096    }
17097}
17098
17099#[derive(Debug)]
17100pub enum UsageReporterEvent {
17101    #[non_exhaustive]
17102    _UnknownEvent {
17103        /// Ordinal of the event that was sent.
17104        ordinal: u64,
17105    },
17106}
17107
17108impl UsageReporterEvent {
17109    /// Decodes a message buffer as a [`UsageReporterEvent`].
17110    fn decode(
17111        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17112    ) -> Result<UsageReporterEvent, fidl::Error> {
17113        let (bytes, _handles) = buf.split_mut();
17114        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17115        debug_assert_eq!(tx_header.tx_id, 0);
17116        match tx_header.ordinal {
17117            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17118                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
17119            }
17120            _ => Err(fidl::Error::UnknownOrdinal {
17121                ordinal: tx_header.ordinal,
17122                protocol_name:
17123                    <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17124            }),
17125        }
17126    }
17127}
17128
17129/// A Stream of incoming requests for fuchsia.media/UsageReporter.
17130pub struct UsageReporterRequestStream {
17131    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17132    is_terminated: bool,
17133}
17134
17135impl std::marker::Unpin for UsageReporterRequestStream {}
17136
17137impl futures::stream::FusedStream for UsageReporterRequestStream {
17138    fn is_terminated(&self) -> bool {
17139        self.is_terminated
17140    }
17141}
17142
17143impl fdomain_client::fidl::RequestStream for UsageReporterRequestStream {
17144    type Protocol = UsageReporterMarker;
17145    type ControlHandle = UsageReporterControlHandle;
17146
17147    fn from_channel(channel: fdomain_client::Channel) -> Self {
17148        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17149    }
17150
17151    fn control_handle(&self) -> Self::ControlHandle {
17152        UsageReporterControlHandle { inner: self.inner.clone() }
17153    }
17154
17155    fn into_inner(
17156        self,
17157    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
17158    {
17159        (self.inner, self.is_terminated)
17160    }
17161
17162    fn from_inner(
17163        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17164        is_terminated: bool,
17165    ) -> Self {
17166        Self { inner, is_terminated }
17167    }
17168}
17169
17170impl futures::Stream for UsageReporterRequestStream {
17171    type Item = Result<UsageReporterRequest, fidl::Error>;
17172
17173    fn poll_next(
17174        mut self: std::pin::Pin<&mut Self>,
17175        cx: &mut std::task::Context<'_>,
17176    ) -> std::task::Poll<Option<Self::Item>> {
17177        let this = &mut *self;
17178        if this.inner.check_shutdown(cx) {
17179            this.is_terminated = true;
17180            return std::task::Poll::Ready(None);
17181        }
17182        if this.is_terminated {
17183            panic!("polled UsageReporterRequestStream after completion");
17184        }
17185        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
17186            |bytes, handles| {
17187                match this.inner.channel().read_etc(cx, bytes, handles) {
17188                    std::task::Poll::Ready(Ok(())) => {}
17189                    std::task::Poll::Pending => return std::task::Poll::Pending,
17190                    std::task::Poll::Ready(Err(None)) => {
17191                        this.is_terminated = true;
17192                        return std::task::Poll::Ready(None);
17193                    }
17194                    std::task::Poll::Ready(Err(Some(e))) => {
17195                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17196                            e.into(),
17197                        ))));
17198                    }
17199                }
17200
17201                // A message has been received from the channel
17202                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17203
17204                std::task::Poll::Ready(Some(match header.ordinal {
17205                0x769e6fb17075c959 => {
17206                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17207                    let mut req = fidl::new_empty!(UsageReporterWatchRequest, fdomain_client::fidl::FDomainResourceDialect);
17208                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
17209                    let control_handle = UsageReporterControlHandle {
17210                        inner: this.inner.clone(),
17211                    };
17212                    Ok(UsageReporterRequest::Watch {usage: req.usage,
17213usage_watcher: req.usage_watcher,
17214
17215                        control_handle,
17216                    })
17217                }
17218                0x4a43c4c82f5d8ce8 => {
17219                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
17220                    let mut req = fidl::new_empty!(UsageReporterWatch2Request, fdomain_client::fidl::FDomainResourceDialect);
17221                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
17222                    let control_handle = UsageReporterControlHandle {
17223                        inner: this.inner.clone(),
17224                    };
17225                    Ok(UsageReporterRequest::Watch2 {usage: req.usage,
17226usage_watcher: req.usage_watcher,
17227
17228                        control_handle,
17229                    })
17230                }
17231                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17232                    Ok(UsageReporterRequest::_UnknownMethod {
17233                        ordinal: header.ordinal,
17234                        control_handle: UsageReporterControlHandle { inner: this.inner.clone() },
17235                        method_type: fidl::MethodType::OneWay,
17236                    })
17237                }
17238                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
17239                    this.inner.send_framework_err(
17240                        fidl::encoding::FrameworkErr::UnknownMethod,
17241                        header.tx_id,
17242                        header.ordinal,
17243                        header.dynamic_flags(),
17244                        (bytes, handles),
17245                    )?;
17246                    Ok(UsageReporterRequest::_UnknownMethod {
17247                        ordinal: header.ordinal,
17248                        control_handle: UsageReporterControlHandle { inner: this.inner.clone() },
17249                        method_type: fidl::MethodType::TwoWay,
17250                    })
17251                }
17252                _ => Err(fidl::Error::UnknownOrdinal {
17253                    ordinal: header.ordinal,
17254                    protocol_name: <UsageReporterMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17255                }),
17256            }))
17257            },
17258        )
17259    }
17260}
17261
17262/// A protocol for setting up watchers of audio usages.
17263#[derive(Debug)]
17264pub enum UsageReporterRequest {
17265    Watch {
17266        usage: Usage,
17267        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
17268        control_handle: UsageReporterControlHandle,
17269    },
17270    Watch2 {
17271        usage: Usage2,
17272        usage_watcher: fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
17273        control_handle: UsageReporterControlHandle,
17274    },
17275    /// An interaction was received which does not match any known method.
17276    #[non_exhaustive]
17277    _UnknownMethod {
17278        /// Ordinal of the method that was called.
17279        ordinal: u64,
17280        control_handle: UsageReporterControlHandle,
17281        method_type: fidl::MethodType,
17282    },
17283}
17284
17285impl UsageReporterRequest {
17286    #[allow(irrefutable_let_patterns)]
17287    pub fn into_watch(
17288        self,
17289    ) -> Option<(
17290        Usage,
17291        fdomain_client::fidl::ClientEnd<UsageWatcherMarker>,
17292        UsageReporterControlHandle,
17293    )> {
17294        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
17295            Some((usage, usage_watcher, control_handle))
17296        } else {
17297            None
17298        }
17299    }
17300
17301    #[allow(irrefutable_let_patterns)]
17302    pub fn into_watch2(
17303        self,
17304    ) -> Option<(
17305        Usage2,
17306        fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>,
17307        UsageReporterControlHandle,
17308    )> {
17309        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
17310            Some((usage, usage_watcher, control_handle))
17311        } else {
17312            None
17313        }
17314    }
17315
17316    /// Name of the method defined in FIDL
17317    pub fn method_name(&self) -> &'static str {
17318        match *self {
17319            UsageReporterRequest::Watch { .. } => "watch",
17320            UsageReporterRequest::Watch2 { .. } => "watch2",
17321            UsageReporterRequest::_UnknownMethod {
17322                method_type: fidl::MethodType::OneWay, ..
17323            } => "unknown one-way method",
17324            UsageReporterRequest::_UnknownMethod {
17325                method_type: fidl::MethodType::TwoWay, ..
17326            } => "unknown two-way method",
17327        }
17328    }
17329}
17330
17331#[derive(Debug, Clone)]
17332pub struct UsageReporterControlHandle {
17333    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17334}
17335
17336impl UsageReporterControlHandle {
17337    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
17338        self.inner.shutdown_with_epitaph(status.into())
17339    }
17340}
17341
17342impl fdomain_client::fidl::ControlHandle for UsageReporterControlHandle {
17343    fn shutdown(&self) {
17344        self.inner.shutdown()
17345    }
17346
17347    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
17348        self.inner.shutdown_with_epitaph(status)
17349    }
17350
17351    fn is_closed(&self) -> bool {
17352        self.inner.channel().is_closed()
17353    }
17354    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
17355        self.inner.channel().on_closed()
17356    }
17357}
17358
17359impl UsageReporterControlHandle {}
17360
17361#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17362pub struct UsageWatcherMarker;
17363
17364impl fdomain_client::fidl::ProtocolMarker for UsageWatcherMarker {
17365    type Proxy = UsageWatcherProxy;
17366    type RequestStream = UsageWatcherRequestStream;
17367
17368    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
17369}
17370
17371pub trait UsageWatcherProxyInterface: Send + Sync {
17372    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17373    fn r#on_state_changed(
17374        &self,
17375        usage: &Usage,
17376        state: &UsageState,
17377    ) -> Self::OnStateChangedResponseFut;
17378}
17379
17380#[derive(Debug, Clone)]
17381pub struct UsageWatcherProxy {
17382    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
17383}
17384
17385impl fdomain_client::fidl::Proxy for UsageWatcherProxy {
17386    type Protocol = UsageWatcherMarker;
17387
17388    fn from_channel(inner: fdomain_client::Channel) -> Self {
17389        Self::new(inner)
17390    }
17391
17392    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
17393        self.client.into_channel().map_err(|client| Self { client })
17394    }
17395
17396    fn as_channel(&self) -> &fdomain_client::Channel {
17397        self.client.as_channel()
17398    }
17399}
17400
17401impl UsageWatcherProxy {
17402    /// Create a new Proxy for fuchsia.media/UsageWatcher.
17403    pub fn new(channel: fdomain_client::Channel) -> Self {
17404        let protocol_name =
17405            <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
17406        Self { client: fidl::client::Client::new(channel, protocol_name) }
17407    }
17408
17409    /// Get a Stream of events from the remote end of the protocol.
17410    ///
17411    /// # Panics
17412    ///
17413    /// Panics if the event stream was already taken.
17414    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
17415        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
17416    }
17417
17418    /// Called on first connection and whenever the watched usage changes. The provided
17419    /// usage will always be the bound usage; it is provided so that an implementation of
17420    /// this protocol may be bound to more than one usage.
17421    ///
17422    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17423    /// events will eventually be disconnected.
17424    pub fn r#on_state_changed(
17425        &self,
17426        mut usage: &Usage,
17427        mut state: &UsageState,
17428    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
17429        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
17430    }
17431}
17432
17433impl UsageWatcherProxyInterface for UsageWatcherProxy {
17434    type OnStateChangedResponseFut =
17435        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
17436    fn r#on_state_changed(
17437        &self,
17438        mut usage: &Usage,
17439        mut state: &UsageState,
17440    ) -> Self::OnStateChangedResponseFut {
17441        fn _decode(
17442            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
17443        ) -> Result<(), fidl::Error> {
17444            let _response = fidl::client::decode_transaction_body::<
17445                fidl::encoding::EmptyPayload,
17446                fdomain_client::fidl::FDomainResourceDialect,
17447                0x5b955c5768ec75c5,
17448            >(_buf?)?;
17449            Ok(_response)
17450        }
17451        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
17452            (usage, state),
17453            0x5b955c5768ec75c5,
17454            fidl::encoding::DynamicFlags::empty(),
17455            _decode,
17456        )
17457    }
17458}
17459
17460pub struct UsageWatcherEventStream {
17461    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
17462}
17463
17464impl std::marker::Unpin for UsageWatcherEventStream {}
17465
17466impl futures::stream::FusedStream for UsageWatcherEventStream {
17467    fn is_terminated(&self) -> bool {
17468        self.event_receiver.is_terminated()
17469    }
17470}
17471
17472impl futures::Stream for UsageWatcherEventStream {
17473    type Item = Result<UsageWatcherEvent, fidl::Error>;
17474
17475    fn poll_next(
17476        mut self: std::pin::Pin<&mut Self>,
17477        cx: &mut std::task::Context<'_>,
17478    ) -> std::task::Poll<Option<Self::Item>> {
17479        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17480            &mut self.event_receiver,
17481            cx
17482        )?) {
17483            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
17484            None => std::task::Poll::Ready(None),
17485        }
17486    }
17487}
17488
17489#[derive(Debug)]
17490pub enum UsageWatcherEvent {}
17491
17492impl UsageWatcherEvent {
17493    /// Decodes a message buffer as a [`UsageWatcherEvent`].
17494    fn decode(
17495        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17496    ) -> Result<UsageWatcherEvent, fidl::Error> {
17497        let (bytes, _handles) = buf.split_mut();
17498        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17499        debug_assert_eq!(tx_header.tx_id, 0);
17500        match tx_header.ordinal {
17501            _ => Err(fidl::Error::UnknownOrdinal {
17502                ordinal: tx_header.ordinal,
17503                protocol_name:
17504                    <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17505            }),
17506        }
17507    }
17508}
17509
17510/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
17511pub struct UsageWatcherRequestStream {
17512    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17513    is_terminated: bool,
17514}
17515
17516impl std::marker::Unpin for UsageWatcherRequestStream {}
17517
17518impl futures::stream::FusedStream for UsageWatcherRequestStream {
17519    fn is_terminated(&self) -> bool {
17520        self.is_terminated
17521    }
17522}
17523
17524impl fdomain_client::fidl::RequestStream for UsageWatcherRequestStream {
17525    type Protocol = UsageWatcherMarker;
17526    type ControlHandle = UsageWatcherControlHandle;
17527
17528    fn from_channel(channel: fdomain_client::Channel) -> Self {
17529        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17530    }
17531
17532    fn control_handle(&self) -> Self::ControlHandle {
17533        UsageWatcherControlHandle { inner: self.inner.clone() }
17534    }
17535
17536    fn into_inner(
17537        self,
17538    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
17539    {
17540        (self.inner, self.is_terminated)
17541    }
17542
17543    fn from_inner(
17544        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17545        is_terminated: bool,
17546    ) -> Self {
17547        Self { inner, is_terminated }
17548    }
17549}
17550
17551impl futures::Stream for UsageWatcherRequestStream {
17552    type Item = Result<UsageWatcherRequest, fidl::Error>;
17553
17554    fn poll_next(
17555        mut self: std::pin::Pin<&mut Self>,
17556        cx: &mut std::task::Context<'_>,
17557    ) -> std::task::Poll<Option<Self::Item>> {
17558        let this = &mut *self;
17559        if this.inner.check_shutdown(cx) {
17560            this.is_terminated = true;
17561            return std::task::Poll::Ready(None);
17562        }
17563        if this.is_terminated {
17564            panic!("polled UsageWatcherRequestStream after completion");
17565        }
17566        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
17567            |bytes, handles| {
17568                match this.inner.channel().read_etc(cx, bytes, handles) {
17569                    std::task::Poll::Ready(Ok(())) => {}
17570                    std::task::Poll::Pending => return std::task::Poll::Pending,
17571                    std::task::Poll::Ready(Err(None)) => {
17572                        this.is_terminated = true;
17573                        return std::task::Poll::Ready(None);
17574                    }
17575                    std::task::Poll::Ready(Err(Some(e))) => {
17576                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17577                            e.into(),
17578                        ))));
17579                    }
17580                }
17581
17582                // A message has been received from the channel
17583                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17584
17585                std::task::Poll::Ready(Some(match header.ordinal {
17586                    0x5b955c5768ec75c5 => {
17587                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
17588                        let mut req = fidl::new_empty!(
17589                            UsageWatcherOnStateChangedRequest,
17590                            fdomain_client::fidl::FDomainResourceDialect
17591                        );
17592                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
17593                        let control_handle =
17594                            UsageWatcherControlHandle { inner: this.inner.clone() };
17595                        Ok(UsageWatcherRequest::OnStateChanged {
17596                            usage: req.usage,
17597                            state: req.state,
17598
17599                            responder: UsageWatcherOnStateChangedResponder {
17600                                control_handle: std::mem::ManuallyDrop::new(control_handle),
17601                                tx_id: header.tx_id,
17602                            },
17603                        })
17604                    }
17605                    _ => Err(fidl::Error::UnknownOrdinal {
17606                        ordinal: header.ordinal,
17607                        protocol_name:
17608                            <UsageWatcherMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17609                    }),
17610                }))
17611            },
17612        )
17613    }
17614}
17615
17616/// A protocol for listening to changes to the policy state of an audio usage.
17617///
17618/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
17619#[derive(Debug)]
17620pub enum UsageWatcherRequest {
17621    /// Called on first connection and whenever the watched usage changes. The provided
17622    /// usage will always be the bound usage; it is provided so that an implementation of
17623    /// this protocol may be bound to more than one usage.
17624    ///
17625    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17626    /// events will eventually be disconnected.
17627    OnStateChanged {
17628        usage: Usage,
17629        state: UsageState,
17630        responder: UsageWatcherOnStateChangedResponder,
17631    },
17632}
17633
17634impl UsageWatcherRequest {
17635    #[allow(irrefutable_let_patterns)]
17636    pub fn into_on_state_changed(
17637        self,
17638    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
17639        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
17640            Some((usage, state, responder))
17641        } else {
17642            None
17643        }
17644    }
17645
17646    /// Name of the method defined in FIDL
17647    pub fn method_name(&self) -> &'static str {
17648        match *self {
17649            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
17650        }
17651    }
17652}
17653
17654#[derive(Debug, Clone)]
17655pub struct UsageWatcherControlHandle {
17656    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17657}
17658
17659impl UsageWatcherControlHandle {
17660    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
17661        self.inner.shutdown_with_epitaph(status.into())
17662    }
17663}
17664
17665impl fdomain_client::fidl::ControlHandle for UsageWatcherControlHandle {
17666    fn shutdown(&self) {
17667        self.inner.shutdown()
17668    }
17669
17670    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
17671        self.inner.shutdown_with_epitaph(status)
17672    }
17673
17674    fn is_closed(&self) -> bool {
17675        self.inner.channel().is_closed()
17676    }
17677    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
17678        self.inner.channel().on_closed()
17679    }
17680}
17681
17682impl UsageWatcherControlHandle {}
17683
17684#[must_use = "FIDL methods require a response to be sent"]
17685#[derive(Debug)]
17686pub struct UsageWatcherOnStateChangedResponder {
17687    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
17688    tx_id: u32,
17689}
17690
17691/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
17692/// if the responder is dropped without sending a response, so that the client
17693/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17694impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
17695    fn drop(&mut self) {
17696        self.control_handle.shutdown();
17697        // Safety: drops once, never accessed again
17698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17699    }
17700}
17701
17702impl fdomain_client::fidl::Responder for UsageWatcherOnStateChangedResponder {
17703    type ControlHandle = UsageWatcherControlHandle;
17704
17705    fn control_handle(&self) -> &UsageWatcherControlHandle {
17706        &self.control_handle
17707    }
17708
17709    fn drop_without_shutdown(mut self) {
17710        // Safety: drops once, never accessed again due to mem::forget
17711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17712        // Prevent Drop from running (which would shut down the channel)
17713        std::mem::forget(self);
17714    }
17715}
17716
17717impl UsageWatcherOnStateChangedResponder {
17718    /// Sends a response to the FIDL transaction.
17719    ///
17720    /// Sets the channel to shutdown if an error occurs.
17721    pub fn send(self) -> Result<(), fidl::Error> {
17722        let _result = self.send_raw();
17723        if _result.is_err() {
17724            self.control_handle.shutdown();
17725        }
17726        self.drop_without_shutdown();
17727        _result
17728    }
17729
17730    /// Similar to "send" but does not shutdown the channel if an error occurs.
17731    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17732        let _result = self.send_raw();
17733        self.drop_without_shutdown();
17734        _result
17735    }
17736
17737    fn send_raw(&self) -> Result<(), fidl::Error> {
17738        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17739            (),
17740            self.tx_id,
17741            0x5b955c5768ec75c5,
17742            fidl::encoding::DynamicFlags::empty(),
17743        )
17744    }
17745}
17746
17747#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17748pub struct UsageWatcher2Marker;
17749
17750impl fdomain_client::fidl::ProtocolMarker for UsageWatcher2Marker {
17751    type Proxy = UsageWatcher2Proxy;
17752    type RequestStream = UsageWatcher2RequestStream;
17753
17754    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
17755}
17756
17757pub trait UsageWatcher2ProxyInterface: Send + Sync {
17758    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17759    fn r#on_state_changed(
17760        &self,
17761        usage: &Usage2,
17762        state: &UsageState,
17763    ) -> Self::OnStateChangedResponseFut;
17764}
17765
17766#[derive(Debug, Clone)]
17767pub struct UsageWatcher2Proxy {
17768    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
17769}
17770
17771impl fdomain_client::fidl::Proxy for UsageWatcher2Proxy {
17772    type Protocol = UsageWatcher2Marker;
17773
17774    fn from_channel(inner: fdomain_client::Channel) -> Self {
17775        Self::new(inner)
17776    }
17777
17778    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
17779        self.client.into_channel().map_err(|client| Self { client })
17780    }
17781
17782    fn as_channel(&self) -> &fdomain_client::Channel {
17783        self.client.as_channel()
17784    }
17785}
17786
17787impl UsageWatcher2Proxy {
17788    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
17789    pub fn new(channel: fdomain_client::Channel) -> Self {
17790        let protocol_name =
17791            <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
17792        Self { client: fidl::client::Client::new(channel, protocol_name) }
17793    }
17794
17795    /// Get a Stream of events from the remote end of the protocol.
17796    ///
17797    /// # Panics
17798    ///
17799    /// Panics if the event stream was already taken.
17800    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
17801        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
17802    }
17803
17804    /// Called on first connection and whenever the watched usage changes. The provided
17805    /// usage will always be the bound usage; it is provided so that an implementation of
17806    /// this protocol may be bound to more than one usage.
17807    ///
17808    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
17809    /// events will eventually be disconnected.
17810    pub fn r#on_state_changed(
17811        &self,
17812        mut usage: &Usage2,
17813        mut state: &UsageState,
17814    ) -> fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect> {
17815        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
17816    }
17817}
17818
17819impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
17820    type OnStateChangedResponseFut =
17821        fidl::client::QueryResponseFut<(), fdomain_client::fidl::FDomainResourceDialect>;
17822    fn r#on_state_changed(
17823        &self,
17824        mut usage: &Usage2,
17825        mut state: &UsageState,
17826    ) -> Self::OnStateChangedResponseFut {
17827        fn _decode(
17828            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
17829        ) -> Result<(), fidl::Error> {
17830            let _response = fidl::client::decode_transaction_body::<
17831                fidl::encoding::EmptyPayload,
17832                fdomain_client::fidl::FDomainResourceDialect,
17833                0xca31a8b13c324d4,
17834            >(_buf?)?;
17835            Ok(_response)
17836        }
17837        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
17838            (usage, state),
17839            0xca31a8b13c324d4,
17840            fidl::encoding::DynamicFlags::empty(),
17841            _decode,
17842        )
17843    }
17844}
17845
17846pub struct UsageWatcher2EventStream {
17847    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
17848}
17849
17850impl std::marker::Unpin for UsageWatcher2EventStream {}
17851
17852impl futures::stream::FusedStream for UsageWatcher2EventStream {
17853    fn is_terminated(&self) -> bool {
17854        self.event_receiver.is_terminated()
17855    }
17856}
17857
17858impl futures::Stream for UsageWatcher2EventStream {
17859    type Item = Result<UsageWatcher2Event, fidl::Error>;
17860
17861    fn poll_next(
17862        mut self: std::pin::Pin<&mut Self>,
17863        cx: &mut std::task::Context<'_>,
17864    ) -> std::task::Poll<Option<Self::Item>> {
17865        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
17866            &mut self.event_receiver,
17867            cx
17868        )?) {
17869            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
17870            None => std::task::Poll::Ready(None),
17871        }
17872    }
17873}
17874
17875#[derive(Debug)]
17876pub enum UsageWatcher2Event {}
17877
17878impl UsageWatcher2Event {
17879    /// Decodes a message buffer as a [`UsageWatcher2Event`].
17880    fn decode(
17881        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
17882    ) -> Result<UsageWatcher2Event, fidl::Error> {
17883        let (bytes, _handles) = buf.split_mut();
17884        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17885        debug_assert_eq!(tx_header.tx_id, 0);
17886        match tx_header.ordinal {
17887            _ => Err(fidl::Error::UnknownOrdinal {
17888                ordinal: tx_header.ordinal,
17889                protocol_name:
17890                    <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17891            }),
17892        }
17893    }
17894}
17895
17896/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
17897pub struct UsageWatcher2RequestStream {
17898    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17899    is_terminated: bool,
17900}
17901
17902impl std::marker::Unpin for UsageWatcher2RequestStream {}
17903
17904impl futures::stream::FusedStream for UsageWatcher2RequestStream {
17905    fn is_terminated(&self) -> bool {
17906        self.is_terminated
17907    }
17908}
17909
17910impl fdomain_client::fidl::RequestStream for UsageWatcher2RequestStream {
17911    type Protocol = UsageWatcher2Marker;
17912    type ControlHandle = UsageWatcher2ControlHandle;
17913
17914    fn from_channel(channel: fdomain_client::Channel) -> Self {
17915        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
17916    }
17917
17918    fn control_handle(&self) -> Self::ControlHandle {
17919        UsageWatcher2ControlHandle { inner: self.inner.clone() }
17920    }
17921
17922    fn into_inner(
17923        self,
17924    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
17925    {
17926        (self.inner, self.is_terminated)
17927    }
17928
17929    fn from_inner(
17930        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
17931        is_terminated: bool,
17932    ) -> Self {
17933        Self { inner, is_terminated }
17934    }
17935}
17936
17937impl futures::Stream for UsageWatcher2RequestStream {
17938    type Item = Result<UsageWatcher2Request, fidl::Error>;
17939
17940    fn poll_next(
17941        mut self: std::pin::Pin<&mut Self>,
17942        cx: &mut std::task::Context<'_>,
17943    ) -> std::task::Poll<Option<Self::Item>> {
17944        let this = &mut *self;
17945        if this.inner.check_shutdown(cx) {
17946            this.is_terminated = true;
17947            return std::task::Poll::Ready(None);
17948        }
17949        if this.is_terminated {
17950            panic!("polled UsageWatcher2RequestStream after completion");
17951        }
17952        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
17953            |bytes, handles| {
17954                match this.inner.channel().read_etc(cx, bytes, handles) {
17955                    std::task::Poll::Ready(Ok(())) => {}
17956                    std::task::Poll::Pending => return std::task::Poll::Pending,
17957                    std::task::Poll::Ready(Err(None)) => {
17958                        this.is_terminated = true;
17959                        return std::task::Poll::Ready(None);
17960                    }
17961                    std::task::Poll::Ready(Err(Some(e))) => {
17962                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
17963                            e.into(),
17964                        ))));
17965                    }
17966                }
17967
17968                // A message has been received from the channel
17969                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
17970
17971                std::task::Poll::Ready(Some(match header.ordinal {
17972                0xca31a8b13c324d4 => {
17973                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
17974                    let mut req = fidl::new_empty!(UsageWatcher2OnStateChangedRequest, fdomain_client::fidl::FDomainResourceDialect);
17975                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
17976                    let control_handle = UsageWatcher2ControlHandle {
17977                        inner: this.inner.clone(),
17978                    };
17979                    Ok(UsageWatcher2Request::OnStateChanged {usage: req.usage,
17980state: req.state,
17981
17982                        responder: UsageWatcher2OnStateChangedResponder {
17983                            control_handle: std::mem::ManuallyDrop::new(control_handle),
17984                            tx_id: header.tx_id,
17985                        },
17986                    })
17987                }
17988                _ => Err(fidl::Error::UnknownOrdinal {
17989                    ordinal: header.ordinal,
17990                    protocol_name: <UsageWatcher2Marker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
17991                }),
17992            }))
17993            },
17994        )
17995    }
17996}
17997
17998#[derive(Debug)]
17999pub enum UsageWatcher2Request {
18000    /// Called on first connection and whenever the watched usage changes. The provided
18001    /// usage will always be the bound usage; it is provided so that an implementation of
18002    /// this protocol may be bound to more than one usage.
18003    ///
18004    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
18005    /// events will eventually be disconnected.
18006    OnStateChanged {
18007        usage: Usage2,
18008        state: UsageState,
18009        responder: UsageWatcher2OnStateChangedResponder,
18010    },
18011}
18012
18013impl UsageWatcher2Request {
18014    #[allow(irrefutable_let_patterns)]
18015    pub fn into_on_state_changed(
18016        self,
18017    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
18018        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
18019            Some((usage, state, responder))
18020        } else {
18021            None
18022        }
18023    }
18024
18025    /// Name of the method defined in FIDL
18026    pub fn method_name(&self) -> &'static str {
18027        match *self {
18028            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
18029        }
18030    }
18031}
18032
18033#[derive(Debug, Clone)]
18034pub struct UsageWatcher2ControlHandle {
18035    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
18036}
18037
18038impl UsageWatcher2ControlHandle {
18039    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
18040        self.inner.shutdown_with_epitaph(status.into())
18041    }
18042}
18043
18044impl fdomain_client::fidl::ControlHandle for UsageWatcher2ControlHandle {
18045    fn shutdown(&self) {
18046        self.inner.shutdown()
18047    }
18048
18049    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
18050        self.inner.shutdown_with_epitaph(status)
18051    }
18052
18053    fn is_closed(&self) -> bool {
18054        self.inner.channel().is_closed()
18055    }
18056    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
18057        self.inner.channel().on_closed()
18058    }
18059}
18060
18061impl UsageWatcher2ControlHandle {}
18062
18063#[must_use = "FIDL methods require a response to be sent"]
18064#[derive(Debug)]
18065pub struct UsageWatcher2OnStateChangedResponder {
18066    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
18067    tx_id: u32,
18068}
18069
18070/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
18071/// if the responder is dropped without sending a response, so that the client
18072/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18073impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
18074    fn drop(&mut self) {
18075        self.control_handle.shutdown();
18076        // Safety: drops once, never accessed again
18077        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18078    }
18079}
18080
18081impl fdomain_client::fidl::Responder for UsageWatcher2OnStateChangedResponder {
18082    type ControlHandle = UsageWatcher2ControlHandle;
18083
18084    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
18085        &self.control_handle
18086    }
18087
18088    fn drop_without_shutdown(mut self) {
18089        // Safety: drops once, never accessed again due to mem::forget
18090        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18091        // Prevent Drop from running (which would shut down the channel)
18092        std::mem::forget(self);
18093    }
18094}
18095
18096impl UsageWatcher2OnStateChangedResponder {
18097    /// Sends a response to the FIDL transaction.
18098    ///
18099    /// Sets the channel to shutdown if an error occurs.
18100    pub fn send(self) -> Result<(), fidl::Error> {
18101        let _result = self.send_raw();
18102        if _result.is_err() {
18103            self.control_handle.shutdown();
18104        }
18105        self.drop_without_shutdown();
18106        _result
18107    }
18108
18109    /// Similar to "send" but does not shutdown the channel if an error occurs.
18110    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18111        let _result = self.send_raw();
18112        self.drop_without_shutdown();
18113        _result
18114    }
18115
18116    fn send_raw(&self) -> Result<(), fidl::Error> {
18117        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18118            (),
18119            self.tx_id,
18120            0xca31a8b13c324d4,
18121            fidl::encoding::DynamicFlags::empty(),
18122        )
18123    }
18124}
18125
18126mod internal {
18127    use super::*;
18128
18129    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
18130        type Borrowed<'a> = &'a mut Self;
18131        fn take_or_borrow<'a>(
18132            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18133        ) -> Self::Borrowed<'a> {
18134            value
18135        }
18136    }
18137
18138    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
18139        type Owned = Self;
18140
18141        #[inline(always)]
18142        fn inline_align(_context: fidl::encoding::Context) -> usize {
18143            4
18144        }
18145
18146        #[inline(always)]
18147        fn inline_size(_context: fidl::encoding::Context) -> usize {
18148            4
18149        }
18150    }
18151
18152    unsafe impl
18153        fidl::encoding::Encode<
18154            AudioCapturerBindGainControlRequest,
18155            fdomain_client::fidl::FDomainResourceDialect,
18156        > for &mut AudioCapturerBindGainControlRequest
18157    {
18158        #[inline]
18159        unsafe fn encode(
18160            self,
18161            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18162            offset: usize,
18163            _depth: fidl::encoding::Depth,
18164        ) -> fidl::Result<()> {
18165            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
18166            // Delegate to tuple encoding.
18167            fidl::encoding::Encode::<
18168                AudioCapturerBindGainControlRequest,
18169                fdomain_client::fidl::FDomainResourceDialect,
18170            >::encode(
18171                (<fidl::encoding::Endpoint<
18172                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18173                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18174                    &mut self.gain_control_request,
18175                ),),
18176                encoder,
18177                offset,
18178                _depth,
18179            )
18180        }
18181    }
18182    unsafe impl<
18183        T0: fidl::encoding::Encode<
18184                fidl::encoding::Endpoint<
18185                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18186                >,
18187                fdomain_client::fidl::FDomainResourceDialect,
18188            >,
18189    >
18190        fidl::encoding::Encode<
18191            AudioCapturerBindGainControlRequest,
18192            fdomain_client::fidl::FDomainResourceDialect,
18193        > for (T0,)
18194    {
18195        #[inline]
18196        unsafe fn encode(
18197            self,
18198            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18199            offset: usize,
18200            depth: fidl::encoding::Depth,
18201        ) -> fidl::Result<()> {
18202            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
18203            // Zero out padding regions. There's no need to apply masks
18204            // because the unmasked parts will be overwritten by fields.
18205            // Write the fields.
18206            self.0.encode(encoder, offset + 0, depth)?;
18207            Ok(())
18208        }
18209    }
18210
18211    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18212        for AudioCapturerBindGainControlRequest
18213    {
18214        #[inline(always)]
18215        fn new_empty() -> Self {
18216            Self {
18217                gain_control_request: fidl::new_empty!(
18218                    fidl::encoding::Endpoint<
18219                        fdomain_client::fidl::ServerEnd<
18220                            fdomain_fuchsia_media_audio::GainControlMarker,
18221                        >,
18222                    >,
18223                    fdomain_client::fidl::FDomainResourceDialect
18224                ),
18225            }
18226        }
18227
18228        #[inline]
18229        unsafe fn decode(
18230            &mut self,
18231            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18232            offset: usize,
18233            _depth: fidl::encoding::Depth,
18234        ) -> fidl::Result<()> {
18235            decoder.debug_check_bounds::<Self>(offset);
18236            // Verify that padding bytes are zero.
18237            fidl::decode!(
18238                fidl::encoding::Endpoint<
18239                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
18240                >,
18241                fdomain_client::fidl::FDomainResourceDialect,
18242                &mut self.gain_control_request,
18243                decoder,
18244                offset + 0,
18245                _depth
18246            )?;
18247            Ok(())
18248        }
18249    }
18250
18251    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
18252        type Borrowed<'a> = &'a mut Self;
18253        fn take_or_borrow<'a>(
18254            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18255        ) -> Self::Borrowed<'a> {
18256            value
18257        }
18258    }
18259
18260    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
18261        type Owned = Self;
18262
18263        #[inline(always)]
18264        fn inline_align(_context: fidl::encoding::Context) -> usize {
18265            4
18266        }
18267
18268        #[inline(always)]
18269        fn inline_size(_context: fidl::encoding::Context) -> usize {
18270            4
18271        }
18272    }
18273
18274    unsafe impl
18275        fidl::encoding::Encode<
18276            AudioCapturerGetReferenceClockResponse,
18277            fdomain_client::fidl::FDomainResourceDialect,
18278        > for &mut AudioCapturerGetReferenceClockResponse
18279    {
18280        #[inline]
18281        unsafe fn encode(
18282            self,
18283            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18284            offset: usize,
18285            _depth: fidl::encoding::Depth,
18286        ) -> fidl::Result<()> {
18287            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
18288            // Delegate to tuple encoding.
18289            fidl::encoding::Encode::<
18290                AudioCapturerGetReferenceClockResponse,
18291                fdomain_client::fidl::FDomainResourceDialect,
18292            >::encode(
18293                (<fidl::encoding::HandleType<
18294                    fdomain_client::Clock,
18295                    { fidl::ObjectType::CLOCK.into_raw() },
18296                    2147483648,
18297                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18298                    &mut self.reference_clock,
18299                ),),
18300                encoder,
18301                offset,
18302                _depth,
18303            )
18304        }
18305    }
18306    unsafe impl<
18307        T0: fidl::encoding::Encode<
18308                fidl::encoding::HandleType<
18309                    fdomain_client::Clock,
18310                    { fidl::ObjectType::CLOCK.into_raw() },
18311                    2147483648,
18312                >,
18313                fdomain_client::fidl::FDomainResourceDialect,
18314            >,
18315    >
18316        fidl::encoding::Encode<
18317            AudioCapturerGetReferenceClockResponse,
18318            fdomain_client::fidl::FDomainResourceDialect,
18319        > for (T0,)
18320    {
18321        #[inline]
18322        unsafe fn encode(
18323            self,
18324            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18325            offset: usize,
18326            depth: fidl::encoding::Depth,
18327        ) -> fidl::Result<()> {
18328            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
18329            // Zero out padding regions. There's no need to apply masks
18330            // because the unmasked parts will be overwritten by fields.
18331            // Write the fields.
18332            self.0.encode(encoder, offset + 0, depth)?;
18333            Ok(())
18334        }
18335    }
18336
18337    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18338        for AudioCapturerGetReferenceClockResponse
18339    {
18340        #[inline(always)]
18341        fn new_empty() -> Self {
18342            Self {
18343                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
18344            }
18345        }
18346
18347        #[inline]
18348        unsafe fn decode(
18349            &mut self,
18350            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18351            offset: usize,
18352            _depth: fidl::encoding::Depth,
18353        ) -> fidl::Result<()> {
18354            decoder.debug_check_bounds::<Self>(offset);
18355            // Verify that padding bytes are zero.
18356            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
18357            Ok(())
18358        }
18359    }
18360
18361    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
18362        type Borrowed<'a> = &'a mut Self;
18363        fn take_or_borrow<'a>(
18364            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18365        ) -> Self::Borrowed<'a> {
18366            value
18367        }
18368    }
18369
18370    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
18371        type Owned = Self;
18372
18373        #[inline(always)]
18374        fn inline_align(_context: fidl::encoding::Context) -> usize {
18375            4
18376        }
18377
18378        #[inline(always)]
18379        fn inline_size(_context: fidl::encoding::Context) -> usize {
18380            4
18381        }
18382    }
18383
18384    unsafe impl
18385        fidl::encoding::Encode<
18386            AudioCapturerSetReferenceClockRequest,
18387            fdomain_client::fidl::FDomainResourceDialect,
18388        > for &mut AudioCapturerSetReferenceClockRequest
18389    {
18390        #[inline]
18391        unsafe fn encode(
18392            self,
18393            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18394            offset: usize,
18395            _depth: fidl::encoding::Depth,
18396        ) -> fidl::Result<()> {
18397            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
18398            // Delegate to tuple encoding.
18399            fidl::encoding::Encode::<
18400                AudioCapturerSetReferenceClockRequest,
18401                fdomain_client::fidl::FDomainResourceDialect,
18402            >::encode(
18403                (<fidl::encoding::Optional<
18404                    fidl::encoding::HandleType<
18405                        fdomain_client::Clock,
18406                        { fidl::ObjectType::CLOCK.into_raw() },
18407                        2147483648,
18408                    >,
18409                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18410                    &mut self.reference_clock,
18411                ),),
18412                encoder,
18413                offset,
18414                _depth,
18415            )
18416        }
18417    }
18418    unsafe impl<
18419        T0: fidl::encoding::Encode<
18420                fidl::encoding::Optional<
18421                    fidl::encoding::HandleType<
18422                        fdomain_client::Clock,
18423                        { fidl::ObjectType::CLOCK.into_raw() },
18424                        2147483648,
18425                    >,
18426                >,
18427                fdomain_client::fidl::FDomainResourceDialect,
18428            >,
18429    >
18430        fidl::encoding::Encode<
18431            AudioCapturerSetReferenceClockRequest,
18432            fdomain_client::fidl::FDomainResourceDialect,
18433        > for (T0,)
18434    {
18435        #[inline]
18436        unsafe fn encode(
18437            self,
18438            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18439            offset: usize,
18440            depth: fidl::encoding::Depth,
18441        ) -> fidl::Result<()> {
18442            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
18443            // Zero out padding regions. There's no need to apply masks
18444            // because the unmasked parts will be overwritten by fields.
18445            // Write the fields.
18446            self.0.encode(encoder, offset + 0, depth)?;
18447            Ok(())
18448        }
18449    }
18450
18451    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18452        for AudioCapturerSetReferenceClockRequest
18453    {
18454        #[inline(always)]
18455        fn new_empty() -> Self {
18456            Self {
18457                reference_clock: fidl::new_empty!(
18458                    fidl::encoding::Optional<
18459                        fidl::encoding::HandleType<
18460                            fdomain_client::Clock,
18461                            { fidl::ObjectType::CLOCK.into_raw() },
18462                            2147483648,
18463                        >,
18464                    >,
18465                    fdomain_client::fidl::FDomainResourceDialect
18466                ),
18467            }
18468        }
18469
18470        #[inline]
18471        unsafe fn decode(
18472            &mut self,
18473            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18474            offset: usize,
18475            _depth: fidl::encoding::Depth,
18476        ) -> fidl::Result<()> {
18477            decoder.debug_check_bounds::<Self>(offset);
18478            // Verify that padding bytes are zero.
18479            fidl::decode!(
18480                fidl::encoding::Optional<
18481                    fidl::encoding::HandleType<
18482                        fdomain_client::Clock,
18483                        { fidl::ObjectType::CLOCK.into_raw() },
18484                        2147483648,
18485                    >,
18486                >,
18487                fdomain_client::fidl::FDomainResourceDialect,
18488                &mut self.reference_clock,
18489                decoder,
18490                offset + 0,
18491                _depth
18492            )?;
18493            Ok(())
18494        }
18495    }
18496
18497    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
18498        type Borrowed<'a> = &'a mut Self;
18499        fn take_or_borrow<'a>(
18500            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18501        ) -> Self::Borrowed<'a> {
18502            value
18503        }
18504    }
18505
18506    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
18507        type Owned = Self;
18508
18509        #[inline(always)]
18510        fn inline_align(_context: fidl::encoding::Context) -> usize {
18511            4
18512        }
18513
18514        #[inline(always)]
18515        fn inline_size(_context: fidl::encoding::Context) -> usize {
18516            4
18517        }
18518    }
18519
18520    unsafe impl
18521        fidl::encoding::Encode<
18522            AudioConsumerBindVolumeControlRequest,
18523            fdomain_client::fidl::FDomainResourceDialect,
18524        > for &mut AudioConsumerBindVolumeControlRequest
18525    {
18526        #[inline]
18527        unsafe fn encode(
18528            self,
18529            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18530            offset: usize,
18531            _depth: fidl::encoding::Depth,
18532        ) -> fidl::Result<()> {
18533            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
18534            // Delegate to tuple encoding.
18535            fidl::encoding::Encode::<
18536                AudioConsumerBindVolumeControlRequest,
18537                fdomain_client::fidl::FDomainResourceDialect,
18538            >::encode(
18539                (<fidl::encoding::Endpoint<
18540                    fdomain_client::fidl::ServerEnd<
18541                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18542                    >,
18543                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18544                    &mut self.volume_control_request,
18545                ),),
18546                encoder,
18547                offset,
18548                _depth,
18549            )
18550        }
18551    }
18552    unsafe impl<
18553        T0: fidl::encoding::Encode<
18554                fidl::encoding::Endpoint<
18555                    fdomain_client::fidl::ServerEnd<
18556                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18557                    >,
18558                >,
18559                fdomain_client::fidl::FDomainResourceDialect,
18560            >,
18561    >
18562        fidl::encoding::Encode<
18563            AudioConsumerBindVolumeControlRequest,
18564            fdomain_client::fidl::FDomainResourceDialect,
18565        > for (T0,)
18566    {
18567        #[inline]
18568        unsafe fn encode(
18569            self,
18570            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18571            offset: usize,
18572            depth: fidl::encoding::Depth,
18573        ) -> fidl::Result<()> {
18574            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
18575            // Zero out padding regions. There's no need to apply masks
18576            // because the unmasked parts will be overwritten by fields.
18577            // Write the fields.
18578            self.0.encode(encoder, offset + 0, depth)?;
18579            Ok(())
18580        }
18581    }
18582
18583    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18584        for AudioConsumerBindVolumeControlRequest
18585    {
18586        #[inline(always)]
18587        fn new_empty() -> Self {
18588            Self {
18589                volume_control_request: fidl::new_empty!(
18590                    fidl::encoding::Endpoint<
18591                        fdomain_client::fidl::ServerEnd<
18592                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18593                        >,
18594                    >,
18595                    fdomain_client::fidl::FDomainResourceDialect
18596                ),
18597            }
18598        }
18599
18600        #[inline]
18601        unsafe fn decode(
18602            &mut self,
18603            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18604            offset: usize,
18605            _depth: fidl::encoding::Depth,
18606        ) -> fidl::Result<()> {
18607            decoder.debug_check_bounds::<Self>(offset);
18608            // Verify that padding bytes are zero.
18609            fidl::decode!(
18610                fidl::encoding::Endpoint<
18611                    fdomain_client::fidl::ServerEnd<
18612                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18613                    >,
18614                >,
18615                fdomain_client::fidl::FDomainResourceDialect,
18616                &mut self.volume_control_request,
18617                decoder,
18618                offset + 0,
18619                _depth
18620            )?;
18621            Ok(())
18622        }
18623    }
18624
18625    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
18626        type Borrowed<'a> = &'a mut Self;
18627        fn take_or_borrow<'a>(
18628            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18629        ) -> Self::Borrowed<'a> {
18630            value
18631        }
18632    }
18633
18634    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
18635        type Owned = Self;
18636
18637        #[inline(always)]
18638        fn inline_align(_context: fidl::encoding::Context) -> usize {
18639            8
18640        }
18641
18642        #[inline(always)]
18643        fn inline_size(_context: fidl::encoding::Context) -> usize {
18644            48
18645        }
18646    }
18647
18648    unsafe impl
18649        fidl::encoding::Encode<
18650            AudioConsumerCreateStreamSinkRequest,
18651            fdomain_client::fidl::FDomainResourceDialect,
18652        > for &mut AudioConsumerCreateStreamSinkRequest
18653    {
18654        #[inline]
18655        unsafe fn encode(
18656            self,
18657            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18658            offset: usize,
18659            _depth: fidl::encoding::Depth,
18660        ) -> fidl::Result<()> {
18661            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
18662            // Delegate to tuple encoding.
18663            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
18664                (
18665                    <fidl::encoding::Vector<fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
18666                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
18667                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
18668                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
18669                ),
18670                encoder, offset, _depth
18671            )
18672        }
18673    }
18674    unsafe impl<
18675        T0: fidl::encoding::Encode<
18676                fidl::encoding::Vector<
18677                    fidl::encoding::HandleType<
18678                        fdomain_client::Vmo,
18679                        { fidl::ObjectType::VMO.into_raw() },
18680                        2147483648,
18681                    >,
18682                    16,
18683                >,
18684                fdomain_client::fidl::FDomainResourceDialect,
18685            >,
18686        T1: fidl::encoding::Encode<AudioStreamType, fdomain_client::fidl::FDomainResourceDialect>,
18687        T2: fidl::encoding::Encode<
18688                fidl::encoding::Boxed<Compression>,
18689                fdomain_client::fidl::FDomainResourceDialect,
18690            >,
18691        T3: fidl::encoding::Encode<
18692                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
18693                fdomain_client::fidl::FDomainResourceDialect,
18694            >,
18695    >
18696        fidl::encoding::Encode<
18697            AudioConsumerCreateStreamSinkRequest,
18698            fdomain_client::fidl::FDomainResourceDialect,
18699        > for (T0, T1, T2, T3)
18700    {
18701        #[inline]
18702        unsafe fn encode(
18703            self,
18704            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18705            offset: usize,
18706            depth: fidl::encoding::Depth,
18707        ) -> fidl::Result<()> {
18708            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
18709            // Zero out padding regions. There's no need to apply masks
18710            // because the unmasked parts will be overwritten by fields.
18711            unsafe {
18712                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
18713                (ptr as *mut u64).write_unaligned(0);
18714            }
18715            unsafe {
18716                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
18717                (ptr as *mut u64).write_unaligned(0);
18718            }
18719            // Write the fields.
18720            self.0.encode(encoder, offset + 0, depth)?;
18721            self.1.encode(encoder, offset + 16, depth)?;
18722            self.2.encode(encoder, offset + 32, depth)?;
18723            self.3.encode(encoder, offset + 40, depth)?;
18724            Ok(())
18725        }
18726    }
18727
18728    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18729        for AudioConsumerCreateStreamSinkRequest
18730    {
18731        #[inline(always)]
18732        fn new_empty() -> Self {
18733            Self {
18734                buffers: fidl::new_empty!(
18735                    fidl::encoding::Vector<
18736                        fidl::encoding::HandleType<
18737                            fdomain_client::Vmo,
18738                            { fidl::ObjectType::VMO.into_raw() },
18739                            2147483648,
18740                        >,
18741                        16,
18742                    >,
18743                    fdomain_client::fidl::FDomainResourceDialect
18744                ),
18745                stream_type: fidl::new_empty!(
18746                    AudioStreamType,
18747                    fdomain_client::fidl::FDomainResourceDialect
18748                ),
18749                compression: fidl::new_empty!(
18750                    fidl::encoding::Boxed<Compression>,
18751                    fdomain_client::fidl::FDomainResourceDialect
18752                ),
18753                stream_sink_request: fidl::new_empty!(
18754                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
18755                    fdomain_client::fidl::FDomainResourceDialect
18756                ),
18757            }
18758        }
18759
18760        #[inline]
18761        unsafe fn decode(
18762            &mut self,
18763            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18764            offset: usize,
18765            _depth: fidl::encoding::Depth,
18766        ) -> fidl::Result<()> {
18767            decoder.debug_check_bounds::<Self>(offset);
18768            // Verify that padding bytes are zero.
18769            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
18770            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18771            let mask = 0xffffffff00000000u64;
18772            let maskedval = padval & mask;
18773            if maskedval != 0 {
18774                return Err(fidl::Error::NonZeroPadding {
18775                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
18776                });
18777            }
18778            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
18779            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18780            let mask = 0xffffffff00000000u64;
18781            let maskedval = padval & mask;
18782            if maskedval != 0 {
18783                return Err(fidl::Error::NonZeroPadding {
18784                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
18785                });
18786            }
18787            fidl::decode!(
18788                fidl::encoding::Vector<
18789                    fidl::encoding::HandleType<
18790                        fdomain_client::Vmo,
18791                        { fidl::ObjectType::VMO.into_raw() },
18792                        2147483648,
18793                    >,
18794                    16,
18795                >,
18796                fdomain_client::fidl::FDomainResourceDialect,
18797                &mut self.buffers,
18798                decoder,
18799                offset + 0,
18800                _depth
18801            )?;
18802            fidl::decode!(
18803                AudioStreamType,
18804                fdomain_client::fidl::FDomainResourceDialect,
18805                &mut self.stream_type,
18806                decoder,
18807                offset + 16,
18808                _depth
18809            )?;
18810            fidl::decode!(
18811                fidl::encoding::Boxed<Compression>,
18812                fdomain_client::fidl::FDomainResourceDialect,
18813                &mut self.compression,
18814                decoder,
18815                offset + 32,
18816                _depth
18817            )?;
18818            fidl::decode!(
18819                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<StreamSinkMarker>>,
18820                fdomain_client::fidl::FDomainResourceDialect,
18821                &mut self.stream_sink_request,
18822                decoder,
18823                offset + 40,
18824                _depth
18825            )?;
18826            Ok(())
18827        }
18828    }
18829
18830    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
18831        type Borrowed<'a> = &'a mut Self;
18832        fn take_or_borrow<'a>(
18833            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18834        ) -> Self::Borrowed<'a> {
18835            value
18836        }
18837    }
18838
18839    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
18840        type Owned = Self;
18841
18842        #[inline(always)]
18843        fn inline_align(_context: fidl::encoding::Context) -> usize {
18844            8
18845        }
18846
18847        #[inline(always)]
18848        fn inline_size(_context: fidl::encoding::Context) -> usize {
18849            24
18850        }
18851    }
18852
18853    unsafe impl
18854        fidl::encoding::Encode<
18855            AudioCoreBindUsageVolumeControl2Request,
18856            fdomain_client::fidl::FDomainResourceDialect,
18857        > for &mut AudioCoreBindUsageVolumeControl2Request
18858    {
18859        #[inline]
18860        unsafe fn encode(
18861            self,
18862            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18863            offset: usize,
18864            _depth: fidl::encoding::Depth,
18865        ) -> fidl::Result<()> {
18866            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
18867            // Delegate to tuple encoding.
18868            fidl::encoding::Encode::<
18869                AudioCoreBindUsageVolumeControl2Request,
18870                fdomain_client::fidl::FDomainResourceDialect,
18871            >::encode(
18872                (
18873                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
18874                    <fidl::encoding::Endpoint<
18875                        fdomain_client::fidl::ServerEnd<
18876                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18877                        >,
18878                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
18879                        &mut self.volume_control,
18880                    ),
18881                ),
18882                encoder,
18883                offset,
18884                _depth,
18885            )
18886        }
18887    }
18888    unsafe impl<
18889        T0: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
18890        T1: fidl::encoding::Encode<
18891                fidl::encoding::Endpoint<
18892                    fdomain_client::fidl::ServerEnd<
18893                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18894                    >,
18895                >,
18896                fdomain_client::fidl::FDomainResourceDialect,
18897            >,
18898    >
18899        fidl::encoding::Encode<
18900            AudioCoreBindUsageVolumeControl2Request,
18901            fdomain_client::fidl::FDomainResourceDialect,
18902        > for (T0, T1)
18903    {
18904        #[inline]
18905        unsafe fn encode(
18906            self,
18907            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18908            offset: usize,
18909            depth: fidl::encoding::Depth,
18910        ) -> fidl::Result<()> {
18911            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
18912            // Zero out padding regions. There's no need to apply masks
18913            // because the unmasked parts will be overwritten by fields.
18914            unsafe {
18915                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
18916                (ptr as *mut u64).write_unaligned(0);
18917            }
18918            // Write the fields.
18919            self.0.encode(encoder, offset + 0, depth)?;
18920            self.1.encode(encoder, offset + 16, depth)?;
18921            Ok(())
18922        }
18923    }
18924
18925    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
18926        for AudioCoreBindUsageVolumeControl2Request
18927    {
18928        #[inline(always)]
18929        fn new_empty() -> Self {
18930            Self {
18931                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
18932                volume_control: fidl::new_empty!(
18933                    fidl::encoding::Endpoint<
18934                        fdomain_client::fidl::ServerEnd<
18935                            fdomain_fuchsia_media_audio::VolumeControlMarker,
18936                        >,
18937                    >,
18938                    fdomain_client::fidl::FDomainResourceDialect
18939                ),
18940            }
18941        }
18942
18943        #[inline]
18944        unsafe fn decode(
18945            &mut self,
18946            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
18947            offset: usize,
18948            _depth: fidl::encoding::Depth,
18949        ) -> fidl::Result<()> {
18950            decoder.debug_check_bounds::<Self>(offset);
18951            // Verify that padding bytes are zero.
18952            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
18953            let padval = unsafe { (ptr as *const u64).read_unaligned() };
18954            let mask = 0xffffffff00000000u64;
18955            let maskedval = padval & mask;
18956            if maskedval != 0 {
18957                return Err(fidl::Error::NonZeroPadding {
18958                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
18959                });
18960            }
18961            fidl::decode!(
18962                Usage2,
18963                fdomain_client::fidl::FDomainResourceDialect,
18964                &mut self.usage,
18965                decoder,
18966                offset + 0,
18967                _depth
18968            )?;
18969            fidl::decode!(
18970                fidl::encoding::Endpoint<
18971                    fdomain_client::fidl::ServerEnd<
18972                        fdomain_fuchsia_media_audio::VolumeControlMarker,
18973                    >,
18974                >,
18975                fdomain_client::fidl::FDomainResourceDialect,
18976                &mut self.volume_control,
18977                decoder,
18978                offset + 16,
18979                _depth
18980            )?;
18981            Ok(())
18982        }
18983    }
18984
18985    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
18986        type Borrowed<'a> = &'a mut Self;
18987        fn take_or_borrow<'a>(
18988            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
18989        ) -> Self::Borrowed<'a> {
18990            value
18991        }
18992    }
18993
18994    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
18995        type Owned = Self;
18996
18997        #[inline(always)]
18998        fn inline_align(_context: fidl::encoding::Context) -> usize {
18999            8
19000        }
19001
19002        #[inline(always)]
19003        fn inline_size(_context: fidl::encoding::Context) -> usize {
19004            24
19005        }
19006    }
19007
19008    unsafe impl
19009        fidl::encoding::Encode<
19010            AudioCoreBindUsageVolumeControlRequest,
19011            fdomain_client::fidl::FDomainResourceDialect,
19012        > for &mut AudioCoreBindUsageVolumeControlRequest
19013    {
19014        #[inline]
19015        unsafe fn encode(
19016            self,
19017            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19018            offset: usize,
19019            _depth: fidl::encoding::Depth,
19020        ) -> fidl::Result<()> {
19021            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
19022            // Delegate to tuple encoding.
19023            fidl::encoding::Encode::<
19024                AudioCoreBindUsageVolumeControlRequest,
19025                fdomain_client::fidl::FDomainResourceDialect,
19026            >::encode(
19027                (
19028                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
19029                    <fidl::encoding::Endpoint<
19030                        fdomain_client::fidl::ServerEnd<
19031                            fdomain_fuchsia_media_audio::VolumeControlMarker,
19032                        >,
19033                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19034                        &mut self.volume_control,
19035                    ),
19036                ),
19037                encoder,
19038                offset,
19039                _depth,
19040            )
19041        }
19042    }
19043    unsafe impl<
19044        T0: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
19045        T1: fidl::encoding::Encode<
19046                fidl::encoding::Endpoint<
19047                    fdomain_client::fidl::ServerEnd<
19048                        fdomain_fuchsia_media_audio::VolumeControlMarker,
19049                    >,
19050                >,
19051                fdomain_client::fidl::FDomainResourceDialect,
19052            >,
19053    >
19054        fidl::encoding::Encode<
19055            AudioCoreBindUsageVolumeControlRequest,
19056            fdomain_client::fidl::FDomainResourceDialect,
19057        > for (T0, T1)
19058    {
19059        #[inline]
19060        unsafe fn encode(
19061            self,
19062            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19063            offset: usize,
19064            depth: fidl::encoding::Depth,
19065        ) -> fidl::Result<()> {
19066            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
19067            // Zero out padding regions. There's no need to apply masks
19068            // because the unmasked parts will be overwritten by fields.
19069            unsafe {
19070                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
19071                (ptr as *mut u64).write_unaligned(0);
19072            }
19073            // Write the fields.
19074            self.0.encode(encoder, offset + 0, depth)?;
19075            self.1.encode(encoder, offset + 16, depth)?;
19076            Ok(())
19077        }
19078    }
19079
19080    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19081        for AudioCoreBindUsageVolumeControlRequest
19082    {
19083        #[inline(always)]
19084        fn new_empty() -> Self {
19085            Self {
19086                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
19087                volume_control: fidl::new_empty!(
19088                    fidl::encoding::Endpoint<
19089                        fdomain_client::fidl::ServerEnd<
19090                            fdomain_fuchsia_media_audio::VolumeControlMarker,
19091                        >,
19092                    >,
19093                    fdomain_client::fidl::FDomainResourceDialect
19094                ),
19095            }
19096        }
19097
19098        #[inline]
19099        unsafe fn decode(
19100            &mut self,
19101            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19102            offset: usize,
19103            _depth: fidl::encoding::Depth,
19104        ) -> fidl::Result<()> {
19105            decoder.debug_check_bounds::<Self>(offset);
19106            // Verify that padding bytes are zero.
19107            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
19108            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19109            let mask = 0xffffffff00000000u64;
19110            let maskedval = padval & mask;
19111            if maskedval != 0 {
19112                return Err(fidl::Error::NonZeroPadding {
19113                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
19114                });
19115            }
19116            fidl::decode!(
19117                Usage,
19118                fdomain_client::fidl::FDomainResourceDialect,
19119                &mut self.usage,
19120                decoder,
19121                offset + 0,
19122                _depth
19123            )?;
19124            fidl::decode!(
19125                fidl::encoding::Endpoint<
19126                    fdomain_client::fidl::ServerEnd<
19127                        fdomain_fuchsia_media_audio::VolumeControlMarker,
19128                    >,
19129                >,
19130                fdomain_client::fidl::FDomainResourceDialect,
19131                &mut self.volume_control,
19132                decoder,
19133                offset + 16,
19134                _depth
19135            )?;
19136            Ok(())
19137        }
19138    }
19139
19140    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
19141        type Borrowed<'a> = &'a mut Self;
19142        fn take_or_borrow<'a>(
19143            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19144        ) -> Self::Borrowed<'a> {
19145            value
19146        }
19147    }
19148
19149    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
19150        type Owned = Self;
19151
19152        #[inline(always)]
19153        fn inline_align(_context: fidl::encoding::Context) -> usize {
19154            4
19155        }
19156
19157        #[inline(always)]
19158        fn inline_size(_context: fidl::encoding::Context) -> usize {
19159            8
19160        }
19161    }
19162
19163    unsafe impl
19164        fidl::encoding::Encode<
19165            AudioCoreCreateAudioCapturerRequest,
19166            fdomain_client::fidl::FDomainResourceDialect,
19167        > for &mut AudioCoreCreateAudioCapturerRequest
19168    {
19169        #[inline]
19170        unsafe fn encode(
19171            self,
19172            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19173            offset: usize,
19174            _depth: fidl::encoding::Depth,
19175        ) -> fidl::Result<()> {
19176            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
19177            // Delegate to tuple encoding.
19178            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19179                (
19180                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
19181                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
19182                ),
19183                encoder, offset, _depth
19184            )
19185        }
19186    }
19187    unsafe impl<
19188        T0: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
19189        T1: fidl::encoding::Encode<
19190                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19191                fdomain_client::fidl::FDomainResourceDialect,
19192            >,
19193    >
19194        fidl::encoding::Encode<
19195            AudioCoreCreateAudioCapturerRequest,
19196            fdomain_client::fidl::FDomainResourceDialect,
19197        > for (T0, T1)
19198    {
19199        #[inline]
19200        unsafe fn encode(
19201            self,
19202            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19203            offset: usize,
19204            depth: fidl::encoding::Depth,
19205        ) -> fidl::Result<()> {
19206            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
19207            // Zero out padding regions. There's no need to apply masks
19208            // because the unmasked parts will be overwritten by fields.
19209            unsafe {
19210                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
19211                (ptr as *mut u32).write_unaligned(0);
19212            }
19213            // Write the fields.
19214            self.0.encode(encoder, offset + 0, depth)?;
19215            self.1.encode(encoder, offset + 4, depth)?;
19216            Ok(())
19217        }
19218    }
19219
19220    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19221        for AudioCoreCreateAudioCapturerRequest
19222    {
19223        #[inline(always)]
19224        fn new_empty() -> Self {
19225            Self {
19226                loopback: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
19227                audio_in_request: fidl::new_empty!(
19228                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19229                    fdomain_client::fidl::FDomainResourceDialect
19230                ),
19231            }
19232        }
19233
19234        #[inline]
19235        unsafe fn decode(
19236            &mut self,
19237            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19238            offset: usize,
19239            _depth: fidl::encoding::Depth,
19240        ) -> fidl::Result<()> {
19241            decoder.debug_check_bounds::<Self>(offset);
19242            // Verify that padding bytes are zero.
19243            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
19244            let padval = unsafe { (ptr as *const u32).read_unaligned() };
19245            let mask = 0xffffff00u32;
19246            let maskedval = padval & mask;
19247            if maskedval != 0 {
19248                return Err(fidl::Error::NonZeroPadding {
19249                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
19250                });
19251            }
19252            fidl::decode!(
19253                bool,
19254                fdomain_client::fidl::FDomainResourceDialect,
19255                &mut self.loopback,
19256                decoder,
19257                offset + 0,
19258                _depth
19259            )?;
19260            fidl::decode!(
19261                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19262                fdomain_client::fidl::FDomainResourceDialect,
19263                &mut self.audio_in_request,
19264                decoder,
19265                offset + 4,
19266                _depth
19267            )?;
19268            Ok(())
19269        }
19270    }
19271
19272    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
19273        type Borrowed<'a> = &'a mut Self;
19274        fn take_or_borrow<'a>(
19275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19276        ) -> Self::Borrowed<'a> {
19277            value
19278        }
19279    }
19280
19281    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
19282        type Owned = Self;
19283
19284        #[inline(always)]
19285        fn inline_align(_context: fidl::encoding::Context) -> usize {
19286            8
19287        }
19288
19289        #[inline(always)]
19290        fn inline_size(_context: fidl::encoding::Context) -> usize {
19291            40
19292        }
19293    }
19294
19295    unsafe impl
19296        fidl::encoding::Encode<
19297            AudioCoreCreateAudioCapturerWithConfigurationRequest,
19298            fdomain_client::fidl::FDomainResourceDialect,
19299        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
19300    {
19301        #[inline]
19302        unsafe fn encode(
19303            self,
19304            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19305            offset: usize,
19306            _depth: fidl::encoding::Depth,
19307        ) -> fidl::Result<()> {
19308            encoder
19309                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
19310            // Delegate to tuple encoding.
19311            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19312                (
19313                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
19314                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
19315                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
19316                ),
19317                encoder, offset, _depth
19318            )
19319        }
19320    }
19321    unsafe impl<
19322        T0: fidl::encoding::Encode<AudioStreamType, fdomain_client::fidl::FDomainResourceDialect>,
19323        T1: fidl::encoding::Encode<
19324                AudioCapturerConfiguration,
19325                fdomain_client::fidl::FDomainResourceDialect,
19326            >,
19327        T2: fidl::encoding::Encode<
19328                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19329                fdomain_client::fidl::FDomainResourceDialect,
19330            >,
19331    >
19332        fidl::encoding::Encode<
19333            AudioCoreCreateAudioCapturerWithConfigurationRequest,
19334            fdomain_client::fidl::FDomainResourceDialect,
19335        > for (T0, T1, T2)
19336    {
19337        #[inline]
19338        unsafe fn encode(
19339            self,
19340            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19341            offset: usize,
19342            depth: fidl::encoding::Depth,
19343        ) -> fidl::Result<()> {
19344            encoder
19345                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
19346            // Zero out padding regions. There's no need to apply masks
19347            // because the unmasked parts will be overwritten by fields.
19348            unsafe {
19349                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
19350                (ptr as *mut u64).write_unaligned(0);
19351            }
19352            unsafe {
19353                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
19354                (ptr as *mut u64).write_unaligned(0);
19355            }
19356            // Write the fields.
19357            self.0.encode(encoder, offset + 0, depth)?;
19358            self.1.encode(encoder, offset + 16, depth)?;
19359            self.2.encode(encoder, offset + 32, depth)?;
19360            Ok(())
19361        }
19362    }
19363
19364    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19365        for AudioCoreCreateAudioCapturerWithConfigurationRequest
19366    {
19367        #[inline(always)]
19368        fn new_empty() -> Self {
19369            Self {
19370                stream_type: fidl::new_empty!(
19371                    AudioStreamType,
19372                    fdomain_client::fidl::FDomainResourceDialect
19373                ),
19374                configuration: fidl::new_empty!(
19375                    AudioCapturerConfiguration,
19376                    fdomain_client::fidl::FDomainResourceDialect
19377                ),
19378                audio_capturer_request: fidl::new_empty!(
19379                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19380                    fdomain_client::fidl::FDomainResourceDialect
19381                ),
19382            }
19383        }
19384
19385        #[inline]
19386        unsafe fn decode(
19387            &mut self,
19388            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19389            offset: usize,
19390            _depth: fidl::encoding::Depth,
19391        ) -> fidl::Result<()> {
19392            decoder.debug_check_bounds::<Self>(offset);
19393            // Verify that padding bytes are zero.
19394            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
19395            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19396            let mask = 0xffffffff00000000u64;
19397            let maskedval = padval & mask;
19398            if maskedval != 0 {
19399                return Err(fidl::Error::NonZeroPadding {
19400                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
19401                });
19402            }
19403            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
19404            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19405            let mask = 0xffffffff00000000u64;
19406            let maskedval = padval & mask;
19407            if maskedval != 0 {
19408                return Err(fidl::Error::NonZeroPadding {
19409                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
19410                });
19411            }
19412            fidl::decode!(
19413                AudioStreamType,
19414                fdomain_client::fidl::FDomainResourceDialect,
19415                &mut self.stream_type,
19416                decoder,
19417                offset + 0,
19418                _depth
19419            )?;
19420            fidl::decode!(
19421                AudioCapturerConfiguration,
19422                fdomain_client::fidl::FDomainResourceDialect,
19423                &mut self.configuration,
19424                decoder,
19425                offset + 16,
19426                _depth
19427            )?;
19428            fidl::decode!(
19429                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19430                fdomain_client::fidl::FDomainResourceDialect,
19431                &mut self.audio_capturer_request,
19432                decoder,
19433                offset + 32,
19434                _depth
19435            )?;
19436            Ok(())
19437        }
19438    }
19439
19440    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
19441        type Borrowed<'a> = &'a mut Self;
19442        fn take_or_borrow<'a>(
19443            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19444        ) -> Self::Borrowed<'a> {
19445            value
19446        }
19447    }
19448
19449    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
19450        type Owned = Self;
19451
19452        #[inline(always)]
19453        fn inline_align(_context: fidl::encoding::Context) -> usize {
19454            4
19455        }
19456
19457        #[inline(always)]
19458        fn inline_size(_context: fidl::encoding::Context) -> usize {
19459            4
19460        }
19461    }
19462
19463    unsafe impl
19464        fidl::encoding::Encode<
19465            AudioCoreCreateAudioRendererRequest,
19466            fdomain_client::fidl::FDomainResourceDialect,
19467        > for &mut AudioCoreCreateAudioRendererRequest
19468    {
19469        #[inline]
19470        unsafe fn encode(
19471            self,
19472            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19473            offset: usize,
19474            _depth: fidl::encoding::Depth,
19475        ) -> fidl::Result<()> {
19476            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
19477            // Delegate to tuple encoding.
19478            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19479                (
19480                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
19481                ),
19482                encoder, offset, _depth
19483            )
19484        }
19485    }
19486    unsafe impl<
19487        T0: fidl::encoding::Encode<
19488                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19489                fdomain_client::fidl::FDomainResourceDialect,
19490            >,
19491    >
19492        fidl::encoding::Encode<
19493            AudioCoreCreateAudioRendererRequest,
19494            fdomain_client::fidl::FDomainResourceDialect,
19495        > for (T0,)
19496    {
19497        #[inline]
19498        unsafe fn encode(
19499            self,
19500            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19501            offset: usize,
19502            depth: fidl::encoding::Depth,
19503        ) -> fidl::Result<()> {
19504            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
19505            // Zero out padding regions. There's no need to apply masks
19506            // because the unmasked parts will be overwritten by fields.
19507            // Write the fields.
19508            self.0.encode(encoder, offset + 0, depth)?;
19509            Ok(())
19510        }
19511    }
19512
19513    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19514        for AudioCoreCreateAudioRendererRequest
19515    {
19516        #[inline(always)]
19517        fn new_empty() -> Self {
19518            Self {
19519                audio_out_request: fidl::new_empty!(
19520                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19521                    fdomain_client::fidl::FDomainResourceDialect
19522                ),
19523            }
19524        }
19525
19526        #[inline]
19527        unsafe fn decode(
19528            &mut self,
19529            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19530            offset: usize,
19531            _depth: fidl::encoding::Depth,
19532        ) -> fidl::Result<()> {
19533            decoder.debug_check_bounds::<Self>(offset);
19534            // Verify that padding bytes are zero.
19535            fidl::decode!(
19536                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19537                fdomain_client::fidl::FDomainResourceDialect,
19538                &mut self.audio_out_request,
19539                decoder,
19540                offset + 0,
19541                _depth
19542            )?;
19543            Ok(())
19544        }
19545    }
19546
19547    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
19548        type Borrowed<'a> = &'a mut Self;
19549        fn take_or_borrow<'a>(
19550            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19551        ) -> Self::Borrowed<'a> {
19552            value
19553        }
19554    }
19555
19556    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
19557        type Owned = Self;
19558
19559        #[inline(always)]
19560        fn inline_align(_context: fidl::encoding::Context) -> usize {
19561            4
19562        }
19563
19564        #[inline(always)]
19565        fn inline_size(_context: fidl::encoding::Context) -> usize {
19566            8
19567        }
19568    }
19569
19570    unsafe impl
19571        fidl::encoding::Encode<
19572            AudioCreateAudioCapturerRequest,
19573            fdomain_client::fidl::FDomainResourceDialect,
19574        > for &mut AudioCreateAudioCapturerRequest
19575    {
19576        #[inline]
19577        unsafe fn encode(
19578            self,
19579            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19580            offset: usize,
19581            _depth: fidl::encoding::Depth,
19582        ) -> fidl::Result<()> {
19583            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
19584            // Delegate to tuple encoding.
19585            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19586                (
19587                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
19588                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
19589                ),
19590                encoder, offset, _depth
19591            )
19592        }
19593    }
19594    unsafe impl<
19595        T0: fidl::encoding::Encode<
19596                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19597                fdomain_client::fidl::FDomainResourceDialect,
19598            >,
19599        T1: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
19600    >
19601        fidl::encoding::Encode<
19602            AudioCreateAudioCapturerRequest,
19603            fdomain_client::fidl::FDomainResourceDialect,
19604        > for (T0, T1)
19605    {
19606        #[inline]
19607        unsafe fn encode(
19608            self,
19609            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19610            offset: usize,
19611            depth: fidl::encoding::Depth,
19612        ) -> fidl::Result<()> {
19613            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
19614            // Zero out padding regions. There's no need to apply masks
19615            // because the unmasked parts will be overwritten by fields.
19616            unsafe {
19617                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
19618                (ptr as *mut u32).write_unaligned(0);
19619            }
19620            // Write the fields.
19621            self.0.encode(encoder, offset + 0, depth)?;
19622            self.1.encode(encoder, offset + 4, depth)?;
19623            Ok(())
19624        }
19625    }
19626
19627    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19628        for AudioCreateAudioCapturerRequest
19629    {
19630        #[inline(always)]
19631        fn new_empty() -> Self {
19632            Self {
19633                audio_capturer_request: fidl::new_empty!(
19634                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19635                    fdomain_client::fidl::FDomainResourceDialect
19636                ),
19637                loopback: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
19638            }
19639        }
19640
19641        #[inline]
19642        unsafe fn decode(
19643            &mut self,
19644            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19645            offset: usize,
19646            _depth: fidl::encoding::Depth,
19647        ) -> fidl::Result<()> {
19648            decoder.debug_check_bounds::<Self>(offset);
19649            // Verify that padding bytes are zero.
19650            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
19651            let padval = unsafe { (ptr as *const u32).read_unaligned() };
19652            let mask = 0xffffff00u32;
19653            let maskedval = padval & mask;
19654            if maskedval != 0 {
19655                return Err(fidl::Error::NonZeroPadding {
19656                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
19657                });
19658            }
19659            fidl::decode!(
19660                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioCapturerMarker>>,
19661                fdomain_client::fidl::FDomainResourceDialect,
19662                &mut self.audio_capturer_request,
19663                decoder,
19664                offset + 0,
19665                _depth
19666            )?;
19667            fidl::decode!(
19668                bool,
19669                fdomain_client::fidl::FDomainResourceDialect,
19670                &mut self.loopback,
19671                decoder,
19672                offset + 4,
19673                _depth
19674            )?;
19675            Ok(())
19676        }
19677    }
19678
19679    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
19680        type Borrowed<'a> = &'a mut Self;
19681        fn take_or_borrow<'a>(
19682            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19683        ) -> Self::Borrowed<'a> {
19684            value
19685        }
19686    }
19687
19688    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
19689        type Owned = Self;
19690
19691        #[inline(always)]
19692        fn inline_align(_context: fidl::encoding::Context) -> usize {
19693            4
19694        }
19695
19696        #[inline(always)]
19697        fn inline_size(_context: fidl::encoding::Context) -> usize {
19698            4
19699        }
19700    }
19701
19702    unsafe impl
19703        fidl::encoding::Encode<
19704            AudioCreateAudioRendererRequest,
19705            fdomain_client::fidl::FDomainResourceDialect,
19706        > for &mut AudioCreateAudioRendererRequest
19707    {
19708        #[inline]
19709        unsafe fn encode(
19710            self,
19711            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19712            offset: usize,
19713            _depth: fidl::encoding::Depth,
19714        ) -> fidl::Result<()> {
19715            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
19716            // Delegate to tuple encoding.
19717            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
19718                (
19719                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
19720                ),
19721                encoder, offset, _depth
19722            )
19723        }
19724    }
19725    unsafe impl<
19726        T0: fidl::encoding::Encode<
19727                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19728                fdomain_client::fidl::FDomainResourceDialect,
19729            >,
19730    >
19731        fidl::encoding::Encode<
19732            AudioCreateAudioRendererRequest,
19733            fdomain_client::fidl::FDomainResourceDialect,
19734        > for (T0,)
19735    {
19736        #[inline]
19737        unsafe fn encode(
19738            self,
19739            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19740            offset: usize,
19741            depth: fidl::encoding::Depth,
19742        ) -> fidl::Result<()> {
19743            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
19744            // Zero out padding regions. There's no need to apply masks
19745            // because the unmasked parts will be overwritten by fields.
19746            // Write the fields.
19747            self.0.encode(encoder, offset + 0, depth)?;
19748            Ok(())
19749        }
19750    }
19751
19752    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19753        for AudioCreateAudioRendererRequest
19754    {
19755        #[inline(always)]
19756        fn new_empty() -> Self {
19757            Self {
19758                audio_renderer_request: fidl::new_empty!(
19759                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19760                    fdomain_client::fidl::FDomainResourceDialect
19761                ),
19762            }
19763        }
19764
19765        #[inline]
19766        unsafe fn decode(
19767            &mut self,
19768            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19769            offset: usize,
19770            _depth: fidl::encoding::Depth,
19771        ) -> fidl::Result<()> {
19772            decoder.debug_check_bounds::<Self>(offset);
19773            // Verify that padding bytes are zero.
19774            fidl::decode!(
19775                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioRendererMarker>>,
19776                fdomain_client::fidl::FDomainResourceDialect,
19777                &mut self.audio_renderer_request,
19778                decoder,
19779                offset + 0,
19780                _depth
19781            )?;
19782            Ok(())
19783        }
19784    }
19785
19786    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
19787        type Borrowed<'a> = &'a mut Self;
19788        fn take_or_borrow<'a>(
19789            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19790        ) -> Self::Borrowed<'a> {
19791            value
19792        }
19793    }
19794
19795    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
19796        type Owned = Self;
19797
19798        #[inline(always)]
19799        fn inline_align(_context: fidl::encoding::Context) -> usize {
19800            8
19801        }
19802
19803        #[inline(always)]
19804        fn inline_size(_context: fidl::encoding::Context) -> usize {
19805            24
19806        }
19807    }
19808
19809    unsafe impl
19810        fidl::encoding::Encode<
19811            AudioDeviceEnumeratorAddDeviceByChannelRequest,
19812            fdomain_client::fidl::FDomainResourceDialect,
19813        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
19814    {
19815        #[inline]
19816        unsafe fn encode(
19817            self,
19818            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19819            offset: usize,
19820            _depth: fidl::encoding::Depth,
19821        ) -> fidl::Result<()> {
19822            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
19823            // Delegate to tuple encoding.
19824            fidl::encoding::Encode::<
19825                AudioDeviceEnumeratorAddDeviceByChannelRequest,
19826                fdomain_client::fidl::FDomainResourceDialect,
19827            >::encode(
19828                (
19829                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
19830                        &self.device_name,
19831                    ),
19832                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
19833                    <fidl::encoding::Endpoint<
19834                        fdomain_client::fidl::ClientEnd<
19835                            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19836                        >,
19837                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
19838                        &mut self.channel
19839                    ),
19840                ),
19841                encoder,
19842                offset,
19843                _depth,
19844            )
19845        }
19846    }
19847    unsafe impl<
19848        T0: fidl::encoding::Encode<
19849                fidl::encoding::BoundedString<256>,
19850                fdomain_client::fidl::FDomainResourceDialect,
19851            >,
19852        T1: fidl::encoding::Encode<bool, fdomain_client::fidl::FDomainResourceDialect>,
19853        T2: fidl::encoding::Encode<
19854                fidl::encoding::Endpoint<
19855                    fdomain_client::fidl::ClientEnd<
19856                        fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19857                    >,
19858                >,
19859                fdomain_client::fidl::FDomainResourceDialect,
19860            >,
19861    >
19862        fidl::encoding::Encode<
19863            AudioDeviceEnumeratorAddDeviceByChannelRequest,
19864            fdomain_client::fidl::FDomainResourceDialect,
19865        > for (T0, T1, T2)
19866    {
19867        #[inline]
19868        unsafe fn encode(
19869            self,
19870            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19871            offset: usize,
19872            depth: fidl::encoding::Depth,
19873        ) -> fidl::Result<()> {
19874            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
19875            // Zero out padding regions. There's no need to apply masks
19876            // because the unmasked parts will be overwritten by fields.
19877            unsafe {
19878                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
19879                (ptr as *mut u64).write_unaligned(0);
19880            }
19881            // Write the fields.
19882            self.0.encode(encoder, offset + 0, depth)?;
19883            self.1.encode(encoder, offset + 16, depth)?;
19884            self.2.encode(encoder, offset + 20, depth)?;
19885            Ok(())
19886        }
19887    }
19888
19889    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
19890        for AudioDeviceEnumeratorAddDeviceByChannelRequest
19891    {
19892        #[inline(always)]
19893        fn new_empty() -> Self {
19894            Self {
19895                device_name: fidl::new_empty!(
19896                    fidl::encoding::BoundedString<256>,
19897                    fdomain_client::fidl::FDomainResourceDialect
19898                ),
19899                is_input: fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect),
19900                channel: fidl::new_empty!(
19901                    fidl::encoding::Endpoint<
19902                        fdomain_client::fidl::ClientEnd<
19903                            fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19904                        >,
19905                    >,
19906                    fdomain_client::fidl::FDomainResourceDialect
19907                ),
19908            }
19909        }
19910
19911        #[inline]
19912        unsafe fn decode(
19913            &mut self,
19914            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19915            offset: usize,
19916            _depth: fidl::encoding::Depth,
19917        ) -> fidl::Result<()> {
19918            decoder.debug_check_bounds::<Self>(offset);
19919            // Verify that padding bytes are zero.
19920            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
19921            let padval = unsafe { (ptr as *const u64).read_unaligned() };
19922            let mask = 0xffffff00u64;
19923            let maskedval = padval & mask;
19924            if maskedval != 0 {
19925                return Err(fidl::Error::NonZeroPadding {
19926                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
19927                });
19928            }
19929            fidl::decode!(
19930                fidl::encoding::BoundedString<256>,
19931                fdomain_client::fidl::FDomainResourceDialect,
19932                &mut self.device_name,
19933                decoder,
19934                offset + 0,
19935                _depth
19936            )?;
19937            fidl::decode!(
19938                bool,
19939                fdomain_client::fidl::FDomainResourceDialect,
19940                &mut self.is_input,
19941                decoder,
19942                offset + 16,
19943                _depth
19944            )?;
19945            fidl::decode!(
19946                fidl::encoding::Endpoint<
19947                    fdomain_client::fidl::ClientEnd<
19948                        fdomain_fuchsia_hardware_audio::StreamConfigMarker,
19949                    >,
19950                >,
19951                fdomain_client::fidl::FDomainResourceDialect,
19952                &mut self.channel,
19953                decoder,
19954                offset + 20,
19955                _depth
19956            )?;
19957            Ok(())
19958        }
19959    }
19960
19961    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
19962        type Borrowed<'a> = &'a mut Self;
19963        fn take_or_borrow<'a>(
19964            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
19965        ) -> Self::Borrowed<'a> {
19966            value
19967        }
19968    }
19969
19970    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
19971        type Owned = Self;
19972
19973        #[inline(always)]
19974        fn inline_align(_context: fidl::encoding::Context) -> usize {
19975            4
19976        }
19977
19978        #[inline(always)]
19979        fn inline_size(_context: fidl::encoding::Context) -> usize {
19980            4
19981        }
19982    }
19983
19984    unsafe impl
19985        fidl::encoding::Encode<
19986            AudioRendererBindGainControlRequest,
19987            fdomain_client::fidl::FDomainResourceDialect,
19988        > for &mut AudioRendererBindGainControlRequest
19989    {
19990        #[inline]
19991        unsafe fn encode(
19992            self,
19993            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
19994            offset: usize,
19995            _depth: fidl::encoding::Depth,
19996        ) -> fidl::Result<()> {
19997            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
19998            // Delegate to tuple encoding.
19999            fidl::encoding::Encode::<
20000                AudioRendererBindGainControlRequest,
20001                fdomain_client::fidl::FDomainResourceDialect,
20002            >::encode(
20003                (<fidl::encoding::Endpoint<
20004                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
20005                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20006                    &mut self.gain_control_request,
20007                ),),
20008                encoder,
20009                offset,
20010                _depth,
20011            )
20012        }
20013    }
20014    unsafe impl<
20015        T0: fidl::encoding::Encode<
20016                fidl::encoding::Endpoint<
20017                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
20018                >,
20019                fdomain_client::fidl::FDomainResourceDialect,
20020            >,
20021    >
20022        fidl::encoding::Encode<
20023            AudioRendererBindGainControlRequest,
20024            fdomain_client::fidl::FDomainResourceDialect,
20025        > for (T0,)
20026    {
20027        #[inline]
20028        unsafe fn encode(
20029            self,
20030            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20031            offset: usize,
20032            depth: fidl::encoding::Depth,
20033        ) -> fidl::Result<()> {
20034            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
20035            // Zero out padding regions. There's no need to apply masks
20036            // because the unmasked parts will be overwritten by fields.
20037            // Write the fields.
20038            self.0.encode(encoder, offset + 0, depth)?;
20039            Ok(())
20040        }
20041    }
20042
20043    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20044        for AudioRendererBindGainControlRequest
20045    {
20046        #[inline(always)]
20047        fn new_empty() -> Self {
20048            Self {
20049                gain_control_request: fidl::new_empty!(
20050                    fidl::encoding::Endpoint<
20051                        fdomain_client::fidl::ServerEnd<
20052                            fdomain_fuchsia_media_audio::GainControlMarker,
20053                        >,
20054                    >,
20055                    fdomain_client::fidl::FDomainResourceDialect
20056                ),
20057            }
20058        }
20059
20060        #[inline]
20061        unsafe fn decode(
20062            &mut self,
20063            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20064            offset: usize,
20065            _depth: fidl::encoding::Depth,
20066        ) -> fidl::Result<()> {
20067            decoder.debug_check_bounds::<Self>(offset);
20068            // Verify that padding bytes are zero.
20069            fidl::decode!(
20070                fidl::encoding::Endpoint<
20071                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_media_audio::GainControlMarker>,
20072                >,
20073                fdomain_client::fidl::FDomainResourceDialect,
20074                &mut self.gain_control_request,
20075                decoder,
20076                offset + 0,
20077                _depth
20078            )?;
20079            Ok(())
20080        }
20081    }
20082
20083    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
20084        type Borrowed<'a> = &'a mut Self;
20085        fn take_or_borrow<'a>(
20086            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20087        ) -> Self::Borrowed<'a> {
20088            value
20089        }
20090    }
20091
20092    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
20093        type Owned = Self;
20094
20095        #[inline(always)]
20096        fn inline_align(_context: fidl::encoding::Context) -> usize {
20097            4
20098        }
20099
20100        #[inline(always)]
20101        fn inline_size(_context: fidl::encoding::Context) -> usize {
20102            4
20103        }
20104    }
20105
20106    unsafe impl
20107        fidl::encoding::Encode<
20108            AudioRendererGetReferenceClockResponse,
20109            fdomain_client::fidl::FDomainResourceDialect,
20110        > for &mut AudioRendererGetReferenceClockResponse
20111    {
20112        #[inline]
20113        unsafe fn encode(
20114            self,
20115            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20116            offset: usize,
20117            _depth: fidl::encoding::Depth,
20118        ) -> fidl::Result<()> {
20119            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
20120            // Delegate to tuple encoding.
20121            fidl::encoding::Encode::<
20122                AudioRendererGetReferenceClockResponse,
20123                fdomain_client::fidl::FDomainResourceDialect,
20124            >::encode(
20125                (<fidl::encoding::HandleType<
20126                    fdomain_client::Clock,
20127                    { fidl::ObjectType::CLOCK.into_raw() },
20128                    2147483648,
20129                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20130                    &mut self.reference_clock,
20131                ),),
20132                encoder,
20133                offset,
20134                _depth,
20135            )
20136        }
20137    }
20138    unsafe impl<
20139        T0: fidl::encoding::Encode<
20140                fidl::encoding::HandleType<
20141                    fdomain_client::Clock,
20142                    { fidl::ObjectType::CLOCK.into_raw() },
20143                    2147483648,
20144                >,
20145                fdomain_client::fidl::FDomainResourceDialect,
20146            >,
20147    >
20148        fidl::encoding::Encode<
20149            AudioRendererGetReferenceClockResponse,
20150            fdomain_client::fidl::FDomainResourceDialect,
20151        > for (T0,)
20152    {
20153        #[inline]
20154        unsafe fn encode(
20155            self,
20156            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20157            offset: usize,
20158            depth: fidl::encoding::Depth,
20159        ) -> fidl::Result<()> {
20160            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
20161            // Zero out padding regions. There's no need to apply masks
20162            // because the unmasked parts will be overwritten by fields.
20163            // Write the fields.
20164            self.0.encode(encoder, offset + 0, depth)?;
20165            Ok(())
20166        }
20167    }
20168
20169    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20170        for AudioRendererGetReferenceClockResponse
20171    {
20172        #[inline(always)]
20173        fn new_empty() -> Self {
20174            Self {
20175                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20176            }
20177        }
20178
20179        #[inline]
20180        unsafe fn decode(
20181            &mut self,
20182            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20183            offset: usize,
20184            _depth: fidl::encoding::Depth,
20185        ) -> fidl::Result<()> {
20186            decoder.debug_check_bounds::<Self>(offset);
20187            // Verify that padding bytes are zero.
20188            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
20189            Ok(())
20190        }
20191    }
20192
20193    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
20194        type Borrowed<'a> = &'a mut Self;
20195        fn take_or_borrow<'a>(
20196            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20197        ) -> Self::Borrowed<'a> {
20198            value
20199        }
20200    }
20201
20202    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
20203        type Owned = Self;
20204
20205        #[inline(always)]
20206        fn inline_align(_context: fidl::encoding::Context) -> usize {
20207            4
20208        }
20209
20210        #[inline(always)]
20211        fn inline_size(_context: fidl::encoding::Context) -> usize {
20212            4
20213        }
20214    }
20215
20216    unsafe impl
20217        fidl::encoding::Encode<
20218            AudioRendererSetReferenceClockRequest,
20219            fdomain_client::fidl::FDomainResourceDialect,
20220        > for &mut AudioRendererSetReferenceClockRequest
20221    {
20222        #[inline]
20223        unsafe fn encode(
20224            self,
20225            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20226            offset: usize,
20227            _depth: fidl::encoding::Depth,
20228        ) -> fidl::Result<()> {
20229            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
20230            // Delegate to tuple encoding.
20231            fidl::encoding::Encode::<
20232                AudioRendererSetReferenceClockRequest,
20233                fdomain_client::fidl::FDomainResourceDialect,
20234            >::encode(
20235                (<fidl::encoding::Optional<
20236                    fidl::encoding::HandleType<
20237                        fdomain_client::Clock,
20238                        { fidl::ObjectType::CLOCK.into_raw() },
20239                        2147483648,
20240                    >,
20241                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20242                    &mut self.reference_clock,
20243                ),),
20244                encoder,
20245                offset,
20246                _depth,
20247            )
20248        }
20249    }
20250    unsafe impl<
20251        T0: fidl::encoding::Encode<
20252                fidl::encoding::Optional<
20253                    fidl::encoding::HandleType<
20254                        fdomain_client::Clock,
20255                        { fidl::ObjectType::CLOCK.into_raw() },
20256                        2147483648,
20257                    >,
20258                >,
20259                fdomain_client::fidl::FDomainResourceDialect,
20260            >,
20261    >
20262        fidl::encoding::Encode<
20263            AudioRendererSetReferenceClockRequest,
20264            fdomain_client::fidl::FDomainResourceDialect,
20265        > for (T0,)
20266    {
20267        #[inline]
20268        unsafe fn encode(
20269            self,
20270            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20271            offset: usize,
20272            depth: fidl::encoding::Depth,
20273        ) -> fidl::Result<()> {
20274            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
20275            // Zero out padding regions. There's no need to apply masks
20276            // because the unmasked parts will be overwritten by fields.
20277            // Write the fields.
20278            self.0.encode(encoder, offset + 0, depth)?;
20279            Ok(())
20280        }
20281    }
20282
20283    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20284        for AudioRendererSetReferenceClockRequest
20285    {
20286        #[inline(always)]
20287        fn new_empty() -> Self {
20288            Self {
20289                reference_clock: fidl::new_empty!(
20290                    fidl::encoding::Optional<
20291                        fidl::encoding::HandleType<
20292                            fdomain_client::Clock,
20293                            { fidl::ObjectType::CLOCK.into_raw() },
20294                            2147483648,
20295                        >,
20296                    >,
20297                    fdomain_client::fidl::FDomainResourceDialect
20298                ),
20299            }
20300        }
20301
20302        #[inline]
20303        unsafe fn decode(
20304            &mut self,
20305            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20306            offset: usize,
20307            _depth: fidl::encoding::Depth,
20308        ) -> fidl::Result<()> {
20309            decoder.debug_check_bounds::<Self>(offset);
20310            // Verify that padding bytes are zero.
20311            fidl::decode!(
20312                fidl::encoding::Optional<
20313                    fidl::encoding::HandleType<
20314                        fdomain_client::Clock,
20315                        { fidl::ObjectType::CLOCK.into_raw() },
20316                        2147483648,
20317                    >,
20318                >,
20319                fdomain_client::fidl::FDomainResourceDialect,
20320                &mut self.reference_clock,
20321                decoder,
20322                offset + 0,
20323                _depth
20324            )?;
20325            Ok(())
20326        }
20327    }
20328
20329    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
20330        type Borrowed<'a> = &'a mut Self;
20331        fn take_or_borrow<'a>(
20332            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20333        ) -> Self::Borrowed<'a> {
20334            value
20335        }
20336    }
20337
20338    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
20339        type Owned = Self;
20340
20341        #[inline(always)]
20342        fn inline_align(_context: fidl::encoding::Context) -> usize {
20343            8
20344        }
20345
20346        #[inline(always)]
20347        fn inline_size(_context: fidl::encoding::Context) -> usize {
20348            40
20349        }
20350    }
20351
20352    unsafe impl
20353        fidl::encoding::Encode<
20354            ProfileProviderRegisterHandlerWithCapacityRequest,
20355            fdomain_client::fidl::FDomainResourceDialect,
20356        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
20357    {
20358        #[inline]
20359        unsafe fn encode(
20360            self,
20361            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20362            offset: usize,
20363            _depth: fidl::encoding::Depth,
20364        ) -> fidl::Result<()> {
20365            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
20366            // Delegate to tuple encoding.
20367            fidl::encoding::Encode::<
20368                ProfileProviderRegisterHandlerWithCapacityRequest,
20369                fdomain_client::fidl::FDomainResourceDialect,
20370            >::encode(
20371                (
20372                    <fidl::encoding::HandleType<
20373                        fdomain_client::Thread,
20374                        { fidl::ObjectType::THREAD.into_raw() },
20375                        2147483648,
20376                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20377                        &mut self.thread_handle,
20378                    ),
20379                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
20380                        &self.name,
20381                    ),
20382                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
20383                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
20384                ),
20385                encoder,
20386                offset,
20387                _depth,
20388            )
20389        }
20390    }
20391    unsafe impl<
20392        T0: fidl::encoding::Encode<
20393                fidl::encoding::HandleType<
20394                    fdomain_client::Thread,
20395                    { fidl::ObjectType::THREAD.into_raw() },
20396                    2147483648,
20397                >,
20398                fdomain_client::fidl::FDomainResourceDialect,
20399            >,
20400        T1: fidl::encoding::Encode<
20401                fidl::encoding::BoundedString<64>,
20402                fdomain_client::fidl::FDomainResourceDialect,
20403            >,
20404        T2: fidl::encoding::Encode<i64, fdomain_client::fidl::FDomainResourceDialect>,
20405        T3: fidl::encoding::Encode<f32, fdomain_client::fidl::FDomainResourceDialect>,
20406    >
20407        fidl::encoding::Encode<
20408            ProfileProviderRegisterHandlerWithCapacityRequest,
20409            fdomain_client::fidl::FDomainResourceDialect,
20410        > for (T0, T1, T2, T3)
20411    {
20412        #[inline]
20413        unsafe fn encode(
20414            self,
20415            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20416            offset: usize,
20417            depth: fidl::encoding::Depth,
20418        ) -> fidl::Result<()> {
20419            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
20420            // Zero out padding regions. There's no need to apply masks
20421            // because the unmasked parts will be overwritten by fields.
20422            unsafe {
20423                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
20424                (ptr as *mut u64).write_unaligned(0);
20425            }
20426            unsafe {
20427                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
20428                (ptr as *mut u64).write_unaligned(0);
20429            }
20430            // Write the fields.
20431            self.0.encode(encoder, offset + 0, depth)?;
20432            self.1.encode(encoder, offset + 8, depth)?;
20433            self.2.encode(encoder, offset + 24, depth)?;
20434            self.3.encode(encoder, offset + 32, depth)?;
20435            Ok(())
20436        }
20437    }
20438
20439    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20440        for ProfileProviderRegisterHandlerWithCapacityRequest
20441    {
20442        #[inline(always)]
20443        fn new_empty() -> Self {
20444            Self {
20445                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20446                name: fidl::new_empty!(
20447                    fidl::encoding::BoundedString<64>,
20448                    fdomain_client::fidl::FDomainResourceDialect
20449                ),
20450                period: fidl::new_empty!(i64, fdomain_client::fidl::FDomainResourceDialect),
20451                capacity: fidl::new_empty!(f32, fdomain_client::fidl::FDomainResourceDialect),
20452            }
20453        }
20454
20455        #[inline]
20456        unsafe fn decode(
20457            &mut self,
20458            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20459            offset: usize,
20460            _depth: fidl::encoding::Depth,
20461        ) -> fidl::Result<()> {
20462            decoder.debug_check_bounds::<Self>(offset);
20463            // Verify that padding bytes are zero.
20464            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
20465            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20466            let mask = 0xffffffff00000000u64;
20467            let maskedval = padval & mask;
20468            if maskedval != 0 {
20469                return Err(fidl::Error::NonZeroPadding {
20470                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
20471                });
20472            }
20473            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
20474            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20475            let mask = 0xffffffff00000000u64;
20476            let maskedval = padval & mask;
20477            if maskedval != 0 {
20478                return Err(fidl::Error::NonZeroPadding {
20479                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
20480                });
20481            }
20482            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
20483            fidl::decode!(
20484                fidl::encoding::BoundedString<64>,
20485                fdomain_client::fidl::FDomainResourceDialect,
20486                &mut self.name,
20487                decoder,
20488                offset + 8,
20489                _depth
20490            )?;
20491            fidl::decode!(
20492                i64,
20493                fdomain_client::fidl::FDomainResourceDialect,
20494                &mut self.period,
20495                decoder,
20496                offset + 24,
20497                _depth
20498            )?;
20499            fidl::decode!(
20500                f32,
20501                fdomain_client::fidl::FDomainResourceDialect,
20502                &mut self.capacity,
20503                decoder,
20504                offset + 32,
20505                _depth
20506            )?;
20507            Ok(())
20508        }
20509    }
20510
20511    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
20512        type Borrowed<'a> = &'a mut Self;
20513        fn take_or_borrow<'a>(
20514            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20515        ) -> Self::Borrowed<'a> {
20516            value
20517        }
20518    }
20519
20520    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
20521        type Owned = Self;
20522
20523        #[inline(always)]
20524        fn inline_align(_context: fidl::encoding::Context) -> usize {
20525            8
20526        }
20527
20528        #[inline(always)]
20529        fn inline_size(_context: fidl::encoding::Context) -> usize {
20530            24
20531        }
20532    }
20533
20534    unsafe impl
20535        fidl::encoding::Encode<
20536            ProfileProviderRegisterMemoryRangeRequest,
20537            fdomain_client::fidl::FDomainResourceDialect,
20538        > for &mut ProfileProviderRegisterMemoryRangeRequest
20539    {
20540        #[inline]
20541        unsafe fn encode(
20542            self,
20543            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20544            offset: usize,
20545            _depth: fidl::encoding::Depth,
20546        ) -> fidl::Result<()> {
20547            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
20548            // Delegate to tuple encoding.
20549            fidl::encoding::Encode::<
20550                ProfileProviderRegisterMemoryRangeRequest,
20551                fdomain_client::fidl::FDomainResourceDialect,
20552            >::encode(
20553                (
20554                    <fidl::encoding::HandleType<
20555                        fdomain_client::Vmar,
20556                        { fidl::ObjectType::VMAR.into_raw() },
20557                        2147483648,
20558                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20559                        &mut self.vmar_handle
20560                    ),
20561                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
20562                        &self.name,
20563                    ),
20564                ),
20565                encoder,
20566                offset,
20567                _depth,
20568            )
20569        }
20570    }
20571    unsafe impl<
20572        T0: fidl::encoding::Encode<
20573                fidl::encoding::HandleType<
20574                    fdomain_client::Vmar,
20575                    { fidl::ObjectType::VMAR.into_raw() },
20576                    2147483648,
20577                >,
20578                fdomain_client::fidl::FDomainResourceDialect,
20579            >,
20580        T1: fidl::encoding::Encode<
20581                fidl::encoding::BoundedString<64>,
20582                fdomain_client::fidl::FDomainResourceDialect,
20583            >,
20584    >
20585        fidl::encoding::Encode<
20586            ProfileProviderRegisterMemoryRangeRequest,
20587            fdomain_client::fidl::FDomainResourceDialect,
20588        > for (T0, T1)
20589    {
20590        #[inline]
20591        unsafe fn encode(
20592            self,
20593            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20594            offset: usize,
20595            depth: fidl::encoding::Depth,
20596        ) -> fidl::Result<()> {
20597            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
20598            // Zero out padding regions. There's no need to apply masks
20599            // because the unmasked parts will be overwritten by fields.
20600            unsafe {
20601                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
20602                (ptr as *mut u64).write_unaligned(0);
20603            }
20604            // Write the fields.
20605            self.0.encode(encoder, offset + 0, depth)?;
20606            self.1.encode(encoder, offset + 8, depth)?;
20607            Ok(())
20608        }
20609    }
20610
20611    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20612        for ProfileProviderRegisterMemoryRangeRequest
20613    {
20614        #[inline(always)]
20615        fn new_empty() -> Self {
20616            Self {
20617                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20618                name: fidl::new_empty!(
20619                    fidl::encoding::BoundedString<64>,
20620                    fdomain_client::fidl::FDomainResourceDialect
20621                ),
20622            }
20623        }
20624
20625        #[inline]
20626        unsafe fn decode(
20627            &mut self,
20628            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20629            offset: usize,
20630            _depth: fidl::encoding::Depth,
20631        ) -> fidl::Result<()> {
20632            decoder.debug_check_bounds::<Self>(offset);
20633            // Verify that padding bytes are zero.
20634            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
20635            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20636            let mask = 0xffffffff00000000u64;
20637            let maskedval = padval & mask;
20638            if maskedval != 0 {
20639                return Err(fidl::Error::NonZeroPadding {
20640                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
20641                });
20642            }
20643            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
20644            fidl::decode!(
20645                fidl::encoding::BoundedString<64>,
20646                fdomain_client::fidl::FDomainResourceDialect,
20647                &mut self.name,
20648                decoder,
20649                offset + 8,
20650                _depth
20651            )?;
20652            Ok(())
20653        }
20654    }
20655
20656    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
20657        type Borrowed<'a> = &'a mut Self;
20658        fn take_or_borrow<'a>(
20659            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20660        ) -> Self::Borrowed<'a> {
20661            value
20662        }
20663    }
20664
20665    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
20666        type Owned = Self;
20667
20668        #[inline(always)]
20669        fn inline_align(_context: fidl::encoding::Context) -> usize {
20670            8
20671        }
20672
20673        #[inline(always)]
20674        fn inline_size(_context: fidl::encoding::Context) -> usize {
20675            24
20676        }
20677    }
20678
20679    unsafe impl
20680        fidl::encoding::Encode<
20681            ProfileProviderUnregisterHandlerRequest,
20682            fdomain_client::fidl::FDomainResourceDialect,
20683        > for &mut ProfileProviderUnregisterHandlerRequest
20684    {
20685        #[inline]
20686        unsafe fn encode(
20687            self,
20688            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20689            offset: usize,
20690            _depth: fidl::encoding::Depth,
20691        ) -> fidl::Result<()> {
20692            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
20693            // Delegate to tuple encoding.
20694            fidl::encoding::Encode::<
20695                ProfileProviderUnregisterHandlerRequest,
20696                fdomain_client::fidl::FDomainResourceDialect,
20697            >::encode(
20698                (
20699                    <fidl::encoding::HandleType<
20700                        fdomain_client::Thread,
20701                        { fidl::ObjectType::THREAD.into_raw() },
20702                        2147483648,
20703                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20704                        &mut self.thread_handle,
20705                    ),
20706                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
20707                        &self.name,
20708                    ),
20709                ),
20710                encoder,
20711                offset,
20712                _depth,
20713            )
20714        }
20715    }
20716    unsafe impl<
20717        T0: fidl::encoding::Encode<
20718                fidl::encoding::HandleType<
20719                    fdomain_client::Thread,
20720                    { fidl::ObjectType::THREAD.into_raw() },
20721                    2147483648,
20722                >,
20723                fdomain_client::fidl::FDomainResourceDialect,
20724            >,
20725        T1: fidl::encoding::Encode<
20726                fidl::encoding::BoundedString<64>,
20727                fdomain_client::fidl::FDomainResourceDialect,
20728            >,
20729    >
20730        fidl::encoding::Encode<
20731            ProfileProviderUnregisterHandlerRequest,
20732            fdomain_client::fidl::FDomainResourceDialect,
20733        > for (T0, T1)
20734    {
20735        #[inline]
20736        unsafe fn encode(
20737            self,
20738            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20739            offset: usize,
20740            depth: fidl::encoding::Depth,
20741        ) -> fidl::Result<()> {
20742            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
20743            // Zero out padding regions. There's no need to apply masks
20744            // because the unmasked parts will be overwritten by fields.
20745            unsafe {
20746                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
20747                (ptr as *mut u64).write_unaligned(0);
20748            }
20749            // Write the fields.
20750            self.0.encode(encoder, offset + 0, depth)?;
20751            self.1.encode(encoder, offset + 8, depth)?;
20752            Ok(())
20753        }
20754    }
20755
20756    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20757        for ProfileProviderUnregisterHandlerRequest
20758    {
20759        #[inline(always)]
20760        fn new_empty() -> Self {
20761            Self {
20762                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20763                name: fidl::new_empty!(
20764                    fidl::encoding::BoundedString<64>,
20765                    fdomain_client::fidl::FDomainResourceDialect
20766                ),
20767            }
20768        }
20769
20770        #[inline]
20771        unsafe fn decode(
20772            &mut self,
20773            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20774            offset: usize,
20775            _depth: fidl::encoding::Depth,
20776        ) -> fidl::Result<()> {
20777            decoder.debug_check_bounds::<Self>(offset);
20778            // Verify that padding bytes are zero.
20779            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
20780            let padval = unsafe { (ptr as *const u64).read_unaligned() };
20781            let mask = 0xffffffff00000000u64;
20782            let maskedval = padval & mask;
20783            if maskedval != 0 {
20784                return Err(fidl::Error::NonZeroPadding {
20785                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
20786                });
20787            }
20788            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
20789            fidl::decode!(
20790                fidl::encoding::BoundedString<64>,
20791                fdomain_client::fidl::FDomainResourceDialect,
20792                &mut self.name,
20793                decoder,
20794                offset + 8,
20795                _depth
20796            )?;
20797            Ok(())
20798        }
20799    }
20800
20801    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
20802        type Borrowed<'a> = &'a mut Self;
20803        fn take_or_borrow<'a>(
20804            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20805        ) -> Self::Borrowed<'a> {
20806            value
20807        }
20808    }
20809
20810    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
20811        type Owned = Self;
20812
20813        #[inline(always)]
20814        fn inline_align(_context: fidl::encoding::Context) -> usize {
20815            4
20816        }
20817
20818        #[inline(always)]
20819        fn inline_size(_context: fidl::encoding::Context) -> usize {
20820            4
20821        }
20822    }
20823
20824    unsafe impl
20825        fidl::encoding::Encode<
20826            ProfileProviderUnregisterMemoryRangeRequest,
20827            fdomain_client::fidl::FDomainResourceDialect,
20828        > for &mut ProfileProviderUnregisterMemoryRangeRequest
20829    {
20830        #[inline]
20831        unsafe fn encode(
20832            self,
20833            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20834            offset: usize,
20835            _depth: fidl::encoding::Depth,
20836        ) -> fidl::Result<()> {
20837            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
20838            // Delegate to tuple encoding.
20839            fidl::encoding::Encode::<
20840                ProfileProviderUnregisterMemoryRangeRequest,
20841                fdomain_client::fidl::FDomainResourceDialect,
20842            >::encode(
20843                (<fidl::encoding::HandleType<
20844                    fdomain_client::Vmar,
20845                    { fidl::ObjectType::VMAR.into_raw() },
20846                    2147483648,
20847                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
20848                    &mut self.vmar_handle
20849                ),),
20850                encoder,
20851                offset,
20852                _depth,
20853            )
20854        }
20855    }
20856    unsafe impl<
20857        T0: fidl::encoding::Encode<
20858                fidl::encoding::HandleType<
20859                    fdomain_client::Vmar,
20860                    { fidl::ObjectType::VMAR.into_raw() },
20861                    2147483648,
20862                >,
20863                fdomain_client::fidl::FDomainResourceDialect,
20864            >,
20865    >
20866        fidl::encoding::Encode<
20867            ProfileProviderUnregisterMemoryRangeRequest,
20868            fdomain_client::fidl::FDomainResourceDialect,
20869        > for (T0,)
20870    {
20871        #[inline]
20872        unsafe fn encode(
20873            self,
20874            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20875            offset: usize,
20876            depth: fidl::encoding::Depth,
20877        ) -> fidl::Result<()> {
20878            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
20879            // Zero out padding regions. There's no need to apply masks
20880            // because the unmasked parts will be overwritten by fields.
20881            // Write the fields.
20882            self.0.encode(encoder, offset + 0, depth)?;
20883            Ok(())
20884        }
20885    }
20886
20887    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20888        for ProfileProviderUnregisterMemoryRangeRequest
20889    {
20890        #[inline(always)]
20891        fn new_empty() -> Self {
20892            Self {
20893                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
20894            }
20895        }
20896
20897        #[inline]
20898        unsafe fn decode(
20899            &mut self,
20900            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20901            offset: usize,
20902            _depth: fidl::encoding::Depth,
20903        ) -> fidl::Result<()> {
20904            decoder.debug_check_bounds::<Self>(offset);
20905            // Verify that padding bytes are zero.
20906            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
20907            Ok(())
20908        }
20909    }
20910
20911    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
20912        type Borrowed<'a> = &'a mut Self;
20913        fn take_or_borrow<'a>(
20914            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
20915        ) -> Self::Borrowed<'a> {
20916            value
20917        }
20918    }
20919
20920    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
20921        type Owned = Self;
20922
20923        #[inline(always)]
20924        fn inline_align(_context: fidl::encoding::Context) -> usize {
20925            8
20926        }
20927
20928        #[inline(always)]
20929        fn inline_size(_context: fidl::encoding::Context) -> usize {
20930            16
20931        }
20932    }
20933
20934    unsafe impl
20935        fidl::encoding::Encode<
20936            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
20937            fdomain_client::fidl::FDomainResourceDialect,
20938        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
20939    {
20940        #[inline]
20941        unsafe fn encode(
20942            self,
20943            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20944            offset: usize,
20945            _depth: fidl::encoding::Depth,
20946        ) -> fidl::Result<()> {
20947            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
20948                offset,
20949            );
20950            // Delegate to tuple encoding.
20951            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
20952                (
20953                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
20954                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
20955                ),
20956                encoder, offset, _depth
20957            )
20958        }
20959    }
20960    unsafe impl<
20961        T0: fidl::encoding::Encode<u64, fdomain_client::fidl::FDomainResourceDialect>,
20962        T1: fidl::encoding::Encode<
20963                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
20964                fdomain_client::fidl::FDomainResourceDialect,
20965            >,
20966    >
20967        fidl::encoding::Encode<
20968            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
20969            fdomain_client::fidl::FDomainResourceDialect,
20970        > for (T0, T1)
20971    {
20972        #[inline]
20973        unsafe fn encode(
20974            self,
20975            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
20976            offset: usize,
20977            depth: fidl::encoding::Depth,
20978        ) -> fidl::Result<()> {
20979            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
20980                offset,
20981            );
20982            // Zero out padding regions. There's no need to apply masks
20983            // because the unmasked parts will be overwritten by fields.
20984            unsafe {
20985                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
20986                (ptr as *mut u64).write_unaligned(0);
20987            }
20988            // Write the fields.
20989            self.0.encode(encoder, offset + 0, depth)?;
20990            self.1.encode(encoder, offset + 8, depth)?;
20991            Ok(())
20992        }
20993    }
20994
20995    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
20996        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
20997    {
20998        #[inline(always)]
20999        fn new_empty() -> Self {
21000            Self {
21001                session_id: fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect),
21002                audio_consumer_request: fidl::new_empty!(
21003                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21004                    fdomain_client::fidl::FDomainResourceDialect
21005                ),
21006            }
21007        }
21008
21009        #[inline]
21010        unsafe fn decode(
21011            &mut self,
21012            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21013            offset: usize,
21014            _depth: fidl::encoding::Depth,
21015        ) -> fidl::Result<()> {
21016            decoder.debug_check_bounds::<Self>(offset);
21017            // Verify that padding bytes are zero.
21018            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
21019            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21020            let mask = 0xffffffff00000000u64;
21021            let maskedval = padval & mask;
21022            if maskedval != 0 {
21023                return Err(fidl::Error::NonZeroPadding {
21024                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
21025                });
21026            }
21027            fidl::decode!(
21028                u64,
21029                fdomain_client::fidl::FDomainResourceDialect,
21030                &mut self.session_id,
21031                decoder,
21032                offset + 0,
21033                _depth
21034            )?;
21035            fidl::decode!(
21036                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21037                fdomain_client::fidl::FDomainResourceDialect,
21038                &mut self.audio_consumer_request,
21039                decoder,
21040                offset + 8,
21041                _depth
21042            )?;
21043            Ok(())
21044        }
21045    }
21046
21047    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
21048        type Borrowed<'a> = &'a mut Self;
21049        fn take_or_borrow<'a>(
21050            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21051        ) -> Self::Borrowed<'a> {
21052            value
21053        }
21054    }
21055
21056    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
21057        type Owned = Self;
21058
21059        #[inline(always)]
21060        fn inline_align(_context: fidl::encoding::Context) -> usize {
21061            4
21062        }
21063
21064        #[inline(always)]
21065        fn inline_size(_context: fidl::encoding::Context) -> usize {
21066            8
21067        }
21068    }
21069
21070    unsafe impl
21071        fidl::encoding::Encode<
21072            StreamBufferSetAddPayloadBufferRequest,
21073            fdomain_client::fidl::FDomainResourceDialect,
21074        > for &mut StreamBufferSetAddPayloadBufferRequest
21075    {
21076        #[inline]
21077        unsafe fn encode(
21078            self,
21079            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21080            offset: usize,
21081            _depth: fidl::encoding::Depth,
21082        ) -> fidl::Result<()> {
21083            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
21084            // Delegate to tuple encoding.
21085            fidl::encoding::Encode::<
21086                StreamBufferSetAddPayloadBufferRequest,
21087                fdomain_client::fidl::FDomainResourceDialect,
21088            >::encode(
21089                (
21090                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
21091                    <fidl::encoding::HandleType<
21092                        fdomain_client::Vmo,
21093                        { fidl::ObjectType::VMO.into_raw() },
21094                        2147483648,
21095                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21096                        &mut self.payload_buffer,
21097                    ),
21098                ),
21099                encoder,
21100                offset,
21101                _depth,
21102            )
21103        }
21104    }
21105    unsafe impl<
21106        T0: fidl::encoding::Encode<u32, fdomain_client::fidl::FDomainResourceDialect>,
21107        T1: fidl::encoding::Encode<
21108                fidl::encoding::HandleType<
21109                    fdomain_client::Vmo,
21110                    { fidl::ObjectType::VMO.into_raw() },
21111                    2147483648,
21112                >,
21113                fdomain_client::fidl::FDomainResourceDialect,
21114            >,
21115    >
21116        fidl::encoding::Encode<
21117            StreamBufferSetAddPayloadBufferRequest,
21118            fdomain_client::fidl::FDomainResourceDialect,
21119        > for (T0, T1)
21120    {
21121        #[inline]
21122        unsafe fn encode(
21123            self,
21124            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21125            offset: usize,
21126            depth: fidl::encoding::Depth,
21127        ) -> fidl::Result<()> {
21128            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
21129            // Zero out padding regions. There's no need to apply masks
21130            // because the unmasked parts will be overwritten by fields.
21131            // Write the fields.
21132            self.0.encode(encoder, offset + 0, depth)?;
21133            self.1.encode(encoder, offset + 4, depth)?;
21134            Ok(())
21135        }
21136    }
21137
21138    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21139        for StreamBufferSetAddPayloadBufferRequest
21140    {
21141        #[inline(always)]
21142        fn new_empty() -> Self {
21143            Self {
21144                id: fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect),
21145                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
21146            }
21147        }
21148
21149        #[inline]
21150        unsafe fn decode(
21151            &mut self,
21152            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21153            offset: usize,
21154            _depth: fidl::encoding::Depth,
21155        ) -> fidl::Result<()> {
21156            decoder.debug_check_bounds::<Self>(offset);
21157            // Verify that padding bytes are zero.
21158            fidl::decode!(
21159                u32,
21160                fdomain_client::fidl::FDomainResourceDialect,
21161                &mut self.id,
21162                decoder,
21163                offset + 0,
21164                _depth
21165            )?;
21166            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
21167            Ok(())
21168        }
21169    }
21170
21171    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
21172        type Borrowed<'a> = &'a mut Self;
21173        fn take_or_borrow<'a>(
21174            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21175        ) -> Self::Borrowed<'a> {
21176            value
21177        }
21178    }
21179
21180    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
21181        type Owned = Self;
21182
21183        #[inline(always)]
21184        fn inline_align(_context: fidl::encoding::Context) -> usize {
21185            8
21186        }
21187
21188        #[inline(always)]
21189        fn inline_size(_context: fidl::encoding::Context) -> usize {
21190            16
21191        }
21192    }
21193
21194    unsafe impl
21195        fidl::encoding::Encode<
21196            StreamProcessorSetInputBufferPartialSettingsRequest,
21197            fdomain_client::fidl::FDomainResourceDialect,
21198        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
21199    {
21200        #[inline]
21201        unsafe fn encode(
21202            self,
21203            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21204            offset: usize,
21205            _depth: fidl::encoding::Depth,
21206        ) -> fidl::Result<()> {
21207            encoder
21208                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
21209            // Delegate to tuple encoding.
21210            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21211                (
21212                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
21213                ),
21214                encoder, offset, _depth
21215            )
21216        }
21217    }
21218    unsafe impl<
21219        T0: fidl::encoding::Encode<
21220                StreamBufferPartialSettings,
21221                fdomain_client::fidl::FDomainResourceDialect,
21222            >,
21223    >
21224        fidl::encoding::Encode<
21225            StreamProcessorSetInputBufferPartialSettingsRequest,
21226            fdomain_client::fidl::FDomainResourceDialect,
21227        > for (T0,)
21228    {
21229        #[inline]
21230        unsafe fn encode(
21231            self,
21232            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21233            offset: usize,
21234            depth: fidl::encoding::Depth,
21235        ) -> fidl::Result<()> {
21236            encoder
21237                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
21238            // Zero out padding regions. There's no need to apply masks
21239            // because the unmasked parts will be overwritten by fields.
21240            // Write the fields.
21241            self.0.encode(encoder, offset + 0, depth)?;
21242            Ok(())
21243        }
21244    }
21245
21246    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21247        for StreamProcessorSetInputBufferPartialSettingsRequest
21248    {
21249        #[inline(always)]
21250        fn new_empty() -> Self {
21251            Self {
21252                input_settings: fidl::new_empty!(
21253                    StreamBufferPartialSettings,
21254                    fdomain_client::fidl::FDomainResourceDialect
21255                ),
21256            }
21257        }
21258
21259        #[inline]
21260        unsafe fn decode(
21261            &mut self,
21262            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21263            offset: usize,
21264            _depth: fidl::encoding::Depth,
21265        ) -> fidl::Result<()> {
21266            decoder.debug_check_bounds::<Self>(offset);
21267            // Verify that padding bytes are zero.
21268            fidl::decode!(
21269                StreamBufferPartialSettings,
21270                fdomain_client::fidl::FDomainResourceDialect,
21271                &mut self.input_settings,
21272                decoder,
21273                offset + 0,
21274                _depth
21275            )?;
21276            Ok(())
21277        }
21278    }
21279
21280    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
21281        type Borrowed<'a> = &'a mut Self;
21282        fn take_or_borrow<'a>(
21283            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21284        ) -> Self::Borrowed<'a> {
21285            value
21286        }
21287    }
21288
21289    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
21290        type Owned = Self;
21291
21292        #[inline(always)]
21293        fn inline_align(_context: fidl::encoding::Context) -> usize {
21294            8
21295        }
21296
21297        #[inline(always)]
21298        fn inline_size(_context: fidl::encoding::Context) -> usize {
21299            16
21300        }
21301    }
21302
21303    unsafe impl
21304        fidl::encoding::Encode<
21305            StreamProcessorSetOutputBufferPartialSettingsRequest,
21306            fdomain_client::fidl::FDomainResourceDialect,
21307        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
21308    {
21309        #[inline]
21310        unsafe fn encode(
21311            self,
21312            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21313            offset: usize,
21314            _depth: fidl::encoding::Depth,
21315        ) -> fidl::Result<()> {
21316            encoder
21317                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
21318            // Delegate to tuple encoding.
21319            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21320                (
21321                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
21322                ),
21323                encoder, offset, _depth
21324            )
21325        }
21326    }
21327    unsafe impl<
21328        T0: fidl::encoding::Encode<
21329                StreamBufferPartialSettings,
21330                fdomain_client::fidl::FDomainResourceDialect,
21331            >,
21332    >
21333        fidl::encoding::Encode<
21334            StreamProcessorSetOutputBufferPartialSettingsRequest,
21335            fdomain_client::fidl::FDomainResourceDialect,
21336        > for (T0,)
21337    {
21338        #[inline]
21339        unsafe fn encode(
21340            self,
21341            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21342            offset: usize,
21343            depth: fidl::encoding::Depth,
21344        ) -> fidl::Result<()> {
21345            encoder
21346                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
21347            // Zero out padding regions. There's no need to apply masks
21348            // because the unmasked parts will be overwritten by fields.
21349            // Write the fields.
21350            self.0.encode(encoder, offset + 0, depth)?;
21351            Ok(())
21352        }
21353    }
21354
21355    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21356        for StreamProcessorSetOutputBufferPartialSettingsRequest
21357    {
21358        #[inline(always)]
21359        fn new_empty() -> Self {
21360            Self {
21361                output_settings: fidl::new_empty!(
21362                    StreamBufferPartialSettings,
21363                    fdomain_client::fidl::FDomainResourceDialect
21364                ),
21365            }
21366        }
21367
21368        #[inline]
21369        unsafe fn decode(
21370            &mut self,
21371            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21372            offset: usize,
21373            _depth: fidl::encoding::Depth,
21374        ) -> fidl::Result<()> {
21375            decoder.debug_check_bounds::<Self>(offset);
21376            // Verify that padding bytes are zero.
21377            fidl::decode!(
21378                StreamBufferPartialSettings,
21379                fdomain_client::fidl::FDomainResourceDialect,
21380                &mut self.output_settings,
21381                decoder,
21382                offset + 0,
21383                _depth
21384            )?;
21385            Ok(())
21386        }
21387    }
21388
21389    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
21390        type Borrowed<'a> = &'a mut Self;
21391        fn take_or_borrow<'a>(
21392            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21393        ) -> Self::Borrowed<'a> {
21394            value
21395        }
21396    }
21397
21398    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
21399        type Owned = Self;
21400
21401        #[inline(always)]
21402        fn inline_align(_context: fidl::encoding::Context) -> usize {
21403            4
21404        }
21405
21406        #[inline(always)]
21407        fn inline_size(_context: fidl::encoding::Context) -> usize {
21408            8
21409        }
21410    }
21411
21412    unsafe impl
21413        fidl::encoding::Encode<
21414            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
21415            fdomain_client::fidl::FDomainResourceDialect,
21416        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
21417    {
21418        #[inline]
21419        unsafe fn encode(
21420            self,
21421            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21422            offset: usize,
21423            _depth: fidl::encoding::Depth,
21424        ) -> fidl::Result<()> {
21425            encoder
21426                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21427            // Delegate to tuple encoding.
21428            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21429                (
21430                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21431                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
21432                ),
21433                encoder, offset, _depth
21434            )
21435        }
21436    }
21437    unsafe impl<
21438        T0: fidl::encoding::Encode<AudioRenderUsage2, fdomain_client::fidl::FDomainResourceDialect>,
21439        T1: fidl::encoding::Encode<
21440                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21441                fdomain_client::fidl::FDomainResourceDialect,
21442            >,
21443    >
21444        fidl::encoding::Encode<
21445            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
21446            fdomain_client::fidl::FDomainResourceDialect,
21447        > for (T0, T1)
21448    {
21449        #[inline]
21450        unsafe fn encode(
21451            self,
21452            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21453            offset: usize,
21454            depth: fidl::encoding::Depth,
21455        ) -> fidl::Result<()> {
21456            encoder
21457                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21458            // Zero out padding regions. There's no need to apply masks
21459            // because the unmasked parts will be overwritten by fields.
21460            // Write the fields.
21461            self.0.encode(encoder, offset + 0, depth)?;
21462            self.1.encode(encoder, offset + 4, depth)?;
21463            Ok(())
21464        }
21465    }
21466
21467    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21468        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
21469    {
21470        #[inline(always)]
21471        fn new_empty() -> Self {
21472            Self {
21473                usage: fidl::new_empty!(
21474                    AudioRenderUsage2,
21475                    fdomain_client::fidl::FDomainResourceDialect
21476                ),
21477                audio_consumer_request: fidl::new_empty!(
21478                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21479                    fdomain_client::fidl::FDomainResourceDialect
21480                ),
21481            }
21482        }
21483
21484        #[inline]
21485        unsafe fn decode(
21486            &mut self,
21487            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21488            offset: usize,
21489            _depth: fidl::encoding::Depth,
21490        ) -> fidl::Result<()> {
21491            decoder.debug_check_bounds::<Self>(offset);
21492            // Verify that padding bytes are zero.
21493            fidl::decode!(
21494                AudioRenderUsage2,
21495                fdomain_client::fidl::FDomainResourceDialect,
21496                &mut self.usage,
21497                decoder,
21498                offset + 0,
21499                _depth
21500            )?;
21501            fidl::decode!(
21502                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21503                fdomain_client::fidl::FDomainResourceDialect,
21504                &mut self.audio_consumer_request,
21505                decoder,
21506                offset + 4,
21507                _depth
21508            )?;
21509            Ok(())
21510        }
21511    }
21512
21513    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
21514        type Borrowed<'a> = &'a mut Self;
21515        fn take_or_borrow<'a>(
21516            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21517        ) -> Self::Borrowed<'a> {
21518            value
21519        }
21520    }
21521
21522    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
21523        type Owned = Self;
21524
21525        #[inline(always)]
21526        fn inline_align(_context: fidl::encoding::Context) -> usize {
21527            4
21528        }
21529
21530        #[inline(always)]
21531        fn inline_size(_context: fidl::encoding::Context) -> usize {
21532            8
21533        }
21534    }
21535
21536    unsafe impl
21537        fidl::encoding::Encode<
21538            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
21539            fdomain_client::fidl::FDomainResourceDialect,
21540        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
21541    {
21542        #[inline]
21543        unsafe fn encode(
21544            self,
21545            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21546            offset: usize,
21547            _depth: fidl::encoding::Depth,
21548        ) -> fidl::Result<()> {
21549            encoder
21550                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21551            // Delegate to tuple encoding.
21552            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
21553                (
21554                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21555                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
21556                ),
21557                encoder, offset, _depth
21558            )
21559        }
21560    }
21561    unsafe impl<
21562        T0: fidl::encoding::Encode<AudioRenderUsage, fdomain_client::fidl::FDomainResourceDialect>,
21563        T1: fidl::encoding::Encode<
21564                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21565                fdomain_client::fidl::FDomainResourceDialect,
21566            >,
21567    >
21568        fidl::encoding::Encode<
21569            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
21570            fdomain_client::fidl::FDomainResourceDialect,
21571        > for (T0, T1)
21572    {
21573        #[inline]
21574        unsafe fn encode(
21575            self,
21576            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21577            offset: usize,
21578            depth: fidl::encoding::Depth,
21579        ) -> fidl::Result<()> {
21580            encoder
21581                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
21582            // Zero out padding regions. There's no need to apply masks
21583            // because the unmasked parts will be overwritten by fields.
21584            // Write the fields.
21585            self.0.encode(encoder, offset + 0, depth)?;
21586            self.1.encode(encoder, offset + 4, depth)?;
21587            Ok(())
21588        }
21589    }
21590
21591    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21592        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
21593    {
21594        #[inline(always)]
21595        fn new_empty() -> Self {
21596            Self {
21597                usage: fidl::new_empty!(
21598                    AudioRenderUsage,
21599                    fdomain_client::fidl::FDomainResourceDialect
21600                ),
21601                audio_consumer_request: fidl::new_empty!(
21602                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21603                    fdomain_client::fidl::FDomainResourceDialect
21604                ),
21605            }
21606        }
21607
21608        #[inline]
21609        unsafe fn decode(
21610            &mut self,
21611            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21612            offset: usize,
21613            _depth: fidl::encoding::Depth,
21614        ) -> fidl::Result<()> {
21615            decoder.debug_check_bounds::<Self>(offset);
21616            // Verify that padding bytes are zero.
21617            fidl::decode!(
21618                AudioRenderUsage,
21619                fdomain_client::fidl::FDomainResourceDialect,
21620                &mut self.usage,
21621                decoder,
21622                offset + 0,
21623                _depth
21624            )?;
21625            fidl::decode!(
21626                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<AudioConsumerMarker>>,
21627                fdomain_client::fidl::FDomainResourceDialect,
21628                &mut self.audio_consumer_request,
21629                decoder,
21630                offset + 4,
21631                _depth
21632            )?;
21633            Ok(())
21634        }
21635    }
21636
21637    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
21638        type Borrowed<'a> = &'a mut Self;
21639        fn take_or_borrow<'a>(
21640            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21641        ) -> Self::Borrowed<'a> {
21642            value
21643        }
21644    }
21645
21646    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
21647        type Owned = Self;
21648
21649        #[inline(always)]
21650        fn inline_align(_context: fidl::encoding::Context) -> usize {
21651            8
21652        }
21653
21654        #[inline(always)]
21655        fn inline_size(_context: fidl::encoding::Context) -> usize {
21656            40
21657        }
21658    }
21659
21660    unsafe impl
21661        fidl::encoding::Encode<
21662            UsageGainReporterRegisterListener2Request,
21663            fdomain_client::fidl::FDomainResourceDialect,
21664        > for &mut UsageGainReporterRegisterListener2Request
21665    {
21666        #[inline]
21667        unsafe fn encode(
21668            self,
21669            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21670            offset: usize,
21671            _depth: fidl::encoding::Depth,
21672        ) -> fidl::Result<()> {
21673            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
21674            // Delegate to tuple encoding.
21675            fidl::encoding::Encode::<
21676                UsageGainReporterRegisterListener2Request,
21677                fdomain_client::fidl::FDomainResourceDialect,
21678            >::encode(
21679                (
21680                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(
21681                        &self.device_unique_id,
21682                    ),
21683                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21684                    <fidl::encoding::Endpoint<
21685                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21686                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21687                        &mut self.usage_gain_listener,
21688                    ),
21689                ),
21690                encoder,
21691                offset,
21692                _depth,
21693            )
21694        }
21695    }
21696    unsafe impl<
21697        T0: fidl::encoding::Encode<
21698                fidl::encoding::BoundedString<36>,
21699                fdomain_client::fidl::FDomainResourceDialect,
21700            >,
21701        T1: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
21702        T2: fidl::encoding::Encode<
21703                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21704                fdomain_client::fidl::FDomainResourceDialect,
21705            >,
21706    >
21707        fidl::encoding::Encode<
21708            UsageGainReporterRegisterListener2Request,
21709            fdomain_client::fidl::FDomainResourceDialect,
21710        > for (T0, T1, T2)
21711    {
21712        #[inline]
21713        unsafe fn encode(
21714            self,
21715            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21716            offset: usize,
21717            depth: fidl::encoding::Depth,
21718        ) -> fidl::Result<()> {
21719            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
21720            // Zero out padding regions. There's no need to apply masks
21721            // because the unmasked parts will be overwritten by fields.
21722            unsafe {
21723                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21724                (ptr as *mut u64).write_unaligned(0);
21725            }
21726            // Write the fields.
21727            self.0.encode(encoder, offset + 0, depth)?;
21728            self.1.encode(encoder, offset + 16, depth)?;
21729            self.2.encode(encoder, offset + 32, depth)?;
21730            Ok(())
21731        }
21732    }
21733
21734    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21735        for UsageGainReporterRegisterListener2Request
21736    {
21737        #[inline(always)]
21738        fn new_empty() -> Self {
21739            Self {
21740                device_unique_id: fidl::new_empty!(
21741                    fidl::encoding::BoundedString<36>,
21742                    fdomain_client::fidl::FDomainResourceDialect
21743                ),
21744                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
21745                usage_gain_listener: fidl::new_empty!(
21746                    fidl::encoding::Endpoint<
21747                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21748                    >,
21749                    fdomain_client::fidl::FDomainResourceDialect
21750                ),
21751            }
21752        }
21753
21754        #[inline]
21755        unsafe fn decode(
21756            &mut self,
21757            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21758            offset: usize,
21759            _depth: fidl::encoding::Depth,
21760        ) -> fidl::Result<()> {
21761            decoder.debug_check_bounds::<Self>(offset);
21762            // Verify that padding bytes are zero.
21763            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21764            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21765            let mask = 0xffffffff00000000u64;
21766            let maskedval = padval & mask;
21767            if maskedval != 0 {
21768                return Err(fidl::Error::NonZeroPadding {
21769                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21770                });
21771            }
21772            fidl::decode!(
21773                fidl::encoding::BoundedString<36>,
21774                fdomain_client::fidl::FDomainResourceDialect,
21775                &mut self.device_unique_id,
21776                decoder,
21777                offset + 0,
21778                _depth
21779            )?;
21780            fidl::decode!(
21781                Usage2,
21782                fdomain_client::fidl::FDomainResourceDialect,
21783                &mut self.usage,
21784                decoder,
21785                offset + 16,
21786                _depth
21787            )?;
21788            fidl::decode!(
21789                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21790                fdomain_client::fidl::FDomainResourceDialect,
21791                &mut self.usage_gain_listener,
21792                decoder,
21793                offset + 32,
21794                _depth
21795            )?;
21796            Ok(())
21797        }
21798    }
21799
21800    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
21801        type Borrowed<'a> = &'a mut Self;
21802        fn take_or_borrow<'a>(
21803            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21804        ) -> Self::Borrowed<'a> {
21805            value
21806        }
21807    }
21808
21809    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
21810        type Owned = Self;
21811
21812        #[inline(always)]
21813        fn inline_align(_context: fidl::encoding::Context) -> usize {
21814            8
21815        }
21816
21817        #[inline(always)]
21818        fn inline_size(_context: fidl::encoding::Context) -> usize {
21819            40
21820        }
21821    }
21822
21823    unsafe impl
21824        fidl::encoding::Encode<
21825            UsageGainReporterRegisterListenerRequest,
21826            fdomain_client::fidl::FDomainResourceDialect,
21827        > for &mut UsageGainReporterRegisterListenerRequest
21828    {
21829        #[inline]
21830        unsafe fn encode(
21831            self,
21832            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21833            offset: usize,
21834            _depth: fidl::encoding::Depth,
21835        ) -> fidl::Result<()> {
21836            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
21837            // Delegate to tuple encoding.
21838            fidl::encoding::Encode::<
21839                UsageGainReporterRegisterListenerRequest,
21840                fdomain_client::fidl::FDomainResourceDialect,
21841            >::encode(
21842                (
21843                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(
21844                        &self.device_unique_id,
21845                    ),
21846                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
21847                    <fidl::encoding::Endpoint<
21848                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21849                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
21850                        &mut self.usage_gain_listener,
21851                    ),
21852                ),
21853                encoder,
21854                offset,
21855                _depth,
21856            )
21857        }
21858    }
21859    unsafe impl<
21860        T0: fidl::encoding::Encode<
21861                fidl::encoding::BoundedString<36>,
21862                fdomain_client::fidl::FDomainResourceDialect,
21863            >,
21864        T1: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
21865        T2: fidl::encoding::Encode<
21866                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21867                fdomain_client::fidl::FDomainResourceDialect,
21868            >,
21869    >
21870        fidl::encoding::Encode<
21871            UsageGainReporterRegisterListenerRequest,
21872            fdomain_client::fidl::FDomainResourceDialect,
21873        > for (T0, T1, T2)
21874    {
21875        #[inline]
21876        unsafe fn encode(
21877            self,
21878            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21879            offset: usize,
21880            depth: fidl::encoding::Depth,
21881        ) -> fidl::Result<()> {
21882            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
21883            // Zero out padding regions. There's no need to apply masks
21884            // because the unmasked parts will be overwritten by fields.
21885            unsafe {
21886                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
21887                (ptr as *mut u64).write_unaligned(0);
21888            }
21889            // Write the fields.
21890            self.0.encode(encoder, offset + 0, depth)?;
21891            self.1.encode(encoder, offset + 16, depth)?;
21892            self.2.encode(encoder, offset + 32, depth)?;
21893            Ok(())
21894        }
21895    }
21896
21897    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
21898        for UsageGainReporterRegisterListenerRequest
21899    {
21900        #[inline(always)]
21901        fn new_empty() -> Self {
21902            Self {
21903                device_unique_id: fidl::new_empty!(
21904                    fidl::encoding::BoundedString<36>,
21905                    fdomain_client::fidl::FDomainResourceDialect
21906                ),
21907                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
21908                usage_gain_listener: fidl::new_empty!(
21909                    fidl::encoding::Endpoint<
21910                        fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>,
21911                    >,
21912                    fdomain_client::fidl::FDomainResourceDialect
21913                ),
21914            }
21915        }
21916
21917        #[inline]
21918        unsafe fn decode(
21919            &mut self,
21920            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21921            offset: usize,
21922            _depth: fidl::encoding::Depth,
21923        ) -> fidl::Result<()> {
21924            decoder.debug_check_bounds::<Self>(offset);
21925            // Verify that padding bytes are zero.
21926            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
21927            let padval = unsafe { (ptr as *const u64).read_unaligned() };
21928            let mask = 0xffffffff00000000u64;
21929            let maskedval = padval & mask;
21930            if maskedval != 0 {
21931                return Err(fidl::Error::NonZeroPadding {
21932                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
21933                });
21934            }
21935            fidl::decode!(
21936                fidl::encoding::BoundedString<36>,
21937                fdomain_client::fidl::FDomainResourceDialect,
21938                &mut self.device_unique_id,
21939                decoder,
21940                offset + 0,
21941                _depth
21942            )?;
21943            fidl::decode!(
21944                Usage,
21945                fdomain_client::fidl::FDomainResourceDialect,
21946                &mut self.usage,
21947                decoder,
21948                offset + 16,
21949                _depth
21950            )?;
21951            fidl::decode!(
21952                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageGainListenerMarker>>,
21953                fdomain_client::fidl::FDomainResourceDialect,
21954                &mut self.usage_gain_listener,
21955                decoder,
21956                offset + 32,
21957                _depth
21958            )?;
21959            Ok(())
21960        }
21961    }
21962
21963    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
21964        type Borrowed<'a> = &'a mut Self;
21965        fn take_or_borrow<'a>(
21966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
21967        ) -> Self::Borrowed<'a> {
21968            value
21969        }
21970    }
21971
21972    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
21973        type Owned = Self;
21974
21975        #[inline(always)]
21976        fn inline_align(_context: fidl::encoding::Context) -> usize {
21977            8
21978        }
21979
21980        #[inline(always)]
21981        fn inline_size(_context: fidl::encoding::Context) -> usize {
21982            24
21983        }
21984    }
21985
21986    unsafe impl
21987        fidl::encoding::Encode<
21988            UsageReporterWatch2Request,
21989            fdomain_client::fidl::FDomainResourceDialect,
21990        > for &mut UsageReporterWatch2Request
21991    {
21992        #[inline]
21993        unsafe fn encode(
21994            self,
21995            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
21996            offset: usize,
21997            _depth: fidl::encoding::Depth,
21998        ) -> fidl::Result<()> {
21999            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
22000            // Delegate to tuple encoding.
22001            fidl::encoding::Encode::<UsageReporterWatch2Request, fdomain_client::fidl::FDomainResourceDialect>::encode(
22002                (
22003                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
22004                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
22005                ),
22006                encoder, offset, _depth
22007            )
22008        }
22009    }
22010    unsafe impl<
22011        T0: fidl::encoding::Encode<Usage2, fdomain_client::fidl::FDomainResourceDialect>,
22012        T1: fidl::encoding::Encode<
22013                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
22014                fdomain_client::fidl::FDomainResourceDialect,
22015            >,
22016    >
22017        fidl::encoding::Encode<
22018            UsageReporterWatch2Request,
22019            fdomain_client::fidl::FDomainResourceDialect,
22020        > for (T0, T1)
22021    {
22022        #[inline]
22023        unsafe fn encode(
22024            self,
22025            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22026            offset: usize,
22027            depth: fidl::encoding::Depth,
22028        ) -> fidl::Result<()> {
22029            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
22030            // Zero out padding regions. There's no need to apply masks
22031            // because the unmasked parts will be overwritten by fields.
22032            unsafe {
22033                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22034                (ptr as *mut u64).write_unaligned(0);
22035            }
22036            // Write the fields.
22037            self.0.encode(encoder, offset + 0, depth)?;
22038            self.1.encode(encoder, offset + 16, depth)?;
22039            Ok(())
22040        }
22041    }
22042
22043    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
22044        for UsageReporterWatch2Request
22045    {
22046        #[inline(always)]
22047        fn new_empty() -> Self {
22048            Self {
22049                usage: fidl::new_empty!(Usage2, fdomain_client::fidl::FDomainResourceDialect),
22050                usage_watcher: fidl::new_empty!(
22051                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
22052                    fdomain_client::fidl::FDomainResourceDialect
22053                ),
22054            }
22055        }
22056
22057        #[inline]
22058        unsafe fn decode(
22059            &mut self,
22060            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22061            offset: usize,
22062            _depth: fidl::encoding::Depth,
22063        ) -> fidl::Result<()> {
22064            decoder.debug_check_bounds::<Self>(offset);
22065            // Verify that padding bytes are zero.
22066            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22067            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22068            let mask = 0xffffffff00000000u64;
22069            let maskedval = padval & mask;
22070            if maskedval != 0 {
22071                return Err(fidl::Error::NonZeroPadding {
22072                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22073                });
22074            }
22075            fidl::decode!(
22076                Usage2,
22077                fdomain_client::fidl::FDomainResourceDialect,
22078                &mut self.usage,
22079                decoder,
22080                offset + 0,
22081                _depth
22082            )?;
22083            fidl::decode!(
22084                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcher2Marker>>,
22085                fdomain_client::fidl::FDomainResourceDialect,
22086                &mut self.usage_watcher,
22087                decoder,
22088                offset + 16,
22089                _depth
22090            )?;
22091            Ok(())
22092        }
22093    }
22094
22095    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
22096        type Borrowed<'a> = &'a mut Self;
22097        fn take_or_borrow<'a>(
22098            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22099        ) -> Self::Borrowed<'a> {
22100            value
22101        }
22102    }
22103
22104    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
22105        type Owned = Self;
22106
22107        #[inline(always)]
22108        fn inline_align(_context: fidl::encoding::Context) -> usize {
22109            8
22110        }
22111
22112        #[inline(always)]
22113        fn inline_size(_context: fidl::encoding::Context) -> usize {
22114            24
22115        }
22116    }
22117
22118    unsafe impl
22119        fidl::encoding::Encode<
22120            UsageReporterWatchRequest,
22121            fdomain_client::fidl::FDomainResourceDialect,
22122        > for &mut UsageReporterWatchRequest
22123    {
22124        #[inline]
22125        unsafe fn encode(
22126            self,
22127            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22128            offset: usize,
22129            _depth: fidl::encoding::Depth,
22130        ) -> fidl::Result<()> {
22131            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
22132            // Delegate to tuple encoding.
22133            fidl::encoding::Encode::<UsageReporterWatchRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
22134                (
22135                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
22136                    <fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
22137                ),
22138                encoder, offset, _depth
22139            )
22140        }
22141    }
22142    unsafe impl<
22143        T0: fidl::encoding::Encode<Usage, fdomain_client::fidl::FDomainResourceDialect>,
22144        T1: fidl::encoding::Encode<
22145                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
22146                fdomain_client::fidl::FDomainResourceDialect,
22147            >,
22148    >
22149        fidl::encoding::Encode<
22150            UsageReporterWatchRequest,
22151            fdomain_client::fidl::FDomainResourceDialect,
22152        > for (T0, T1)
22153    {
22154        #[inline]
22155        unsafe fn encode(
22156            self,
22157            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22158            offset: usize,
22159            depth: fidl::encoding::Depth,
22160        ) -> fidl::Result<()> {
22161            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
22162            // Zero out padding regions. There's no need to apply masks
22163            // because the unmasked parts will be overwritten by fields.
22164            unsafe {
22165                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
22166                (ptr as *mut u64).write_unaligned(0);
22167            }
22168            // Write the fields.
22169            self.0.encode(encoder, offset + 0, depth)?;
22170            self.1.encode(encoder, offset + 16, depth)?;
22171            Ok(())
22172        }
22173    }
22174
22175    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
22176        for UsageReporterWatchRequest
22177    {
22178        #[inline(always)]
22179        fn new_empty() -> Self {
22180            Self {
22181                usage: fidl::new_empty!(Usage, fdomain_client::fidl::FDomainResourceDialect),
22182                usage_watcher: fidl::new_empty!(
22183                    fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
22184                    fdomain_client::fidl::FDomainResourceDialect
22185                ),
22186            }
22187        }
22188
22189        #[inline]
22190        unsafe fn decode(
22191            &mut self,
22192            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22193            offset: usize,
22194            _depth: fidl::encoding::Depth,
22195        ) -> fidl::Result<()> {
22196            decoder.debug_check_bounds::<Self>(offset);
22197            // Verify that padding bytes are zero.
22198            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
22199            let padval = unsafe { (ptr as *const u64).read_unaligned() };
22200            let mask = 0xffffffff00000000u64;
22201            let maskedval = padval & mask;
22202            if maskedval != 0 {
22203                return Err(fidl::Error::NonZeroPadding {
22204                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
22205                });
22206            }
22207            fidl::decode!(
22208                Usage,
22209                fdomain_client::fidl::FDomainResourceDialect,
22210                &mut self.usage,
22211                decoder,
22212                offset + 0,
22213                _depth
22214            )?;
22215            fidl::decode!(
22216                fidl::encoding::Endpoint<fdomain_client::fidl::ClientEnd<UsageWatcherMarker>>,
22217                fdomain_client::fidl::FDomainResourceDialect,
22218                &mut self.usage_watcher,
22219                decoder,
22220                offset + 16,
22221                _depth
22222            )?;
22223            Ok(())
22224        }
22225    }
22226
22227    impl StreamBufferPartialSettings {
22228        #[inline(always)]
22229        fn max_ordinal_present(&self) -> u64 {
22230            if let Some(_) = self.sysmem2_token {
22231                return 7;
22232            }
22233            if let Some(_) = self.sysmem_token {
22234                return 6;
22235            }
22236            if let Some(_) = self.packet_count_for_client {
22237                return 5;
22238            }
22239            if let Some(_) = self.packet_count_for_server {
22240                return 4;
22241            }
22242            if let Some(_) = self.single_buffer_mode {
22243                return 3;
22244            }
22245            if let Some(_) = self.buffer_constraints_version_ordinal {
22246                return 2;
22247            }
22248            if let Some(_) = self.buffer_lifetime_ordinal {
22249                return 1;
22250            }
22251            0
22252        }
22253    }
22254
22255    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
22256        type Borrowed<'a> = &'a mut Self;
22257        fn take_or_borrow<'a>(
22258            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22259        ) -> Self::Borrowed<'a> {
22260            value
22261        }
22262    }
22263
22264    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
22265        type Owned = Self;
22266
22267        #[inline(always)]
22268        fn inline_align(_context: fidl::encoding::Context) -> usize {
22269            8
22270        }
22271
22272        #[inline(always)]
22273        fn inline_size(_context: fidl::encoding::Context) -> usize {
22274            16
22275        }
22276    }
22277
22278    unsafe impl
22279        fidl::encoding::Encode<
22280            StreamBufferPartialSettings,
22281            fdomain_client::fidl::FDomainResourceDialect,
22282        > for &mut StreamBufferPartialSettings
22283    {
22284        unsafe fn encode(
22285            self,
22286            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22287            offset: usize,
22288            mut depth: fidl::encoding::Depth,
22289        ) -> fidl::Result<()> {
22290            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
22291            // Vector header
22292            let max_ordinal: u64 = self.max_ordinal_present();
22293            encoder.write_num(max_ordinal, offset);
22294            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
22295            // Calling encoder.out_of_line_offset(0) is not allowed.
22296            if max_ordinal == 0 {
22297                return Ok(());
22298            }
22299            depth.increment()?;
22300            let envelope_size = 8;
22301            let bytes_len = max_ordinal as usize * envelope_size;
22302            #[allow(unused_variables)]
22303            let offset = encoder.out_of_line_offset(bytes_len);
22304            let mut _prev_end_offset: usize = 0;
22305            if 1 > max_ordinal {
22306                return Ok(());
22307            }
22308
22309            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22310            // are envelope_size bytes.
22311            let cur_offset: usize = (1 - 1) * envelope_size;
22312
22313            // Zero reserved fields.
22314            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22315
22316            // Safety:
22317            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22318            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22319            //   envelope_size bytes, there is always sufficient room.
22320            fidl::encoding::encode_in_envelope_optional::<
22321                u64,
22322                fdomain_client::fidl::FDomainResourceDialect,
22323            >(
22324                self.buffer_lifetime_ordinal
22325                    .as_ref()
22326                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
22327                encoder,
22328                offset + cur_offset,
22329                depth,
22330            )?;
22331
22332            _prev_end_offset = cur_offset + envelope_size;
22333            if 2 > max_ordinal {
22334                return Ok(());
22335            }
22336
22337            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22338            // are envelope_size bytes.
22339            let cur_offset: usize = (2 - 1) * envelope_size;
22340
22341            // Zero reserved fields.
22342            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22343
22344            // Safety:
22345            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22346            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22347            //   envelope_size bytes, there is always sufficient room.
22348            fidl::encoding::encode_in_envelope_optional::<
22349                u64,
22350                fdomain_client::fidl::FDomainResourceDialect,
22351            >(
22352                self.buffer_constraints_version_ordinal
22353                    .as_ref()
22354                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
22355                encoder,
22356                offset + cur_offset,
22357                depth,
22358            )?;
22359
22360            _prev_end_offset = cur_offset + envelope_size;
22361            if 3 > max_ordinal {
22362                return Ok(());
22363            }
22364
22365            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22366            // are envelope_size bytes.
22367            let cur_offset: usize = (3 - 1) * envelope_size;
22368
22369            // Zero reserved fields.
22370            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22371
22372            // Safety:
22373            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22374            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22375            //   envelope_size bytes, there is always sufficient room.
22376            fidl::encoding::encode_in_envelope_optional::<
22377                bool,
22378                fdomain_client::fidl::FDomainResourceDialect,
22379            >(
22380                self.single_buffer_mode
22381                    .as_ref()
22382                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
22383                encoder,
22384                offset + cur_offset,
22385                depth,
22386            )?;
22387
22388            _prev_end_offset = cur_offset + envelope_size;
22389            if 4 > max_ordinal {
22390                return Ok(());
22391            }
22392
22393            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22394            // are envelope_size bytes.
22395            let cur_offset: usize = (4 - 1) * envelope_size;
22396
22397            // Zero reserved fields.
22398            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22399
22400            // Safety:
22401            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22402            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22403            //   envelope_size bytes, there is always sufficient room.
22404            fidl::encoding::encode_in_envelope_optional::<
22405                u32,
22406                fdomain_client::fidl::FDomainResourceDialect,
22407            >(
22408                self.packet_count_for_server
22409                    .as_ref()
22410                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
22411                encoder,
22412                offset + cur_offset,
22413                depth,
22414            )?;
22415
22416            _prev_end_offset = cur_offset + envelope_size;
22417            if 5 > max_ordinal {
22418                return Ok(());
22419            }
22420
22421            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22422            // are envelope_size bytes.
22423            let cur_offset: usize = (5 - 1) * envelope_size;
22424
22425            // Zero reserved fields.
22426            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22427
22428            // Safety:
22429            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22430            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22431            //   envelope_size bytes, there is always sufficient room.
22432            fidl::encoding::encode_in_envelope_optional::<
22433                u32,
22434                fdomain_client::fidl::FDomainResourceDialect,
22435            >(
22436                self.packet_count_for_client
22437                    .as_ref()
22438                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
22439                encoder,
22440                offset + cur_offset,
22441                depth,
22442            )?;
22443
22444            _prev_end_offset = cur_offset + envelope_size;
22445            if 6 > max_ordinal {
22446                return Ok(());
22447            }
22448
22449            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22450            // are envelope_size bytes.
22451            let cur_offset: usize = (6 - 1) * envelope_size;
22452
22453            // Zero reserved fields.
22454            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22455
22456            // Safety:
22457            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22458            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22459            //   envelope_size bytes, there is always sufficient room.
22460            fidl::encoding::encode_in_envelope_optional::<
22461                fidl::encoding::Endpoint<
22462                    fdomain_client::fidl::ClientEnd<
22463                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22464                    >,
22465                >,
22466                fdomain_client::fidl::FDomainResourceDialect,
22467            >(
22468                self.sysmem_token.as_mut().map(
22469                    <fidl::encoding::Endpoint<
22470                        fdomain_client::fidl::ClientEnd<
22471                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22472                        >,
22473                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
22474                ),
22475                encoder,
22476                offset + cur_offset,
22477                depth,
22478            )?;
22479
22480            _prev_end_offset = cur_offset + envelope_size;
22481            if 7 > max_ordinal {
22482                return Ok(());
22483            }
22484
22485            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
22486            // are envelope_size bytes.
22487            let cur_offset: usize = (7 - 1) * envelope_size;
22488
22489            // Zero reserved fields.
22490            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
22491
22492            // Safety:
22493            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
22494            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
22495            //   envelope_size bytes, there is always sufficient room.
22496            fidl::encoding::encode_in_envelope_optional::<
22497                fidl::encoding::Endpoint<
22498                    fdomain_client::fidl::ClientEnd<
22499                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22500                    >,
22501                >,
22502                fdomain_client::fidl::FDomainResourceDialect,
22503            >(
22504                self.sysmem2_token.as_mut().map(
22505                    <fidl::encoding::Endpoint<
22506                        fdomain_client::fidl::ClientEnd<
22507                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22508                        >,
22509                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
22510                ),
22511                encoder,
22512                offset + cur_offset,
22513                depth,
22514            )?;
22515
22516            _prev_end_offset = cur_offset + envelope_size;
22517
22518            Ok(())
22519        }
22520    }
22521
22522    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
22523        for StreamBufferPartialSettings
22524    {
22525        #[inline(always)]
22526        fn new_empty() -> Self {
22527            Self::default()
22528        }
22529
22530        unsafe fn decode(
22531            &mut self,
22532            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
22533            offset: usize,
22534            mut depth: fidl::encoding::Depth,
22535        ) -> fidl::Result<()> {
22536            decoder.debug_check_bounds::<Self>(offset);
22537            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
22538                None => return Err(fidl::Error::NotNullable),
22539                Some(len) => len,
22540            };
22541            // Calling decoder.out_of_line_offset(0) is not allowed.
22542            if len == 0 {
22543                return Ok(());
22544            };
22545            depth.increment()?;
22546            let envelope_size = 8;
22547            let bytes_len = len * envelope_size;
22548            let offset = decoder.out_of_line_offset(bytes_len)?;
22549            // Decode the envelope for each type.
22550            let mut _next_ordinal_to_read = 0;
22551            let mut next_offset = offset;
22552            let end_offset = offset + bytes_len;
22553            _next_ordinal_to_read += 1;
22554            if next_offset >= end_offset {
22555                return Ok(());
22556            }
22557
22558            // Decode unknown envelopes for gaps in ordinals.
22559            while _next_ordinal_to_read < 1 {
22560                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22561                _next_ordinal_to_read += 1;
22562                next_offset += envelope_size;
22563            }
22564
22565            let next_out_of_line = decoder.next_out_of_line();
22566            let handles_before = decoder.remaining_handles();
22567            if let Some((inlined, num_bytes, num_handles)) =
22568                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22569            {
22570                let member_inline_size =
22571                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22572                if inlined != (member_inline_size <= 4) {
22573                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22574                }
22575                let inner_offset;
22576                let mut inner_depth = depth.clone();
22577                if inlined {
22578                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22579                    inner_offset = next_offset;
22580                } else {
22581                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22582                    inner_depth.increment()?;
22583                }
22584                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
22585                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
22586                });
22587                fidl::decode!(
22588                    u64,
22589                    fdomain_client::fidl::FDomainResourceDialect,
22590                    val_ref,
22591                    decoder,
22592                    inner_offset,
22593                    inner_depth
22594                )?;
22595                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22596                {
22597                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22598                }
22599                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22600                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22601                }
22602            }
22603
22604            next_offset += envelope_size;
22605            _next_ordinal_to_read += 1;
22606            if next_offset >= end_offset {
22607                return Ok(());
22608            }
22609
22610            // Decode unknown envelopes for gaps in ordinals.
22611            while _next_ordinal_to_read < 2 {
22612                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22613                _next_ordinal_to_read += 1;
22614                next_offset += envelope_size;
22615            }
22616
22617            let next_out_of_line = decoder.next_out_of_line();
22618            let handles_before = decoder.remaining_handles();
22619            if let Some((inlined, num_bytes, num_handles)) =
22620                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22621            {
22622                let member_inline_size =
22623                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22624                if inlined != (member_inline_size <= 4) {
22625                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22626                }
22627                let inner_offset;
22628                let mut inner_depth = depth.clone();
22629                if inlined {
22630                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22631                    inner_offset = next_offset;
22632                } else {
22633                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22634                    inner_depth.increment()?;
22635                }
22636                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
22637                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
22638                });
22639                fidl::decode!(
22640                    u64,
22641                    fdomain_client::fidl::FDomainResourceDialect,
22642                    val_ref,
22643                    decoder,
22644                    inner_offset,
22645                    inner_depth
22646                )?;
22647                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22648                {
22649                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22650                }
22651                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22652                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22653                }
22654            }
22655
22656            next_offset += envelope_size;
22657            _next_ordinal_to_read += 1;
22658            if next_offset >= end_offset {
22659                return Ok(());
22660            }
22661
22662            // Decode unknown envelopes for gaps in ordinals.
22663            while _next_ordinal_to_read < 3 {
22664                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22665                _next_ordinal_to_read += 1;
22666                next_offset += envelope_size;
22667            }
22668
22669            let next_out_of_line = decoder.next_out_of_line();
22670            let handles_before = decoder.remaining_handles();
22671            if let Some((inlined, num_bytes, num_handles)) =
22672                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22673            {
22674                let member_inline_size =
22675                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22676                if inlined != (member_inline_size <= 4) {
22677                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22678                }
22679                let inner_offset;
22680                let mut inner_depth = depth.clone();
22681                if inlined {
22682                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22683                    inner_offset = next_offset;
22684                } else {
22685                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22686                    inner_depth.increment()?;
22687                }
22688                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
22689                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
22690                });
22691                fidl::decode!(
22692                    bool,
22693                    fdomain_client::fidl::FDomainResourceDialect,
22694                    val_ref,
22695                    decoder,
22696                    inner_offset,
22697                    inner_depth
22698                )?;
22699                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22700                {
22701                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22702                }
22703                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22704                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22705                }
22706            }
22707
22708            next_offset += envelope_size;
22709            _next_ordinal_to_read += 1;
22710            if next_offset >= end_offset {
22711                return Ok(());
22712            }
22713
22714            // Decode unknown envelopes for gaps in ordinals.
22715            while _next_ordinal_to_read < 4 {
22716                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22717                _next_ordinal_to_read += 1;
22718                next_offset += envelope_size;
22719            }
22720
22721            let next_out_of_line = decoder.next_out_of_line();
22722            let handles_before = decoder.remaining_handles();
22723            if let Some((inlined, num_bytes, num_handles)) =
22724                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22725            {
22726                let member_inline_size =
22727                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22728                if inlined != (member_inline_size <= 4) {
22729                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22730                }
22731                let inner_offset;
22732                let mut inner_depth = depth.clone();
22733                if inlined {
22734                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22735                    inner_offset = next_offset;
22736                } else {
22737                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22738                    inner_depth.increment()?;
22739                }
22740                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
22741                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
22742                });
22743                fidl::decode!(
22744                    u32,
22745                    fdomain_client::fidl::FDomainResourceDialect,
22746                    val_ref,
22747                    decoder,
22748                    inner_offset,
22749                    inner_depth
22750                )?;
22751                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22752                {
22753                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22754                }
22755                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22756                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22757                }
22758            }
22759
22760            next_offset += envelope_size;
22761            _next_ordinal_to_read += 1;
22762            if next_offset >= end_offset {
22763                return Ok(());
22764            }
22765
22766            // Decode unknown envelopes for gaps in ordinals.
22767            while _next_ordinal_to_read < 5 {
22768                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22769                _next_ordinal_to_read += 1;
22770                next_offset += envelope_size;
22771            }
22772
22773            let next_out_of_line = decoder.next_out_of_line();
22774            let handles_before = decoder.remaining_handles();
22775            if let Some((inlined, num_bytes, num_handles)) =
22776                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22777            {
22778                let member_inline_size =
22779                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
22780                if inlined != (member_inline_size <= 4) {
22781                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22782                }
22783                let inner_offset;
22784                let mut inner_depth = depth.clone();
22785                if inlined {
22786                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22787                    inner_offset = next_offset;
22788                } else {
22789                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22790                    inner_depth.increment()?;
22791                }
22792                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
22793                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
22794                });
22795                fidl::decode!(
22796                    u32,
22797                    fdomain_client::fidl::FDomainResourceDialect,
22798                    val_ref,
22799                    decoder,
22800                    inner_offset,
22801                    inner_depth
22802                )?;
22803                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22804                {
22805                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22806                }
22807                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22808                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22809                }
22810            }
22811
22812            next_offset += envelope_size;
22813            _next_ordinal_to_read += 1;
22814            if next_offset >= end_offset {
22815                return Ok(());
22816            }
22817
22818            // Decode unknown envelopes for gaps in ordinals.
22819            while _next_ordinal_to_read < 6 {
22820                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22821                _next_ordinal_to_read += 1;
22822                next_offset += envelope_size;
22823            }
22824
22825            let next_out_of_line = decoder.next_out_of_line();
22826            let handles_before = decoder.remaining_handles();
22827            if let Some((inlined, num_bytes, num_handles)) =
22828                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22829            {
22830                let member_inline_size = <fidl::encoding::Endpoint<
22831                    fdomain_client::fidl::ClientEnd<
22832                        fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22833                    >,
22834                > as fidl::encoding::TypeMarker>::inline_size(
22835                    decoder.context
22836                );
22837                if inlined != (member_inline_size <= 4) {
22838                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22839                }
22840                let inner_offset;
22841                let mut inner_depth = depth.clone();
22842                if inlined {
22843                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22844                    inner_offset = next_offset;
22845                } else {
22846                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22847                    inner_depth.increment()?;
22848                }
22849                let val_ref = self.sysmem_token.get_or_insert_with(|| {
22850                    fidl::new_empty!(
22851                        fidl::encoding::Endpoint<
22852                            fdomain_client::fidl::ClientEnd<
22853                                fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22854                            >,
22855                        >,
22856                        fdomain_client::fidl::FDomainResourceDialect
22857                    )
22858                });
22859                fidl::decode!(
22860                    fidl::encoding::Endpoint<
22861                        fdomain_client::fidl::ClientEnd<
22862                            fdomain_fuchsia_sysmem::BufferCollectionTokenMarker,
22863                        >,
22864                    >,
22865                    fdomain_client::fidl::FDomainResourceDialect,
22866                    val_ref,
22867                    decoder,
22868                    inner_offset,
22869                    inner_depth
22870                )?;
22871                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22872                {
22873                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22874                }
22875                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22876                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22877                }
22878            }
22879
22880            next_offset += envelope_size;
22881            _next_ordinal_to_read += 1;
22882            if next_offset >= end_offset {
22883                return Ok(());
22884            }
22885
22886            // Decode unknown envelopes for gaps in ordinals.
22887            while _next_ordinal_to_read < 7 {
22888                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22889                _next_ordinal_to_read += 1;
22890                next_offset += envelope_size;
22891            }
22892
22893            let next_out_of_line = decoder.next_out_of_line();
22894            let handles_before = decoder.remaining_handles();
22895            if let Some((inlined, num_bytes, num_handles)) =
22896                fidl::encoding::decode_envelope_header(decoder, next_offset)?
22897            {
22898                let member_inline_size = <fidl::encoding::Endpoint<
22899                    fdomain_client::fidl::ClientEnd<
22900                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22901                    >,
22902                > as fidl::encoding::TypeMarker>::inline_size(
22903                    decoder.context
22904                );
22905                if inlined != (member_inline_size <= 4) {
22906                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
22907                }
22908                let inner_offset;
22909                let mut inner_depth = depth.clone();
22910                if inlined {
22911                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
22912                    inner_offset = next_offset;
22913                } else {
22914                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
22915                    inner_depth.increment()?;
22916                }
22917                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
22918                    fidl::new_empty!(
22919                        fidl::encoding::Endpoint<
22920                            fdomain_client::fidl::ClientEnd<
22921                                fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22922                            >,
22923                        >,
22924                        fdomain_client::fidl::FDomainResourceDialect
22925                    )
22926                });
22927                fidl::decode!(
22928                    fidl::encoding::Endpoint<
22929                        fdomain_client::fidl::ClientEnd<
22930                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
22931                        >,
22932                    >,
22933                    fdomain_client::fidl::FDomainResourceDialect,
22934                    val_ref,
22935                    decoder,
22936                    inner_offset,
22937                    inner_depth
22938                )?;
22939                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
22940                {
22941                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
22942                }
22943                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
22944                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
22945                }
22946            }
22947
22948            next_offset += envelope_size;
22949
22950            // Decode the remaining unknown envelopes.
22951            while next_offset < end_offset {
22952                _next_ordinal_to_read += 1;
22953                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
22954                next_offset += envelope_size;
22955            }
22956
22957            Ok(())
22958        }
22959    }
22960
22961    impl StreamProcessorAddBufferRequest {
22962        #[inline(always)]
22963        fn max_ordinal_present(&self) -> u64 {
22964            if let Some(_) = self.buffer {
22965                return 5;
22966            }
22967            if let Some(_) = self.buffer_index {
22968                return 4;
22969            }
22970            if let Some(_) = self.buffer_lifetime_ordinal {
22971                return 3;
22972            }
22973            if let Some(_) = self.buffer_constraints_version_ordinal {
22974                return 2;
22975            }
22976            if let Some(_) = self.port {
22977                return 1;
22978            }
22979            0
22980        }
22981    }
22982
22983    impl fidl::encoding::ResourceTypeMarker for StreamProcessorAddBufferRequest {
22984        type Borrowed<'a> = &'a mut Self;
22985        fn take_or_borrow<'a>(
22986            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22987        ) -> Self::Borrowed<'a> {
22988            value
22989        }
22990    }
22991
22992    unsafe impl fidl::encoding::TypeMarker for StreamProcessorAddBufferRequest {
22993        type Owned = Self;
22994
22995        #[inline(always)]
22996        fn inline_align(_context: fidl::encoding::Context) -> usize {
22997            8
22998        }
22999
23000        #[inline(always)]
23001        fn inline_size(_context: fidl::encoding::Context) -> usize {
23002            16
23003        }
23004    }
23005
23006    unsafe impl
23007        fidl::encoding::Encode<
23008            StreamProcessorAddBufferRequest,
23009            fdomain_client::fidl::FDomainResourceDialect,
23010        > for &mut StreamProcessorAddBufferRequest
23011    {
23012        unsafe fn encode(
23013            self,
23014            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23015            offset: usize,
23016            mut depth: fidl::encoding::Depth,
23017        ) -> fidl::Result<()> {
23018            encoder.debug_check_bounds::<StreamProcessorAddBufferRequest>(offset);
23019            // Vector header
23020            let max_ordinal: u64 = self.max_ordinal_present();
23021            encoder.write_num(max_ordinal, offset);
23022            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
23023            // Calling encoder.out_of_line_offset(0) is not allowed.
23024            if max_ordinal == 0 {
23025                return Ok(());
23026            }
23027            depth.increment()?;
23028            let envelope_size = 8;
23029            let bytes_len = max_ordinal as usize * envelope_size;
23030            #[allow(unused_variables)]
23031            let offset = encoder.out_of_line_offset(bytes_len);
23032            let mut _prev_end_offset: usize = 0;
23033            if 1 > max_ordinal {
23034                return Ok(());
23035            }
23036
23037            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23038            // are envelope_size bytes.
23039            let cur_offset: usize = (1 - 1) * envelope_size;
23040
23041            // Zero reserved fields.
23042            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23043
23044            // Safety:
23045            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23046            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23047            //   envelope_size bytes, there is always sufficient room.
23048            fidl::encoding::encode_in_envelope_optional::<
23049                Port,
23050                fdomain_client::fidl::FDomainResourceDialect,
23051            >(
23052                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
23053                encoder,
23054                offset + cur_offset,
23055                depth,
23056            )?;
23057
23058            _prev_end_offset = cur_offset + envelope_size;
23059            if 2 > max_ordinal {
23060                return Ok(());
23061            }
23062
23063            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23064            // are envelope_size bytes.
23065            let cur_offset: usize = (2 - 1) * envelope_size;
23066
23067            // Zero reserved fields.
23068            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23069
23070            // Safety:
23071            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23072            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23073            //   envelope_size bytes, there is always sufficient room.
23074            fidl::encoding::encode_in_envelope_optional::<
23075                u64,
23076                fdomain_client::fidl::FDomainResourceDialect,
23077            >(
23078                self.buffer_constraints_version_ordinal
23079                    .as_ref()
23080                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
23081                encoder,
23082                offset + cur_offset,
23083                depth,
23084            )?;
23085
23086            _prev_end_offset = cur_offset + envelope_size;
23087            if 3 > max_ordinal {
23088                return Ok(());
23089            }
23090
23091            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23092            // are envelope_size bytes.
23093            let cur_offset: usize = (3 - 1) * envelope_size;
23094
23095            // Zero reserved fields.
23096            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23097
23098            // Safety:
23099            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23100            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23101            //   envelope_size bytes, there is always sufficient room.
23102            fidl::encoding::encode_in_envelope_optional::<
23103                u64,
23104                fdomain_client::fidl::FDomainResourceDialect,
23105            >(
23106                self.buffer_lifetime_ordinal
23107                    .as_ref()
23108                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
23109                encoder,
23110                offset + cur_offset,
23111                depth,
23112            )?;
23113
23114            _prev_end_offset = cur_offset + envelope_size;
23115            if 4 > max_ordinal {
23116                return Ok(());
23117            }
23118
23119            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23120            // are envelope_size bytes.
23121            let cur_offset: usize = (4 - 1) * envelope_size;
23122
23123            // Zero reserved fields.
23124            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23125
23126            // Safety:
23127            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23128            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23129            //   envelope_size bytes, there is always sufficient room.
23130            fidl::encoding::encode_in_envelope_optional::<
23131                u32,
23132                fdomain_client::fidl::FDomainResourceDialect,
23133            >(
23134                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
23135                encoder,
23136                offset + cur_offset,
23137                depth,
23138            )?;
23139
23140            _prev_end_offset = cur_offset + envelope_size;
23141            if 5 > max_ordinal {
23142                return Ok(());
23143            }
23144
23145            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23146            // are envelope_size bytes.
23147            let cur_offset: usize = (5 - 1) * envelope_size;
23148
23149            // Zero reserved fields.
23150            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23151
23152            // Safety:
23153            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23154            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23155            //   envelope_size bytes, there is always sufficient room.
23156            fidl::encoding::encode_in_envelope_optional::<
23157                fidl::encoding::HandleType<
23158                    fdomain_client::Vmo,
23159                    { fidl::ObjectType::VMO.into_raw() },
23160                    2147483648,
23161                >,
23162                fdomain_client::fidl::FDomainResourceDialect,
23163            >(
23164                self.buffer.as_mut().map(
23165                    <fidl::encoding::HandleType<
23166                        fdomain_client::Vmo,
23167                        { fidl::ObjectType::VMO.into_raw() },
23168                        2147483648,
23169                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
23170                ),
23171                encoder,
23172                offset + cur_offset,
23173                depth,
23174            )?;
23175
23176            _prev_end_offset = cur_offset + envelope_size;
23177
23178            Ok(())
23179        }
23180    }
23181
23182    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
23183        for StreamProcessorAddBufferRequest
23184    {
23185        #[inline(always)]
23186        fn new_empty() -> Self {
23187            Self::default()
23188        }
23189
23190        unsafe fn decode(
23191            &mut self,
23192            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23193            offset: usize,
23194            mut depth: fidl::encoding::Depth,
23195        ) -> fidl::Result<()> {
23196            decoder.debug_check_bounds::<Self>(offset);
23197            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
23198                None => return Err(fidl::Error::NotNullable),
23199                Some(len) => len,
23200            };
23201            // Calling decoder.out_of_line_offset(0) is not allowed.
23202            if len == 0 {
23203                return Ok(());
23204            };
23205            depth.increment()?;
23206            let envelope_size = 8;
23207            let bytes_len = len * envelope_size;
23208            let offset = decoder.out_of_line_offset(bytes_len)?;
23209            // Decode the envelope for each type.
23210            let mut _next_ordinal_to_read = 0;
23211            let mut next_offset = offset;
23212            let end_offset = offset + bytes_len;
23213            _next_ordinal_to_read += 1;
23214            if next_offset >= end_offset {
23215                return Ok(());
23216            }
23217
23218            // Decode unknown envelopes for gaps in ordinals.
23219            while _next_ordinal_to_read < 1 {
23220                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23221                _next_ordinal_to_read += 1;
23222                next_offset += envelope_size;
23223            }
23224
23225            let next_out_of_line = decoder.next_out_of_line();
23226            let handles_before = decoder.remaining_handles();
23227            if let Some((inlined, num_bytes, num_handles)) =
23228                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23229            {
23230                let member_inline_size =
23231                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23232                if inlined != (member_inline_size <= 4) {
23233                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23234                }
23235                let inner_offset;
23236                let mut inner_depth = depth.clone();
23237                if inlined {
23238                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23239                    inner_offset = next_offset;
23240                } else {
23241                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23242                    inner_depth.increment()?;
23243                }
23244                let val_ref = self.port.get_or_insert_with(|| {
23245                    fidl::new_empty!(Port, fdomain_client::fidl::FDomainResourceDialect)
23246                });
23247                fidl::decode!(
23248                    Port,
23249                    fdomain_client::fidl::FDomainResourceDialect,
23250                    val_ref,
23251                    decoder,
23252                    inner_offset,
23253                    inner_depth
23254                )?;
23255                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23256                {
23257                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23258                }
23259                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23260                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23261                }
23262            }
23263
23264            next_offset += envelope_size;
23265            _next_ordinal_to_read += 1;
23266            if next_offset >= end_offset {
23267                return Ok(());
23268            }
23269
23270            // Decode unknown envelopes for gaps in ordinals.
23271            while _next_ordinal_to_read < 2 {
23272                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23273                _next_ordinal_to_read += 1;
23274                next_offset += envelope_size;
23275            }
23276
23277            let next_out_of_line = decoder.next_out_of_line();
23278            let handles_before = decoder.remaining_handles();
23279            if let Some((inlined, num_bytes, num_handles)) =
23280                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23281            {
23282                let member_inline_size =
23283                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23284                if inlined != (member_inline_size <= 4) {
23285                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23286                }
23287                let inner_offset;
23288                let mut inner_depth = depth.clone();
23289                if inlined {
23290                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23291                    inner_offset = next_offset;
23292                } else {
23293                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23294                    inner_depth.increment()?;
23295                }
23296                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
23297                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23298                });
23299                fidl::decode!(
23300                    u64,
23301                    fdomain_client::fidl::FDomainResourceDialect,
23302                    val_ref,
23303                    decoder,
23304                    inner_offset,
23305                    inner_depth
23306                )?;
23307                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23308                {
23309                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23310                }
23311                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23312                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23313                }
23314            }
23315
23316            next_offset += envelope_size;
23317            _next_ordinal_to_read += 1;
23318            if next_offset >= end_offset {
23319                return Ok(());
23320            }
23321
23322            // Decode unknown envelopes for gaps in ordinals.
23323            while _next_ordinal_to_read < 3 {
23324                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23325                _next_ordinal_to_read += 1;
23326                next_offset += envelope_size;
23327            }
23328
23329            let next_out_of_line = decoder.next_out_of_line();
23330            let handles_before = decoder.remaining_handles();
23331            if let Some((inlined, num_bytes, num_handles)) =
23332                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23333            {
23334                let member_inline_size =
23335                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23336                if inlined != (member_inline_size <= 4) {
23337                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23338                }
23339                let inner_offset;
23340                let mut inner_depth = depth.clone();
23341                if inlined {
23342                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23343                    inner_offset = next_offset;
23344                } else {
23345                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23346                    inner_depth.increment()?;
23347                }
23348                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
23349                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23350                });
23351                fidl::decode!(
23352                    u64,
23353                    fdomain_client::fidl::FDomainResourceDialect,
23354                    val_ref,
23355                    decoder,
23356                    inner_offset,
23357                    inner_depth
23358                )?;
23359                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23360                {
23361                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23362                }
23363                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23364                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23365                }
23366            }
23367
23368            next_offset += envelope_size;
23369            _next_ordinal_to_read += 1;
23370            if next_offset >= end_offset {
23371                return Ok(());
23372            }
23373
23374            // Decode unknown envelopes for gaps in ordinals.
23375            while _next_ordinal_to_read < 4 {
23376                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23377                _next_ordinal_to_read += 1;
23378                next_offset += envelope_size;
23379            }
23380
23381            let next_out_of_line = decoder.next_out_of_line();
23382            let handles_before = decoder.remaining_handles();
23383            if let Some((inlined, num_bytes, num_handles)) =
23384                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23385            {
23386                let member_inline_size =
23387                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23388                if inlined != (member_inline_size <= 4) {
23389                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23390                }
23391                let inner_offset;
23392                let mut inner_depth = depth.clone();
23393                if inlined {
23394                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23395                    inner_offset = next_offset;
23396                } else {
23397                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23398                    inner_depth.increment()?;
23399                }
23400                let val_ref = self.buffer_index.get_or_insert_with(|| {
23401                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
23402                });
23403                fidl::decode!(
23404                    u32,
23405                    fdomain_client::fidl::FDomainResourceDialect,
23406                    val_ref,
23407                    decoder,
23408                    inner_offset,
23409                    inner_depth
23410                )?;
23411                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23412                {
23413                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23414                }
23415                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23416                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23417                }
23418            }
23419
23420            next_offset += envelope_size;
23421            _next_ordinal_to_read += 1;
23422            if next_offset >= end_offset {
23423                return Ok(());
23424            }
23425
23426            // Decode unknown envelopes for gaps in ordinals.
23427            while _next_ordinal_to_read < 5 {
23428                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23429                _next_ordinal_to_read += 1;
23430                next_offset += envelope_size;
23431            }
23432
23433            let next_out_of_line = decoder.next_out_of_line();
23434            let handles_before = decoder.remaining_handles();
23435            if let Some((inlined, num_bytes, num_handles)) =
23436                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23437            {
23438                let member_inline_size = <fidl::encoding::HandleType<
23439                    fdomain_client::Vmo,
23440                    { fidl::ObjectType::VMO.into_raw() },
23441                    2147483648,
23442                > as fidl::encoding::TypeMarker>::inline_size(
23443                    decoder.context
23444                );
23445                if inlined != (member_inline_size <= 4) {
23446                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23447                }
23448                let inner_offset;
23449                let mut inner_depth = depth.clone();
23450                if inlined {
23451                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23452                    inner_offset = next_offset;
23453                } else {
23454                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23455                    inner_depth.increment()?;
23456                }
23457                let val_ref =
23458                self.buffer.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
23459                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
23460                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23461                {
23462                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23463                }
23464                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23465                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23466                }
23467            }
23468
23469            next_offset += envelope_size;
23470
23471            // Decode the remaining unknown envelopes.
23472            while next_offset < end_offset {
23473                _next_ordinal_to_read += 1;
23474                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23475                next_offset += envelope_size;
23476            }
23477
23478            Ok(())
23479        }
23480    }
23481
23482    impl StreamProcessorParticipateInBufferAllocationRequest {
23483        #[inline(always)]
23484        fn max_ordinal_present(&self) -> u64 {
23485            if let Some(_) = self.allow_single_buffer {
23486                return 5;
23487            }
23488            if let Some(_) = self.buffer_lifetime_ordinal {
23489                return 4;
23490            }
23491            if let Some(_) = self.sysmem2_token {
23492                return 3;
23493            }
23494            if let Some(_) = self.buffer_constraints_version_ordinal {
23495                return 2;
23496            }
23497            if let Some(_) = self.port {
23498                return 1;
23499            }
23500            0
23501        }
23502    }
23503
23504    impl fidl::encoding::ResourceTypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
23505        type Borrowed<'a> = &'a mut Self;
23506        fn take_or_borrow<'a>(
23507            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23508        ) -> Self::Borrowed<'a> {
23509            value
23510        }
23511    }
23512
23513    unsafe impl fidl::encoding::TypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
23514        type Owned = Self;
23515
23516        #[inline(always)]
23517        fn inline_align(_context: fidl::encoding::Context) -> usize {
23518            8
23519        }
23520
23521        #[inline(always)]
23522        fn inline_size(_context: fidl::encoding::Context) -> usize {
23523            16
23524        }
23525    }
23526
23527    unsafe impl
23528        fidl::encoding::Encode<
23529            StreamProcessorParticipateInBufferAllocationRequest,
23530            fdomain_client::fidl::FDomainResourceDialect,
23531        > for &mut StreamProcessorParticipateInBufferAllocationRequest
23532    {
23533        unsafe fn encode(
23534            self,
23535            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23536            offset: usize,
23537            mut depth: fidl::encoding::Depth,
23538        ) -> fidl::Result<()> {
23539            encoder
23540                .debug_check_bounds::<StreamProcessorParticipateInBufferAllocationRequest>(offset);
23541            // Vector header
23542            let max_ordinal: u64 = self.max_ordinal_present();
23543            encoder.write_num(max_ordinal, offset);
23544            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
23545            // Calling encoder.out_of_line_offset(0) is not allowed.
23546            if max_ordinal == 0 {
23547                return Ok(());
23548            }
23549            depth.increment()?;
23550            let envelope_size = 8;
23551            let bytes_len = max_ordinal as usize * envelope_size;
23552            #[allow(unused_variables)]
23553            let offset = encoder.out_of_line_offset(bytes_len);
23554            let mut _prev_end_offset: usize = 0;
23555            if 1 > max_ordinal {
23556                return Ok(());
23557            }
23558
23559            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23560            // are envelope_size bytes.
23561            let cur_offset: usize = (1 - 1) * envelope_size;
23562
23563            // Zero reserved fields.
23564            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23565
23566            // Safety:
23567            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23568            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23569            //   envelope_size bytes, there is always sufficient room.
23570            fidl::encoding::encode_in_envelope_optional::<
23571                Port,
23572                fdomain_client::fidl::FDomainResourceDialect,
23573            >(
23574                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
23575                encoder,
23576                offset + cur_offset,
23577                depth,
23578            )?;
23579
23580            _prev_end_offset = cur_offset + envelope_size;
23581            if 2 > max_ordinal {
23582                return Ok(());
23583            }
23584
23585            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23586            // are envelope_size bytes.
23587            let cur_offset: usize = (2 - 1) * envelope_size;
23588
23589            // Zero reserved fields.
23590            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23591
23592            // Safety:
23593            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23594            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23595            //   envelope_size bytes, there is always sufficient room.
23596            fidl::encoding::encode_in_envelope_optional::<
23597                u64,
23598                fdomain_client::fidl::FDomainResourceDialect,
23599            >(
23600                self.buffer_constraints_version_ordinal
23601                    .as_ref()
23602                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
23603                encoder,
23604                offset + cur_offset,
23605                depth,
23606            )?;
23607
23608            _prev_end_offset = cur_offset + envelope_size;
23609            if 3 > max_ordinal {
23610                return Ok(());
23611            }
23612
23613            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23614            // are envelope_size bytes.
23615            let cur_offset: usize = (3 - 1) * envelope_size;
23616
23617            // Zero reserved fields.
23618            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23619
23620            // Safety:
23621            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23622            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23623            //   envelope_size bytes, there is always sufficient room.
23624            fidl::encoding::encode_in_envelope_optional::<
23625                fidl::encoding::Endpoint<
23626                    fdomain_client::fidl::ClientEnd<
23627                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23628                    >,
23629                >,
23630                fdomain_client::fidl::FDomainResourceDialect,
23631            >(
23632                self.sysmem2_token.as_mut().map(
23633                    <fidl::encoding::Endpoint<
23634                        fdomain_client::fidl::ClientEnd<
23635                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23636                        >,
23637                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
23638                ),
23639                encoder,
23640                offset + cur_offset,
23641                depth,
23642            )?;
23643
23644            _prev_end_offset = cur_offset + envelope_size;
23645            if 4 > max_ordinal {
23646                return Ok(());
23647            }
23648
23649            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23650            // are envelope_size bytes.
23651            let cur_offset: usize = (4 - 1) * envelope_size;
23652
23653            // Zero reserved fields.
23654            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23655
23656            // Safety:
23657            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23658            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23659            //   envelope_size bytes, there is always sufficient room.
23660            fidl::encoding::encode_in_envelope_optional::<
23661                u64,
23662                fdomain_client::fidl::FDomainResourceDialect,
23663            >(
23664                self.buffer_lifetime_ordinal
23665                    .as_ref()
23666                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
23667                encoder,
23668                offset + cur_offset,
23669                depth,
23670            )?;
23671
23672            _prev_end_offset = cur_offset + envelope_size;
23673            if 5 > max_ordinal {
23674                return Ok(());
23675            }
23676
23677            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
23678            // are envelope_size bytes.
23679            let cur_offset: usize = (5 - 1) * envelope_size;
23680
23681            // Zero reserved fields.
23682            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
23683
23684            // Safety:
23685            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
23686            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
23687            //   envelope_size bytes, there is always sufficient room.
23688            fidl::encoding::encode_in_envelope_optional::<
23689                bool,
23690                fdomain_client::fidl::FDomainResourceDialect,
23691            >(
23692                self.allow_single_buffer
23693                    .as_ref()
23694                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
23695                encoder,
23696                offset + cur_offset,
23697                depth,
23698            )?;
23699
23700            _prev_end_offset = cur_offset + envelope_size;
23701
23702            Ok(())
23703        }
23704    }
23705
23706    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
23707        for StreamProcessorParticipateInBufferAllocationRequest
23708    {
23709        #[inline(always)]
23710        fn new_empty() -> Self {
23711            Self::default()
23712        }
23713
23714        unsafe fn decode(
23715            &mut self,
23716            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
23717            offset: usize,
23718            mut depth: fidl::encoding::Depth,
23719        ) -> fidl::Result<()> {
23720            decoder.debug_check_bounds::<Self>(offset);
23721            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
23722                None => return Err(fidl::Error::NotNullable),
23723                Some(len) => len,
23724            };
23725            // Calling decoder.out_of_line_offset(0) is not allowed.
23726            if len == 0 {
23727                return Ok(());
23728            };
23729            depth.increment()?;
23730            let envelope_size = 8;
23731            let bytes_len = len * envelope_size;
23732            let offset = decoder.out_of_line_offset(bytes_len)?;
23733            // Decode the envelope for each type.
23734            let mut _next_ordinal_to_read = 0;
23735            let mut next_offset = offset;
23736            let end_offset = offset + bytes_len;
23737            _next_ordinal_to_read += 1;
23738            if next_offset >= end_offset {
23739                return Ok(());
23740            }
23741
23742            // Decode unknown envelopes for gaps in ordinals.
23743            while _next_ordinal_to_read < 1 {
23744                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23745                _next_ordinal_to_read += 1;
23746                next_offset += envelope_size;
23747            }
23748
23749            let next_out_of_line = decoder.next_out_of_line();
23750            let handles_before = decoder.remaining_handles();
23751            if let Some((inlined, num_bytes, num_handles)) =
23752                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23753            {
23754                let member_inline_size =
23755                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23756                if inlined != (member_inline_size <= 4) {
23757                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23758                }
23759                let inner_offset;
23760                let mut inner_depth = depth.clone();
23761                if inlined {
23762                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23763                    inner_offset = next_offset;
23764                } else {
23765                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23766                    inner_depth.increment()?;
23767                }
23768                let val_ref = self.port.get_or_insert_with(|| {
23769                    fidl::new_empty!(Port, fdomain_client::fidl::FDomainResourceDialect)
23770                });
23771                fidl::decode!(
23772                    Port,
23773                    fdomain_client::fidl::FDomainResourceDialect,
23774                    val_ref,
23775                    decoder,
23776                    inner_offset,
23777                    inner_depth
23778                )?;
23779                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23780                {
23781                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23782                }
23783                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23784                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23785                }
23786            }
23787
23788            next_offset += envelope_size;
23789            _next_ordinal_to_read += 1;
23790            if next_offset >= end_offset {
23791                return Ok(());
23792            }
23793
23794            // Decode unknown envelopes for gaps in ordinals.
23795            while _next_ordinal_to_read < 2 {
23796                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23797                _next_ordinal_to_read += 1;
23798                next_offset += envelope_size;
23799            }
23800
23801            let next_out_of_line = decoder.next_out_of_line();
23802            let handles_before = decoder.remaining_handles();
23803            if let Some((inlined, num_bytes, num_handles)) =
23804                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23805            {
23806                let member_inline_size =
23807                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23808                if inlined != (member_inline_size <= 4) {
23809                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23810                }
23811                let inner_offset;
23812                let mut inner_depth = depth.clone();
23813                if inlined {
23814                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23815                    inner_offset = next_offset;
23816                } else {
23817                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23818                    inner_depth.increment()?;
23819                }
23820                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
23821                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23822                });
23823                fidl::decode!(
23824                    u64,
23825                    fdomain_client::fidl::FDomainResourceDialect,
23826                    val_ref,
23827                    decoder,
23828                    inner_offset,
23829                    inner_depth
23830                )?;
23831                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23832                {
23833                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23834                }
23835                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23836                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23837                }
23838            }
23839
23840            next_offset += envelope_size;
23841            _next_ordinal_to_read += 1;
23842            if next_offset >= end_offset {
23843                return Ok(());
23844            }
23845
23846            // Decode unknown envelopes for gaps in ordinals.
23847            while _next_ordinal_to_read < 3 {
23848                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23849                _next_ordinal_to_read += 1;
23850                next_offset += envelope_size;
23851            }
23852
23853            let next_out_of_line = decoder.next_out_of_line();
23854            let handles_before = decoder.remaining_handles();
23855            if let Some((inlined, num_bytes, num_handles)) =
23856                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23857            {
23858                let member_inline_size = <fidl::encoding::Endpoint<
23859                    fdomain_client::fidl::ClientEnd<
23860                        fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23861                    >,
23862                > as fidl::encoding::TypeMarker>::inline_size(
23863                    decoder.context
23864                );
23865                if inlined != (member_inline_size <= 4) {
23866                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23867                }
23868                let inner_offset;
23869                let mut inner_depth = depth.clone();
23870                if inlined {
23871                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23872                    inner_offset = next_offset;
23873                } else {
23874                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23875                    inner_depth.increment()?;
23876                }
23877                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
23878                    fidl::new_empty!(
23879                        fidl::encoding::Endpoint<
23880                            fdomain_client::fidl::ClientEnd<
23881                                fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23882                            >,
23883                        >,
23884                        fdomain_client::fidl::FDomainResourceDialect
23885                    )
23886                });
23887                fidl::decode!(
23888                    fidl::encoding::Endpoint<
23889                        fdomain_client::fidl::ClientEnd<
23890                            fdomain_fuchsia_sysmem2::BufferCollectionTokenMarker,
23891                        >,
23892                    >,
23893                    fdomain_client::fidl::FDomainResourceDialect,
23894                    val_ref,
23895                    decoder,
23896                    inner_offset,
23897                    inner_depth
23898                )?;
23899                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23900                {
23901                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23902                }
23903                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23904                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23905                }
23906            }
23907
23908            next_offset += envelope_size;
23909            _next_ordinal_to_read += 1;
23910            if next_offset >= end_offset {
23911                return Ok(());
23912            }
23913
23914            // Decode unknown envelopes for gaps in ordinals.
23915            while _next_ordinal_to_read < 4 {
23916                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23917                _next_ordinal_to_read += 1;
23918                next_offset += envelope_size;
23919            }
23920
23921            let next_out_of_line = decoder.next_out_of_line();
23922            let handles_before = decoder.remaining_handles();
23923            if let Some((inlined, num_bytes, num_handles)) =
23924                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23925            {
23926                let member_inline_size =
23927                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23928                if inlined != (member_inline_size <= 4) {
23929                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23930                }
23931                let inner_offset;
23932                let mut inner_depth = depth.clone();
23933                if inlined {
23934                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23935                    inner_offset = next_offset;
23936                } else {
23937                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23938                    inner_depth.increment()?;
23939                }
23940                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
23941                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
23942                });
23943                fidl::decode!(
23944                    u64,
23945                    fdomain_client::fidl::FDomainResourceDialect,
23946                    val_ref,
23947                    decoder,
23948                    inner_offset,
23949                    inner_depth
23950                )?;
23951                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
23952                {
23953                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
23954                }
23955                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
23956                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
23957                }
23958            }
23959
23960            next_offset += envelope_size;
23961            _next_ordinal_to_read += 1;
23962            if next_offset >= end_offset {
23963                return Ok(());
23964            }
23965
23966            // Decode unknown envelopes for gaps in ordinals.
23967            while _next_ordinal_to_read < 5 {
23968                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
23969                _next_ordinal_to_read += 1;
23970                next_offset += envelope_size;
23971            }
23972
23973            let next_out_of_line = decoder.next_out_of_line();
23974            let handles_before = decoder.remaining_handles();
23975            if let Some((inlined, num_bytes, num_handles)) =
23976                fidl::encoding::decode_envelope_header(decoder, next_offset)?
23977            {
23978                let member_inline_size =
23979                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
23980                if inlined != (member_inline_size <= 4) {
23981                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
23982                }
23983                let inner_offset;
23984                let mut inner_depth = depth.clone();
23985                if inlined {
23986                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
23987                    inner_offset = next_offset;
23988                } else {
23989                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
23990                    inner_depth.increment()?;
23991                }
23992                let val_ref = self.allow_single_buffer.get_or_insert_with(|| {
23993                    fidl::new_empty!(bool, fdomain_client::fidl::FDomainResourceDialect)
23994                });
23995                fidl::decode!(
23996                    bool,
23997                    fdomain_client::fidl::FDomainResourceDialect,
23998                    val_ref,
23999                    decoder,
24000                    inner_offset,
24001                    inner_depth
24002                )?;
24003                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24004                {
24005                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24006                }
24007                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24008                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24009                }
24010            }
24011
24012            next_offset += envelope_size;
24013
24014            // Decode the remaining unknown envelopes.
24015            while next_offset < end_offset {
24016                _next_ordinal_to_read += 1;
24017                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24018                next_offset += envelope_size;
24019            }
24020
24021            Ok(())
24022        }
24023    }
24024
24025    impl StreamProcessorRemoveBufferRequest {
24026        #[inline(always)]
24027        fn max_ordinal_present(&self) -> u64 {
24028            if let Some(_) = self.buffer_index {
24029                return 3;
24030            }
24031            if let Some(_) = self.buffer_lifetime_ordinal {
24032                return 2;
24033            }
24034            if let Some(_) = self.port {
24035                return 1;
24036            }
24037            0
24038        }
24039    }
24040
24041    impl fidl::encoding::ResourceTypeMarker for StreamProcessorRemoveBufferRequest {
24042        type Borrowed<'a> = &'a mut Self;
24043        fn take_or_borrow<'a>(
24044            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24045        ) -> Self::Borrowed<'a> {
24046            value
24047        }
24048    }
24049
24050    unsafe impl fidl::encoding::TypeMarker for StreamProcessorRemoveBufferRequest {
24051        type Owned = Self;
24052
24053        #[inline(always)]
24054        fn inline_align(_context: fidl::encoding::Context) -> usize {
24055            8
24056        }
24057
24058        #[inline(always)]
24059        fn inline_size(_context: fidl::encoding::Context) -> usize {
24060            16
24061        }
24062    }
24063
24064    unsafe impl
24065        fidl::encoding::Encode<
24066            StreamProcessorRemoveBufferRequest,
24067            fdomain_client::fidl::FDomainResourceDialect,
24068        > for &mut StreamProcessorRemoveBufferRequest
24069    {
24070        unsafe fn encode(
24071            self,
24072            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
24073            offset: usize,
24074            mut depth: fidl::encoding::Depth,
24075        ) -> fidl::Result<()> {
24076            encoder.debug_check_bounds::<StreamProcessorRemoveBufferRequest>(offset);
24077            // Vector header
24078            let max_ordinal: u64 = self.max_ordinal_present();
24079            encoder.write_num(max_ordinal, offset);
24080            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
24081            // Calling encoder.out_of_line_offset(0) is not allowed.
24082            if max_ordinal == 0 {
24083                return Ok(());
24084            }
24085            depth.increment()?;
24086            let envelope_size = 8;
24087            let bytes_len = max_ordinal as usize * envelope_size;
24088            #[allow(unused_variables)]
24089            let offset = encoder.out_of_line_offset(bytes_len);
24090            let mut _prev_end_offset: usize = 0;
24091            if 1 > max_ordinal {
24092                return Ok(());
24093            }
24094
24095            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24096            // are envelope_size bytes.
24097            let cur_offset: usize = (1 - 1) * envelope_size;
24098
24099            // Zero reserved fields.
24100            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24101
24102            // Safety:
24103            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24104            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24105            //   envelope_size bytes, there is always sufficient room.
24106            fidl::encoding::encode_in_envelope_optional::<
24107                Port,
24108                fdomain_client::fidl::FDomainResourceDialect,
24109            >(
24110                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
24111                encoder,
24112                offset + cur_offset,
24113                depth,
24114            )?;
24115
24116            _prev_end_offset = cur_offset + envelope_size;
24117            if 2 > max_ordinal {
24118                return Ok(());
24119            }
24120
24121            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24122            // are envelope_size bytes.
24123            let cur_offset: usize = (2 - 1) * envelope_size;
24124
24125            // Zero reserved fields.
24126            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24127
24128            // Safety:
24129            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24130            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24131            //   envelope_size bytes, there is always sufficient room.
24132            fidl::encoding::encode_in_envelope_optional::<
24133                u64,
24134                fdomain_client::fidl::FDomainResourceDialect,
24135            >(
24136                self.buffer_lifetime_ordinal
24137                    .as_ref()
24138                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
24139                encoder,
24140                offset + cur_offset,
24141                depth,
24142            )?;
24143
24144            _prev_end_offset = cur_offset + envelope_size;
24145            if 3 > max_ordinal {
24146                return Ok(());
24147            }
24148
24149            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
24150            // are envelope_size bytes.
24151            let cur_offset: usize = (3 - 1) * envelope_size;
24152
24153            // Zero reserved fields.
24154            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
24155
24156            // Safety:
24157            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
24158            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
24159            //   envelope_size bytes, there is always sufficient room.
24160            fidl::encoding::encode_in_envelope_optional::<
24161                u32,
24162                fdomain_client::fidl::FDomainResourceDialect,
24163            >(
24164                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
24165                encoder,
24166                offset + cur_offset,
24167                depth,
24168            )?;
24169
24170            _prev_end_offset = cur_offset + envelope_size;
24171
24172            Ok(())
24173        }
24174    }
24175
24176    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
24177        for StreamProcessorRemoveBufferRequest
24178    {
24179        #[inline(always)]
24180        fn new_empty() -> Self {
24181            Self::default()
24182        }
24183
24184        unsafe fn decode(
24185            &mut self,
24186            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
24187            offset: usize,
24188            mut depth: fidl::encoding::Depth,
24189        ) -> fidl::Result<()> {
24190            decoder.debug_check_bounds::<Self>(offset);
24191            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
24192                None => return Err(fidl::Error::NotNullable),
24193                Some(len) => len,
24194            };
24195            // Calling decoder.out_of_line_offset(0) is not allowed.
24196            if len == 0 {
24197                return Ok(());
24198            };
24199            depth.increment()?;
24200            let envelope_size = 8;
24201            let bytes_len = len * envelope_size;
24202            let offset = decoder.out_of_line_offset(bytes_len)?;
24203            // Decode the envelope for each type.
24204            let mut _next_ordinal_to_read = 0;
24205            let mut next_offset = offset;
24206            let end_offset = offset + bytes_len;
24207            _next_ordinal_to_read += 1;
24208            if next_offset >= end_offset {
24209                return Ok(());
24210            }
24211
24212            // Decode unknown envelopes for gaps in ordinals.
24213            while _next_ordinal_to_read < 1 {
24214                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24215                _next_ordinal_to_read += 1;
24216                next_offset += envelope_size;
24217            }
24218
24219            let next_out_of_line = decoder.next_out_of_line();
24220            let handles_before = decoder.remaining_handles();
24221            if let Some((inlined, num_bytes, num_handles)) =
24222                fidl::encoding::decode_envelope_header(decoder, next_offset)?
24223            {
24224                let member_inline_size =
24225                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
24226                if inlined != (member_inline_size <= 4) {
24227                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
24228                }
24229                let inner_offset;
24230                let mut inner_depth = depth.clone();
24231                if inlined {
24232                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
24233                    inner_offset = next_offset;
24234                } else {
24235                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
24236                    inner_depth.increment()?;
24237                }
24238                let val_ref = self.port.get_or_insert_with(|| {
24239                    fidl::new_empty!(Port, fdomain_client::fidl::FDomainResourceDialect)
24240                });
24241                fidl::decode!(
24242                    Port,
24243                    fdomain_client::fidl::FDomainResourceDialect,
24244                    val_ref,
24245                    decoder,
24246                    inner_offset,
24247                    inner_depth
24248                )?;
24249                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24250                {
24251                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24252                }
24253                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24254                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24255                }
24256            }
24257
24258            next_offset += envelope_size;
24259            _next_ordinal_to_read += 1;
24260            if next_offset >= end_offset {
24261                return Ok(());
24262            }
24263
24264            // Decode unknown envelopes for gaps in ordinals.
24265            while _next_ordinal_to_read < 2 {
24266                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24267                _next_ordinal_to_read += 1;
24268                next_offset += envelope_size;
24269            }
24270
24271            let next_out_of_line = decoder.next_out_of_line();
24272            let handles_before = decoder.remaining_handles();
24273            if let Some((inlined, num_bytes, num_handles)) =
24274                fidl::encoding::decode_envelope_header(decoder, next_offset)?
24275            {
24276                let member_inline_size =
24277                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
24278                if inlined != (member_inline_size <= 4) {
24279                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
24280                }
24281                let inner_offset;
24282                let mut inner_depth = depth.clone();
24283                if inlined {
24284                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
24285                    inner_offset = next_offset;
24286                } else {
24287                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
24288                    inner_depth.increment()?;
24289                }
24290                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
24291                    fidl::new_empty!(u64, fdomain_client::fidl::FDomainResourceDialect)
24292                });
24293                fidl::decode!(
24294                    u64,
24295                    fdomain_client::fidl::FDomainResourceDialect,
24296                    val_ref,
24297                    decoder,
24298                    inner_offset,
24299                    inner_depth
24300                )?;
24301                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24302                {
24303                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24304                }
24305                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24306                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24307                }
24308            }
24309
24310            next_offset += envelope_size;
24311            _next_ordinal_to_read += 1;
24312            if next_offset >= end_offset {
24313                return Ok(());
24314            }
24315
24316            // Decode unknown envelopes for gaps in ordinals.
24317            while _next_ordinal_to_read < 3 {
24318                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24319                _next_ordinal_to_read += 1;
24320                next_offset += envelope_size;
24321            }
24322
24323            let next_out_of_line = decoder.next_out_of_line();
24324            let handles_before = decoder.remaining_handles();
24325            if let Some((inlined, num_bytes, num_handles)) =
24326                fidl::encoding::decode_envelope_header(decoder, next_offset)?
24327            {
24328                let member_inline_size =
24329                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
24330                if inlined != (member_inline_size <= 4) {
24331                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
24332                }
24333                let inner_offset;
24334                let mut inner_depth = depth.clone();
24335                if inlined {
24336                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
24337                    inner_offset = next_offset;
24338                } else {
24339                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
24340                    inner_depth.increment()?;
24341                }
24342                let val_ref = self.buffer_index.get_or_insert_with(|| {
24343                    fidl::new_empty!(u32, fdomain_client::fidl::FDomainResourceDialect)
24344                });
24345                fidl::decode!(
24346                    u32,
24347                    fdomain_client::fidl::FDomainResourceDialect,
24348                    val_ref,
24349                    decoder,
24350                    inner_offset,
24351                    inner_depth
24352                )?;
24353                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
24354                {
24355                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
24356                }
24357                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
24358                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
24359                }
24360            }
24361
24362            next_offset += envelope_size;
24363
24364            // Decode the remaining unknown envelopes.
24365            while next_offset < end_offset {
24366                _next_ordinal_to_read += 1;
24367                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
24368                next_offset += envelope_size;
24369            }
24370
24371            Ok(())
24372        }
24373    }
24374}