Skip to main content

fidl_fuchsia_media/
fidl_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 fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_media_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct AudioCapturerBindGainControlRequest {
16    pub gain_control_request:
17        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for AudioCapturerBindGainControlRequest
22{
23}
24
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct AudioCapturerGetReferenceClockResponse {
27    pub reference_clock: fidl::Clock,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for AudioCapturerGetReferenceClockResponse
32{
33}
34
35#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct AudioCapturerSetReferenceClockRequest {
37    pub reference_clock: Option<fidl::Clock>,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for AudioCapturerSetReferenceClockRequest
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct AudioConsumerBindVolumeControlRequest {
47    pub volume_control_request:
48        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
52    for AudioConsumerBindVolumeControlRequest
53{
54}
55
56#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
57pub struct AudioConsumerCreateStreamSinkRequest {
58    pub buffers: Vec<fidl::Vmo>,
59    pub stream_type: AudioStreamType,
60    pub compression: Option<Box<Compression>>,
61    pub stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
62}
63
64impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
65    for AudioConsumerCreateStreamSinkRequest
66{
67}
68
69#[derive(Debug, PartialEq)]
70pub struct AudioCoreBindUsageVolumeControl2Request {
71    pub usage: Usage2,
72    pub volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
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: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
84}
85
86impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
87    for AudioCoreBindUsageVolumeControlRequest
88{
89}
90
91#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct AudioCoreCreateAudioCapturerRequest {
93    pub loopback: bool,
94    pub audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
95}
96
97impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
98    for AudioCoreCreateAudioCapturerRequest
99{
100}
101
102#[derive(Debug, PartialEq)]
103pub struct AudioCoreCreateAudioCapturerWithConfigurationRequest {
104    pub stream_type: AudioStreamType,
105    pub configuration: AudioCapturerConfiguration,
106    pub audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
107}
108
109impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
110    for AudioCoreCreateAudioCapturerWithConfigurationRequest
111{
112}
113
114#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
115pub struct AudioCoreCreateAudioRendererRequest {
116    pub audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
120    for AudioCoreCreateAudioRendererRequest
121{
122}
123
124#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
125pub struct AudioCreateAudioCapturerRequest {
126    pub audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
127    pub loopback: bool,
128}
129
130impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
131    for AudioCreateAudioCapturerRequest
132{
133}
134
135#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
136pub struct AudioCreateAudioRendererRequest {
137    pub audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
138}
139
140impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
141    for AudioCreateAudioRendererRequest
142{
143}
144
145#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
146pub struct AudioDeviceEnumeratorAddDeviceByChannelRequest {
147    pub device_name: String,
148    pub is_input: bool,
149    pub channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
150}
151
152impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
153    for AudioDeviceEnumeratorAddDeviceByChannelRequest
154{
155}
156
157#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
158pub struct AudioRendererBindGainControlRequest {
159    pub gain_control_request:
160        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
161}
162
163impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
164    for AudioRendererBindGainControlRequest
165{
166}
167
168#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
169pub struct AudioRendererGetReferenceClockResponse {
170    pub reference_clock: fidl::Clock,
171}
172
173impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
174    for AudioRendererGetReferenceClockResponse
175{
176}
177
178#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
179pub struct AudioRendererSetReferenceClockRequest {
180    pub reference_clock: Option<fidl::Clock>,
181}
182
183impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
184    for AudioRendererSetReferenceClockRequest
185{
186}
187
188#[derive(Debug, PartialEq, PartialOrd)]
189pub struct ProfileProviderRegisterHandlerWithCapacityRequest {
190    pub thread_handle: fidl::Thread,
191    pub name: String,
192    pub period: i64,
193    pub capacity: f32,
194}
195
196impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
197    for ProfileProviderRegisterHandlerWithCapacityRequest
198{
199}
200
201#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
202pub struct ProfileProviderRegisterMemoryRangeRequest {
203    pub vmar_handle: fidl::Vmar,
204    pub name: String,
205}
206
207impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
208    for ProfileProviderRegisterMemoryRangeRequest
209{
210}
211
212#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
213pub struct ProfileProviderUnregisterHandlerRequest {
214    pub thread_handle: fidl::Thread,
215    pub name: String,
216}
217
218impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
219    for ProfileProviderUnregisterHandlerRequest
220{
221}
222
223#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
224pub struct ProfileProviderUnregisterMemoryRangeRequest {
225    pub vmar_handle: fidl::Vmar,
226}
227
228impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
229    for ProfileProviderUnregisterMemoryRangeRequest
230{
231}
232
233#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
234pub struct SessionAudioConsumerFactoryCreateAudioConsumerRequest {
235    pub session_id: u64,
236    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
237}
238
239impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
240    for SessionAudioConsumerFactoryCreateAudioConsumerRequest
241{
242}
243
244#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
245pub struct StreamBufferSetAddPayloadBufferRequest {
246    pub id: u32,
247    pub payload_buffer: fidl::Vmo,
248}
249
250impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
251    for StreamBufferSetAddPayloadBufferRequest
252{
253}
254
255#[derive(Debug, PartialEq)]
256pub struct StreamProcessorSetInputBufferPartialSettingsRequest {
257    pub input_settings: StreamBufferPartialSettings,
258}
259
260impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
261    for StreamProcessorSetInputBufferPartialSettingsRequest
262{
263}
264
265#[derive(Debug, PartialEq)]
266pub struct StreamProcessorSetOutputBufferPartialSettingsRequest {
267    pub output_settings: StreamBufferPartialSettings,
268}
269
270impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
271    for StreamProcessorSetOutputBufferPartialSettingsRequest
272{
273}
274
275#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
276pub struct Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
277    pub usage: AudioRenderUsage2,
278    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
279}
280
281impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
282    for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
283{
284}
285
286#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
287pub struct UsageAudioConsumerFactoryCreateAudioConsumerRequest {
288    pub usage: AudioRenderUsage,
289    pub audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
290}
291
292impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
293    for UsageAudioConsumerFactoryCreateAudioConsumerRequest
294{
295}
296
297#[derive(Debug, PartialEq)]
298pub struct UsageGainReporterRegisterListener2Request {
299    pub device_unique_id: String,
300    pub usage: Usage2,
301    pub usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
302}
303
304impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
305    for UsageGainReporterRegisterListener2Request
306{
307}
308
309#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
310pub struct UsageGainReporterRegisterListenerRequest {
311    pub device_unique_id: String,
312    pub usage: Usage,
313    pub usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
314}
315
316impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
317    for UsageGainReporterRegisterListenerRequest
318{
319}
320
321#[derive(Debug, PartialEq)]
322pub struct UsageReporterWatch2Request {
323    pub usage: Usage2,
324    pub usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
325}
326
327impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
328    for UsageReporterWatch2Request
329{
330}
331
332#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
333pub struct UsageReporterWatchRequest {
334    pub usage: Usage,
335    pub usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
336}
337
338impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for UsageReporterWatchRequest {}
339
340#[derive(Debug, Default, PartialEq)]
341pub struct StreamBufferPartialSettings {
342    /// Each buffer is associated with a `buffer_lifetime_ordinal` value.
343    ///
344    /// There is a separate buffer_lifetime_ordinal for input vs. output.
345    ///
346    /// Values must be odd. Values must only increase (increasing by more than 2
347    /// is permitted).
348    ///
349    /// When using `SetInputBufferPartialSettings` or
350    /// `SetOutputBufferPartialSettings`, re-use of the same value (considering
351    /// input and output separately) for the new message is not allowed. Using
352    /// these messages, all the buffers of a given buffer_lifetime_ordinal value
353    /// are allocated as one sysmem buffer collection.
354    ///
355    /// When a new buffer_lifetime_ordinal starts, that also automatically
356    /// starts un-registering and releasing any buffers associated with prior
357    /// buffer_lifetime_ordinal values, but does not force them to complete
358    /// un-registration (or release) if they're still used by the codec for
359    /// reference purposes (VP9 can do this across a mid-stream dimensions
360    /// switch). A buffer can still be output by the server (as indicated by an
361    /// output packet) until un-registration completes.
362    ///
363    /// If the client wants the server to drop all buffers quickly, the client
364    /// can send `CloseCurrentStream` with `release_input_buffers` and/or
365    /// `release_output_buffers` set. This of course also stops decode of the
366    /// current stream. Closing the `StreamProcessor` client end is another
367    /// option.
368    pub buffer_lifetime_ordinal: Option<u64>,
369    /// This value indicates which version of constraints the client is/was
370    /// aware of so far.
371    ///
372    /// For input, this must always be 0 because constraints don't change for
373    /// input (settings can change, but there's no settings vs current
374    /// constraints synchronization issue on input).
375    ///
376    /// For output, this allows the server to know when the client is
377    /// sufficiently caught up before the server will generate any more output.
378    ///
379    /// When there is no active stream, a client is permitted to re-configure
380    /// buffers again using the same buffer_constraints_version_ordinal.
381    pub buffer_constraints_version_ordinal: Option<u64>,
382    pub single_buffer_mode: Option<bool>,
383    pub packet_count_for_server: Option<u32>,
384    pub packet_count_for_client: Option<u32>,
385    pub sysmem_token:
386        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>>,
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:
395        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
396    #[doc(hidden)]
397    pub __source_breaking: fidl::marker::SourceBreaking,
398}
399
400impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
401    for StreamBufferPartialSettings
402{
403}
404
405#[derive(Debug, Default, PartialEq)]
406pub struct StreamProcessorAddBufferRequest {
407    /// Must be set. Which port (input or output) the buffer is for.
408    pub port: Option<Port>,
409    /// Typically this is the latest buffer_constraints_version_ordinal
410    /// known to the client based on OnInputConstraints/OnOutputConstraints.
411    /// Older values are not harmful to correctness.
412    ///
413    /// The server will ignore this message if the server has already
414    /// created a later buffer_constraints_version_ordinal value that has
415    /// action_required true. If the server ignores this message, a later
416    /// RemoveBuffer for this buffer will complete quickly and without
417    /// creating an error.
418    ///
419    /// A client is not required to ensure that every call to AddBuffer with
420    /// the same buffer_lifetime_ordinal uses the same
421    /// buffer_constraints_version_ordinal, but the client must ensure that
422    /// all buffer_constraints_version_ordinal values which share the same
423    /// buffer_lifetime_ordinal are within the same action_required true
424    /// interval. Each such interval starts with a value that has
425    /// action_required true, and lasts until but not including the next
426    /// value with action_required true, or until the current value if there
427    /// is not yet a next value with action_required true. If this would
428    /// create a problem for a server, that server should set
429    /// action_required true instead of false.
430    pub buffer_constraints_version_ordinal: Option<u64>,
431    /// These values are scoped to input/output separately.
432    ///
433    /// The first message from the client with a new (higher)
434    /// buffer_lifetime_ordinal value begins removing all buffers on the
435    /// same port with lower buffer_lifetime_ordinal. However, until removal
436    /// is complete, the older buffers can still be used by the codec.
437    ///
438    /// The AddBuffer message adds the buffer to this
439    /// buffer_lifetime_ordinal.
440    pub buffer_lifetime_ordinal: Option<u64>,
441    /// The buffer_index values under a buffer_lifetime_ordinal must be
442    /// unique among all added but not yet fully removed buffers. This value
443    /// is initially allocated/specified by the client using this field, and
444    /// then both the client and the server will then refer to a this added
445    /// buffer uniquely using input vs output, buffer_lifetime_ordinal, and
446    /// the buffer_index (all three parts are needed to unambiguously
447    /// specify this buffer).
448    ///
449    /// See RemoveBuffer doc comments for how to safely remove a buffer and
450    /// potentially re-use a buffer_index value.
451    ///
452    /// In contrast to using
453    /// SetInputBufferPartialSettings/SetOutputBufferPartialSettings, when
454    /// using AddBuffer and RemoveBuffer, the StreamProcessor buffer_index
455    /// value has no relation to the sysmem buffer_index (under the sysmem
456    /// buffer_collection_id). Instead, the StreamProcessor buffer_index is
457    /// specified by this field, not by using sysmem's buffer_index. This
458    /// way, two buffers from two sysmem collections having the same sysmem
459    /// buffer_index (under separate buffer_collection_id(s)) can be
460    /// specified unambiguously in StreamProcessor messages.
461    pub buffer_index: Option<u32>,
462    /// This is a VMO handle that the server can use to access the sysmem
463    /// buffer.
464    ///
465    /// This VMO is required to have been provided by sysmem, and required
466    /// to be compatible with the server's sysmem constraints.
467    ///
468    /// The buffer_constraints_version_ordinal check occurs first, and
469    /// failure of that check just silently ignores the remainder of this
470    /// message without checking the buffer field (buffer is just dropped).
471    ///
472    /// If the buffer_constraints_version_ordinal check passes, but `buffer`
473    /// isn't a sysmem-provided VMO or isn't consistent with the server's
474    /// sysmem constraints, the server will close the StreamProcessor
475    /// server_end. The client can avoid triggering this failure case by
476    /// allocating the buffers per the following.
477    ///
478    /// For video decoder input buffers, the client can allocate the buffer
479    /// using sysmem, with participation of this or another instance of the
480    /// same codec implementation, using ParticipateInBufferAllocation with
481    /// Port.INPUT. The same StreamProcessor instance isn't required
482    /// in this case, only the same codec implementation. If using a
483    /// different StreamProcessor instance (but still from the same codec
484    /// implementation), the client should take care to create the two
485    /// StreamProcessor instances with the same requirements specified to
486    /// CodecFactory (for example with secure_input_mode and
487    /// secure_output_mode set the same way). Video decoder server
488    /// implementations with supports_dynamic_buffers true are required to
489    /// support allocating input buffers using one StreamProcessor instance
490    /// then using them with a different StreamProcessor instance (in
491    /// contrast, for output buffers, this is not required).
492    ///
493    /// For video decoder output buffers, this can be achieved by allocating
494    /// the buffer using sysmem, with participation of the same
495    /// StreamProcessor instance, using ParticipateInBufferAllocation with
496    /// Port.OUTPUT.
497    ///
498    /// Servers should verify that this VMO is (a) provided by sysmem, and
499    /// (b) meets the server's current sysmem constraints. The server can
500    /// verify both (a) and (b) by checking the result of sysmem's
501    /// CheckVmoConstraints before using this VMO. If that check fails, the
502    /// server can close the StreamProcessor server_end.
503    pub buffer: Option<fidl::Vmo>,
504    #[doc(hidden)]
505    pub __source_breaking: fidl::marker::SourceBreaking,
506}
507
508impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
509    for StreamProcessorAddBufferRequest
510{
511}
512
513#[derive(Debug, Default, PartialEq)]
514pub struct StreamProcessorParticipateInBufferAllocationRequest {
515    /// Which port (input or output) the buffer(s) are for.
516    ///
517    /// Must be set.
518    pub port: Option<Port>,
519    /// For input, this field must be set to 1, at least for now.
520    ///
521    /// For output, this field must set to the latest known (to the client)
522    /// buffer_constraints_version_ordinal value from the server. If the
523    /// value is less than the latest buffer_constraints_version_ordinal
524    /// created by the server which had action_reqiured true, then the
525    /// server will set generic sysmem constraints (just min_buffer_count 1)
526    /// and otherwise ignore this message. This is intended to allow
527    /// allocation to succeed (to allow simpler client error handling for
528    /// some clients); in this case a new buffer_constraints_version_ordinal
529    /// will reach the client and the client can catch up to the latest.
530    ///
531    /// If this value is a future value, the server will drop the
532    /// sysmem2_token which will cause allocation failure.
533    ///
534    /// Must be set.
535    pub buffer_constraints_version_ordinal: Option<u64>,
536    /// This sysmem token is used by the server to inform sysmem directly of
537    /// any applicable buffer constraints. These constraints are allowed to
538    /// (and in some cases must) depend on how this StreamProcessor instance
539    /// was created. For example, secure_input_mode/secure_output_mode
540    /// during StreamProcessor creation causes the server to set
541    /// secure_required for input/output respectively (as specified by
542    /// Port.INPUT or Port.OUTPUT respectively).
543    ///
544    /// Must be set.
545    pub sysmem2_token:
546        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
547    /// If set, and there's been at least one AddBuffer previously sent with
548    /// this buffer_lifetime_ordinal on the same StreamProcessor instance
549    /// which hasn't yet been removed server-side, the new buffer(s) will be
550    /// allocated with identical SingleBufferSettings, or fail allocation.
551    /// If any of the conditions in this paragraph aren't met, the effect is
552    /// the same as if this field is not set.
553    ///
554    /// If this field is not set, the sysmem constraints set by the server
555    /// will be suitable for a buffer of a new buffer_lifetime_ordinal, and
556    /// the new buffer's SingleBufferSettings might not match any previous
557    /// buffer's SingleBufferSettings.
558    ///
559    /// If the server has a current stream and `port` indicates the output
560    /// port, the constraints set will allow the stream to be correctly
561    /// processed across the switch to new buffer_lifetime_ordinal (assuming
562    /// the client is using a new buffer_lifetime_ordinal and adds the new
563    /// buffer(s) subsequently etc). If port indicates the input port, the
564    /// constraints set will be generic for the input port regardless of any
565    /// current stream.
566    ///
567    /// If this mechanism isn't used, the client must still ensure that all
568    /// AddBuffer with a given StreamProcessor instance, port, and
569    /// buffer_lifetime_ordinal have identical SingleBufferSettings. One way
570    /// to do this is to allocate all the buffers of a
571    /// buffer_lifetime_ordinal under a single sysmem buffer collection.
572    /// Another way is for the client to tell sysmem directly that a new
573    /// buffer collection must match the SingleBufferSettings of a prior
574    /// collection using
575    /// `[fuchsia.sysmem2/BufferCollectionConstraints.must_match_vmo]`
576    /// client-side.
577    ///
578    /// It's not recommended for a client to attempt to force a new
579    /// collecton's SingleBufferSettings to match an old collection's
580    /// SingleBufferSettings without sysmem's help and without
581    /// StreamProcessor's help via this field, because sysmem intentionally
582    /// allows clients participating in the same collection to be using
583    /// different versions of the sysmem interfaces, so the client may not
584    /// have enough information to successfully force the
585    /// SingleBufferSettings to match without using `must_match_vmo`, for
586    /// example if the client is unaware of a new SingleBufferSettings field
587    /// (or similar). The most common StreamProcessor server implementation
588    /// (CodecImpl) will handle this field using `must_match_vmo` on behalf
589    /// of the client as long as there's still at least one buffer of the
590    /// buffer_lifetime_ordinal active in the server. The ability to
591    /// dynamically add more buffers to an existing sysmem collection may be
592    /// added to sysmem at some point; that would give the client another
593    /// way to ensure identical SingleBufferSettings within a
594    /// buffer_lifetime_ordinal, but only if/when all sysmem collection
595    /// participants indicate support for a dynamic sysmem buffer
596    /// collection.
597    ///
598    /// For output, setting this field is strongly recommended if a client
599    /// is adding additional output buffers to an existing
600    /// buffer_lifetime_ordinal using a new/different sysmem buffer
601    /// collection, and setting this field is recommended for all output
602    /// buffer allocations.
603    ///
604    /// For input, if a client is using the same StreamProcessor instance
605    /// for this message and AddBuffer (which is itself recommended when
606    /// feasible), use of this field is recommended for those input buffers.
607    ///
608    /// If set, this value must match the buffer_lifetime_ordinal later sent
609    /// in AddBuffer.
610    ///
611    /// Clients should set this when feasible; see above.
612    pub buffer_lifetime_ordinal: Option<u64>,
613    /// If set to true, the server will leave all `buffer_count_*` fields
614    /// un-set when sending SetConstraints to sysmem, and will set
615    /// `min_buffer_count` to 1.
616    ///
617    /// If un-set or set to false, the server will fill out buffer count
618    /// fields when sending SetConstraints to sysmem based on the current
619    /// value of `buffer_count_for_server_current`, without any extra slack.
620    /// The client can add slack as desired via its own retained token.
621    ///
622    /// Regardless of whether this field is set to true, it's up to the
623    /// client to `AddBuffer` at least `buffer_count_for_server_current`
624    /// buffers so that processing can make progress.
625    pub allow_single_buffer: Option<bool>,
626    #[doc(hidden)]
627    pub __source_breaking: fidl::marker::SourceBreaking,
628}
629
630impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
631    for StreamProcessorParticipateInBufferAllocationRequest
632{
633}
634
635#[derive(Debug, Default, PartialEq)]
636pub struct StreamProcessorRemoveBufferRequest {
637    /// Must be set. Which port (input or output) the buffer is for.
638    pub port: Option<Port>,
639    /// Scoped to input or output, this is the buffer_lifetime_ordinal under
640    /// which the buffer_index is meaningful.
641    pub buffer_lifetime_ordinal: Option<u64>,
642    /// The buffer_index of the buffer previously established (and most
643    /// recently established) by AddBuffer, or by
644    /// SetInputBufferPartialSettings / SetOutputBufferPartialSettings. The
645    /// scope of this value is under input vs. output and under the
646    /// buffer_lifetime_ordinal value.
647    ///
648    /// When using dynamic buffers, the buffer_index values that are between
649    /// AddBuffer starting and RemoveBuffer completing (the active
650    /// buffer_index values) must be unique for a given Port value and
651    /// buffer_lifetime_ordinal value.
652    ///
653    /// Clients using dynamic buffers may wish to not re-use a buffer_index
654    /// value quickly upon completion of RemoveBuffer just to make
655    /// debugging/diagnosing easier, but technically re-use of buffer_index
656    /// in a subsequent AddBuffer is permitted as soon as RemoveBuffer
657    /// completes (from the StreamProcessor point of view - the client may
658    /// have its own reasons to not re-use that quickly). AddBuffer under an
659    /// old (not current) buffer_lifetime_ordinal is never allowed.
660    pub buffer_index: Option<u32>,
661    #[doc(hidden)]
662    pub __source_breaking: fidl::marker::SourceBreaking,
663}
664
665impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
666    for StreamProcessorRemoveBufferRequest
667{
668}
669
670#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
671pub struct ActivityReporterMarker;
672
673impl fidl::endpoints::ProtocolMarker for ActivityReporterMarker {
674    type Proxy = ActivityReporterProxy;
675    type RequestStream = ActivityReporterRequestStream;
676    #[cfg(target_os = "fuchsia")]
677    type SynchronousProxy = ActivityReporterSynchronousProxy;
678
679    const DEBUG_NAME: &'static str = "fuchsia.media.ActivityReporter";
680}
681impl fidl::endpoints::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#[derive(Debug)]
698#[cfg(target_os = "fuchsia")]
699pub struct ActivityReporterSynchronousProxy {
700    client: fidl::client::sync::Client,
701}
702
703#[cfg(target_os = "fuchsia")]
704impl fidl::endpoints::SynchronousProxy for ActivityReporterSynchronousProxy {
705    type Proxy = ActivityReporterProxy;
706    type Protocol = ActivityReporterMarker;
707
708    fn from_channel(inner: fidl::Channel) -> Self {
709        Self::new(inner)
710    }
711
712    fn into_channel(self) -> fidl::Channel {
713        self.client.into_channel()
714    }
715
716    fn as_channel(&self) -> &fidl::Channel {
717        self.client.as_channel()
718    }
719}
720
721#[cfg(target_os = "fuchsia")]
722impl ActivityReporterSynchronousProxy {
723    pub fn new(channel: fidl::Channel) -> Self {
724        Self { client: fidl::client::sync::Client::new(channel) }
725    }
726
727    pub fn into_channel(self) -> fidl::Channel {
728        self.client.into_channel()
729    }
730
731    /// Waits until an event arrives and returns it. It is safe for other
732    /// threads to make concurrent requests while waiting for an event.
733    pub fn wait_for_event(
734        &self,
735        deadline: zx::MonotonicInstant,
736    ) -> Result<ActivityReporterEvent, fidl::Error> {
737        ActivityReporterEvent::decode(
738            self.client.wait_for_event::<ActivityReporterMarker>(deadline)?,
739        )
740    }
741
742    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
743    /// It returns immediately the first time that it is called.
744    pub fn r#watch_render_activity(
745        &self,
746        ___deadline: zx::MonotonicInstant,
747    ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
748        let _response = self.client.send_query::<
749            fidl::encoding::EmptyPayload,
750            ActivityReporterWatchRenderActivityResponse,
751            ActivityReporterMarker,
752        >(
753            (),
754            0x2974e9f5880b2f1f,
755            fidl::encoding::DynamicFlags::empty(),
756            ___deadline,
757        )?;
758        Ok(_response.active_usages)
759    }
760
761    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
762    /// It returns immediately the first time that it is called.
763    pub fn r#watch_render_activity2(
764        &self,
765        ___deadline: zx::MonotonicInstant,
766    ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
767        let _response = self.client.send_query::<
768            fidl::encoding::EmptyPayload,
769            fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
770            ActivityReporterMarker,
771        >(
772            (),
773            0x484236fc11b363e6,
774            fidl::encoding::DynamicFlags::FLEXIBLE,
775            ___deadline,
776        )?
777        .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
778        Ok(_response.active_usages)
779    }
780
781    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
782    /// It returns immediately the first time that it is called.
783    pub fn r#watch_capture_activity(
784        &self,
785        ___deadline: zx::MonotonicInstant,
786    ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
787        let _response = self.client.send_query::<
788            fidl::encoding::EmptyPayload,
789            ActivityReporterWatchCaptureActivityResponse,
790            ActivityReporterMarker,
791        >(
792            (),
793            0x70e7038e9658e128,
794            fidl::encoding::DynamicFlags::empty(),
795            ___deadline,
796        )?;
797        Ok(_response.active_usages)
798    }
799
800    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
801    /// It returns immediately the first time that it is called.
802    pub fn r#watch_capture_activity2(
803        &self,
804        ___deadline: zx::MonotonicInstant,
805    ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
806        let _response = self.client.send_query::<
807            fidl::encoding::EmptyPayload,
808            fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
809            ActivityReporterMarker,
810        >(
811            (),
812            0x3d137e0364f9d550,
813            fidl::encoding::DynamicFlags::FLEXIBLE,
814            ___deadline,
815        )?
816        .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
817        Ok(_response.active_usages)
818    }
819}
820
821#[cfg(target_os = "fuchsia")]
822impl From<ActivityReporterSynchronousProxy> for zx::NullableHandle {
823    fn from(value: ActivityReporterSynchronousProxy) -> Self {
824        value.into_channel().into()
825    }
826}
827
828#[cfg(target_os = "fuchsia")]
829impl From<fidl::Channel> for ActivityReporterSynchronousProxy {
830    fn from(value: fidl::Channel) -> Self {
831        Self::new(value)
832    }
833}
834
835#[cfg(target_os = "fuchsia")]
836impl fidl::endpoints::FromClient for ActivityReporterSynchronousProxy {
837    type Protocol = ActivityReporterMarker;
838
839    fn from_client(value: fidl::endpoints::ClientEnd<ActivityReporterMarker>) -> Self {
840        Self::new(value.into_channel())
841    }
842}
843
844#[derive(Debug, Clone)]
845pub struct ActivityReporterProxy {
846    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
847}
848
849impl fidl::endpoints::Proxy for ActivityReporterProxy {
850    type Protocol = ActivityReporterMarker;
851
852    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
853        Self::new(inner)
854    }
855
856    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
857        self.client.into_channel().map_err(|client| Self { client })
858    }
859
860    fn as_channel(&self) -> &::fidl::AsyncChannel {
861        self.client.as_channel()
862    }
863}
864
865impl ActivityReporterProxy {
866    /// Create a new Proxy for fuchsia.media/ActivityReporter.
867    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
868        let protocol_name = <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
869        Self { client: fidl::client::Client::new(channel, protocol_name) }
870    }
871
872    /// Get a Stream of events from the remote end of the protocol.
873    ///
874    /// # Panics
875    ///
876    /// Panics if the event stream was already taken.
877    pub fn take_event_stream(&self) -> ActivityReporterEventStream {
878        ActivityReporterEventStream { event_receiver: self.client.take_event_receiver() }
879    }
880
881    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
882    /// It returns immediately the first time that it is called.
883    pub fn r#watch_render_activity(
884        &self,
885    ) -> fidl::client::QueryResponseFut<
886        Vec<AudioRenderUsage>,
887        fidl::encoding::DefaultFuchsiaResourceDialect,
888    > {
889        ActivityReporterProxyInterface::r#watch_render_activity(self)
890    }
891
892    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
893    /// It returns immediately the first time that it is called.
894    pub fn r#watch_render_activity2(
895        &self,
896    ) -> fidl::client::QueryResponseFut<
897        Vec<AudioRenderUsage2>,
898        fidl::encoding::DefaultFuchsiaResourceDialect,
899    > {
900        ActivityReporterProxyInterface::r#watch_render_activity2(self)
901    }
902
903    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
904    /// It returns immediately the first time that it is called.
905    pub fn r#watch_capture_activity(
906        &self,
907    ) -> fidl::client::QueryResponseFut<
908        Vec<AudioCaptureUsage>,
909        fidl::encoding::DefaultFuchsiaResourceDialect,
910    > {
911        ActivityReporterProxyInterface::r#watch_capture_activity(self)
912    }
913
914    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
915    /// It returns immediately the first time that it is called.
916    pub fn r#watch_capture_activity2(
917        &self,
918    ) -> fidl::client::QueryResponseFut<
919        Vec<AudioCaptureUsage2>,
920        fidl::encoding::DefaultFuchsiaResourceDialect,
921    > {
922        ActivityReporterProxyInterface::r#watch_capture_activity2(self)
923    }
924}
925
926impl ActivityReporterProxyInterface for ActivityReporterProxy {
927    type WatchRenderActivityResponseFut = fidl::client::QueryResponseFut<
928        Vec<AudioRenderUsage>,
929        fidl::encoding::DefaultFuchsiaResourceDialect,
930    >;
931    fn r#watch_render_activity(&self) -> Self::WatchRenderActivityResponseFut {
932        fn _decode(
933            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
934        ) -> Result<Vec<AudioRenderUsage>, fidl::Error> {
935            let _response = fidl::client::decode_transaction_body::<
936                ActivityReporterWatchRenderActivityResponse,
937                fidl::encoding::DefaultFuchsiaResourceDialect,
938                0x2974e9f5880b2f1f,
939            >(_buf?)?;
940            Ok(_response.active_usages)
941        }
942        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage>>(
943            (),
944            0x2974e9f5880b2f1f,
945            fidl::encoding::DynamicFlags::empty(),
946            _decode,
947        )
948    }
949
950    type WatchRenderActivity2ResponseFut = fidl::client::QueryResponseFut<
951        Vec<AudioRenderUsage2>,
952        fidl::encoding::DefaultFuchsiaResourceDialect,
953    >;
954    fn r#watch_render_activity2(&self) -> Self::WatchRenderActivity2ResponseFut {
955        fn _decode(
956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
957        ) -> Result<Vec<AudioRenderUsage2>, fidl::Error> {
958            let _response = fidl::client::decode_transaction_body::<
959                fidl::encoding::FlexibleType<ActivityReporterWatchRenderActivity2Response>,
960                fidl::encoding::DefaultFuchsiaResourceDialect,
961                0x484236fc11b363e6,
962            >(_buf?)?
963            .into_result::<ActivityReporterMarker>("watch_render_activity2")?;
964            Ok(_response.active_usages)
965        }
966        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioRenderUsage2>>(
967            (),
968            0x484236fc11b363e6,
969            fidl::encoding::DynamicFlags::FLEXIBLE,
970            _decode,
971        )
972    }
973
974    type WatchCaptureActivityResponseFut = fidl::client::QueryResponseFut<
975        Vec<AudioCaptureUsage>,
976        fidl::encoding::DefaultFuchsiaResourceDialect,
977    >;
978    fn r#watch_capture_activity(&self) -> Self::WatchCaptureActivityResponseFut {
979        fn _decode(
980            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
981        ) -> Result<Vec<AudioCaptureUsage>, fidl::Error> {
982            let _response = fidl::client::decode_transaction_body::<
983                ActivityReporterWatchCaptureActivityResponse,
984                fidl::encoding::DefaultFuchsiaResourceDialect,
985                0x70e7038e9658e128,
986            >(_buf?)?;
987            Ok(_response.active_usages)
988        }
989        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage>>(
990            (),
991            0x70e7038e9658e128,
992            fidl::encoding::DynamicFlags::empty(),
993            _decode,
994        )
995    }
996
997    type WatchCaptureActivity2ResponseFut = fidl::client::QueryResponseFut<
998        Vec<AudioCaptureUsage2>,
999        fidl::encoding::DefaultFuchsiaResourceDialect,
1000    >;
1001    fn r#watch_capture_activity2(&self) -> Self::WatchCaptureActivity2ResponseFut {
1002        fn _decode(
1003            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1004        ) -> Result<Vec<AudioCaptureUsage2>, fidl::Error> {
1005            let _response = fidl::client::decode_transaction_body::<
1006                fidl::encoding::FlexibleType<ActivityReporterWatchCaptureActivity2Response>,
1007                fidl::encoding::DefaultFuchsiaResourceDialect,
1008                0x3d137e0364f9d550,
1009            >(_buf?)?
1010            .into_result::<ActivityReporterMarker>("watch_capture_activity2")?;
1011            Ok(_response.active_usages)
1012        }
1013        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioCaptureUsage2>>(
1014            (),
1015            0x3d137e0364f9d550,
1016            fidl::encoding::DynamicFlags::FLEXIBLE,
1017            _decode,
1018        )
1019    }
1020}
1021
1022pub struct ActivityReporterEventStream {
1023    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1024}
1025
1026impl std::marker::Unpin for ActivityReporterEventStream {}
1027
1028impl futures::stream::FusedStream for ActivityReporterEventStream {
1029    fn is_terminated(&self) -> bool {
1030        self.event_receiver.is_terminated()
1031    }
1032}
1033
1034impl futures::Stream for ActivityReporterEventStream {
1035    type Item = Result<ActivityReporterEvent, fidl::Error>;
1036
1037    fn poll_next(
1038        mut self: std::pin::Pin<&mut Self>,
1039        cx: &mut std::task::Context<'_>,
1040    ) -> std::task::Poll<Option<Self::Item>> {
1041        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1042            &mut self.event_receiver,
1043            cx
1044        )?) {
1045            Some(buf) => std::task::Poll::Ready(Some(ActivityReporterEvent::decode(buf))),
1046            None => std::task::Poll::Ready(None),
1047        }
1048    }
1049}
1050
1051#[derive(Debug)]
1052pub enum ActivityReporterEvent {
1053    #[non_exhaustive]
1054    _UnknownEvent {
1055        /// Ordinal of the event that was sent.
1056        ordinal: u64,
1057    },
1058}
1059
1060impl ActivityReporterEvent {
1061    /// Decodes a message buffer as a [`ActivityReporterEvent`].
1062    fn decode(
1063        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1064    ) -> Result<ActivityReporterEvent, fidl::Error> {
1065        let (bytes, _handles) = buf.split_mut();
1066        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1067        debug_assert_eq!(tx_header.tx_id, 0);
1068        match tx_header.ordinal {
1069            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1070                Ok(ActivityReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1071            }
1072            _ => Err(fidl::Error::UnknownOrdinal {
1073                ordinal: tx_header.ordinal,
1074                protocol_name:
1075                    <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1076            }),
1077        }
1078    }
1079}
1080
1081/// A Stream of incoming requests for fuchsia.media/ActivityReporter.
1082pub struct ActivityReporterRequestStream {
1083    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1084    is_terminated: bool,
1085}
1086
1087impl std::marker::Unpin for ActivityReporterRequestStream {}
1088
1089impl futures::stream::FusedStream for ActivityReporterRequestStream {
1090    fn is_terminated(&self) -> bool {
1091        self.is_terminated
1092    }
1093}
1094
1095impl fidl::endpoints::RequestStream for ActivityReporterRequestStream {
1096    type Protocol = ActivityReporterMarker;
1097    type ControlHandle = ActivityReporterControlHandle;
1098
1099    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1100        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1101    }
1102
1103    fn control_handle(&self) -> Self::ControlHandle {
1104        ActivityReporterControlHandle { inner: self.inner.clone() }
1105    }
1106
1107    fn into_inner(
1108        self,
1109    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1110    {
1111        (self.inner, self.is_terminated)
1112    }
1113
1114    fn from_inner(
1115        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1116        is_terminated: bool,
1117    ) -> Self {
1118        Self { inner, is_terminated }
1119    }
1120}
1121
1122impl futures::Stream for ActivityReporterRequestStream {
1123    type Item = Result<ActivityReporterRequest, fidl::Error>;
1124
1125    fn poll_next(
1126        mut self: std::pin::Pin<&mut Self>,
1127        cx: &mut std::task::Context<'_>,
1128    ) -> std::task::Poll<Option<Self::Item>> {
1129        let this = &mut *self;
1130        if this.inner.check_shutdown(cx) {
1131            this.is_terminated = true;
1132            return std::task::Poll::Ready(None);
1133        }
1134        if this.is_terminated {
1135            panic!("polled ActivityReporterRequestStream after completion");
1136        }
1137        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1138            |bytes, handles| {
1139                match this.inner.channel().read_etc(cx, bytes, handles) {
1140                    std::task::Poll::Ready(Ok(())) => {}
1141                    std::task::Poll::Pending => return std::task::Poll::Pending,
1142                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1143                        this.is_terminated = true;
1144                        return std::task::Poll::Ready(None);
1145                    }
1146                    std::task::Poll::Ready(Err(e)) => {
1147                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1148                            e.into(),
1149                        ))));
1150                    }
1151                }
1152
1153                // A message has been received from the channel
1154                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1155
1156                std::task::Poll::Ready(Some(match header.ordinal {
1157                    0x2974e9f5880b2f1f => {
1158                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1159                        let mut req = fidl::new_empty!(
1160                            fidl::encoding::EmptyPayload,
1161                            fidl::encoding::DefaultFuchsiaResourceDialect
1162                        );
1163                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1164                        let control_handle =
1165                            ActivityReporterControlHandle { inner: this.inner.clone() };
1166                        Ok(ActivityReporterRequest::WatchRenderActivity {
1167                            responder: ActivityReporterWatchRenderActivityResponder {
1168                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1169                                tx_id: header.tx_id,
1170                            },
1171                        })
1172                    }
1173                    0x484236fc11b363e6 => {
1174                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1175                        let mut req = fidl::new_empty!(
1176                            fidl::encoding::EmptyPayload,
1177                            fidl::encoding::DefaultFuchsiaResourceDialect
1178                        );
1179                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1180                        let control_handle =
1181                            ActivityReporterControlHandle { inner: this.inner.clone() };
1182                        Ok(ActivityReporterRequest::WatchRenderActivity2 {
1183                            responder: ActivityReporterWatchRenderActivity2Responder {
1184                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1185                                tx_id: header.tx_id,
1186                            },
1187                        })
1188                    }
1189                    0x70e7038e9658e128 => {
1190                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1191                        let mut req = fidl::new_empty!(
1192                            fidl::encoding::EmptyPayload,
1193                            fidl::encoding::DefaultFuchsiaResourceDialect
1194                        );
1195                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1196                        let control_handle =
1197                            ActivityReporterControlHandle { inner: this.inner.clone() };
1198                        Ok(ActivityReporterRequest::WatchCaptureActivity {
1199                            responder: ActivityReporterWatchCaptureActivityResponder {
1200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1201                                tx_id: header.tx_id,
1202                            },
1203                        })
1204                    }
1205                    0x3d137e0364f9d550 => {
1206                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1207                        let mut req = fidl::new_empty!(
1208                            fidl::encoding::EmptyPayload,
1209                            fidl::encoding::DefaultFuchsiaResourceDialect
1210                        );
1211                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1212                        let control_handle =
1213                            ActivityReporterControlHandle { inner: this.inner.clone() };
1214                        Ok(ActivityReporterRequest::WatchCaptureActivity2 {
1215                            responder: ActivityReporterWatchCaptureActivity2Responder {
1216                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1217                                tx_id: header.tx_id,
1218                            },
1219                        })
1220                    }
1221                    _ if header.tx_id == 0
1222                        && header
1223                            .dynamic_flags()
1224                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1225                    {
1226                        Ok(ActivityReporterRequest::_UnknownMethod {
1227                            ordinal: header.ordinal,
1228                            control_handle: ActivityReporterControlHandle {
1229                                inner: this.inner.clone(),
1230                            },
1231                            method_type: fidl::MethodType::OneWay,
1232                        })
1233                    }
1234                    _ if header
1235                        .dynamic_flags()
1236                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1237                    {
1238                        this.inner.send_framework_err(
1239                            fidl::encoding::FrameworkErr::UnknownMethod,
1240                            header.tx_id,
1241                            header.ordinal,
1242                            header.dynamic_flags(),
1243                            (bytes, handles),
1244                        )?;
1245                        Ok(ActivityReporterRequest::_UnknownMethod {
1246                            ordinal: header.ordinal,
1247                            control_handle: ActivityReporterControlHandle {
1248                                inner: this.inner.clone(),
1249                            },
1250                            method_type: fidl::MethodType::TwoWay,
1251                        })
1252                    }
1253                    _ => Err(fidl::Error::UnknownOrdinal {
1254                        ordinal: header.ordinal,
1255                        protocol_name:
1256                            <ActivityReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1257                    }),
1258                }))
1259            },
1260        )
1261    }
1262}
1263
1264/// A protocol for monitoring the usage activity of the AudioRenderers and AudioCapturers.
1265#[derive(Debug)]
1266pub enum ActivityReporterRequest {
1267    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1268    /// It returns immediately the first time that it is called.
1269    WatchRenderActivity { responder: ActivityReporterWatchRenderActivityResponder },
1270    /// Notifies the client whenever there is a change in the set of active AudioRenderUsages.
1271    /// It returns immediately the first time that it is called.
1272    WatchRenderActivity2 { responder: ActivityReporterWatchRenderActivity2Responder },
1273    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1274    /// It returns immediately the first time that it is called.
1275    WatchCaptureActivity { responder: ActivityReporterWatchCaptureActivityResponder },
1276    /// Notifies the client whenever there is a change in the set of active AudioCaptureUsages.
1277    /// It returns immediately the first time that it is called.
1278    WatchCaptureActivity2 { responder: ActivityReporterWatchCaptureActivity2Responder },
1279    /// An interaction was received which does not match any known method.
1280    #[non_exhaustive]
1281    _UnknownMethod {
1282        /// Ordinal of the method that was called.
1283        ordinal: u64,
1284        control_handle: ActivityReporterControlHandle,
1285        method_type: fidl::MethodType,
1286    },
1287}
1288
1289impl ActivityReporterRequest {
1290    #[allow(irrefutable_let_patterns)]
1291    pub fn into_watch_render_activity(
1292        self,
1293    ) -> Option<(ActivityReporterWatchRenderActivityResponder)> {
1294        if let ActivityReporterRequest::WatchRenderActivity { responder } = self {
1295            Some((responder))
1296        } else {
1297            None
1298        }
1299    }
1300
1301    #[allow(irrefutable_let_patterns)]
1302    pub fn into_watch_render_activity2(
1303        self,
1304    ) -> Option<(ActivityReporterWatchRenderActivity2Responder)> {
1305        if let ActivityReporterRequest::WatchRenderActivity2 { responder } = self {
1306            Some((responder))
1307        } else {
1308            None
1309        }
1310    }
1311
1312    #[allow(irrefutable_let_patterns)]
1313    pub fn into_watch_capture_activity(
1314        self,
1315    ) -> Option<(ActivityReporterWatchCaptureActivityResponder)> {
1316        if let ActivityReporterRequest::WatchCaptureActivity { responder } = self {
1317            Some((responder))
1318        } else {
1319            None
1320        }
1321    }
1322
1323    #[allow(irrefutable_let_patterns)]
1324    pub fn into_watch_capture_activity2(
1325        self,
1326    ) -> Option<(ActivityReporterWatchCaptureActivity2Responder)> {
1327        if let ActivityReporterRequest::WatchCaptureActivity2 { responder } = self {
1328            Some((responder))
1329        } else {
1330            None
1331        }
1332    }
1333
1334    /// Name of the method defined in FIDL
1335    pub fn method_name(&self) -> &'static str {
1336        match *self {
1337            ActivityReporterRequest::WatchRenderActivity { .. } => "watch_render_activity",
1338            ActivityReporterRequest::WatchRenderActivity2 { .. } => "watch_render_activity2",
1339            ActivityReporterRequest::WatchCaptureActivity { .. } => "watch_capture_activity",
1340            ActivityReporterRequest::WatchCaptureActivity2 { .. } => "watch_capture_activity2",
1341            ActivityReporterRequest::_UnknownMethod {
1342                method_type: fidl::MethodType::OneWay,
1343                ..
1344            } => "unknown one-way method",
1345            ActivityReporterRequest::_UnknownMethod {
1346                method_type: fidl::MethodType::TwoWay,
1347                ..
1348            } => "unknown two-way method",
1349        }
1350    }
1351}
1352
1353#[derive(Debug, Clone)]
1354pub struct ActivityReporterControlHandle {
1355    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1356}
1357
1358impl ActivityReporterControlHandle {
1359    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1360        self.inner.shutdown_with_epitaph(status.into())
1361    }
1362}
1363
1364impl fidl::endpoints::ControlHandle for ActivityReporterControlHandle {
1365    fn shutdown(&self) {
1366        self.inner.shutdown()
1367    }
1368
1369    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1370        self.inner.shutdown_with_epitaph(status)
1371    }
1372
1373    fn is_closed(&self) -> bool {
1374        self.inner.channel().is_closed()
1375    }
1376    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1377        self.inner.channel().on_closed()
1378    }
1379
1380    #[cfg(target_os = "fuchsia")]
1381    fn signal_peer(
1382        &self,
1383        clear_mask: zx::Signals,
1384        set_mask: zx::Signals,
1385    ) -> Result<(), zx_status::Status> {
1386        use fidl::Peered;
1387        self.inner.channel().signal_peer(clear_mask, set_mask)
1388    }
1389}
1390
1391impl ActivityReporterControlHandle {}
1392
1393#[must_use = "FIDL methods require a response to be sent"]
1394#[derive(Debug)]
1395pub struct ActivityReporterWatchRenderActivityResponder {
1396    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1397    tx_id: u32,
1398}
1399
1400/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1401/// if the responder is dropped without sending a response, so that the client
1402/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1403impl std::ops::Drop for ActivityReporterWatchRenderActivityResponder {
1404    fn drop(&mut self) {
1405        self.control_handle.shutdown();
1406        // Safety: drops once, never accessed again
1407        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1408    }
1409}
1410
1411impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivityResponder {
1412    type ControlHandle = ActivityReporterControlHandle;
1413
1414    fn control_handle(&self) -> &ActivityReporterControlHandle {
1415        &self.control_handle
1416    }
1417
1418    fn drop_without_shutdown(mut self) {
1419        // Safety: drops once, never accessed again due to mem::forget
1420        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1421        // Prevent Drop from running (which would shut down the channel)
1422        std::mem::forget(self);
1423    }
1424}
1425
1426impl ActivityReporterWatchRenderActivityResponder {
1427    /// Sends a response to the FIDL transaction.
1428    ///
1429    /// Sets the channel to shutdown if an error occurs.
1430    pub fn send(self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1431        let _result = self.send_raw(active_usages);
1432        if _result.is_err() {
1433            self.control_handle.shutdown();
1434        }
1435        self.drop_without_shutdown();
1436        _result
1437    }
1438
1439    /// Similar to "send" but does not shutdown the channel if an error occurs.
1440    pub fn send_no_shutdown_on_err(
1441        self,
1442        mut active_usages: &[AudioRenderUsage],
1443    ) -> Result<(), fidl::Error> {
1444        let _result = self.send_raw(active_usages);
1445        self.drop_without_shutdown();
1446        _result
1447    }
1448
1449    fn send_raw(&self, mut active_usages: &[AudioRenderUsage]) -> Result<(), fidl::Error> {
1450        self.control_handle.inner.send::<ActivityReporterWatchRenderActivityResponse>(
1451            (active_usages,),
1452            self.tx_id,
1453            0x2974e9f5880b2f1f,
1454            fidl::encoding::DynamicFlags::empty(),
1455        )
1456    }
1457}
1458
1459#[must_use = "FIDL methods require a response to be sent"]
1460#[derive(Debug)]
1461pub struct ActivityReporterWatchRenderActivity2Responder {
1462    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1463    tx_id: u32,
1464}
1465
1466/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1467/// if the responder is dropped without sending a response, so that the client
1468/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1469impl std::ops::Drop for ActivityReporterWatchRenderActivity2Responder {
1470    fn drop(&mut self) {
1471        self.control_handle.shutdown();
1472        // Safety: drops once, never accessed again
1473        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1474    }
1475}
1476
1477impl fidl::endpoints::Responder for ActivityReporterWatchRenderActivity2Responder {
1478    type ControlHandle = ActivityReporterControlHandle;
1479
1480    fn control_handle(&self) -> &ActivityReporterControlHandle {
1481        &self.control_handle
1482    }
1483
1484    fn drop_without_shutdown(mut self) {
1485        // Safety: drops once, never accessed again due to mem::forget
1486        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1487        // Prevent Drop from running (which would shut down the channel)
1488        std::mem::forget(self);
1489    }
1490}
1491
1492impl ActivityReporterWatchRenderActivity2Responder {
1493    /// Sends a response to the FIDL transaction.
1494    ///
1495    /// Sets the channel to shutdown if an error occurs.
1496    pub fn send(self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1497        let _result = self.send_raw(active_usages);
1498        if _result.is_err() {
1499            self.control_handle.shutdown();
1500        }
1501        self.drop_without_shutdown();
1502        _result
1503    }
1504
1505    /// Similar to "send" but does not shutdown the channel if an error occurs.
1506    pub fn send_no_shutdown_on_err(
1507        self,
1508        mut active_usages: &[AudioRenderUsage2],
1509    ) -> Result<(), fidl::Error> {
1510        let _result = self.send_raw(active_usages);
1511        self.drop_without_shutdown();
1512        _result
1513    }
1514
1515    fn send_raw(&self, mut active_usages: &[AudioRenderUsage2]) -> Result<(), fidl::Error> {
1516        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1517            ActivityReporterWatchRenderActivity2Response,
1518        >>(
1519            fidl::encoding::Flexible::new((active_usages,)),
1520            self.tx_id,
1521            0x484236fc11b363e6,
1522            fidl::encoding::DynamicFlags::FLEXIBLE,
1523        )
1524    }
1525}
1526
1527#[must_use = "FIDL methods require a response to be sent"]
1528#[derive(Debug)]
1529pub struct ActivityReporterWatchCaptureActivityResponder {
1530    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1531    tx_id: u32,
1532}
1533
1534/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1535/// if the responder is dropped without sending a response, so that the client
1536/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1537impl std::ops::Drop for ActivityReporterWatchCaptureActivityResponder {
1538    fn drop(&mut self) {
1539        self.control_handle.shutdown();
1540        // Safety: drops once, never accessed again
1541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1542    }
1543}
1544
1545impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivityResponder {
1546    type ControlHandle = ActivityReporterControlHandle;
1547
1548    fn control_handle(&self) -> &ActivityReporterControlHandle {
1549        &self.control_handle
1550    }
1551
1552    fn drop_without_shutdown(mut self) {
1553        // Safety: drops once, never accessed again due to mem::forget
1554        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1555        // Prevent Drop from running (which would shut down the channel)
1556        std::mem::forget(self);
1557    }
1558}
1559
1560impl ActivityReporterWatchCaptureActivityResponder {
1561    /// Sends a response to the FIDL transaction.
1562    ///
1563    /// Sets the channel to shutdown if an error occurs.
1564    pub fn send(self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1565        let _result = self.send_raw(active_usages);
1566        if _result.is_err() {
1567            self.control_handle.shutdown();
1568        }
1569        self.drop_without_shutdown();
1570        _result
1571    }
1572
1573    /// Similar to "send" but does not shutdown the channel if an error occurs.
1574    pub fn send_no_shutdown_on_err(
1575        self,
1576        mut active_usages: &[AudioCaptureUsage],
1577    ) -> Result<(), fidl::Error> {
1578        let _result = self.send_raw(active_usages);
1579        self.drop_without_shutdown();
1580        _result
1581    }
1582
1583    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage]) -> Result<(), fidl::Error> {
1584        self.control_handle.inner.send::<ActivityReporterWatchCaptureActivityResponse>(
1585            (active_usages,),
1586            self.tx_id,
1587            0x70e7038e9658e128,
1588            fidl::encoding::DynamicFlags::empty(),
1589        )
1590    }
1591}
1592
1593#[must_use = "FIDL methods require a response to be sent"]
1594#[derive(Debug)]
1595pub struct ActivityReporterWatchCaptureActivity2Responder {
1596    control_handle: std::mem::ManuallyDrop<ActivityReporterControlHandle>,
1597    tx_id: u32,
1598}
1599
1600/// Set the the channel to be shutdown (see [`ActivityReporterControlHandle::shutdown`])
1601/// if the responder is dropped without sending a response, so that the client
1602/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1603impl std::ops::Drop for ActivityReporterWatchCaptureActivity2Responder {
1604    fn drop(&mut self) {
1605        self.control_handle.shutdown();
1606        // Safety: drops once, never accessed again
1607        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1608    }
1609}
1610
1611impl fidl::endpoints::Responder for ActivityReporterWatchCaptureActivity2Responder {
1612    type ControlHandle = ActivityReporterControlHandle;
1613
1614    fn control_handle(&self) -> &ActivityReporterControlHandle {
1615        &self.control_handle
1616    }
1617
1618    fn drop_without_shutdown(mut self) {
1619        // Safety: drops once, never accessed again due to mem::forget
1620        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1621        // Prevent Drop from running (which would shut down the channel)
1622        std::mem::forget(self);
1623    }
1624}
1625
1626impl ActivityReporterWatchCaptureActivity2Responder {
1627    /// Sends a response to the FIDL transaction.
1628    ///
1629    /// Sets the channel to shutdown if an error occurs.
1630    pub fn send(self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1631        let _result = self.send_raw(active_usages);
1632        if _result.is_err() {
1633            self.control_handle.shutdown();
1634        }
1635        self.drop_without_shutdown();
1636        _result
1637    }
1638
1639    /// Similar to "send" but does not shutdown the channel if an error occurs.
1640    pub fn send_no_shutdown_on_err(
1641        self,
1642        mut active_usages: &[AudioCaptureUsage2],
1643    ) -> Result<(), fidl::Error> {
1644        let _result = self.send_raw(active_usages);
1645        self.drop_without_shutdown();
1646        _result
1647    }
1648
1649    fn send_raw(&self, mut active_usages: &[AudioCaptureUsage2]) -> Result<(), fidl::Error> {
1650        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1651            ActivityReporterWatchCaptureActivity2Response,
1652        >>(
1653            fidl::encoding::Flexible::new((active_usages,)),
1654            self.tx_id,
1655            0x3d137e0364f9d550,
1656            fidl::encoding::DynamicFlags::FLEXIBLE,
1657        )
1658    }
1659}
1660
1661#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1662pub struct AudioMarker;
1663
1664impl fidl::endpoints::ProtocolMarker for AudioMarker {
1665    type Proxy = AudioProxy;
1666    type RequestStream = AudioRequestStream;
1667    #[cfg(target_os = "fuchsia")]
1668    type SynchronousProxy = AudioSynchronousProxy;
1669
1670    const DEBUG_NAME: &'static str = "fuchsia.media.Audio";
1671}
1672impl fidl::endpoints::DiscoverableProtocolMarker for AudioMarker {}
1673
1674pub trait AudioProxyInterface: Send + Sync {
1675    fn r#create_audio_renderer(
1676        &self,
1677        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1678    ) -> Result<(), fidl::Error>;
1679    fn r#create_audio_capturer(
1680        &self,
1681        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1682        loopback: bool,
1683    ) -> Result<(), fidl::Error>;
1684}
1685#[derive(Debug)]
1686#[cfg(target_os = "fuchsia")]
1687pub struct AudioSynchronousProxy {
1688    client: fidl::client::sync::Client,
1689}
1690
1691#[cfg(target_os = "fuchsia")]
1692impl fidl::endpoints::SynchronousProxy for AudioSynchronousProxy {
1693    type Proxy = AudioProxy;
1694    type Protocol = AudioMarker;
1695
1696    fn from_channel(inner: fidl::Channel) -> Self {
1697        Self::new(inner)
1698    }
1699
1700    fn into_channel(self) -> fidl::Channel {
1701        self.client.into_channel()
1702    }
1703
1704    fn as_channel(&self) -> &fidl::Channel {
1705        self.client.as_channel()
1706    }
1707}
1708
1709#[cfg(target_os = "fuchsia")]
1710impl AudioSynchronousProxy {
1711    pub fn new(channel: fidl::Channel) -> Self {
1712        Self { client: fidl::client::sync::Client::new(channel) }
1713    }
1714
1715    pub fn into_channel(self) -> fidl::Channel {
1716        self.client.into_channel()
1717    }
1718
1719    /// Waits until an event arrives and returns it. It is safe for other
1720    /// threads to make concurrent requests while waiting for an event.
1721    pub fn wait_for_event(
1722        &self,
1723        deadline: zx::MonotonicInstant,
1724    ) -> Result<AudioEvent, fidl::Error> {
1725        AudioEvent::decode(self.client.wait_for_event::<AudioMarker>(deadline)?)
1726    }
1727
1728    pub fn r#create_audio_renderer(
1729        &self,
1730        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1731    ) -> Result<(), fidl::Error> {
1732        self.client.send::<AudioCreateAudioRendererRequest>(
1733            (audio_renderer_request,),
1734            0x572f413566fd58f1,
1735            fidl::encoding::DynamicFlags::empty(),
1736        )
1737    }
1738
1739    /// Creates an AudioCapturer which either captures from the current default
1740    /// audio input device, or loops-back from the current default audio output
1741    /// device based on value passed for the loopback flag.
1742    pub fn r#create_audio_capturer(
1743        &self,
1744        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1745        mut loopback: bool,
1746    ) -> Result<(), fidl::Error> {
1747        self.client.send::<AudioCreateAudioCapturerRequest>(
1748            (audio_capturer_request, loopback),
1749            0x44660fc63a6202f,
1750            fidl::encoding::DynamicFlags::empty(),
1751        )
1752    }
1753}
1754
1755#[cfg(target_os = "fuchsia")]
1756impl From<AudioSynchronousProxy> for zx::NullableHandle {
1757    fn from(value: AudioSynchronousProxy) -> Self {
1758        value.into_channel().into()
1759    }
1760}
1761
1762#[cfg(target_os = "fuchsia")]
1763impl From<fidl::Channel> for AudioSynchronousProxy {
1764    fn from(value: fidl::Channel) -> Self {
1765        Self::new(value)
1766    }
1767}
1768
1769#[cfg(target_os = "fuchsia")]
1770impl fidl::endpoints::FromClient for AudioSynchronousProxy {
1771    type Protocol = AudioMarker;
1772
1773    fn from_client(value: fidl::endpoints::ClientEnd<AudioMarker>) -> Self {
1774        Self::new(value.into_channel())
1775    }
1776}
1777
1778#[derive(Debug, Clone)]
1779pub struct AudioProxy {
1780    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1781}
1782
1783impl fidl::endpoints::Proxy for AudioProxy {
1784    type Protocol = AudioMarker;
1785
1786    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1787        Self::new(inner)
1788    }
1789
1790    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1791        self.client.into_channel().map_err(|client| Self { client })
1792    }
1793
1794    fn as_channel(&self) -> &::fidl::AsyncChannel {
1795        self.client.as_channel()
1796    }
1797}
1798
1799impl AudioProxy {
1800    /// Create a new Proxy for fuchsia.media/Audio.
1801    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1802        let protocol_name = <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1803        Self { client: fidl::client::Client::new(channel, protocol_name) }
1804    }
1805
1806    /// Get a Stream of events from the remote end of the protocol.
1807    ///
1808    /// # Panics
1809    ///
1810    /// Panics if the event stream was already taken.
1811    pub fn take_event_stream(&self) -> AudioEventStream {
1812        AudioEventStream { event_receiver: self.client.take_event_receiver() }
1813    }
1814
1815    pub fn r#create_audio_renderer(
1816        &self,
1817        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1818    ) -> Result<(), fidl::Error> {
1819        AudioProxyInterface::r#create_audio_renderer(self, audio_renderer_request)
1820    }
1821
1822    /// Creates an AudioCapturer which either captures from the current default
1823    /// audio input device, or loops-back from the current default audio output
1824    /// device based on value passed for the loopback flag.
1825    pub fn r#create_audio_capturer(
1826        &self,
1827        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1828        mut loopback: bool,
1829    ) -> Result<(), fidl::Error> {
1830        AudioProxyInterface::r#create_audio_capturer(self, audio_capturer_request, loopback)
1831    }
1832}
1833
1834impl AudioProxyInterface for AudioProxy {
1835    fn r#create_audio_renderer(
1836        &self,
1837        mut audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
1838    ) -> Result<(), fidl::Error> {
1839        self.client.send::<AudioCreateAudioRendererRequest>(
1840            (audio_renderer_request,),
1841            0x572f413566fd58f1,
1842            fidl::encoding::DynamicFlags::empty(),
1843        )
1844    }
1845
1846    fn r#create_audio_capturer(
1847        &self,
1848        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
1849        mut loopback: bool,
1850    ) -> Result<(), fidl::Error> {
1851        self.client.send::<AudioCreateAudioCapturerRequest>(
1852            (audio_capturer_request, loopback),
1853            0x44660fc63a6202f,
1854            fidl::encoding::DynamicFlags::empty(),
1855        )
1856    }
1857}
1858
1859pub struct AudioEventStream {
1860    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1861}
1862
1863impl std::marker::Unpin for AudioEventStream {}
1864
1865impl futures::stream::FusedStream for AudioEventStream {
1866    fn is_terminated(&self) -> bool {
1867        self.event_receiver.is_terminated()
1868    }
1869}
1870
1871impl futures::Stream for AudioEventStream {
1872    type Item = Result<AudioEvent, fidl::Error>;
1873
1874    fn poll_next(
1875        mut self: std::pin::Pin<&mut Self>,
1876        cx: &mut std::task::Context<'_>,
1877    ) -> std::task::Poll<Option<Self::Item>> {
1878        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1879            &mut self.event_receiver,
1880            cx
1881        )?) {
1882            Some(buf) => std::task::Poll::Ready(Some(AudioEvent::decode(buf))),
1883            None => std::task::Poll::Ready(None),
1884        }
1885    }
1886}
1887
1888#[derive(Debug)]
1889pub enum AudioEvent {}
1890
1891impl AudioEvent {
1892    /// Decodes a message buffer as a [`AudioEvent`].
1893    fn decode(
1894        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1895    ) -> Result<AudioEvent, fidl::Error> {
1896        let (bytes, _handles) = buf.split_mut();
1897        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1898        debug_assert_eq!(tx_header.tx_id, 0);
1899        match tx_header.ordinal {
1900            _ => Err(fidl::Error::UnknownOrdinal {
1901                ordinal: tx_header.ordinal,
1902                protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1903            }),
1904        }
1905    }
1906}
1907
1908/// A Stream of incoming requests for fuchsia.media/Audio.
1909pub struct AudioRequestStream {
1910    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1911    is_terminated: bool,
1912}
1913
1914impl std::marker::Unpin for AudioRequestStream {}
1915
1916impl futures::stream::FusedStream for AudioRequestStream {
1917    fn is_terminated(&self) -> bool {
1918        self.is_terminated
1919    }
1920}
1921
1922impl fidl::endpoints::RequestStream for AudioRequestStream {
1923    type Protocol = AudioMarker;
1924    type ControlHandle = AudioControlHandle;
1925
1926    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1927        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1928    }
1929
1930    fn control_handle(&self) -> Self::ControlHandle {
1931        AudioControlHandle { inner: self.inner.clone() }
1932    }
1933
1934    fn into_inner(
1935        self,
1936    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1937    {
1938        (self.inner, self.is_terminated)
1939    }
1940
1941    fn from_inner(
1942        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1943        is_terminated: bool,
1944    ) -> Self {
1945        Self { inner, is_terminated }
1946    }
1947}
1948
1949impl futures::Stream for AudioRequestStream {
1950    type Item = Result<AudioRequest, fidl::Error>;
1951
1952    fn poll_next(
1953        mut self: std::pin::Pin<&mut Self>,
1954        cx: &mut std::task::Context<'_>,
1955    ) -> std::task::Poll<Option<Self::Item>> {
1956        let this = &mut *self;
1957        if this.inner.check_shutdown(cx) {
1958            this.is_terminated = true;
1959            return std::task::Poll::Ready(None);
1960        }
1961        if this.is_terminated {
1962            panic!("polled AudioRequestStream after completion");
1963        }
1964        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1965            |bytes, handles| {
1966                match this.inner.channel().read_etc(cx, bytes, handles) {
1967                    std::task::Poll::Ready(Ok(())) => {}
1968                    std::task::Poll::Pending => return std::task::Poll::Pending,
1969                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1970                        this.is_terminated = true;
1971                        return std::task::Poll::Ready(None);
1972                    }
1973                    std::task::Poll::Ready(Err(e)) => {
1974                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1975                            e.into(),
1976                        ))));
1977                    }
1978                }
1979
1980                // A message has been received from the channel
1981                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1982
1983                std::task::Poll::Ready(Some(match header.ordinal {
1984                    0x572f413566fd58f1 => {
1985                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1986                        let mut req = fidl::new_empty!(
1987                            AudioCreateAudioRendererRequest,
1988                            fidl::encoding::DefaultFuchsiaResourceDialect
1989                        );
1990                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
1991                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
1992                        Ok(AudioRequest::CreateAudioRenderer {
1993                            audio_renderer_request: req.audio_renderer_request,
1994
1995                            control_handle,
1996                        })
1997                    }
1998                    0x44660fc63a6202f => {
1999                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2000                        let mut req = fidl::new_empty!(
2001                            AudioCreateAudioCapturerRequest,
2002                            fidl::encoding::DefaultFuchsiaResourceDialect
2003                        );
2004                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
2005                        let control_handle = AudioControlHandle { inner: this.inner.clone() };
2006                        Ok(AudioRequest::CreateAudioCapturer {
2007                            audio_capturer_request: req.audio_capturer_request,
2008                            loopback: req.loopback,
2009
2010                            control_handle,
2011                        })
2012                    }
2013                    _ => Err(fidl::Error::UnknownOrdinal {
2014                        ordinal: header.ordinal,
2015                        protocol_name: <AudioMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2016                    }),
2017                }))
2018            },
2019        )
2020    }
2021}
2022
2023#[derive(Debug)]
2024pub enum AudioRequest {
2025    CreateAudioRenderer {
2026        audio_renderer_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
2027        control_handle: AudioControlHandle,
2028    },
2029    /// Creates an AudioCapturer which either captures from the current default
2030    /// audio input device, or loops-back from the current default audio output
2031    /// device based on value passed for the loopback flag.
2032    CreateAudioCapturer {
2033        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
2034        loopback: bool,
2035        control_handle: AudioControlHandle,
2036    },
2037}
2038
2039impl AudioRequest {
2040    #[allow(irrefutable_let_patterns)]
2041    pub fn into_create_audio_renderer(
2042        self,
2043    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioControlHandle)> {
2044        if let AudioRequest::CreateAudioRenderer { audio_renderer_request, control_handle } = self {
2045            Some((audio_renderer_request, control_handle))
2046        } else {
2047            None
2048        }
2049    }
2050
2051    #[allow(irrefutable_let_patterns)]
2052    pub fn into_create_audio_capturer(
2053        self,
2054    ) -> Option<(fidl::endpoints::ServerEnd<AudioCapturerMarker>, bool, AudioControlHandle)> {
2055        if let AudioRequest::CreateAudioCapturer {
2056            audio_capturer_request,
2057            loopback,
2058            control_handle,
2059        } = self
2060        {
2061            Some((audio_capturer_request, loopback, control_handle))
2062        } else {
2063            None
2064        }
2065    }
2066
2067    /// Name of the method defined in FIDL
2068    pub fn method_name(&self) -> &'static str {
2069        match *self {
2070            AudioRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
2071            AudioRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
2072        }
2073    }
2074}
2075
2076#[derive(Debug, Clone)]
2077pub struct AudioControlHandle {
2078    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2079}
2080
2081impl AudioControlHandle {
2082    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2083        self.inner.shutdown_with_epitaph(status.into())
2084    }
2085}
2086
2087impl fidl::endpoints::ControlHandle for AudioControlHandle {
2088    fn shutdown(&self) {
2089        self.inner.shutdown()
2090    }
2091
2092    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2093        self.inner.shutdown_with_epitaph(status)
2094    }
2095
2096    fn is_closed(&self) -> bool {
2097        self.inner.channel().is_closed()
2098    }
2099    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2100        self.inner.channel().on_closed()
2101    }
2102
2103    #[cfg(target_os = "fuchsia")]
2104    fn signal_peer(
2105        &self,
2106        clear_mask: zx::Signals,
2107        set_mask: zx::Signals,
2108    ) -> Result<(), zx_status::Status> {
2109        use fidl::Peered;
2110        self.inner.channel().signal_peer(clear_mask, set_mask)
2111    }
2112}
2113
2114impl AudioControlHandle {}
2115
2116#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2117pub struct AudioCapturerMarker;
2118
2119impl fidl::endpoints::ProtocolMarker for AudioCapturerMarker {
2120    type Proxy = AudioCapturerProxy;
2121    type RequestStream = AudioCapturerRequestStream;
2122    #[cfg(target_os = "fuchsia")]
2123    type SynchronousProxy = AudioCapturerSynchronousProxy;
2124
2125    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCapturer";
2126}
2127impl fidl::endpoints::DiscoverableProtocolMarker for AudioCapturerMarker {}
2128
2129pub trait AudioCapturerProxyInterface: Send + Sync {
2130    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
2131    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
2132    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
2133    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2134    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
2135    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
2136    fn r#set_pcm_stream_type(&self, stream_type: &AudioStreamType) -> Result<(), fidl::Error>;
2137    type CaptureAtResponseFut: std::future::Future<Output = Result<StreamPacket, fidl::Error>>
2138        + Send;
2139    fn r#capture_at(
2140        &self,
2141        payload_buffer_id: u32,
2142        payload_offset: u32,
2143        frames: u32,
2144    ) -> Self::CaptureAtResponseFut;
2145    fn r#start_async_capture(&self, frames_per_packet: u32) -> Result<(), fidl::Error>;
2146    type StopAsyncCaptureResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2147    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut;
2148    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error>;
2149    fn r#bind_gain_control(
2150        &self,
2151        gain_control_request: fidl::endpoints::ServerEnd<
2152            fidl_fuchsia_media_audio::GainControlMarker,
2153        >,
2154    ) -> Result<(), fidl::Error>;
2155    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
2156        + Send;
2157    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
2158    fn r#set_reference_clock(
2159        &self,
2160        reference_clock: Option<fidl::Clock>,
2161    ) -> Result<(), fidl::Error>;
2162    fn r#set_usage(&self, usage: AudioCaptureUsage) -> Result<(), fidl::Error>;
2163    fn r#set_usage2(&self, usage: AudioCaptureUsage2) -> Result<(), fidl::Error>;
2164    type GetStreamTypeResponseFut: std::future::Future<Output = Result<StreamType, fidl::Error>>
2165        + Send;
2166    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut;
2167}
2168#[derive(Debug)]
2169#[cfg(target_os = "fuchsia")]
2170pub struct AudioCapturerSynchronousProxy {
2171    client: fidl::client::sync::Client,
2172}
2173
2174#[cfg(target_os = "fuchsia")]
2175impl fidl::endpoints::SynchronousProxy for AudioCapturerSynchronousProxy {
2176    type Proxy = AudioCapturerProxy;
2177    type Protocol = AudioCapturerMarker;
2178
2179    fn from_channel(inner: fidl::Channel) -> Self {
2180        Self::new(inner)
2181    }
2182
2183    fn into_channel(self) -> fidl::Channel {
2184        self.client.into_channel()
2185    }
2186
2187    fn as_channel(&self) -> &fidl::Channel {
2188        self.client.as_channel()
2189    }
2190}
2191
2192#[cfg(target_os = "fuchsia")]
2193impl AudioCapturerSynchronousProxy {
2194    pub fn new(channel: fidl::Channel) -> Self {
2195        Self { client: fidl::client::sync::Client::new(channel) }
2196    }
2197
2198    pub fn into_channel(self) -> fidl::Channel {
2199        self.client.into_channel()
2200    }
2201
2202    /// Waits until an event arrives and returns it. It is safe for other
2203    /// threads to make concurrent requests while waiting for an event.
2204    pub fn wait_for_event(
2205        &self,
2206        deadline: zx::MonotonicInstant,
2207    ) -> Result<AudioCapturerEvent, fidl::Error> {
2208        AudioCapturerEvent::decode(self.client.wait_for_event::<AudioCapturerMarker>(deadline)?)
2209    }
2210
2211    /// Adds a payload buffer to the current buffer set associated with the
2212    /// connection. A `StreamPacket` struct reference a payload buffer in the
2213    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2214    ///
2215    /// A buffer with ID `id` must not be in the current set when this method is
2216    /// invoked, otherwise the service will close the connection.
2217    pub fn r#add_payload_buffer(
2218        &self,
2219        mut id: u32,
2220        mut payload_buffer: fidl::Vmo,
2221    ) -> Result<(), fidl::Error> {
2222        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2223            (id, payload_buffer),
2224            0x3b3a37fc34fe5b56,
2225            fidl::encoding::DynamicFlags::empty(),
2226        )
2227    }
2228
2229    /// Removes a payload buffer from the current buffer set associated with the
2230    /// connection.
2231    ///
2232    /// A buffer with ID `id` must exist in the current set when this method is
2233    /// invoked, otherwise the service will will close the connection.
2234    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2235        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2236            (id,),
2237            0x5d1e4f74c3658262,
2238            fidl::encoding::DynamicFlags::empty(),
2239        )
2240    }
2241
2242    /// Releases payload memory associated with a packet previously delivered
2243    /// via `OnPacketProduced`.
2244    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2245        self.client.send::<StreamSourceReleasePacketRequest>(
2246            (packet,),
2247            0x7a7b57f0f7d9e4bb,
2248            fidl::encoding::DynamicFlags::empty(),
2249        )
2250    }
2251
2252    pub fn r#discard_all_packets(
2253        &self,
2254        ___deadline: zx::MonotonicInstant,
2255    ) -> Result<(), fidl::Error> {
2256        let _response = self.client.send_query::<
2257            fidl::encoding::EmptyPayload,
2258            fidl::encoding::EmptyPayload,
2259            AudioCapturerMarker,
2260        >(
2261            (),
2262            0x27afd605e97b09d2,
2263            fidl::encoding::DynamicFlags::empty(),
2264            ___deadline,
2265        )?;
2266        Ok(_response)
2267    }
2268
2269    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2270        self.client.send::<fidl::encoding::EmptyPayload>(
2271            (),
2272            0x35f9d721e905b831,
2273            fidl::encoding::DynamicFlags::empty(),
2274        )
2275    }
2276
2277    /// Sets the stream type of the stream to be delivered. Causes the source
2278    /// material to be reformatted/resampled if needed in order to produce the
2279    /// requested stream type. Must be called before the payload buffer is
2280    /// established.
2281    pub fn r#set_pcm_stream_type(
2282        &self,
2283        mut stream_type: &AudioStreamType,
2284    ) -> Result<(), fidl::Error> {
2285        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2286            (stream_type,),
2287            0x1531ea9ea2c852cd,
2288            fidl::encoding::DynamicFlags::empty(),
2289        )
2290    }
2291
2292    /// Explicitly specifies a region of the shared payload buffer for the audio
2293    /// input to capture into.
2294    pub fn r#capture_at(
2295        &self,
2296        mut payload_buffer_id: u32,
2297        mut payload_offset: u32,
2298        mut frames: u32,
2299        ___deadline: zx::MonotonicInstant,
2300    ) -> Result<StreamPacket, fidl::Error> {
2301        let _response = self.client.send_query::<
2302            AudioCapturerCaptureAtRequest,
2303            AudioCapturerCaptureAtResponse,
2304            AudioCapturerMarker,
2305        >(
2306            (payload_buffer_id, payload_offset, frames,),
2307            0x784e25df72cea780,
2308            fidl::encoding::DynamicFlags::empty(),
2309            ___deadline,
2310        )?;
2311        Ok(_response.captured_packet)
2312    }
2313
2314    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2315    /// packets of exactly 'frames_per_packet' number of frames each. The
2316    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2317    /// of produced packets.
2318    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2319        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2320            (frames_per_packet,),
2321            0x7768adbb1ccfd7a6,
2322            fidl::encoding::DynamicFlags::empty(),
2323        )
2324    }
2325
2326    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2327    /// that may be used by the client if explicit synchronization is needed.
2328    pub fn r#stop_async_capture(
2329        &self,
2330        ___deadline: zx::MonotonicInstant,
2331    ) -> Result<(), fidl::Error> {
2332        let _response = self.client.send_query::<
2333            fidl::encoding::EmptyPayload,
2334            fidl::encoding::EmptyPayload,
2335            AudioCapturerMarker,
2336        >(
2337            (),
2338            0x5bfc8790a8cef8cb,
2339            fidl::encoding::DynamicFlags::empty(),
2340            ___deadline,
2341        )?;
2342        Ok(_response)
2343    }
2344
2345    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2346        self.client.send::<fidl::encoding::EmptyPayload>(
2347            (),
2348            0x33223cb2962c95e3,
2349            fidl::encoding::DynamicFlags::empty(),
2350        )
2351    }
2352
2353    /// Binds to the gain control for this AudioCapturer.
2354    pub fn r#bind_gain_control(
2355        &self,
2356        mut gain_control_request: fidl::endpoints::ServerEnd<
2357            fidl_fuchsia_media_audio::GainControlMarker,
2358        >,
2359    ) -> Result<(), fidl::Error> {
2360        self.client.send::<AudioCapturerBindGainControlRequest>(
2361            (gain_control_request,),
2362            0x658a6a17ddb3a8e0,
2363            fidl::encoding::DynamicFlags::empty(),
2364        )
2365    }
2366
2367    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2368    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2369    pub fn r#get_reference_clock(
2370        &self,
2371        ___deadline: zx::MonotonicInstant,
2372    ) -> Result<fidl::Clock, fidl::Error> {
2373        let _response = self.client.send_query::<
2374            fidl::encoding::EmptyPayload,
2375            AudioCapturerGetReferenceClockResponse,
2376            AudioCapturerMarker,
2377        >(
2378            (),
2379            0x50d037aa5a4b4d71,
2380            fidl::encoding::DynamicFlags::empty(),
2381            ___deadline,
2382        )?;
2383        Ok(_response.reference_clock)
2384    }
2385
2386    /// Sets the reference clock that controls this capturer's playback rate. If the input
2387    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2388    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2389    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2390    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2391    ///
2392    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2393    /// added. It also cannot be called a second time (even before capture).
2394    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2395    /// diverge at some later time, they should create a clone of the monotonic clock, set
2396    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2397    pub fn r#set_reference_clock(
2398        &self,
2399        mut reference_clock: Option<fidl::Clock>,
2400    ) -> Result<(), fidl::Error> {
2401        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2402            (reference_clock,),
2403            0x732b2c496d521bcf,
2404            fidl::encoding::DynamicFlags::empty(),
2405        )
2406    }
2407
2408    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2409    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2410    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2411        self.client.send::<AudioCapturerSetUsageRequest>(
2412            (usage,),
2413            0x42a16f392bd21b25,
2414            fidl::encoding::DynamicFlags::empty(),
2415        )
2416    }
2417
2418    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2419    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2420    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2421        self.client.send::<AudioCapturerSetUsage2Request>(
2422            (usage,),
2423            0x7a73e251b8d2382b,
2424            fidl::encoding::DynamicFlags::FLEXIBLE,
2425        )
2426    }
2427
2428    /// Gets the currently configured stream type. Note: for an AudioCapturer
2429    /// which was just created and has not yet had its stream type explicitly
2430    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2431    /// was created -- of the source (input or looped-back output) to which the
2432    /// AudioCapturer is bound. Even if this matches the client's desired format,
2433    /// `SetPcmStreamType` must still be called.
2434    pub fn r#get_stream_type(
2435        &self,
2436        ___deadline: zx::MonotonicInstant,
2437    ) -> Result<StreamType, fidl::Error> {
2438        let _response = self.client.send_query::<
2439            fidl::encoding::EmptyPayload,
2440            AudioCapturerGetStreamTypeResponse,
2441            AudioCapturerMarker,
2442        >(
2443            (),
2444            0x5dcaaa670b433088,
2445            fidl::encoding::DynamicFlags::empty(),
2446            ___deadline,
2447        )?;
2448        Ok(_response.stream_type)
2449    }
2450}
2451
2452#[cfg(target_os = "fuchsia")]
2453impl From<AudioCapturerSynchronousProxy> for zx::NullableHandle {
2454    fn from(value: AudioCapturerSynchronousProxy) -> Self {
2455        value.into_channel().into()
2456    }
2457}
2458
2459#[cfg(target_os = "fuchsia")]
2460impl From<fidl::Channel> for AudioCapturerSynchronousProxy {
2461    fn from(value: fidl::Channel) -> Self {
2462        Self::new(value)
2463    }
2464}
2465
2466#[cfg(target_os = "fuchsia")]
2467impl fidl::endpoints::FromClient for AudioCapturerSynchronousProxy {
2468    type Protocol = AudioCapturerMarker;
2469
2470    fn from_client(value: fidl::endpoints::ClientEnd<AudioCapturerMarker>) -> Self {
2471        Self::new(value.into_channel())
2472    }
2473}
2474
2475#[derive(Debug, Clone)]
2476pub struct AudioCapturerProxy {
2477    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2478}
2479
2480impl fidl::endpoints::Proxy for AudioCapturerProxy {
2481    type Protocol = AudioCapturerMarker;
2482
2483    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2484        Self::new(inner)
2485    }
2486
2487    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2488        self.client.into_channel().map_err(|client| Self { client })
2489    }
2490
2491    fn as_channel(&self) -> &::fidl::AsyncChannel {
2492        self.client.as_channel()
2493    }
2494}
2495
2496impl AudioCapturerProxy {
2497    /// Create a new Proxy for fuchsia.media/AudioCapturer.
2498    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2499        let protocol_name = <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2500        Self { client: fidl::client::Client::new(channel, protocol_name) }
2501    }
2502
2503    /// Get a Stream of events from the remote end of the protocol.
2504    ///
2505    /// # Panics
2506    ///
2507    /// Panics if the event stream was already taken.
2508    pub fn take_event_stream(&self) -> AudioCapturerEventStream {
2509        AudioCapturerEventStream { event_receiver: self.client.take_event_receiver() }
2510    }
2511
2512    /// Adds a payload buffer to the current buffer set associated with the
2513    /// connection. A `StreamPacket` struct reference a payload buffer in the
2514    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
2515    ///
2516    /// A buffer with ID `id` must not be in the current set when this method is
2517    /// invoked, otherwise the service will close the connection.
2518    pub fn r#add_payload_buffer(
2519        &self,
2520        mut id: u32,
2521        mut payload_buffer: fidl::Vmo,
2522    ) -> Result<(), fidl::Error> {
2523        AudioCapturerProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
2524    }
2525
2526    /// Removes a payload buffer from the current buffer set associated with the
2527    /// connection.
2528    ///
2529    /// A buffer with ID `id` must exist in the current set when this method is
2530    /// invoked, otherwise the service will will close the connection.
2531    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2532        AudioCapturerProxyInterface::r#remove_payload_buffer(self, id)
2533    }
2534
2535    /// Releases payload memory associated with a packet previously delivered
2536    /// via `OnPacketProduced`.
2537    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2538        AudioCapturerProxyInterface::r#release_packet(self, packet)
2539    }
2540
2541    pub fn r#discard_all_packets(
2542        &self,
2543    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2544        AudioCapturerProxyInterface::r#discard_all_packets(self)
2545    }
2546
2547    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2548        AudioCapturerProxyInterface::r#discard_all_packets_no_reply(self)
2549    }
2550
2551    /// Sets the stream type of the stream to be delivered. Causes the source
2552    /// material to be reformatted/resampled if needed in order to produce the
2553    /// requested stream type. Must be called before the payload buffer is
2554    /// established.
2555    pub fn r#set_pcm_stream_type(
2556        &self,
2557        mut stream_type: &AudioStreamType,
2558    ) -> Result<(), fidl::Error> {
2559        AudioCapturerProxyInterface::r#set_pcm_stream_type(self, stream_type)
2560    }
2561
2562    /// Explicitly specifies a region of the shared payload buffer for the audio
2563    /// input to capture into.
2564    pub fn r#capture_at(
2565        &self,
2566        mut payload_buffer_id: u32,
2567        mut payload_offset: u32,
2568        mut frames: u32,
2569    ) -> fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>
2570    {
2571        AudioCapturerProxyInterface::r#capture_at(self, payload_buffer_id, payload_offset, frames)
2572    }
2573
2574    /// Places the AudioCapturer into 'async' capture mode and begin to produce
2575    /// packets of exactly 'frames_per_packet' number of frames each. The
2576    /// OnPacketProduced event (of StreamSink) will be used to inform the client
2577    /// of produced packets.
2578    pub fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2579        AudioCapturerProxyInterface::r#start_async_capture(self, frames_per_packet)
2580    }
2581
2582    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
2583    /// that may be used by the client if explicit synchronization is needed.
2584    pub fn r#stop_async_capture(
2585        &self,
2586    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2587        AudioCapturerProxyInterface::r#stop_async_capture(self)
2588    }
2589
2590    pub fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2591        AudioCapturerProxyInterface::r#stop_async_capture_no_reply(self)
2592    }
2593
2594    /// Binds to the gain control for this AudioCapturer.
2595    pub fn r#bind_gain_control(
2596        &self,
2597        mut gain_control_request: fidl::endpoints::ServerEnd<
2598            fidl_fuchsia_media_audio::GainControlMarker,
2599        >,
2600    ) -> Result<(), fidl::Error> {
2601        AudioCapturerProxyInterface::r#bind_gain_control(self, gain_control_request)
2602    }
2603
2604    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
2605    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
2606    pub fn r#get_reference_clock(
2607        &self,
2608    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
2609    {
2610        AudioCapturerProxyInterface::r#get_reference_clock(self)
2611    }
2612
2613    /// Sets the reference clock that controls this capturer's playback rate. If the input
2614    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
2615    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
2616    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
2617    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
2618    ///
2619    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
2620    /// added. It also cannot be called a second time (even before capture).
2621    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
2622    /// diverge at some later time, they should create a clone of the monotonic clock, set
2623    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
2624    pub fn r#set_reference_clock(
2625        &self,
2626        mut reference_clock: Option<fidl::Clock>,
2627    ) -> Result<(), fidl::Error> {
2628        AudioCapturerProxyInterface::r#set_reference_clock(self, reference_clock)
2629    }
2630
2631    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
2632    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
2633    pub fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2634        AudioCapturerProxyInterface::r#set_usage(self, usage)
2635    }
2636
2637    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
2638    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
2639    pub fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2640        AudioCapturerProxyInterface::r#set_usage2(self, usage)
2641    }
2642
2643    /// Gets the currently configured stream type. Note: for an AudioCapturer
2644    /// which was just created and has not yet had its stream type explicitly
2645    /// set, this will retrieve the stream type -- at the time the AudioCapturer
2646    /// was created -- of the source (input or looped-back output) to which the
2647    /// AudioCapturer is bound. Even if this matches the client's desired format,
2648    /// `SetPcmStreamType` must still be called.
2649    pub fn r#get_stream_type(
2650        &self,
2651    ) -> fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>
2652    {
2653        AudioCapturerProxyInterface::r#get_stream_type(self)
2654    }
2655}
2656
2657impl AudioCapturerProxyInterface for AudioCapturerProxy {
2658    fn r#add_payload_buffer(
2659        &self,
2660        mut id: u32,
2661        mut payload_buffer: fidl::Vmo,
2662    ) -> Result<(), fidl::Error> {
2663        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
2664            (id, payload_buffer),
2665            0x3b3a37fc34fe5b56,
2666            fidl::encoding::DynamicFlags::empty(),
2667        )
2668    }
2669
2670    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
2671        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
2672            (id,),
2673            0x5d1e4f74c3658262,
2674            fidl::encoding::DynamicFlags::empty(),
2675        )
2676    }
2677
2678    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
2679        self.client.send::<StreamSourceReleasePacketRequest>(
2680            (packet,),
2681            0x7a7b57f0f7d9e4bb,
2682            fidl::encoding::DynamicFlags::empty(),
2683        )
2684    }
2685
2686    type DiscardAllPacketsResponseFut =
2687        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2688    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
2689        fn _decode(
2690            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2691        ) -> Result<(), fidl::Error> {
2692            let _response = fidl::client::decode_transaction_body::<
2693                fidl::encoding::EmptyPayload,
2694                fidl::encoding::DefaultFuchsiaResourceDialect,
2695                0x27afd605e97b09d2,
2696            >(_buf?)?;
2697            Ok(_response)
2698        }
2699        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2700            (),
2701            0x27afd605e97b09d2,
2702            fidl::encoding::DynamicFlags::empty(),
2703            _decode,
2704        )
2705    }
2706
2707    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
2708        self.client.send::<fidl::encoding::EmptyPayload>(
2709            (),
2710            0x35f9d721e905b831,
2711            fidl::encoding::DynamicFlags::empty(),
2712        )
2713    }
2714
2715    fn r#set_pcm_stream_type(&self, mut stream_type: &AudioStreamType) -> Result<(), fidl::Error> {
2716        self.client.send::<AudioCapturerSetPcmStreamTypeRequest>(
2717            (stream_type,),
2718            0x1531ea9ea2c852cd,
2719            fidl::encoding::DynamicFlags::empty(),
2720        )
2721    }
2722
2723    type CaptureAtResponseFut =
2724        fidl::client::QueryResponseFut<StreamPacket, fidl::encoding::DefaultFuchsiaResourceDialect>;
2725    fn r#capture_at(
2726        &self,
2727        mut payload_buffer_id: u32,
2728        mut payload_offset: u32,
2729        mut frames: u32,
2730    ) -> Self::CaptureAtResponseFut {
2731        fn _decode(
2732            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2733        ) -> Result<StreamPacket, fidl::Error> {
2734            let _response = fidl::client::decode_transaction_body::<
2735                AudioCapturerCaptureAtResponse,
2736                fidl::encoding::DefaultFuchsiaResourceDialect,
2737                0x784e25df72cea780,
2738            >(_buf?)?;
2739            Ok(_response.captured_packet)
2740        }
2741        self.client.send_query_and_decode::<AudioCapturerCaptureAtRequest, StreamPacket>(
2742            (payload_buffer_id, payload_offset, frames),
2743            0x784e25df72cea780,
2744            fidl::encoding::DynamicFlags::empty(),
2745            _decode,
2746        )
2747    }
2748
2749    fn r#start_async_capture(&self, mut frames_per_packet: u32) -> Result<(), fidl::Error> {
2750        self.client.send::<AudioCapturerStartAsyncCaptureRequest>(
2751            (frames_per_packet,),
2752            0x7768adbb1ccfd7a6,
2753            fidl::encoding::DynamicFlags::empty(),
2754        )
2755    }
2756
2757    type StopAsyncCaptureResponseFut =
2758        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2759    fn r#stop_async_capture(&self) -> Self::StopAsyncCaptureResponseFut {
2760        fn _decode(
2761            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2762        ) -> Result<(), fidl::Error> {
2763            let _response = fidl::client::decode_transaction_body::<
2764                fidl::encoding::EmptyPayload,
2765                fidl::encoding::DefaultFuchsiaResourceDialect,
2766                0x5bfc8790a8cef8cb,
2767            >(_buf?)?;
2768            Ok(_response)
2769        }
2770        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2771            (),
2772            0x5bfc8790a8cef8cb,
2773            fidl::encoding::DynamicFlags::empty(),
2774            _decode,
2775        )
2776    }
2777
2778    fn r#stop_async_capture_no_reply(&self) -> Result<(), fidl::Error> {
2779        self.client.send::<fidl::encoding::EmptyPayload>(
2780            (),
2781            0x33223cb2962c95e3,
2782            fidl::encoding::DynamicFlags::empty(),
2783        )
2784    }
2785
2786    fn r#bind_gain_control(
2787        &self,
2788        mut gain_control_request: fidl::endpoints::ServerEnd<
2789            fidl_fuchsia_media_audio::GainControlMarker,
2790        >,
2791    ) -> Result<(), fidl::Error> {
2792        self.client.send::<AudioCapturerBindGainControlRequest>(
2793            (gain_control_request,),
2794            0x658a6a17ddb3a8e0,
2795            fidl::encoding::DynamicFlags::empty(),
2796        )
2797    }
2798
2799    type GetReferenceClockResponseFut =
2800        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
2801    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
2802        fn _decode(
2803            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2804        ) -> Result<fidl::Clock, fidl::Error> {
2805            let _response = fidl::client::decode_transaction_body::<
2806                AudioCapturerGetReferenceClockResponse,
2807                fidl::encoding::DefaultFuchsiaResourceDialect,
2808                0x50d037aa5a4b4d71,
2809            >(_buf?)?;
2810            Ok(_response.reference_clock)
2811        }
2812        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
2813            (),
2814            0x50d037aa5a4b4d71,
2815            fidl::encoding::DynamicFlags::empty(),
2816            _decode,
2817        )
2818    }
2819
2820    fn r#set_reference_clock(
2821        &self,
2822        mut reference_clock: Option<fidl::Clock>,
2823    ) -> Result<(), fidl::Error> {
2824        self.client.send::<AudioCapturerSetReferenceClockRequest>(
2825            (reference_clock,),
2826            0x732b2c496d521bcf,
2827            fidl::encoding::DynamicFlags::empty(),
2828        )
2829    }
2830
2831    fn r#set_usage(&self, mut usage: AudioCaptureUsage) -> Result<(), fidl::Error> {
2832        self.client.send::<AudioCapturerSetUsageRequest>(
2833            (usage,),
2834            0x42a16f392bd21b25,
2835            fidl::encoding::DynamicFlags::empty(),
2836        )
2837    }
2838
2839    fn r#set_usage2(&self, mut usage: AudioCaptureUsage2) -> Result<(), fidl::Error> {
2840        self.client.send::<AudioCapturerSetUsage2Request>(
2841            (usage,),
2842            0x7a73e251b8d2382b,
2843            fidl::encoding::DynamicFlags::FLEXIBLE,
2844        )
2845    }
2846
2847    type GetStreamTypeResponseFut =
2848        fidl::client::QueryResponseFut<StreamType, fidl::encoding::DefaultFuchsiaResourceDialect>;
2849    fn r#get_stream_type(&self) -> Self::GetStreamTypeResponseFut {
2850        fn _decode(
2851            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2852        ) -> Result<StreamType, fidl::Error> {
2853            let _response = fidl::client::decode_transaction_body::<
2854                AudioCapturerGetStreamTypeResponse,
2855                fidl::encoding::DefaultFuchsiaResourceDialect,
2856                0x5dcaaa670b433088,
2857            >(_buf?)?;
2858            Ok(_response.stream_type)
2859        }
2860        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, StreamType>(
2861            (),
2862            0x5dcaaa670b433088,
2863            fidl::encoding::DynamicFlags::empty(),
2864            _decode,
2865        )
2866    }
2867}
2868
2869pub struct AudioCapturerEventStream {
2870    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2871}
2872
2873impl std::marker::Unpin for AudioCapturerEventStream {}
2874
2875impl futures::stream::FusedStream for AudioCapturerEventStream {
2876    fn is_terminated(&self) -> bool {
2877        self.event_receiver.is_terminated()
2878    }
2879}
2880
2881impl futures::Stream for AudioCapturerEventStream {
2882    type Item = Result<AudioCapturerEvent, fidl::Error>;
2883
2884    fn poll_next(
2885        mut self: std::pin::Pin<&mut Self>,
2886        cx: &mut std::task::Context<'_>,
2887    ) -> std::task::Poll<Option<Self::Item>> {
2888        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2889            &mut self.event_receiver,
2890            cx
2891        )?) {
2892            Some(buf) => std::task::Poll::Ready(Some(AudioCapturerEvent::decode(buf))),
2893            None => std::task::Poll::Ready(None),
2894        }
2895    }
2896}
2897
2898#[derive(Debug)]
2899pub enum AudioCapturerEvent {
2900    OnPacketProduced {
2901        packet: StreamPacket,
2902    },
2903    OnEndOfStream {},
2904    #[non_exhaustive]
2905    _UnknownEvent {
2906        /// Ordinal of the event that was sent.
2907        ordinal: u64,
2908    },
2909}
2910
2911impl AudioCapturerEvent {
2912    #[allow(irrefutable_let_patterns)]
2913    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
2914        if let AudioCapturerEvent::OnPacketProduced { packet } = self {
2915            Some((packet))
2916        } else {
2917            None
2918        }
2919    }
2920    #[allow(irrefutable_let_patterns)]
2921    pub fn into_on_end_of_stream(self) -> Option<()> {
2922        if let AudioCapturerEvent::OnEndOfStream {} = self { Some(()) } else { None }
2923    }
2924
2925    /// Decodes a message buffer as a [`AudioCapturerEvent`].
2926    fn decode(
2927        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2928    ) -> Result<AudioCapturerEvent, fidl::Error> {
2929        let (bytes, _handles) = buf.split_mut();
2930        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2931        debug_assert_eq!(tx_header.tx_id, 0);
2932        match tx_header.ordinal {
2933            0x6bbe69746a3c8bd9 => {
2934                let mut out = fidl::new_empty!(
2935                    StreamSourceOnPacketProducedRequest,
2936                    fidl::encoding::DefaultFuchsiaResourceDialect
2937                );
2938                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2939                Ok((AudioCapturerEvent::OnPacketProduced { packet: out.packet }))
2940            }
2941            0x550e69b41d03e2c2 => {
2942                let mut out = fidl::new_empty!(
2943                    fidl::encoding::EmptyPayload,
2944                    fidl::encoding::DefaultFuchsiaResourceDialect
2945                );
2946                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
2947                Ok((AudioCapturerEvent::OnEndOfStream {}))
2948            }
2949            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2950                Ok(AudioCapturerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2951            }
2952            _ => Err(fidl::Error::UnknownOrdinal {
2953                ordinal: tx_header.ordinal,
2954                protocol_name: <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2955            }),
2956        }
2957    }
2958}
2959
2960/// A Stream of incoming requests for fuchsia.media/AudioCapturer.
2961pub struct AudioCapturerRequestStream {
2962    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2963    is_terminated: bool,
2964}
2965
2966impl std::marker::Unpin for AudioCapturerRequestStream {}
2967
2968impl futures::stream::FusedStream for AudioCapturerRequestStream {
2969    fn is_terminated(&self) -> bool {
2970        self.is_terminated
2971    }
2972}
2973
2974impl fidl::endpoints::RequestStream for AudioCapturerRequestStream {
2975    type Protocol = AudioCapturerMarker;
2976    type ControlHandle = AudioCapturerControlHandle;
2977
2978    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2979        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2980    }
2981
2982    fn control_handle(&self) -> Self::ControlHandle {
2983        AudioCapturerControlHandle { inner: self.inner.clone() }
2984    }
2985
2986    fn into_inner(
2987        self,
2988    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2989    {
2990        (self.inner, self.is_terminated)
2991    }
2992
2993    fn from_inner(
2994        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2995        is_terminated: bool,
2996    ) -> Self {
2997        Self { inner, is_terminated }
2998    }
2999}
3000
3001impl futures::Stream for AudioCapturerRequestStream {
3002    type Item = Result<AudioCapturerRequest, fidl::Error>;
3003
3004    fn poll_next(
3005        mut self: std::pin::Pin<&mut Self>,
3006        cx: &mut std::task::Context<'_>,
3007    ) -> std::task::Poll<Option<Self::Item>> {
3008        let this = &mut *self;
3009        if this.inner.check_shutdown(cx) {
3010            this.is_terminated = true;
3011            return std::task::Poll::Ready(None);
3012        }
3013        if this.is_terminated {
3014            panic!("polled AudioCapturerRequestStream after completion");
3015        }
3016        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3017            |bytes, handles| {
3018                match this.inner.channel().read_etc(cx, bytes, handles) {
3019                    std::task::Poll::Ready(Ok(())) => {}
3020                    std::task::Poll::Pending => return std::task::Poll::Pending,
3021                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3022                        this.is_terminated = true;
3023                        return std::task::Poll::Ready(None);
3024                    }
3025                    std::task::Poll::Ready(Err(e)) => {
3026                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3027                            e.into(),
3028                        ))));
3029                    }
3030                }
3031
3032                // A message has been received from the channel
3033                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3034
3035                std::task::Poll::Ready(Some(match header.ordinal {
3036                    0x3b3a37fc34fe5b56 => {
3037                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3038                        let mut req = fidl::new_empty!(
3039                            StreamBufferSetAddPayloadBufferRequest,
3040                            fidl::encoding::DefaultFuchsiaResourceDialect
3041                        );
3042                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
3043                        let control_handle =
3044                            AudioCapturerControlHandle { inner: this.inner.clone() };
3045                        Ok(AudioCapturerRequest::AddPayloadBuffer {
3046                            id: req.id,
3047                            payload_buffer: req.payload_buffer,
3048
3049                            control_handle,
3050                        })
3051                    }
3052                    0x5d1e4f74c3658262 => {
3053                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3054                        let mut req = fidl::new_empty!(
3055                            StreamBufferSetRemovePayloadBufferRequest,
3056                            fidl::encoding::DefaultFuchsiaResourceDialect
3057                        );
3058                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
3059                        let control_handle =
3060                            AudioCapturerControlHandle { inner: this.inner.clone() };
3061                        Ok(AudioCapturerRequest::RemovePayloadBuffer { id: req.id, control_handle })
3062                    }
3063                    0x7a7b57f0f7d9e4bb => {
3064                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3065                        let mut req = fidl::new_empty!(
3066                            StreamSourceReleasePacketRequest,
3067                            fidl::encoding::DefaultFuchsiaResourceDialect
3068                        );
3069                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
3070                        let control_handle =
3071                            AudioCapturerControlHandle { inner: this.inner.clone() };
3072                        Ok(AudioCapturerRequest::ReleasePacket {
3073                            packet: req.packet,
3074
3075                            control_handle,
3076                        })
3077                    }
3078                    0x27afd605e97b09d2 => {
3079                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3080                        let mut req = fidl::new_empty!(
3081                            fidl::encoding::EmptyPayload,
3082                            fidl::encoding::DefaultFuchsiaResourceDialect
3083                        );
3084                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3085                        let control_handle =
3086                            AudioCapturerControlHandle { inner: this.inner.clone() };
3087                        Ok(AudioCapturerRequest::DiscardAllPackets {
3088                            responder: AudioCapturerDiscardAllPacketsResponder {
3089                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3090                                tx_id: header.tx_id,
3091                            },
3092                        })
3093                    }
3094                    0x35f9d721e905b831 => {
3095                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3096                        let mut req = fidl::new_empty!(
3097                            fidl::encoding::EmptyPayload,
3098                            fidl::encoding::DefaultFuchsiaResourceDialect
3099                        );
3100                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3101                        let control_handle =
3102                            AudioCapturerControlHandle { inner: this.inner.clone() };
3103                        Ok(AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle })
3104                    }
3105                    0x1531ea9ea2c852cd => {
3106                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3107                        let mut req = fidl::new_empty!(
3108                            AudioCapturerSetPcmStreamTypeRequest,
3109                            fidl::encoding::DefaultFuchsiaResourceDialect
3110                        );
3111                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
3112                        let control_handle =
3113                            AudioCapturerControlHandle { inner: this.inner.clone() };
3114                        Ok(AudioCapturerRequest::SetPcmStreamType {
3115                            stream_type: req.stream_type,
3116
3117                            control_handle,
3118                        })
3119                    }
3120                    0x784e25df72cea780 => {
3121                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3122                        let mut req = fidl::new_empty!(
3123                            AudioCapturerCaptureAtRequest,
3124                            fidl::encoding::DefaultFuchsiaResourceDialect
3125                        );
3126                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerCaptureAtRequest>(&header, _body_bytes, handles, &mut req)?;
3127                        let control_handle =
3128                            AudioCapturerControlHandle { inner: this.inner.clone() };
3129                        Ok(AudioCapturerRequest::CaptureAt {
3130                            payload_buffer_id: req.payload_buffer_id,
3131                            payload_offset: req.payload_offset,
3132                            frames: req.frames,
3133
3134                            responder: AudioCapturerCaptureAtResponder {
3135                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3136                                tx_id: header.tx_id,
3137                            },
3138                        })
3139                    }
3140                    0x7768adbb1ccfd7a6 => {
3141                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3142                        let mut req = fidl::new_empty!(
3143                            AudioCapturerStartAsyncCaptureRequest,
3144                            fidl::encoding::DefaultFuchsiaResourceDialect
3145                        );
3146                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerStartAsyncCaptureRequest>(&header, _body_bytes, handles, &mut req)?;
3147                        let control_handle =
3148                            AudioCapturerControlHandle { inner: this.inner.clone() };
3149                        Ok(AudioCapturerRequest::StartAsyncCapture {
3150                            frames_per_packet: req.frames_per_packet,
3151
3152                            control_handle,
3153                        })
3154                    }
3155                    0x5bfc8790a8cef8cb => {
3156                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3157                        let mut req = fidl::new_empty!(
3158                            fidl::encoding::EmptyPayload,
3159                            fidl::encoding::DefaultFuchsiaResourceDialect
3160                        );
3161                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3162                        let control_handle =
3163                            AudioCapturerControlHandle { inner: this.inner.clone() };
3164                        Ok(AudioCapturerRequest::StopAsyncCapture {
3165                            responder: AudioCapturerStopAsyncCaptureResponder {
3166                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3167                                tx_id: header.tx_id,
3168                            },
3169                        })
3170                    }
3171                    0x33223cb2962c95e3 => {
3172                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3173                        let mut req = fidl::new_empty!(
3174                            fidl::encoding::EmptyPayload,
3175                            fidl::encoding::DefaultFuchsiaResourceDialect
3176                        );
3177                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3178                        let control_handle =
3179                            AudioCapturerControlHandle { inner: this.inner.clone() };
3180                        Ok(AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle })
3181                    }
3182                    0x658a6a17ddb3a8e0 => {
3183                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3184                        let mut req = fidl::new_empty!(
3185                            AudioCapturerBindGainControlRequest,
3186                            fidl::encoding::DefaultFuchsiaResourceDialect
3187                        );
3188                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
3189                        let control_handle =
3190                            AudioCapturerControlHandle { inner: this.inner.clone() };
3191                        Ok(AudioCapturerRequest::BindGainControl {
3192                            gain_control_request: req.gain_control_request,
3193
3194                            control_handle,
3195                        })
3196                    }
3197                    0x50d037aa5a4b4d71 => {
3198                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3199                        let mut req = fidl::new_empty!(
3200                            fidl::encoding::EmptyPayload,
3201                            fidl::encoding::DefaultFuchsiaResourceDialect
3202                        );
3203                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3204                        let control_handle =
3205                            AudioCapturerControlHandle { inner: this.inner.clone() };
3206                        Ok(AudioCapturerRequest::GetReferenceClock {
3207                            responder: AudioCapturerGetReferenceClockResponder {
3208                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3209                                tx_id: header.tx_id,
3210                            },
3211                        })
3212                    }
3213                    0x732b2c496d521bcf => {
3214                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3215                        let mut req = fidl::new_empty!(
3216                            AudioCapturerSetReferenceClockRequest,
3217                            fidl::encoding::DefaultFuchsiaResourceDialect
3218                        );
3219                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
3220                        let control_handle =
3221                            AudioCapturerControlHandle { inner: this.inner.clone() };
3222                        Ok(AudioCapturerRequest::SetReferenceClock {
3223                            reference_clock: req.reference_clock,
3224
3225                            control_handle,
3226                        })
3227                    }
3228                    0x42a16f392bd21b25 => {
3229                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3230                        let mut req = fidl::new_empty!(
3231                            AudioCapturerSetUsageRequest,
3232                            fidl::encoding::DefaultFuchsiaResourceDialect
3233                        );
3234                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
3235                        let control_handle =
3236                            AudioCapturerControlHandle { inner: this.inner.clone() };
3237                        Ok(AudioCapturerRequest::SetUsage { usage: req.usage, control_handle })
3238                    }
3239                    0x7a73e251b8d2382b => {
3240                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3241                        let mut req = fidl::new_empty!(
3242                            AudioCapturerSetUsage2Request,
3243                            fidl::encoding::DefaultFuchsiaResourceDialect
3244                        );
3245                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCapturerSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
3246                        let control_handle =
3247                            AudioCapturerControlHandle { inner: this.inner.clone() };
3248                        Ok(AudioCapturerRequest::SetUsage2 { usage: req.usage, control_handle })
3249                    }
3250                    0x5dcaaa670b433088 => {
3251                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3252                        let mut req = fidl::new_empty!(
3253                            fidl::encoding::EmptyPayload,
3254                            fidl::encoding::DefaultFuchsiaResourceDialect
3255                        );
3256                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3257                        let control_handle =
3258                            AudioCapturerControlHandle { inner: this.inner.clone() };
3259                        Ok(AudioCapturerRequest::GetStreamType {
3260                            responder: AudioCapturerGetStreamTypeResponder {
3261                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3262                                tx_id: header.tx_id,
3263                            },
3264                        })
3265                    }
3266                    _ if header.tx_id == 0
3267                        && header
3268                            .dynamic_flags()
3269                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3270                    {
3271                        Ok(AudioCapturerRequest::_UnknownMethod {
3272                            ordinal: header.ordinal,
3273                            control_handle: AudioCapturerControlHandle {
3274                                inner: this.inner.clone(),
3275                            },
3276                            method_type: fidl::MethodType::OneWay,
3277                        })
3278                    }
3279                    _ if header
3280                        .dynamic_flags()
3281                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3282                    {
3283                        this.inner.send_framework_err(
3284                            fidl::encoding::FrameworkErr::UnknownMethod,
3285                            header.tx_id,
3286                            header.ordinal,
3287                            header.dynamic_flags(),
3288                            (bytes, handles),
3289                        )?;
3290                        Ok(AudioCapturerRequest::_UnknownMethod {
3291                            ordinal: header.ordinal,
3292                            control_handle: AudioCapturerControlHandle {
3293                                inner: this.inner.clone(),
3294                            },
3295                            method_type: fidl::MethodType::TwoWay,
3296                        })
3297                    }
3298                    _ => Err(fidl::Error::UnknownOrdinal {
3299                        ordinal: header.ordinal,
3300                        protocol_name:
3301                            <AudioCapturerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3302                    }),
3303                }))
3304            },
3305        )
3306    }
3307}
3308
3309/// AudioCapturer
3310///
3311/// An AudioCapturer is an interface returned from an fuchsia.media.Audio's
3312/// CreateAudioCapturer method, which may be used by clients to capture audio
3313/// from either the current default audio input device, or the current default
3314/// audio output device depending on the flags passed during creation.
3315///
3316/// **Format support**
3317///
3318/// See (Get|Set)StreamType below. By default, the captured stream type will be
3319/// initially determined by the currently configured stream type of the source
3320/// that the AudioCapturer was bound to at creation time. Users may either fetch
3321/// this type using GetStreamType, or they may choose to have the media
3322/// resampled or converted to a type of their choosing by calling SetStreamType.
3323/// Note: the stream type may only be set while the system is not running,
3324/// meaning that there are no pending capture regions (specified using CaptureAt)
3325/// and that the system is not currently running in 'async' capture mode.
3326///
3327/// **Buffers and memory management**
3328///
3329/// Audio data is captured into a shared memory buffer (a VMO) supplied by the
3330/// user to the AudioCapturer during the AddPayloadBuffer call. Please note the
3331/// following requirements related to the management of the payload buffer.
3332///
3333/// + The payload buffer must be supplied before any capture operation may
3334///   start. Any attempt to start capture (via either CaptureAt or
3335///   StartAsyncCapture) before a payload buffer has been established is an
3336///   error.
3337/// + The payload buffer may not be changed while there are any capture
3338///   operations pending.
3339/// + The stream type may not be changed after the payload buffer has been set.
3340/// + The payload buffer must be an integral number of audio frame sizes (in
3341///   bytes)
3342/// + When running in 'async' mode (see below), the payload buffer must be at
3343///   least as large as twice the frames_per_packet size specified during
3344///   StartAsyncCapture.
3345/// + The handle to the payload buffer supplied by the user must be readable,
3346///   writable, mappable and transferable.
3347/// + Users should always treat the payload buffer as read-only.
3348///
3349/// **Synchronous vs. Asynchronous capture mode**
3350///
3351/// The AudioCapturer interface can be used in one of two mutually exclusive
3352/// modes: Synchronous and Asynchronous. A description of each mode and their
3353/// tradeoffs is given below.
3354///
3355/// **Synchronous mode**
3356///
3357/// By default, AudioCapturer instances are running in 'sync' mode. They will
3358/// only capture data when a user supplies at least one region to capture into
3359/// using the CaptureAt method. Regions supplied in this way will be filled in
3360/// the order that they are received and returned to the client as StreamPackets
3361/// via the return value of the CaptureAt method. If an AudioCapturer instance
3362/// has data to capture, but no place to put it (because there are no more
3363/// pending regions to fill), the next payload generated will indicate that their
3364/// has been an overflow by setting the Discontinuity flag on the next produced
3365/// StreamPacket. Synchronous mode may not be used in conjunction with
3366/// Asynchronous mode. It is an error to attempt to call StartAsyncCapture while
3367/// the system still regions supplied by CaptureAt waiting to be filled.
3368///
3369/// If a user has supplied regions to be filled by the AudioCapturer instance in
3370/// the past, but wishes to reclaim those regions, they may do so using the
3371/// DiscardAllPackets method. Calling the DiscardAllPackets method will cause
3372/// all pending regions to be returned, but with `NO_TIMESTAMP` as their
3373/// StreamPacket's PTS. See "Timing and Overflows", below, for a discussion of
3374/// timestamps and discontinuity flags. After a DiscardAllPackets operation,
3375/// an OnEndOfStream event will be produced. While an AudioCapturer will never
3376/// overwrite any region of the payload buffer after a completed region is
3377/// returned, it may overwrite the unfilled portions of a partially filled
3378/// buffer which has been returned as a result of a DiscardAllPackets operation.
3379///
3380/// **Asynchronous mode**
3381///
3382/// While running in 'async' mode, clients do not need to explicitly supply
3383/// shared buffer regions to be filled by the AudioCapturer instance. Instead, a
3384/// client enters into 'async' mode by calling StartAsyncCapture and supplying a
3385/// callback interface and the number of frames to capture per-callback. Once
3386/// running in async mode, the AudioCapturer instance will identify which
3387/// payload buffer regions to capture into, capture the specified number of
3388/// frames, then deliver those frames as StreamPackets using the OnPacketCapture
3389/// FIDL event. Users may stop capturing and return the AudioCapturer instance to
3390/// 'sync' mode using the StopAsyncCapture method.
3391///
3392/// It is considered an error to attempt any of the following operations.
3393///
3394/// + To attempt to enter 'async' capture mode when no payload buffer has been
3395///   established.
3396/// + To specify a number of frames to capture per payload which does not permit
3397///   at least two contiguous capture payloads to exist in the established
3398///   shared payload buffer simultaneously.
3399/// + To send a region to capture into using the CaptureAt method while the
3400///   AudioCapturer instance is running in 'async' mode.
3401/// + To attempt to call DiscardAllPackets while the AudioCapturer instance is
3402///   running in 'async' mode.
3403/// + To attempt to re-start 'async' mode capturing without having first
3404///   stopped.
3405/// + To attempt any operation except for SetGain while in the process of
3406///   stopping.
3407///
3408/// **Synchronizing with a StopAsyncCapture operation**
3409///
3410/// Stopping asynchronous capture mode and returning to synchronous capture mode
3411/// is an operation which takes time. Aside from SetGain, users may not call any
3412/// other methods on the AudioCapturer interface after calling StopAsyncCapture
3413/// (including calling StopAsyncCapture again) until after the stop operation has
3414/// completed. Because of this, it is important for users to be able to
3415/// synchronize with the stop operation. Two mechanisms are provided for doing
3416/// so.
3417///
3418/// The first is to use StopAsyncCapture (not the NoReply variant). When the user's
3419/// callback has been called, they can be certain that stop operation is complete
3420/// and that the AudioCapturer instance has returned to synchronous operation
3421/// mode.
3422///
3423/// The second way to determine that a stop operation has completed is to use the
3424/// flags on the packets which get delivered via the user-supplied
3425/// AudioCapturerCallback interface after calling StopAsyncCapture. When
3426/// asked to stop, any partially filled packet will be returned to the user, and
3427/// the final packet returned will always have the end-of-stream flag (kFlagsEos)
3428/// set on it to indicate that this is the final frame in the sequence. If
3429/// there is no partially filled packet to return, the AudioCapturer will
3430/// synthesize an empty packet with no timestamp, and offset/length set to zero,
3431/// in order to deliver a packet with the end-of-stream flag set on it. Once
3432/// users have seen the end-of-stream flag after calling stop, the AudioCapturer
3433/// has finished the stop operation and returned to synchronous operating mode.
3434///
3435/// **Timing and Overflows**
3436///
3437/// All media packets produced by an AudioCapturer instance will have their PTS
3438/// field filled out with the capture time of the audio expressed as a timestamp
3439/// given by the reference clock timeline. Note: this timestamp is actually a
3440/// capture timestamp, not a presentation timestamp (it is more of a CTS than a
3441/// PTS) and is meant to represent the underlying system's best estimate of the
3442/// capture time of the first frame of audio, including all outboard and hardware
3443/// introduced buffering delay. As a result, all timestamps produced by an
3444/// AudioCapturer should be expected to be in the past relative to 'now' on the
3445/// stream's reference clock timeline.
3446///
3447/// The one exception to the "everything has an explicit timestamp" rule is when
3448/// discarding submitted regions while operating in synchronous mode. Discarded
3449/// packets have no data in them, but FIDL demands that all pending
3450/// method-return-value callbacks be executed. Because of this, the regions will
3451/// be returned to the user, but their timestamps will be set to
3452/// `NO_TIMESTAMP`, and their payload sizes will be set to zero. Any
3453/// partially filled payload will have a valid timestamp, but a payload size
3454/// smaller than originally requested. The final discarded payload (if there
3455/// were any to discard) will be followed by an OnEndOfStream event.
3456///
3457/// Two StreamPackets delivered by an AudioCapturer instance are 'continuous' if
3458/// the first frame of audio contained in the second packet was captured exactly
3459/// one nominal frame time after the final frame of audio in the first packet.
3460/// If this relationship does not hold, the second StreamPacket will have the
3461/// `STREAM_PACKET_FLAG_DISCONTINUITY` bit set in its `flags` field.
3462///
3463/// Even though explicit timestamps are provided on every StreamPacket produced,
3464/// users who have very precise timing requirements are encouraged to always
3465/// reason about time by counting frames delivered since the last discontinuity,
3466/// rather than simply using the raw capture timestamps. This is because the
3467/// explicit timestamps written on continuous packets may have a small amount of
3468/// rounding error based on whether or not the units of the capture timeline
3469/// reference clock are divisible by the chosen audio frame rate.
3470///
3471/// Users should always expect the first StreamPacket produced by an
3472/// AudioCapturer to have the discontinuous flag set on it (as there is no
3473/// previous packet to be continuous with). Similarly, the first StreamPacket
3474/// after a DiscardAllPackets or a Stop/Start cycle will always be
3475/// discontinuous. After that, there are only two reasons that a StreamPacket
3476/// will ever be discontinuous:
3477///
3478/// 1. The user is operating in synchronous mode and does not supply regions to
3479///    be filled quickly enough. If the next continuous frame of data has not
3480///    been captured by the time it needs to be purged from the source buffers,
3481///    an overflow has occurred and the AudioCapturer will flag the next captured
3482///    region as discontinuous.
3483/// 2. The user is operating in asynchronous mode and some internal error
3484///    prevents the AudioCapturer instance from capturing the next frame of audio
3485///    in a continuous fashion. This might be high system load or a hardware
3486///    error, but in general it is something which should never normally happen.
3487///    In practice, however, if it does, the next produced packet will be flagged
3488///    as being discontinuous.
3489///
3490/// **Synchronous vs. Asynchronous Trade-offs**
3491///
3492/// The choice of operating in synchronous vs. asynchronous mode is up to the
3493/// user, and depending on the user's requirements, there are some advantages and
3494/// disadvantages to each choice.
3495///
3496/// Synchronous mode requires only a single Zircon channel under the hood and can
3497/// achieve some small savings because of this. In addition, the user has
3498/// complete control over the buffer management. Users specify exactly where
3499/// audio will be captured to and in what order. Because of this, if users do
3500/// not need to always be capturing, it is simple to stop and restart the capture
3501/// later (just by ceasing to supply packets, then resuming later on). Payloads
3502/// do not need to be uniform in size either, clients may specify payloads of
3503/// whatever granularity is appropriate.
3504///
3505/// The primary downside of operating in synchronous mode is that two messages
3506/// will need to be sent for every packet to be captured. One to inform the
3507/// AudioCapturer of the instance to capture into, and one to inform the user
3508/// that the packet has been captured. This may end up increasing overhead and
3509/// potentially complicating client designs.
3510///
3511/// Asynchronous mode has the advantage requiring only 1/2 of the messages,
3512/// however, when operating in 'async' mode, AudioCapturer instances have no way
3513/// of knowing if a user is processing the StreamPackets being sent in a timely
3514/// fashion, and no way of automatically detecting an overflow condition. Users
3515/// of 'async' mode should be careful to use a buffer large enough to ensure that
3516/// they will be able to process their data before an AudioCapturer will be
3517/// forced to overwrite it.
3518#[derive(Debug)]
3519pub enum AudioCapturerRequest {
3520    /// Adds a payload buffer to the current buffer set associated with the
3521    /// connection. A `StreamPacket` struct reference a payload buffer in the
3522    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
3523    ///
3524    /// A buffer with ID `id` must not be in the current set when this method is
3525    /// invoked, otherwise the service will close the connection.
3526    AddPayloadBuffer {
3527        id: u32,
3528        payload_buffer: fidl::Vmo,
3529        control_handle: AudioCapturerControlHandle,
3530    },
3531    /// Removes a payload buffer from the current buffer set associated with the
3532    /// connection.
3533    ///
3534    /// A buffer with ID `id` must exist in the current set when this method is
3535    /// invoked, otherwise the service will will close the connection.
3536    RemovePayloadBuffer {
3537        id: u32,
3538        control_handle: AudioCapturerControlHandle,
3539    },
3540    /// Releases payload memory associated with a packet previously delivered
3541    /// via `OnPacketProduced`.
3542    ReleasePacket {
3543        packet: StreamPacket,
3544        control_handle: AudioCapturerControlHandle,
3545    },
3546    DiscardAllPackets {
3547        responder: AudioCapturerDiscardAllPacketsResponder,
3548    },
3549    DiscardAllPacketsNoReply {
3550        control_handle: AudioCapturerControlHandle,
3551    },
3552    /// Sets the stream type of the stream to be delivered. Causes the source
3553    /// material to be reformatted/resampled if needed in order to produce the
3554    /// requested stream type. Must be called before the payload buffer is
3555    /// established.
3556    SetPcmStreamType {
3557        stream_type: AudioStreamType,
3558        control_handle: AudioCapturerControlHandle,
3559    },
3560    /// Explicitly specifies a region of the shared payload buffer for the audio
3561    /// input to capture into.
3562    CaptureAt {
3563        payload_buffer_id: u32,
3564        payload_offset: u32,
3565        frames: u32,
3566        responder: AudioCapturerCaptureAtResponder,
3567    },
3568    /// Places the AudioCapturer into 'async' capture mode and begin to produce
3569    /// packets of exactly 'frames_per_packet' number of frames each. The
3570    /// OnPacketProduced event (of StreamSink) will be used to inform the client
3571    /// of produced packets.
3572    StartAsyncCapture {
3573        frames_per_packet: u32,
3574        control_handle: AudioCapturerControlHandle,
3575    },
3576    /// Stops capturing in 'async' capture mode and (optionally) deliver a callback
3577    /// that may be used by the client if explicit synchronization is needed.
3578    StopAsyncCapture {
3579        responder: AudioCapturerStopAsyncCaptureResponder,
3580    },
3581    StopAsyncCaptureNoReply {
3582        control_handle: AudioCapturerControlHandle,
3583    },
3584    /// Binds to the gain control for this AudioCapturer.
3585    BindGainControl {
3586        gain_control_request:
3587            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3588        control_handle: AudioCapturerControlHandle,
3589    },
3590    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
3591    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
3592    GetReferenceClock {
3593        responder: AudioCapturerGetReferenceClockResponder,
3594    },
3595    /// Sets the reference clock that controls this capturer's playback rate. If the input
3596    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
3597    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
3598    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
3599    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
3600    ///
3601    /// `SetReferenceClock` cannot be called after the capturer payload buffer has been
3602    /// added. It also cannot be called a second time (even before capture).
3603    /// If the client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
3604    /// diverge at some later time, they should create a clone of the monotonic clock, set
3605    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
3606    SetReferenceClock {
3607        reference_clock: Option<fidl::Clock>,
3608        control_handle: AudioCapturerControlHandle,
3609    },
3610    /// Sets the usage of the capture stream. This may be changed on the fly, but packets in flight
3611    /// may be affected. By default, Capturers are created with the FOREGROUND usage.
3612    SetUsage {
3613        usage: AudioCaptureUsage,
3614        control_handle: AudioCapturerControlHandle,
3615    },
3616    /// Sets the usage of the capture stream. This may be changed on the fly, but this may affect
3617    /// packets in flight. By default, Capturers are created with the FOREGROUND usage.
3618    SetUsage2 {
3619        usage: AudioCaptureUsage2,
3620        control_handle: AudioCapturerControlHandle,
3621    },
3622    /// Gets the currently configured stream type. Note: for an AudioCapturer
3623    /// which was just created and has not yet had its stream type explicitly
3624    /// set, this will retrieve the stream type -- at the time the AudioCapturer
3625    /// was created -- of the source (input or looped-back output) to which the
3626    /// AudioCapturer is bound. Even if this matches the client's desired format,
3627    /// `SetPcmStreamType` must still be called.
3628    GetStreamType {
3629        responder: AudioCapturerGetStreamTypeResponder,
3630    },
3631    /// An interaction was received which does not match any known method.
3632    #[non_exhaustive]
3633    _UnknownMethod {
3634        /// Ordinal of the method that was called.
3635        ordinal: u64,
3636        control_handle: AudioCapturerControlHandle,
3637        method_type: fidl::MethodType,
3638    },
3639}
3640
3641impl AudioCapturerRequest {
3642    #[allow(irrefutable_let_patterns)]
3643    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioCapturerControlHandle)> {
3644        if let AudioCapturerRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
3645        {
3646            Some((id, payload_buffer, control_handle))
3647        } else {
3648            None
3649        }
3650    }
3651
3652    #[allow(irrefutable_let_patterns)]
3653    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioCapturerControlHandle)> {
3654        if let AudioCapturerRequest::RemovePayloadBuffer { id, control_handle } = self {
3655            Some((id, control_handle))
3656        } else {
3657            None
3658        }
3659    }
3660
3661    #[allow(irrefutable_let_patterns)]
3662    pub fn into_release_packet(self) -> Option<(StreamPacket, AudioCapturerControlHandle)> {
3663        if let AudioCapturerRequest::ReleasePacket { packet, control_handle } = self {
3664            Some((packet, control_handle))
3665        } else {
3666            None
3667        }
3668    }
3669
3670    #[allow(irrefutable_let_patterns)]
3671    pub fn into_discard_all_packets(self) -> Option<(AudioCapturerDiscardAllPacketsResponder)> {
3672        if let AudioCapturerRequest::DiscardAllPackets { responder } = self {
3673            Some((responder))
3674        } else {
3675            None
3676        }
3677    }
3678
3679    #[allow(irrefutable_let_patterns)]
3680    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3681        if let AudioCapturerRequest::DiscardAllPacketsNoReply { control_handle } = self {
3682            Some((control_handle))
3683        } else {
3684            None
3685        }
3686    }
3687
3688    #[allow(irrefutable_let_patterns)]
3689    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioCapturerControlHandle)> {
3690        if let AudioCapturerRequest::SetPcmStreamType { stream_type, control_handle } = self {
3691            Some((stream_type, control_handle))
3692        } else {
3693            None
3694        }
3695    }
3696
3697    #[allow(irrefutable_let_patterns)]
3698    pub fn into_capture_at(self) -> Option<(u32, u32, u32, AudioCapturerCaptureAtResponder)> {
3699        if let AudioCapturerRequest::CaptureAt {
3700            payload_buffer_id,
3701            payload_offset,
3702            frames,
3703            responder,
3704        } = self
3705        {
3706            Some((payload_buffer_id, payload_offset, frames, responder))
3707        } else {
3708            None
3709        }
3710    }
3711
3712    #[allow(irrefutable_let_patterns)]
3713    pub fn into_start_async_capture(self) -> Option<(u32, AudioCapturerControlHandle)> {
3714        if let AudioCapturerRequest::StartAsyncCapture { frames_per_packet, control_handle } = self
3715        {
3716            Some((frames_per_packet, control_handle))
3717        } else {
3718            None
3719        }
3720    }
3721
3722    #[allow(irrefutable_let_patterns)]
3723    pub fn into_stop_async_capture(self) -> Option<(AudioCapturerStopAsyncCaptureResponder)> {
3724        if let AudioCapturerRequest::StopAsyncCapture { responder } = self {
3725            Some((responder))
3726        } else {
3727            None
3728        }
3729    }
3730
3731    #[allow(irrefutable_let_patterns)]
3732    pub fn into_stop_async_capture_no_reply(self) -> Option<(AudioCapturerControlHandle)> {
3733        if let AudioCapturerRequest::StopAsyncCaptureNoReply { control_handle } = self {
3734            Some((control_handle))
3735        } else {
3736            None
3737        }
3738    }
3739
3740    #[allow(irrefutable_let_patterns)]
3741    pub fn into_bind_gain_control(
3742        self,
3743    ) -> Option<(
3744        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
3745        AudioCapturerControlHandle,
3746    )> {
3747        if let AudioCapturerRequest::BindGainControl { gain_control_request, control_handle } = self
3748        {
3749            Some((gain_control_request, control_handle))
3750        } else {
3751            None
3752        }
3753    }
3754
3755    #[allow(irrefutable_let_patterns)]
3756    pub fn into_get_reference_clock(self) -> Option<(AudioCapturerGetReferenceClockResponder)> {
3757        if let AudioCapturerRequest::GetReferenceClock { responder } = self {
3758            Some((responder))
3759        } else {
3760            None
3761        }
3762    }
3763
3764    #[allow(irrefutable_let_patterns)]
3765    pub fn into_set_reference_clock(
3766        self,
3767    ) -> Option<(Option<fidl::Clock>, AudioCapturerControlHandle)> {
3768        if let AudioCapturerRequest::SetReferenceClock { reference_clock, control_handle } = self {
3769            Some((reference_clock, control_handle))
3770        } else {
3771            None
3772        }
3773    }
3774
3775    #[allow(irrefutable_let_patterns)]
3776    pub fn into_set_usage(self) -> Option<(AudioCaptureUsage, AudioCapturerControlHandle)> {
3777        if let AudioCapturerRequest::SetUsage { usage, control_handle } = self {
3778            Some((usage, control_handle))
3779        } else {
3780            None
3781        }
3782    }
3783
3784    #[allow(irrefutable_let_patterns)]
3785    pub fn into_set_usage2(self) -> Option<(AudioCaptureUsage2, AudioCapturerControlHandle)> {
3786        if let AudioCapturerRequest::SetUsage2 { usage, control_handle } = self {
3787            Some((usage, control_handle))
3788        } else {
3789            None
3790        }
3791    }
3792
3793    #[allow(irrefutable_let_patterns)]
3794    pub fn into_get_stream_type(self) -> Option<(AudioCapturerGetStreamTypeResponder)> {
3795        if let AudioCapturerRequest::GetStreamType { responder } = self {
3796            Some((responder))
3797        } else {
3798            None
3799        }
3800    }
3801
3802    /// Name of the method defined in FIDL
3803    pub fn method_name(&self) -> &'static str {
3804        match *self {
3805            AudioCapturerRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
3806            AudioCapturerRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
3807            AudioCapturerRequest::ReleasePacket { .. } => "release_packet",
3808            AudioCapturerRequest::DiscardAllPackets { .. } => "discard_all_packets",
3809            AudioCapturerRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
3810            AudioCapturerRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
3811            AudioCapturerRequest::CaptureAt { .. } => "capture_at",
3812            AudioCapturerRequest::StartAsyncCapture { .. } => "start_async_capture",
3813            AudioCapturerRequest::StopAsyncCapture { .. } => "stop_async_capture",
3814            AudioCapturerRequest::StopAsyncCaptureNoReply { .. } => "stop_async_capture_no_reply",
3815            AudioCapturerRequest::BindGainControl { .. } => "bind_gain_control",
3816            AudioCapturerRequest::GetReferenceClock { .. } => "get_reference_clock",
3817            AudioCapturerRequest::SetReferenceClock { .. } => "set_reference_clock",
3818            AudioCapturerRequest::SetUsage { .. } => "set_usage",
3819            AudioCapturerRequest::SetUsage2 { .. } => "set_usage2",
3820            AudioCapturerRequest::GetStreamType { .. } => "get_stream_type",
3821            AudioCapturerRequest::_UnknownMethod {
3822                method_type: fidl::MethodType::OneWay, ..
3823            } => "unknown one-way method",
3824            AudioCapturerRequest::_UnknownMethod {
3825                method_type: fidl::MethodType::TwoWay, ..
3826            } => "unknown two-way method",
3827        }
3828    }
3829}
3830
3831#[derive(Debug, Clone)]
3832pub struct AudioCapturerControlHandle {
3833    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3834}
3835
3836impl AudioCapturerControlHandle {
3837    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3838        self.inner.shutdown_with_epitaph(status.into())
3839    }
3840}
3841
3842impl fidl::endpoints::ControlHandle for AudioCapturerControlHandle {
3843    fn shutdown(&self) {
3844        self.inner.shutdown()
3845    }
3846
3847    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3848        self.inner.shutdown_with_epitaph(status)
3849    }
3850
3851    fn is_closed(&self) -> bool {
3852        self.inner.channel().is_closed()
3853    }
3854    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3855        self.inner.channel().on_closed()
3856    }
3857
3858    #[cfg(target_os = "fuchsia")]
3859    fn signal_peer(
3860        &self,
3861        clear_mask: zx::Signals,
3862        set_mask: zx::Signals,
3863    ) -> Result<(), zx_status::Status> {
3864        use fidl::Peered;
3865        self.inner.channel().signal_peer(clear_mask, set_mask)
3866    }
3867}
3868
3869impl AudioCapturerControlHandle {
3870    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
3871        self.inner.send::<StreamSourceOnPacketProducedRequest>(
3872            (packet,),
3873            0,
3874            0x6bbe69746a3c8bd9,
3875            fidl::encoding::DynamicFlags::empty(),
3876        )
3877    }
3878
3879    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
3880        self.inner.send::<fidl::encoding::EmptyPayload>(
3881            (),
3882            0,
3883            0x550e69b41d03e2c2,
3884            fidl::encoding::DynamicFlags::empty(),
3885        )
3886    }
3887}
3888
3889#[must_use = "FIDL methods require a response to be sent"]
3890#[derive(Debug)]
3891pub struct AudioCapturerDiscardAllPacketsResponder {
3892    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3893    tx_id: u32,
3894}
3895
3896/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3897/// if the responder is dropped without sending a response, so that the client
3898/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3899impl std::ops::Drop for AudioCapturerDiscardAllPacketsResponder {
3900    fn drop(&mut self) {
3901        self.control_handle.shutdown();
3902        // Safety: drops once, never accessed again
3903        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3904    }
3905}
3906
3907impl fidl::endpoints::Responder for AudioCapturerDiscardAllPacketsResponder {
3908    type ControlHandle = AudioCapturerControlHandle;
3909
3910    fn control_handle(&self) -> &AudioCapturerControlHandle {
3911        &self.control_handle
3912    }
3913
3914    fn drop_without_shutdown(mut self) {
3915        // Safety: drops once, never accessed again due to mem::forget
3916        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3917        // Prevent Drop from running (which would shut down the channel)
3918        std::mem::forget(self);
3919    }
3920}
3921
3922impl AudioCapturerDiscardAllPacketsResponder {
3923    /// Sends a response to the FIDL transaction.
3924    ///
3925    /// Sets the channel to shutdown if an error occurs.
3926    pub fn send(self) -> Result<(), fidl::Error> {
3927        let _result = self.send_raw();
3928        if _result.is_err() {
3929            self.control_handle.shutdown();
3930        }
3931        self.drop_without_shutdown();
3932        _result
3933    }
3934
3935    /// Similar to "send" but does not shutdown the channel if an error occurs.
3936    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3937        let _result = self.send_raw();
3938        self.drop_without_shutdown();
3939        _result
3940    }
3941
3942    fn send_raw(&self) -> Result<(), fidl::Error> {
3943        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
3944            (),
3945            self.tx_id,
3946            0x27afd605e97b09d2,
3947            fidl::encoding::DynamicFlags::empty(),
3948        )
3949    }
3950}
3951
3952#[must_use = "FIDL methods require a response to be sent"]
3953#[derive(Debug)]
3954pub struct AudioCapturerCaptureAtResponder {
3955    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
3956    tx_id: u32,
3957}
3958
3959/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
3960/// if the responder is dropped without sending a response, so that the client
3961/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3962impl std::ops::Drop for AudioCapturerCaptureAtResponder {
3963    fn drop(&mut self) {
3964        self.control_handle.shutdown();
3965        // Safety: drops once, never accessed again
3966        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3967    }
3968}
3969
3970impl fidl::endpoints::Responder for AudioCapturerCaptureAtResponder {
3971    type ControlHandle = AudioCapturerControlHandle;
3972
3973    fn control_handle(&self) -> &AudioCapturerControlHandle {
3974        &self.control_handle
3975    }
3976
3977    fn drop_without_shutdown(mut self) {
3978        // Safety: drops once, never accessed again due to mem::forget
3979        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3980        // Prevent Drop from running (which would shut down the channel)
3981        std::mem::forget(self);
3982    }
3983}
3984
3985impl AudioCapturerCaptureAtResponder {
3986    /// Sends a response to the FIDL transaction.
3987    ///
3988    /// Sets the channel to shutdown if an error occurs.
3989    pub fn send(self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
3990        let _result = self.send_raw(captured_packet);
3991        if _result.is_err() {
3992            self.control_handle.shutdown();
3993        }
3994        self.drop_without_shutdown();
3995        _result
3996    }
3997
3998    /// Similar to "send" but does not shutdown the channel if an error occurs.
3999    pub fn send_no_shutdown_on_err(
4000        self,
4001        mut captured_packet: &StreamPacket,
4002    ) -> Result<(), fidl::Error> {
4003        let _result = self.send_raw(captured_packet);
4004        self.drop_without_shutdown();
4005        _result
4006    }
4007
4008    fn send_raw(&self, mut captured_packet: &StreamPacket) -> Result<(), fidl::Error> {
4009        self.control_handle.inner.send::<AudioCapturerCaptureAtResponse>(
4010            (captured_packet,),
4011            self.tx_id,
4012            0x784e25df72cea780,
4013            fidl::encoding::DynamicFlags::empty(),
4014        )
4015    }
4016}
4017
4018#[must_use = "FIDL methods require a response to be sent"]
4019#[derive(Debug)]
4020pub struct AudioCapturerStopAsyncCaptureResponder {
4021    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
4022    tx_id: u32,
4023}
4024
4025/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
4026/// if the responder is dropped without sending a response, so that the client
4027/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4028impl std::ops::Drop for AudioCapturerStopAsyncCaptureResponder {
4029    fn drop(&mut self) {
4030        self.control_handle.shutdown();
4031        // Safety: drops once, never accessed again
4032        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4033    }
4034}
4035
4036impl fidl::endpoints::Responder for AudioCapturerStopAsyncCaptureResponder {
4037    type ControlHandle = AudioCapturerControlHandle;
4038
4039    fn control_handle(&self) -> &AudioCapturerControlHandle {
4040        &self.control_handle
4041    }
4042
4043    fn drop_without_shutdown(mut self) {
4044        // Safety: drops once, never accessed again due to mem::forget
4045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4046        // Prevent Drop from running (which would shut down the channel)
4047        std::mem::forget(self);
4048    }
4049}
4050
4051impl AudioCapturerStopAsyncCaptureResponder {
4052    /// Sends a response to the FIDL transaction.
4053    ///
4054    /// Sets the channel to shutdown if an error occurs.
4055    pub fn send(self) -> Result<(), fidl::Error> {
4056        let _result = self.send_raw();
4057        if _result.is_err() {
4058            self.control_handle.shutdown();
4059        }
4060        self.drop_without_shutdown();
4061        _result
4062    }
4063
4064    /// Similar to "send" but does not shutdown the channel if an error occurs.
4065    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4066        let _result = self.send_raw();
4067        self.drop_without_shutdown();
4068        _result
4069    }
4070
4071    fn send_raw(&self) -> Result<(), fidl::Error> {
4072        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
4073            (),
4074            self.tx_id,
4075            0x5bfc8790a8cef8cb,
4076            fidl::encoding::DynamicFlags::empty(),
4077        )
4078    }
4079}
4080
4081#[must_use = "FIDL methods require a response to be sent"]
4082#[derive(Debug)]
4083pub struct AudioCapturerGetReferenceClockResponder {
4084    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
4085    tx_id: u32,
4086}
4087
4088/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
4089/// if the responder is dropped without sending a response, so that the client
4090/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4091impl std::ops::Drop for AudioCapturerGetReferenceClockResponder {
4092    fn drop(&mut self) {
4093        self.control_handle.shutdown();
4094        // Safety: drops once, never accessed again
4095        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4096    }
4097}
4098
4099impl fidl::endpoints::Responder for AudioCapturerGetReferenceClockResponder {
4100    type ControlHandle = AudioCapturerControlHandle;
4101
4102    fn control_handle(&self) -> &AudioCapturerControlHandle {
4103        &self.control_handle
4104    }
4105
4106    fn drop_without_shutdown(mut self) {
4107        // Safety: drops once, never accessed again due to mem::forget
4108        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4109        // Prevent Drop from running (which would shut down the channel)
4110        std::mem::forget(self);
4111    }
4112}
4113
4114impl AudioCapturerGetReferenceClockResponder {
4115    /// Sends a response to the FIDL transaction.
4116    ///
4117    /// Sets the channel to shutdown if an error occurs.
4118    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
4119        let _result = self.send_raw(reference_clock);
4120        if _result.is_err() {
4121            self.control_handle.shutdown();
4122        }
4123        self.drop_without_shutdown();
4124        _result
4125    }
4126
4127    /// Similar to "send" but does not shutdown the channel if an error occurs.
4128    pub fn send_no_shutdown_on_err(
4129        self,
4130        mut reference_clock: fidl::Clock,
4131    ) -> Result<(), fidl::Error> {
4132        let _result = self.send_raw(reference_clock);
4133        self.drop_without_shutdown();
4134        _result
4135    }
4136
4137    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
4138        self.control_handle.inner.send::<AudioCapturerGetReferenceClockResponse>(
4139            (reference_clock,),
4140            self.tx_id,
4141            0x50d037aa5a4b4d71,
4142            fidl::encoding::DynamicFlags::empty(),
4143        )
4144    }
4145}
4146
4147#[must_use = "FIDL methods require a response to be sent"]
4148#[derive(Debug)]
4149pub struct AudioCapturerGetStreamTypeResponder {
4150    control_handle: std::mem::ManuallyDrop<AudioCapturerControlHandle>,
4151    tx_id: u32,
4152}
4153
4154/// Set the the channel to be shutdown (see [`AudioCapturerControlHandle::shutdown`])
4155/// if the responder is dropped without sending a response, so that the client
4156/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4157impl std::ops::Drop for AudioCapturerGetStreamTypeResponder {
4158    fn drop(&mut self) {
4159        self.control_handle.shutdown();
4160        // Safety: drops once, never accessed again
4161        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4162    }
4163}
4164
4165impl fidl::endpoints::Responder for AudioCapturerGetStreamTypeResponder {
4166    type ControlHandle = AudioCapturerControlHandle;
4167
4168    fn control_handle(&self) -> &AudioCapturerControlHandle {
4169        &self.control_handle
4170    }
4171
4172    fn drop_without_shutdown(mut self) {
4173        // Safety: drops once, never accessed again due to mem::forget
4174        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4175        // Prevent Drop from running (which would shut down the channel)
4176        std::mem::forget(self);
4177    }
4178}
4179
4180impl AudioCapturerGetStreamTypeResponder {
4181    /// Sends a response to the FIDL transaction.
4182    ///
4183    /// Sets the channel to shutdown if an error occurs.
4184    pub fn send(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
4185        let _result = self.send_raw(stream_type);
4186        if _result.is_err() {
4187            self.control_handle.shutdown();
4188        }
4189        self.drop_without_shutdown();
4190        _result
4191    }
4192
4193    /// Similar to "send" but does not shutdown the channel if an error occurs.
4194    pub fn send_no_shutdown_on_err(self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
4195        let _result = self.send_raw(stream_type);
4196        self.drop_without_shutdown();
4197        _result
4198    }
4199
4200    fn send_raw(&self, mut stream_type: &StreamType) -> Result<(), fidl::Error> {
4201        self.control_handle.inner.send::<AudioCapturerGetStreamTypeResponse>(
4202            (stream_type,),
4203            self.tx_id,
4204            0x5dcaaa670b433088,
4205            fidl::encoding::DynamicFlags::empty(),
4206        )
4207    }
4208}
4209
4210#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4211pub struct AudioConsumerMarker;
4212
4213impl fidl::endpoints::ProtocolMarker for AudioConsumerMarker {
4214    type Proxy = AudioConsumerProxy;
4215    type RequestStream = AudioConsumerRequestStream;
4216    #[cfg(target_os = "fuchsia")]
4217    type SynchronousProxy = AudioConsumerSynchronousProxy;
4218
4219    const DEBUG_NAME: &'static str = "(anonymous) AudioConsumer";
4220}
4221
4222pub trait AudioConsumerProxyInterface: Send + Sync {
4223    fn r#create_stream_sink(
4224        &self,
4225        buffers: Vec<fidl::Vmo>,
4226        stream_type: &AudioStreamType,
4227        compression: Option<&Compression>,
4228        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4229    ) -> Result<(), fidl::Error>;
4230    fn r#start(
4231        &self,
4232        flags: AudioConsumerStartFlags,
4233        reference_time: i64,
4234        media_time: i64,
4235    ) -> Result<(), fidl::Error>;
4236    fn r#stop(&self) -> Result<(), fidl::Error>;
4237    fn r#set_rate(&self, rate: f32) -> Result<(), fidl::Error>;
4238    fn r#bind_volume_control(
4239        &self,
4240        volume_control_request: fidl::endpoints::ServerEnd<
4241            fidl_fuchsia_media_audio::VolumeControlMarker,
4242        >,
4243    ) -> Result<(), fidl::Error>;
4244    type WatchStatusResponseFut: std::future::Future<Output = Result<AudioConsumerStatus, fidl::Error>>
4245        + Send;
4246    fn r#watch_status(&self) -> Self::WatchStatusResponseFut;
4247}
4248#[derive(Debug)]
4249#[cfg(target_os = "fuchsia")]
4250pub struct AudioConsumerSynchronousProxy {
4251    client: fidl::client::sync::Client,
4252}
4253
4254#[cfg(target_os = "fuchsia")]
4255impl fidl::endpoints::SynchronousProxy for AudioConsumerSynchronousProxy {
4256    type Proxy = AudioConsumerProxy;
4257    type Protocol = AudioConsumerMarker;
4258
4259    fn from_channel(inner: fidl::Channel) -> Self {
4260        Self::new(inner)
4261    }
4262
4263    fn into_channel(self) -> fidl::Channel {
4264        self.client.into_channel()
4265    }
4266
4267    fn as_channel(&self) -> &fidl::Channel {
4268        self.client.as_channel()
4269    }
4270}
4271
4272#[cfg(target_os = "fuchsia")]
4273impl AudioConsumerSynchronousProxy {
4274    pub fn new(channel: fidl::Channel) -> Self {
4275        Self { client: fidl::client::sync::Client::new(channel) }
4276    }
4277
4278    pub fn into_channel(self) -> fidl::Channel {
4279        self.client.into_channel()
4280    }
4281
4282    /// Waits until an event arrives and returns it. It is safe for other
4283    /// threads to make concurrent requests while waiting for an event.
4284    pub fn wait_for_event(
4285        &self,
4286        deadline: zx::MonotonicInstant,
4287    ) -> Result<AudioConsumerEvent, fidl::Error> {
4288        AudioConsumerEvent::decode(self.client.wait_for_event::<AudioConsumerMarker>(deadline)?)
4289    }
4290
4291    /// Creates a `StreamSink` for the consumer with the indicated properties.
4292    ///
4293    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4294    /// sequentially rather than concurrently. The first stream sink that's created using this
4295    /// method is used as the sole source of packets incoming to the logical consumer until that
4296    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4297    /// the second stream sink is used, and so on.
4298    ///
4299    /// If an unsupported compression type is supplied, the
4300    /// `stream_sink_request` request will be closed with an epitaph value of
4301    /// `ZX_ERR_INVALID_ARGS`.
4302    pub fn r#create_stream_sink(
4303        &self,
4304        mut buffers: Vec<fidl::Vmo>,
4305        mut stream_type: &AudioStreamType,
4306        mut compression: Option<&Compression>,
4307        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4308    ) -> Result<(), fidl::Error> {
4309        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4310            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4311            0x525b3b97fdf7d884,
4312            fidl::encoding::DynamicFlags::empty(),
4313        )
4314    }
4315
4316    /// Starts rendering as indicated by `flags`.
4317    ///
4318    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4319    /// Typically, this is the timestamp of the first packet that will be
4320    /// rendered. If packets will be supplied with no timestamps, this value
4321    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4322    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4323    ///     1. When starting for the first time, the default media time is the
4324    ///        timestamp on the first packet sent to the stream sink.
4325    ///     2. When resuming after stop, the default media time is the media
4326    ///        time at which the stream stopped.
4327    ///
4328    /// `reference_time` is the monotonic system time at which rendering should
4329    /// be started. For supply-driven sources, this must be the time at which
4330    /// the first packet was (or will be) sent plus a lead time, which must be
4331    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4332    /// sources, the client must ensure that the lead time requirement is met at
4333    /// the start time.  Passing the default value of 0 for `reference_time`
4334    /// causes the consumer to choose a start time based on the availability of
4335    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4336    /// specified.
4337    ///
4338    /// The actual start time will be reflected in the updated status.
4339    pub fn r#start(
4340        &self,
4341        mut flags: AudioConsumerStartFlags,
4342        mut reference_time: i64,
4343        mut media_time: i64,
4344    ) -> Result<(), fidl::Error> {
4345        self.client.send::<AudioConsumerStartRequest>(
4346            (flags, reference_time, media_time),
4347            0x4fdbd44b3f2a3a3c,
4348            fidl::encoding::DynamicFlags::empty(),
4349        )
4350    }
4351
4352    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4353    /// be reflected in the updated status.
4354    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4355        self.client.send::<fidl::encoding::EmptyPayload>(
4356            (),
4357            0x3d46c3741686c40d,
4358            fidl::encoding::DynamicFlags::empty(),
4359        )
4360    }
4361
4362    /// Requests to change the playback rate of the renderer. 1.0 means normal
4363    /// playback. Negative rates are not supported. The new rate will be
4364    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4365    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4366        self.client.send::<AudioConsumerSetRateRequest>(
4367            (rate,),
4368            0x45342b73968bfafe,
4369            fidl::encoding::DynamicFlags::empty(),
4370        )
4371    }
4372
4373    /// Binds to this `AudioConsumer` volume control for control and notifications.
4374    pub fn r#bind_volume_control(
4375        &self,
4376        mut volume_control_request: fidl::endpoints::ServerEnd<
4377            fidl_fuchsia_media_audio::VolumeControlMarker,
4378        >,
4379    ) -> Result<(), fidl::Error> {
4380        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4381            (volume_control_request,),
4382            0x6f1b01fd887f5748,
4383            fidl::encoding::DynamicFlags::empty(),
4384        )
4385    }
4386
4387    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4388    /// to this method when the status changes - initially with respect to the initial status value
4389    /// and thereafter with respect to the previously-reported status value.
4390    pub fn r#watch_status(
4391        &self,
4392        ___deadline: zx::MonotonicInstant,
4393    ) -> Result<AudioConsumerStatus, fidl::Error> {
4394        let _response = self.client.send_query::<
4395            fidl::encoding::EmptyPayload,
4396            AudioConsumerWatchStatusResponse,
4397            AudioConsumerMarker,
4398        >(
4399            (),
4400            0x35cf702c721e2cc6,
4401            fidl::encoding::DynamicFlags::empty(),
4402            ___deadline,
4403        )?;
4404        Ok(_response.status)
4405    }
4406}
4407
4408#[cfg(target_os = "fuchsia")]
4409impl From<AudioConsumerSynchronousProxy> for zx::NullableHandle {
4410    fn from(value: AudioConsumerSynchronousProxy) -> Self {
4411        value.into_channel().into()
4412    }
4413}
4414
4415#[cfg(target_os = "fuchsia")]
4416impl From<fidl::Channel> for AudioConsumerSynchronousProxy {
4417    fn from(value: fidl::Channel) -> Self {
4418        Self::new(value)
4419    }
4420}
4421
4422#[cfg(target_os = "fuchsia")]
4423impl fidl::endpoints::FromClient for AudioConsumerSynchronousProxy {
4424    type Protocol = AudioConsumerMarker;
4425
4426    fn from_client(value: fidl::endpoints::ClientEnd<AudioConsumerMarker>) -> Self {
4427        Self::new(value.into_channel())
4428    }
4429}
4430
4431#[derive(Debug, Clone)]
4432pub struct AudioConsumerProxy {
4433    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4434}
4435
4436impl fidl::endpoints::Proxy for AudioConsumerProxy {
4437    type Protocol = AudioConsumerMarker;
4438
4439    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4440        Self::new(inner)
4441    }
4442
4443    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4444        self.client.into_channel().map_err(|client| Self { client })
4445    }
4446
4447    fn as_channel(&self) -> &::fidl::AsyncChannel {
4448        self.client.as_channel()
4449    }
4450}
4451
4452impl AudioConsumerProxy {
4453    /// Create a new Proxy for fuchsia.media/AudioConsumer.
4454    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4455        let protocol_name = <AudioConsumerMarker as fidl::endpoints::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) -> AudioConsumerEventStream {
4465        AudioConsumerEventStream { event_receiver: self.client.take_event_receiver() }
4466    }
4467
4468    /// Creates a `StreamSink` for the consumer with the indicated properties.
4469    ///
4470    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4471    /// sequentially rather than concurrently. The first stream sink that's created using this
4472    /// method is used as the sole source of packets incoming to the logical consumer until that
4473    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4474    /// the second stream sink is used, and so on.
4475    ///
4476    /// If an unsupported compression type is supplied, the
4477    /// `stream_sink_request` request will be closed with an epitaph value of
4478    /// `ZX_ERR_INVALID_ARGS`.
4479    pub fn r#create_stream_sink(
4480        &self,
4481        mut buffers: Vec<fidl::Vmo>,
4482        mut stream_type: &AudioStreamType,
4483        mut compression: Option<&Compression>,
4484        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4485    ) -> Result<(), fidl::Error> {
4486        AudioConsumerProxyInterface::r#create_stream_sink(
4487            self,
4488            buffers,
4489            stream_type,
4490            compression,
4491            stream_sink_request,
4492        )
4493    }
4494
4495    /// Starts rendering as indicated by `flags`.
4496    ///
4497    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4498    /// Typically, this is the timestamp of the first packet that will be
4499    /// rendered. If packets will be supplied with no timestamps, this value
4500    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4501    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4502    ///     1. When starting for the first time, the default media time is the
4503    ///        timestamp on the first packet sent to the stream sink.
4504    ///     2. When resuming after stop, the default media time is the media
4505    ///        time at which the stream stopped.
4506    ///
4507    /// `reference_time` is the monotonic system time at which rendering should
4508    /// be started. For supply-driven sources, this must be the time at which
4509    /// the first packet was (or will be) sent plus a lead time, which must be
4510    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4511    /// sources, the client must ensure that the lead time requirement is met at
4512    /// the start time.  Passing the default value of 0 for `reference_time`
4513    /// causes the consumer to choose a start time based on the availability of
4514    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4515    /// specified.
4516    ///
4517    /// The actual start time will be reflected in the updated status.
4518    pub fn r#start(
4519        &self,
4520        mut flags: AudioConsumerStartFlags,
4521        mut reference_time: i64,
4522        mut media_time: i64,
4523    ) -> Result<(), fidl::Error> {
4524        AudioConsumerProxyInterface::r#start(self, flags, reference_time, media_time)
4525    }
4526
4527    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4528    /// be reflected in the updated status.
4529    pub fn r#stop(&self) -> Result<(), fidl::Error> {
4530        AudioConsumerProxyInterface::r#stop(self)
4531    }
4532
4533    /// Requests to change the playback rate of the renderer. 1.0 means normal
4534    /// playback. Negative rates are not supported. The new rate will be
4535    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4536    pub fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4537        AudioConsumerProxyInterface::r#set_rate(self, rate)
4538    }
4539
4540    /// Binds to this `AudioConsumer` volume control for control and notifications.
4541    pub fn r#bind_volume_control(
4542        &self,
4543        mut volume_control_request: fidl::endpoints::ServerEnd<
4544            fidl_fuchsia_media_audio::VolumeControlMarker,
4545        >,
4546    ) -> Result<(), fidl::Error> {
4547        AudioConsumerProxyInterface::r#bind_volume_control(self, volume_control_request)
4548    }
4549
4550    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4551    /// to this method when the status changes - initially with respect to the initial status value
4552    /// and thereafter with respect to the previously-reported status value.
4553    pub fn r#watch_status(
4554        &self,
4555    ) -> fidl::client::QueryResponseFut<
4556        AudioConsumerStatus,
4557        fidl::encoding::DefaultFuchsiaResourceDialect,
4558    > {
4559        AudioConsumerProxyInterface::r#watch_status(self)
4560    }
4561}
4562
4563impl AudioConsumerProxyInterface for AudioConsumerProxy {
4564    fn r#create_stream_sink(
4565        &self,
4566        mut buffers: Vec<fidl::Vmo>,
4567        mut stream_type: &AudioStreamType,
4568        mut compression: Option<&Compression>,
4569        mut stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4570    ) -> Result<(), fidl::Error> {
4571        self.client.send::<AudioConsumerCreateStreamSinkRequest>(
4572            (buffers.as_mut(), stream_type, compression, stream_sink_request),
4573            0x525b3b97fdf7d884,
4574            fidl::encoding::DynamicFlags::empty(),
4575        )
4576    }
4577
4578    fn r#start(
4579        &self,
4580        mut flags: AudioConsumerStartFlags,
4581        mut reference_time: i64,
4582        mut media_time: i64,
4583    ) -> Result<(), fidl::Error> {
4584        self.client.send::<AudioConsumerStartRequest>(
4585            (flags, reference_time, media_time),
4586            0x4fdbd44b3f2a3a3c,
4587            fidl::encoding::DynamicFlags::empty(),
4588        )
4589    }
4590
4591    fn r#stop(&self) -> Result<(), fidl::Error> {
4592        self.client.send::<fidl::encoding::EmptyPayload>(
4593            (),
4594            0x3d46c3741686c40d,
4595            fidl::encoding::DynamicFlags::empty(),
4596        )
4597    }
4598
4599    fn r#set_rate(&self, mut rate: f32) -> Result<(), fidl::Error> {
4600        self.client.send::<AudioConsumerSetRateRequest>(
4601            (rate,),
4602            0x45342b73968bfafe,
4603            fidl::encoding::DynamicFlags::empty(),
4604        )
4605    }
4606
4607    fn r#bind_volume_control(
4608        &self,
4609        mut volume_control_request: fidl::endpoints::ServerEnd<
4610            fidl_fuchsia_media_audio::VolumeControlMarker,
4611        >,
4612    ) -> Result<(), fidl::Error> {
4613        self.client.send::<AudioConsumerBindVolumeControlRequest>(
4614            (volume_control_request,),
4615            0x6f1b01fd887f5748,
4616            fidl::encoding::DynamicFlags::empty(),
4617        )
4618    }
4619
4620    type WatchStatusResponseFut = fidl::client::QueryResponseFut<
4621        AudioConsumerStatus,
4622        fidl::encoding::DefaultFuchsiaResourceDialect,
4623    >;
4624    fn r#watch_status(&self) -> Self::WatchStatusResponseFut {
4625        fn _decode(
4626            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4627        ) -> Result<AudioConsumerStatus, fidl::Error> {
4628            let _response = fidl::client::decode_transaction_body::<
4629                AudioConsumerWatchStatusResponse,
4630                fidl::encoding::DefaultFuchsiaResourceDialect,
4631                0x35cf702c721e2cc6,
4632            >(_buf?)?;
4633            Ok(_response.status)
4634        }
4635        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, AudioConsumerStatus>(
4636            (),
4637            0x35cf702c721e2cc6,
4638            fidl::encoding::DynamicFlags::empty(),
4639            _decode,
4640        )
4641    }
4642}
4643
4644pub struct AudioConsumerEventStream {
4645    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4646}
4647
4648impl std::marker::Unpin for AudioConsumerEventStream {}
4649
4650impl futures::stream::FusedStream for AudioConsumerEventStream {
4651    fn is_terminated(&self) -> bool {
4652        self.event_receiver.is_terminated()
4653    }
4654}
4655
4656impl futures::Stream for AudioConsumerEventStream {
4657    type Item = Result<AudioConsumerEvent, fidl::Error>;
4658
4659    fn poll_next(
4660        mut self: std::pin::Pin<&mut Self>,
4661        cx: &mut std::task::Context<'_>,
4662    ) -> std::task::Poll<Option<Self::Item>> {
4663        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4664            &mut self.event_receiver,
4665            cx
4666        )?) {
4667            Some(buf) => std::task::Poll::Ready(Some(AudioConsumerEvent::decode(buf))),
4668            None => std::task::Poll::Ready(None),
4669        }
4670    }
4671}
4672
4673#[derive(Debug)]
4674pub enum AudioConsumerEvent {
4675    OnEndOfStream {},
4676}
4677
4678impl AudioConsumerEvent {
4679    #[allow(irrefutable_let_patterns)]
4680    pub fn into_on_end_of_stream(self) -> Option<()> {
4681        if let AudioConsumerEvent::OnEndOfStream {} = self { Some(()) } else { None }
4682    }
4683
4684    /// Decodes a message buffer as a [`AudioConsumerEvent`].
4685    fn decode(
4686        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4687    ) -> Result<AudioConsumerEvent, fidl::Error> {
4688        let (bytes, _handles) = buf.split_mut();
4689        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4690        debug_assert_eq!(tx_header.tx_id, 0);
4691        match tx_header.ordinal {
4692            0x53a64e6d0e8f8a20 => {
4693                let mut out = fidl::new_empty!(
4694                    fidl::encoding::EmptyPayload,
4695                    fidl::encoding::DefaultFuchsiaResourceDialect
4696                );
4697                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
4698                Ok((AudioConsumerEvent::OnEndOfStream {}))
4699            }
4700            _ => Err(fidl::Error::UnknownOrdinal {
4701                ordinal: tx_header.ordinal,
4702                protocol_name: <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4703            }),
4704        }
4705    }
4706}
4707
4708/// A Stream of incoming requests for fuchsia.media/AudioConsumer.
4709pub struct AudioConsumerRequestStream {
4710    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4711    is_terminated: bool,
4712}
4713
4714impl std::marker::Unpin for AudioConsumerRequestStream {}
4715
4716impl futures::stream::FusedStream for AudioConsumerRequestStream {
4717    fn is_terminated(&self) -> bool {
4718        self.is_terminated
4719    }
4720}
4721
4722impl fidl::endpoints::RequestStream for AudioConsumerRequestStream {
4723    type Protocol = AudioConsumerMarker;
4724    type ControlHandle = AudioConsumerControlHandle;
4725
4726    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4727        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4728    }
4729
4730    fn control_handle(&self) -> Self::ControlHandle {
4731        AudioConsumerControlHandle { inner: self.inner.clone() }
4732    }
4733
4734    fn into_inner(
4735        self,
4736    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4737    {
4738        (self.inner, self.is_terminated)
4739    }
4740
4741    fn from_inner(
4742        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4743        is_terminated: bool,
4744    ) -> Self {
4745        Self { inner, is_terminated }
4746    }
4747}
4748
4749impl futures::Stream for AudioConsumerRequestStream {
4750    type Item = Result<AudioConsumerRequest, fidl::Error>;
4751
4752    fn poll_next(
4753        mut self: std::pin::Pin<&mut Self>,
4754        cx: &mut std::task::Context<'_>,
4755    ) -> std::task::Poll<Option<Self::Item>> {
4756        let this = &mut *self;
4757        if this.inner.check_shutdown(cx) {
4758            this.is_terminated = true;
4759            return std::task::Poll::Ready(None);
4760        }
4761        if this.is_terminated {
4762            panic!("polled AudioConsumerRequestStream after completion");
4763        }
4764        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4765            |bytes, handles| {
4766                match this.inner.channel().read_etc(cx, bytes, handles) {
4767                    std::task::Poll::Ready(Ok(())) => {}
4768                    std::task::Poll::Pending => return std::task::Poll::Pending,
4769                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4770                        this.is_terminated = true;
4771                        return std::task::Poll::Ready(None);
4772                    }
4773                    std::task::Poll::Ready(Err(e)) => {
4774                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4775                            e.into(),
4776                        ))));
4777                    }
4778                }
4779
4780                // A message has been received from the channel
4781                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4782
4783                std::task::Poll::Ready(Some(match header.ordinal {
4784                    0x525b3b97fdf7d884 => {
4785                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4786                        let mut req = fidl::new_empty!(
4787                            AudioConsumerCreateStreamSinkRequest,
4788                            fidl::encoding::DefaultFuchsiaResourceDialect
4789                        );
4790                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerCreateStreamSinkRequest>(&header, _body_bytes, handles, &mut req)?;
4791                        let control_handle =
4792                            AudioConsumerControlHandle { inner: this.inner.clone() };
4793                        Ok(AudioConsumerRequest::CreateStreamSink {
4794                            buffers: req.buffers,
4795                            stream_type: req.stream_type,
4796                            compression: req.compression,
4797                            stream_sink_request: req.stream_sink_request,
4798
4799                            control_handle,
4800                        })
4801                    }
4802                    0x4fdbd44b3f2a3a3c => {
4803                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4804                        let mut req = fidl::new_empty!(
4805                            AudioConsumerStartRequest,
4806                            fidl::encoding::DefaultFuchsiaResourceDialect
4807                        );
4808                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerStartRequest>(&header, _body_bytes, handles, &mut req)?;
4809                        let control_handle =
4810                            AudioConsumerControlHandle { inner: this.inner.clone() };
4811                        Ok(AudioConsumerRequest::Start {
4812                            flags: req.flags,
4813                            reference_time: req.reference_time,
4814                            media_time: req.media_time,
4815
4816                            control_handle,
4817                        })
4818                    }
4819                    0x3d46c3741686c40d => {
4820                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4821                        let mut req = fidl::new_empty!(
4822                            fidl::encoding::EmptyPayload,
4823                            fidl::encoding::DefaultFuchsiaResourceDialect
4824                        );
4825                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4826                        let control_handle =
4827                            AudioConsumerControlHandle { inner: this.inner.clone() };
4828                        Ok(AudioConsumerRequest::Stop { control_handle })
4829                    }
4830                    0x45342b73968bfafe => {
4831                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4832                        let mut req = fidl::new_empty!(
4833                            AudioConsumerSetRateRequest,
4834                            fidl::encoding::DefaultFuchsiaResourceDialect
4835                        );
4836                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerSetRateRequest>(&header, _body_bytes, handles, &mut req)?;
4837                        let control_handle =
4838                            AudioConsumerControlHandle { inner: this.inner.clone() };
4839                        Ok(AudioConsumerRequest::SetRate { rate: req.rate, control_handle })
4840                    }
4841                    0x6f1b01fd887f5748 => {
4842                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4843                        let mut req = fidl::new_empty!(
4844                            AudioConsumerBindVolumeControlRequest,
4845                            fidl::encoding::DefaultFuchsiaResourceDialect
4846                        );
4847                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioConsumerBindVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
4848                        let control_handle =
4849                            AudioConsumerControlHandle { inner: this.inner.clone() };
4850                        Ok(AudioConsumerRequest::BindVolumeControl {
4851                            volume_control_request: req.volume_control_request,
4852
4853                            control_handle,
4854                        })
4855                    }
4856                    0x35cf702c721e2cc6 => {
4857                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4858                        let mut req = fidl::new_empty!(
4859                            fidl::encoding::EmptyPayload,
4860                            fidl::encoding::DefaultFuchsiaResourceDialect
4861                        );
4862                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4863                        let control_handle =
4864                            AudioConsumerControlHandle { inner: this.inner.clone() };
4865                        Ok(AudioConsumerRequest::WatchStatus {
4866                            responder: AudioConsumerWatchStatusResponder {
4867                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4868                                tx_id: header.tx_id,
4869                            },
4870                        })
4871                    }
4872                    _ => Err(fidl::Error::UnknownOrdinal {
4873                        ordinal: header.ordinal,
4874                        protocol_name:
4875                            <AudioConsumerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4876                    }),
4877                }))
4878            },
4879        )
4880    }
4881}
4882
4883/// Interface for playing and controlling audio.
4884#[derive(Debug)]
4885pub enum AudioConsumerRequest {
4886    /// Creates a `StreamSink` for the consumer with the indicated properties.
4887    ///
4888    /// Multiple stream sinks may be acquired using this method, but they are intended to be used
4889    /// sequentially rather than concurrently. The first stream sink that's created using this
4890    /// method is used as the sole source of packets incoming to the logical consumer until that
4891    /// stream sink is closed or the `EndOfStream` method is called on that sink. At that point,
4892    /// the second stream sink is used, and so on.
4893    ///
4894    /// If an unsupported compression type is supplied, the
4895    /// `stream_sink_request` request will be closed with an epitaph value of
4896    /// `ZX_ERR_INVALID_ARGS`.
4897    CreateStreamSink {
4898        buffers: Vec<fidl::Vmo>,
4899        stream_type: AudioStreamType,
4900        compression: Option<Box<Compression>>,
4901        stream_sink_request: fidl::endpoints::ServerEnd<StreamSinkMarker>,
4902        control_handle: AudioConsumerControlHandle,
4903    },
4904    /// Starts rendering as indicated by `flags`.
4905    ///
4906    /// `media_time` indicates the packet timestamp that corresponds to `reference_time`.
4907    /// Typically, this is the timestamp of the first packet that will be
4908    /// rendered. If packets will be supplied with no timestamps, this value
4909    /// should be `NO_TIMESTAMP`.  Passing a `media_time` value of
4910    /// `NO_TIMESTAMP` chooses the default media time, established as follows:
4911    ///     1. When starting for the first time, the default media time is the
4912    ///        timestamp on the first packet sent to the stream sink.
4913    ///     2. When resuming after stop, the default media time is the media
4914    ///        time at which the stream stopped.
4915    ///
4916    /// `reference_time` is the monotonic system time at which rendering should
4917    /// be started. For supply-driven sources, this must be the time at which
4918    /// the first packet was (or will be) sent plus a lead time, which must be
4919    /// in the range indicated in the `AudioConsumerStatus`. For demand-driven
4920    /// sources, the client must ensure that the lead time requirement is met at
4921    /// the start time.  Passing the default value of 0 for `reference_time`
4922    /// causes the consumer to choose a start time based on the availability of
4923    /// packets, the lead time requirements, and whether `LOW_LATENCY` has been
4924    /// specified.
4925    ///
4926    /// The actual start time will be reflected in the updated status.
4927    Start {
4928        flags: AudioConsumerStartFlags,
4929        reference_time: i64,
4930        media_time: i64,
4931        control_handle: AudioConsumerControlHandle,
4932    },
4933    /// Stops rendering as soon as possible after this method is called. The actual stop time will
4934    /// be reflected in the updated status.
4935    Stop { control_handle: AudioConsumerControlHandle },
4936    /// Requests to change the playback rate of the renderer. 1.0 means normal
4937    /// playback. Negative rates are not supported. The new rate will be
4938    /// reflected in the updated status. The default rate of any newly created `StreamSink` is 1.0.
4939    SetRate { rate: f32, control_handle: AudioConsumerControlHandle },
4940    /// Binds to this `AudioConsumer` volume control for control and notifications.
4941    BindVolumeControl {
4942        volume_control_request:
4943            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
4944        control_handle: AudioConsumerControlHandle,
4945    },
4946    /// Gets the current status of the consumer using the long get pattern. The consumer responds
4947    /// to this method when the status changes - initially with respect to the initial status value
4948    /// and thereafter with respect to the previously-reported status value.
4949    WatchStatus { responder: AudioConsumerWatchStatusResponder },
4950}
4951
4952impl AudioConsumerRequest {
4953    #[allow(irrefutable_let_patterns)]
4954    pub fn into_create_stream_sink(
4955        self,
4956    ) -> Option<(
4957        Vec<fidl::Vmo>,
4958        AudioStreamType,
4959        Option<Box<Compression>>,
4960        fidl::endpoints::ServerEnd<StreamSinkMarker>,
4961        AudioConsumerControlHandle,
4962    )> {
4963        if let AudioConsumerRequest::CreateStreamSink {
4964            buffers,
4965            stream_type,
4966            compression,
4967            stream_sink_request,
4968            control_handle,
4969        } = self
4970        {
4971            Some((buffers, stream_type, compression, stream_sink_request, control_handle))
4972        } else {
4973            None
4974        }
4975    }
4976
4977    #[allow(irrefutable_let_patterns)]
4978    pub fn into_start(
4979        self,
4980    ) -> Option<(AudioConsumerStartFlags, i64, i64, AudioConsumerControlHandle)> {
4981        if let AudioConsumerRequest::Start { flags, reference_time, media_time, control_handle } =
4982            self
4983        {
4984            Some((flags, reference_time, media_time, control_handle))
4985        } else {
4986            None
4987        }
4988    }
4989
4990    #[allow(irrefutable_let_patterns)]
4991    pub fn into_stop(self) -> Option<(AudioConsumerControlHandle)> {
4992        if let AudioConsumerRequest::Stop { control_handle } = self {
4993            Some((control_handle))
4994        } else {
4995            None
4996        }
4997    }
4998
4999    #[allow(irrefutable_let_patterns)]
5000    pub fn into_set_rate(self) -> Option<(f32, AudioConsumerControlHandle)> {
5001        if let AudioConsumerRequest::SetRate { rate, control_handle } = self {
5002            Some((rate, control_handle))
5003        } else {
5004            None
5005        }
5006    }
5007
5008    #[allow(irrefutable_let_patterns)]
5009    pub fn into_bind_volume_control(
5010        self,
5011    ) -> Option<(
5012        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
5013        AudioConsumerControlHandle,
5014    )> {
5015        if let AudioConsumerRequest::BindVolumeControl { volume_control_request, control_handle } =
5016            self
5017        {
5018            Some((volume_control_request, control_handle))
5019        } else {
5020            None
5021        }
5022    }
5023
5024    #[allow(irrefutable_let_patterns)]
5025    pub fn into_watch_status(self) -> Option<(AudioConsumerWatchStatusResponder)> {
5026        if let AudioConsumerRequest::WatchStatus { responder } = self {
5027            Some((responder))
5028        } else {
5029            None
5030        }
5031    }
5032
5033    /// Name of the method defined in FIDL
5034    pub fn method_name(&self) -> &'static str {
5035        match *self {
5036            AudioConsumerRequest::CreateStreamSink { .. } => "create_stream_sink",
5037            AudioConsumerRequest::Start { .. } => "start",
5038            AudioConsumerRequest::Stop { .. } => "stop",
5039            AudioConsumerRequest::SetRate { .. } => "set_rate",
5040            AudioConsumerRequest::BindVolumeControl { .. } => "bind_volume_control",
5041            AudioConsumerRequest::WatchStatus { .. } => "watch_status",
5042        }
5043    }
5044}
5045
5046#[derive(Debug, Clone)]
5047pub struct AudioConsumerControlHandle {
5048    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5049}
5050
5051impl AudioConsumerControlHandle {
5052    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5053        self.inner.shutdown_with_epitaph(status.into())
5054    }
5055}
5056
5057impl fidl::endpoints::ControlHandle for AudioConsumerControlHandle {
5058    fn shutdown(&self) {
5059        self.inner.shutdown()
5060    }
5061
5062    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5063        self.inner.shutdown_with_epitaph(status)
5064    }
5065
5066    fn is_closed(&self) -> bool {
5067        self.inner.channel().is_closed()
5068    }
5069    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5070        self.inner.channel().on_closed()
5071    }
5072
5073    #[cfg(target_os = "fuchsia")]
5074    fn signal_peer(
5075        &self,
5076        clear_mask: zx::Signals,
5077        set_mask: zx::Signals,
5078    ) -> Result<(), zx_status::Status> {
5079        use fidl::Peered;
5080        self.inner.channel().signal_peer(clear_mask, set_mask)
5081    }
5082}
5083
5084impl AudioConsumerControlHandle {
5085    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
5086        self.inner.send::<fidl::encoding::EmptyPayload>(
5087            (),
5088            0,
5089            0x53a64e6d0e8f8a20,
5090            fidl::encoding::DynamicFlags::empty(),
5091        )
5092    }
5093}
5094
5095#[must_use = "FIDL methods require a response to be sent"]
5096#[derive(Debug)]
5097pub struct AudioConsumerWatchStatusResponder {
5098    control_handle: std::mem::ManuallyDrop<AudioConsumerControlHandle>,
5099    tx_id: u32,
5100}
5101
5102/// Set the the channel to be shutdown (see [`AudioConsumerControlHandle::shutdown`])
5103/// if the responder is dropped without sending a response, so that the client
5104/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5105impl std::ops::Drop for AudioConsumerWatchStatusResponder {
5106    fn drop(&mut self) {
5107        self.control_handle.shutdown();
5108        // Safety: drops once, never accessed again
5109        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5110    }
5111}
5112
5113impl fidl::endpoints::Responder for AudioConsumerWatchStatusResponder {
5114    type ControlHandle = AudioConsumerControlHandle;
5115
5116    fn control_handle(&self) -> &AudioConsumerControlHandle {
5117        &self.control_handle
5118    }
5119
5120    fn drop_without_shutdown(mut self) {
5121        // Safety: drops once, never accessed again due to mem::forget
5122        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5123        // Prevent Drop from running (which would shut down the channel)
5124        std::mem::forget(self);
5125    }
5126}
5127
5128impl AudioConsumerWatchStatusResponder {
5129    /// Sends a response to the FIDL transaction.
5130    ///
5131    /// Sets the channel to shutdown if an error occurs.
5132    pub fn send(self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
5133        let _result = self.send_raw(status);
5134        if _result.is_err() {
5135            self.control_handle.shutdown();
5136        }
5137        self.drop_without_shutdown();
5138        _result
5139    }
5140
5141    /// Similar to "send" but does not shutdown the channel if an error occurs.
5142    pub fn send_no_shutdown_on_err(
5143        self,
5144        mut status: &AudioConsumerStatus,
5145    ) -> Result<(), fidl::Error> {
5146        let _result = self.send_raw(status);
5147        self.drop_without_shutdown();
5148        _result
5149    }
5150
5151    fn send_raw(&self, mut status: &AudioConsumerStatus) -> Result<(), fidl::Error> {
5152        self.control_handle.inner.send::<AudioConsumerWatchStatusResponse>(
5153            (status,),
5154            self.tx_id,
5155            0x35cf702c721e2cc6,
5156            fidl::encoding::DynamicFlags::empty(),
5157        )
5158    }
5159}
5160
5161#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5162pub struct AudioCoreMarker;
5163
5164impl fidl::endpoints::ProtocolMarker for AudioCoreMarker {
5165    type Proxy = AudioCoreProxy;
5166    type RequestStream = AudioCoreRequestStream;
5167    #[cfg(target_os = "fuchsia")]
5168    type SynchronousProxy = AudioCoreSynchronousProxy;
5169
5170    const DEBUG_NAME: &'static str = "fuchsia.media.AudioCore";
5171}
5172impl fidl::endpoints::DiscoverableProtocolMarker for AudioCoreMarker {}
5173
5174pub trait AudioCoreProxyInterface: Send + Sync {
5175    fn r#create_audio_renderer(
5176        &self,
5177        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5178    ) -> Result<(), fidl::Error>;
5179    fn r#create_audio_capturer_with_configuration(
5180        &self,
5181        stream_type: &AudioStreamType,
5182        configuration: &AudioCapturerConfiguration,
5183        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5184    ) -> Result<(), fidl::Error>;
5185    fn r#create_audio_capturer(
5186        &self,
5187        loopback: bool,
5188        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5189    ) -> Result<(), fidl::Error>;
5190    fn r#set_render_usage_gain(
5191        &self,
5192        usage: AudioRenderUsage,
5193        gain_db: f32,
5194    ) -> Result<(), fidl::Error>;
5195    fn r#set_render_usage_gain2(
5196        &self,
5197        usage: AudioRenderUsage2,
5198        gain_db: f32,
5199    ) -> Result<(), fidl::Error>;
5200    fn r#set_capture_usage_gain(
5201        &self,
5202        usage: AudioCaptureUsage,
5203        gain_db: f32,
5204    ) -> Result<(), fidl::Error>;
5205    fn r#set_capture_usage_gain2(
5206        &self,
5207        usage: AudioCaptureUsage2,
5208        gain_db: f32,
5209    ) -> Result<(), fidl::Error>;
5210    fn r#bind_usage_volume_control(
5211        &self,
5212        usage: &Usage,
5213        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
5214    ) -> Result<(), fidl::Error>;
5215    fn r#bind_usage_volume_control2(
5216        &self,
5217        usage: &Usage2,
5218        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
5219    ) -> Result<(), fidl::Error>;
5220    type GetVolumeFromDbResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5221    fn r#get_volume_from_db(&self, usage: &Usage, gain_db: f32)
5222    -> Self::GetVolumeFromDbResponseFut;
5223    type GetVolumeFromDb2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5224    fn r#get_volume_from_db2(
5225        &self,
5226        usage: &Usage2,
5227        gain_db: f32,
5228    ) -> Self::GetVolumeFromDb2ResponseFut;
5229    type GetDbFromVolumeResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5230    fn r#get_db_from_volume(&self, usage: &Usage, volume: f32) -> Self::GetDbFromVolumeResponseFut;
5231    type GetDbFromVolume2ResponseFut: std::future::Future<Output = Result<f32, fidl::Error>> + Send;
5232    fn r#get_db_from_volume2(
5233        &self,
5234        usage: &Usage2,
5235        volume: f32,
5236    ) -> Self::GetDbFromVolume2ResponseFut;
5237    fn r#set_interaction(
5238        &self,
5239        active: &Usage,
5240        affected: &Usage,
5241        behavior: Behavior,
5242    ) -> Result<(), fidl::Error>;
5243    fn r#set_interaction2(
5244        &self,
5245        active: &Usage2,
5246        affected: &Usage2,
5247        behavior: Behavior,
5248    ) -> Result<(), fidl::Error>;
5249    fn r#reset_interactions(&self) -> Result<(), fidl::Error>;
5250    fn r#load_defaults(&self) -> Result<(), fidl::Error>;
5251}
5252#[derive(Debug)]
5253#[cfg(target_os = "fuchsia")]
5254pub struct AudioCoreSynchronousProxy {
5255    client: fidl::client::sync::Client,
5256}
5257
5258#[cfg(target_os = "fuchsia")]
5259impl fidl::endpoints::SynchronousProxy for AudioCoreSynchronousProxy {
5260    type Proxy = AudioCoreProxy;
5261    type Protocol = AudioCoreMarker;
5262
5263    fn from_channel(inner: fidl::Channel) -> Self {
5264        Self::new(inner)
5265    }
5266
5267    fn into_channel(self) -> fidl::Channel {
5268        self.client.into_channel()
5269    }
5270
5271    fn as_channel(&self) -> &fidl::Channel {
5272        self.client.as_channel()
5273    }
5274}
5275
5276#[cfg(target_os = "fuchsia")]
5277impl AudioCoreSynchronousProxy {
5278    pub fn new(channel: fidl::Channel) -> Self {
5279        Self { client: fidl::client::sync::Client::new(channel) }
5280    }
5281
5282    pub fn into_channel(self) -> fidl::Channel {
5283        self.client.into_channel()
5284    }
5285
5286    /// Waits until an event arrives and returns it. It is safe for other
5287    /// threads to make concurrent requests while waiting for an event.
5288    pub fn wait_for_event(
5289        &self,
5290        deadline: zx::MonotonicInstant,
5291    ) -> Result<AudioCoreEvent, fidl::Error> {
5292        AudioCoreEvent::decode(self.client.wait_for_event::<AudioCoreMarker>(deadline)?)
5293    }
5294
5295    /// Creates an AudioRenderer which outputs audio to the default device.
5296    pub fn r#create_audio_renderer(
5297        &self,
5298        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5299    ) -> Result<(), fidl::Error> {
5300        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5301            (audio_out_request,),
5302            0x2ac9beba47f83435,
5303            fidl::encoding::DynamicFlags::empty(),
5304        )
5305    }
5306
5307    /// Creates an AudioCapturer according to the given requirements.
5308    ///
5309    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5310    /// It causes the source material to be reformatted/resampled if needed
5311    /// in order to produce the requested stream type.
5312    ///
5313    /// `usage` is used by Fuchsia to make decisions about user experience.
5314    /// See `AudioCaptureUsage` for more details.
5315    ///
5316    /// `configuration` must be initialized to a variant, or no capturer
5317    /// can be created.
5318    pub fn r#create_audio_capturer_with_configuration(
5319        &self,
5320        mut stream_type: &AudioStreamType,
5321        mut configuration: &AudioCapturerConfiguration,
5322        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5323    ) -> Result<(), fidl::Error> {
5324        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5325            (stream_type, configuration, audio_capturer_request),
5326            0x459de383b0d76d97,
5327            fidl::encoding::DynamicFlags::empty(),
5328        )
5329    }
5330
5331    /// Creates an AudioCapturer which either captures from the current default
5332    /// audio input device, or loops-back from the current default audio output
5333    /// device based on value passed for the loopback flag.
5334    pub fn r#create_audio_capturer(
5335        &self,
5336        mut loopback: bool,
5337        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5338    ) -> Result<(), fidl::Error> {
5339        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5340            (loopback, audio_in_request),
5341            0x787db169df99aed0,
5342            fidl::encoding::DynamicFlags::empty(),
5343        )
5344    }
5345
5346    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5347    pub fn r#set_render_usage_gain(
5348        &self,
5349        mut usage: AudioRenderUsage,
5350        mut gain_db: f32,
5351    ) -> Result<(), fidl::Error> {
5352        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5353            (usage, gain_db),
5354            0x48097f45f6e2b8e7,
5355            fidl::encoding::DynamicFlags::empty(),
5356        )
5357    }
5358
5359    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5360    pub fn r#set_render_usage_gain2(
5361        &self,
5362        mut usage: AudioRenderUsage2,
5363        mut gain_db: f32,
5364    ) -> Result<(), fidl::Error> {
5365        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5366            (usage, gain_db),
5367            0x779b1531dc9e64f4,
5368            fidl::encoding::DynamicFlags::FLEXIBLE,
5369        )
5370    }
5371
5372    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5373    pub fn r#set_capture_usage_gain(
5374        &self,
5375        mut usage: AudioCaptureUsage,
5376        mut gain_db: f32,
5377    ) -> Result<(), fidl::Error> {
5378        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5379            (usage, gain_db),
5380            0x457d29217d4ea248,
5381            fidl::encoding::DynamicFlags::empty(),
5382        )
5383    }
5384
5385    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5386    pub fn r#set_capture_usage_gain2(
5387        &self,
5388        mut usage: AudioCaptureUsage2,
5389        mut gain_db: f32,
5390    ) -> Result<(), fidl::Error> {
5391        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5392            (usage, gain_db),
5393            0x15065ee308f44af0,
5394            fidl::encoding::DynamicFlags::FLEXIBLE,
5395        )
5396    }
5397
5398    /// Binds to a volume control protocol for the given usage.
5399    pub fn r#bind_usage_volume_control(
5400        &self,
5401        mut usage: &Usage,
5402        mut volume_control: fidl::endpoints::ServerEnd<
5403            fidl_fuchsia_media_audio::VolumeControlMarker,
5404        >,
5405    ) -> Result<(), fidl::Error> {
5406        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5407            (usage, volume_control),
5408            0x7225be116aadc137,
5409            fidl::encoding::DynamicFlags::empty(),
5410        )
5411    }
5412
5413    /// Binds to a volume control protocol for the given usage.
5414    pub fn r#bind_usage_volume_control2(
5415        &self,
5416        mut usage: &Usage2,
5417        mut volume_control: fidl::endpoints::ServerEnd<
5418            fidl_fuchsia_media_audio::VolumeControlMarker,
5419        >,
5420    ) -> Result<(), fidl::Error> {
5421        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5422            (usage, volume_control),
5423            0x729dff93019d055,
5424            fidl::encoding::DynamicFlags::FLEXIBLE,
5425        )
5426    }
5427
5428    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5429    /// `usage`. This is the same mapping as used by the VolumeControl from
5430    /// `BindUsageVolumeControl`.
5431    pub fn r#get_volume_from_db(
5432        &self,
5433        mut usage: &Usage,
5434        mut gain_db: f32,
5435        ___deadline: zx::MonotonicInstant,
5436    ) -> Result<f32, fidl::Error> {
5437        let _response = self.client.send_query::<
5438            AudioCoreGetVolumeFromDbRequest,
5439            AudioCoreGetVolumeFromDbResponse,
5440            AudioCoreMarker,
5441        >(
5442            (usage, gain_db,),
5443            0x50e3ca45509770bf,
5444            fidl::encoding::DynamicFlags::empty(),
5445            ___deadline,
5446        )?;
5447        Ok(_response.volume)
5448    }
5449
5450    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5451    /// `usage`. This is the same mapping as used by the VolumeControl from
5452    /// `BindUsageVolumeControl`.
5453    pub fn r#get_volume_from_db2(
5454        &self,
5455        mut usage: &Usage2,
5456        mut gain_db: f32,
5457        ___deadline: zx::MonotonicInstant,
5458    ) -> Result<f32, fidl::Error> {
5459        let _response = self.client.send_query::<
5460            AudioCoreGetVolumeFromDb2Request,
5461            fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5462            AudioCoreMarker,
5463        >(
5464            (usage, gain_db,),
5465            0x165c811091ef99da,
5466            fidl::encoding::DynamicFlags::FLEXIBLE,
5467            ___deadline,
5468        )?
5469        .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5470        Ok(_response.volume)
5471    }
5472
5473    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5474    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5475    pub fn r#get_db_from_volume(
5476        &self,
5477        mut usage: &Usage,
5478        mut volume: f32,
5479        ___deadline: zx::MonotonicInstant,
5480    ) -> Result<f32, fidl::Error> {
5481        let _response = self.client.send_query::<
5482            AudioCoreGetDbFromVolumeRequest,
5483            AudioCoreGetDbFromVolumeResponse,
5484            AudioCoreMarker,
5485        >(
5486            (usage, volume,),
5487            0x3e8eec27dd5a8bda,
5488            fidl::encoding::DynamicFlags::empty(),
5489            ___deadline,
5490        )?;
5491        Ok(_response.gain_db)
5492    }
5493
5494    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5495    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5496    pub fn r#get_db_from_volume2(
5497        &self,
5498        mut usage: &Usage2,
5499        mut volume: f32,
5500        ___deadline: zx::MonotonicInstant,
5501    ) -> Result<f32, fidl::Error> {
5502        let _response = self.client.send_query::<
5503            AudioCoreGetDbFromVolume2Request,
5504            fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
5505            AudioCoreMarker,
5506        >(
5507            (usage, volume,),
5508            0x5f421a8ebf265bf3,
5509            fidl::encoding::DynamicFlags::FLEXIBLE,
5510            ___deadline,
5511        )?
5512        .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
5513        Ok(_response.gain_db)
5514    }
5515
5516    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5517    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5518    /// the Behavior specified will be applied to the streams of Usage `affected`.
5519    pub fn r#set_interaction(
5520        &self,
5521        mut active: &Usage,
5522        mut affected: &Usage,
5523        mut behavior: Behavior,
5524    ) -> Result<(), fidl::Error> {
5525        self.client.send::<AudioCoreSetInteractionRequest>(
5526            (active, affected, behavior),
5527            0x7bfed14345ece7b7,
5528            fidl::encoding::DynamicFlags::empty(),
5529        )
5530    }
5531
5532    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5533    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5534    /// the Behavior specified will be applied to the streams of Usage `affected`.
5535    pub fn r#set_interaction2(
5536        &self,
5537        mut active: &Usage2,
5538        mut affected: &Usage2,
5539        mut behavior: Behavior,
5540    ) -> Result<(), fidl::Error> {
5541        self.client.send::<AudioCoreSetInteraction2Request>(
5542            (active, affected, behavior),
5543            0x7226c7c6e6edc62f,
5544            fidl::encoding::DynamicFlags::FLEXIBLE,
5545        )
5546    }
5547
5548    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5549    /// audio_core. The default behavior is 'NONE'.
5550    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5551        self.client.send::<fidl::encoding::EmptyPayload>(
5552            (),
5553            0x65bd94d9d0a28b5e,
5554            fidl::encoding::DynamicFlags::empty(),
5555        )
5556    }
5557
5558    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5559    /// does not provide a config.
5560    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5561        self.client.send::<fidl::encoding::EmptyPayload>(
5562            (),
5563            0x54a0bebca85f6b31,
5564            fidl::encoding::DynamicFlags::empty(),
5565        )
5566    }
5567}
5568
5569#[cfg(target_os = "fuchsia")]
5570impl From<AudioCoreSynchronousProxy> for zx::NullableHandle {
5571    fn from(value: AudioCoreSynchronousProxy) -> Self {
5572        value.into_channel().into()
5573    }
5574}
5575
5576#[cfg(target_os = "fuchsia")]
5577impl From<fidl::Channel> for AudioCoreSynchronousProxy {
5578    fn from(value: fidl::Channel) -> Self {
5579        Self::new(value)
5580    }
5581}
5582
5583#[cfg(target_os = "fuchsia")]
5584impl fidl::endpoints::FromClient for AudioCoreSynchronousProxy {
5585    type Protocol = AudioCoreMarker;
5586
5587    fn from_client(value: fidl::endpoints::ClientEnd<AudioCoreMarker>) -> Self {
5588        Self::new(value.into_channel())
5589    }
5590}
5591
5592#[derive(Debug, Clone)]
5593pub struct AudioCoreProxy {
5594    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5595}
5596
5597impl fidl::endpoints::Proxy for AudioCoreProxy {
5598    type Protocol = AudioCoreMarker;
5599
5600    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5601        Self::new(inner)
5602    }
5603
5604    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5605        self.client.into_channel().map_err(|client| Self { client })
5606    }
5607
5608    fn as_channel(&self) -> &::fidl::AsyncChannel {
5609        self.client.as_channel()
5610    }
5611}
5612
5613impl AudioCoreProxy {
5614    /// Create a new Proxy for fuchsia.media/AudioCore.
5615    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5616        let protocol_name = <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5617        Self { client: fidl::client::Client::new(channel, protocol_name) }
5618    }
5619
5620    /// Get a Stream of events from the remote end of the protocol.
5621    ///
5622    /// # Panics
5623    ///
5624    /// Panics if the event stream was already taken.
5625    pub fn take_event_stream(&self) -> AudioCoreEventStream {
5626        AudioCoreEventStream { event_receiver: self.client.take_event_receiver() }
5627    }
5628
5629    /// Creates an AudioRenderer which outputs audio to the default device.
5630    pub fn r#create_audio_renderer(
5631        &self,
5632        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5633    ) -> Result<(), fidl::Error> {
5634        AudioCoreProxyInterface::r#create_audio_renderer(self, audio_out_request)
5635    }
5636
5637    /// Creates an AudioCapturer according to the given requirements.
5638    ///
5639    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
5640    /// It causes the source material to be reformatted/resampled if needed
5641    /// in order to produce the requested stream type.
5642    ///
5643    /// `usage` is used by Fuchsia to make decisions about user experience.
5644    /// See `AudioCaptureUsage` for more details.
5645    ///
5646    /// `configuration` must be initialized to a variant, or no capturer
5647    /// can be created.
5648    pub fn r#create_audio_capturer_with_configuration(
5649        &self,
5650        mut stream_type: &AudioStreamType,
5651        mut configuration: &AudioCapturerConfiguration,
5652        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5653    ) -> Result<(), fidl::Error> {
5654        AudioCoreProxyInterface::r#create_audio_capturer_with_configuration(
5655            self,
5656            stream_type,
5657            configuration,
5658            audio_capturer_request,
5659        )
5660    }
5661
5662    /// Creates an AudioCapturer which either captures from the current default
5663    /// audio input device, or loops-back from the current default audio output
5664    /// device based on value passed for the loopback flag.
5665    pub fn r#create_audio_capturer(
5666        &self,
5667        mut loopback: bool,
5668        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5669    ) -> Result<(), fidl::Error> {
5670        AudioCoreProxyInterface::r#create_audio_capturer(self, loopback, audio_in_request)
5671    }
5672
5673    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5674    pub fn r#set_render_usage_gain(
5675        &self,
5676        mut usage: AudioRenderUsage,
5677        mut gain_db: f32,
5678    ) -> Result<(), fidl::Error> {
5679        AudioCoreProxyInterface::r#set_render_usage_gain(self, usage, gain_db)
5680    }
5681
5682    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
5683    pub fn r#set_render_usage_gain2(
5684        &self,
5685        mut usage: AudioRenderUsage2,
5686        mut gain_db: f32,
5687    ) -> Result<(), fidl::Error> {
5688        AudioCoreProxyInterface::r#set_render_usage_gain2(self, usage, gain_db)
5689    }
5690
5691    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5692    pub fn r#set_capture_usage_gain(
5693        &self,
5694        mut usage: AudioCaptureUsage,
5695        mut gain_db: f32,
5696    ) -> Result<(), fidl::Error> {
5697        AudioCoreProxyInterface::r#set_capture_usage_gain(self, usage, gain_db)
5698    }
5699
5700    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
5701    pub fn r#set_capture_usage_gain2(
5702        &self,
5703        mut usage: AudioCaptureUsage2,
5704        mut gain_db: f32,
5705    ) -> Result<(), fidl::Error> {
5706        AudioCoreProxyInterface::r#set_capture_usage_gain2(self, usage, gain_db)
5707    }
5708
5709    /// Binds to a volume control protocol for the given usage.
5710    pub fn r#bind_usage_volume_control(
5711        &self,
5712        mut usage: &Usage,
5713        mut volume_control: fidl::endpoints::ServerEnd<
5714            fidl_fuchsia_media_audio::VolumeControlMarker,
5715        >,
5716    ) -> Result<(), fidl::Error> {
5717        AudioCoreProxyInterface::r#bind_usage_volume_control(self, usage, volume_control)
5718    }
5719
5720    /// Binds to a volume control protocol for the given usage.
5721    pub fn r#bind_usage_volume_control2(
5722        &self,
5723        mut usage: &Usage2,
5724        mut volume_control: fidl::endpoints::ServerEnd<
5725            fidl_fuchsia_media_audio::VolumeControlMarker,
5726        >,
5727    ) -> Result<(), fidl::Error> {
5728        AudioCoreProxyInterface::r#bind_usage_volume_control2(self, usage, volume_control)
5729    }
5730
5731    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5732    /// `usage`. This is the same mapping as used by the VolumeControl from
5733    /// `BindUsageVolumeControl`.
5734    pub fn r#get_volume_from_db(
5735        &self,
5736        mut usage: &Usage,
5737        mut gain_db: f32,
5738    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5739        AudioCoreProxyInterface::r#get_volume_from_db(self, usage, gain_db)
5740    }
5741
5742    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
5743    /// `usage`. This is the same mapping as used by the VolumeControl from
5744    /// `BindUsageVolumeControl`.
5745    pub fn r#get_volume_from_db2(
5746        &self,
5747        mut usage: &Usage2,
5748        mut gain_db: f32,
5749    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5750        AudioCoreProxyInterface::r#get_volume_from_db2(self, usage, gain_db)
5751    }
5752
5753    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5754    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5755    pub fn r#get_db_from_volume(
5756        &self,
5757        mut usage: &Usage,
5758        mut volume: f32,
5759    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5760        AudioCoreProxyInterface::r#get_db_from_volume(self, usage, volume)
5761    }
5762
5763    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
5764    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
5765    pub fn r#get_db_from_volume2(
5766        &self,
5767        mut usage: &Usage2,
5768        mut volume: f32,
5769    ) -> fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect> {
5770        AudioCoreProxyInterface::r#get_db_from_volume2(self, usage, volume)
5771    }
5772
5773    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5774    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5775    /// the Behavior specified will be applied to the streams of Usage `affected`.
5776    pub fn r#set_interaction(
5777        &self,
5778        mut active: &Usage,
5779        mut affected: &Usage,
5780        mut behavior: Behavior,
5781    ) -> Result<(), fidl::Error> {
5782        AudioCoreProxyInterface::r#set_interaction(self, active, affected, behavior)
5783    }
5784
5785    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
5786    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
5787    /// the Behavior specified will be applied to the streams of Usage `affected`.
5788    pub fn r#set_interaction2(
5789        &self,
5790        mut active: &Usage2,
5791        mut affected: &Usage2,
5792        mut behavior: Behavior,
5793    ) -> Result<(), fidl::Error> {
5794        AudioCoreProxyInterface::r#set_interaction2(self, active, affected, behavior)
5795    }
5796
5797    /// Re-initializes the set of rules that are currently governing the interaction of streams in
5798    /// audio_core. The default behavior is 'NONE'.
5799    pub fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
5800        AudioCoreProxyInterface::r#reset_interactions(self)
5801    }
5802
5803    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
5804    /// does not provide a config.
5805    pub fn r#load_defaults(&self) -> Result<(), fidl::Error> {
5806        AudioCoreProxyInterface::r#load_defaults(self)
5807    }
5808}
5809
5810impl AudioCoreProxyInterface for AudioCoreProxy {
5811    fn r#create_audio_renderer(
5812        &self,
5813        mut audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
5814    ) -> Result<(), fidl::Error> {
5815        self.client.send::<AudioCoreCreateAudioRendererRequest>(
5816            (audio_out_request,),
5817            0x2ac9beba47f83435,
5818            fidl::encoding::DynamicFlags::empty(),
5819        )
5820    }
5821
5822    fn r#create_audio_capturer_with_configuration(
5823        &self,
5824        mut stream_type: &AudioStreamType,
5825        mut configuration: &AudioCapturerConfiguration,
5826        mut audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5827    ) -> Result<(), fidl::Error> {
5828        self.client.send::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(
5829            (stream_type, configuration, audio_capturer_request),
5830            0x459de383b0d76d97,
5831            fidl::encoding::DynamicFlags::empty(),
5832        )
5833    }
5834
5835    fn r#create_audio_capturer(
5836        &self,
5837        mut loopback: bool,
5838        mut audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
5839    ) -> Result<(), fidl::Error> {
5840        self.client.send::<AudioCoreCreateAudioCapturerRequest>(
5841            (loopback, audio_in_request),
5842            0x787db169df99aed0,
5843            fidl::encoding::DynamicFlags::empty(),
5844        )
5845    }
5846
5847    fn r#set_render_usage_gain(
5848        &self,
5849        mut usage: AudioRenderUsage,
5850        mut gain_db: f32,
5851    ) -> Result<(), fidl::Error> {
5852        self.client.send::<AudioCoreSetRenderUsageGainRequest>(
5853            (usage, gain_db),
5854            0x48097f45f6e2b8e7,
5855            fidl::encoding::DynamicFlags::empty(),
5856        )
5857    }
5858
5859    fn r#set_render_usage_gain2(
5860        &self,
5861        mut usage: AudioRenderUsage2,
5862        mut gain_db: f32,
5863    ) -> Result<(), fidl::Error> {
5864        self.client.send::<AudioCoreSetRenderUsageGain2Request>(
5865            (usage, gain_db),
5866            0x779b1531dc9e64f4,
5867            fidl::encoding::DynamicFlags::FLEXIBLE,
5868        )
5869    }
5870
5871    fn r#set_capture_usage_gain(
5872        &self,
5873        mut usage: AudioCaptureUsage,
5874        mut gain_db: f32,
5875    ) -> Result<(), fidl::Error> {
5876        self.client.send::<AudioCoreSetCaptureUsageGainRequest>(
5877            (usage, gain_db),
5878            0x457d29217d4ea248,
5879            fidl::encoding::DynamicFlags::empty(),
5880        )
5881    }
5882
5883    fn r#set_capture_usage_gain2(
5884        &self,
5885        mut usage: AudioCaptureUsage2,
5886        mut gain_db: f32,
5887    ) -> Result<(), fidl::Error> {
5888        self.client.send::<AudioCoreSetCaptureUsageGain2Request>(
5889            (usage, gain_db),
5890            0x15065ee308f44af0,
5891            fidl::encoding::DynamicFlags::FLEXIBLE,
5892        )
5893    }
5894
5895    fn r#bind_usage_volume_control(
5896        &self,
5897        mut usage: &Usage,
5898        mut volume_control: fidl::endpoints::ServerEnd<
5899            fidl_fuchsia_media_audio::VolumeControlMarker,
5900        >,
5901    ) -> Result<(), fidl::Error> {
5902        self.client.send::<AudioCoreBindUsageVolumeControlRequest>(
5903            (usage, volume_control),
5904            0x7225be116aadc137,
5905            fidl::encoding::DynamicFlags::empty(),
5906        )
5907    }
5908
5909    fn r#bind_usage_volume_control2(
5910        &self,
5911        mut usage: &Usage2,
5912        mut volume_control: fidl::endpoints::ServerEnd<
5913            fidl_fuchsia_media_audio::VolumeControlMarker,
5914        >,
5915    ) -> Result<(), fidl::Error> {
5916        self.client.send::<AudioCoreBindUsageVolumeControl2Request>(
5917            (usage, volume_control),
5918            0x729dff93019d055,
5919            fidl::encoding::DynamicFlags::FLEXIBLE,
5920        )
5921    }
5922
5923    type GetVolumeFromDbResponseFut =
5924        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5925    fn r#get_volume_from_db(
5926        &self,
5927        mut usage: &Usage,
5928        mut gain_db: f32,
5929    ) -> Self::GetVolumeFromDbResponseFut {
5930        fn _decode(
5931            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5932        ) -> Result<f32, fidl::Error> {
5933            let _response = fidl::client::decode_transaction_body::<
5934                AudioCoreGetVolumeFromDbResponse,
5935                fidl::encoding::DefaultFuchsiaResourceDialect,
5936                0x50e3ca45509770bf,
5937            >(_buf?)?;
5938            Ok(_response.volume)
5939        }
5940        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDbRequest, f32>(
5941            (usage, gain_db),
5942            0x50e3ca45509770bf,
5943            fidl::encoding::DynamicFlags::empty(),
5944            _decode,
5945        )
5946    }
5947
5948    type GetVolumeFromDb2ResponseFut =
5949        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5950    fn r#get_volume_from_db2(
5951        &self,
5952        mut usage: &Usage2,
5953        mut gain_db: f32,
5954    ) -> Self::GetVolumeFromDb2ResponseFut {
5955        fn _decode(
5956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5957        ) -> Result<f32, fidl::Error> {
5958            let _response = fidl::client::decode_transaction_body::<
5959                fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>,
5960                fidl::encoding::DefaultFuchsiaResourceDialect,
5961                0x165c811091ef99da,
5962            >(_buf?)?
5963            .into_result::<AudioCoreMarker>("get_volume_from_db2")?;
5964            Ok(_response.volume)
5965        }
5966        self.client.send_query_and_decode::<AudioCoreGetVolumeFromDb2Request, f32>(
5967            (usage, gain_db),
5968            0x165c811091ef99da,
5969            fidl::encoding::DynamicFlags::FLEXIBLE,
5970            _decode,
5971        )
5972    }
5973
5974    type GetDbFromVolumeResponseFut =
5975        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
5976    fn r#get_db_from_volume(
5977        &self,
5978        mut usage: &Usage,
5979        mut volume: f32,
5980    ) -> Self::GetDbFromVolumeResponseFut {
5981        fn _decode(
5982            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5983        ) -> Result<f32, fidl::Error> {
5984            let _response = fidl::client::decode_transaction_body::<
5985                AudioCoreGetDbFromVolumeResponse,
5986                fidl::encoding::DefaultFuchsiaResourceDialect,
5987                0x3e8eec27dd5a8bda,
5988            >(_buf?)?;
5989            Ok(_response.gain_db)
5990        }
5991        self.client.send_query_and_decode::<AudioCoreGetDbFromVolumeRequest, f32>(
5992            (usage, volume),
5993            0x3e8eec27dd5a8bda,
5994            fidl::encoding::DynamicFlags::empty(),
5995            _decode,
5996        )
5997    }
5998
5999    type GetDbFromVolume2ResponseFut =
6000        fidl::client::QueryResponseFut<f32, fidl::encoding::DefaultFuchsiaResourceDialect>;
6001    fn r#get_db_from_volume2(
6002        &self,
6003        mut usage: &Usage2,
6004        mut volume: f32,
6005    ) -> Self::GetDbFromVolume2ResponseFut {
6006        fn _decode(
6007            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6008        ) -> Result<f32, fidl::Error> {
6009            let _response = fidl::client::decode_transaction_body::<
6010                fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>,
6011                fidl::encoding::DefaultFuchsiaResourceDialect,
6012                0x5f421a8ebf265bf3,
6013            >(_buf?)?
6014            .into_result::<AudioCoreMarker>("get_db_from_volume2")?;
6015            Ok(_response.gain_db)
6016        }
6017        self.client.send_query_and_decode::<AudioCoreGetDbFromVolume2Request, f32>(
6018            (usage, volume),
6019            0x5f421a8ebf265bf3,
6020            fidl::encoding::DynamicFlags::FLEXIBLE,
6021            _decode,
6022        )
6023    }
6024
6025    fn r#set_interaction(
6026        &self,
6027        mut active: &Usage,
6028        mut affected: &Usage,
6029        mut behavior: Behavior,
6030    ) -> Result<(), fidl::Error> {
6031        self.client.send::<AudioCoreSetInteractionRequest>(
6032            (active, affected, behavior),
6033            0x7bfed14345ece7b7,
6034            fidl::encoding::DynamicFlags::empty(),
6035        )
6036    }
6037
6038    fn r#set_interaction2(
6039        &self,
6040        mut active: &Usage2,
6041        mut affected: &Usage2,
6042        mut behavior: Behavior,
6043    ) -> Result<(), fidl::Error> {
6044        self.client.send::<AudioCoreSetInteraction2Request>(
6045            (active, affected, behavior),
6046            0x7226c7c6e6edc62f,
6047            fidl::encoding::DynamicFlags::FLEXIBLE,
6048        )
6049    }
6050
6051    fn r#reset_interactions(&self) -> Result<(), fidl::Error> {
6052        self.client.send::<fidl::encoding::EmptyPayload>(
6053            (),
6054            0x65bd94d9d0a28b5e,
6055            fidl::encoding::DynamicFlags::empty(),
6056        )
6057    }
6058
6059    fn r#load_defaults(&self) -> Result<(), fidl::Error> {
6060        self.client.send::<fidl::encoding::EmptyPayload>(
6061            (),
6062            0x54a0bebca85f6b31,
6063            fidl::encoding::DynamicFlags::empty(),
6064        )
6065    }
6066}
6067
6068pub struct AudioCoreEventStream {
6069    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6070}
6071
6072impl std::marker::Unpin for AudioCoreEventStream {}
6073
6074impl futures::stream::FusedStream for AudioCoreEventStream {
6075    fn is_terminated(&self) -> bool {
6076        self.event_receiver.is_terminated()
6077    }
6078}
6079
6080impl futures::Stream for AudioCoreEventStream {
6081    type Item = Result<AudioCoreEvent, fidl::Error>;
6082
6083    fn poll_next(
6084        mut self: std::pin::Pin<&mut Self>,
6085        cx: &mut std::task::Context<'_>,
6086    ) -> std::task::Poll<Option<Self::Item>> {
6087        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6088            &mut self.event_receiver,
6089            cx
6090        )?) {
6091            Some(buf) => std::task::Poll::Ready(Some(AudioCoreEvent::decode(buf))),
6092            None => std::task::Poll::Ready(None),
6093        }
6094    }
6095}
6096
6097#[derive(Debug)]
6098pub enum AudioCoreEvent {
6099    #[non_exhaustive]
6100    _UnknownEvent {
6101        /// Ordinal of the event that was sent.
6102        ordinal: u64,
6103    },
6104}
6105
6106impl AudioCoreEvent {
6107    /// Decodes a message buffer as a [`AudioCoreEvent`].
6108    fn decode(
6109        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6110    ) -> Result<AudioCoreEvent, fidl::Error> {
6111        let (bytes, _handles) = buf.split_mut();
6112        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6113        debug_assert_eq!(tx_header.tx_id, 0);
6114        match tx_header.ordinal {
6115            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
6116                Ok(AudioCoreEvent::_UnknownEvent { ordinal: tx_header.ordinal })
6117            }
6118            _ => Err(fidl::Error::UnknownOrdinal {
6119                ordinal: tx_header.ordinal,
6120                protocol_name: <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6121            }),
6122        }
6123    }
6124}
6125
6126/// A Stream of incoming requests for fuchsia.media/AudioCore.
6127pub struct AudioCoreRequestStream {
6128    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6129    is_terminated: bool,
6130}
6131
6132impl std::marker::Unpin for AudioCoreRequestStream {}
6133
6134impl futures::stream::FusedStream for AudioCoreRequestStream {
6135    fn is_terminated(&self) -> bool {
6136        self.is_terminated
6137    }
6138}
6139
6140impl fidl::endpoints::RequestStream for AudioCoreRequestStream {
6141    type Protocol = AudioCoreMarker;
6142    type ControlHandle = AudioCoreControlHandle;
6143
6144    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6145        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6146    }
6147
6148    fn control_handle(&self) -> Self::ControlHandle {
6149        AudioCoreControlHandle { inner: self.inner.clone() }
6150    }
6151
6152    fn into_inner(
6153        self,
6154    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6155    {
6156        (self.inner, self.is_terminated)
6157    }
6158
6159    fn from_inner(
6160        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6161        is_terminated: bool,
6162    ) -> Self {
6163        Self { inner, is_terminated }
6164    }
6165}
6166
6167impl futures::Stream for AudioCoreRequestStream {
6168    type Item = Result<AudioCoreRequest, fidl::Error>;
6169
6170    fn poll_next(
6171        mut self: std::pin::Pin<&mut Self>,
6172        cx: &mut std::task::Context<'_>,
6173    ) -> std::task::Poll<Option<Self::Item>> {
6174        let this = &mut *self;
6175        if this.inner.check_shutdown(cx) {
6176            this.is_terminated = true;
6177            return std::task::Poll::Ready(None);
6178        }
6179        if this.is_terminated {
6180            panic!("polled AudioCoreRequestStream after completion");
6181        }
6182        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6183            |bytes, handles| {
6184                match this.inner.channel().read_etc(cx, bytes, handles) {
6185                    std::task::Poll::Ready(Ok(())) => {}
6186                    std::task::Poll::Pending => return std::task::Poll::Pending,
6187                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6188                        this.is_terminated = true;
6189                        return std::task::Poll::Ready(None);
6190                    }
6191                    std::task::Poll::Ready(Err(e)) => {
6192                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6193                            e.into(),
6194                        ))));
6195                    }
6196                }
6197
6198                // A message has been received from the channel
6199                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6200
6201                std::task::Poll::Ready(Some(match header.ordinal {
6202                    0x2ac9beba47f83435 => {
6203                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6204                        let mut req = fidl::new_empty!(
6205                            AudioCoreCreateAudioRendererRequest,
6206                            fidl::encoding::DefaultFuchsiaResourceDialect
6207                        );
6208                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioRendererRequest>(&header, _body_bytes, handles, &mut req)?;
6209                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6210                        Ok(AudioCoreRequest::CreateAudioRenderer {
6211                            audio_out_request: req.audio_out_request,
6212
6213                            control_handle,
6214                        })
6215                    }
6216                    0x459de383b0d76d97 => {
6217                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6218                        let mut req = fidl::new_empty!(
6219                            AudioCoreCreateAudioCapturerWithConfigurationRequest,
6220                            fidl::encoding::DefaultFuchsiaResourceDialect
6221                        );
6222                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(&header, _body_bytes, handles, &mut req)?;
6223                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6224                        Ok(AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6225                            stream_type: req.stream_type,
6226                            configuration: req.configuration,
6227                            audio_capturer_request: req.audio_capturer_request,
6228
6229                            control_handle,
6230                        })
6231                    }
6232                    0x787db169df99aed0 => {
6233                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6234                        let mut req = fidl::new_empty!(
6235                            AudioCoreCreateAudioCapturerRequest,
6236                            fidl::encoding::DefaultFuchsiaResourceDialect
6237                        );
6238                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreCreateAudioCapturerRequest>(&header, _body_bytes, handles, &mut req)?;
6239                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6240                        Ok(AudioCoreRequest::CreateAudioCapturer {
6241                            loopback: req.loopback,
6242                            audio_in_request: req.audio_in_request,
6243
6244                            control_handle,
6245                        })
6246                    }
6247                    0x48097f45f6e2b8e7 => {
6248                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6249                        let mut req = fidl::new_empty!(
6250                            AudioCoreSetRenderUsageGainRequest,
6251                            fidl::encoding::DefaultFuchsiaResourceDialect
6252                        );
6253                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
6254                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6255                        Ok(AudioCoreRequest::SetRenderUsageGain {
6256                            usage: req.usage,
6257                            gain_db: req.gain_db,
6258
6259                            control_handle,
6260                        })
6261                    }
6262                    0x779b1531dc9e64f4 => {
6263                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6264                        let mut req = fidl::new_empty!(
6265                            AudioCoreSetRenderUsageGain2Request,
6266                            fidl::encoding::DefaultFuchsiaResourceDialect
6267                        );
6268                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetRenderUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
6269                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6270                        Ok(AudioCoreRequest::SetRenderUsageGain2 {
6271                            usage: req.usage,
6272                            gain_db: req.gain_db,
6273
6274                            control_handle,
6275                        })
6276                    }
6277                    0x457d29217d4ea248 => {
6278                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6279                        let mut req = fidl::new_empty!(
6280                            AudioCoreSetCaptureUsageGainRequest,
6281                            fidl::encoding::DefaultFuchsiaResourceDialect
6282                        );
6283                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGainRequest>(&header, _body_bytes, handles, &mut req)?;
6284                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6285                        Ok(AudioCoreRequest::SetCaptureUsageGain {
6286                            usage: req.usage,
6287                            gain_db: req.gain_db,
6288
6289                            control_handle,
6290                        })
6291                    }
6292                    0x15065ee308f44af0 => {
6293                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6294                        let mut req = fidl::new_empty!(
6295                            AudioCoreSetCaptureUsageGain2Request,
6296                            fidl::encoding::DefaultFuchsiaResourceDialect
6297                        );
6298                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetCaptureUsageGain2Request>(&header, _body_bytes, handles, &mut req)?;
6299                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6300                        Ok(AudioCoreRequest::SetCaptureUsageGain2 {
6301                            usage: req.usage,
6302                            gain_db: req.gain_db,
6303
6304                            control_handle,
6305                        })
6306                    }
6307                    0x7225be116aadc137 => {
6308                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6309                        let mut req = fidl::new_empty!(
6310                            AudioCoreBindUsageVolumeControlRequest,
6311                            fidl::encoding::DefaultFuchsiaResourceDialect
6312                        );
6313                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControlRequest>(&header, _body_bytes, handles, &mut req)?;
6314                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6315                        Ok(AudioCoreRequest::BindUsageVolumeControl {
6316                            usage: req.usage,
6317                            volume_control: req.volume_control,
6318
6319                            control_handle,
6320                        })
6321                    }
6322                    0x729dff93019d055 => {
6323                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6324                        let mut req = fidl::new_empty!(
6325                            AudioCoreBindUsageVolumeControl2Request,
6326                            fidl::encoding::DefaultFuchsiaResourceDialect
6327                        );
6328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreBindUsageVolumeControl2Request>(&header, _body_bytes, handles, &mut req)?;
6329                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6330                        Ok(AudioCoreRequest::BindUsageVolumeControl2 {
6331                            usage: req.usage,
6332                            volume_control: req.volume_control,
6333
6334                            control_handle,
6335                        })
6336                    }
6337                    0x50e3ca45509770bf => {
6338                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6339                        let mut req = fidl::new_empty!(
6340                            AudioCoreGetVolumeFromDbRequest,
6341                            fidl::encoding::DefaultFuchsiaResourceDialect
6342                        );
6343                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDbRequest>(&header, _body_bytes, handles, &mut req)?;
6344                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6345                        Ok(AudioCoreRequest::GetVolumeFromDb {
6346                            usage: req.usage,
6347                            gain_db: req.gain_db,
6348
6349                            responder: AudioCoreGetVolumeFromDbResponder {
6350                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6351                                tx_id: header.tx_id,
6352                            },
6353                        })
6354                    }
6355                    0x165c811091ef99da => {
6356                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6357                        let mut req = fidl::new_empty!(
6358                            AudioCoreGetVolumeFromDb2Request,
6359                            fidl::encoding::DefaultFuchsiaResourceDialect
6360                        );
6361                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetVolumeFromDb2Request>(&header, _body_bytes, handles, &mut req)?;
6362                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6363                        Ok(AudioCoreRequest::GetVolumeFromDb2 {
6364                            usage: req.usage,
6365                            gain_db: req.gain_db,
6366
6367                            responder: AudioCoreGetVolumeFromDb2Responder {
6368                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6369                                tx_id: header.tx_id,
6370                            },
6371                        })
6372                    }
6373                    0x3e8eec27dd5a8bda => {
6374                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6375                        let mut req = fidl::new_empty!(
6376                            AudioCoreGetDbFromVolumeRequest,
6377                            fidl::encoding::DefaultFuchsiaResourceDialect
6378                        );
6379                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolumeRequest>(&header, _body_bytes, handles, &mut req)?;
6380                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6381                        Ok(AudioCoreRequest::GetDbFromVolume {
6382                            usage: req.usage,
6383                            volume: req.volume,
6384
6385                            responder: AudioCoreGetDbFromVolumeResponder {
6386                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6387                                tx_id: header.tx_id,
6388                            },
6389                        })
6390                    }
6391                    0x5f421a8ebf265bf3 => {
6392                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6393                        let mut req = fidl::new_empty!(
6394                            AudioCoreGetDbFromVolume2Request,
6395                            fidl::encoding::DefaultFuchsiaResourceDialect
6396                        );
6397                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreGetDbFromVolume2Request>(&header, _body_bytes, handles, &mut req)?;
6398                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6399                        Ok(AudioCoreRequest::GetDbFromVolume2 {
6400                            usage: req.usage,
6401                            volume: req.volume,
6402
6403                            responder: AudioCoreGetDbFromVolume2Responder {
6404                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6405                                tx_id: header.tx_id,
6406                            },
6407                        })
6408                    }
6409                    0x7bfed14345ece7b7 => {
6410                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6411                        let mut req = fidl::new_empty!(
6412                            AudioCoreSetInteractionRequest,
6413                            fidl::encoding::DefaultFuchsiaResourceDialect
6414                        );
6415                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteractionRequest>(&header, _body_bytes, handles, &mut req)?;
6416                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6417                        Ok(AudioCoreRequest::SetInteraction {
6418                            active: req.active,
6419                            affected: req.affected,
6420                            behavior: req.behavior,
6421
6422                            control_handle,
6423                        })
6424                    }
6425                    0x7226c7c6e6edc62f => {
6426                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6427                        let mut req = fidl::new_empty!(
6428                            AudioCoreSetInteraction2Request,
6429                            fidl::encoding::DefaultFuchsiaResourceDialect
6430                        );
6431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioCoreSetInteraction2Request>(&header, _body_bytes, handles, &mut req)?;
6432                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6433                        Ok(AudioCoreRequest::SetInteraction2 {
6434                            active: req.active,
6435                            affected: req.affected,
6436                            behavior: req.behavior,
6437
6438                            control_handle,
6439                        })
6440                    }
6441                    0x65bd94d9d0a28b5e => {
6442                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6443                        let mut req = fidl::new_empty!(
6444                            fidl::encoding::EmptyPayload,
6445                            fidl::encoding::DefaultFuchsiaResourceDialect
6446                        );
6447                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6448                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6449                        Ok(AudioCoreRequest::ResetInteractions { control_handle })
6450                    }
6451                    0x54a0bebca85f6b31 => {
6452                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
6453                        let mut req = fidl::new_empty!(
6454                            fidl::encoding::EmptyPayload,
6455                            fidl::encoding::DefaultFuchsiaResourceDialect
6456                        );
6457                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6458                        let control_handle = AudioCoreControlHandle { inner: this.inner.clone() };
6459                        Ok(AudioCoreRequest::LoadDefaults { control_handle })
6460                    }
6461                    _ if header.tx_id == 0
6462                        && header
6463                            .dynamic_flags()
6464                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6465                    {
6466                        Ok(AudioCoreRequest::_UnknownMethod {
6467                            ordinal: header.ordinal,
6468                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6469                            method_type: fidl::MethodType::OneWay,
6470                        })
6471                    }
6472                    _ if header
6473                        .dynamic_flags()
6474                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
6475                    {
6476                        this.inner.send_framework_err(
6477                            fidl::encoding::FrameworkErr::UnknownMethod,
6478                            header.tx_id,
6479                            header.ordinal,
6480                            header.dynamic_flags(),
6481                            (bytes, handles),
6482                        )?;
6483                        Ok(AudioCoreRequest::_UnknownMethod {
6484                            ordinal: header.ordinal,
6485                            control_handle: AudioCoreControlHandle { inner: this.inner.clone() },
6486                            method_type: fidl::MethodType::TwoWay,
6487                        })
6488                    }
6489                    _ => Err(fidl::Error::UnknownOrdinal {
6490                        ordinal: header.ordinal,
6491                        protocol_name:
6492                            <AudioCoreMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6493                    }),
6494                }))
6495            },
6496        )
6497    }
6498}
6499
6500#[derive(Debug)]
6501pub enum AudioCoreRequest {
6502    /// Creates an AudioRenderer which outputs audio to the default device.
6503    CreateAudioRenderer {
6504        audio_out_request: fidl::endpoints::ServerEnd<AudioRendererMarker>,
6505        control_handle: AudioCoreControlHandle,
6506    },
6507    /// Creates an AudioCapturer according to the given requirements.
6508    ///
6509    /// `pcm_stream_type` sets the stream type of the stream to be delivered.
6510    /// It causes the source material to be reformatted/resampled if needed
6511    /// in order to produce the requested stream type.
6512    ///
6513    /// `usage` is used by Fuchsia to make decisions about user experience.
6514    /// See `AudioCaptureUsage` for more details.
6515    ///
6516    /// `configuration` must be initialized to a variant, or no capturer
6517    /// can be created.
6518    CreateAudioCapturerWithConfiguration {
6519        stream_type: AudioStreamType,
6520        configuration: AudioCapturerConfiguration,
6521        audio_capturer_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6522        control_handle: AudioCoreControlHandle,
6523    },
6524    /// Creates an AudioCapturer which either captures from the current default
6525    /// audio input device, or loops-back from the current default audio output
6526    /// device based on value passed for the loopback flag.
6527    CreateAudioCapturer {
6528        loopback: bool,
6529        audio_in_request: fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6530        control_handle: AudioCoreControlHandle,
6531    },
6532    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6533    SetRenderUsageGain {
6534        usage: AudioRenderUsage,
6535        gain_db: f32,
6536        control_handle: AudioCoreControlHandle,
6537    },
6538    /// Sets the gain for this render usage. By default, all render usages are set to Unity (0 db).
6539    SetRenderUsageGain2 {
6540        usage: AudioRenderUsage2,
6541        gain_db: f32,
6542        control_handle: AudioCoreControlHandle,
6543    },
6544    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6545    SetCaptureUsageGain {
6546        usage: AudioCaptureUsage,
6547        gain_db: f32,
6548        control_handle: AudioCoreControlHandle,
6549    },
6550    /// Sets gain for this capture usage. By default, all capture usages are set to Unity (0 db).
6551    SetCaptureUsageGain2 {
6552        usage: AudioCaptureUsage2,
6553        gain_db: f32,
6554        control_handle: AudioCoreControlHandle,
6555    },
6556    /// Binds to a volume control protocol for the given usage.
6557    BindUsageVolumeControl {
6558        usage: Usage,
6559        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6560        control_handle: AudioCoreControlHandle,
6561    },
6562    /// Binds to a volume control protocol for the given usage.
6563    BindUsageVolumeControl2 {
6564        usage: Usage2,
6565        volume_control: fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6566        control_handle: AudioCoreControlHandle,
6567    },
6568    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6569    /// `usage`. This is the same mapping as used by the VolumeControl from
6570    /// `BindUsageVolumeControl`.
6571    GetVolumeFromDb { usage: Usage, gain_db: f32, responder: AudioCoreGetVolumeFromDbResponder },
6572    /// Queries the volume percentage [0, 1] that maps to a `gain_db` value for a particular
6573    /// `usage`. This is the same mapping as used by the VolumeControl from
6574    /// `BindUsageVolumeControl`.
6575    GetVolumeFromDb2 { usage: Usage2, gain_db: f32, responder: AudioCoreGetVolumeFromDb2Responder },
6576    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6577    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6578    GetDbFromVolume { usage: Usage, volume: f32, responder: AudioCoreGetDbFromVolumeResponder },
6579    /// Queries the decibel value that maps to a volume percentage [0, 1] for a particular `usage`.
6580    /// This is the same mapping as used by the VolumeControl from `BindUsageVolumeControl`.
6581    GetDbFromVolume2 { usage: Usage2, volume: f32, responder: AudioCoreGetDbFromVolume2Responder },
6582    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6583    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6584    /// the Behavior specified will be applied to the streams of Usage `affected`.
6585    SetInteraction {
6586        active: Usage,
6587        affected: Usage,
6588        behavior: Behavior,
6589        control_handle: AudioCoreControlHandle,
6590    },
6591    /// Sets how audio_core handles interactions of multiple active streams simultaneously. If
6592    /// streams of Usage `active` are processing audio, and streams of Usage `affected` are as well,
6593    /// the Behavior specified will be applied to the streams of Usage `affected`.
6594    SetInteraction2 {
6595        active: Usage2,
6596        affected: Usage2,
6597        behavior: Behavior,
6598        control_handle: AudioCoreControlHandle,
6599    },
6600    /// Re-initializes the set of rules that are currently governing the interaction of streams in
6601    /// audio_core. The default behavior is 'NONE'.
6602    ResetInteractions { control_handle: AudioCoreControlHandle },
6603    /// Re-loads the platform policy configuration. Falls back to a default config if the platform
6604    /// does not provide a config.
6605    LoadDefaults { control_handle: AudioCoreControlHandle },
6606    /// An interaction was received which does not match any known method.
6607    #[non_exhaustive]
6608    _UnknownMethod {
6609        /// Ordinal of the method that was called.
6610        ordinal: u64,
6611        control_handle: AudioCoreControlHandle,
6612        method_type: fidl::MethodType,
6613    },
6614}
6615
6616impl AudioCoreRequest {
6617    #[allow(irrefutable_let_patterns)]
6618    pub fn into_create_audio_renderer(
6619        self,
6620    ) -> Option<(fidl::endpoints::ServerEnd<AudioRendererMarker>, AudioCoreControlHandle)> {
6621        if let AudioCoreRequest::CreateAudioRenderer { audio_out_request, control_handle } = self {
6622            Some((audio_out_request, control_handle))
6623        } else {
6624            None
6625        }
6626    }
6627
6628    #[allow(irrefutable_let_patterns)]
6629    pub fn into_create_audio_capturer_with_configuration(
6630        self,
6631    ) -> Option<(
6632        AudioStreamType,
6633        AudioCapturerConfiguration,
6634        fidl::endpoints::ServerEnd<AudioCapturerMarker>,
6635        AudioCoreControlHandle,
6636    )> {
6637        if let AudioCoreRequest::CreateAudioCapturerWithConfiguration {
6638            stream_type,
6639            configuration,
6640            audio_capturer_request,
6641            control_handle,
6642        } = self
6643        {
6644            Some((stream_type, configuration, audio_capturer_request, control_handle))
6645        } else {
6646            None
6647        }
6648    }
6649
6650    #[allow(irrefutable_let_patterns)]
6651    pub fn into_create_audio_capturer(
6652        self,
6653    ) -> Option<(bool, fidl::endpoints::ServerEnd<AudioCapturerMarker>, AudioCoreControlHandle)>
6654    {
6655        if let AudioCoreRequest::CreateAudioCapturer {
6656            loopback,
6657            audio_in_request,
6658            control_handle,
6659        } = self
6660        {
6661            Some((loopback, audio_in_request, control_handle))
6662        } else {
6663            None
6664        }
6665    }
6666
6667    #[allow(irrefutable_let_patterns)]
6668    pub fn into_set_render_usage_gain(
6669        self,
6670    ) -> Option<(AudioRenderUsage, f32, AudioCoreControlHandle)> {
6671        if let AudioCoreRequest::SetRenderUsageGain { usage, gain_db, control_handle } = self {
6672            Some((usage, gain_db, control_handle))
6673        } else {
6674            None
6675        }
6676    }
6677
6678    #[allow(irrefutable_let_patterns)]
6679    pub fn into_set_render_usage_gain2(
6680        self,
6681    ) -> Option<(AudioRenderUsage2, f32, AudioCoreControlHandle)> {
6682        if let AudioCoreRequest::SetRenderUsageGain2 { usage, gain_db, control_handle } = self {
6683            Some((usage, gain_db, control_handle))
6684        } else {
6685            None
6686        }
6687    }
6688
6689    #[allow(irrefutable_let_patterns)]
6690    pub fn into_set_capture_usage_gain(
6691        self,
6692    ) -> Option<(AudioCaptureUsage, f32, AudioCoreControlHandle)> {
6693        if let AudioCoreRequest::SetCaptureUsageGain { usage, gain_db, control_handle } = self {
6694            Some((usage, gain_db, control_handle))
6695        } else {
6696            None
6697        }
6698    }
6699
6700    #[allow(irrefutable_let_patterns)]
6701    pub fn into_set_capture_usage_gain2(
6702        self,
6703    ) -> Option<(AudioCaptureUsage2, f32, AudioCoreControlHandle)> {
6704        if let AudioCoreRequest::SetCaptureUsageGain2 { usage, gain_db, control_handle } = self {
6705            Some((usage, gain_db, control_handle))
6706        } else {
6707            None
6708        }
6709    }
6710
6711    #[allow(irrefutable_let_patterns)]
6712    pub fn into_bind_usage_volume_control(
6713        self,
6714    ) -> Option<(
6715        Usage,
6716        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6717        AudioCoreControlHandle,
6718    )> {
6719        if let AudioCoreRequest::BindUsageVolumeControl { usage, volume_control, control_handle } =
6720            self
6721        {
6722            Some((usage, volume_control, control_handle))
6723        } else {
6724            None
6725        }
6726    }
6727
6728    #[allow(irrefutable_let_patterns)]
6729    pub fn into_bind_usage_volume_control2(
6730        self,
6731    ) -> Option<(
6732        Usage2,
6733        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
6734        AudioCoreControlHandle,
6735    )> {
6736        if let AudioCoreRequest::BindUsageVolumeControl2 { usage, volume_control, control_handle } =
6737            self
6738        {
6739            Some((usage, volume_control, control_handle))
6740        } else {
6741            None
6742        }
6743    }
6744
6745    #[allow(irrefutable_let_patterns)]
6746    pub fn into_get_volume_from_db(
6747        self,
6748    ) -> Option<(Usage, f32, AudioCoreGetVolumeFromDbResponder)> {
6749        if let AudioCoreRequest::GetVolumeFromDb { usage, gain_db, responder } = self {
6750            Some((usage, gain_db, responder))
6751        } else {
6752            None
6753        }
6754    }
6755
6756    #[allow(irrefutable_let_patterns)]
6757    pub fn into_get_volume_from_db2(
6758        self,
6759    ) -> Option<(Usage2, f32, AudioCoreGetVolumeFromDb2Responder)> {
6760        if let AudioCoreRequest::GetVolumeFromDb2 { usage, gain_db, responder } = self {
6761            Some((usage, gain_db, responder))
6762        } else {
6763            None
6764        }
6765    }
6766
6767    #[allow(irrefutable_let_patterns)]
6768    pub fn into_get_db_from_volume(
6769        self,
6770    ) -> Option<(Usage, f32, AudioCoreGetDbFromVolumeResponder)> {
6771        if let AudioCoreRequest::GetDbFromVolume { usage, volume, responder } = self {
6772            Some((usage, volume, responder))
6773        } else {
6774            None
6775        }
6776    }
6777
6778    #[allow(irrefutable_let_patterns)]
6779    pub fn into_get_db_from_volume2(
6780        self,
6781    ) -> Option<(Usage2, f32, AudioCoreGetDbFromVolume2Responder)> {
6782        if let AudioCoreRequest::GetDbFromVolume2 { usage, volume, responder } = self {
6783            Some((usage, volume, responder))
6784        } else {
6785            None
6786        }
6787    }
6788
6789    #[allow(irrefutable_let_patterns)]
6790    pub fn into_set_interaction(self) -> Option<(Usage, Usage, Behavior, AudioCoreControlHandle)> {
6791        if let AudioCoreRequest::SetInteraction { active, affected, behavior, control_handle } =
6792            self
6793        {
6794            Some((active, affected, behavior, control_handle))
6795        } else {
6796            None
6797        }
6798    }
6799
6800    #[allow(irrefutable_let_patterns)]
6801    pub fn into_set_interaction2(
6802        self,
6803    ) -> Option<(Usage2, Usage2, Behavior, AudioCoreControlHandle)> {
6804        if let AudioCoreRequest::SetInteraction2 { active, affected, behavior, control_handle } =
6805            self
6806        {
6807            Some((active, affected, behavior, control_handle))
6808        } else {
6809            None
6810        }
6811    }
6812
6813    #[allow(irrefutable_let_patterns)]
6814    pub fn into_reset_interactions(self) -> Option<(AudioCoreControlHandle)> {
6815        if let AudioCoreRequest::ResetInteractions { control_handle } = self {
6816            Some((control_handle))
6817        } else {
6818            None
6819        }
6820    }
6821
6822    #[allow(irrefutable_let_patterns)]
6823    pub fn into_load_defaults(self) -> Option<(AudioCoreControlHandle)> {
6824        if let AudioCoreRequest::LoadDefaults { control_handle } = self {
6825            Some((control_handle))
6826        } else {
6827            None
6828        }
6829    }
6830
6831    /// Name of the method defined in FIDL
6832    pub fn method_name(&self) -> &'static str {
6833        match *self {
6834            AudioCoreRequest::CreateAudioRenderer { .. } => "create_audio_renderer",
6835            AudioCoreRequest::CreateAudioCapturerWithConfiguration { .. } => {
6836                "create_audio_capturer_with_configuration"
6837            }
6838            AudioCoreRequest::CreateAudioCapturer { .. } => "create_audio_capturer",
6839            AudioCoreRequest::SetRenderUsageGain { .. } => "set_render_usage_gain",
6840            AudioCoreRequest::SetRenderUsageGain2 { .. } => "set_render_usage_gain2",
6841            AudioCoreRequest::SetCaptureUsageGain { .. } => "set_capture_usage_gain",
6842            AudioCoreRequest::SetCaptureUsageGain2 { .. } => "set_capture_usage_gain2",
6843            AudioCoreRequest::BindUsageVolumeControl { .. } => "bind_usage_volume_control",
6844            AudioCoreRequest::BindUsageVolumeControl2 { .. } => "bind_usage_volume_control2",
6845            AudioCoreRequest::GetVolumeFromDb { .. } => "get_volume_from_db",
6846            AudioCoreRequest::GetVolumeFromDb2 { .. } => "get_volume_from_db2",
6847            AudioCoreRequest::GetDbFromVolume { .. } => "get_db_from_volume",
6848            AudioCoreRequest::GetDbFromVolume2 { .. } => "get_db_from_volume2",
6849            AudioCoreRequest::SetInteraction { .. } => "set_interaction",
6850            AudioCoreRequest::SetInteraction2 { .. } => "set_interaction2",
6851            AudioCoreRequest::ResetInteractions { .. } => "reset_interactions",
6852            AudioCoreRequest::LoadDefaults { .. } => "load_defaults",
6853            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
6854                "unknown one-way method"
6855            }
6856            AudioCoreRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
6857                "unknown two-way method"
6858            }
6859        }
6860    }
6861}
6862
6863#[derive(Debug, Clone)]
6864pub struct AudioCoreControlHandle {
6865    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6866}
6867
6868impl AudioCoreControlHandle {
6869    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6870        self.inner.shutdown_with_epitaph(status.into())
6871    }
6872}
6873
6874impl fidl::endpoints::ControlHandle for AudioCoreControlHandle {
6875    fn shutdown(&self) {
6876        self.inner.shutdown()
6877    }
6878
6879    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6880        self.inner.shutdown_with_epitaph(status)
6881    }
6882
6883    fn is_closed(&self) -> bool {
6884        self.inner.channel().is_closed()
6885    }
6886    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6887        self.inner.channel().on_closed()
6888    }
6889
6890    #[cfg(target_os = "fuchsia")]
6891    fn signal_peer(
6892        &self,
6893        clear_mask: zx::Signals,
6894        set_mask: zx::Signals,
6895    ) -> Result<(), zx_status::Status> {
6896        use fidl::Peered;
6897        self.inner.channel().signal_peer(clear_mask, set_mask)
6898    }
6899}
6900
6901impl AudioCoreControlHandle {}
6902
6903#[must_use = "FIDL methods require a response to be sent"]
6904#[derive(Debug)]
6905pub struct AudioCoreGetVolumeFromDbResponder {
6906    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6907    tx_id: u32,
6908}
6909
6910/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6911/// if the responder is dropped without sending a response, so that the client
6912/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6913impl std::ops::Drop for AudioCoreGetVolumeFromDbResponder {
6914    fn drop(&mut self) {
6915        self.control_handle.shutdown();
6916        // Safety: drops once, never accessed again
6917        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6918    }
6919}
6920
6921impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDbResponder {
6922    type ControlHandle = AudioCoreControlHandle;
6923
6924    fn control_handle(&self) -> &AudioCoreControlHandle {
6925        &self.control_handle
6926    }
6927
6928    fn drop_without_shutdown(mut self) {
6929        // Safety: drops once, never accessed again due to mem::forget
6930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6931        // Prevent Drop from running (which would shut down the channel)
6932        std::mem::forget(self);
6933    }
6934}
6935
6936impl AudioCoreGetVolumeFromDbResponder {
6937    /// Sends a response to the FIDL transaction.
6938    ///
6939    /// Sets the channel to shutdown if an error occurs.
6940    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
6941        let _result = self.send_raw(volume);
6942        if _result.is_err() {
6943            self.control_handle.shutdown();
6944        }
6945        self.drop_without_shutdown();
6946        _result
6947    }
6948
6949    /// Similar to "send" but does not shutdown the channel if an error occurs.
6950    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
6951        let _result = self.send_raw(volume);
6952        self.drop_without_shutdown();
6953        _result
6954    }
6955
6956    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
6957        self.control_handle.inner.send::<AudioCoreGetVolumeFromDbResponse>(
6958            (volume,),
6959            self.tx_id,
6960            0x50e3ca45509770bf,
6961            fidl::encoding::DynamicFlags::empty(),
6962        )
6963    }
6964}
6965
6966#[must_use = "FIDL methods require a response to be sent"]
6967#[derive(Debug)]
6968pub struct AudioCoreGetVolumeFromDb2Responder {
6969    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
6970    tx_id: u32,
6971}
6972
6973/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
6974/// if the responder is dropped without sending a response, so that the client
6975/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6976impl std::ops::Drop for AudioCoreGetVolumeFromDb2Responder {
6977    fn drop(&mut self) {
6978        self.control_handle.shutdown();
6979        // Safety: drops once, never accessed again
6980        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6981    }
6982}
6983
6984impl fidl::endpoints::Responder for AudioCoreGetVolumeFromDb2Responder {
6985    type ControlHandle = AudioCoreControlHandle;
6986
6987    fn control_handle(&self) -> &AudioCoreControlHandle {
6988        &self.control_handle
6989    }
6990
6991    fn drop_without_shutdown(mut self) {
6992        // Safety: drops once, never accessed again due to mem::forget
6993        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6994        // Prevent Drop from running (which would shut down the channel)
6995        std::mem::forget(self);
6996    }
6997}
6998
6999impl AudioCoreGetVolumeFromDb2Responder {
7000    /// Sends a response to the FIDL transaction.
7001    ///
7002    /// Sets the channel to shutdown if an error occurs.
7003    pub fn send(self, mut volume: f32) -> Result<(), fidl::Error> {
7004        let _result = self.send_raw(volume);
7005        if _result.is_err() {
7006            self.control_handle.shutdown();
7007        }
7008        self.drop_without_shutdown();
7009        _result
7010    }
7011
7012    /// Similar to "send" but does not shutdown the channel if an error occurs.
7013    pub fn send_no_shutdown_on_err(self, mut volume: f32) -> Result<(), fidl::Error> {
7014        let _result = self.send_raw(volume);
7015        self.drop_without_shutdown();
7016        _result
7017    }
7018
7019    fn send_raw(&self, mut volume: f32) -> Result<(), fidl::Error> {
7020        self.control_handle
7021            .inner
7022            .send::<fidl::encoding::FlexibleType<AudioCoreGetVolumeFromDb2Response>>(
7023                fidl::encoding::Flexible::new((volume,)),
7024                self.tx_id,
7025                0x165c811091ef99da,
7026                fidl::encoding::DynamicFlags::FLEXIBLE,
7027            )
7028    }
7029}
7030
7031#[must_use = "FIDL methods require a response to be sent"]
7032#[derive(Debug)]
7033pub struct AudioCoreGetDbFromVolumeResponder {
7034    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
7035    tx_id: u32,
7036}
7037
7038/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
7039/// if the responder is dropped without sending a response, so that the client
7040/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7041impl std::ops::Drop for AudioCoreGetDbFromVolumeResponder {
7042    fn drop(&mut self) {
7043        self.control_handle.shutdown();
7044        // Safety: drops once, never accessed again
7045        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7046    }
7047}
7048
7049impl fidl::endpoints::Responder for AudioCoreGetDbFromVolumeResponder {
7050    type ControlHandle = AudioCoreControlHandle;
7051
7052    fn control_handle(&self) -> &AudioCoreControlHandle {
7053        &self.control_handle
7054    }
7055
7056    fn drop_without_shutdown(mut self) {
7057        // Safety: drops once, never accessed again due to mem::forget
7058        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7059        // Prevent Drop from running (which would shut down the channel)
7060        std::mem::forget(self);
7061    }
7062}
7063
7064impl AudioCoreGetDbFromVolumeResponder {
7065    /// Sends a response to the FIDL transaction.
7066    ///
7067    /// Sets the channel to shutdown if an error occurs.
7068    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7069        let _result = self.send_raw(gain_db);
7070        if _result.is_err() {
7071            self.control_handle.shutdown();
7072        }
7073        self.drop_without_shutdown();
7074        _result
7075    }
7076
7077    /// Similar to "send" but does not shutdown the channel if an error occurs.
7078    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7079        let _result = self.send_raw(gain_db);
7080        self.drop_without_shutdown();
7081        _result
7082    }
7083
7084    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
7085        self.control_handle.inner.send::<AudioCoreGetDbFromVolumeResponse>(
7086            (gain_db,),
7087            self.tx_id,
7088            0x3e8eec27dd5a8bda,
7089            fidl::encoding::DynamicFlags::empty(),
7090        )
7091    }
7092}
7093
7094#[must_use = "FIDL methods require a response to be sent"]
7095#[derive(Debug)]
7096pub struct AudioCoreGetDbFromVolume2Responder {
7097    control_handle: std::mem::ManuallyDrop<AudioCoreControlHandle>,
7098    tx_id: u32,
7099}
7100
7101/// Set the the channel to be shutdown (see [`AudioCoreControlHandle::shutdown`])
7102/// if the responder is dropped without sending a response, so that the client
7103/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7104impl std::ops::Drop for AudioCoreGetDbFromVolume2Responder {
7105    fn drop(&mut self) {
7106        self.control_handle.shutdown();
7107        // Safety: drops once, never accessed again
7108        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7109    }
7110}
7111
7112impl fidl::endpoints::Responder for AudioCoreGetDbFromVolume2Responder {
7113    type ControlHandle = AudioCoreControlHandle;
7114
7115    fn control_handle(&self) -> &AudioCoreControlHandle {
7116        &self.control_handle
7117    }
7118
7119    fn drop_without_shutdown(mut self) {
7120        // Safety: drops once, never accessed again due to mem::forget
7121        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7122        // Prevent Drop from running (which would shut down the channel)
7123        std::mem::forget(self);
7124    }
7125}
7126
7127impl AudioCoreGetDbFromVolume2Responder {
7128    /// Sends a response to the FIDL transaction.
7129    ///
7130    /// Sets the channel to shutdown if an error occurs.
7131    pub fn send(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7132        let _result = self.send_raw(gain_db);
7133        if _result.is_err() {
7134            self.control_handle.shutdown();
7135        }
7136        self.drop_without_shutdown();
7137        _result
7138    }
7139
7140    /// Similar to "send" but does not shutdown the channel if an error occurs.
7141    pub fn send_no_shutdown_on_err(self, mut gain_db: f32) -> Result<(), fidl::Error> {
7142        let _result = self.send_raw(gain_db);
7143        self.drop_without_shutdown();
7144        _result
7145    }
7146
7147    fn send_raw(&self, mut gain_db: f32) -> Result<(), fidl::Error> {
7148        self.control_handle
7149            .inner
7150            .send::<fidl::encoding::FlexibleType<AudioCoreGetDbFromVolume2Response>>(
7151                fidl::encoding::Flexible::new((gain_db,)),
7152                self.tx_id,
7153                0x5f421a8ebf265bf3,
7154                fidl::encoding::DynamicFlags::FLEXIBLE,
7155            )
7156    }
7157}
7158
7159#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7160pub struct AudioDeviceEnumeratorMarker;
7161
7162impl fidl::endpoints::ProtocolMarker for AudioDeviceEnumeratorMarker {
7163    type Proxy = AudioDeviceEnumeratorProxy;
7164    type RequestStream = AudioDeviceEnumeratorRequestStream;
7165    #[cfg(target_os = "fuchsia")]
7166    type SynchronousProxy = AudioDeviceEnumeratorSynchronousProxy;
7167
7168    const DEBUG_NAME: &'static str = "fuchsia.media.AudioDeviceEnumerator";
7169}
7170impl fidl::endpoints::DiscoverableProtocolMarker for AudioDeviceEnumeratorMarker {}
7171
7172pub trait AudioDeviceEnumeratorProxyInterface: Send + Sync {
7173    type GetDevicesResponseFut: std::future::Future<Output = Result<Vec<AudioDeviceInfo>, fidl::Error>>
7174        + Send;
7175    fn r#get_devices(&self) -> Self::GetDevicesResponseFut;
7176    type GetDeviceGainResponseFut: std::future::Future<Output = Result<(u64, AudioGainInfo), fidl::Error>>
7177        + Send;
7178    fn r#get_device_gain(&self, device_token: u64) -> Self::GetDeviceGainResponseFut;
7179    fn r#set_device_gain(
7180        &self,
7181        device_token: u64,
7182        gain_info: &AudioGainInfo,
7183        valid_flags: AudioGainValidFlags,
7184    ) -> Result<(), fidl::Error>;
7185    fn r#add_device_by_channel(
7186        &self,
7187        device_name: &str,
7188        is_input: bool,
7189        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7190    ) -> Result<(), fidl::Error>;
7191}
7192#[derive(Debug)]
7193#[cfg(target_os = "fuchsia")]
7194pub struct AudioDeviceEnumeratorSynchronousProxy {
7195    client: fidl::client::sync::Client,
7196}
7197
7198#[cfg(target_os = "fuchsia")]
7199impl fidl::endpoints::SynchronousProxy for AudioDeviceEnumeratorSynchronousProxy {
7200    type Proxy = AudioDeviceEnumeratorProxy;
7201    type Protocol = AudioDeviceEnumeratorMarker;
7202
7203    fn from_channel(inner: fidl::Channel) -> Self {
7204        Self::new(inner)
7205    }
7206
7207    fn into_channel(self) -> fidl::Channel {
7208        self.client.into_channel()
7209    }
7210
7211    fn as_channel(&self) -> &fidl::Channel {
7212        self.client.as_channel()
7213    }
7214}
7215
7216#[cfg(target_os = "fuchsia")]
7217impl AudioDeviceEnumeratorSynchronousProxy {
7218    pub fn new(channel: fidl::Channel) -> Self {
7219        Self { client: fidl::client::sync::Client::new(channel) }
7220    }
7221
7222    pub fn into_channel(self) -> fidl::Channel {
7223        self.client.into_channel()
7224    }
7225
7226    /// Waits until an event arrives and returns it. It is safe for other
7227    /// threads to make concurrent requests while waiting for an event.
7228    pub fn wait_for_event(
7229        &self,
7230        deadline: zx::MonotonicInstant,
7231    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7232        AudioDeviceEnumeratorEvent::decode(
7233            self.client.wait_for_event::<AudioDeviceEnumeratorMarker>(deadline)?,
7234        )
7235    }
7236
7237    /// Obtain the list of currently active audio devices.
7238    pub fn r#get_devices(
7239        &self,
7240        ___deadline: zx::MonotonicInstant,
7241    ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7242        let _response = self.client.send_query::<
7243            fidl::encoding::EmptyPayload,
7244            AudioDeviceEnumeratorGetDevicesResponse,
7245            AudioDeviceEnumeratorMarker,
7246        >(
7247            (),
7248            0x4ce1aa218aeb12a6,
7249            fidl::encoding::DynamicFlags::empty(),
7250            ___deadline,
7251        )?;
7252        Ok(_response.devices)
7253    }
7254
7255    /// Gain/Mute/AGC control
7256    ///
7257    /// Note that each of these operations requires a device_token in order to
7258    /// target the proper input/output.
7259    ///
7260    /// The Get command returns the device_token of the device whose gain is
7261    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7262    /// device_token was invalid or the device had been removed from the system
7263    /// before the Get command could be processed.
7264    ///
7265    /// Set commands which are given an invalid device token are ignored and
7266    /// have no effect on the system. In addition, users do not need to control
7267    /// all of the gain settings for an audio device with each call. Only the
7268    /// settings with a corresponding flag set in the set_flags parameter will
7269    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7270    /// a SetDeviceGain call to care only about the mute setting in the
7271    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7272    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7273    /// status to be changed simultaneously.
7274    pub fn r#get_device_gain(
7275        &self,
7276        mut device_token: u64,
7277        ___deadline: zx::MonotonicInstant,
7278    ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7279        let _response = self.client.send_query::<
7280            AudioDeviceEnumeratorGetDeviceGainRequest,
7281            AudioDeviceEnumeratorGetDeviceGainResponse,
7282            AudioDeviceEnumeratorMarker,
7283        >(
7284            (device_token,),
7285            0x25dd4723403c414b,
7286            fidl::encoding::DynamicFlags::empty(),
7287            ___deadline,
7288        )?;
7289        Ok((_response.device_token, _response.gain_info))
7290    }
7291
7292    pub fn r#set_device_gain(
7293        &self,
7294        mut device_token: u64,
7295        mut gain_info: &AudioGainInfo,
7296        mut valid_flags: AudioGainValidFlags,
7297    ) -> Result<(), fidl::Error> {
7298        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7299            (device_token, gain_info, valid_flags),
7300            0x5bdabc8ebe83591,
7301            fidl::encoding::DynamicFlags::empty(),
7302        )
7303    }
7304
7305    /// # Deprecation
7306    ///
7307    /// StreamConfig is not supported anymore, instead use an
7308    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7309    /// , see
7310    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7311    pub fn r#add_device_by_channel(
7312        &self,
7313        mut device_name: &str,
7314        mut is_input: bool,
7315        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7316    ) -> Result<(), fidl::Error> {
7317        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7318            (device_name, is_input, channel),
7319            0x72cdbada4d70ed67,
7320            fidl::encoding::DynamicFlags::empty(),
7321        )
7322    }
7323}
7324
7325#[cfg(target_os = "fuchsia")]
7326impl From<AudioDeviceEnumeratorSynchronousProxy> for zx::NullableHandle {
7327    fn from(value: AudioDeviceEnumeratorSynchronousProxy) -> Self {
7328        value.into_channel().into()
7329    }
7330}
7331
7332#[cfg(target_os = "fuchsia")]
7333impl From<fidl::Channel> for AudioDeviceEnumeratorSynchronousProxy {
7334    fn from(value: fidl::Channel) -> Self {
7335        Self::new(value)
7336    }
7337}
7338
7339#[cfg(target_os = "fuchsia")]
7340impl fidl::endpoints::FromClient for AudioDeviceEnumeratorSynchronousProxy {
7341    type Protocol = AudioDeviceEnumeratorMarker;
7342
7343    fn from_client(value: fidl::endpoints::ClientEnd<AudioDeviceEnumeratorMarker>) -> Self {
7344        Self::new(value.into_channel())
7345    }
7346}
7347
7348#[derive(Debug, Clone)]
7349pub struct AudioDeviceEnumeratorProxy {
7350    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7351}
7352
7353impl fidl::endpoints::Proxy for AudioDeviceEnumeratorProxy {
7354    type Protocol = AudioDeviceEnumeratorMarker;
7355
7356    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7357        Self::new(inner)
7358    }
7359
7360    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7361        self.client.into_channel().map_err(|client| Self { client })
7362    }
7363
7364    fn as_channel(&self) -> &::fidl::AsyncChannel {
7365        self.client.as_channel()
7366    }
7367}
7368
7369impl AudioDeviceEnumeratorProxy {
7370    /// Create a new Proxy for fuchsia.media/AudioDeviceEnumerator.
7371    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7372        let protocol_name =
7373            <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7374        Self { client: fidl::client::Client::new(channel, protocol_name) }
7375    }
7376
7377    /// Get a Stream of events from the remote end of the protocol.
7378    ///
7379    /// # Panics
7380    ///
7381    /// Panics if the event stream was already taken.
7382    pub fn take_event_stream(&self) -> AudioDeviceEnumeratorEventStream {
7383        AudioDeviceEnumeratorEventStream { event_receiver: self.client.take_event_receiver() }
7384    }
7385
7386    /// Obtain the list of currently active audio devices.
7387    pub fn r#get_devices(
7388        &self,
7389    ) -> fidl::client::QueryResponseFut<
7390        Vec<AudioDeviceInfo>,
7391        fidl::encoding::DefaultFuchsiaResourceDialect,
7392    > {
7393        AudioDeviceEnumeratorProxyInterface::r#get_devices(self)
7394    }
7395
7396    /// Gain/Mute/AGC control
7397    ///
7398    /// Note that each of these operations requires a device_token in order to
7399    /// target the proper input/output.
7400    ///
7401    /// The Get command returns the device_token of the device whose gain is
7402    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7403    /// device_token was invalid or the device had been removed from the system
7404    /// before the Get command could be processed.
7405    ///
7406    /// Set commands which are given an invalid device token are ignored and
7407    /// have no effect on the system. In addition, users do not need to control
7408    /// all of the gain settings for an audio device with each call. Only the
7409    /// settings with a corresponding flag set in the set_flags parameter will
7410    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7411    /// a SetDeviceGain call to care only about the mute setting in the
7412    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7413    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7414    /// status to be changed simultaneously.
7415    pub fn r#get_device_gain(
7416        &self,
7417        mut device_token: u64,
7418    ) -> fidl::client::QueryResponseFut<
7419        (u64, AudioGainInfo),
7420        fidl::encoding::DefaultFuchsiaResourceDialect,
7421    > {
7422        AudioDeviceEnumeratorProxyInterface::r#get_device_gain(self, device_token)
7423    }
7424
7425    pub fn r#set_device_gain(
7426        &self,
7427        mut device_token: u64,
7428        mut gain_info: &AudioGainInfo,
7429        mut valid_flags: AudioGainValidFlags,
7430    ) -> Result<(), fidl::Error> {
7431        AudioDeviceEnumeratorProxyInterface::r#set_device_gain(
7432            self,
7433            device_token,
7434            gain_info,
7435            valid_flags,
7436        )
7437    }
7438
7439    /// # Deprecation
7440    ///
7441    /// StreamConfig is not supported anymore, instead use an
7442    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7443    /// , see
7444    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7445    pub fn r#add_device_by_channel(
7446        &self,
7447        mut device_name: &str,
7448        mut is_input: bool,
7449        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7450    ) -> Result<(), fidl::Error> {
7451        AudioDeviceEnumeratorProxyInterface::r#add_device_by_channel(
7452            self,
7453            device_name,
7454            is_input,
7455            channel,
7456        )
7457    }
7458}
7459
7460impl AudioDeviceEnumeratorProxyInterface for AudioDeviceEnumeratorProxy {
7461    type GetDevicesResponseFut = fidl::client::QueryResponseFut<
7462        Vec<AudioDeviceInfo>,
7463        fidl::encoding::DefaultFuchsiaResourceDialect,
7464    >;
7465    fn r#get_devices(&self) -> Self::GetDevicesResponseFut {
7466        fn _decode(
7467            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7468        ) -> Result<Vec<AudioDeviceInfo>, fidl::Error> {
7469            let _response = fidl::client::decode_transaction_body::<
7470                AudioDeviceEnumeratorGetDevicesResponse,
7471                fidl::encoding::DefaultFuchsiaResourceDialect,
7472                0x4ce1aa218aeb12a6,
7473            >(_buf?)?;
7474            Ok(_response.devices)
7475        }
7476        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<AudioDeviceInfo>>(
7477            (),
7478            0x4ce1aa218aeb12a6,
7479            fidl::encoding::DynamicFlags::empty(),
7480            _decode,
7481        )
7482    }
7483
7484    type GetDeviceGainResponseFut = fidl::client::QueryResponseFut<
7485        (u64, AudioGainInfo),
7486        fidl::encoding::DefaultFuchsiaResourceDialect,
7487    >;
7488    fn r#get_device_gain(&self, mut device_token: u64) -> Self::GetDeviceGainResponseFut {
7489        fn _decode(
7490            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7491        ) -> Result<(u64, AudioGainInfo), fidl::Error> {
7492            let _response = fidl::client::decode_transaction_body::<
7493                AudioDeviceEnumeratorGetDeviceGainResponse,
7494                fidl::encoding::DefaultFuchsiaResourceDialect,
7495                0x25dd4723403c414b,
7496            >(_buf?)?;
7497            Ok((_response.device_token, _response.gain_info))
7498        }
7499        self.client.send_query_and_decode::<
7500            AudioDeviceEnumeratorGetDeviceGainRequest,
7501            (u64, AudioGainInfo),
7502        >(
7503            (device_token,),
7504            0x25dd4723403c414b,
7505            fidl::encoding::DynamicFlags::empty(),
7506            _decode,
7507        )
7508    }
7509
7510    fn r#set_device_gain(
7511        &self,
7512        mut device_token: u64,
7513        mut gain_info: &AudioGainInfo,
7514        mut valid_flags: AudioGainValidFlags,
7515    ) -> Result<(), fidl::Error> {
7516        self.client.send::<AudioDeviceEnumeratorSetDeviceGainRequest>(
7517            (device_token, gain_info, valid_flags),
7518            0x5bdabc8ebe83591,
7519            fidl::encoding::DynamicFlags::empty(),
7520        )
7521    }
7522
7523    fn r#add_device_by_channel(
7524        &self,
7525        mut device_name: &str,
7526        mut is_input: bool,
7527        mut channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7528    ) -> Result<(), fidl::Error> {
7529        self.client.send::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(
7530            (device_name, is_input, channel),
7531            0x72cdbada4d70ed67,
7532            fidl::encoding::DynamicFlags::empty(),
7533        )
7534    }
7535}
7536
7537pub struct AudioDeviceEnumeratorEventStream {
7538    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7539}
7540
7541impl std::marker::Unpin for AudioDeviceEnumeratorEventStream {}
7542
7543impl futures::stream::FusedStream for AudioDeviceEnumeratorEventStream {
7544    fn is_terminated(&self) -> bool {
7545        self.event_receiver.is_terminated()
7546    }
7547}
7548
7549impl futures::Stream for AudioDeviceEnumeratorEventStream {
7550    type Item = Result<AudioDeviceEnumeratorEvent, fidl::Error>;
7551
7552    fn poll_next(
7553        mut self: std::pin::Pin<&mut Self>,
7554        cx: &mut std::task::Context<'_>,
7555    ) -> std::task::Poll<Option<Self::Item>> {
7556        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7557            &mut self.event_receiver,
7558            cx
7559        )?) {
7560            Some(buf) => std::task::Poll::Ready(Some(AudioDeviceEnumeratorEvent::decode(buf))),
7561            None => std::task::Poll::Ready(None),
7562        }
7563    }
7564}
7565
7566#[derive(Debug)]
7567pub enum AudioDeviceEnumeratorEvent {
7568    OnDeviceAdded { device: AudioDeviceInfo },
7569    OnDeviceRemoved { device_token: u64 },
7570    OnDeviceGainChanged { device_token: u64, gain_info: AudioGainInfo },
7571    OnDefaultDeviceChanged { old_default_token: u64, new_default_token: u64 },
7572}
7573
7574impl AudioDeviceEnumeratorEvent {
7575    #[allow(irrefutable_let_patterns)]
7576    pub fn into_on_device_added(self) -> Option<AudioDeviceInfo> {
7577        if let AudioDeviceEnumeratorEvent::OnDeviceAdded { device } = self {
7578            Some((device))
7579        } else {
7580            None
7581        }
7582    }
7583    #[allow(irrefutable_let_patterns)]
7584    pub fn into_on_device_removed(self) -> Option<u64> {
7585        if let AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token } = self {
7586            Some((device_token))
7587        } else {
7588            None
7589        }
7590    }
7591    #[allow(irrefutable_let_patterns)]
7592    pub fn into_on_device_gain_changed(self) -> Option<(u64, AudioGainInfo)> {
7593        if let AudioDeviceEnumeratorEvent::OnDeviceGainChanged { device_token, gain_info } = self {
7594            Some((device_token, gain_info))
7595        } else {
7596            None
7597        }
7598    }
7599    #[allow(irrefutable_let_patterns)]
7600    pub fn into_on_default_device_changed(self) -> Option<(u64, u64)> {
7601        if let AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7602            old_default_token,
7603            new_default_token,
7604        } = self
7605        {
7606            Some((old_default_token, new_default_token))
7607        } else {
7608            None
7609        }
7610    }
7611
7612    /// Decodes a message buffer as a [`AudioDeviceEnumeratorEvent`].
7613    fn decode(
7614        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7615    ) -> Result<AudioDeviceEnumeratorEvent, fidl::Error> {
7616        let (bytes, _handles) = buf.split_mut();
7617        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7618        debug_assert_eq!(tx_header.tx_id, 0);
7619        match tx_header.ordinal {
7620            0xe0fbe40057c4b44 => {
7621                let mut out = fidl::new_empty!(
7622                    AudioDeviceEnumeratorOnDeviceAddedRequest,
7623                    fidl::encoding::DefaultFuchsiaResourceDialect
7624                );
7625                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceAddedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7626                Ok((AudioDeviceEnumeratorEvent::OnDeviceAdded { device: out.device }))
7627            }
7628            0x6f3b7574463d9ff8 => {
7629                let mut out = fidl::new_empty!(
7630                    AudioDeviceEnumeratorOnDeviceRemovedRequest,
7631                    fidl::encoding::DefaultFuchsiaResourceDialect
7632                );
7633                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7634                Ok((AudioDeviceEnumeratorEvent::OnDeviceRemoved { device_token: out.device_token }))
7635            }
7636            0x14aefcbbb076b0e9 => {
7637                let mut out = fidl::new_empty!(
7638                    AudioDeviceEnumeratorOnDeviceGainChangedRequest,
7639                    fidl::encoding::DefaultFuchsiaResourceDialect
7640                );
7641                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7642                Ok((AudioDeviceEnumeratorEvent::OnDeviceGainChanged {
7643                    device_token: out.device_token,
7644                    gain_info: out.gain_info,
7645                }))
7646            }
7647            0x16357b42d4c16e11 => {
7648                let mut out = fidl::new_empty!(
7649                    AudioDeviceEnumeratorOnDefaultDeviceChangedRequest,
7650                    fidl::encoding::DefaultFuchsiaResourceDialect
7651                );
7652                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
7653                Ok((AudioDeviceEnumeratorEvent::OnDefaultDeviceChanged {
7654                    old_default_token: out.old_default_token,
7655                    new_default_token: out.new_default_token,
7656                }))
7657            }
7658            _ => Err(fidl::Error::UnknownOrdinal {
7659                ordinal: tx_header.ordinal,
7660                protocol_name:
7661                    <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7662            }),
7663        }
7664    }
7665}
7666
7667/// A Stream of incoming requests for fuchsia.media/AudioDeviceEnumerator.
7668pub struct AudioDeviceEnumeratorRequestStream {
7669    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7670    is_terminated: bool,
7671}
7672
7673impl std::marker::Unpin for AudioDeviceEnumeratorRequestStream {}
7674
7675impl futures::stream::FusedStream for AudioDeviceEnumeratorRequestStream {
7676    fn is_terminated(&self) -> bool {
7677        self.is_terminated
7678    }
7679}
7680
7681impl fidl::endpoints::RequestStream for AudioDeviceEnumeratorRequestStream {
7682    type Protocol = AudioDeviceEnumeratorMarker;
7683    type ControlHandle = AudioDeviceEnumeratorControlHandle;
7684
7685    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7686        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7687    }
7688
7689    fn control_handle(&self) -> Self::ControlHandle {
7690        AudioDeviceEnumeratorControlHandle { inner: self.inner.clone() }
7691    }
7692
7693    fn into_inner(
7694        self,
7695    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7696    {
7697        (self.inner, self.is_terminated)
7698    }
7699
7700    fn from_inner(
7701        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7702        is_terminated: bool,
7703    ) -> Self {
7704        Self { inner, is_terminated }
7705    }
7706}
7707
7708impl futures::Stream for AudioDeviceEnumeratorRequestStream {
7709    type Item = Result<AudioDeviceEnumeratorRequest, fidl::Error>;
7710
7711    fn poll_next(
7712        mut self: std::pin::Pin<&mut Self>,
7713        cx: &mut std::task::Context<'_>,
7714    ) -> std::task::Poll<Option<Self::Item>> {
7715        let this = &mut *self;
7716        if this.inner.check_shutdown(cx) {
7717            this.is_terminated = true;
7718            return std::task::Poll::Ready(None);
7719        }
7720        if this.is_terminated {
7721            panic!("polled AudioDeviceEnumeratorRequestStream after completion");
7722        }
7723        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7724            |bytes, handles| {
7725                match this.inner.channel().read_etc(cx, bytes, handles) {
7726                    std::task::Poll::Ready(Ok(())) => {}
7727                    std::task::Poll::Pending => return std::task::Poll::Pending,
7728                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7729                        this.is_terminated = true;
7730                        return std::task::Poll::Ready(None);
7731                    }
7732                    std::task::Poll::Ready(Err(e)) => {
7733                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7734                            e.into(),
7735                        ))));
7736                    }
7737                }
7738
7739                // A message has been received from the channel
7740                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7741
7742                std::task::Poll::Ready(Some(match header.ordinal {
7743                0x4ce1aa218aeb12a6 => {
7744                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7745                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
7746                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
7747                    let control_handle = AudioDeviceEnumeratorControlHandle {
7748                        inner: this.inner.clone(),
7749                    };
7750                    Ok(AudioDeviceEnumeratorRequest::GetDevices {
7751                        responder: AudioDeviceEnumeratorGetDevicesResponder {
7752                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7753                            tx_id: header.tx_id,
7754                        },
7755                    })
7756                }
7757                0x25dd4723403c414b => {
7758                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7759                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorGetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7760                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorGetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7761                    let control_handle = AudioDeviceEnumeratorControlHandle {
7762                        inner: this.inner.clone(),
7763                    };
7764                    Ok(AudioDeviceEnumeratorRequest::GetDeviceGain {device_token: req.device_token,
7765
7766                        responder: AudioDeviceEnumeratorGetDeviceGainResponder {
7767                            control_handle: std::mem::ManuallyDrop::new(control_handle),
7768                            tx_id: header.tx_id,
7769                        },
7770                    })
7771                }
7772                0x5bdabc8ebe83591 => {
7773                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7774                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorSetDeviceGainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7775                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorSetDeviceGainRequest>(&header, _body_bytes, handles, &mut req)?;
7776                    let control_handle = AudioDeviceEnumeratorControlHandle {
7777                        inner: this.inner.clone(),
7778                    };
7779                    Ok(AudioDeviceEnumeratorRequest::SetDeviceGain {device_token: req.device_token,
7780gain_info: req.gain_info,
7781valid_flags: req.valid_flags,
7782
7783                        control_handle,
7784                    })
7785                }
7786                0x72cdbada4d70ed67 => {
7787                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
7788                    let mut req = fidl::new_empty!(AudioDeviceEnumeratorAddDeviceByChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
7789                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(&header, _body_bytes, handles, &mut req)?;
7790                    let control_handle = AudioDeviceEnumeratorControlHandle {
7791                        inner: this.inner.clone(),
7792                    };
7793                    Ok(AudioDeviceEnumeratorRequest::AddDeviceByChannel {device_name: req.device_name,
7794is_input: req.is_input,
7795channel: req.channel,
7796
7797                        control_handle,
7798                    })
7799                }
7800                _ => Err(fidl::Error::UnknownOrdinal {
7801                    ordinal: header.ordinal,
7802                    protocol_name: <AudioDeviceEnumeratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7803                }),
7804            }))
7805            },
7806        )
7807    }
7808}
7809
7810#[derive(Debug)]
7811pub enum AudioDeviceEnumeratorRequest {
7812    /// Obtain the list of currently active audio devices.
7813    GetDevices { responder: AudioDeviceEnumeratorGetDevicesResponder },
7814    /// Gain/Mute/AGC control
7815    ///
7816    /// Note that each of these operations requires a device_token in order to
7817    /// target the proper input/output.
7818    ///
7819    /// The Get command returns the device_token of the device whose gain is
7820    /// being reported, or `ZX_KOID_INVALID` in the case that the requested
7821    /// device_token was invalid or the device had been removed from the system
7822    /// before the Get command could be processed.
7823    ///
7824    /// Set commands which are given an invalid device token are ignored and
7825    /// have no effect on the system. In addition, users do not need to control
7826    /// all of the gain settings for an audio device with each call. Only the
7827    /// settings with a corresponding flag set in the set_flags parameter will
7828    /// be affected. For example, passing SetAudioGainFlag_MuteValid will cause
7829    /// a SetDeviceGain call to care only about the mute setting in the
7830    /// gain_info structure, while passing (SetAudioGainFlag_GainValid |
7831    /// SetAudioGainFlag_MuteValid) will cause both the mute and the gain
7832    /// status to be changed simultaneously.
7833    GetDeviceGain { device_token: u64, responder: AudioDeviceEnumeratorGetDeviceGainResponder },
7834    SetDeviceGain {
7835        device_token: u64,
7836        gain_info: AudioGainInfo,
7837        valid_flags: AudioGainValidFlags,
7838        control_handle: AudioDeviceEnumeratorControlHandle,
7839    },
7840    /// # Deprecation
7841    ///
7842    /// StreamConfig is not supported anymore, instead use an
7843    /// [Audio Composite](https://fuchsia.dev/fuchsia-src/development/audio/drivers/composite)
7844    /// , see
7845    /// [Audio Drivers Architecture](https://fuchsia.dev/fuchsia-src/development/audio/drivers/architecture)
7846    AddDeviceByChannel {
7847        device_name: String,
7848        is_input: bool,
7849        channel: fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7850        control_handle: AudioDeviceEnumeratorControlHandle,
7851    },
7852}
7853
7854impl AudioDeviceEnumeratorRequest {
7855    #[allow(irrefutable_let_patterns)]
7856    pub fn into_get_devices(self) -> Option<(AudioDeviceEnumeratorGetDevicesResponder)> {
7857        if let AudioDeviceEnumeratorRequest::GetDevices { responder } = self {
7858            Some((responder))
7859        } else {
7860            None
7861        }
7862    }
7863
7864    #[allow(irrefutable_let_patterns)]
7865    pub fn into_get_device_gain(
7866        self,
7867    ) -> Option<(u64, AudioDeviceEnumeratorGetDeviceGainResponder)> {
7868        if let AudioDeviceEnumeratorRequest::GetDeviceGain { device_token, responder } = self {
7869            Some((device_token, responder))
7870        } else {
7871            None
7872        }
7873    }
7874
7875    #[allow(irrefutable_let_patterns)]
7876    pub fn into_set_device_gain(
7877        self,
7878    ) -> Option<(u64, AudioGainInfo, AudioGainValidFlags, AudioDeviceEnumeratorControlHandle)> {
7879        if let AudioDeviceEnumeratorRequest::SetDeviceGain {
7880            device_token,
7881            gain_info,
7882            valid_flags,
7883            control_handle,
7884        } = self
7885        {
7886            Some((device_token, gain_info, valid_flags, control_handle))
7887        } else {
7888            None
7889        }
7890    }
7891
7892    #[allow(irrefutable_let_patterns)]
7893    pub fn into_add_device_by_channel(
7894        self,
7895    ) -> Option<(
7896        String,
7897        bool,
7898        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
7899        AudioDeviceEnumeratorControlHandle,
7900    )> {
7901        if let AudioDeviceEnumeratorRequest::AddDeviceByChannel {
7902            device_name,
7903            is_input,
7904            channel,
7905            control_handle,
7906        } = self
7907        {
7908            Some((device_name, is_input, channel, control_handle))
7909        } else {
7910            None
7911        }
7912    }
7913
7914    /// Name of the method defined in FIDL
7915    pub fn method_name(&self) -> &'static str {
7916        match *self {
7917            AudioDeviceEnumeratorRequest::GetDevices { .. } => "get_devices",
7918            AudioDeviceEnumeratorRequest::GetDeviceGain { .. } => "get_device_gain",
7919            AudioDeviceEnumeratorRequest::SetDeviceGain { .. } => "set_device_gain",
7920            AudioDeviceEnumeratorRequest::AddDeviceByChannel { .. } => "add_device_by_channel",
7921        }
7922    }
7923}
7924
7925#[derive(Debug, Clone)]
7926pub struct AudioDeviceEnumeratorControlHandle {
7927    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7928}
7929
7930impl AudioDeviceEnumeratorControlHandle {
7931    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
7932        self.inner.shutdown_with_epitaph(status.into())
7933    }
7934}
7935
7936impl fidl::endpoints::ControlHandle for AudioDeviceEnumeratorControlHandle {
7937    fn shutdown(&self) {
7938        self.inner.shutdown()
7939    }
7940
7941    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
7942        self.inner.shutdown_with_epitaph(status)
7943    }
7944
7945    fn is_closed(&self) -> bool {
7946        self.inner.channel().is_closed()
7947    }
7948    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7949        self.inner.channel().on_closed()
7950    }
7951
7952    #[cfg(target_os = "fuchsia")]
7953    fn signal_peer(
7954        &self,
7955        clear_mask: zx::Signals,
7956        set_mask: zx::Signals,
7957    ) -> Result<(), zx_status::Status> {
7958        use fidl::Peered;
7959        self.inner.channel().signal_peer(clear_mask, set_mask)
7960    }
7961}
7962
7963impl AudioDeviceEnumeratorControlHandle {
7964    pub fn send_on_device_added(&self, mut device: &AudioDeviceInfo) -> Result<(), fidl::Error> {
7965        self.inner.send::<AudioDeviceEnumeratorOnDeviceAddedRequest>(
7966            (device,),
7967            0,
7968            0xe0fbe40057c4b44,
7969            fidl::encoding::DynamicFlags::empty(),
7970        )
7971    }
7972
7973    pub fn send_on_device_removed(&self, mut device_token: u64) -> Result<(), fidl::Error> {
7974        self.inner.send::<AudioDeviceEnumeratorOnDeviceRemovedRequest>(
7975            (device_token,),
7976            0,
7977            0x6f3b7574463d9ff8,
7978            fidl::encoding::DynamicFlags::empty(),
7979        )
7980    }
7981
7982    pub fn send_on_device_gain_changed(
7983        &self,
7984        mut device_token: u64,
7985        mut gain_info: &AudioGainInfo,
7986    ) -> Result<(), fidl::Error> {
7987        self.inner.send::<AudioDeviceEnumeratorOnDeviceGainChangedRequest>(
7988            (device_token, gain_info),
7989            0,
7990            0x14aefcbbb076b0e9,
7991            fidl::encoding::DynamicFlags::empty(),
7992        )
7993    }
7994
7995    pub fn send_on_default_device_changed(
7996        &self,
7997        mut old_default_token: u64,
7998        mut new_default_token: u64,
7999    ) -> Result<(), fidl::Error> {
8000        self.inner.send::<AudioDeviceEnumeratorOnDefaultDeviceChangedRequest>(
8001            (old_default_token, new_default_token),
8002            0,
8003            0x16357b42d4c16e11,
8004            fidl::encoding::DynamicFlags::empty(),
8005        )
8006    }
8007}
8008
8009#[must_use = "FIDL methods require a response to be sent"]
8010#[derive(Debug)]
8011pub struct AudioDeviceEnumeratorGetDevicesResponder {
8012    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
8013    tx_id: u32,
8014}
8015
8016/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
8017/// if the responder is dropped without sending a response, so that the client
8018/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8019impl std::ops::Drop for AudioDeviceEnumeratorGetDevicesResponder {
8020    fn drop(&mut self) {
8021        self.control_handle.shutdown();
8022        // Safety: drops once, never accessed again
8023        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8024    }
8025}
8026
8027impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDevicesResponder {
8028    type ControlHandle = AudioDeviceEnumeratorControlHandle;
8029
8030    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
8031        &self.control_handle
8032    }
8033
8034    fn drop_without_shutdown(mut self) {
8035        // Safety: drops once, never accessed again due to mem::forget
8036        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8037        // Prevent Drop from running (which would shut down the channel)
8038        std::mem::forget(self);
8039    }
8040}
8041
8042impl AudioDeviceEnumeratorGetDevicesResponder {
8043    /// Sends a response to the FIDL transaction.
8044    ///
8045    /// Sets the channel to shutdown if an error occurs.
8046    pub fn send(self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
8047        let _result = self.send_raw(devices);
8048        if _result.is_err() {
8049            self.control_handle.shutdown();
8050        }
8051        self.drop_without_shutdown();
8052        _result
8053    }
8054
8055    /// Similar to "send" but does not shutdown the channel if an error occurs.
8056    pub fn send_no_shutdown_on_err(
8057        self,
8058        mut devices: &[AudioDeviceInfo],
8059    ) -> Result<(), fidl::Error> {
8060        let _result = self.send_raw(devices);
8061        self.drop_without_shutdown();
8062        _result
8063    }
8064
8065    fn send_raw(&self, mut devices: &[AudioDeviceInfo]) -> Result<(), fidl::Error> {
8066        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDevicesResponse>(
8067            (devices,),
8068            self.tx_id,
8069            0x4ce1aa218aeb12a6,
8070            fidl::encoding::DynamicFlags::empty(),
8071        )
8072    }
8073}
8074
8075#[must_use = "FIDL methods require a response to be sent"]
8076#[derive(Debug)]
8077pub struct AudioDeviceEnumeratorGetDeviceGainResponder {
8078    control_handle: std::mem::ManuallyDrop<AudioDeviceEnumeratorControlHandle>,
8079    tx_id: u32,
8080}
8081
8082/// Set the the channel to be shutdown (see [`AudioDeviceEnumeratorControlHandle::shutdown`])
8083/// if the responder is dropped without sending a response, so that the client
8084/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
8085impl std::ops::Drop for AudioDeviceEnumeratorGetDeviceGainResponder {
8086    fn drop(&mut self) {
8087        self.control_handle.shutdown();
8088        // Safety: drops once, never accessed again
8089        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8090    }
8091}
8092
8093impl fidl::endpoints::Responder for AudioDeviceEnumeratorGetDeviceGainResponder {
8094    type ControlHandle = AudioDeviceEnumeratorControlHandle;
8095
8096    fn control_handle(&self) -> &AudioDeviceEnumeratorControlHandle {
8097        &self.control_handle
8098    }
8099
8100    fn drop_without_shutdown(mut self) {
8101        // Safety: drops once, never accessed again due to mem::forget
8102        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
8103        // Prevent Drop from running (which would shut down the channel)
8104        std::mem::forget(self);
8105    }
8106}
8107
8108impl AudioDeviceEnumeratorGetDeviceGainResponder {
8109    /// Sends a response to the FIDL transaction.
8110    ///
8111    /// Sets the channel to shutdown if an error occurs.
8112    pub fn send(
8113        self,
8114        mut device_token: u64,
8115        mut gain_info: &AudioGainInfo,
8116    ) -> Result<(), fidl::Error> {
8117        let _result = self.send_raw(device_token, gain_info);
8118        if _result.is_err() {
8119            self.control_handle.shutdown();
8120        }
8121        self.drop_without_shutdown();
8122        _result
8123    }
8124
8125    /// Similar to "send" but does not shutdown the channel if an error occurs.
8126    pub fn send_no_shutdown_on_err(
8127        self,
8128        mut device_token: u64,
8129        mut gain_info: &AudioGainInfo,
8130    ) -> Result<(), fidl::Error> {
8131        let _result = self.send_raw(device_token, gain_info);
8132        self.drop_without_shutdown();
8133        _result
8134    }
8135
8136    fn send_raw(
8137        &self,
8138        mut device_token: u64,
8139        mut gain_info: &AudioGainInfo,
8140    ) -> Result<(), fidl::Error> {
8141        self.control_handle.inner.send::<AudioDeviceEnumeratorGetDeviceGainResponse>(
8142            (device_token, gain_info),
8143            self.tx_id,
8144            0x25dd4723403c414b,
8145            fidl::encoding::DynamicFlags::empty(),
8146        )
8147    }
8148}
8149
8150#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
8151pub struct AudioRendererMarker;
8152
8153impl fidl::endpoints::ProtocolMarker for AudioRendererMarker {
8154    type Proxy = AudioRendererProxy;
8155    type RequestStream = AudioRendererRequestStream;
8156    #[cfg(target_os = "fuchsia")]
8157    type SynchronousProxy = AudioRendererSynchronousProxy;
8158
8159    const DEBUG_NAME: &'static str = "fuchsia.media.AudioRenderer";
8160}
8161impl fidl::endpoints::DiscoverableProtocolMarker for AudioRendererMarker {}
8162
8163pub trait AudioRendererProxyInterface: Send + Sync {
8164    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
8165    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
8166    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8167    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
8168    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
8169    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
8170    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
8171    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
8172    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
8173    fn r#bind_gain_control(
8174        &self,
8175        gain_control_request: fidl::endpoints::ServerEnd<
8176            fidl_fuchsia_media_audio::GainControlMarker,
8177        >,
8178    ) -> Result<(), fidl::Error>;
8179    fn r#set_pts_units(
8180        &self,
8181        tick_per_second_numerator: u32,
8182        tick_per_second_denominator: u32,
8183    ) -> Result<(), fidl::Error>;
8184    fn r#set_pts_continuity_threshold(&self, threshold_seconds: f32) -> Result<(), fidl::Error>;
8185    type GetReferenceClockResponseFut: std::future::Future<Output = Result<fidl::Clock, fidl::Error>>
8186        + Send;
8187    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut;
8188    fn r#set_reference_clock(
8189        &self,
8190        reference_clock: Option<fidl::Clock>,
8191    ) -> Result<(), fidl::Error>;
8192    fn r#set_usage(&self, usage: AudioRenderUsage) -> Result<(), fidl::Error>;
8193    fn r#set_usage2(&self, usage2: AudioRenderUsage2) -> Result<(), fidl::Error>;
8194    fn r#set_pcm_stream_type(&self, type_: &AudioStreamType) -> Result<(), fidl::Error>;
8195    fn r#enable_min_lead_time_events(&self, enabled: bool) -> Result<(), fidl::Error>;
8196    type GetMinLeadTimeResponseFut: std::future::Future<Output = Result<i64, fidl::Error>> + Send;
8197    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut;
8198    type PlayResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
8199    fn r#play(&self, reference_time: i64, media_time: i64) -> Self::PlayResponseFut;
8200    fn r#play_no_reply(&self, reference_time: i64, media_time: i64) -> Result<(), fidl::Error>;
8201    type PauseResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>> + Send;
8202    fn r#pause(&self) -> Self::PauseResponseFut;
8203    fn r#pause_no_reply(&self) -> Result<(), fidl::Error>;
8204}
8205#[derive(Debug)]
8206#[cfg(target_os = "fuchsia")]
8207pub struct AudioRendererSynchronousProxy {
8208    client: fidl::client::sync::Client,
8209}
8210
8211#[cfg(target_os = "fuchsia")]
8212impl fidl::endpoints::SynchronousProxy for AudioRendererSynchronousProxy {
8213    type Proxy = AudioRendererProxy;
8214    type Protocol = AudioRendererMarker;
8215
8216    fn from_channel(inner: fidl::Channel) -> Self {
8217        Self::new(inner)
8218    }
8219
8220    fn into_channel(self) -> fidl::Channel {
8221        self.client.into_channel()
8222    }
8223
8224    fn as_channel(&self) -> &fidl::Channel {
8225        self.client.as_channel()
8226    }
8227}
8228
8229#[cfg(target_os = "fuchsia")]
8230impl AudioRendererSynchronousProxy {
8231    pub fn new(channel: fidl::Channel) -> Self {
8232        Self { client: fidl::client::sync::Client::new(channel) }
8233    }
8234
8235    pub fn into_channel(self) -> fidl::Channel {
8236        self.client.into_channel()
8237    }
8238
8239    /// Waits until an event arrives and returns it. It is safe for other
8240    /// threads to make concurrent requests while waiting for an event.
8241    pub fn wait_for_event(
8242        &self,
8243        deadline: zx::MonotonicInstant,
8244    ) -> Result<AudioRendererEvent, fidl::Error> {
8245        AudioRendererEvent::decode(self.client.wait_for_event::<AudioRendererMarker>(deadline)?)
8246    }
8247
8248    /// Adds a payload buffer to the current buffer set associated with the
8249    /// connection. A `StreamPacket` struct reference a payload buffer in the
8250    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8251    ///
8252    /// A buffer with ID `id` must not be in the current set when this method is
8253    /// invoked, otherwise the service will close the connection.
8254    pub fn r#add_payload_buffer(
8255        &self,
8256        mut id: u32,
8257        mut payload_buffer: fidl::Vmo,
8258    ) -> Result<(), fidl::Error> {
8259        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
8260            (id, payload_buffer),
8261            0x3b3a37fc34fe5b56,
8262            fidl::encoding::DynamicFlags::empty(),
8263        )
8264    }
8265
8266    /// Removes a payload buffer from the current buffer set associated with the
8267    /// connection.
8268    ///
8269    /// A buffer with ID `id` must exist in the current set when this method is
8270    /// invoked, otherwise the service will will close the connection.
8271    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8272        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
8273            (id,),
8274            0x5d1e4f74c3658262,
8275            fidl::encoding::DynamicFlags::empty(),
8276        )
8277    }
8278
8279    /// Sends a packet to the service. The response is sent when the service is
8280    /// done with the associated payload memory.
8281    ///
8282    /// `packet` must be valid for the current buffer set, otherwise the service
8283    /// will close the connection.
8284    pub fn r#send_packet(
8285        &self,
8286        mut packet: &StreamPacket,
8287        ___deadline: zx::MonotonicInstant,
8288    ) -> Result<(), fidl::Error> {
8289        let _response = self.client.send_query::<
8290            StreamSinkSendPacketRequest,
8291            fidl::encoding::EmptyPayload,
8292            AudioRendererMarker,
8293        >(
8294            (packet,),
8295            0x67cddd607442775f,
8296            fidl::encoding::DynamicFlags::empty(),
8297            ___deadline,
8298        )?;
8299        Ok(_response)
8300    }
8301
8302    /// Sends a packet to the service. This interface doesn't define how the
8303    /// client knows when the sink is done with the associated payload memory.
8304    /// The inheriting interface must define that.
8305    ///
8306    /// `packet` must be valid for the current buffer set, otherwise the service
8307    /// will close the connection.
8308    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8309        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
8310            (packet,),
8311            0x8d9b8b413ceba9d,
8312            fidl::encoding::DynamicFlags::empty(),
8313        )
8314    }
8315
8316    /// Indicates the stream has ended. The precise semantics of this method are
8317    /// determined by the inheriting interface.
8318    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8319        self.client.send::<fidl::encoding::EmptyPayload>(
8320            (),
8321            0x6180fd6f7e793b71,
8322            fidl::encoding::DynamicFlags::empty(),
8323        )
8324    }
8325
8326    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8327    /// and not yet released. The response is sent after all packets have been
8328    /// released.
8329    pub fn r#discard_all_packets(
8330        &self,
8331        ___deadline: zx::MonotonicInstant,
8332    ) -> Result<(), fidl::Error> {
8333        let _response = self.client.send_query::<
8334            fidl::encoding::EmptyPayload,
8335            fidl::encoding::EmptyPayload,
8336            AudioRendererMarker,
8337        >(
8338            (),
8339            0x6f4dad7af2917665,
8340            fidl::encoding::DynamicFlags::empty(),
8341            ___deadline,
8342        )?;
8343        Ok(_response)
8344    }
8345
8346    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8347    /// and not yet released.
8348    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8349        self.client.send::<fidl::encoding::EmptyPayload>(
8350            (),
8351            0x50d36d0d23081bc4,
8352            fidl::encoding::DynamicFlags::empty(),
8353        )
8354    }
8355
8356    /// Binds to the gain control for this AudioRenderer.
8357    pub fn r#bind_gain_control(
8358        &self,
8359        mut gain_control_request: fidl::endpoints::ServerEnd<
8360            fidl_fuchsia_media_audio::GainControlMarker,
8361        >,
8362    ) -> Result<(), fidl::Error> {
8363        self.client.send::<AudioRendererBindGainControlRequest>(
8364            (gain_control_request,),
8365            0x293f5c7f8fba2bdc,
8366            fidl::encoding::DynamicFlags::empty(),
8367        )
8368    }
8369
8370    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8371    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8372    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8373    pub fn r#set_pts_units(
8374        &self,
8375        mut tick_per_second_numerator: u32,
8376        mut tick_per_second_denominator: u32,
8377    ) -> Result<(), fidl::Error> {
8378        self.client.send::<AudioRendererSetPtsUnitsRequest>(
8379            (tick_per_second_numerator, tick_per_second_denominator),
8380            0xf68cd108785a27c,
8381            fidl::encoding::DynamicFlags::empty(),
8382        )
8383    }
8384
8385    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8386    /// and expected PTS (determined using interpolation). Beyond this threshold,
8387    /// a stream is no longer considered 'continuous' by the renderer.
8388    ///
8389    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8390    /// Most users should not need to change this value from its default.
8391    ///
8392    /// Example:
8393    /// A user is playing back 48KHz audio from a container, which also contains
8394    /// video and needs to be synchronized with the audio. The timestamps are
8395    /// provided explicitly per packet by the container, and expressed in mSec
8396    /// units. This means that a single tick of the media timeline (1 mSec)
8397    /// represents exactly 48 frames of audio. The application in this scenario
8398    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8399    /// frames of audio, and each with an explicit timestamp set to the best
8400    /// possible representation of the presentation time (given this media
8401    /// clock's resolution). So, starting from zero, the timestamps would be..
8402    ///
8403    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8404    ///
8405    /// In this example, attempting to use the presentation time to compute the
8406    /// starting frame number of the audio in the packet would be wrong the
8407    /// majority of the time. The first timestamp is correct (by definition), but
8408    /// it will be 24 packets before the timestamps and frame numbers come back
8409    /// into alignment (the 24th packet would start with the 11280th audio frame
8410    /// and have a PTS of exactly 235).
8411    ///
8412    /// One way to fix this situation is to set the PTS continuity threshold
8413    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8414    /// the number of frames contained within a single tick of the media clock,
8415    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8416    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8417    /// explicitly provided PTS would be considered to be a continuation of the
8418    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8419    /// would work well.
8420    ///
8421    /// Other possible uses:
8422    /// Users who are scheduling audio explicitly, relative to a clock which has
8423    /// not been configured as the reference clock, can use this value to control
8424    /// the maximum acceptable synchronization error before a discontinuity is
8425    /// introduced. E.g., if a user is scheduling audio based on a recovered
8426    /// common media clock, and has not published that clock as the reference
8427    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8428    /// can accumulate before the AudioRenderer deliberately inserts a
8429    /// presentation discontinuity to account for the error.
8430    ///
8431    /// Users whose need to deal with a container where their timestamps may be
8432    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8433    /// something larger. This should be the maximum level of inaccuracy present
8434    /// in the container timestamps, if known. Failing that, it could be set to
8435    /// the maximum tolerable level of drift error before absolute timestamps are
8436    /// explicitly obeyed. Finally, a user could set this number to a very large
8437    /// value (86400.0 seconds, for example) to effectively cause *all*
8438    /// timestamps to be ignored after the first, thus treating all audio as
8439    /// continuous with previously delivered packets. Conversely, users who wish
8440    /// to *always* explicitly schedule their audio packets exactly may specify
8441    /// a CT of 0.
8442    ///
8443    /// Note: explicitly specifying high-frequency PTS units reduces the default
8444    /// continuity threshold accordingly. Internally, this threshold is stored as an
8445    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8446    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8447    /// For this reason, specifying PTS units with a frequency greater than 8192x
8448    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8449    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8450    pub fn r#set_pts_continuity_threshold(
8451        &self,
8452        mut threshold_seconds: f32,
8453    ) -> Result<(), fidl::Error> {
8454        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
8455            (threshold_seconds,),
8456            0x2849ba571d1971ba,
8457            fidl::encoding::DynamicFlags::empty(),
8458        )
8459    }
8460
8461    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8462    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8463    pub fn r#get_reference_clock(
8464        &self,
8465        ___deadline: zx::MonotonicInstant,
8466    ) -> Result<fidl::Clock, fidl::Error> {
8467        let _response = self.client.send_query::<
8468            fidl::encoding::EmptyPayload,
8469            AudioRendererGetReferenceClockResponse,
8470            AudioRendererMarker,
8471        >(
8472            (),
8473            0x2f7a7f011a172f7e,
8474            fidl::encoding::DynamicFlags::empty(),
8475            ___deadline,
8476        )?;
8477        Ok(_response.reference_clock)
8478    }
8479
8480    /// Sets the reference clock that controls this renderer's playback rate. If the input
8481    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8482    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8483    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8484    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8485    ///
8486    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8487    /// cannot be called a second time (even if the renderer format has not yet been set).
8488    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8489    /// diverge at some later time, they should create a clone of the monotonic clock, set
8490    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8491    pub fn r#set_reference_clock(
8492        &self,
8493        mut reference_clock: Option<fidl::Clock>,
8494    ) -> Result<(), fidl::Error> {
8495        self.client.send::<AudioRendererSetReferenceClockRequest>(
8496            (reference_clock,),
8497            0x39acd05d832b5fed,
8498            fidl::encoding::DynamicFlags::empty(),
8499        )
8500    }
8501
8502    /// Sets the usage of the render stream. This method may not be called after
8503    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8504    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
8505        self.client.send::<AudioRendererSetUsageRequest>(
8506            (usage,),
8507            0x3994bd23b55a733e,
8508            fidl::encoding::DynamicFlags::empty(),
8509        )
8510    }
8511
8512    /// Sets the usage of the render stream. This method may not be called after
8513    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
8514    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
8515        self.client.send::<AudioRendererSetUsage2Request>(
8516            (usage2,),
8517            0x2904035c7132b103,
8518            fidl::encoding::DynamicFlags::FLEXIBLE,
8519        )
8520    }
8521
8522    /// Sets the type of the stream to be delivered by the client. Using this method implies
8523    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
8524    ///
8525    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
8526    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
8527    /// methods such as `SendPacket`/`SendPacketNoReply`.
8528    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
8529        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
8530            (type_,),
8531            0x27aa715d8901fa19,
8532            fidl::encoding::DynamicFlags::empty(),
8533        )
8534    }
8535
8536    /// Enables or disables notifications about changes to the minimum clock lead
8537    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
8538    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
8539    /// event with the current minimum lead time for the AudioRenderer. If the
8540    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
8541    /// new value. This behavior will continue until the user calls
8542    /// `EnableMinLeadTimeEvents(false)`.
8543    ///
8544    /// The minimum clock lead time is the amount of time ahead of the reference
8545    /// clock's understanding of "now" that packets needs to arrive (relative to
8546    /// the playback clock transformation) in order for the mixer to be able to
8547    /// mix packet. For example...
8548    ///
8549    /// + Let the PTS of packet X be P(X)
8550    /// + Let the function which transforms PTS -> RefClock be R(p) (this
8551    ///   function is determined by the call to Play(...)
8552    /// + Let the minimum lead time be MLT
8553    ///
8554    /// If R(P(X)) < RefClock.Now() + MLT
8555    /// Then the packet is late, and some (or all) of the packet's payload will
8556    /// need to be skipped in order to present the packet at the scheduled time.
8557    ///
8558    /// The value `min_lead_time_nsec = 0` is a special value which indicates
8559    /// that the AudioRenderer is not yet routed to an output device. If `Play`
8560    /// is called before the AudioRenderer is routed, any played packets will be
8561    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
8562    /// calling `Play`.
8563    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
8564        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
8565            (enabled,),
8566            0x62808dfad72bf890,
8567            fidl::encoding::DynamicFlags::empty(),
8568        )
8569    }
8570
8571    ///
8572    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
8573    /// there's little reason to do so. This is because lead time is a function
8574    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
8575    /// If min lead time events are enabled before `SetPcmStreamType` (with
8576    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
8577    /// response to `SetPcmStreamType`.
8578    pub fn r#get_min_lead_time(
8579        &self,
8580        ___deadline: zx::MonotonicInstant,
8581    ) -> Result<i64, fidl::Error> {
8582        let _response = self.client.send_query::<
8583            fidl::encoding::EmptyPayload,
8584            AudioRendererGetMinLeadTimeResponse,
8585            AudioRendererMarker,
8586        >(
8587            (),
8588            0x1cf3c3ecd8fec26b,
8589            fidl::encoding::DynamicFlags::empty(),
8590            ___deadline,
8591        )?;
8592        Ok(_response.min_lead_time_nsec)
8593    }
8594
8595    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
8596    /// of the media timeline, using specific values provided by the caller (or
8597    /// default values if not specified). In an optional callback, returns the
8598    /// timestamp values ultimately used -- these set the ongoing relationship
8599    /// between the media and reference timelines (i.e., how to translate between
8600    /// the domain of presentation timestamps, and the realm of local system
8601    /// time).
8602    ///
8603    /// Local system time is specified in units of nanoseconds; media_time is
8604    /// specified in the units defined by the user in the `SetPtsUnits` function,
8605    /// or nanoseconds if `SetPtsUnits` is not called.
8606    ///
8607    /// The act of placing an AudioRenderer into the playback state establishes a
8608    /// relationship between 1) the user-defined media (or presentation) timeline
8609    /// for this particular AudioRenderer, and 2) the real-world system reference
8610    /// timeline. To communicate how to translate between timelines, the Play()
8611    /// callback provides an equivalent timestamp in each time domain. The first
8612    /// value ('reference_time') is given in terms of this renderer's reference
8613    /// clock; the second value ('media_time') is what media instant exactly
8614    /// corresponds to that local time. Restated, the frame at 'media_time' in
8615    /// the audio stream should be presented at 'reference_time' according to
8616    /// the reference clock.
8617    ///
8618    /// Note: on calling this API, media_time immediately starts advancing. It is
8619    /// possible (if uncommon) for a caller to specify a system time that is
8620    /// far in the past, or far into the future. This, along with the specified
8621    /// media time, is simply used to determine what media time corresponds to
8622    /// 'now', and THAT media time is then intersected with presentation
8623    /// timestamps of packets already submitted, to determine which media frames
8624    /// should be presented next.
8625    ///
8626    /// With the corresponding reference_time and media_time values, a user can
8627    /// translate arbitrary time values from one timeline into the other. After
8628    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
8629    /// given the 'ref_start' and 'media_start' values from `Play`, then for
8630    /// any 'ref_time':
8631    ///
8632    /// media_time = ( (ref_time - ref_start) / 1e9
8633    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
8634    ///              + media_start
8635    ///
8636    /// Conversely, for any presentation timestamp 'media_time':
8637    ///
8638    /// ref_time = ( (media_time - media_start)
8639    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
8640    ///              * 1e9 )
8641    ///            + ref_start
8642    ///
8643    /// Users, depending on their use case, may optionally choose not to specify
8644    /// one or both of these timestamps. A timestamp may be omitted by supplying
8645    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
8646    /// any omitted timestamp value using the following rules:
8647    ///
8648    /// Reference Time
8649    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
8650    /// reference time to begin presentation, based on the minimum lead times for
8651    /// the output devices that are currently bound to this AudioRenderer. For
8652    /// example, if an AudioRenderer is bound to an internal audio output
8653    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
8654    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
8655    /// is omitted) select a reference time 80 mSec from now.
8656    ///
8657    /// Media Time
8658    /// If media_time is omitted, the AudioRenderer will select one of two
8659    /// values.
8660    /// - If the AudioRenderer is resuming from the paused state, and packets
8661    /// have not been discarded since being paused, then the AudioRenderer will
8662    /// use a media_time corresponding to the instant at which the presentation
8663    /// became paused.
8664    /// - If the AudioRenderer is being placed into a playing state for the first
8665    /// time following startup or a 'discard packets' operation, the initial
8666    /// media_time will be set to the PTS of the first payload in the pending
8667    /// packet queue. If the pending queue is empty, initial media_time will be
8668    /// set to zero.
8669    ///
8670    /// Return Value
8671    /// When requested, the AudioRenderer will return the 'reference_time' and
8672    /// 'media_time' which were selected and used (whether they were explicitly
8673    /// specified or not) in the return value of the play call.
8674    ///
8675    /// Examples
8676    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
8677    /// to start playing as soon as possible. The user may call Play without
8678    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
8679    ///
8680    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
8681    /// playback at a specified 'reference_time', in sync with some other media
8682    /// stream, either initially or after discarding packets. The user would call
8683    /// `Play(reference_time, NO_TIMESTAMP)`.
8684    ///
8685    /// 3. A user has queued some audio using `SendPacket`. The first of these
8686    /// packets has a PTS of zero, and the user wishes playback to begin as soon
8687    /// as possible, but wishes to skip all of the audio content between PTS 0
8688    /// and PTS 'media_time'. The user would call
8689    /// `Play(NO_TIMESTAMP, media_time)`.
8690    ///
8691    /// 4. A user has queued some audio using `SendPacket` and want to present
8692    /// this media in synch with another player in a different device. The
8693    /// coordinator of the group of distributed players sends an explicit
8694    /// message to each player telling them to begin presentation of audio at
8695    /// PTS 'media_time', at the time (based on the group's shared reference
8696    /// clock) 'reference_time'. Here the user would call
8697    /// `Play(reference_time, media_time)`.
8698    pub fn r#play(
8699        &self,
8700        mut reference_time: i64,
8701        mut media_time: i64,
8702        ___deadline: zx::MonotonicInstant,
8703    ) -> Result<(i64, i64), fidl::Error> {
8704        let _response = self
8705            .client
8706            .send_query::<AudioRendererPlayRequest, AudioRendererPlayResponse, AudioRendererMarker>(
8707                (reference_time, media_time),
8708                0x3c0162db084f74a3,
8709                fidl::encoding::DynamicFlags::empty(),
8710                ___deadline,
8711            )?;
8712        Ok((_response.reference_time, _response.media_time))
8713    }
8714
8715    pub fn r#play_no_reply(
8716        &self,
8717        mut reference_time: i64,
8718        mut media_time: i64,
8719    ) -> Result<(), fidl::Error> {
8720        self.client.send::<AudioRendererPlayNoReplyRequest>(
8721            (reference_time, media_time),
8722            0x1b7fe832b68c22ef,
8723            fidl::encoding::DynamicFlags::empty(),
8724        )
8725    }
8726
8727    /// Immediately puts the AudioRenderer into the paused state and then report
8728    /// the relationship between the media and reference timelines which was
8729    /// established (if requested).
8730    ///
8731    /// If the AudioRenderer is already in the paused state when this called,
8732    /// the previously-established timeline values are returned (if requested).
8733    pub fn r#pause(&self, ___deadline: zx::MonotonicInstant) -> Result<(i64, i64), fidl::Error> {
8734        let _response = self.client.send_query::<
8735            fidl::encoding::EmptyPayload,
8736            AudioRendererPauseResponse,
8737            AudioRendererMarker,
8738        >(
8739            (),
8740            0x41d557588d93d153,
8741            fidl::encoding::DynamicFlags::empty(),
8742            ___deadline,
8743        )?;
8744        Ok((_response.reference_time, _response.media_time))
8745    }
8746
8747    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
8748        self.client.send::<fidl::encoding::EmptyPayload>(
8749            (),
8750            0x24cc45d4f3855ab,
8751            fidl::encoding::DynamicFlags::empty(),
8752        )
8753    }
8754}
8755
8756#[cfg(target_os = "fuchsia")]
8757impl From<AudioRendererSynchronousProxy> for zx::NullableHandle {
8758    fn from(value: AudioRendererSynchronousProxy) -> Self {
8759        value.into_channel().into()
8760    }
8761}
8762
8763#[cfg(target_os = "fuchsia")]
8764impl From<fidl::Channel> for AudioRendererSynchronousProxy {
8765    fn from(value: fidl::Channel) -> Self {
8766        Self::new(value)
8767    }
8768}
8769
8770#[cfg(target_os = "fuchsia")]
8771impl fidl::endpoints::FromClient for AudioRendererSynchronousProxy {
8772    type Protocol = AudioRendererMarker;
8773
8774    fn from_client(value: fidl::endpoints::ClientEnd<AudioRendererMarker>) -> Self {
8775        Self::new(value.into_channel())
8776    }
8777}
8778
8779#[derive(Debug, Clone)]
8780pub struct AudioRendererProxy {
8781    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
8782}
8783
8784impl fidl::endpoints::Proxy for AudioRendererProxy {
8785    type Protocol = AudioRendererMarker;
8786
8787    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
8788        Self::new(inner)
8789    }
8790
8791    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
8792        self.client.into_channel().map_err(|client| Self { client })
8793    }
8794
8795    fn as_channel(&self) -> &::fidl::AsyncChannel {
8796        self.client.as_channel()
8797    }
8798}
8799
8800impl AudioRendererProxy {
8801    /// Create a new Proxy for fuchsia.media/AudioRenderer.
8802    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
8803        let protocol_name = <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
8804        Self { client: fidl::client::Client::new(channel, protocol_name) }
8805    }
8806
8807    /// Get a Stream of events from the remote end of the protocol.
8808    ///
8809    /// # Panics
8810    ///
8811    /// Panics if the event stream was already taken.
8812    pub fn take_event_stream(&self) -> AudioRendererEventStream {
8813        AudioRendererEventStream { event_receiver: self.client.take_event_receiver() }
8814    }
8815
8816    /// Adds a payload buffer to the current buffer set associated with the
8817    /// connection. A `StreamPacket` struct reference a payload buffer in the
8818    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
8819    ///
8820    /// A buffer with ID `id` must not be in the current set when this method is
8821    /// invoked, otherwise the service will close the connection.
8822    pub fn r#add_payload_buffer(
8823        &self,
8824        mut id: u32,
8825        mut payload_buffer: fidl::Vmo,
8826    ) -> Result<(), fidl::Error> {
8827        AudioRendererProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
8828    }
8829
8830    /// Removes a payload buffer from the current buffer set associated with the
8831    /// connection.
8832    ///
8833    /// A buffer with ID `id` must exist in the current set when this method is
8834    /// invoked, otherwise the service will will close the connection.
8835    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
8836        AudioRendererProxyInterface::r#remove_payload_buffer(self, id)
8837    }
8838
8839    /// Sends a packet to the service. The response is sent when the service is
8840    /// done with the associated payload memory.
8841    ///
8842    /// `packet` must be valid for the current buffer set, otherwise the service
8843    /// will close the connection.
8844    pub fn r#send_packet(
8845        &self,
8846        mut packet: &StreamPacket,
8847    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8848        AudioRendererProxyInterface::r#send_packet(self, packet)
8849    }
8850
8851    /// Sends a packet to the service. This interface doesn't define how the
8852    /// client knows when the sink is done with the associated payload memory.
8853    /// The inheriting interface must define that.
8854    ///
8855    /// `packet` must be valid for the current buffer set, otherwise the service
8856    /// will close the connection.
8857    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
8858        AudioRendererProxyInterface::r#send_packet_no_reply(self, packet)
8859    }
8860
8861    /// Indicates the stream has ended. The precise semantics of this method are
8862    /// determined by the inheriting interface.
8863    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
8864        AudioRendererProxyInterface::r#end_of_stream(self)
8865    }
8866
8867    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8868    /// and not yet released. The response is sent after all packets have been
8869    /// released.
8870    pub fn r#discard_all_packets(
8871        &self,
8872    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
8873        AudioRendererProxyInterface::r#discard_all_packets(self)
8874    }
8875
8876    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
8877    /// and not yet released.
8878    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
8879        AudioRendererProxyInterface::r#discard_all_packets_no_reply(self)
8880    }
8881
8882    /// Binds to the gain control for this AudioRenderer.
8883    pub fn r#bind_gain_control(
8884        &self,
8885        mut gain_control_request: fidl::endpoints::ServerEnd<
8886            fidl_fuchsia_media_audio::GainControlMarker,
8887        >,
8888    ) -> Result<(), fidl::Error> {
8889        AudioRendererProxyInterface::r#bind_gain_control(self, gain_control_request)
8890    }
8891
8892    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
8893    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
8894    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
8895    pub fn r#set_pts_units(
8896        &self,
8897        mut tick_per_second_numerator: u32,
8898        mut tick_per_second_denominator: u32,
8899    ) -> Result<(), fidl::Error> {
8900        AudioRendererProxyInterface::r#set_pts_units(
8901            self,
8902            tick_per_second_numerator,
8903            tick_per_second_denominator,
8904        )
8905    }
8906
8907    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
8908    /// and expected PTS (determined using interpolation). Beyond this threshold,
8909    /// a stream is no longer considered 'continuous' by the renderer.
8910    ///
8911    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
8912    /// Most users should not need to change this value from its default.
8913    ///
8914    /// Example:
8915    /// A user is playing back 48KHz audio from a container, which also contains
8916    /// video and needs to be synchronized with the audio. The timestamps are
8917    /// provided explicitly per packet by the container, and expressed in mSec
8918    /// units. This means that a single tick of the media timeline (1 mSec)
8919    /// represents exactly 48 frames of audio. The application in this scenario
8920    /// delivers packets of audio to the AudioRenderer, each with exactly 470
8921    /// frames of audio, and each with an explicit timestamp set to the best
8922    /// possible representation of the presentation time (given this media
8923    /// clock's resolution). So, starting from zero, the timestamps would be..
8924    ///
8925    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
8926    ///
8927    /// In this example, attempting to use the presentation time to compute the
8928    /// starting frame number of the audio in the packet would be wrong the
8929    /// majority of the time. The first timestamp is correct (by definition), but
8930    /// it will be 24 packets before the timestamps and frame numbers come back
8931    /// into alignment (the 24th packet would start with the 11280th audio frame
8932    /// and have a PTS of exactly 235).
8933    ///
8934    /// One way to fix this situation is to set the PTS continuity threshold
8935    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
8936    /// the number of frames contained within a single tick of the media clock,
8937    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
8938    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
8939    /// explicitly provided PTS would be considered to be a continuation of the
8940    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
8941    /// would work well.
8942    ///
8943    /// Other possible uses:
8944    /// Users who are scheduling audio explicitly, relative to a clock which has
8945    /// not been configured as the reference clock, can use this value to control
8946    /// the maximum acceptable synchronization error before a discontinuity is
8947    /// introduced. E.g., if a user is scheduling audio based on a recovered
8948    /// common media clock, and has not published that clock as the reference
8949    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
8950    /// can accumulate before the AudioRenderer deliberately inserts a
8951    /// presentation discontinuity to account for the error.
8952    ///
8953    /// Users whose need to deal with a container where their timestamps may be
8954    /// even less correct than +/- 1/2 of a PTS tick may set this value to
8955    /// something larger. This should be the maximum level of inaccuracy present
8956    /// in the container timestamps, if known. Failing that, it could be set to
8957    /// the maximum tolerable level of drift error before absolute timestamps are
8958    /// explicitly obeyed. Finally, a user could set this number to a very large
8959    /// value (86400.0 seconds, for example) to effectively cause *all*
8960    /// timestamps to be ignored after the first, thus treating all audio as
8961    /// continuous with previously delivered packets. Conversely, users who wish
8962    /// to *always* explicitly schedule their audio packets exactly may specify
8963    /// a CT of 0.
8964    ///
8965    /// Note: explicitly specifying high-frequency PTS units reduces the default
8966    /// continuity threshold accordingly. Internally, this threshold is stored as an
8967    /// integer of 1/8192 subframes. The default threshold is computed as follows:
8968    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
8969    /// For this reason, specifying PTS units with a frequency greater than 8192x
8970    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
8971    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
8972    pub fn r#set_pts_continuity_threshold(
8973        &self,
8974        mut threshold_seconds: f32,
8975    ) -> Result<(), fidl::Error> {
8976        AudioRendererProxyInterface::r#set_pts_continuity_threshold(self, threshold_seconds)
8977    }
8978
8979    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
8980    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
8981    pub fn r#get_reference_clock(
8982        &self,
8983    ) -> fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>
8984    {
8985        AudioRendererProxyInterface::r#get_reference_clock(self)
8986    }
8987
8988    /// Sets the reference clock that controls this renderer's playback rate. If the input
8989    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
8990    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
8991    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
8992    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
8993    ///
8994    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
8995    /// cannot be called a second time (even if the renderer format has not yet been set).
8996    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
8997    /// diverge at some later time, they should create a clone of the monotonic clock, set
8998    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
8999    pub fn r#set_reference_clock(
9000        &self,
9001        mut reference_clock: Option<fidl::Clock>,
9002    ) -> Result<(), fidl::Error> {
9003        AudioRendererProxyInterface::r#set_reference_clock(self, reference_clock)
9004    }
9005
9006    /// Sets the usage of the render stream. This method may not be called after
9007    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9008    pub fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9009        AudioRendererProxyInterface::r#set_usage(self, usage)
9010    }
9011
9012    /// Sets the usage of the render stream. This method may not be called after
9013    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
9014    pub fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9015        AudioRendererProxyInterface::r#set_usage2(self, usage2)
9016    }
9017
9018    /// Sets the type of the stream to be delivered by the client. Using this method implies
9019    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
9020    ///
9021    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
9022    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
9023    /// methods such as `SendPacket`/`SendPacketNoReply`.
9024    pub fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9025        AudioRendererProxyInterface::r#set_pcm_stream_type(self, type_)
9026    }
9027
9028    /// Enables or disables notifications about changes to the minimum clock lead
9029    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
9030    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
9031    /// event with the current minimum lead time for the AudioRenderer. If the
9032    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
9033    /// new value. This behavior will continue until the user calls
9034    /// `EnableMinLeadTimeEvents(false)`.
9035    ///
9036    /// The minimum clock lead time is the amount of time ahead of the reference
9037    /// clock's understanding of "now" that packets needs to arrive (relative to
9038    /// the playback clock transformation) in order for the mixer to be able to
9039    /// mix packet. For example...
9040    ///
9041    /// + Let the PTS of packet X be P(X)
9042    /// + Let the function which transforms PTS -> RefClock be R(p) (this
9043    ///   function is determined by the call to Play(...)
9044    /// + Let the minimum lead time be MLT
9045    ///
9046    /// If R(P(X)) < RefClock.Now() + MLT
9047    /// Then the packet is late, and some (or all) of the packet's payload will
9048    /// need to be skipped in order to present the packet at the scheduled time.
9049    ///
9050    /// The value `min_lead_time_nsec = 0` is a special value which indicates
9051    /// that the AudioRenderer is not yet routed to an output device. If `Play`
9052    /// is called before the AudioRenderer is routed, any played packets will be
9053    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
9054    /// calling `Play`.
9055    pub fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9056        AudioRendererProxyInterface::r#enable_min_lead_time_events(self, enabled)
9057    }
9058
9059    ///
9060    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
9061    /// there's little reason to do so. This is because lead time is a function
9062    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
9063    /// If min lead time events are enabled before `SetPcmStreamType` (with
9064    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
9065    /// response to `SetPcmStreamType`.
9066    pub fn r#get_min_lead_time(
9067        &self,
9068    ) -> fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect> {
9069        AudioRendererProxyInterface::r#get_min_lead_time(self)
9070    }
9071
9072    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
9073    /// of the media timeline, using specific values provided by the caller (or
9074    /// default values if not specified). In an optional callback, returns the
9075    /// timestamp values ultimately used -- these set the ongoing relationship
9076    /// between the media and reference timelines (i.e., how to translate between
9077    /// the domain of presentation timestamps, and the realm of local system
9078    /// time).
9079    ///
9080    /// Local system time is specified in units of nanoseconds; media_time is
9081    /// specified in the units defined by the user in the `SetPtsUnits` function,
9082    /// or nanoseconds if `SetPtsUnits` is not called.
9083    ///
9084    /// The act of placing an AudioRenderer into the playback state establishes a
9085    /// relationship between 1) the user-defined media (or presentation) timeline
9086    /// for this particular AudioRenderer, and 2) the real-world system reference
9087    /// timeline. To communicate how to translate between timelines, the Play()
9088    /// callback provides an equivalent timestamp in each time domain. The first
9089    /// value ('reference_time') is given in terms of this renderer's reference
9090    /// clock; the second value ('media_time') is what media instant exactly
9091    /// corresponds to that local time. Restated, the frame at 'media_time' in
9092    /// the audio stream should be presented at 'reference_time' according to
9093    /// the reference clock.
9094    ///
9095    /// Note: on calling this API, media_time immediately starts advancing. It is
9096    /// possible (if uncommon) for a caller to specify a system time that is
9097    /// far in the past, or far into the future. This, along with the specified
9098    /// media time, is simply used to determine what media time corresponds to
9099    /// 'now', and THAT media time is then intersected with presentation
9100    /// timestamps of packets already submitted, to determine which media frames
9101    /// should be presented next.
9102    ///
9103    /// With the corresponding reference_time and media_time values, a user can
9104    /// translate arbitrary time values from one timeline into the other. After
9105    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
9106    /// given the 'ref_start' and 'media_start' values from `Play`, then for
9107    /// any 'ref_time':
9108    ///
9109    /// media_time = ( (ref_time - ref_start) / 1e9
9110    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
9111    ///              + media_start
9112    ///
9113    /// Conversely, for any presentation timestamp 'media_time':
9114    ///
9115    /// ref_time = ( (media_time - media_start)
9116    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
9117    ///              * 1e9 )
9118    ///            + ref_start
9119    ///
9120    /// Users, depending on their use case, may optionally choose not to specify
9121    /// one or both of these timestamps. A timestamp may be omitted by supplying
9122    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
9123    /// any omitted timestamp value using the following rules:
9124    ///
9125    /// Reference Time
9126    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
9127    /// reference time to begin presentation, based on the minimum lead times for
9128    /// the output devices that are currently bound to this AudioRenderer. For
9129    /// example, if an AudioRenderer is bound to an internal audio output
9130    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
9131    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
9132    /// is omitted) select a reference time 80 mSec from now.
9133    ///
9134    /// Media Time
9135    /// If media_time is omitted, the AudioRenderer will select one of two
9136    /// values.
9137    /// - If the AudioRenderer is resuming from the paused state, and packets
9138    /// have not been discarded since being paused, then the AudioRenderer will
9139    /// use a media_time corresponding to the instant at which the presentation
9140    /// became paused.
9141    /// - If the AudioRenderer is being placed into a playing state for the first
9142    /// time following startup or a 'discard packets' operation, the initial
9143    /// media_time will be set to the PTS of the first payload in the pending
9144    /// packet queue. If the pending queue is empty, initial media_time will be
9145    /// set to zero.
9146    ///
9147    /// Return Value
9148    /// When requested, the AudioRenderer will return the 'reference_time' and
9149    /// 'media_time' which were selected and used (whether they were explicitly
9150    /// specified or not) in the return value of the play call.
9151    ///
9152    /// Examples
9153    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
9154    /// to start playing as soon as possible. The user may call Play without
9155    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
9156    ///
9157    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
9158    /// playback at a specified 'reference_time', in sync with some other media
9159    /// stream, either initially or after discarding packets. The user would call
9160    /// `Play(reference_time, NO_TIMESTAMP)`.
9161    ///
9162    /// 3. A user has queued some audio using `SendPacket`. The first of these
9163    /// packets has a PTS of zero, and the user wishes playback to begin as soon
9164    /// as possible, but wishes to skip all of the audio content between PTS 0
9165    /// and PTS 'media_time'. The user would call
9166    /// `Play(NO_TIMESTAMP, media_time)`.
9167    ///
9168    /// 4. A user has queued some audio using `SendPacket` and want to present
9169    /// this media in synch with another player in a different device. The
9170    /// coordinator of the group of distributed players sends an explicit
9171    /// message to each player telling them to begin presentation of audio at
9172    /// PTS 'media_time', at the time (based on the group's shared reference
9173    /// clock) 'reference_time'. Here the user would call
9174    /// `Play(reference_time, media_time)`.
9175    pub fn r#play(
9176        &self,
9177        mut reference_time: i64,
9178        mut media_time: i64,
9179    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
9180    {
9181        AudioRendererProxyInterface::r#play(self, reference_time, media_time)
9182    }
9183
9184    pub fn r#play_no_reply(
9185        &self,
9186        mut reference_time: i64,
9187        mut media_time: i64,
9188    ) -> Result<(), fidl::Error> {
9189        AudioRendererProxyInterface::r#play_no_reply(self, reference_time, media_time)
9190    }
9191
9192    /// Immediately puts the AudioRenderer into the paused state and then report
9193    /// the relationship between the media and reference timelines which was
9194    /// established (if requested).
9195    ///
9196    /// If the AudioRenderer is already in the paused state when this called,
9197    /// the previously-established timeline values are returned (if requested).
9198    pub fn r#pause(
9199        &self,
9200    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
9201    {
9202        AudioRendererProxyInterface::r#pause(self)
9203    }
9204
9205    pub fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9206        AudioRendererProxyInterface::r#pause_no_reply(self)
9207    }
9208}
9209
9210impl AudioRendererProxyInterface for AudioRendererProxy {
9211    fn r#add_payload_buffer(
9212        &self,
9213        mut id: u32,
9214        mut payload_buffer: fidl::Vmo,
9215    ) -> Result<(), fidl::Error> {
9216        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
9217            (id, payload_buffer),
9218            0x3b3a37fc34fe5b56,
9219            fidl::encoding::DynamicFlags::empty(),
9220        )
9221    }
9222
9223    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
9224        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
9225            (id,),
9226            0x5d1e4f74c3658262,
9227            fidl::encoding::DynamicFlags::empty(),
9228        )
9229    }
9230
9231    type SendPacketResponseFut =
9232        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9233    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
9234        fn _decode(
9235            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9236        ) -> Result<(), fidl::Error> {
9237            let _response = fidl::client::decode_transaction_body::<
9238                fidl::encoding::EmptyPayload,
9239                fidl::encoding::DefaultFuchsiaResourceDialect,
9240                0x67cddd607442775f,
9241            >(_buf?)?;
9242            Ok(_response)
9243        }
9244        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
9245            (packet,),
9246            0x67cddd607442775f,
9247            fidl::encoding::DynamicFlags::empty(),
9248            _decode,
9249        )
9250    }
9251
9252    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
9253        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
9254            (packet,),
9255            0x8d9b8b413ceba9d,
9256            fidl::encoding::DynamicFlags::empty(),
9257        )
9258    }
9259
9260    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
9261        self.client.send::<fidl::encoding::EmptyPayload>(
9262            (),
9263            0x6180fd6f7e793b71,
9264            fidl::encoding::DynamicFlags::empty(),
9265        )
9266    }
9267
9268    type DiscardAllPacketsResponseFut =
9269        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
9270    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
9271        fn _decode(
9272            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9273        ) -> Result<(), fidl::Error> {
9274            let _response = fidl::client::decode_transaction_body::<
9275                fidl::encoding::EmptyPayload,
9276                fidl::encoding::DefaultFuchsiaResourceDialect,
9277                0x6f4dad7af2917665,
9278            >(_buf?)?;
9279            Ok(_response)
9280        }
9281        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
9282            (),
9283            0x6f4dad7af2917665,
9284            fidl::encoding::DynamicFlags::empty(),
9285            _decode,
9286        )
9287    }
9288
9289    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
9290        self.client.send::<fidl::encoding::EmptyPayload>(
9291            (),
9292            0x50d36d0d23081bc4,
9293            fidl::encoding::DynamicFlags::empty(),
9294        )
9295    }
9296
9297    fn r#bind_gain_control(
9298        &self,
9299        mut gain_control_request: fidl::endpoints::ServerEnd<
9300            fidl_fuchsia_media_audio::GainControlMarker,
9301        >,
9302    ) -> Result<(), fidl::Error> {
9303        self.client.send::<AudioRendererBindGainControlRequest>(
9304            (gain_control_request,),
9305            0x293f5c7f8fba2bdc,
9306            fidl::encoding::DynamicFlags::empty(),
9307        )
9308    }
9309
9310    fn r#set_pts_units(
9311        &self,
9312        mut tick_per_second_numerator: u32,
9313        mut tick_per_second_denominator: u32,
9314    ) -> Result<(), fidl::Error> {
9315        self.client.send::<AudioRendererSetPtsUnitsRequest>(
9316            (tick_per_second_numerator, tick_per_second_denominator),
9317            0xf68cd108785a27c,
9318            fidl::encoding::DynamicFlags::empty(),
9319        )
9320    }
9321
9322    fn r#set_pts_continuity_threshold(
9323        &self,
9324        mut threshold_seconds: f32,
9325    ) -> Result<(), fidl::Error> {
9326        self.client.send::<AudioRendererSetPtsContinuityThresholdRequest>(
9327            (threshold_seconds,),
9328            0x2849ba571d1971ba,
9329            fidl::encoding::DynamicFlags::empty(),
9330        )
9331    }
9332
9333    type GetReferenceClockResponseFut =
9334        fidl::client::QueryResponseFut<fidl::Clock, fidl::encoding::DefaultFuchsiaResourceDialect>;
9335    fn r#get_reference_clock(&self) -> Self::GetReferenceClockResponseFut {
9336        fn _decode(
9337            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9338        ) -> Result<fidl::Clock, fidl::Error> {
9339            let _response = fidl::client::decode_transaction_body::<
9340                AudioRendererGetReferenceClockResponse,
9341                fidl::encoding::DefaultFuchsiaResourceDialect,
9342                0x2f7a7f011a172f7e,
9343            >(_buf?)?;
9344            Ok(_response.reference_clock)
9345        }
9346        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Clock>(
9347            (),
9348            0x2f7a7f011a172f7e,
9349            fidl::encoding::DynamicFlags::empty(),
9350            _decode,
9351        )
9352    }
9353
9354    fn r#set_reference_clock(
9355        &self,
9356        mut reference_clock: Option<fidl::Clock>,
9357    ) -> Result<(), fidl::Error> {
9358        self.client.send::<AudioRendererSetReferenceClockRequest>(
9359            (reference_clock,),
9360            0x39acd05d832b5fed,
9361            fidl::encoding::DynamicFlags::empty(),
9362        )
9363    }
9364
9365    fn r#set_usage(&self, mut usage: AudioRenderUsage) -> Result<(), fidl::Error> {
9366        self.client.send::<AudioRendererSetUsageRequest>(
9367            (usage,),
9368            0x3994bd23b55a733e,
9369            fidl::encoding::DynamicFlags::empty(),
9370        )
9371    }
9372
9373    fn r#set_usage2(&self, mut usage2: AudioRenderUsage2) -> Result<(), fidl::Error> {
9374        self.client.send::<AudioRendererSetUsage2Request>(
9375            (usage2,),
9376            0x2904035c7132b103,
9377            fidl::encoding::DynamicFlags::FLEXIBLE,
9378        )
9379    }
9380
9381    fn r#set_pcm_stream_type(&self, mut type_: &AudioStreamType) -> Result<(), fidl::Error> {
9382        self.client.send::<AudioRendererSetPcmStreamTypeRequest>(
9383            (type_,),
9384            0x27aa715d8901fa19,
9385            fidl::encoding::DynamicFlags::empty(),
9386        )
9387    }
9388
9389    fn r#enable_min_lead_time_events(&self, mut enabled: bool) -> Result<(), fidl::Error> {
9390        self.client.send::<AudioRendererEnableMinLeadTimeEventsRequest>(
9391            (enabled,),
9392            0x62808dfad72bf890,
9393            fidl::encoding::DynamicFlags::empty(),
9394        )
9395    }
9396
9397    type GetMinLeadTimeResponseFut =
9398        fidl::client::QueryResponseFut<i64, fidl::encoding::DefaultFuchsiaResourceDialect>;
9399    fn r#get_min_lead_time(&self) -> Self::GetMinLeadTimeResponseFut {
9400        fn _decode(
9401            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9402        ) -> Result<i64, fidl::Error> {
9403            let _response = fidl::client::decode_transaction_body::<
9404                AudioRendererGetMinLeadTimeResponse,
9405                fidl::encoding::DefaultFuchsiaResourceDialect,
9406                0x1cf3c3ecd8fec26b,
9407            >(_buf?)?;
9408            Ok(_response.min_lead_time_nsec)
9409        }
9410        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, i64>(
9411            (),
9412            0x1cf3c3ecd8fec26b,
9413            fidl::encoding::DynamicFlags::empty(),
9414            _decode,
9415        )
9416    }
9417
9418    type PlayResponseFut =
9419        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9420    fn r#play(&self, mut reference_time: i64, mut media_time: i64) -> Self::PlayResponseFut {
9421        fn _decode(
9422            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9423        ) -> Result<(i64, i64), fidl::Error> {
9424            let _response = fidl::client::decode_transaction_body::<
9425                AudioRendererPlayResponse,
9426                fidl::encoding::DefaultFuchsiaResourceDialect,
9427                0x3c0162db084f74a3,
9428            >(_buf?)?;
9429            Ok((_response.reference_time, _response.media_time))
9430        }
9431        self.client.send_query_and_decode::<AudioRendererPlayRequest, (i64, i64)>(
9432            (reference_time, media_time),
9433            0x3c0162db084f74a3,
9434            fidl::encoding::DynamicFlags::empty(),
9435            _decode,
9436        )
9437    }
9438
9439    fn r#play_no_reply(
9440        &self,
9441        mut reference_time: i64,
9442        mut media_time: i64,
9443    ) -> Result<(), fidl::Error> {
9444        self.client.send::<AudioRendererPlayNoReplyRequest>(
9445            (reference_time, media_time),
9446            0x1b7fe832b68c22ef,
9447            fidl::encoding::DynamicFlags::empty(),
9448        )
9449    }
9450
9451    type PauseResponseFut =
9452        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
9453    fn r#pause(&self) -> Self::PauseResponseFut {
9454        fn _decode(
9455            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
9456        ) -> Result<(i64, i64), fidl::Error> {
9457            let _response = fidl::client::decode_transaction_body::<
9458                AudioRendererPauseResponse,
9459                fidl::encoding::DefaultFuchsiaResourceDialect,
9460                0x41d557588d93d153,
9461            >(_buf?)?;
9462            Ok((_response.reference_time, _response.media_time))
9463        }
9464        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (i64, i64)>(
9465            (),
9466            0x41d557588d93d153,
9467            fidl::encoding::DynamicFlags::empty(),
9468            _decode,
9469        )
9470    }
9471
9472    fn r#pause_no_reply(&self) -> Result<(), fidl::Error> {
9473        self.client.send::<fidl::encoding::EmptyPayload>(
9474            (),
9475            0x24cc45d4f3855ab,
9476            fidl::encoding::DynamicFlags::empty(),
9477        )
9478    }
9479}
9480
9481pub struct AudioRendererEventStream {
9482    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
9483}
9484
9485impl std::marker::Unpin for AudioRendererEventStream {}
9486
9487impl futures::stream::FusedStream for AudioRendererEventStream {
9488    fn is_terminated(&self) -> bool {
9489        self.event_receiver.is_terminated()
9490    }
9491}
9492
9493impl futures::Stream for AudioRendererEventStream {
9494    type Item = Result<AudioRendererEvent, fidl::Error>;
9495
9496    fn poll_next(
9497        mut self: std::pin::Pin<&mut Self>,
9498        cx: &mut std::task::Context<'_>,
9499    ) -> std::task::Poll<Option<Self::Item>> {
9500        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
9501            &mut self.event_receiver,
9502            cx
9503        )?) {
9504            Some(buf) => std::task::Poll::Ready(Some(AudioRendererEvent::decode(buf))),
9505            None => std::task::Poll::Ready(None),
9506        }
9507    }
9508}
9509
9510#[derive(Debug)]
9511pub enum AudioRendererEvent {
9512    OnMinLeadTimeChanged {
9513        min_lead_time_nsec: i64,
9514    },
9515    #[non_exhaustive]
9516    _UnknownEvent {
9517        /// Ordinal of the event that was sent.
9518        ordinal: u64,
9519    },
9520}
9521
9522impl AudioRendererEvent {
9523    #[allow(irrefutable_let_patterns)]
9524    pub fn into_on_min_lead_time_changed(self) -> Option<i64> {
9525        if let AudioRendererEvent::OnMinLeadTimeChanged { min_lead_time_nsec } = self {
9526            Some((min_lead_time_nsec))
9527        } else {
9528            None
9529        }
9530    }
9531
9532    /// Decodes a message buffer as a [`AudioRendererEvent`].
9533    fn decode(
9534        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
9535    ) -> Result<AudioRendererEvent, fidl::Error> {
9536        let (bytes, _handles) = buf.split_mut();
9537        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9538        debug_assert_eq!(tx_header.tx_id, 0);
9539        match tx_header.ordinal {
9540            0x4feff7d278978c4e => {
9541                let mut out = fidl::new_empty!(
9542                    AudioRendererOnMinLeadTimeChangedRequest,
9543                    fidl::encoding::DefaultFuchsiaResourceDialect
9544                );
9545                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererOnMinLeadTimeChangedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
9546                Ok((AudioRendererEvent::OnMinLeadTimeChanged {
9547                    min_lead_time_nsec: out.min_lead_time_nsec,
9548                }))
9549            }
9550            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
9551                Ok(AudioRendererEvent::_UnknownEvent { ordinal: tx_header.ordinal })
9552            }
9553            _ => Err(fidl::Error::UnknownOrdinal {
9554                ordinal: tx_header.ordinal,
9555                protocol_name: <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9556            }),
9557        }
9558    }
9559}
9560
9561/// A Stream of incoming requests for fuchsia.media/AudioRenderer.
9562pub struct AudioRendererRequestStream {
9563    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9564    is_terminated: bool,
9565}
9566
9567impl std::marker::Unpin for AudioRendererRequestStream {}
9568
9569impl futures::stream::FusedStream for AudioRendererRequestStream {
9570    fn is_terminated(&self) -> bool {
9571        self.is_terminated
9572    }
9573}
9574
9575impl fidl::endpoints::RequestStream for AudioRendererRequestStream {
9576    type Protocol = AudioRendererMarker;
9577    type ControlHandle = AudioRendererControlHandle;
9578
9579    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
9580        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
9581    }
9582
9583    fn control_handle(&self) -> Self::ControlHandle {
9584        AudioRendererControlHandle { inner: self.inner.clone() }
9585    }
9586
9587    fn into_inner(
9588        self,
9589    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
9590    {
9591        (self.inner, self.is_terminated)
9592    }
9593
9594    fn from_inner(
9595        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
9596        is_terminated: bool,
9597    ) -> Self {
9598        Self { inner, is_terminated }
9599    }
9600}
9601
9602impl futures::Stream for AudioRendererRequestStream {
9603    type Item = Result<AudioRendererRequest, fidl::Error>;
9604
9605    fn poll_next(
9606        mut self: std::pin::Pin<&mut Self>,
9607        cx: &mut std::task::Context<'_>,
9608    ) -> std::task::Poll<Option<Self::Item>> {
9609        let this = &mut *self;
9610        if this.inner.check_shutdown(cx) {
9611            this.is_terminated = true;
9612            return std::task::Poll::Ready(None);
9613        }
9614        if this.is_terminated {
9615            panic!("polled AudioRendererRequestStream after completion");
9616        }
9617        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
9618            |bytes, handles| {
9619                match this.inner.channel().read_etc(cx, bytes, handles) {
9620                    std::task::Poll::Ready(Ok(())) => {}
9621                    std::task::Poll::Pending => return std::task::Poll::Pending,
9622                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
9623                        this.is_terminated = true;
9624                        return std::task::Poll::Ready(None);
9625                    }
9626                    std::task::Poll::Ready(Err(e)) => {
9627                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
9628                            e.into(),
9629                        ))));
9630                    }
9631                }
9632
9633                // A message has been received from the channel
9634                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
9635
9636                std::task::Poll::Ready(Some(match header.ordinal {
9637                    0x3b3a37fc34fe5b56 => {
9638                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9639                        let mut req = fidl::new_empty!(
9640                            StreamBufferSetAddPayloadBufferRequest,
9641                            fidl::encoding::DefaultFuchsiaResourceDialect
9642                        );
9643                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9644                        let control_handle =
9645                            AudioRendererControlHandle { inner: this.inner.clone() };
9646                        Ok(AudioRendererRequest::AddPayloadBuffer {
9647                            id: req.id,
9648                            payload_buffer: req.payload_buffer,
9649
9650                            control_handle,
9651                        })
9652                    }
9653                    0x5d1e4f74c3658262 => {
9654                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9655                        let mut req = fidl::new_empty!(
9656                            StreamBufferSetRemovePayloadBufferRequest,
9657                            fidl::encoding::DefaultFuchsiaResourceDialect
9658                        );
9659                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
9660                        let control_handle =
9661                            AudioRendererControlHandle { inner: this.inner.clone() };
9662                        Ok(AudioRendererRequest::RemovePayloadBuffer { id: req.id, control_handle })
9663                    }
9664                    0x67cddd607442775f => {
9665                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9666                        let mut req = fidl::new_empty!(
9667                            StreamSinkSendPacketRequest,
9668                            fidl::encoding::DefaultFuchsiaResourceDialect
9669                        );
9670                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
9671                        let control_handle =
9672                            AudioRendererControlHandle { inner: this.inner.clone() };
9673                        Ok(AudioRendererRequest::SendPacket {
9674                            packet: req.packet,
9675
9676                            responder: AudioRendererSendPacketResponder {
9677                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9678                                tx_id: header.tx_id,
9679                            },
9680                        })
9681                    }
9682                    0x8d9b8b413ceba9d => {
9683                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9684                        let mut req = fidl::new_empty!(
9685                            StreamSinkSendPacketNoReplyRequest,
9686                            fidl::encoding::DefaultFuchsiaResourceDialect
9687                        );
9688                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9689                        let control_handle =
9690                            AudioRendererControlHandle { inner: this.inner.clone() };
9691                        Ok(AudioRendererRequest::SendPacketNoReply {
9692                            packet: req.packet,
9693
9694                            control_handle,
9695                        })
9696                    }
9697                    0x6180fd6f7e793b71 => {
9698                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9699                        let mut req = fidl::new_empty!(
9700                            fidl::encoding::EmptyPayload,
9701                            fidl::encoding::DefaultFuchsiaResourceDialect
9702                        );
9703                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9704                        let control_handle =
9705                            AudioRendererControlHandle { inner: this.inner.clone() };
9706                        Ok(AudioRendererRequest::EndOfStream { control_handle })
9707                    }
9708                    0x6f4dad7af2917665 => {
9709                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9710                        let mut req = fidl::new_empty!(
9711                            fidl::encoding::EmptyPayload,
9712                            fidl::encoding::DefaultFuchsiaResourceDialect
9713                        );
9714                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9715                        let control_handle =
9716                            AudioRendererControlHandle { inner: this.inner.clone() };
9717                        Ok(AudioRendererRequest::DiscardAllPackets {
9718                            responder: AudioRendererDiscardAllPacketsResponder {
9719                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9720                                tx_id: header.tx_id,
9721                            },
9722                        })
9723                    }
9724                    0x50d36d0d23081bc4 => {
9725                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9726                        let mut req = fidl::new_empty!(
9727                            fidl::encoding::EmptyPayload,
9728                            fidl::encoding::DefaultFuchsiaResourceDialect
9729                        );
9730                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9731                        let control_handle =
9732                            AudioRendererControlHandle { inner: this.inner.clone() };
9733                        Ok(AudioRendererRequest::DiscardAllPacketsNoReply { control_handle })
9734                    }
9735                    0x293f5c7f8fba2bdc => {
9736                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9737                        let mut req = fidl::new_empty!(
9738                            AudioRendererBindGainControlRequest,
9739                            fidl::encoding::DefaultFuchsiaResourceDialect
9740                        );
9741                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererBindGainControlRequest>(&header, _body_bytes, handles, &mut req)?;
9742                        let control_handle =
9743                            AudioRendererControlHandle { inner: this.inner.clone() };
9744                        Ok(AudioRendererRequest::BindGainControl {
9745                            gain_control_request: req.gain_control_request,
9746
9747                            control_handle,
9748                        })
9749                    }
9750                    0xf68cd108785a27c => {
9751                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9752                        let mut req = fidl::new_empty!(
9753                            AudioRendererSetPtsUnitsRequest,
9754                            fidl::encoding::DefaultFuchsiaResourceDialect
9755                        );
9756                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsUnitsRequest>(&header, _body_bytes, handles, &mut req)?;
9757                        let control_handle =
9758                            AudioRendererControlHandle { inner: this.inner.clone() };
9759                        Ok(AudioRendererRequest::SetPtsUnits {
9760                            tick_per_second_numerator: req.tick_per_second_numerator,
9761                            tick_per_second_denominator: req.tick_per_second_denominator,
9762
9763                            control_handle,
9764                        })
9765                    }
9766                    0x2849ba571d1971ba => {
9767                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9768                        let mut req = fidl::new_empty!(
9769                            AudioRendererSetPtsContinuityThresholdRequest,
9770                            fidl::encoding::DefaultFuchsiaResourceDialect
9771                        );
9772                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPtsContinuityThresholdRequest>(&header, _body_bytes, handles, &mut req)?;
9773                        let control_handle =
9774                            AudioRendererControlHandle { inner: this.inner.clone() };
9775                        Ok(AudioRendererRequest::SetPtsContinuityThreshold {
9776                            threshold_seconds: req.threshold_seconds,
9777
9778                            control_handle,
9779                        })
9780                    }
9781                    0x2f7a7f011a172f7e => {
9782                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9783                        let mut req = fidl::new_empty!(
9784                            fidl::encoding::EmptyPayload,
9785                            fidl::encoding::DefaultFuchsiaResourceDialect
9786                        );
9787                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9788                        let control_handle =
9789                            AudioRendererControlHandle { inner: this.inner.clone() };
9790                        Ok(AudioRendererRequest::GetReferenceClock {
9791                            responder: AudioRendererGetReferenceClockResponder {
9792                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9793                                tx_id: header.tx_id,
9794                            },
9795                        })
9796                    }
9797                    0x39acd05d832b5fed => {
9798                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9799                        let mut req = fidl::new_empty!(
9800                            AudioRendererSetReferenceClockRequest,
9801                            fidl::encoding::DefaultFuchsiaResourceDialect
9802                        );
9803                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetReferenceClockRequest>(&header, _body_bytes, handles, &mut req)?;
9804                        let control_handle =
9805                            AudioRendererControlHandle { inner: this.inner.clone() };
9806                        Ok(AudioRendererRequest::SetReferenceClock {
9807                            reference_clock: req.reference_clock,
9808
9809                            control_handle,
9810                        })
9811                    }
9812                    0x3994bd23b55a733e => {
9813                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9814                        let mut req = fidl::new_empty!(
9815                            AudioRendererSetUsageRequest,
9816                            fidl::encoding::DefaultFuchsiaResourceDialect
9817                        );
9818                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsageRequest>(&header, _body_bytes, handles, &mut req)?;
9819                        let control_handle =
9820                            AudioRendererControlHandle { inner: this.inner.clone() };
9821                        Ok(AudioRendererRequest::SetUsage { usage: req.usage, control_handle })
9822                    }
9823                    0x2904035c7132b103 => {
9824                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9825                        let mut req = fidl::new_empty!(
9826                            AudioRendererSetUsage2Request,
9827                            fidl::encoding::DefaultFuchsiaResourceDialect
9828                        );
9829                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetUsage2Request>(&header, _body_bytes, handles, &mut req)?;
9830                        let control_handle =
9831                            AudioRendererControlHandle { inner: this.inner.clone() };
9832                        Ok(AudioRendererRequest::SetUsage2 { usage2: req.usage2, control_handle })
9833                    }
9834                    0x27aa715d8901fa19 => {
9835                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9836                        let mut req = fidl::new_empty!(
9837                            AudioRendererSetPcmStreamTypeRequest,
9838                            fidl::encoding::DefaultFuchsiaResourceDialect
9839                        );
9840                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererSetPcmStreamTypeRequest>(&header, _body_bytes, handles, &mut req)?;
9841                        let control_handle =
9842                            AudioRendererControlHandle { inner: this.inner.clone() };
9843                        Ok(AudioRendererRequest::SetPcmStreamType {
9844                            type_: req.type_,
9845
9846                            control_handle,
9847                        })
9848                    }
9849                    0x62808dfad72bf890 => {
9850                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9851                        let mut req = fidl::new_empty!(
9852                            AudioRendererEnableMinLeadTimeEventsRequest,
9853                            fidl::encoding::DefaultFuchsiaResourceDialect
9854                        );
9855                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererEnableMinLeadTimeEventsRequest>(&header, _body_bytes, handles, &mut req)?;
9856                        let control_handle =
9857                            AudioRendererControlHandle { inner: this.inner.clone() };
9858                        Ok(AudioRendererRequest::EnableMinLeadTimeEvents {
9859                            enabled: req.enabled,
9860
9861                            control_handle,
9862                        })
9863                    }
9864                    0x1cf3c3ecd8fec26b => {
9865                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9866                        let mut req = fidl::new_empty!(
9867                            fidl::encoding::EmptyPayload,
9868                            fidl::encoding::DefaultFuchsiaResourceDialect
9869                        );
9870                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9871                        let control_handle =
9872                            AudioRendererControlHandle { inner: this.inner.clone() };
9873                        Ok(AudioRendererRequest::GetMinLeadTime {
9874                            responder: AudioRendererGetMinLeadTimeResponder {
9875                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9876                                tx_id: header.tx_id,
9877                            },
9878                        })
9879                    }
9880                    0x3c0162db084f74a3 => {
9881                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9882                        let mut req = fidl::new_empty!(
9883                            AudioRendererPlayRequest,
9884                            fidl::encoding::DefaultFuchsiaResourceDialect
9885                        );
9886                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayRequest>(&header, _body_bytes, handles, &mut req)?;
9887                        let control_handle =
9888                            AudioRendererControlHandle { inner: this.inner.clone() };
9889                        Ok(AudioRendererRequest::Play {
9890                            reference_time: req.reference_time,
9891                            media_time: req.media_time,
9892
9893                            responder: AudioRendererPlayResponder {
9894                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9895                                tx_id: header.tx_id,
9896                            },
9897                        })
9898                    }
9899                    0x1b7fe832b68c22ef => {
9900                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9901                        let mut req = fidl::new_empty!(
9902                            AudioRendererPlayNoReplyRequest,
9903                            fidl::encoding::DefaultFuchsiaResourceDialect
9904                        );
9905                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AudioRendererPlayNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
9906                        let control_handle =
9907                            AudioRendererControlHandle { inner: this.inner.clone() };
9908                        Ok(AudioRendererRequest::PlayNoReply {
9909                            reference_time: req.reference_time,
9910                            media_time: req.media_time,
9911
9912                            control_handle,
9913                        })
9914                    }
9915                    0x41d557588d93d153 => {
9916                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
9917                        let mut req = fidl::new_empty!(
9918                            fidl::encoding::EmptyPayload,
9919                            fidl::encoding::DefaultFuchsiaResourceDialect
9920                        );
9921                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9922                        let control_handle =
9923                            AudioRendererControlHandle { inner: this.inner.clone() };
9924                        Ok(AudioRendererRequest::Pause {
9925                            responder: AudioRendererPauseResponder {
9926                                control_handle: std::mem::ManuallyDrop::new(control_handle),
9927                                tx_id: header.tx_id,
9928                            },
9929                        })
9930                    }
9931                    0x24cc45d4f3855ab => {
9932                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
9933                        let mut req = fidl::new_empty!(
9934                            fidl::encoding::EmptyPayload,
9935                            fidl::encoding::DefaultFuchsiaResourceDialect
9936                        );
9937                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
9938                        let control_handle =
9939                            AudioRendererControlHandle { inner: this.inner.clone() };
9940                        Ok(AudioRendererRequest::PauseNoReply { control_handle })
9941                    }
9942                    _ if header.tx_id == 0
9943                        && header
9944                            .dynamic_flags()
9945                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9946                    {
9947                        Ok(AudioRendererRequest::_UnknownMethod {
9948                            ordinal: header.ordinal,
9949                            control_handle: AudioRendererControlHandle {
9950                                inner: this.inner.clone(),
9951                            },
9952                            method_type: fidl::MethodType::OneWay,
9953                        })
9954                    }
9955                    _ if header
9956                        .dynamic_flags()
9957                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
9958                    {
9959                        this.inner.send_framework_err(
9960                            fidl::encoding::FrameworkErr::UnknownMethod,
9961                            header.tx_id,
9962                            header.ordinal,
9963                            header.dynamic_flags(),
9964                            (bytes, handles),
9965                        )?;
9966                        Ok(AudioRendererRequest::_UnknownMethod {
9967                            ordinal: header.ordinal,
9968                            control_handle: AudioRendererControlHandle {
9969                                inner: this.inner.clone(),
9970                            },
9971                            method_type: fidl::MethodType::TwoWay,
9972                        })
9973                    }
9974                    _ => Err(fidl::Error::UnknownOrdinal {
9975                        ordinal: header.ordinal,
9976                        protocol_name:
9977                            <AudioRendererMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
9978                    }),
9979                }))
9980            },
9981        )
9982    }
9983}
9984
9985/// AudioRenderers can be in one of two states at any time: _configurable_ or _operational_. A
9986/// renderer is considered operational whenever it has packets queued to be rendered; otherwise it
9987/// is _configurable_. Once an AudioRenderer enters the operational state, calls to "configuring"
9988/// methods are disallowed and will cause the audio service to disconnect the client's connection.
9989/// The following are considered configuring methods: `AddPayloadBuffer`, `SetPcmStreamType`,
9990/// `SetStreamType`, `SetPtsUnits`, `SetPtsContinuityThreshold`.
9991///
9992/// If an AudioRenderer must be reconfigured, the client must ensure that no packets are still
9993/// enqueued when these "configuring" methods are called. Thus it is best practice to call
9994/// `DiscardAllPackets` on the AudioRenderer (and ideally `Stop` before `DiscardAllPackets`), prior
9995/// to reconfiguring the renderer.
9996#[derive(Debug)]
9997pub enum AudioRendererRequest {
9998    /// Adds a payload buffer to the current buffer set associated with the
9999    /// connection. A `StreamPacket` struct reference a payload buffer in the
10000    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
10001    ///
10002    /// A buffer with ID `id` must not be in the current set when this method is
10003    /// invoked, otherwise the service will close the connection.
10004    AddPayloadBuffer {
10005        id: u32,
10006        payload_buffer: fidl::Vmo,
10007        control_handle: AudioRendererControlHandle,
10008    },
10009    /// Removes a payload buffer from the current buffer set associated with the
10010    /// connection.
10011    ///
10012    /// A buffer with ID `id` must exist in the current set when this method is
10013    /// invoked, otherwise the service will will close the connection.
10014    RemovePayloadBuffer {
10015        id: u32,
10016        control_handle: AudioRendererControlHandle,
10017    },
10018    /// Sends a packet to the service. The response is sent when the service is
10019    /// done with the associated payload memory.
10020    ///
10021    /// `packet` must be valid for the current buffer set, otherwise the service
10022    /// will close the connection.
10023    SendPacket {
10024        packet: StreamPacket,
10025        responder: AudioRendererSendPacketResponder,
10026    },
10027    /// Sends a packet to the service. This interface doesn't define how the
10028    /// client knows when the sink is done with the associated payload memory.
10029    /// The inheriting interface must define that.
10030    ///
10031    /// `packet` must be valid for the current buffer set, otherwise the service
10032    /// will close the connection.
10033    SendPacketNoReply {
10034        packet: StreamPacket,
10035        control_handle: AudioRendererControlHandle,
10036    },
10037    /// Indicates the stream has ended. The precise semantics of this method are
10038    /// determined by the inheriting interface.
10039    EndOfStream {
10040        control_handle: AudioRendererControlHandle,
10041    },
10042    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10043    /// and not yet released. The response is sent after all packets have been
10044    /// released.
10045    DiscardAllPackets {
10046        responder: AudioRendererDiscardAllPacketsResponder,
10047    },
10048    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
10049    /// and not yet released.
10050    DiscardAllPacketsNoReply {
10051        control_handle: AudioRendererControlHandle,
10052    },
10053    /// Binds to the gain control for this AudioRenderer.
10054    BindGainControl {
10055        gain_control_request:
10056            fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10057        control_handle: AudioRendererControlHandle,
10058    },
10059    /// Sets the units used by the presentation (media) timeline. By default, PTS units are
10060    /// nanoseconds (as if this were called with numerator of 1e9 and denominator of 1).
10061    /// This ratio must lie between 1/60 (1 tick per minute) and 1e9/1 (1ns per tick).
10062    SetPtsUnits {
10063        tick_per_second_numerator: u32,
10064        tick_per_second_denominator: u32,
10065        control_handle: AudioRendererControlHandle,
10066    },
10067    /// Sets the maximum threshold (in seconds) between explicit user-provided PTS
10068    /// and expected PTS (determined using interpolation). Beyond this threshold,
10069    /// a stream is no longer considered 'continuous' by the renderer.
10070    ///
10071    /// Defaults to an interval of half a PTS 'tick', using the currently-defined PTS units.
10072    /// Most users should not need to change this value from its default.
10073    ///
10074    /// Example:
10075    /// A user is playing back 48KHz audio from a container, which also contains
10076    /// video and needs to be synchronized with the audio. The timestamps are
10077    /// provided explicitly per packet by the container, and expressed in mSec
10078    /// units. This means that a single tick of the media timeline (1 mSec)
10079    /// represents exactly 48 frames of audio. The application in this scenario
10080    /// delivers packets of audio to the AudioRenderer, each with exactly 470
10081    /// frames of audio, and each with an explicit timestamp set to the best
10082    /// possible representation of the presentation time (given this media
10083    /// clock's resolution). So, starting from zero, the timestamps would be..
10084    ///
10085    /// [ 0, 10, 20, 29, 39, 49, 59, 69, 78, 88, ... ]
10086    ///
10087    /// In this example, attempting to use the presentation time to compute the
10088    /// starting frame number of the audio in the packet would be wrong the
10089    /// majority of the time. The first timestamp is correct (by definition), but
10090    /// it will be 24 packets before the timestamps and frame numbers come back
10091    /// into alignment (the 24th packet would start with the 11280th audio frame
10092    /// and have a PTS of exactly 235).
10093    ///
10094    /// One way to fix this situation is to set the PTS continuity threshold
10095    /// (henceforth, CT) for the stream to be equal to 1/2 of the time taken by
10096    /// the number of frames contained within a single tick of the media clock,
10097    /// rounded up. In this scenario, that would be 24.0 frames of audio, or 500
10098    /// uSec. Any packets whose expected PTS was within +/-CT frames of the
10099    /// explicitly provided PTS would be considered to be a continuation of the
10100    /// previous frame of audio. For this example, calling 'SetPtsContinuityThreshold(0.0005)'
10101    /// would work well.
10102    ///
10103    /// Other possible uses:
10104    /// Users who are scheduling audio explicitly, relative to a clock which has
10105    /// not been configured as the reference clock, can use this value to control
10106    /// the maximum acceptable synchronization error before a discontinuity is
10107    /// introduced. E.g., if a user is scheduling audio based on a recovered
10108    /// common media clock, and has not published that clock as the reference
10109    /// clock, and they set the CT to 20mSec, then up to 20mSec of drift error
10110    /// can accumulate before the AudioRenderer deliberately inserts a
10111    /// presentation discontinuity to account for the error.
10112    ///
10113    /// Users whose need to deal with a container where their timestamps may be
10114    /// even less correct than +/- 1/2 of a PTS tick may set this value to
10115    /// something larger. This should be the maximum level of inaccuracy present
10116    /// in the container timestamps, if known. Failing that, it could be set to
10117    /// the maximum tolerable level of drift error before absolute timestamps are
10118    /// explicitly obeyed. Finally, a user could set this number to a very large
10119    /// value (86400.0 seconds, for example) to effectively cause *all*
10120    /// timestamps to be ignored after the first, thus treating all audio as
10121    /// continuous with previously delivered packets. Conversely, users who wish
10122    /// to *always* explicitly schedule their audio packets exactly may specify
10123    /// a CT of 0.
10124    ///
10125    /// Note: explicitly specifying high-frequency PTS units reduces the default
10126    /// continuity threshold accordingly. Internally, this threshold is stored as an
10127    /// integer of 1/8192 subframes. The default threshold is computed as follows:
10128    ///     RoundUp((AudioFPS/PTSTicksPerSec) * 4096) / (AudioFPS * 8192)
10129    /// For this reason, specifying PTS units with a frequency greater than 8192x
10130    /// the frame rate (or NOT calling SetPtsUnits, which accepts the default PTS
10131    /// unit of 1 nanosec) will result in a default continuity threshold of zero.
10132    SetPtsContinuityThreshold {
10133        threshold_seconds: f32,
10134        control_handle: AudioRendererControlHandle,
10135    },
10136    /// Retrieves the stream's reference clock. The returned handle will have READ, DUPLICATE
10137    /// and TRANSFER rights, and will refer to a zx::clock that is MONOTONIC and CONTINUOUS.
10138    GetReferenceClock {
10139        responder: AudioRendererGetReferenceClockResponder,
10140    },
10141    /// Sets the reference clock that controls this renderer's playback rate. If the input
10142    /// parameter is a valid zx::clock, it must have READ, DUPLICATE, TRANSFER rights and
10143    /// refer to a clock that is both MONOTONIC and CONTINUOUS. If instead an invalid clock
10144    /// is passed (such as the uninitialized `zx::clock()`), this indicates that the stream
10145    /// will use a 'flexible' clock generated by AudioCore that tracks the audio device.
10146    ///
10147    /// `SetReferenceClock` cannot be called once `SetPcmStreamType` is called. It also
10148    /// cannot be called a second time (even if the renderer format has not yet been set).
10149    /// If a client wants a reference clock that is initially `CLOCK_MONOTONIC` but may
10150    /// diverge at some later time, they should create a clone of the monotonic clock, set
10151    /// this as the stream's reference clock, then rate-adjust it subsequently as needed.
10152    SetReferenceClock {
10153        reference_clock: Option<fidl::Clock>,
10154        control_handle: AudioRendererControlHandle,
10155    },
10156    /// Sets the usage of the render stream. This method may not be called after
10157    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
10158    SetUsage {
10159        usage: AudioRenderUsage,
10160        control_handle: AudioRendererControlHandle,
10161    },
10162    /// Sets the usage of the render stream. This method may not be called after
10163    /// `SetPcmStreamType` is called. The default usage is `MEDIA`.
10164    SetUsage2 {
10165        usage2: AudioRenderUsage2,
10166        control_handle: AudioRendererControlHandle,
10167    },
10168    /// Sets the type of the stream to be delivered by the client. Using this method implies
10169    /// that the stream encoding is `AUDIO_ENCODING_LPCM`.
10170    ///
10171    /// This must be called before `Play` or `PlayNoReply`. After a call to `SetPcmStreamType`,
10172    /// the client must then send an `AddPayloadBuffer` request, then the various `StreamSink`
10173    /// methods such as `SendPacket`/`SendPacketNoReply`.
10174    SetPcmStreamType {
10175        type_: AudioStreamType,
10176        control_handle: AudioRendererControlHandle,
10177    },
10178    /// Enables or disables notifications about changes to the minimum clock lead
10179    /// time (in nanoseconds) for this AudioRenderer. Calling this method with
10180    /// 'enabled' set to true will trigger an immediate `OnMinLeadTimeChanged`
10181    /// event with the current minimum lead time for the AudioRenderer. If the
10182    /// value changes, an `OnMinLeadTimeChanged` event will be raised with the
10183    /// new value. This behavior will continue until the user calls
10184    /// `EnableMinLeadTimeEvents(false)`.
10185    ///
10186    /// The minimum clock lead time is the amount of time ahead of the reference
10187    /// clock's understanding of "now" that packets needs to arrive (relative to
10188    /// the playback clock transformation) in order for the mixer to be able to
10189    /// mix packet. For example...
10190    ///
10191    /// + Let the PTS of packet X be P(X)
10192    /// + Let the function which transforms PTS -> RefClock be R(p) (this
10193    ///   function is determined by the call to Play(...)
10194    /// + Let the minimum lead time be MLT
10195    ///
10196    /// If R(P(X)) < RefClock.Now() + MLT
10197    /// Then the packet is late, and some (or all) of the packet's payload will
10198    /// need to be skipped in order to present the packet at the scheduled time.
10199    ///
10200    /// The value `min_lead_time_nsec = 0` is a special value which indicates
10201    /// that the AudioRenderer is not yet routed to an output device. If `Play`
10202    /// is called before the AudioRenderer is routed, any played packets will be
10203    /// dropped. Clients should wait until `min_lead_time_nsec > 0` before
10204    /// calling `Play`.
10205    EnableMinLeadTimeEvents {
10206        enabled: bool,
10207        control_handle: AudioRendererControlHandle,
10208    },
10209    ///
10210    /// While it is possible to call `GetMinLeadTime` before `SetPcmStreamType`,
10211    /// there's little reason to do so. This is because lead time is a function
10212    /// of format/rate, so lead time will be recalculated after `SetPcmStreamType`.
10213    /// If min lead time events are enabled before `SetPcmStreamType` (with
10214    /// `EnableMinLeadTimeEvents(true)`), then an event will be generated in
10215    /// response to `SetPcmStreamType`.
10216    GetMinLeadTime {
10217        responder: AudioRendererGetMinLeadTimeResponder,
10218    },
10219    /// Immediately puts the AudioRenderer into a playing state. Starts the advance
10220    /// of the media timeline, using specific values provided by the caller (or
10221    /// default values if not specified). In an optional callback, returns the
10222    /// timestamp values ultimately used -- these set the ongoing relationship
10223    /// between the media and reference timelines (i.e., how to translate between
10224    /// the domain of presentation timestamps, and the realm of local system
10225    /// time).
10226    ///
10227    /// Local system time is specified in units of nanoseconds; media_time is
10228    /// specified in the units defined by the user in the `SetPtsUnits` function,
10229    /// or nanoseconds if `SetPtsUnits` is not called.
10230    ///
10231    /// The act of placing an AudioRenderer into the playback state establishes a
10232    /// relationship between 1) the user-defined media (or presentation) timeline
10233    /// for this particular AudioRenderer, and 2) the real-world system reference
10234    /// timeline. To communicate how to translate between timelines, the Play()
10235    /// callback provides an equivalent timestamp in each time domain. The first
10236    /// value ('reference_time') is given in terms of this renderer's reference
10237    /// clock; the second value ('media_time') is what media instant exactly
10238    /// corresponds to that local time. Restated, the frame at 'media_time' in
10239    /// the audio stream should be presented at 'reference_time' according to
10240    /// the reference clock.
10241    ///
10242    /// Note: on calling this API, media_time immediately starts advancing. It is
10243    /// possible (if uncommon) for a caller to specify a system time that is
10244    /// far in the past, or far into the future. This, along with the specified
10245    /// media time, is simply used to determine what media time corresponds to
10246    /// 'now', and THAT media time is then intersected with presentation
10247    /// timestamps of packets already submitted, to determine which media frames
10248    /// should be presented next.
10249    ///
10250    /// With the corresponding reference_time and media_time values, a user can
10251    /// translate arbitrary time values from one timeline into the other. After
10252    /// calling `SetPtsUnits(pts_per_sec_numerator, pts_per_sec_denominator)` and
10253    /// given the 'ref_start' and 'media_start' values from `Play`, then for
10254    /// any 'ref_time':
10255    ///
10256    /// media_time = ( (ref_time - ref_start) / 1e9
10257    ///                * (pts_per_sec_numerator / pts_per_sec_denominator) )
10258    ///              + media_start
10259    ///
10260    /// Conversely, for any presentation timestamp 'media_time':
10261    ///
10262    /// ref_time = ( (media_time - media_start)
10263    ///              * (pts_per_sec_denominator / pts_per_sec_numerator)
10264    ///              * 1e9 )
10265    ///            + ref_start
10266    ///
10267    /// Users, depending on their use case, may optionally choose not to specify
10268    /// one or both of these timestamps. A timestamp may be omitted by supplying
10269    /// the special value '`NO_TIMESTAMP`'. The AudioRenderer automatically deduces
10270    /// any omitted timestamp value using the following rules:
10271    ///
10272    /// Reference Time
10273    /// If 'reference_time' is omitted, the AudioRenderer will select a "safe"
10274    /// reference time to begin presentation, based on the minimum lead times for
10275    /// the output devices that are currently bound to this AudioRenderer. For
10276    /// example, if an AudioRenderer is bound to an internal audio output
10277    /// requiring at least 3 mSec of lead time, and an HDMI output requiring at
10278    /// least 75 mSec of lead time, the AudioRenderer might (if 'reference_time'
10279    /// is omitted) select a reference time 80 mSec from now.
10280    ///
10281    /// Media Time
10282    /// If media_time is omitted, the AudioRenderer will select one of two
10283    /// values.
10284    /// - If the AudioRenderer is resuming from the paused state, and packets
10285    /// have not been discarded since being paused, then the AudioRenderer will
10286    /// use a media_time corresponding to the instant at which the presentation
10287    /// became paused.
10288    /// - If the AudioRenderer is being placed into a playing state for the first
10289    /// time following startup or a 'discard packets' operation, the initial
10290    /// media_time will be set to the PTS of the first payload in the pending
10291    /// packet queue. If the pending queue is empty, initial media_time will be
10292    /// set to zero.
10293    ///
10294    /// Return Value
10295    /// When requested, the AudioRenderer will return the 'reference_time' and
10296    /// 'media_time' which were selected and used (whether they were explicitly
10297    /// specified or not) in the return value of the play call.
10298    ///
10299    /// Examples
10300    /// 1. A user has queued some audio using `SendPacket` and simply wishes them
10301    /// to start playing as soon as possible. The user may call Play without
10302    /// providing explicit timestamps -- `Play(NO_TIMESTAMP, NO_TIMESTAMP)`.
10303    ///
10304    /// 2. A user has queued some audio using `SendPacket`, and wishes to start
10305    /// playback at a specified 'reference_time', in sync with some other media
10306    /// stream, either initially or after discarding packets. The user would call
10307    /// `Play(reference_time, NO_TIMESTAMP)`.
10308    ///
10309    /// 3. A user has queued some audio using `SendPacket`. The first of these
10310    /// packets has a PTS of zero, and the user wishes playback to begin as soon
10311    /// as possible, but wishes to skip all of the audio content between PTS 0
10312    /// and PTS 'media_time'. The user would call
10313    /// `Play(NO_TIMESTAMP, media_time)`.
10314    ///
10315    /// 4. A user has queued some audio using `SendPacket` and want to present
10316    /// this media in synch with another player in a different device. The
10317    /// coordinator of the group of distributed players sends an explicit
10318    /// message to each player telling them to begin presentation of audio at
10319    /// PTS 'media_time', at the time (based on the group's shared reference
10320    /// clock) 'reference_time'. Here the user would call
10321    /// `Play(reference_time, media_time)`.
10322    Play {
10323        reference_time: i64,
10324        media_time: i64,
10325        responder: AudioRendererPlayResponder,
10326    },
10327    PlayNoReply {
10328        reference_time: i64,
10329        media_time: i64,
10330        control_handle: AudioRendererControlHandle,
10331    },
10332    /// Immediately puts the AudioRenderer into the paused state and then report
10333    /// the relationship between the media and reference timelines which was
10334    /// established (if requested).
10335    ///
10336    /// If the AudioRenderer is already in the paused state when this called,
10337    /// the previously-established timeline values are returned (if requested).
10338    Pause {
10339        responder: AudioRendererPauseResponder,
10340    },
10341    PauseNoReply {
10342        control_handle: AudioRendererControlHandle,
10343    },
10344    /// An interaction was received which does not match any known method.
10345    #[non_exhaustive]
10346    _UnknownMethod {
10347        /// Ordinal of the method that was called.
10348        ordinal: u64,
10349        control_handle: AudioRendererControlHandle,
10350        method_type: fidl::MethodType,
10351    },
10352}
10353
10354impl AudioRendererRequest {
10355    #[allow(irrefutable_let_patterns)]
10356    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, AudioRendererControlHandle)> {
10357        if let AudioRendererRequest::AddPayloadBuffer { id, payload_buffer, control_handle } = self
10358        {
10359            Some((id, payload_buffer, control_handle))
10360        } else {
10361            None
10362        }
10363    }
10364
10365    #[allow(irrefutable_let_patterns)]
10366    pub fn into_remove_payload_buffer(self) -> Option<(u32, AudioRendererControlHandle)> {
10367        if let AudioRendererRequest::RemovePayloadBuffer { id, control_handle } = self {
10368            Some((id, control_handle))
10369        } else {
10370            None
10371        }
10372    }
10373
10374    #[allow(irrefutable_let_patterns)]
10375    pub fn into_send_packet(self) -> Option<(StreamPacket, AudioRendererSendPacketResponder)> {
10376        if let AudioRendererRequest::SendPacket { packet, responder } = self {
10377            Some((packet, responder))
10378        } else {
10379            None
10380        }
10381    }
10382
10383    #[allow(irrefutable_let_patterns)]
10384    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, AudioRendererControlHandle)> {
10385        if let AudioRendererRequest::SendPacketNoReply { packet, control_handle } = self {
10386            Some((packet, control_handle))
10387        } else {
10388            None
10389        }
10390    }
10391
10392    #[allow(irrefutable_let_patterns)]
10393    pub fn into_end_of_stream(self) -> Option<(AudioRendererControlHandle)> {
10394        if let AudioRendererRequest::EndOfStream { control_handle } = self {
10395            Some((control_handle))
10396        } else {
10397            None
10398        }
10399    }
10400
10401    #[allow(irrefutable_let_patterns)]
10402    pub fn into_discard_all_packets(self) -> Option<(AudioRendererDiscardAllPacketsResponder)> {
10403        if let AudioRendererRequest::DiscardAllPackets { responder } = self {
10404            Some((responder))
10405        } else {
10406            None
10407        }
10408    }
10409
10410    #[allow(irrefutable_let_patterns)]
10411    pub fn into_discard_all_packets_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10412        if let AudioRendererRequest::DiscardAllPacketsNoReply { control_handle } = self {
10413            Some((control_handle))
10414        } else {
10415            None
10416        }
10417    }
10418
10419    #[allow(irrefutable_let_patterns)]
10420    pub fn into_bind_gain_control(
10421        self,
10422    ) -> Option<(
10423        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
10424        AudioRendererControlHandle,
10425    )> {
10426        if let AudioRendererRequest::BindGainControl { gain_control_request, control_handle } = self
10427        {
10428            Some((gain_control_request, control_handle))
10429        } else {
10430            None
10431        }
10432    }
10433
10434    #[allow(irrefutable_let_patterns)]
10435    pub fn into_set_pts_units(self) -> Option<(u32, u32, AudioRendererControlHandle)> {
10436        if let AudioRendererRequest::SetPtsUnits {
10437            tick_per_second_numerator,
10438            tick_per_second_denominator,
10439            control_handle,
10440        } = self
10441        {
10442            Some((tick_per_second_numerator, tick_per_second_denominator, control_handle))
10443        } else {
10444            None
10445        }
10446    }
10447
10448    #[allow(irrefutable_let_patterns)]
10449    pub fn into_set_pts_continuity_threshold(self) -> Option<(f32, AudioRendererControlHandle)> {
10450        if let AudioRendererRequest::SetPtsContinuityThreshold {
10451            threshold_seconds,
10452            control_handle,
10453        } = self
10454        {
10455            Some((threshold_seconds, control_handle))
10456        } else {
10457            None
10458        }
10459    }
10460
10461    #[allow(irrefutable_let_patterns)]
10462    pub fn into_get_reference_clock(self) -> Option<(AudioRendererGetReferenceClockResponder)> {
10463        if let AudioRendererRequest::GetReferenceClock { responder } = self {
10464            Some((responder))
10465        } else {
10466            None
10467        }
10468    }
10469
10470    #[allow(irrefutable_let_patterns)]
10471    pub fn into_set_reference_clock(
10472        self,
10473    ) -> Option<(Option<fidl::Clock>, AudioRendererControlHandle)> {
10474        if let AudioRendererRequest::SetReferenceClock { reference_clock, control_handle } = self {
10475            Some((reference_clock, control_handle))
10476        } else {
10477            None
10478        }
10479    }
10480
10481    #[allow(irrefutable_let_patterns)]
10482    pub fn into_set_usage(self) -> Option<(AudioRenderUsage, AudioRendererControlHandle)> {
10483        if let AudioRendererRequest::SetUsage { usage, control_handle } = self {
10484            Some((usage, control_handle))
10485        } else {
10486            None
10487        }
10488    }
10489
10490    #[allow(irrefutable_let_patterns)]
10491    pub fn into_set_usage2(self) -> Option<(AudioRenderUsage2, AudioRendererControlHandle)> {
10492        if let AudioRendererRequest::SetUsage2 { usage2, control_handle } = self {
10493            Some((usage2, control_handle))
10494        } else {
10495            None
10496        }
10497    }
10498
10499    #[allow(irrefutable_let_patterns)]
10500    pub fn into_set_pcm_stream_type(self) -> Option<(AudioStreamType, AudioRendererControlHandle)> {
10501        if let AudioRendererRequest::SetPcmStreamType { type_, control_handle } = self {
10502            Some((type_, control_handle))
10503        } else {
10504            None
10505        }
10506    }
10507
10508    #[allow(irrefutable_let_patterns)]
10509    pub fn into_enable_min_lead_time_events(self) -> Option<(bool, AudioRendererControlHandle)> {
10510        if let AudioRendererRequest::EnableMinLeadTimeEvents { enabled, control_handle } = self {
10511            Some((enabled, control_handle))
10512        } else {
10513            None
10514        }
10515    }
10516
10517    #[allow(irrefutable_let_patterns)]
10518    pub fn into_get_min_lead_time(self) -> Option<(AudioRendererGetMinLeadTimeResponder)> {
10519        if let AudioRendererRequest::GetMinLeadTime { responder } = self {
10520            Some((responder))
10521        } else {
10522            None
10523        }
10524    }
10525
10526    #[allow(irrefutable_let_patterns)]
10527    pub fn into_play(self) -> Option<(i64, i64, AudioRendererPlayResponder)> {
10528        if let AudioRendererRequest::Play { reference_time, media_time, responder } = self {
10529            Some((reference_time, media_time, responder))
10530        } else {
10531            None
10532        }
10533    }
10534
10535    #[allow(irrefutable_let_patterns)]
10536    pub fn into_play_no_reply(self) -> Option<(i64, i64, AudioRendererControlHandle)> {
10537        if let AudioRendererRequest::PlayNoReply { reference_time, media_time, control_handle } =
10538            self
10539        {
10540            Some((reference_time, media_time, control_handle))
10541        } else {
10542            None
10543        }
10544    }
10545
10546    #[allow(irrefutable_let_patterns)]
10547    pub fn into_pause(self) -> Option<(AudioRendererPauseResponder)> {
10548        if let AudioRendererRequest::Pause { responder } = self { Some((responder)) } else { None }
10549    }
10550
10551    #[allow(irrefutable_let_patterns)]
10552    pub fn into_pause_no_reply(self) -> Option<(AudioRendererControlHandle)> {
10553        if let AudioRendererRequest::PauseNoReply { control_handle } = self {
10554            Some((control_handle))
10555        } else {
10556            None
10557        }
10558    }
10559
10560    /// Name of the method defined in FIDL
10561    pub fn method_name(&self) -> &'static str {
10562        match *self {
10563            AudioRendererRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
10564            AudioRendererRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
10565            AudioRendererRequest::SendPacket { .. } => "send_packet",
10566            AudioRendererRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
10567            AudioRendererRequest::EndOfStream { .. } => "end_of_stream",
10568            AudioRendererRequest::DiscardAllPackets { .. } => "discard_all_packets",
10569            AudioRendererRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
10570            AudioRendererRequest::BindGainControl { .. } => "bind_gain_control",
10571            AudioRendererRequest::SetPtsUnits { .. } => "set_pts_units",
10572            AudioRendererRequest::SetPtsContinuityThreshold { .. } => {
10573                "set_pts_continuity_threshold"
10574            }
10575            AudioRendererRequest::GetReferenceClock { .. } => "get_reference_clock",
10576            AudioRendererRequest::SetReferenceClock { .. } => "set_reference_clock",
10577            AudioRendererRequest::SetUsage { .. } => "set_usage",
10578            AudioRendererRequest::SetUsage2 { .. } => "set_usage2",
10579            AudioRendererRequest::SetPcmStreamType { .. } => "set_pcm_stream_type",
10580            AudioRendererRequest::EnableMinLeadTimeEvents { .. } => "enable_min_lead_time_events",
10581            AudioRendererRequest::GetMinLeadTime { .. } => "get_min_lead_time",
10582            AudioRendererRequest::Play { .. } => "play",
10583            AudioRendererRequest::PlayNoReply { .. } => "play_no_reply",
10584            AudioRendererRequest::Pause { .. } => "pause",
10585            AudioRendererRequest::PauseNoReply { .. } => "pause_no_reply",
10586            AudioRendererRequest::_UnknownMethod {
10587                method_type: fidl::MethodType::OneWay, ..
10588            } => "unknown one-way method",
10589            AudioRendererRequest::_UnknownMethod {
10590                method_type: fidl::MethodType::TwoWay, ..
10591            } => "unknown two-way method",
10592        }
10593    }
10594}
10595
10596#[derive(Debug, Clone)]
10597pub struct AudioRendererControlHandle {
10598    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
10599}
10600
10601impl AudioRendererControlHandle {
10602    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
10603        self.inner.shutdown_with_epitaph(status.into())
10604    }
10605}
10606
10607impl fidl::endpoints::ControlHandle for AudioRendererControlHandle {
10608    fn shutdown(&self) {
10609        self.inner.shutdown()
10610    }
10611
10612    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
10613        self.inner.shutdown_with_epitaph(status)
10614    }
10615
10616    fn is_closed(&self) -> bool {
10617        self.inner.channel().is_closed()
10618    }
10619    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
10620        self.inner.channel().on_closed()
10621    }
10622
10623    #[cfg(target_os = "fuchsia")]
10624    fn signal_peer(
10625        &self,
10626        clear_mask: zx::Signals,
10627        set_mask: zx::Signals,
10628    ) -> Result<(), zx_status::Status> {
10629        use fidl::Peered;
10630        self.inner.channel().signal_peer(clear_mask, set_mask)
10631    }
10632}
10633
10634impl AudioRendererControlHandle {
10635    pub fn send_on_min_lead_time_changed(
10636        &self,
10637        mut min_lead_time_nsec: i64,
10638    ) -> Result<(), fidl::Error> {
10639        self.inner.send::<AudioRendererOnMinLeadTimeChangedRequest>(
10640            (min_lead_time_nsec,),
10641            0,
10642            0x4feff7d278978c4e,
10643            fidl::encoding::DynamicFlags::empty(),
10644        )
10645    }
10646}
10647
10648#[must_use = "FIDL methods require a response to be sent"]
10649#[derive(Debug)]
10650pub struct AudioRendererSendPacketResponder {
10651    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10652    tx_id: u32,
10653}
10654
10655/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10656/// if the responder is dropped without sending a response, so that the client
10657/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10658impl std::ops::Drop for AudioRendererSendPacketResponder {
10659    fn drop(&mut self) {
10660        self.control_handle.shutdown();
10661        // Safety: drops once, never accessed again
10662        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10663    }
10664}
10665
10666impl fidl::endpoints::Responder for AudioRendererSendPacketResponder {
10667    type ControlHandle = AudioRendererControlHandle;
10668
10669    fn control_handle(&self) -> &AudioRendererControlHandle {
10670        &self.control_handle
10671    }
10672
10673    fn drop_without_shutdown(mut self) {
10674        // Safety: drops once, never accessed again due to mem::forget
10675        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10676        // Prevent Drop from running (which would shut down the channel)
10677        std::mem::forget(self);
10678    }
10679}
10680
10681impl AudioRendererSendPacketResponder {
10682    /// Sends a response to the FIDL transaction.
10683    ///
10684    /// Sets the channel to shutdown if an error occurs.
10685    pub fn send(self) -> Result<(), fidl::Error> {
10686        let _result = self.send_raw();
10687        if _result.is_err() {
10688            self.control_handle.shutdown();
10689        }
10690        self.drop_without_shutdown();
10691        _result
10692    }
10693
10694    /// Similar to "send" but does not shutdown the channel if an error occurs.
10695    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10696        let _result = self.send_raw();
10697        self.drop_without_shutdown();
10698        _result
10699    }
10700
10701    fn send_raw(&self) -> Result<(), fidl::Error> {
10702        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10703            (),
10704            self.tx_id,
10705            0x67cddd607442775f,
10706            fidl::encoding::DynamicFlags::empty(),
10707        )
10708    }
10709}
10710
10711#[must_use = "FIDL methods require a response to be sent"]
10712#[derive(Debug)]
10713pub struct AudioRendererDiscardAllPacketsResponder {
10714    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10715    tx_id: u32,
10716}
10717
10718/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10719/// if the responder is dropped without sending a response, so that the client
10720/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10721impl std::ops::Drop for AudioRendererDiscardAllPacketsResponder {
10722    fn drop(&mut self) {
10723        self.control_handle.shutdown();
10724        // Safety: drops once, never accessed again
10725        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10726    }
10727}
10728
10729impl fidl::endpoints::Responder for AudioRendererDiscardAllPacketsResponder {
10730    type ControlHandle = AudioRendererControlHandle;
10731
10732    fn control_handle(&self) -> &AudioRendererControlHandle {
10733        &self.control_handle
10734    }
10735
10736    fn drop_without_shutdown(mut self) {
10737        // Safety: drops once, never accessed again due to mem::forget
10738        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10739        // Prevent Drop from running (which would shut down the channel)
10740        std::mem::forget(self);
10741    }
10742}
10743
10744impl AudioRendererDiscardAllPacketsResponder {
10745    /// Sends a response to the FIDL transaction.
10746    ///
10747    /// Sets the channel to shutdown if an error occurs.
10748    pub fn send(self) -> Result<(), fidl::Error> {
10749        let _result = self.send_raw();
10750        if _result.is_err() {
10751            self.control_handle.shutdown();
10752        }
10753        self.drop_without_shutdown();
10754        _result
10755    }
10756
10757    /// Similar to "send" but does not shutdown the channel if an error occurs.
10758    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
10759        let _result = self.send_raw();
10760        self.drop_without_shutdown();
10761        _result
10762    }
10763
10764    fn send_raw(&self) -> Result<(), fidl::Error> {
10765        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
10766            (),
10767            self.tx_id,
10768            0x6f4dad7af2917665,
10769            fidl::encoding::DynamicFlags::empty(),
10770        )
10771    }
10772}
10773
10774#[must_use = "FIDL methods require a response to be sent"]
10775#[derive(Debug)]
10776pub struct AudioRendererGetReferenceClockResponder {
10777    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10778    tx_id: u32,
10779}
10780
10781/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10782/// if the responder is dropped without sending a response, so that the client
10783/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10784impl std::ops::Drop for AudioRendererGetReferenceClockResponder {
10785    fn drop(&mut self) {
10786        self.control_handle.shutdown();
10787        // Safety: drops once, never accessed again
10788        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10789    }
10790}
10791
10792impl fidl::endpoints::Responder for AudioRendererGetReferenceClockResponder {
10793    type ControlHandle = AudioRendererControlHandle;
10794
10795    fn control_handle(&self) -> &AudioRendererControlHandle {
10796        &self.control_handle
10797    }
10798
10799    fn drop_without_shutdown(mut self) {
10800        // Safety: drops once, never accessed again due to mem::forget
10801        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10802        // Prevent Drop from running (which would shut down the channel)
10803        std::mem::forget(self);
10804    }
10805}
10806
10807impl AudioRendererGetReferenceClockResponder {
10808    /// Sends a response to the FIDL transaction.
10809    ///
10810    /// Sets the channel to shutdown if an error occurs.
10811    pub fn send(self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10812        let _result = self.send_raw(reference_clock);
10813        if _result.is_err() {
10814            self.control_handle.shutdown();
10815        }
10816        self.drop_without_shutdown();
10817        _result
10818    }
10819
10820    /// Similar to "send" but does not shutdown the channel if an error occurs.
10821    pub fn send_no_shutdown_on_err(
10822        self,
10823        mut reference_clock: fidl::Clock,
10824    ) -> Result<(), fidl::Error> {
10825        let _result = self.send_raw(reference_clock);
10826        self.drop_without_shutdown();
10827        _result
10828    }
10829
10830    fn send_raw(&self, mut reference_clock: fidl::Clock) -> Result<(), fidl::Error> {
10831        self.control_handle.inner.send::<AudioRendererGetReferenceClockResponse>(
10832            (reference_clock,),
10833            self.tx_id,
10834            0x2f7a7f011a172f7e,
10835            fidl::encoding::DynamicFlags::empty(),
10836        )
10837    }
10838}
10839
10840#[must_use = "FIDL methods require a response to be sent"]
10841#[derive(Debug)]
10842pub struct AudioRendererGetMinLeadTimeResponder {
10843    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10844    tx_id: u32,
10845}
10846
10847/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10848/// if the responder is dropped without sending a response, so that the client
10849/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10850impl std::ops::Drop for AudioRendererGetMinLeadTimeResponder {
10851    fn drop(&mut self) {
10852        self.control_handle.shutdown();
10853        // Safety: drops once, never accessed again
10854        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10855    }
10856}
10857
10858impl fidl::endpoints::Responder for AudioRendererGetMinLeadTimeResponder {
10859    type ControlHandle = AudioRendererControlHandle;
10860
10861    fn control_handle(&self) -> &AudioRendererControlHandle {
10862        &self.control_handle
10863    }
10864
10865    fn drop_without_shutdown(mut self) {
10866        // Safety: drops once, never accessed again due to mem::forget
10867        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10868        // Prevent Drop from running (which would shut down the channel)
10869        std::mem::forget(self);
10870    }
10871}
10872
10873impl AudioRendererGetMinLeadTimeResponder {
10874    /// Sends a response to the FIDL transaction.
10875    ///
10876    /// Sets the channel to shutdown if an error occurs.
10877    pub fn send(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10878        let _result = self.send_raw(min_lead_time_nsec);
10879        if _result.is_err() {
10880            self.control_handle.shutdown();
10881        }
10882        self.drop_without_shutdown();
10883        _result
10884    }
10885
10886    /// Similar to "send" but does not shutdown the channel if an error occurs.
10887    pub fn send_no_shutdown_on_err(self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10888        let _result = self.send_raw(min_lead_time_nsec);
10889        self.drop_without_shutdown();
10890        _result
10891    }
10892
10893    fn send_raw(&self, mut min_lead_time_nsec: i64) -> Result<(), fidl::Error> {
10894        self.control_handle.inner.send::<AudioRendererGetMinLeadTimeResponse>(
10895            (min_lead_time_nsec,),
10896            self.tx_id,
10897            0x1cf3c3ecd8fec26b,
10898            fidl::encoding::DynamicFlags::empty(),
10899        )
10900    }
10901}
10902
10903#[must_use = "FIDL methods require a response to be sent"]
10904#[derive(Debug)]
10905pub struct AudioRendererPlayResponder {
10906    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10907    tx_id: u32,
10908}
10909
10910/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10911/// if the responder is dropped without sending a response, so that the client
10912/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10913impl std::ops::Drop for AudioRendererPlayResponder {
10914    fn drop(&mut self) {
10915        self.control_handle.shutdown();
10916        // Safety: drops once, never accessed again
10917        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10918    }
10919}
10920
10921impl fidl::endpoints::Responder for AudioRendererPlayResponder {
10922    type ControlHandle = AudioRendererControlHandle;
10923
10924    fn control_handle(&self) -> &AudioRendererControlHandle {
10925        &self.control_handle
10926    }
10927
10928    fn drop_without_shutdown(mut self) {
10929        // Safety: drops once, never accessed again due to mem::forget
10930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10931        // Prevent Drop from running (which would shut down the channel)
10932        std::mem::forget(self);
10933    }
10934}
10935
10936impl AudioRendererPlayResponder {
10937    /// Sends a response to the FIDL transaction.
10938    ///
10939    /// Sets the channel to shutdown if an error occurs.
10940    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10941        let _result = self.send_raw(reference_time, media_time);
10942        if _result.is_err() {
10943            self.control_handle.shutdown();
10944        }
10945        self.drop_without_shutdown();
10946        _result
10947    }
10948
10949    /// Similar to "send" but does not shutdown the channel if an error occurs.
10950    pub fn send_no_shutdown_on_err(
10951        self,
10952        mut reference_time: i64,
10953        mut media_time: i64,
10954    ) -> Result<(), fidl::Error> {
10955        let _result = self.send_raw(reference_time, media_time);
10956        self.drop_without_shutdown();
10957        _result
10958    }
10959
10960    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
10961        self.control_handle.inner.send::<AudioRendererPlayResponse>(
10962            (reference_time, media_time),
10963            self.tx_id,
10964            0x3c0162db084f74a3,
10965            fidl::encoding::DynamicFlags::empty(),
10966        )
10967    }
10968}
10969
10970#[must_use = "FIDL methods require a response to be sent"]
10971#[derive(Debug)]
10972pub struct AudioRendererPauseResponder {
10973    control_handle: std::mem::ManuallyDrop<AudioRendererControlHandle>,
10974    tx_id: u32,
10975}
10976
10977/// Set the the channel to be shutdown (see [`AudioRendererControlHandle::shutdown`])
10978/// if the responder is dropped without sending a response, so that the client
10979/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
10980impl std::ops::Drop for AudioRendererPauseResponder {
10981    fn drop(&mut self) {
10982        self.control_handle.shutdown();
10983        // Safety: drops once, never accessed again
10984        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10985    }
10986}
10987
10988impl fidl::endpoints::Responder for AudioRendererPauseResponder {
10989    type ControlHandle = AudioRendererControlHandle;
10990
10991    fn control_handle(&self) -> &AudioRendererControlHandle {
10992        &self.control_handle
10993    }
10994
10995    fn drop_without_shutdown(mut self) {
10996        // Safety: drops once, never accessed again due to mem::forget
10997        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
10998        // Prevent Drop from running (which would shut down the channel)
10999        std::mem::forget(self);
11000    }
11001}
11002
11003impl AudioRendererPauseResponder {
11004    /// Sends a response to the FIDL transaction.
11005    ///
11006    /// Sets the channel to shutdown if an error occurs.
11007    pub fn send(self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
11008        let _result = self.send_raw(reference_time, media_time);
11009        if _result.is_err() {
11010            self.control_handle.shutdown();
11011        }
11012        self.drop_without_shutdown();
11013        _result
11014    }
11015
11016    /// Similar to "send" but does not shutdown the channel if an error occurs.
11017    pub fn send_no_shutdown_on_err(
11018        self,
11019        mut reference_time: i64,
11020        mut media_time: i64,
11021    ) -> Result<(), fidl::Error> {
11022        let _result = self.send_raw(reference_time, media_time);
11023        self.drop_without_shutdown();
11024        _result
11025    }
11026
11027    fn send_raw(&self, mut reference_time: i64, mut media_time: i64) -> Result<(), fidl::Error> {
11028        self.control_handle.inner.send::<AudioRendererPauseResponse>(
11029            (reference_time, media_time),
11030            self.tx_id,
11031            0x41d557588d93d153,
11032            fidl::encoding::DynamicFlags::empty(),
11033        )
11034    }
11035}
11036
11037#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
11038pub struct ProfileProviderMarker;
11039
11040impl fidl::endpoints::ProtocolMarker for ProfileProviderMarker {
11041    type Proxy = ProfileProviderProxy;
11042    type RequestStream = ProfileProviderRequestStream;
11043    #[cfg(target_os = "fuchsia")]
11044    type SynchronousProxy = ProfileProviderSynchronousProxy;
11045
11046    const DEBUG_NAME: &'static str = "fuchsia.media.ProfileProvider";
11047}
11048impl fidl::endpoints::DiscoverableProtocolMarker for ProfileProviderMarker {}
11049
11050pub trait ProfileProviderProxyInterface: Send + Sync {
11051    type RegisterHandlerWithCapacityResponseFut: std::future::Future<Output = Result<(i64, i64), fidl::Error>>
11052        + Send;
11053    fn r#register_handler_with_capacity(
11054        &self,
11055        thread_handle: fidl::Thread,
11056        name: &str,
11057        period: i64,
11058        capacity: f32,
11059    ) -> Self::RegisterHandlerWithCapacityResponseFut;
11060    type UnregisterHandlerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
11061    fn r#unregister_handler(
11062        &self,
11063        thread_handle: fidl::Thread,
11064        name: &str,
11065    ) -> Self::UnregisterHandlerResponseFut;
11066    type RegisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
11067        + Send;
11068    fn r#register_memory_range(
11069        &self,
11070        vmar_handle: fidl::Vmar,
11071        name: &str,
11072    ) -> Self::RegisterMemoryRangeResponseFut;
11073    type UnregisterMemoryRangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
11074        + Send;
11075    fn r#unregister_memory_range(
11076        &self,
11077        vmar_handle: fidl::Vmar,
11078    ) -> Self::UnregisterMemoryRangeResponseFut;
11079}
11080#[derive(Debug)]
11081#[cfg(target_os = "fuchsia")]
11082pub struct ProfileProviderSynchronousProxy {
11083    client: fidl::client::sync::Client,
11084}
11085
11086#[cfg(target_os = "fuchsia")]
11087impl fidl::endpoints::SynchronousProxy for ProfileProviderSynchronousProxy {
11088    type Proxy = ProfileProviderProxy;
11089    type Protocol = ProfileProviderMarker;
11090
11091    fn from_channel(inner: fidl::Channel) -> Self {
11092        Self::new(inner)
11093    }
11094
11095    fn into_channel(self) -> fidl::Channel {
11096        self.client.into_channel()
11097    }
11098
11099    fn as_channel(&self) -> &fidl::Channel {
11100        self.client.as_channel()
11101    }
11102}
11103
11104#[cfg(target_os = "fuchsia")]
11105impl ProfileProviderSynchronousProxy {
11106    pub fn new(channel: fidl::Channel) -> Self {
11107        Self { client: fidl::client::sync::Client::new(channel) }
11108    }
11109
11110    pub fn into_channel(self) -> fidl::Channel {
11111        self.client.into_channel()
11112    }
11113
11114    /// Waits until an event arrives and returns it. It is safe for other
11115    /// threads to make concurrent requests while waiting for an event.
11116    pub fn wait_for_event(
11117        &self,
11118        deadline: zx::MonotonicInstant,
11119    ) -> Result<ProfileProviderEvent, fidl::Error> {
11120        ProfileProviderEvent::decode(self.client.wait_for_event::<ProfileProviderMarker>(deadline)?)
11121    }
11122
11123    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11124    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11125    /// deadlines.
11126    ///
11127    /// `name` is the name of a system scheduling role to apply to the thread given by
11128    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11129    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11130    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11131    /// the scheduling interval the thread needs to be running to achieve good performance or to
11132    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11133    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11134    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11135    /// be rejected or result in scaling back the performance of other threads to fit resource
11136    /// limits.
11137    ///
11138    /// Capacity, max runtime, and period have the following relationship:
11139    ///
11140    ///   capacity = max runtime / period
11141    ///
11142    /// Where:
11143    ///
11144    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11145    ///
11146    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11147    /// performance processor(s) in the system. The system will automatically adjust the effective
11148    /// capacity to account for slower processors and operating points and will avoid processors and
11149    /// operating points that are too slow to meet the requested scheduling parameters (provided
11150    /// they are reasonable).
11151    ///
11152    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11153    /// may be zero to indicate not applicable.
11154    pub fn r#register_handler_with_capacity(
11155        &self,
11156        mut thread_handle: fidl::Thread,
11157        mut name: &str,
11158        mut period: i64,
11159        mut capacity: f32,
11160        ___deadline: zx::MonotonicInstant,
11161    ) -> Result<(i64, i64), fidl::Error> {
11162        let _response = self.client.send_query::<
11163            ProfileProviderRegisterHandlerWithCapacityRequest,
11164            ProfileProviderRegisterHandlerWithCapacityResponse,
11165            ProfileProviderMarker,
11166        >(
11167            (thread_handle, name, period, capacity,),
11168            0x60459ecef7458176,
11169            fidl::encoding::DynamicFlags::empty(),
11170            ___deadline,
11171        )?;
11172        Ok((_response.period, _response.capacity))
11173    }
11174
11175    /// Reset a thread's scheduling profile to the default.
11176    pub fn r#unregister_handler(
11177        &self,
11178        mut thread_handle: fidl::Thread,
11179        mut name: &str,
11180        ___deadline: zx::MonotonicInstant,
11181    ) -> Result<(), fidl::Error> {
11182        let _response = self.client.send_query::<
11183            ProfileProviderUnregisterHandlerRequest,
11184            fidl::encoding::EmptyPayload,
11185            ProfileProviderMarker,
11186        >(
11187            (thread_handle, name,),
11188            0x724d9d5fd8ef544c,
11189            fidl::encoding::DynamicFlags::empty(),
11190            ___deadline,
11191        )?;
11192        Ok(_response)
11193    }
11194
11195    /// Register a memory range as being used for media processing. This notifies the media
11196    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11197    /// meet audio or video deadlines.
11198    ///
11199    /// `name` is the name of a system memory role to apply to the memory given by
11200    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11201    /// on the requested role.
11202    pub fn r#register_memory_range(
11203        &self,
11204        mut vmar_handle: fidl::Vmar,
11205        mut name: &str,
11206        ___deadline: zx::MonotonicInstant,
11207    ) -> Result<(), fidl::Error> {
11208        let _response = self.client.send_query::<
11209            ProfileProviderRegisterMemoryRangeRequest,
11210            fidl::encoding::EmptyPayload,
11211            ProfileProviderMarker,
11212        >(
11213            (vmar_handle, name,),
11214            0x2f509d3523e9562d,
11215            fidl::encoding::DynamicFlags::empty(),
11216            ___deadline,
11217        )?;
11218        Ok(_response)
11219    }
11220
11221    /// Reset a memory range's memory profile.
11222    pub fn r#unregister_memory_range(
11223        &self,
11224        mut vmar_handle: fidl::Vmar,
11225        ___deadline: zx::MonotonicInstant,
11226    ) -> Result<(), fidl::Error> {
11227        let _response = self.client.send_query::<
11228            ProfileProviderUnregisterMemoryRangeRequest,
11229            fidl::encoding::EmptyPayload,
11230            ProfileProviderMarker,
11231        >(
11232            (vmar_handle,),
11233            0x2dc313d6aa81ad27,
11234            fidl::encoding::DynamicFlags::empty(),
11235            ___deadline,
11236        )?;
11237        Ok(_response)
11238    }
11239}
11240
11241#[cfg(target_os = "fuchsia")]
11242impl From<ProfileProviderSynchronousProxy> for zx::NullableHandle {
11243    fn from(value: ProfileProviderSynchronousProxy) -> Self {
11244        value.into_channel().into()
11245    }
11246}
11247
11248#[cfg(target_os = "fuchsia")]
11249impl From<fidl::Channel> for ProfileProviderSynchronousProxy {
11250    fn from(value: fidl::Channel) -> Self {
11251        Self::new(value)
11252    }
11253}
11254
11255#[cfg(target_os = "fuchsia")]
11256impl fidl::endpoints::FromClient for ProfileProviderSynchronousProxy {
11257    type Protocol = ProfileProviderMarker;
11258
11259    fn from_client(value: fidl::endpoints::ClientEnd<ProfileProviderMarker>) -> Self {
11260        Self::new(value.into_channel())
11261    }
11262}
11263
11264#[derive(Debug, Clone)]
11265pub struct ProfileProviderProxy {
11266    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
11267}
11268
11269impl fidl::endpoints::Proxy for ProfileProviderProxy {
11270    type Protocol = ProfileProviderMarker;
11271
11272    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
11273        Self::new(inner)
11274    }
11275
11276    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
11277        self.client.into_channel().map_err(|client| Self { client })
11278    }
11279
11280    fn as_channel(&self) -> &::fidl::AsyncChannel {
11281        self.client.as_channel()
11282    }
11283}
11284
11285impl ProfileProviderProxy {
11286    /// Create a new Proxy for fuchsia.media/ProfileProvider.
11287    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
11288        let protocol_name = <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
11289        Self { client: fidl::client::Client::new(channel, protocol_name) }
11290    }
11291
11292    /// Get a Stream of events from the remote end of the protocol.
11293    ///
11294    /// # Panics
11295    ///
11296    /// Panics if the event stream was already taken.
11297    pub fn take_event_stream(&self) -> ProfileProviderEventStream {
11298        ProfileProviderEventStream { event_receiver: self.client.take_event_receiver() }
11299    }
11300
11301    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11302    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11303    /// deadlines.
11304    ///
11305    /// `name` is the name of a system scheduling role to apply to the thread given by
11306    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11307    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11308    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11309    /// the scheduling interval the thread needs to be running to achieve good performance or to
11310    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11311    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11312    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11313    /// be rejected or result in scaling back the performance of other threads to fit resource
11314    /// limits.
11315    ///
11316    /// Capacity, max runtime, and period have the following relationship:
11317    ///
11318    ///   capacity = max runtime / period
11319    ///
11320    /// Where:
11321    ///
11322    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11323    ///
11324    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11325    /// performance processor(s) in the system. The system will automatically adjust the effective
11326    /// capacity to account for slower processors and operating points and will avoid processors and
11327    /// operating points that are too slow to meet the requested scheduling parameters (provided
11328    /// they are reasonable).
11329    ///
11330    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11331    /// may be zero to indicate not applicable.
11332    pub fn r#register_handler_with_capacity(
11333        &self,
11334        mut thread_handle: fidl::Thread,
11335        mut name: &str,
11336        mut period: i64,
11337        mut capacity: f32,
11338    ) -> fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>
11339    {
11340        ProfileProviderProxyInterface::r#register_handler_with_capacity(
11341            self,
11342            thread_handle,
11343            name,
11344            period,
11345            capacity,
11346        )
11347    }
11348
11349    /// Reset a thread's scheduling profile to the default.
11350    pub fn r#unregister_handler(
11351        &self,
11352        mut thread_handle: fidl::Thread,
11353        mut name: &str,
11354    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11355        ProfileProviderProxyInterface::r#unregister_handler(self, thread_handle, name)
11356    }
11357
11358    /// Register a memory range as being used for media processing. This notifies the media
11359    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11360    /// meet audio or video deadlines.
11361    ///
11362    /// `name` is the name of a system memory role to apply to the memory given by
11363    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11364    /// on the requested role.
11365    pub fn r#register_memory_range(
11366        &self,
11367        mut vmar_handle: fidl::Vmar,
11368        mut name: &str,
11369    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11370        ProfileProviderProxyInterface::r#register_memory_range(self, vmar_handle, name)
11371    }
11372
11373    /// Reset a memory range's memory profile.
11374    pub fn r#unregister_memory_range(
11375        &self,
11376        mut vmar_handle: fidl::Vmar,
11377    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
11378        ProfileProviderProxyInterface::r#unregister_memory_range(self, vmar_handle)
11379    }
11380}
11381
11382impl ProfileProviderProxyInterface for ProfileProviderProxy {
11383    type RegisterHandlerWithCapacityResponseFut =
11384        fidl::client::QueryResponseFut<(i64, i64), fidl::encoding::DefaultFuchsiaResourceDialect>;
11385    fn r#register_handler_with_capacity(
11386        &self,
11387        mut thread_handle: fidl::Thread,
11388        mut name: &str,
11389        mut period: i64,
11390        mut capacity: f32,
11391    ) -> Self::RegisterHandlerWithCapacityResponseFut {
11392        fn _decode(
11393            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11394        ) -> Result<(i64, i64), fidl::Error> {
11395            let _response = fidl::client::decode_transaction_body::<
11396                ProfileProviderRegisterHandlerWithCapacityResponse,
11397                fidl::encoding::DefaultFuchsiaResourceDialect,
11398                0x60459ecef7458176,
11399            >(_buf?)?;
11400            Ok((_response.period, _response.capacity))
11401        }
11402        self.client
11403            .send_query_and_decode::<ProfileProviderRegisterHandlerWithCapacityRequest, (i64, i64)>(
11404                (thread_handle, name, period, capacity),
11405                0x60459ecef7458176,
11406                fidl::encoding::DynamicFlags::empty(),
11407                _decode,
11408            )
11409    }
11410
11411    type UnregisterHandlerResponseFut =
11412        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11413    fn r#unregister_handler(
11414        &self,
11415        mut thread_handle: fidl::Thread,
11416        mut name: &str,
11417    ) -> Self::UnregisterHandlerResponseFut {
11418        fn _decode(
11419            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11420        ) -> Result<(), fidl::Error> {
11421            let _response = fidl::client::decode_transaction_body::<
11422                fidl::encoding::EmptyPayload,
11423                fidl::encoding::DefaultFuchsiaResourceDialect,
11424                0x724d9d5fd8ef544c,
11425            >(_buf?)?;
11426            Ok(_response)
11427        }
11428        self.client.send_query_and_decode::<ProfileProviderUnregisterHandlerRequest, ()>(
11429            (thread_handle, name),
11430            0x724d9d5fd8ef544c,
11431            fidl::encoding::DynamicFlags::empty(),
11432            _decode,
11433        )
11434    }
11435
11436    type RegisterMemoryRangeResponseFut =
11437        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11438    fn r#register_memory_range(
11439        &self,
11440        mut vmar_handle: fidl::Vmar,
11441        mut name: &str,
11442    ) -> Self::RegisterMemoryRangeResponseFut {
11443        fn _decode(
11444            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11445        ) -> Result<(), fidl::Error> {
11446            let _response = fidl::client::decode_transaction_body::<
11447                fidl::encoding::EmptyPayload,
11448                fidl::encoding::DefaultFuchsiaResourceDialect,
11449                0x2f509d3523e9562d,
11450            >(_buf?)?;
11451            Ok(_response)
11452        }
11453        self.client.send_query_and_decode::<ProfileProviderRegisterMemoryRangeRequest, ()>(
11454            (vmar_handle, name),
11455            0x2f509d3523e9562d,
11456            fidl::encoding::DynamicFlags::empty(),
11457            _decode,
11458        )
11459    }
11460
11461    type UnregisterMemoryRangeResponseFut =
11462        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
11463    fn r#unregister_memory_range(
11464        &self,
11465        mut vmar_handle: fidl::Vmar,
11466    ) -> Self::UnregisterMemoryRangeResponseFut {
11467        fn _decode(
11468            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
11469        ) -> Result<(), fidl::Error> {
11470            let _response = fidl::client::decode_transaction_body::<
11471                fidl::encoding::EmptyPayload,
11472                fidl::encoding::DefaultFuchsiaResourceDialect,
11473                0x2dc313d6aa81ad27,
11474            >(_buf?)?;
11475            Ok(_response)
11476        }
11477        self.client.send_query_and_decode::<ProfileProviderUnregisterMemoryRangeRequest, ()>(
11478            (vmar_handle,),
11479            0x2dc313d6aa81ad27,
11480            fidl::encoding::DynamicFlags::empty(),
11481            _decode,
11482        )
11483    }
11484}
11485
11486pub struct ProfileProviderEventStream {
11487    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
11488}
11489
11490impl std::marker::Unpin for ProfileProviderEventStream {}
11491
11492impl futures::stream::FusedStream for ProfileProviderEventStream {
11493    fn is_terminated(&self) -> bool {
11494        self.event_receiver.is_terminated()
11495    }
11496}
11497
11498impl futures::Stream for ProfileProviderEventStream {
11499    type Item = Result<ProfileProviderEvent, fidl::Error>;
11500
11501    fn poll_next(
11502        mut self: std::pin::Pin<&mut Self>,
11503        cx: &mut std::task::Context<'_>,
11504    ) -> std::task::Poll<Option<Self::Item>> {
11505        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
11506            &mut self.event_receiver,
11507            cx
11508        )?) {
11509            Some(buf) => std::task::Poll::Ready(Some(ProfileProviderEvent::decode(buf))),
11510            None => std::task::Poll::Ready(None),
11511        }
11512    }
11513}
11514
11515#[derive(Debug)]
11516pub enum ProfileProviderEvent {}
11517
11518impl ProfileProviderEvent {
11519    /// Decodes a message buffer as a [`ProfileProviderEvent`].
11520    fn decode(
11521        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
11522    ) -> Result<ProfileProviderEvent, fidl::Error> {
11523        let (bytes, _handles) = buf.split_mut();
11524        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11525        debug_assert_eq!(tx_header.tx_id, 0);
11526        match tx_header.ordinal {
11527            _ => Err(fidl::Error::UnknownOrdinal {
11528                ordinal: tx_header.ordinal,
11529                protocol_name:
11530                    <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11531            }),
11532        }
11533    }
11534}
11535
11536/// A Stream of incoming requests for fuchsia.media/ProfileProvider.
11537pub struct ProfileProviderRequestStream {
11538    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11539    is_terminated: bool,
11540}
11541
11542impl std::marker::Unpin for ProfileProviderRequestStream {}
11543
11544impl futures::stream::FusedStream for ProfileProviderRequestStream {
11545    fn is_terminated(&self) -> bool {
11546        self.is_terminated
11547    }
11548}
11549
11550impl fidl::endpoints::RequestStream for ProfileProviderRequestStream {
11551    type Protocol = ProfileProviderMarker;
11552    type ControlHandle = ProfileProviderControlHandle;
11553
11554    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
11555        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
11556    }
11557
11558    fn control_handle(&self) -> Self::ControlHandle {
11559        ProfileProviderControlHandle { inner: self.inner.clone() }
11560    }
11561
11562    fn into_inner(
11563        self,
11564    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
11565    {
11566        (self.inner, self.is_terminated)
11567    }
11568
11569    fn from_inner(
11570        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11571        is_terminated: bool,
11572    ) -> Self {
11573        Self { inner, is_terminated }
11574    }
11575}
11576
11577impl futures::Stream for ProfileProviderRequestStream {
11578    type Item = Result<ProfileProviderRequest, fidl::Error>;
11579
11580    fn poll_next(
11581        mut self: std::pin::Pin<&mut Self>,
11582        cx: &mut std::task::Context<'_>,
11583    ) -> std::task::Poll<Option<Self::Item>> {
11584        let this = &mut *self;
11585        if this.inner.check_shutdown(cx) {
11586            this.is_terminated = true;
11587            return std::task::Poll::Ready(None);
11588        }
11589        if this.is_terminated {
11590            panic!("polled ProfileProviderRequestStream after completion");
11591        }
11592        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
11593            |bytes, handles| {
11594                match this.inner.channel().read_etc(cx, bytes, handles) {
11595                    std::task::Poll::Ready(Ok(())) => {}
11596                    std::task::Poll::Pending => return std::task::Poll::Pending,
11597                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
11598                        this.is_terminated = true;
11599                        return std::task::Poll::Ready(None);
11600                    }
11601                    std::task::Poll::Ready(Err(e)) => {
11602                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
11603                            e.into(),
11604                        ))));
11605                    }
11606                }
11607
11608                // A message has been received from the channel
11609                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
11610
11611                std::task::Poll::Ready(Some(match header.ordinal {
11612                    0x60459ecef7458176 => {
11613                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11614                        let mut req = fidl::new_empty!(
11615                            ProfileProviderRegisterHandlerWithCapacityRequest,
11616                            fidl::encoding::DefaultFuchsiaResourceDialect
11617                        );
11618                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterHandlerWithCapacityRequest>(&header, _body_bytes, handles, &mut req)?;
11619                        let control_handle =
11620                            ProfileProviderControlHandle { inner: this.inner.clone() };
11621                        Ok(ProfileProviderRequest::RegisterHandlerWithCapacity {
11622                            thread_handle: req.thread_handle,
11623                            name: req.name,
11624                            period: req.period,
11625                            capacity: req.capacity,
11626
11627                            responder: ProfileProviderRegisterHandlerWithCapacityResponder {
11628                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11629                                tx_id: header.tx_id,
11630                            },
11631                        })
11632                    }
11633                    0x724d9d5fd8ef544c => {
11634                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11635                        let mut req = fidl::new_empty!(
11636                            ProfileProviderUnregisterHandlerRequest,
11637                            fidl::encoding::DefaultFuchsiaResourceDialect
11638                        );
11639                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterHandlerRequest>(&header, _body_bytes, handles, &mut req)?;
11640                        let control_handle =
11641                            ProfileProviderControlHandle { inner: this.inner.clone() };
11642                        Ok(ProfileProviderRequest::UnregisterHandler {
11643                            thread_handle: req.thread_handle,
11644                            name: req.name,
11645
11646                            responder: ProfileProviderUnregisterHandlerResponder {
11647                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11648                                tx_id: header.tx_id,
11649                            },
11650                        })
11651                    }
11652                    0x2f509d3523e9562d => {
11653                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11654                        let mut req = fidl::new_empty!(
11655                            ProfileProviderRegisterMemoryRangeRequest,
11656                            fidl::encoding::DefaultFuchsiaResourceDialect
11657                        );
11658                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderRegisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11659                        let control_handle =
11660                            ProfileProviderControlHandle { inner: this.inner.clone() };
11661                        Ok(ProfileProviderRequest::RegisterMemoryRange {
11662                            vmar_handle: req.vmar_handle,
11663                            name: req.name,
11664
11665                            responder: ProfileProviderRegisterMemoryRangeResponder {
11666                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11667                                tx_id: header.tx_id,
11668                            },
11669                        })
11670                    }
11671                    0x2dc313d6aa81ad27 => {
11672                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
11673                        let mut req = fidl::new_empty!(
11674                            ProfileProviderUnregisterMemoryRangeRequest,
11675                            fidl::encoding::DefaultFuchsiaResourceDialect
11676                        );
11677                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProfileProviderUnregisterMemoryRangeRequest>(&header, _body_bytes, handles, &mut req)?;
11678                        let control_handle =
11679                            ProfileProviderControlHandle { inner: this.inner.clone() };
11680                        Ok(ProfileProviderRequest::UnregisterMemoryRange {
11681                            vmar_handle: req.vmar_handle,
11682
11683                            responder: ProfileProviderUnregisterMemoryRangeResponder {
11684                                control_handle: std::mem::ManuallyDrop::new(control_handle),
11685                                tx_id: header.tx_id,
11686                            },
11687                        })
11688                    }
11689                    _ => Err(fidl::Error::UnknownOrdinal {
11690                        ordinal: header.ordinal,
11691                        protocol_name:
11692                            <ProfileProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
11693                    }),
11694                }))
11695            },
11696        )
11697    }
11698}
11699
11700#[derive(Debug)]
11701pub enum ProfileProviderRequest {
11702    /// Register a thread as a media thread. This notifies the media subsystem that this thread
11703    /// should have an elevated scheduling profile applied to it in order to meet audio or video
11704    /// deadlines.
11705    ///
11706    /// `name` is the name of a system scheduling role to apply to the thread given by
11707    /// `thread_handle` -- different products may customize the underlying scheduling strategy based
11708    /// on the requested role. `period` is the suggested interval to be scheduled at. `period` may
11709    /// be zero if the thread has no preferred scheduling interval. `capacity` is the proportion of
11710    /// the scheduling interval the thread needs to be running to achieve good performance or to
11711    /// meet the scheduling deadline defined by `period`. `capacity` may be zero if the workload has
11712    /// no firm runtime requirements. Note that `capacity` should be a good faith estimate based on
11713    /// the worst case runtime the thread requires each period.  Excessive capacity requests may
11714    /// be rejected or result in scaling back the performance of other threads to fit resource
11715    /// limits.
11716    ///
11717    /// Capacity, max runtime, and period have the following relationship:
11718    ///
11719    ///   capacity = max runtime / period
11720    ///
11721    /// Where:
11722    ///
11723    ///   0 <= max runtime <= period    and    0 <= capacity <= 1
11724    ///
11725    /// For heterogeneous systems, the capacity should be planned / measured against the highest
11726    /// performance processor(s) in the system. The system will automatically adjust the effective
11727    /// capacity to account for slower processors and operating points and will avoid processors and
11728    /// operating points that are too slow to meet the requested scheduling parameters (provided
11729    /// they are reasonable).
11730    ///
11731    /// Returns the period and capacity (actually maximum runtime) that was applied, either of which
11732    /// may be zero to indicate not applicable.
11733    RegisterHandlerWithCapacity {
11734        thread_handle: fidl::Thread,
11735        name: String,
11736        period: i64,
11737        capacity: f32,
11738        responder: ProfileProviderRegisterHandlerWithCapacityResponder,
11739    },
11740    /// Reset a thread's scheduling profile to the default.
11741    UnregisterHandler {
11742        thread_handle: fidl::Thread,
11743        name: String,
11744        responder: ProfileProviderUnregisterHandlerResponder,
11745    },
11746    /// Register a memory range as being used for media processing. This notifies the media
11747    /// subsystem that this memory should have an elevated memory profile applied to it in order to
11748    /// meet audio or video deadlines.
11749    ///
11750    /// `name` is the name of a system memory role to apply to the memory given by
11751    /// `vmar_handle` -- different products may customize the underlying memory strategy based
11752    /// on the requested role.
11753    RegisterMemoryRange {
11754        vmar_handle: fidl::Vmar,
11755        name: String,
11756        responder: ProfileProviderRegisterMemoryRangeResponder,
11757    },
11758    /// Reset a memory range's memory profile.
11759    UnregisterMemoryRange {
11760        vmar_handle: fidl::Vmar,
11761        responder: ProfileProviderUnregisterMemoryRangeResponder,
11762    },
11763}
11764
11765impl ProfileProviderRequest {
11766    #[allow(irrefutable_let_patterns)]
11767    pub fn into_register_handler_with_capacity(
11768        self,
11769    ) -> Option<(fidl::Thread, String, i64, f32, ProfileProviderRegisterHandlerWithCapacityResponder)>
11770    {
11771        if let ProfileProviderRequest::RegisterHandlerWithCapacity {
11772            thread_handle,
11773            name,
11774            period,
11775            capacity,
11776            responder,
11777        } = self
11778        {
11779            Some((thread_handle, name, period, capacity, responder))
11780        } else {
11781            None
11782        }
11783    }
11784
11785    #[allow(irrefutable_let_patterns)]
11786    pub fn into_unregister_handler(
11787        self,
11788    ) -> Option<(fidl::Thread, String, ProfileProviderUnregisterHandlerResponder)> {
11789        if let ProfileProviderRequest::UnregisterHandler { thread_handle, name, responder } = self {
11790            Some((thread_handle, name, responder))
11791        } else {
11792            None
11793        }
11794    }
11795
11796    #[allow(irrefutable_let_patterns)]
11797    pub fn into_register_memory_range(
11798        self,
11799    ) -> Option<(fidl::Vmar, String, ProfileProviderRegisterMemoryRangeResponder)> {
11800        if let ProfileProviderRequest::RegisterMemoryRange { vmar_handle, name, responder } = self {
11801            Some((vmar_handle, name, responder))
11802        } else {
11803            None
11804        }
11805    }
11806
11807    #[allow(irrefutable_let_patterns)]
11808    pub fn into_unregister_memory_range(
11809        self,
11810    ) -> Option<(fidl::Vmar, ProfileProviderUnregisterMemoryRangeResponder)> {
11811        if let ProfileProviderRequest::UnregisterMemoryRange { vmar_handle, responder } = self {
11812            Some((vmar_handle, responder))
11813        } else {
11814            None
11815        }
11816    }
11817
11818    /// Name of the method defined in FIDL
11819    pub fn method_name(&self) -> &'static str {
11820        match *self {
11821            ProfileProviderRequest::RegisterHandlerWithCapacity { .. } => {
11822                "register_handler_with_capacity"
11823            }
11824            ProfileProviderRequest::UnregisterHandler { .. } => "unregister_handler",
11825            ProfileProviderRequest::RegisterMemoryRange { .. } => "register_memory_range",
11826            ProfileProviderRequest::UnregisterMemoryRange { .. } => "unregister_memory_range",
11827        }
11828    }
11829}
11830
11831#[derive(Debug, Clone)]
11832pub struct ProfileProviderControlHandle {
11833    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
11834}
11835
11836impl ProfileProviderControlHandle {
11837    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
11838        self.inner.shutdown_with_epitaph(status.into())
11839    }
11840}
11841
11842impl fidl::endpoints::ControlHandle for ProfileProviderControlHandle {
11843    fn shutdown(&self) {
11844        self.inner.shutdown()
11845    }
11846
11847    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
11848        self.inner.shutdown_with_epitaph(status)
11849    }
11850
11851    fn is_closed(&self) -> bool {
11852        self.inner.channel().is_closed()
11853    }
11854    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
11855        self.inner.channel().on_closed()
11856    }
11857
11858    #[cfg(target_os = "fuchsia")]
11859    fn signal_peer(
11860        &self,
11861        clear_mask: zx::Signals,
11862        set_mask: zx::Signals,
11863    ) -> Result<(), zx_status::Status> {
11864        use fidl::Peered;
11865        self.inner.channel().signal_peer(clear_mask, set_mask)
11866    }
11867}
11868
11869impl ProfileProviderControlHandle {}
11870
11871#[must_use = "FIDL methods require a response to be sent"]
11872#[derive(Debug)]
11873pub struct ProfileProviderRegisterHandlerWithCapacityResponder {
11874    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11875    tx_id: u32,
11876}
11877
11878/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11879/// if the responder is dropped without sending a response, so that the client
11880/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11881impl std::ops::Drop for ProfileProviderRegisterHandlerWithCapacityResponder {
11882    fn drop(&mut self) {
11883        self.control_handle.shutdown();
11884        // Safety: drops once, never accessed again
11885        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11886    }
11887}
11888
11889impl fidl::endpoints::Responder for ProfileProviderRegisterHandlerWithCapacityResponder {
11890    type ControlHandle = ProfileProviderControlHandle;
11891
11892    fn control_handle(&self) -> &ProfileProviderControlHandle {
11893        &self.control_handle
11894    }
11895
11896    fn drop_without_shutdown(mut self) {
11897        // Safety: drops once, never accessed again due to mem::forget
11898        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11899        // Prevent Drop from running (which would shut down the channel)
11900        std::mem::forget(self);
11901    }
11902}
11903
11904impl ProfileProviderRegisterHandlerWithCapacityResponder {
11905    /// Sends a response to the FIDL transaction.
11906    ///
11907    /// Sets the channel to shutdown if an error occurs.
11908    pub fn send(self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11909        let _result = self.send_raw(period, capacity);
11910        if _result.is_err() {
11911            self.control_handle.shutdown();
11912        }
11913        self.drop_without_shutdown();
11914        _result
11915    }
11916
11917    /// Similar to "send" but does not shutdown the channel if an error occurs.
11918    pub fn send_no_shutdown_on_err(
11919        self,
11920        mut period: i64,
11921        mut capacity: i64,
11922    ) -> Result<(), fidl::Error> {
11923        let _result = self.send_raw(period, capacity);
11924        self.drop_without_shutdown();
11925        _result
11926    }
11927
11928    fn send_raw(&self, mut period: i64, mut capacity: i64) -> Result<(), fidl::Error> {
11929        self.control_handle.inner.send::<ProfileProviderRegisterHandlerWithCapacityResponse>(
11930            (period, capacity),
11931            self.tx_id,
11932            0x60459ecef7458176,
11933            fidl::encoding::DynamicFlags::empty(),
11934        )
11935    }
11936}
11937
11938#[must_use = "FIDL methods require a response to be sent"]
11939#[derive(Debug)]
11940pub struct ProfileProviderUnregisterHandlerResponder {
11941    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
11942    tx_id: u32,
11943}
11944
11945/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
11946/// if the responder is dropped without sending a response, so that the client
11947/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
11948impl std::ops::Drop for ProfileProviderUnregisterHandlerResponder {
11949    fn drop(&mut self) {
11950        self.control_handle.shutdown();
11951        // Safety: drops once, never accessed again
11952        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11953    }
11954}
11955
11956impl fidl::endpoints::Responder for ProfileProviderUnregisterHandlerResponder {
11957    type ControlHandle = ProfileProviderControlHandle;
11958
11959    fn control_handle(&self) -> &ProfileProviderControlHandle {
11960        &self.control_handle
11961    }
11962
11963    fn drop_without_shutdown(mut self) {
11964        // Safety: drops once, never accessed again due to mem::forget
11965        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
11966        // Prevent Drop from running (which would shut down the channel)
11967        std::mem::forget(self);
11968    }
11969}
11970
11971impl ProfileProviderUnregisterHandlerResponder {
11972    /// Sends a response to the FIDL transaction.
11973    ///
11974    /// Sets the channel to shutdown if an error occurs.
11975    pub fn send(self) -> Result<(), fidl::Error> {
11976        let _result = self.send_raw();
11977        if _result.is_err() {
11978            self.control_handle.shutdown();
11979        }
11980        self.drop_without_shutdown();
11981        _result
11982    }
11983
11984    /// Similar to "send" but does not shutdown the channel if an error occurs.
11985    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
11986        let _result = self.send_raw();
11987        self.drop_without_shutdown();
11988        _result
11989    }
11990
11991    fn send_raw(&self) -> Result<(), fidl::Error> {
11992        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
11993            (),
11994            self.tx_id,
11995            0x724d9d5fd8ef544c,
11996            fidl::encoding::DynamicFlags::empty(),
11997        )
11998    }
11999}
12000
12001#[must_use = "FIDL methods require a response to be sent"]
12002#[derive(Debug)]
12003pub struct ProfileProviderRegisterMemoryRangeResponder {
12004    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
12005    tx_id: u32,
12006}
12007
12008/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
12009/// if the responder is dropped without sending a response, so that the client
12010/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12011impl std::ops::Drop for ProfileProviderRegisterMemoryRangeResponder {
12012    fn drop(&mut self) {
12013        self.control_handle.shutdown();
12014        // Safety: drops once, never accessed again
12015        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12016    }
12017}
12018
12019impl fidl::endpoints::Responder for ProfileProviderRegisterMemoryRangeResponder {
12020    type ControlHandle = ProfileProviderControlHandle;
12021
12022    fn control_handle(&self) -> &ProfileProviderControlHandle {
12023        &self.control_handle
12024    }
12025
12026    fn drop_without_shutdown(mut self) {
12027        // Safety: drops once, never accessed again due to mem::forget
12028        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12029        // Prevent Drop from running (which would shut down the channel)
12030        std::mem::forget(self);
12031    }
12032}
12033
12034impl ProfileProviderRegisterMemoryRangeResponder {
12035    /// Sends a response to the FIDL transaction.
12036    ///
12037    /// Sets the channel to shutdown if an error occurs.
12038    pub fn send(self) -> Result<(), fidl::Error> {
12039        let _result = self.send_raw();
12040        if _result.is_err() {
12041            self.control_handle.shutdown();
12042        }
12043        self.drop_without_shutdown();
12044        _result
12045    }
12046
12047    /// Similar to "send" but does not shutdown the channel if an error occurs.
12048    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12049        let _result = self.send_raw();
12050        self.drop_without_shutdown();
12051        _result
12052    }
12053
12054    fn send_raw(&self) -> Result<(), fidl::Error> {
12055        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
12056            (),
12057            self.tx_id,
12058            0x2f509d3523e9562d,
12059            fidl::encoding::DynamicFlags::empty(),
12060        )
12061    }
12062}
12063
12064#[must_use = "FIDL methods require a response to be sent"]
12065#[derive(Debug)]
12066pub struct ProfileProviderUnregisterMemoryRangeResponder {
12067    control_handle: std::mem::ManuallyDrop<ProfileProviderControlHandle>,
12068    tx_id: u32,
12069}
12070
12071/// Set the the channel to be shutdown (see [`ProfileProviderControlHandle::shutdown`])
12072/// if the responder is dropped without sending a response, so that the client
12073/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
12074impl std::ops::Drop for ProfileProviderUnregisterMemoryRangeResponder {
12075    fn drop(&mut self) {
12076        self.control_handle.shutdown();
12077        // Safety: drops once, never accessed again
12078        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12079    }
12080}
12081
12082impl fidl::endpoints::Responder for ProfileProviderUnregisterMemoryRangeResponder {
12083    type ControlHandle = ProfileProviderControlHandle;
12084
12085    fn control_handle(&self) -> &ProfileProviderControlHandle {
12086        &self.control_handle
12087    }
12088
12089    fn drop_without_shutdown(mut self) {
12090        // Safety: drops once, never accessed again due to mem::forget
12091        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
12092        // Prevent Drop from running (which would shut down the channel)
12093        std::mem::forget(self);
12094    }
12095}
12096
12097impl ProfileProviderUnregisterMemoryRangeResponder {
12098    /// Sends a response to the FIDL transaction.
12099    ///
12100    /// Sets the channel to shutdown if an error occurs.
12101    pub fn send(self) -> Result<(), fidl::Error> {
12102        let _result = self.send_raw();
12103        if _result.is_err() {
12104            self.control_handle.shutdown();
12105        }
12106        self.drop_without_shutdown();
12107        _result
12108    }
12109
12110    /// Similar to "send" but does not shutdown the channel if an error occurs.
12111    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
12112        let _result = self.send_raw();
12113        self.drop_without_shutdown();
12114        _result
12115    }
12116
12117    fn send_raw(&self) -> Result<(), fidl::Error> {
12118        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
12119            (),
12120            self.tx_id,
12121            0x2dc313d6aa81ad27,
12122            fidl::encoding::DynamicFlags::empty(),
12123        )
12124    }
12125}
12126
12127#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12128pub struct SessionAudioConsumerFactoryMarker;
12129
12130impl fidl::endpoints::ProtocolMarker for SessionAudioConsumerFactoryMarker {
12131    type Proxy = SessionAudioConsumerFactoryProxy;
12132    type RequestStream = SessionAudioConsumerFactoryRequestStream;
12133    #[cfg(target_os = "fuchsia")]
12134    type SynchronousProxy = SessionAudioConsumerFactorySynchronousProxy;
12135
12136    const DEBUG_NAME: &'static str = "fuchsia.media.SessionAudioConsumerFactory";
12137}
12138impl fidl::endpoints::DiscoverableProtocolMarker for SessionAudioConsumerFactoryMarker {}
12139
12140pub trait SessionAudioConsumerFactoryProxyInterface: Send + Sync {
12141    fn r#create_audio_consumer(
12142        &self,
12143        session_id: u64,
12144        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12145    ) -> Result<(), fidl::Error>;
12146}
12147#[derive(Debug)]
12148#[cfg(target_os = "fuchsia")]
12149pub struct SessionAudioConsumerFactorySynchronousProxy {
12150    client: fidl::client::sync::Client,
12151}
12152
12153#[cfg(target_os = "fuchsia")]
12154impl fidl::endpoints::SynchronousProxy for SessionAudioConsumerFactorySynchronousProxy {
12155    type Proxy = SessionAudioConsumerFactoryProxy;
12156    type Protocol = SessionAudioConsumerFactoryMarker;
12157
12158    fn from_channel(inner: fidl::Channel) -> Self {
12159        Self::new(inner)
12160    }
12161
12162    fn into_channel(self) -> fidl::Channel {
12163        self.client.into_channel()
12164    }
12165
12166    fn as_channel(&self) -> &fidl::Channel {
12167        self.client.as_channel()
12168    }
12169}
12170
12171#[cfg(target_os = "fuchsia")]
12172impl SessionAudioConsumerFactorySynchronousProxy {
12173    pub fn new(channel: fidl::Channel) -> Self {
12174        Self { client: fidl::client::sync::Client::new(channel) }
12175    }
12176
12177    pub fn into_channel(self) -> fidl::Channel {
12178        self.client.into_channel()
12179    }
12180
12181    /// Waits until an event arrives and returns it. It is safe for other
12182    /// threads to make concurrent requests while waiting for an event.
12183    pub fn wait_for_event(
12184        &self,
12185        deadline: zx::MonotonicInstant,
12186    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
12187        SessionAudioConsumerFactoryEvent::decode(
12188            self.client.wait_for_event::<SessionAudioConsumerFactoryMarker>(deadline)?,
12189        )
12190    }
12191
12192    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12193    /// to a particular session. `session_id` is the identifier of the media session
12194    /// for which audio is to be rendered.
12195    pub fn r#create_audio_consumer(
12196        &self,
12197        mut session_id: u64,
12198        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12199    ) -> Result<(), fidl::Error> {
12200        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
12201            (session_id, audio_consumer_request),
12202            0x6fab96f988e7d7fb,
12203            fidl::encoding::DynamicFlags::empty(),
12204        )
12205    }
12206}
12207
12208#[cfg(target_os = "fuchsia")]
12209impl From<SessionAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
12210    fn from(value: SessionAudioConsumerFactorySynchronousProxy) -> Self {
12211        value.into_channel().into()
12212    }
12213}
12214
12215#[cfg(target_os = "fuchsia")]
12216impl From<fidl::Channel> for SessionAudioConsumerFactorySynchronousProxy {
12217    fn from(value: fidl::Channel) -> Self {
12218        Self::new(value)
12219    }
12220}
12221
12222#[cfg(target_os = "fuchsia")]
12223impl fidl::endpoints::FromClient for SessionAudioConsumerFactorySynchronousProxy {
12224    type Protocol = SessionAudioConsumerFactoryMarker;
12225
12226    fn from_client(value: fidl::endpoints::ClientEnd<SessionAudioConsumerFactoryMarker>) -> Self {
12227        Self::new(value.into_channel())
12228    }
12229}
12230
12231#[derive(Debug, Clone)]
12232pub struct SessionAudioConsumerFactoryProxy {
12233    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12234}
12235
12236impl fidl::endpoints::Proxy for SessionAudioConsumerFactoryProxy {
12237    type Protocol = SessionAudioConsumerFactoryMarker;
12238
12239    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12240        Self::new(inner)
12241    }
12242
12243    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12244        self.client.into_channel().map_err(|client| Self { client })
12245    }
12246
12247    fn as_channel(&self) -> &::fidl::AsyncChannel {
12248        self.client.as_channel()
12249    }
12250}
12251
12252impl SessionAudioConsumerFactoryProxy {
12253    /// Create a new Proxy for fuchsia.media/SessionAudioConsumerFactory.
12254    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12255        let protocol_name =
12256            <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12257        Self { client: fidl::client::Client::new(channel, protocol_name) }
12258    }
12259
12260    /// Get a Stream of events from the remote end of the protocol.
12261    ///
12262    /// # Panics
12263    ///
12264    /// Panics if the event stream was already taken.
12265    pub fn take_event_stream(&self) -> SessionAudioConsumerFactoryEventStream {
12266        SessionAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
12267    }
12268
12269    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12270    /// to a particular session. `session_id` is the identifier of the media session
12271    /// for which audio is to be rendered.
12272    pub fn r#create_audio_consumer(
12273        &self,
12274        mut session_id: u64,
12275        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12276    ) -> Result<(), fidl::Error> {
12277        SessionAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
12278            self,
12279            session_id,
12280            audio_consumer_request,
12281        )
12282    }
12283}
12284
12285impl SessionAudioConsumerFactoryProxyInterface for SessionAudioConsumerFactoryProxy {
12286    fn r#create_audio_consumer(
12287        &self,
12288        mut session_id: u64,
12289        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12290    ) -> Result<(), fidl::Error> {
12291        self.client.send::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
12292            (session_id, audio_consumer_request),
12293            0x6fab96f988e7d7fb,
12294            fidl::encoding::DynamicFlags::empty(),
12295        )
12296    }
12297}
12298
12299pub struct SessionAudioConsumerFactoryEventStream {
12300    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12301}
12302
12303impl std::marker::Unpin for SessionAudioConsumerFactoryEventStream {}
12304
12305impl futures::stream::FusedStream for SessionAudioConsumerFactoryEventStream {
12306    fn is_terminated(&self) -> bool {
12307        self.event_receiver.is_terminated()
12308    }
12309}
12310
12311impl futures::Stream for SessionAudioConsumerFactoryEventStream {
12312    type Item = Result<SessionAudioConsumerFactoryEvent, fidl::Error>;
12313
12314    fn poll_next(
12315        mut self: std::pin::Pin<&mut Self>,
12316        cx: &mut std::task::Context<'_>,
12317    ) -> std::task::Poll<Option<Self::Item>> {
12318        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12319            &mut self.event_receiver,
12320            cx
12321        )?) {
12322            Some(buf) => {
12323                std::task::Poll::Ready(Some(SessionAudioConsumerFactoryEvent::decode(buf)))
12324            }
12325            None => std::task::Poll::Ready(None),
12326        }
12327    }
12328}
12329
12330#[derive(Debug)]
12331pub enum SessionAudioConsumerFactoryEvent {}
12332
12333impl SessionAudioConsumerFactoryEvent {
12334    /// Decodes a message buffer as a [`SessionAudioConsumerFactoryEvent`].
12335    fn decode(
12336        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12337    ) -> Result<SessionAudioConsumerFactoryEvent, fidl::Error> {
12338        let (bytes, _handles) = buf.split_mut();
12339        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12340        debug_assert_eq!(tx_header.tx_id, 0);
12341        match tx_header.ordinal {
12342            _ => Err(fidl::Error::UnknownOrdinal {
12343                ordinal: tx_header.ordinal,
12344                protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12345            })
12346        }
12347    }
12348}
12349
12350/// A Stream of incoming requests for fuchsia.media/SessionAudioConsumerFactory.
12351pub struct SessionAudioConsumerFactoryRequestStream {
12352    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12353    is_terminated: bool,
12354}
12355
12356impl std::marker::Unpin for SessionAudioConsumerFactoryRequestStream {}
12357
12358impl futures::stream::FusedStream for SessionAudioConsumerFactoryRequestStream {
12359    fn is_terminated(&self) -> bool {
12360        self.is_terminated
12361    }
12362}
12363
12364impl fidl::endpoints::RequestStream for SessionAudioConsumerFactoryRequestStream {
12365    type Protocol = SessionAudioConsumerFactoryMarker;
12366    type ControlHandle = SessionAudioConsumerFactoryControlHandle;
12367
12368    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12369        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12370    }
12371
12372    fn control_handle(&self) -> Self::ControlHandle {
12373        SessionAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
12374    }
12375
12376    fn into_inner(
12377        self,
12378    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
12379    {
12380        (self.inner, self.is_terminated)
12381    }
12382
12383    fn from_inner(
12384        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12385        is_terminated: bool,
12386    ) -> Self {
12387        Self { inner, is_terminated }
12388    }
12389}
12390
12391impl futures::Stream for SessionAudioConsumerFactoryRequestStream {
12392    type Item = Result<SessionAudioConsumerFactoryRequest, fidl::Error>;
12393
12394    fn poll_next(
12395        mut self: std::pin::Pin<&mut Self>,
12396        cx: &mut std::task::Context<'_>,
12397    ) -> std::task::Poll<Option<Self::Item>> {
12398        let this = &mut *self;
12399        if this.inner.check_shutdown(cx) {
12400            this.is_terminated = true;
12401            return std::task::Poll::Ready(None);
12402        }
12403        if this.is_terminated {
12404            panic!("polled SessionAudioConsumerFactoryRequestStream after completion");
12405        }
12406        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
12407            |bytes, handles| {
12408                match this.inner.channel().read_etc(cx, bytes, handles) {
12409                    std::task::Poll::Ready(Ok(())) => {}
12410                    std::task::Poll::Pending => return std::task::Poll::Pending,
12411                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
12412                        this.is_terminated = true;
12413                        return std::task::Poll::Ready(None);
12414                    }
12415                    std::task::Poll::Ready(Err(e)) => {
12416                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
12417                            e.into(),
12418                        ))));
12419                    }
12420                }
12421
12422                // A message has been received from the channel
12423                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12424
12425                std::task::Poll::Ready(Some(match header.ordinal {
12426                0x6fab96f988e7d7fb => {
12427                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
12428                    let mut req = fidl::new_empty!(SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
12429                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
12430                    let control_handle = SessionAudioConsumerFactoryControlHandle {
12431                        inner: this.inner.clone(),
12432                    };
12433                    Ok(SessionAudioConsumerFactoryRequest::CreateAudioConsumer {session_id: req.session_id,
12434audio_consumer_request: req.audio_consumer_request,
12435
12436                        control_handle,
12437                    })
12438                }
12439                _ => Err(fidl::Error::UnknownOrdinal {
12440                    ordinal: header.ordinal,
12441                    protocol_name: <SessionAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12442                }),
12443            }))
12444            },
12445        )
12446    }
12447}
12448
12449/// Interface for creating audio consumers bound to a session.
12450#[derive(Debug)]
12451pub enum SessionAudioConsumerFactoryRequest {
12452    /// Creates an `AudioConsumer`, which is an interface for playing audio, bound
12453    /// to a particular session. `session_id` is the identifier of the media session
12454    /// for which audio is to be rendered.
12455    CreateAudioConsumer {
12456        session_id: u64,
12457        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12458        control_handle: SessionAudioConsumerFactoryControlHandle,
12459    },
12460}
12461
12462impl SessionAudioConsumerFactoryRequest {
12463    #[allow(irrefutable_let_patterns)]
12464    pub fn into_create_audio_consumer(
12465        self,
12466    ) -> Option<(
12467        u64,
12468        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
12469        SessionAudioConsumerFactoryControlHandle,
12470    )> {
12471        if let SessionAudioConsumerFactoryRequest::CreateAudioConsumer {
12472            session_id,
12473            audio_consumer_request,
12474            control_handle,
12475        } = self
12476        {
12477            Some((session_id, audio_consumer_request, control_handle))
12478        } else {
12479            None
12480        }
12481    }
12482
12483    /// Name of the method defined in FIDL
12484    pub fn method_name(&self) -> &'static str {
12485        match *self {
12486            SessionAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
12487                "create_audio_consumer"
12488            }
12489        }
12490    }
12491}
12492
12493#[derive(Debug, Clone)]
12494pub struct SessionAudioConsumerFactoryControlHandle {
12495    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12496}
12497
12498impl SessionAudioConsumerFactoryControlHandle {
12499    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
12500        self.inner.shutdown_with_epitaph(status.into())
12501    }
12502}
12503
12504impl fidl::endpoints::ControlHandle for SessionAudioConsumerFactoryControlHandle {
12505    fn shutdown(&self) {
12506        self.inner.shutdown()
12507    }
12508
12509    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
12510        self.inner.shutdown_with_epitaph(status)
12511    }
12512
12513    fn is_closed(&self) -> bool {
12514        self.inner.channel().is_closed()
12515    }
12516    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
12517        self.inner.channel().on_closed()
12518    }
12519
12520    #[cfg(target_os = "fuchsia")]
12521    fn signal_peer(
12522        &self,
12523        clear_mask: zx::Signals,
12524        set_mask: zx::Signals,
12525    ) -> Result<(), zx_status::Status> {
12526        use fidl::Peered;
12527        self.inner.channel().signal_peer(clear_mask, set_mask)
12528    }
12529}
12530
12531impl SessionAudioConsumerFactoryControlHandle {}
12532
12533#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
12534pub struct SimpleStreamSinkMarker;
12535
12536impl fidl::endpoints::ProtocolMarker for SimpleStreamSinkMarker {
12537    type Proxy = SimpleStreamSinkProxy;
12538    type RequestStream = SimpleStreamSinkRequestStream;
12539    #[cfg(target_os = "fuchsia")]
12540    type SynchronousProxy = SimpleStreamSinkSynchronousProxy;
12541
12542    const DEBUG_NAME: &'static str = "(anonymous) SimpleStreamSink";
12543}
12544
12545pub trait SimpleStreamSinkProxyInterface: Send + Sync {
12546    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
12547    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
12548    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12549    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
12550    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
12551    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
12552    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
12553    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
12554    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
12555}
12556#[derive(Debug)]
12557#[cfg(target_os = "fuchsia")]
12558pub struct SimpleStreamSinkSynchronousProxy {
12559    client: fidl::client::sync::Client,
12560}
12561
12562#[cfg(target_os = "fuchsia")]
12563impl fidl::endpoints::SynchronousProxy for SimpleStreamSinkSynchronousProxy {
12564    type Proxy = SimpleStreamSinkProxy;
12565    type Protocol = SimpleStreamSinkMarker;
12566
12567    fn from_channel(inner: fidl::Channel) -> Self {
12568        Self::new(inner)
12569    }
12570
12571    fn into_channel(self) -> fidl::Channel {
12572        self.client.into_channel()
12573    }
12574
12575    fn as_channel(&self) -> &fidl::Channel {
12576        self.client.as_channel()
12577    }
12578}
12579
12580#[cfg(target_os = "fuchsia")]
12581impl SimpleStreamSinkSynchronousProxy {
12582    pub fn new(channel: fidl::Channel) -> Self {
12583        Self { client: fidl::client::sync::Client::new(channel) }
12584    }
12585
12586    pub fn into_channel(self) -> fidl::Channel {
12587        self.client.into_channel()
12588    }
12589
12590    /// Waits until an event arrives and returns it. It is safe for other
12591    /// threads to make concurrent requests while waiting for an event.
12592    pub fn wait_for_event(
12593        &self,
12594        deadline: zx::MonotonicInstant,
12595    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12596        SimpleStreamSinkEvent::decode(
12597            self.client.wait_for_event::<SimpleStreamSinkMarker>(deadline)?,
12598        )
12599    }
12600
12601    /// Adds a payload buffer to the current buffer set associated with the
12602    /// connection. A `StreamPacket` struct reference a payload buffer in the
12603    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12604    ///
12605    /// A buffer with ID `id` must not be in the current set when this method is
12606    /// invoked, otherwise the service will close the connection.
12607    pub fn r#add_payload_buffer(
12608        &self,
12609        mut id: u32,
12610        mut payload_buffer: fidl::Vmo,
12611    ) -> Result<(), fidl::Error> {
12612        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12613            (id, payload_buffer),
12614            0x3b3a37fc34fe5b56,
12615            fidl::encoding::DynamicFlags::empty(),
12616        )
12617    }
12618
12619    /// Removes a payload buffer from the current buffer set associated with the
12620    /// connection.
12621    ///
12622    /// A buffer with ID `id` must exist in the current set when this method is
12623    /// invoked, otherwise the service will will close the connection.
12624    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12625        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12626            (id,),
12627            0x5d1e4f74c3658262,
12628            fidl::encoding::DynamicFlags::empty(),
12629        )
12630    }
12631
12632    /// Sends a packet to the service. The response is sent when the service is
12633    /// done with the associated payload memory.
12634    ///
12635    /// `packet` must be valid for the current buffer set, otherwise the service
12636    /// will close the connection.
12637    pub fn r#send_packet(
12638        &self,
12639        mut packet: &StreamPacket,
12640        ___deadline: zx::MonotonicInstant,
12641    ) -> Result<(), fidl::Error> {
12642        let _response = self.client.send_query::<
12643            StreamSinkSendPacketRequest,
12644            fidl::encoding::EmptyPayload,
12645            SimpleStreamSinkMarker,
12646        >(
12647            (packet,),
12648            0x67cddd607442775f,
12649            fidl::encoding::DynamicFlags::empty(),
12650            ___deadline,
12651        )?;
12652        Ok(_response)
12653    }
12654
12655    /// Sends a packet to the service. This interface doesn't define how the
12656    /// client knows when the sink is done with the associated payload memory.
12657    /// The inheriting interface must define that.
12658    ///
12659    /// `packet` must be valid for the current buffer set, otherwise the service
12660    /// will close the connection.
12661    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12662        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12663            (packet,),
12664            0x8d9b8b413ceba9d,
12665            fidl::encoding::DynamicFlags::empty(),
12666        )
12667    }
12668
12669    /// Indicates the stream has ended. The precise semantics of this method are
12670    /// determined by the inheriting interface.
12671    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12672        self.client.send::<fidl::encoding::EmptyPayload>(
12673            (),
12674            0x6180fd6f7e793b71,
12675            fidl::encoding::DynamicFlags::empty(),
12676        )
12677    }
12678
12679    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12680    /// and not yet released. The response is sent after all packets have been
12681    /// released.
12682    pub fn r#discard_all_packets(
12683        &self,
12684        ___deadline: zx::MonotonicInstant,
12685    ) -> Result<(), fidl::Error> {
12686        let _response = self.client.send_query::<
12687            fidl::encoding::EmptyPayload,
12688            fidl::encoding::EmptyPayload,
12689            SimpleStreamSinkMarker,
12690        >(
12691            (),
12692            0x6f4dad7af2917665,
12693            fidl::encoding::DynamicFlags::empty(),
12694            ___deadline,
12695        )?;
12696        Ok(_response)
12697    }
12698
12699    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12700    /// and not yet released.
12701    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12702        self.client.send::<fidl::encoding::EmptyPayload>(
12703            (),
12704            0x50d36d0d23081bc4,
12705            fidl::encoding::DynamicFlags::empty(),
12706        )
12707    }
12708}
12709
12710#[cfg(target_os = "fuchsia")]
12711impl From<SimpleStreamSinkSynchronousProxy> for zx::NullableHandle {
12712    fn from(value: SimpleStreamSinkSynchronousProxy) -> Self {
12713        value.into_channel().into()
12714    }
12715}
12716
12717#[cfg(target_os = "fuchsia")]
12718impl From<fidl::Channel> for SimpleStreamSinkSynchronousProxy {
12719    fn from(value: fidl::Channel) -> Self {
12720        Self::new(value)
12721    }
12722}
12723
12724#[cfg(target_os = "fuchsia")]
12725impl fidl::endpoints::FromClient for SimpleStreamSinkSynchronousProxy {
12726    type Protocol = SimpleStreamSinkMarker;
12727
12728    fn from_client(value: fidl::endpoints::ClientEnd<SimpleStreamSinkMarker>) -> Self {
12729        Self::new(value.into_channel())
12730    }
12731}
12732
12733#[derive(Debug, Clone)]
12734pub struct SimpleStreamSinkProxy {
12735    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
12736}
12737
12738impl fidl::endpoints::Proxy for SimpleStreamSinkProxy {
12739    type Protocol = SimpleStreamSinkMarker;
12740
12741    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
12742        Self::new(inner)
12743    }
12744
12745    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
12746        self.client.into_channel().map_err(|client| Self { client })
12747    }
12748
12749    fn as_channel(&self) -> &::fidl::AsyncChannel {
12750        self.client.as_channel()
12751    }
12752}
12753
12754impl SimpleStreamSinkProxy {
12755    /// Create a new Proxy for fuchsia.media/SimpleStreamSink.
12756    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
12757        let protocol_name = <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
12758        Self { client: fidl::client::Client::new(channel, protocol_name) }
12759    }
12760
12761    /// Get a Stream of events from the remote end of the protocol.
12762    ///
12763    /// # Panics
12764    ///
12765    /// Panics if the event stream was already taken.
12766    pub fn take_event_stream(&self) -> SimpleStreamSinkEventStream {
12767        SimpleStreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
12768    }
12769
12770    /// Adds a payload buffer to the current buffer set associated with the
12771    /// connection. A `StreamPacket` struct reference a payload buffer in the
12772    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
12773    ///
12774    /// A buffer with ID `id` must not be in the current set when this method is
12775    /// invoked, otherwise the service will close the connection.
12776    pub fn r#add_payload_buffer(
12777        &self,
12778        mut id: u32,
12779        mut payload_buffer: fidl::Vmo,
12780    ) -> Result<(), fidl::Error> {
12781        SimpleStreamSinkProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
12782    }
12783
12784    /// Removes a payload buffer from the current buffer set associated with the
12785    /// connection.
12786    ///
12787    /// A buffer with ID `id` must exist in the current set when this method is
12788    /// invoked, otherwise the service will will close the connection.
12789    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12790        SimpleStreamSinkProxyInterface::r#remove_payload_buffer(self, id)
12791    }
12792
12793    /// Sends a packet to the service. The response is sent when the service is
12794    /// done with the associated payload memory.
12795    ///
12796    /// `packet` must be valid for the current buffer set, otherwise the service
12797    /// will close the connection.
12798    pub fn r#send_packet(
12799        &self,
12800        mut packet: &StreamPacket,
12801    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12802        SimpleStreamSinkProxyInterface::r#send_packet(self, packet)
12803    }
12804
12805    /// Sends a packet to the service. This interface doesn't define how the
12806    /// client knows when the sink is done with the associated payload memory.
12807    /// The inheriting interface must define that.
12808    ///
12809    /// `packet` must be valid for the current buffer set, otherwise the service
12810    /// will close the connection.
12811    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12812        SimpleStreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
12813    }
12814
12815    /// Indicates the stream has ended. The precise semantics of this method are
12816    /// determined by the inheriting interface.
12817    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12818        SimpleStreamSinkProxyInterface::r#end_of_stream(self)
12819    }
12820
12821    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12822    /// and not yet released. The response is sent after all packets have been
12823    /// released.
12824    pub fn r#discard_all_packets(
12825        &self,
12826    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
12827        SimpleStreamSinkProxyInterface::r#discard_all_packets(self)
12828    }
12829
12830    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
12831    /// and not yet released.
12832    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12833        SimpleStreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
12834    }
12835}
12836
12837impl SimpleStreamSinkProxyInterface for SimpleStreamSinkProxy {
12838    fn r#add_payload_buffer(
12839        &self,
12840        mut id: u32,
12841        mut payload_buffer: fidl::Vmo,
12842    ) -> Result<(), fidl::Error> {
12843        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
12844            (id, payload_buffer),
12845            0x3b3a37fc34fe5b56,
12846            fidl::encoding::DynamicFlags::empty(),
12847        )
12848    }
12849
12850    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
12851        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
12852            (id,),
12853            0x5d1e4f74c3658262,
12854            fidl::encoding::DynamicFlags::empty(),
12855        )
12856    }
12857
12858    type SendPacketResponseFut =
12859        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12860    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
12861        fn _decode(
12862            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12863        ) -> Result<(), fidl::Error> {
12864            let _response = fidl::client::decode_transaction_body::<
12865                fidl::encoding::EmptyPayload,
12866                fidl::encoding::DefaultFuchsiaResourceDialect,
12867                0x67cddd607442775f,
12868            >(_buf?)?;
12869            Ok(_response)
12870        }
12871        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
12872            (packet,),
12873            0x67cddd607442775f,
12874            fidl::encoding::DynamicFlags::empty(),
12875            _decode,
12876        )
12877    }
12878
12879    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
12880        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
12881            (packet,),
12882            0x8d9b8b413ceba9d,
12883            fidl::encoding::DynamicFlags::empty(),
12884        )
12885    }
12886
12887    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
12888        self.client.send::<fidl::encoding::EmptyPayload>(
12889            (),
12890            0x6180fd6f7e793b71,
12891            fidl::encoding::DynamicFlags::empty(),
12892        )
12893    }
12894
12895    type DiscardAllPacketsResponseFut =
12896        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
12897    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
12898        fn _decode(
12899            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
12900        ) -> Result<(), fidl::Error> {
12901            let _response = fidl::client::decode_transaction_body::<
12902                fidl::encoding::EmptyPayload,
12903                fidl::encoding::DefaultFuchsiaResourceDialect,
12904                0x6f4dad7af2917665,
12905            >(_buf?)?;
12906            Ok(_response)
12907        }
12908        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
12909            (),
12910            0x6f4dad7af2917665,
12911            fidl::encoding::DynamicFlags::empty(),
12912            _decode,
12913        )
12914    }
12915
12916    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
12917        self.client.send::<fidl::encoding::EmptyPayload>(
12918            (),
12919            0x50d36d0d23081bc4,
12920            fidl::encoding::DynamicFlags::empty(),
12921        )
12922    }
12923}
12924
12925pub struct SimpleStreamSinkEventStream {
12926    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
12927}
12928
12929impl std::marker::Unpin for SimpleStreamSinkEventStream {}
12930
12931impl futures::stream::FusedStream for SimpleStreamSinkEventStream {
12932    fn is_terminated(&self) -> bool {
12933        self.event_receiver.is_terminated()
12934    }
12935}
12936
12937impl futures::Stream for SimpleStreamSinkEventStream {
12938    type Item = Result<SimpleStreamSinkEvent, fidl::Error>;
12939
12940    fn poll_next(
12941        mut self: std::pin::Pin<&mut Self>,
12942        cx: &mut std::task::Context<'_>,
12943    ) -> std::task::Poll<Option<Self::Item>> {
12944        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
12945            &mut self.event_receiver,
12946            cx
12947        )?) {
12948            Some(buf) => std::task::Poll::Ready(Some(SimpleStreamSinkEvent::decode(buf))),
12949            None => std::task::Poll::Ready(None),
12950        }
12951    }
12952}
12953
12954#[derive(Debug)]
12955pub enum SimpleStreamSinkEvent {}
12956
12957impl SimpleStreamSinkEvent {
12958    /// Decodes a message buffer as a [`SimpleStreamSinkEvent`].
12959    fn decode(
12960        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
12961    ) -> Result<SimpleStreamSinkEvent, fidl::Error> {
12962        let (bytes, _handles) = buf.split_mut();
12963        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
12964        debug_assert_eq!(tx_header.tx_id, 0);
12965        match tx_header.ordinal {
12966            _ => Err(fidl::Error::UnknownOrdinal {
12967                ordinal: tx_header.ordinal,
12968                protocol_name:
12969                    <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
12970            }),
12971        }
12972    }
12973}
12974
12975/// A Stream of incoming requests for fuchsia.media/SimpleStreamSink.
12976pub struct SimpleStreamSinkRequestStream {
12977    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
12978    is_terminated: bool,
12979}
12980
12981impl std::marker::Unpin for SimpleStreamSinkRequestStream {}
12982
12983impl futures::stream::FusedStream for SimpleStreamSinkRequestStream {
12984    fn is_terminated(&self) -> bool {
12985        self.is_terminated
12986    }
12987}
12988
12989impl fidl::endpoints::RequestStream for SimpleStreamSinkRequestStream {
12990    type Protocol = SimpleStreamSinkMarker;
12991    type ControlHandle = SimpleStreamSinkControlHandle;
12992
12993    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
12994        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
12995    }
12996
12997    fn control_handle(&self) -> Self::ControlHandle {
12998        SimpleStreamSinkControlHandle { inner: self.inner.clone() }
12999    }
13000
13001    fn into_inner(
13002        self,
13003    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13004    {
13005        (self.inner, self.is_terminated)
13006    }
13007
13008    fn from_inner(
13009        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13010        is_terminated: bool,
13011    ) -> Self {
13012        Self { inner, is_terminated }
13013    }
13014}
13015
13016impl futures::Stream for SimpleStreamSinkRequestStream {
13017    type Item = Result<SimpleStreamSinkRequest, fidl::Error>;
13018
13019    fn poll_next(
13020        mut self: std::pin::Pin<&mut Self>,
13021        cx: &mut std::task::Context<'_>,
13022    ) -> std::task::Poll<Option<Self::Item>> {
13023        let this = &mut *self;
13024        if this.inner.check_shutdown(cx) {
13025            this.is_terminated = true;
13026            return std::task::Poll::Ready(None);
13027        }
13028        if this.is_terminated {
13029            panic!("polled SimpleStreamSinkRequestStream after completion");
13030        }
13031        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13032            |bytes, handles| {
13033                match this.inner.channel().read_etc(cx, bytes, handles) {
13034                    std::task::Poll::Ready(Ok(())) => {}
13035                    std::task::Poll::Pending => return std::task::Poll::Pending,
13036                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13037                        this.is_terminated = true;
13038                        return std::task::Poll::Ready(None);
13039                    }
13040                    std::task::Poll::Ready(Err(e)) => {
13041                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13042                            e.into(),
13043                        ))));
13044                    }
13045                }
13046
13047                // A message has been received from the channel
13048                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13049
13050                std::task::Poll::Ready(Some(match header.ordinal {
13051                    0x3b3a37fc34fe5b56 => {
13052                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13053                        let mut req = fidl::new_empty!(
13054                            StreamBufferSetAddPayloadBufferRequest,
13055                            fidl::encoding::DefaultFuchsiaResourceDialect
13056                        );
13057                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13058                        let control_handle =
13059                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13060                        Ok(SimpleStreamSinkRequest::AddPayloadBuffer {
13061                            id: req.id,
13062                            payload_buffer: req.payload_buffer,
13063
13064                            control_handle,
13065                        })
13066                    }
13067                    0x5d1e4f74c3658262 => {
13068                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13069                        let mut req = fidl::new_empty!(
13070                            StreamBufferSetRemovePayloadBufferRequest,
13071                            fidl::encoding::DefaultFuchsiaResourceDialect
13072                        );
13073                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13074                        let control_handle =
13075                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13076                        Ok(SimpleStreamSinkRequest::RemovePayloadBuffer {
13077                            id: req.id,
13078
13079                            control_handle,
13080                        })
13081                    }
13082                    0x67cddd607442775f => {
13083                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13084                        let mut req = fidl::new_empty!(
13085                            StreamSinkSendPacketRequest,
13086                            fidl::encoding::DefaultFuchsiaResourceDialect
13087                        );
13088                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
13089                        let control_handle =
13090                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13091                        Ok(SimpleStreamSinkRequest::SendPacket {
13092                            packet: req.packet,
13093
13094                            responder: SimpleStreamSinkSendPacketResponder {
13095                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13096                                tx_id: header.tx_id,
13097                            },
13098                        })
13099                    }
13100                    0x8d9b8b413ceba9d => {
13101                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13102                        let mut req = fidl::new_empty!(
13103                            StreamSinkSendPacketNoReplyRequest,
13104                            fidl::encoding::DefaultFuchsiaResourceDialect
13105                        );
13106                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
13107                        let control_handle =
13108                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13109                        Ok(SimpleStreamSinkRequest::SendPacketNoReply {
13110                            packet: req.packet,
13111
13112                            control_handle,
13113                        })
13114                    }
13115                    0x6180fd6f7e793b71 => {
13116                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13117                        let mut req = fidl::new_empty!(
13118                            fidl::encoding::EmptyPayload,
13119                            fidl::encoding::DefaultFuchsiaResourceDialect
13120                        );
13121                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13122                        let control_handle =
13123                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13124                        Ok(SimpleStreamSinkRequest::EndOfStream { control_handle })
13125                    }
13126                    0x6f4dad7af2917665 => {
13127                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
13128                        let mut req = fidl::new_empty!(
13129                            fidl::encoding::EmptyPayload,
13130                            fidl::encoding::DefaultFuchsiaResourceDialect
13131                        );
13132                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13133                        let control_handle =
13134                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13135                        Ok(SimpleStreamSinkRequest::DiscardAllPackets {
13136                            responder: SimpleStreamSinkDiscardAllPacketsResponder {
13137                                control_handle: std::mem::ManuallyDrop::new(control_handle),
13138                                tx_id: header.tx_id,
13139                            },
13140                        })
13141                    }
13142                    0x50d36d0d23081bc4 => {
13143                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13144                        let mut req = fidl::new_empty!(
13145                            fidl::encoding::EmptyPayload,
13146                            fidl::encoding::DefaultFuchsiaResourceDialect
13147                        );
13148                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
13149                        let control_handle =
13150                            SimpleStreamSinkControlHandle { inner: this.inner.clone() };
13151                        Ok(SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
13152                    }
13153                    _ => Err(fidl::Error::UnknownOrdinal {
13154                        ordinal: header.ordinal,
13155                        protocol_name:
13156                            <SimpleStreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13157                    }),
13158                }))
13159            },
13160        )
13161    }
13162}
13163
13164/// A StreamSink that uses StreamBufferSet for buffer management.
13165#[derive(Debug)]
13166pub enum SimpleStreamSinkRequest {
13167    /// Adds a payload buffer to the current buffer set associated with the
13168    /// connection. A `StreamPacket` struct reference a payload buffer in the
13169    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13170    ///
13171    /// A buffer with ID `id` must not be in the current set when this method is
13172    /// invoked, otherwise the service will close the connection.
13173    AddPayloadBuffer {
13174        id: u32,
13175        payload_buffer: fidl::Vmo,
13176        control_handle: SimpleStreamSinkControlHandle,
13177    },
13178    /// Removes a payload buffer from the current buffer set associated with the
13179    /// connection.
13180    ///
13181    /// A buffer with ID `id` must exist in the current set when this method is
13182    /// invoked, otherwise the service will will close the connection.
13183    RemovePayloadBuffer { id: u32, control_handle: SimpleStreamSinkControlHandle },
13184    /// Sends a packet to the service. The response is sent when the service is
13185    /// done with the associated payload memory.
13186    ///
13187    /// `packet` must be valid for the current buffer set, otherwise the service
13188    /// will close the connection.
13189    SendPacket { packet: StreamPacket, responder: SimpleStreamSinkSendPacketResponder },
13190    /// Sends a packet to the service. This interface doesn't define how the
13191    /// client knows when the sink is done with the associated payload memory.
13192    /// The inheriting interface must define that.
13193    ///
13194    /// `packet` must be valid for the current buffer set, otherwise the service
13195    /// will close the connection.
13196    SendPacketNoReply { packet: StreamPacket, control_handle: SimpleStreamSinkControlHandle },
13197    /// Indicates the stream has ended. The precise semantics of this method are
13198    /// determined by the inheriting interface.
13199    EndOfStream { control_handle: SimpleStreamSinkControlHandle },
13200    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
13201    /// and not yet released. The response is sent after all packets have been
13202    /// released.
13203    DiscardAllPackets { responder: SimpleStreamSinkDiscardAllPacketsResponder },
13204    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
13205    /// and not yet released.
13206    DiscardAllPacketsNoReply { control_handle: SimpleStreamSinkControlHandle },
13207}
13208
13209impl SimpleStreamSinkRequest {
13210    #[allow(irrefutable_let_patterns)]
13211    pub fn into_add_payload_buffer(
13212        self,
13213    ) -> Option<(u32, fidl::Vmo, SimpleStreamSinkControlHandle)> {
13214        if let SimpleStreamSinkRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13215            self
13216        {
13217            Some((id, payload_buffer, control_handle))
13218        } else {
13219            None
13220        }
13221    }
13222
13223    #[allow(irrefutable_let_patterns)]
13224    pub fn into_remove_payload_buffer(self) -> Option<(u32, SimpleStreamSinkControlHandle)> {
13225        if let SimpleStreamSinkRequest::RemovePayloadBuffer { id, control_handle } = self {
13226            Some((id, control_handle))
13227        } else {
13228            None
13229        }
13230    }
13231
13232    #[allow(irrefutable_let_patterns)]
13233    pub fn into_send_packet(self) -> Option<(StreamPacket, SimpleStreamSinkSendPacketResponder)> {
13234        if let SimpleStreamSinkRequest::SendPacket { packet, responder } = self {
13235            Some((packet, responder))
13236        } else {
13237            None
13238        }
13239    }
13240
13241    #[allow(irrefutable_let_patterns)]
13242    pub fn into_send_packet_no_reply(
13243        self,
13244    ) -> Option<(StreamPacket, SimpleStreamSinkControlHandle)> {
13245        if let SimpleStreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
13246            Some((packet, control_handle))
13247        } else {
13248            None
13249        }
13250    }
13251
13252    #[allow(irrefutable_let_patterns)]
13253    pub fn into_end_of_stream(self) -> Option<(SimpleStreamSinkControlHandle)> {
13254        if let SimpleStreamSinkRequest::EndOfStream { control_handle } = self {
13255            Some((control_handle))
13256        } else {
13257            None
13258        }
13259    }
13260
13261    #[allow(irrefutable_let_patterns)]
13262    pub fn into_discard_all_packets(self) -> Option<(SimpleStreamSinkDiscardAllPacketsResponder)> {
13263        if let SimpleStreamSinkRequest::DiscardAllPackets { responder } = self {
13264            Some((responder))
13265        } else {
13266            None
13267        }
13268    }
13269
13270    #[allow(irrefutable_let_patterns)]
13271    pub fn into_discard_all_packets_no_reply(self) -> Option<(SimpleStreamSinkControlHandle)> {
13272        if let SimpleStreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
13273            Some((control_handle))
13274        } else {
13275            None
13276        }
13277    }
13278
13279    /// Name of the method defined in FIDL
13280    pub fn method_name(&self) -> &'static str {
13281        match *self {
13282            SimpleStreamSinkRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13283            SimpleStreamSinkRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13284            SimpleStreamSinkRequest::SendPacket { .. } => "send_packet",
13285            SimpleStreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
13286            SimpleStreamSinkRequest::EndOfStream { .. } => "end_of_stream",
13287            SimpleStreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
13288            SimpleStreamSinkRequest::DiscardAllPacketsNoReply { .. } => {
13289                "discard_all_packets_no_reply"
13290            }
13291        }
13292    }
13293}
13294
13295#[derive(Debug, Clone)]
13296pub struct SimpleStreamSinkControlHandle {
13297    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13298}
13299
13300impl SimpleStreamSinkControlHandle {
13301    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
13302        self.inner.shutdown_with_epitaph(status.into())
13303    }
13304}
13305
13306impl fidl::endpoints::ControlHandle for SimpleStreamSinkControlHandle {
13307    fn shutdown(&self) {
13308        self.inner.shutdown()
13309    }
13310
13311    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
13312        self.inner.shutdown_with_epitaph(status)
13313    }
13314
13315    fn is_closed(&self) -> bool {
13316        self.inner.channel().is_closed()
13317    }
13318    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13319        self.inner.channel().on_closed()
13320    }
13321
13322    #[cfg(target_os = "fuchsia")]
13323    fn signal_peer(
13324        &self,
13325        clear_mask: zx::Signals,
13326        set_mask: zx::Signals,
13327    ) -> Result<(), zx_status::Status> {
13328        use fidl::Peered;
13329        self.inner.channel().signal_peer(clear_mask, set_mask)
13330    }
13331}
13332
13333impl SimpleStreamSinkControlHandle {}
13334
13335#[must_use = "FIDL methods require a response to be sent"]
13336#[derive(Debug)]
13337pub struct SimpleStreamSinkSendPacketResponder {
13338    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13339    tx_id: u32,
13340}
13341
13342/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13343/// if the responder is dropped without sending a response, so that the client
13344/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13345impl std::ops::Drop for SimpleStreamSinkSendPacketResponder {
13346    fn drop(&mut self) {
13347        self.control_handle.shutdown();
13348        // Safety: drops once, never accessed again
13349        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13350    }
13351}
13352
13353impl fidl::endpoints::Responder for SimpleStreamSinkSendPacketResponder {
13354    type ControlHandle = SimpleStreamSinkControlHandle;
13355
13356    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13357        &self.control_handle
13358    }
13359
13360    fn drop_without_shutdown(mut self) {
13361        // Safety: drops once, never accessed again due to mem::forget
13362        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13363        // Prevent Drop from running (which would shut down the channel)
13364        std::mem::forget(self);
13365    }
13366}
13367
13368impl SimpleStreamSinkSendPacketResponder {
13369    /// Sends a response to the FIDL transaction.
13370    ///
13371    /// Sets the channel to shutdown if an error occurs.
13372    pub fn send(self) -> Result<(), fidl::Error> {
13373        let _result = self.send_raw();
13374        if _result.is_err() {
13375            self.control_handle.shutdown();
13376        }
13377        self.drop_without_shutdown();
13378        _result
13379    }
13380
13381    /// Similar to "send" but does not shutdown the channel if an error occurs.
13382    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13383        let _result = self.send_raw();
13384        self.drop_without_shutdown();
13385        _result
13386    }
13387
13388    fn send_raw(&self) -> Result<(), fidl::Error> {
13389        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13390            (),
13391            self.tx_id,
13392            0x67cddd607442775f,
13393            fidl::encoding::DynamicFlags::empty(),
13394        )
13395    }
13396}
13397
13398#[must_use = "FIDL methods require a response to be sent"]
13399#[derive(Debug)]
13400pub struct SimpleStreamSinkDiscardAllPacketsResponder {
13401    control_handle: std::mem::ManuallyDrop<SimpleStreamSinkControlHandle>,
13402    tx_id: u32,
13403}
13404
13405/// Set the the channel to be shutdown (see [`SimpleStreamSinkControlHandle::shutdown`])
13406/// if the responder is dropped without sending a response, so that the client
13407/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
13408impl std::ops::Drop for SimpleStreamSinkDiscardAllPacketsResponder {
13409    fn drop(&mut self) {
13410        self.control_handle.shutdown();
13411        // Safety: drops once, never accessed again
13412        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13413    }
13414}
13415
13416impl fidl::endpoints::Responder for SimpleStreamSinkDiscardAllPacketsResponder {
13417    type ControlHandle = SimpleStreamSinkControlHandle;
13418
13419    fn control_handle(&self) -> &SimpleStreamSinkControlHandle {
13420        &self.control_handle
13421    }
13422
13423    fn drop_without_shutdown(mut self) {
13424        // Safety: drops once, never accessed again due to mem::forget
13425        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
13426        // Prevent Drop from running (which would shut down the channel)
13427        std::mem::forget(self);
13428    }
13429}
13430
13431impl SimpleStreamSinkDiscardAllPacketsResponder {
13432    /// Sends a response to the FIDL transaction.
13433    ///
13434    /// Sets the channel to shutdown if an error occurs.
13435    pub fn send(self) -> Result<(), fidl::Error> {
13436        let _result = self.send_raw();
13437        if _result.is_err() {
13438            self.control_handle.shutdown();
13439        }
13440        self.drop_without_shutdown();
13441        _result
13442    }
13443
13444    /// Similar to "send" but does not shutdown the channel if an error occurs.
13445    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
13446        let _result = self.send_raw();
13447        self.drop_without_shutdown();
13448        _result
13449    }
13450
13451    fn send_raw(&self) -> Result<(), fidl::Error> {
13452        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
13453            (),
13454            self.tx_id,
13455            0x6f4dad7af2917665,
13456            fidl::encoding::DynamicFlags::empty(),
13457        )
13458    }
13459}
13460
13461#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13462pub struct StreamBufferSetMarker;
13463
13464impl fidl::endpoints::ProtocolMarker for StreamBufferSetMarker {
13465    type Proxy = StreamBufferSetProxy;
13466    type RequestStream = StreamBufferSetRequestStream;
13467    #[cfg(target_os = "fuchsia")]
13468    type SynchronousProxy = StreamBufferSetSynchronousProxy;
13469
13470    const DEBUG_NAME: &'static str = "(anonymous) StreamBufferSet";
13471}
13472
13473pub trait StreamBufferSetProxyInterface: Send + Sync {
13474    fn r#add_payload_buffer(&self, id: u32, payload_buffer: fidl::Vmo) -> Result<(), fidl::Error>;
13475    fn r#remove_payload_buffer(&self, id: u32) -> Result<(), fidl::Error>;
13476}
13477#[derive(Debug)]
13478#[cfg(target_os = "fuchsia")]
13479pub struct StreamBufferSetSynchronousProxy {
13480    client: fidl::client::sync::Client,
13481}
13482
13483#[cfg(target_os = "fuchsia")]
13484impl fidl::endpoints::SynchronousProxy for StreamBufferSetSynchronousProxy {
13485    type Proxy = StreamBufferSetProxy;
13486    type Protocol = StreamBufferSetMarker;
13487
13488    fn from_channel(inner: fidl::Channel) -> Self {
13489        Self::new(inner)
13490    }
13491
13492    fn into_channel(self) -> fidl::Channel {
13493        self.client.into_channel()
13494    }
13495
13496    fn as_channel(&self) -> &fidl::Channel {
13497        self.client.as_channel()
13498    }
13499}
13500
13501#[cfg(target_os = "fuchsia")]
13502impl StreamBufferSetSynchronousProxy {
13503    pub fn new(channel: fidl::Channel) -> Self {
13504        Self { client: fidl::client::sync::Client::new(channel) }
13505    }
13506
13507    pub fn into_channel(self) -> fidl::Channel {
13508        self.client.into_channel()
13509    }
13510
13511    /// Waits until an event arrives and returns it. It is safe for other
13512    /// threads to make concurrent requests while waiting for an event.
13513    pub fn wait_for_event(
13514        &self,
13515        deadline: zx::MonotonicInstant,
13516    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13517        StreamBufferSetEvent::decode(self.client.wait_for_event::<StreamBufferSetMarker>(deadline)?)
13518    }
13519
13520    /// Adds a payload buffer to the current buffer set associated with the
13521    /// connection. A `StreamPacket` struct reference a payload buffer in the
13522    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13523    ///
13524    /// A buffer with ID `id` must not be in the current set when this method is
13525    /// invoked, otherwise the service will close the connection.
13526    pub fn r#add_payload_buffer(
13527        &self,
13528        mut id: u32,
13529        mut payload_buffer: fidl::Vmo,
13530    ) -> Result<(), fidl::Error> {
13531        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13532            (id, payload_buffer),
13533            0x3b3a37fc34fe5b56,
13534            fidl::encoding::DynamicFlags::empty(),
13535        )
13536    }
13537
13538    /// Removes a payload buffer from the current buffer set associated with the
13539    /// connection.
13540    ///
13541    /// A buffer with ID `id` must exist in the current set when this method is
13542    /// invoked, otherwise the service will will close the connection.
13543    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13544        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13545            (id,),
13546            0x5d1e4f74c3658262,
13547            fidl::encoding::DynamicFlags::empty(),
13548        )
13549    }
13550}
13551
13552#[cfg(target_os = "fuchsia")]
13553impl From<StreamBufferSetSynchronousProxy> for zx::NullableHandle {
13554    fn from(value: StreamBufferSetSynchronousProxy) -> Self {
13555        value.into_channel().into()
13556    }
13557}
13558
13559#[cfg(target_os = "fuchsia")]
13560impl From<fidl::Channel> for StreamBufferSetSynchronousProxy {
13561    fn from(value: fidl::Channel) -> Self {
13562        Self::new(value)
13563    }
13564}
13565
13566#[cfg(target_os = "fuchsia")]
13567impl fidl::endpoints::FromClient for StreamBufferSetSynchronousProxy {
13568    type Protocol = StreamBufferSetMarker;
13569
13570    fn from_client(value: fidl::endpoints::ClientEnd<StreamBufferSetMarker>) -> Self {
13571        Self::new(value.into_channel())
13572    }
13573}
13574
13575#[derive(Debug, Clone)]
13576pub struct StreamBufferSetProxy {
13577    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
13578}
13579
13580impl fidl::endpoints::Proxy for StreamBufferSetProxy {
13581    type Protocol = StreamBufferSetMarker;
13582
13583    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
13584        Self::new(inner)
13585    }
13586
13587    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
13588        self.client.into_channel().map_err(|client| Self { client })
13589    }
13590
13591    fn as_channel(&self) -> &::fidl::AsyncChannel {
13592        self.client.as_channel()
13593    }
13594}
13595
13596impl StreamBufferSetProxy {
13597    /// Create a new Proxy for fuchsia.media/StreamBufferSet.
13598    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
13599        let protocol_name = <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
13600        Self { client: fidl::client::Client::new(channel, protocol_name) }
13601    }
13602
13603    /// Get a Stream of events from the remote end of the protocol.
13604    ///
13605    /// # Panics
13606    ///
13607    /// Panics if the event stream was already taken.
13608    pub fn take_event_stream(&self) -> StreamBufferSetEventStream {
13609        StreamBufferSetEventStream { event_receiver: self.client.take_event_receiver() }
13610    }
13611
13612    /// Adds a payload buffer to the current buffer set associated with the
13613    /// connection. A `StreamPacket` struct reference a payload buffer in the
13614    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13615    ///
13616    /// A buffer with ID `id` must not be in the current set when this method is
13617    /// invoked, otherwise the service will close the connection.
13618    pub fn r#add_payload_buffer(
13619        &self,
13620        mut id: u32,
13621        mut payload_buffer: fidl::Vmo,
13622    ) -> Result<(), fidl::Error> {
13623        StreamBufferSetProxyInterface::r#add_payload_buffer(self, id, payload_buffer)
13624    }
13625
13626    /// Removes a payload buffer from the current buffer set associated with the
13627    /// connection.
13628    ///
13629    /// A buffer with ID `id` must exist in the current set when this method is
13630    /// invoked, otherwise the service will will close the connection.
13631    pub fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13632        StreamBufferSetProxyInterface::r#remove_payload_buffer(self, id)
13633    }
13634}
13635
13636impl StreamBufferSetProxyInterface for StreamBufferSetProxy {
13637    fn r#add_payload_buffer(
13638        &self,
13639        mut id: u32,
13640        mut payload_buffer: fidl::Vmo,
13641    ) -> Result<(), fidl::Error> {
13642        self.client.send::<StreamBufferSetAddPayloadBufferRequest>(
13643            (id, payload_buffer),
13644            0x3b3a37fc34fe5b56,
13645            fidl::encoding::DynamicFlags::empty(),
13646        )
13647    }
13648
13649    fn r#remove_payload_buffer(&self, mut id: u32) -> Result<(), fidl::Error> {
13650        self.client.send::<StreamBufferSetRemovePayloadBufferRequest>(
13651            (id,),
13652            0x5d1e4f74c3658262,
13653            fidl::encoding::DynamicFlags::empty(),
13654        )
13655    }
13656}
13657
13658pub struct StreamBufferSetEventStream {
13659    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
13660}
13661
13662impl std::marker::Unpin for StreamBufferSetEventStream {}
13663
13664impl futures::stream::FusedStream for StreamBufferSetEventStream {
13665    fn is_terminated(&self) -> bool {
13666        self.event_receiver.is_terminated()
13667    }
13668}
13669
13670impl futures::Stream for StreamBufferSetEventStream {
13671    type Item = Result<StreamBufferSetEvent, fidl::Error>;
13672
13673    fn poll_next(
13674        mut self: std::pin::Pin<&mut Self>,
13675        cx: &mut std::task::Context<'_>,
13676    ) -> std::task::Poll<Option<Self::Item>> {
13677        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
13678            &mut self.event_receiver,
13679            cx
13680        )?) {
13681            Some(buf) => std::task::Poll::Ready(Some(StreamBufferSetEvent::decode(buf))),
13682            None => std::task::Poll::Ready(None),
13683        }
13684    }
13685}
13686
13687#[derive(Debug)]
13688pub enum StreamBufferSetEvent {}
13689
13690impl StreamBufferSetEvent {
13691    /// Decodes a message buffer as a [`StreamBufferSetEvent`].
13692    fn decode(
13693        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
13694    ) -> Result<StreamBufferSetEvent, fidl::Error> {
13695        let (bytes, _handles) = buf.split_mut();
13696        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13697        debug_assert_eq!(tx_header.tx_id, 0);
13698        match tx_header.ordinal {
13699            _ => Err(fidl::Error::UnknownOrdinal {
13700                ordinal: tx_header.ordinal,
13701                protocol_name:
13702                    <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13703            }),
13704        }
13705    }
13706}
13707
13708/// A Stream of incoming requests for fuchsia.media/StreamBufferSet.
13709pub struct StreamBufferSetRequestStream {
13710    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13711    is_terminated: bool,
13712}
13713
13714impl std::marker::Unpin for StreamBufferSetRequestStream {}
13715
13716impl futures::stream::FusedStream for StreamBufferSetRequestStream {
13717    fn is_terminated(&self) -> bool {
13718        self.is_terminated
13719    }
13720}
13721
13722impl fidl::endpoints::RequestStream for StreamBufferSetRequestStream {
13723    type Protocol = StreamBufferSetMarker;
13724    type ControlHandle = StreamBufferSetControlHandle;
13725
13726    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
13727        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
13728    }
13729
13730    fn control_handle(&self) -> Self::ControlHandle {
13731        StreamBufferSetControlHandle { inner: self.inner.clone() }
13732    }
13733
13734    fn into_inner(
13735        self,
13736    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
13737    {
13738        (self.inner, self.is_terminated)
13739    }
13740
13741    fn from_inner(
13742        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13743        is_terminated: bool,
13744    ) -> Self {
13745        Self { inner, is_terminated }
13746    }
13747}
13748
13749impl futures::Stream for StreamBufferSetRequestStream {
13750    type Item = Result<StreamBufferSetRequest, fidl::Error>;
13751
13752    fn poll_next(
13753        mut self: std::pin::Pin<&mut Self>,
13754        cx: &mut std::task::Context<'_>,
13755    ) -> std::task::Poll<Option<Self::Item>> {
13756        let this = &mut *self;
13757        if this.inner.check_shutdown(cx) {
13758            this.is_terminated = true;
13759            return std::task::Poll::Ready(None);
13760        }
13761        if this.is_terminated {
13762            panic!("polled StreamBufferSetRequestStream after completion");
13763        }
13764        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
13765            |bytes, handles| {
13766                match this.inner.channel().read_etc(cx, bytes, handles) {
13767                    std::task::Poll::Ready(Ok(())) => {}
13768                    std::task::Poll::Pending => return std::task::Poll::Pending,
13769                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
13770                        this.is_terminated = true;
13771                        return std::task::Poll::Ready(None);
13772                    }
13773                    std::task::Poll::Ready(Err(e)) => {
13774                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
13775                            e.into(),
13776                        ))));
13777                    }
13778                }
13779
13780                // A message has been received from the channel
13781                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
13782
13783                std::task::Poll::Ready(Some(match header.ordinal {
13784                    0x3b3a37fc34fe5b56 => {
13785                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13786                        let mut req = fidl::new_empty!(
13787                            StreamBufferSetAddPayloadBufferRequest,
13788                            fidl::encoding::DefaultFuchsiaResourceDialect
13789                        );
13790                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetAddPayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13791                        let control_handle =
13792                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13793                        Ok(StreamBufferSetRequest::AddPayloadBuffer {
13794                            id: req.id,
13795                            payload_buffer: req.payload_buffer,
13796
13797                            control_handle,
13798                        })
13799                    }
13800                    0x5d1e4f74c3658262 => {
13801                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
13802                        let mut req = fidl::new_empty!(
13803                            StreamBufferSetRemovePayloadBufferRequest,
13804                            fidl::encoding::DefaultFuchsiaResourceDialect
13805                        );
13806                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamBufferSetRemovePayloadBufferRequest>(&header, _body_bytes, handles, &mut req)?;
13807                        let control_handle =
13808                            StreamBufferSetControlHandle { inner: this.inner.clone() };
13809                        Ok(StreamBufferSetRequest::RemovePayloadBuffer {
13810                            id: req.id,
13811
13812                            control_handle,
13813                        })
13814                    }
13815                    _ => Err(fidl::Error::UnknownOrdinal {
13816                        ordinal: header.ordinal,
13817                        protocol_name:
13818                            <StreamBufferSetMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
13819                    }),
13820                }))
13821            },
13822        )
13823    }
13824}
13825
13826/// Manages a set of payload buffers for a stream. This interface is typically
13827/// inherited along with `StreamSink` or `StreamSource` to enable the transport
13828/// of elementary streams between clients and services.
13829#[derive(Debug)]
13830pub enum StreamBufferSetRequest {
13831    /// Adds a payload buffer to the current buffer set associated with the
13832    /// connection. A `StreamPacket` struct reference a payload buffer in the
13833    /// current set by ID using the `StreamPacket.payload_buffer_id` field.
13834    ///
13835    /// A buffer with ID `id` must not be in the current set when this method is
13836    /// invoked, otherwise the service will close the connection.
13837    AddPayloadBuffer {
13838        id: u32,
13839        payload_buffer: fidl::Vmo,
13840        control_handle: StreamBufferSetControlHandle,
13841    },
13842    /// Removes a payload buffer from the current buffer set associated with the
13843    /// connection.
13844    ///
13845    /// A buffer with ID `id` must exist in the current set when this method is
13846    /// invoked, otherwise the service will will close the connection.
13847    RemovePayloadBuffer { id: u32, control_handle: StreamBufferSetControlHandle },
13848}
13849
13850impl StreamBufferSetRequest {
13851    #[allow(irrefutable_let_patterns)]
13852    pub fn into_add_payload_buffer(self) -> Option<(u32, fidl::Vmo, StreamBufferSetControlHandle)> {
13853        if let StreamBufferSetRequest::AddPayloadBuffer { id, payload_buffer, control_handle } =
13854            self
13855        {
13856            Some((id, payload_buffer, control_handle))
13857        } else {
13858            None
13859        }
13860    }
13861
13862    #[allow(irrefutable_let_patterns)]
13863    pub fn into_remove_payload_buffer(self) -> Option<(u32, StreamBufferSetControlHandle)> {
13864        if let StreamBufferSetRequest::RemovePayloadBuffer { id, control_handle } = self {
13865            Some((id, control_handle))
13866        } else {
13867            None
13868        }
13869    }
13870
13871    /// Name of the method defined in FIDL
13872    pub fn method_name(&self) -> &'static str {
13873        match *self {
13874            StreamBufferSetRequest::AddPayloadBuffer { .. } => "add_payload_buffer",
13875            StreamBufferSetRequest::RemovePayloadBuffer { .. } => "remove_payload_buffer",
13876        }
13877    }
13878}
13879
13880#[derive(Debug, Clone)]
13881pub struct StreamBufferSetControlHandle {
13882    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
13883}
13884
13885impl StreamBufferSetControlHandle {
13886    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
13887        self.inner.shutdown_with_epitaph(status.into())
13888    }
13889}
13890
13891impl fidl::endpoints::ControlHandle for StreamBufferSetControlHandle {
13892    fn shutdown(&self) {
13893        self.inner.shutdown()
13894    }
13895
13896    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
13897        self.inner.shutdown_with_epitaph(status)
13898    }
13899
13900    fn is_closed(&self) -> bool {
13901        self.inner.channel().is_closed()
13902    }
13903    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
13904        self.inner.channel().on_closed()
13905    }
13906
13907    #[cfg(target_os = "fuchsia")]
13908    fn signal_peer(
13909        &self,
13910        clear_mask: zx::Signals,
13911        set_mask: zx::Signals,
13912    ) -> Result<(), zx_status::Status> {
13913        use fidl::Peered;
13914        self.inner.channel().signal_peer(clear_mask, set_mask)
13915    }
13916}
13917
13918impl StreamBufferSetControlHandle {}
13919
13920#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
13921pub struct StreamProcessorMarker;
13922
13923impl fidl::endpoints::ProtocolMarker for StreamProcessorMarker {
13924    type Proxy = StreamProcessorProxy;
13925    type RequestStream = StreamProcessorRequestStream;
13926    #[cfg(target_os = "fuchsia")]
13927    type SynchronousProxy = StreamProcessorSynchronousProxy;
13928
13929    const DEBUG_NAME: &'static str = "(anonymous) StreamProcessor";
13930}
13931
13932pub trait StreamProcessorProxyInterface: Send + Sync {
13933    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error>;
13934    fn r#set_input_buffer_partial_settings(
13935        &self,
13936        input_settings: StreamBufferPartialSettings,
13937    ) -> Result<(), fidl::Error>;
13938    fn r#set_output_buffer_partial_settings(
13939        &self,
13940        output_settings: StreamBufferPartialSettings,
13941    ) -> Result<(), fidl::Error>;
13942    fn r#complete_output_buffer_partial_settings(
13943        &self,
13944        buffer_lifetime_ordinal: u64,
13945    ) -> Result<(), fidl::Error>;
13946    fn r#flush_end_of_stream_and_close_stream(
13947        &self,
13948        stream_lifetime_ordinal: u64,
13949    ) -> Result<(), fidl::Error>;
13950    fn r#close_current_stream(
13951        &self,
13952        stream_lifetime_ordinal: u64,
13953        release_input_buffers: bool,
13954        release_output_buffers: bool,
13955    ) -> Result<(), fidl::Error>;
13956    type SyncResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13957    fn r#sync(&self) -> Self::SyncResponseFut;
13958    fn r#recycle_output_packet(
13959        &self,
13960        available_output_packet: &PacketHeader,
13961    ) -> Result<(), fidl::Error>;
13962    fn r#queue_input_format_details(
13963        &self,
13964        stream_lifetime_ordinal: u64,
13965        format_details: &FormatDetails,
13966    ) -> Result<(), fidl::Error>;
13967    fn r#queue_input_packet(&self, packet: &Packet) -> Result<(), fidl::Error>;
13968    fn r#queue_input_end_of_stream(&self, stream_lifetime_ordinal: u64) -> Result<(), fidl::Error>;
13969    fn r#participate_in_buffer_allocation(
13970        &self,
13971        payload: StreamProcessorParticipateInBufferAllocationRequest,
13972    ) -> Result<(), fidl::Error>;
13973    fn r#add_buffer(&self, payload: StreamProcessorAddBufferRequest) -> Result<(), fidl::Error>;
13974    type RemoveBufferResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
13975    fn r#remove_buffer(
13976        &self,
13977        payload: StreamProcessorRemoveBufferRequest,
13978    ) -> Self::RemoveBufferResponseFut;
13979    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error>;
13980    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error>;
13981    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error>;
13982}
13983#[derive(Debug)]
13984#[cfg(target_os = "fuchsia")]
13985pub struct StreamProcessorSynchronousProxy {
13986    client: fidl::client::sync::Client,
13987}
13988
13989#[cfg(target_os = "fuchsia")]
13990impl fidl::endpoints::SynchronousProxy for StreamProcessorSynchronousProxy {
13991    type Proxy = StreamProcessorProxy;
13992    type Protocol = StreamProcessorMarker;
13993
13994    fn from_channel(inner: fidl::Channel) -> Self {
13995        Self::new(inner)
13996    }
13997
13998    fn into_channel(self) -> fidl::Channel {
13999        self.client.into_channel()
14000    }
14001
14002    fn as_channel(&self) -> &fidl::Channel {
14003        self.client.as_channel()
14004    }
14005}
14006
14007#[cfg(target_os = "fuchsia")]
14008impl StreamProcessorSynchronousProxy {
14009    pub fn new(channel: fidl::Channel) -> Self {
14010        Self { client: fidl::client::sync::Client::new(channel) }
14011    }
14012
14013    pub fn into_channel(self) -> fidl::Channel {
14014        self.client.into_channel()
14015    }
14016
14017    /// Waits until an event arrives and returns it. It is safe for other
14018    /// threads to make concurrent requests while waiting for an event.
14019    pub fn wait_for_event(
14020        &self,
14021        deadline: zx::MonotonicInstant,
14022    ) -> Result<StreamProcessorEvent, fidl::Error> {
14023        StreamProcessorEvent::decode(self.client.wait_for_event::<StreamProcessorMarker>(deadline)?)
14024    }
14025
14026    /// Permit the server to use OnStreamFailed() instead of the server just
14027    /// closing the whole StreamProcessor channel on stream failure.
14028    ///
14029    /// If the server hasn't seen this message by the time a stream fails, the
14030    /// server will close the StreamProcessor channel instead of sending
14031    /// OnStreamFailed().
14032    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14033        self.client.send::<fidl::encoding::EmptyPayload>(
14034            (),
14035            0x3940929617dbf02b,
14036            fidl::encoding::DynamicFlags::empty(),
14037        )
14038    }
14039
14040    /// When the client is not using dynamic buffers, a single
14041    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
14042    /// client-specified input settings and a BufferCollectionToken which the
14043    /// StreamProcessor will use to convey constraints to sysmem.  Both the
14044    /// client and the StreamProcessor will be informed of the allocated buffers
14045    /// directly by sysmem via their BufferCollection channel (not via the
14046    /// StreamProcessor channel).
14047    ///
14048    /// The client must not QueueInput...() until after sysmem informs the
14049    /// client that buffer allocation has completed and was successful.
14050    ///
14051    /// The server should be prepared to see QueueInput...() before the server
14052    /// has necessarily heard from sysmem that the buffers are allocated - the
14053    /// server must tolerate either ordering, as the QueueInput...() and
14054    /// notification of sysmem allocation completion arrive on different
14055    /// channels, so the client having heard that allocation is complete doesn't
14056    /// mean the server knows that allocation is complete yet.  However, the
14057    /// server can expect that allocation is in fact complete and can expect to
14058    /// get the allocation information from sysmem immediately upon requesting
14059    /// the information from sysmem.
14060    ///
14061    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
14062    /// while there are any buffers still active on the port. To successfully
14063    /// switch modes for a port, most clients will want to just start over with
14064    /// a new StreamProcessor instance. This can also be done reliably by first
14065    /// ensuring that every added buffer under the port up to "now" (including
14066    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14067    /// request. Only then is it known ok to switch modes for that port under
14068    /// the same StreamProcessor. Most clients will just use one way or the
14069    /// other to add buffers and never need to switch to the other way,
14070    /// especially within the same StreamProcessor.
14071    pub fn r#set_input_buffer_partial_settings(
14072        &self,
14073        mut input_settings: StreamBufferPartialSettings,
14074    ) -> Result<(), fidl::Error> {
14075        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
14076            (&mut input_settings,),
14077            0xb02e0663a40e4c4,
14078            fidl::encoding::DynamicFlags::empty(),
14079        )
14080    }
14081
14082    /// This is the replacement for SetOutputBufferSettings().
14083    ///
14084    /// When the client is using sysmem to allocate buffers, this message is
14085    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14086    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14087    /// with the client-specified output settings and a BufferCollectionToken
14088    /// which the StreamProcessor will use to convey constraints to sysmem. Both
14089    /// the client and the StreamProcessor will be informed of the allocated
14090    /// buffers directly by sysmem via their BufferCollection channel (not via
14091    /// the StreamProcessor channel).
14092    ///
14093    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14094    /// received by the client with buffer_constraints_action_required true and
14095    /// stream_lifetime_ordinal equal to the client's current
14096    /// stream_lifetime_ordinal (even if there is an active stream), and is
14097    /// _permitted_ any time there is no current stream.
14098    ///
14099    /// Closing the current stream occurs on the StreamControl ordering domain,
14100    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
14101    /// subsequent Sync() completion must be received by the client before the
14102    /// client knows that there's no longer a current stream.
14103    ///
14104    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
14105    /// while there are any buffers still active on the port. To successfully
14106    /// switch modes for a port, most clients will want to just start over with
14107    /// a new StreamProcessor instance. This can also be done reliably by first
14108    /// ensuring that every added buffer under the port up to "now" (including
14109    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14110    /// request. Only then is it known ok to switch modes for that port under
14111    /// the same StreamProcessor. Most clients will just use one way or the
14112    /// other to add buffers and never need to switch to the other way,
14113    /// especially not within the same StreamProcessor instance.
14114    ///
14115    /// See also CompleteOutputBufferPartialSettings().
14116    pub fn r#set_output_buffer_partial_settings(
14117        &self,
14118        mut output_settings: StreamBufferPartialSettings,
14119    ) -> Result<(), fidl::Error> {
14120        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
14121            (&mut output_settings,),
14122            0x118bb8c819a7bbbb,
14123            fidl::encoding::DynamicFlags::empty(),
14124        )
14125    }
14126
14127    /// After SetOutputBufferPartialSettings(), the server won't send
14128    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
14129    /// OnOutputEndOfStream() until after the client sends
14130    /// CompleteOutputBufferPartialSettings().
14131    ///
14132    /// This message isn't permitted after AddBuffer. When using dynamic buffers
14133    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
14134    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
14135    /// the case of OnOutputPacket there must also be at least one output buffer
14136    /// that's been added but not yet fully removed (RemoveBuffer not yet
14137    /// complete).
14138    ///
14139    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
14140    /// immediately after SetOutputBufferPartialSettings() - in that case the
14141    /// client needs to be prepared to receive output without knowing the buffer
14142    /// count or packet count yet - such clients may internally delay processing
14143    /// the received output until the client has heard from sysmem (which is
14144    /// when the client will learn the buffer count and packet count).
14145    ///
14146    /// Other clients may first wait for sysmem to allocate, prepare to receive
14147    /// output, and then send CompleteOutputBufferPartialSettings().
14148    pub fn r#complete_output_buffer_partial_settings(
14149        &self,
14150        mut buffer_lifetime_ordinal: u64,
14151    ) -> Result<(), fidl::Error> {
14152        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
14153            (buffer_lifetime_ordinal,),
14154            0x50529e5c680ae3ab,
14155            fidl::encoding::DynamicFlags::empty(),
14156        )
14157    }
14158
14159    /// This message is optional; a client isn't required to send this ever.
14160    ///
14161    /// Terminology note: In the name of this message, "flush" means flush
14162    /// through, sometimes called "drain". This messge does not discard. To
14163    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
14164    /// without first waiting for OnOutputEndOfStream of the old stream and
14165    /// without sending FlushEndOfStreamAndCloseStream.
14166    ///
14167    /// There is currently no way to cancel the flush effect of this message
14168    /// short of the client closing the StreamProcessor channel.
14169    ///
14170    /// This message is only valid after QueueInputEndOfStream() for this
14171    /// stream. The stream_lifetime_ordinal input parameter must match the
14172    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
14173    /// will close the channel.
14174    ///
14175    /// A client can use this message to flush through (drain, not discard) the
14176    /// last input data of a stream so that the stream processor server
14177    /// generates corresponding output data for all the input data before the
14178    /// server moves on to the next stream, without forcing the client to wait
14179    /// for OnOutputEndOfStream() before queueing data of another stream.
14180    ///
14181    /// The difference between QueueInputEndOfStream() and
14182    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
14183    /// from the client that there will not be any more input data for the
14184    /// stream (and this info is needed by some stream processors for the stream
14185    /// processor to ever emit the very last output data).  The
14186    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
14187    /// later completely discarding the rest of the current stream by closing
14188    /// the current stream (with or without a stream switch).  In contrast,
14189    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
14190    /// the previously-queued input data be processed including the logical
14191    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
14192    /// before moving on to any newer stream - this essentially changes the
14193    /// close-stream handling from discard to flush-through for this stream
14194    /// only.
14195    ///
14196    /// A client using this message can start providing input data for a new
14197    /// stream without that causing discard of old stream data.  That's the
14198    /// purpose of this message - to allow a client to flush through (not
14199    /// discard) the old stream's last data (instead of the default when closing
14200    /// or switching streams which is discard).
14201    ///
14202    /// Because the old stream is not done processing yet and the old stream's
14203    /// data is not being discarded, the client must be prepared to continue to
14204    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
14205    /// is done. The client will know the stream_lifetime_ordinal is done when
14206    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
14207    /// closes.
14208    pub fn r#flush_end_of_stream_and_close_stream(
14209        &self,
14210        mut stream_lifetime_ordinal: u64,
14211    ) -> Result<(), fidl::Error> {
14212        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
14213            (stream_lifetime_ordinal,),
14214            0x2b62c3e26d0667e6,
14215            fidl::encoding::DynamicFlags::empty(),
14216        )
14217    }
14218
14219    /// This "closes" the current stream, leaving no current stream.  In
14220    /// addition, this message can optionally release (and unregister) input
14221    /// buffers or output buffers.
14222    ///
14223    /// If there has never been any active stream, the stream_lifetime_ordinal
14224    /// must be zero or the server will close the channel.  If there has been an
14225    /// active stream, the stream_lifetime_ordinal must be the most recent
14226    /// active stream whether that stream is still active or not.  Else the
14227    /// server will close the channel.
14228    ///
14229    /// Multiple of this message without any new active stream in between is not
14230    /// to be considered an error, which allows a client to use this message to
14231    /// close the current stream to stop wasting processing power on a stream
14232    /// the user no longer cares about, then later decide that buffers should be
14233    /// released and send this message again with release_input_buffers and/or
14234    /// release_output_buffers true to get the buffers released, if the client
14235    /// is interested in trying to avoid overlap in resource usage between old
14236    /// buffers and new buffers (not all clients are).
14237    ///
14238    /// See also Sync().
14239    pub fn r#close_current_stream(
14240        &self,
14241        mut stream_lifetime_ordinal: u64,
14242        mut release_input_buffers: bool,
14243        mut release_output_buffers: bool,
14244    ) -> Result<(), fidl::Error> {
14245        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
14246            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
14247            0x1d8a67522170ca07,
14248            fidl::encoding::DynamicFlags::empty(),
14249        )
14250    }
14251
14252    /// On completion, all previous StreamProcessor calls have done what they're
14253    /// going to do server-side, _except_ for processing of data queued using
14254    /// QueueInputPacket().
14255    ///
14256    /// The main purpose of this call is to enable the client to wait until
14257    /// CloseCurrentStream() with release_input_buffers and/or
14258    /// release_output_buffers set to true to take effect, before the client
14259    /// allocates new buffers and re-sets-up input and/or output buffers.  This
14260    /// de-overlapping of resource usage can be worthwhile for media buffers
14261    /// which can consume resource types whose overall pools aren't necessarily
14262    /// vast in comparison to resources consumed.  Especially if a client is
14263    /// reconfiguring buffers multiple times.
14264    ///
14265    /// Note that Sync() prior to allocating new media buffers is not alone
14266    /// sufficient to achieve non-overlap of media buffer resource usage system
14267    /// wide, but it can be a useful part of achieving that.
14268    ///
14269    /// The Sync() transits the Output ordering domain and the StreamControl
14270    /// ordering domain, but not the InputData ordering domain.
14271    ///
14272    /// This request can be used to avoid hitting kMaxInFlightStreams which is
14273    /// presently 10.  A client that stays <= 8 in-flight streams will
14274    /// comfortably stay under the limit of 10.  While the protocol permits
14275    /// repeated SetInputBufferSettings() and the like, a client that spams the
14276    /// channel can expect that the channel will just close if the server or the
14277    /// channel itself gets too far behind.
14278    pub fn r#sync(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
14279        let _response = self.client.send_query::<
14280            fidl::encoding::EmptyPayload,
14281            fidl::encoding::EmptyPayload,
14282            StreamProcessorMarker,
14283        >(
14284            (),
14285            0x4b3e44300b0ec6aa,
14286            fidl::encoding::DynamicFlags::empty(),
14287            ___deadline,
14288        )?;
14289        Ok(_response)
14290    }
14291
14292    /// After the client is done with an output packet, the client needs to tell
14293    /// the stream processor that the output packet can be re-used for more
14294    /// output, using this message.
14295    ///
14296    /// It's not permitted to recycle an output packet that's already free with
14297    /// the stream processor server.
14298    ///
14299    /// If a client is using EnableOldOutputBuffers, the client must recycle all
14300    /// packets when done with them, even those of old buffer_lifetime_ordinal.
14301    /// This is also permitted behavior for all clients.
14302    ///
14303    /// If a client is not using EnableOldOutputBuffers, the client may
14304    /// optionally omit this message for packets with an old
14305    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
14306    /// or implicit output buffer de-configuration don't need to be recycled if
14307    /// the client isn't using and won't be using EnableOldOutputBuffers.
14308    pub fn r#recycle_output_packet(
14309        &self,
14310        mut available_output_packet: &PacketHeader,
14311    ) -> Result<(), fidl::Error> {
14312        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
14313            (available_output_packet,),
14314            0x32763632b94e0bd5,
14315            fidl::encoding::DynamicFlags::empty(),
14316        )
14317    }
14318
14319    /// If the input format details are still the same as specified during
14320    /// StreamProcessor creation, this message is unnecessary and does not need
14321    /// to be sent.
14322    ///
14323    /// If the stream doesn't exist yet, this message creates the stream.
14324    ///
14325    /// The server won't send OnOutputConstraints() until after the client has
14326    /// sent at least one QueueInput* message.
14327    ///
14328    /// All servers must permit QueueInputFormatDetails() at the start of a
14329    /// stream without failing, as long as the new format is supported by the
14330    /// StreamProcessor instance. Technically this allows for a server to only
14331    /// support the exact input format set during StreamProcessor creation, and
14332    /// that is by design. A client that tries to switch formats and gets a
14333    /// StreamProcessor channel failure should try again one more time with a
14334    /// fresh StreamProcessor instance created with CodecFactory using the new
14335    /// input format during creation, before giving up.
14336    ///
14337    /// These format details override the format details specified during stream
14338    /// processor creation for this stream only. The next stream will default
14339    /// back to the format details set during stream processor creation.
14340    ///
14341    /// This message is permitted at the start of the first stream (just like at
14342    /// the start of any stream). The format specified need not match what was
14343    /// specified during stream processor creation, but if it doesn't match, the
14344    /// StreamProcessor channel might close as described above.
14345    pub fn r#queue_input_format_details(
14346        &self,
14347        mut stream_lifetime_ordinal: u64,
14348        mut format_details: &FormatDetails,
14349    ) -> Result<(), fidl::Error> {
14350        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
14351            (stream_lifetime_ordinal, format_details),
14352            0x170dc0979d52231,
14353            fidl::encoding::DynamicFlags::empty(),
14354        )
14355    }
14356
14357    /// This message queues input data to the stream processor for processing.
14358    ///
14359    /// If the stream doesn't exist yet, this message creates the new stream.
14360    ///
14361    /// The server won't send OnOutputConstraints() until after the client has
14362    /// sent at least one QueueInput* message.
14363    ///
14364    /// When using dynamic buffers the server can send OnOutputConstraints,
14365    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
14366    /// the first QueueInputPacket. In the case of OnOutputPacket there must
14367    /// also be at least one output buffer that's been added but not yet fully
14368    /// removed (RemoveBuffer not yet complete).
14369    ///
14370    /// The client must continue to deliver input data via this message even if
14371    /// the stream processor has not yet generated the first
14372    /// OnOutputConstraints, and even if the StreamProcessor is generating
14373    /// OnFreeInputPacket for previously-queued input packets.  The input data
14374    /// must continue as long as there are free packets to be assured that the
14375    /// server will ever generate the first OnOutputConstraints.
14376    ///
14377    /// The server will close the channel if this packet refers to an old
14378    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
14379    /// different dimensions to a video encoder can either (a) allocate buffers
14380    /// large enough to contain the range of needed image sizes and use those to
14381    /// deliver all the input images, (b) keep their own sets of buffers used
14382    /// for different image dimensions and re-add old buffers with AddBuffer,
14383    /// moving to a new buffer_lifetime_ordinal each time image dimensions
14384    /// change, or (c) allocate new buffers each time image dimensions change.
14385    /// The (a) option is preferred, for clients that have the flexibiilty to
14386    /// store images of varying dimensions in a single set of buffers. Clients
14387    /// that require each buffer to have a single image size can use option (b)
14388    /// or (c).
14389    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
14390        self.client.send::<StreamProcessorQueueInputPacketRequest>(
14391            (packet,),
14392            0x47173d2652d9df3b,
14393            fidl::encoding::DynamicFlags::empty(),
14394        )
14395    }
14396
14397    /// Inform the server that all QueueInputPacket() messages for this stream
14398    /// have been sent.
14399    ///
14400    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
14401    /// or StreamProcessor channel closing), there will later be a corresponding
14402    /// OnOutputEndOfStream().
14403    ///
14404    /// The corresponding OnOutputEndOfStream() message will be generated only
14405    /// if the server finishes processing the stream before the server sees the
14406    /// client close the stream (such as by starting a new stream). A way to
14407    /// force the server to finish the stream before closing is to use
14408    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
14409    /// any new stream. Another way to force the server to finish the stream
14410    /// before closing is to wait for the OnOutputEndOfStream() before taking
14411    /// any action that closes the stream.
14412    ///
14413    /// In addition to serving as an "EndOfStream" marker to make it obvious
14414    /// client-side when all input data has been processed, if a client never
14415    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
14416    /// result in all input data getting processed through to the output. Some
14417    /// stream processors have some internally-delayed data which only gets
14418    /// drained (pushed through) by additional input data _or_ by this
14419    /// EndOfStream marker. In that sense, this message can be viewed as a drain
14420    /// at InputData domain level, but the drain only takes effect if the stream
14421    /// processor even gets that far before the stream is just closed at
14422    /// StreamControl domain level. This message is not alone sufficient to act
14423    /// as an overall drain at StreamControl level. For that, send this message
14424    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
14425    /// becomes possible to queue input data for a new stream without causing
14426    /// discard of this older stream's data). Alternately, the client can wait
14427    /// for the OnOutputEndOfStream before closing the current stream.
14428    ///
14429    /// After a client sends QueueInputEndOfStream for a stream, if the client
14430    /// then sends for the same stream any of QueueInputPacket,
14431    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
14432    /// the StreamProcessor channel.
14433    pub fn r#queue_input_end_of_stream(
14434        &self,
14435        mut stream_lifetime_ordinal: u64,
14436    ) -> Result<(), fidl::Error> {
14437        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
14438            (stream_lifetime_ordinal,),
14439            0x2051b6ad00f20b37,
14440            fidl::encoding::DynamicFlags::empty(),
14441        )
14442    }
14443
14444    /// This message results in channel closure unless supports_dynamic_buffers
14445    /// is set to true.
14446    ///
14447    /// This participates in allocation of buffers to be used with AddBuffer
14448    /// later. The client can get VMO handles for these buffers by also
14449    /// participating in the sysmem allocation, using the client's own related
14450    /// sysmem token (associated with the same logical buffer collection). It's
14451    /// up to the client to separately set any constraints needed by the client
14452    /// using the client's own related sysmem token, if any.
14453    ///
14454    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
14455    /// SetOutputBufferPartialSettings. Servers must support those messages.
14456    ///
14457    /// In handling this message, if `allow_single_buffer` is set to true, the
14458    /// server must not constrain the number of buffers allocated. The server
14459    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
14460    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
14461    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
14462    /// same value if the intent is to allocate exactly that many buffers. If
14463    /// `allow_single_buffer` is un-set or set to false, the server will
14464    /// indicate needed buffer counts to sysmem.
14465    ///
14466    /// The server's BufferCollection channel (created from the passed-in
14467    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
14468    /// particular, the server shouldn't expect the BufferCollection channel to
14469    /// remain connected to sysmem beyond the server sending SetConstraints. For
14470    /// this reason, the server may not be able to call
14471    /// WaitForAllBuffersAllocated or similar, so the server should just send
14472    /// SetConstraints, Close, then close the server's BufferCollection
14473    /// client_end. This means the server in general shouldn't attempt to get
14474    /// VMO handles for these buffers while processing this message.
14475    ///
14476    /// The server should not assume that these buffers will necessarily ever be
14477    /// added with AddBuffer to this StreamProcessor instance or any other
14478    /// StreamProcessor instance (owned by the server or not). These buffers may
14479    /// instead be dropped, or as a less-common example, possibly added to a
14480    /// different codec served by a different server implementation which also
14481    /// participated in the same sysmem buffer collection allocation.
14482    ///
14483    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
14484    /// StreamProcessor instance of the same codec (same per CodecFactory) is
14485    /// likely to work, but using the same StreamProcessor instance is
14486    /// recommended when feasible.
14487    ///
14488    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
14489    /// a different StreamProcessor instance of the same codec (same per
14490    /// CodecFactory) can't (within reason) be made work in general, especially
14491    /// for video decoders. Therefore, for output buffers, the same
14492    /// StreamProcessor instance must be used for this message and AddBuffer.
14493    /// While a client may currently be able to get away with using different
14494    /// StreamProcessor instances for this message and AddBuffer for output
14495    /// buffers for some codecs, this may break at any time without it being
14496    /// considered a server-side bug.
14497    ///
14498    /// The allocated buffers can later be added using AddBuffer (piecemeal),
14499    /// and can be removed (piecemeal) using RemoveBuffer.
14500    ///
14501    /// Multiple different ParticipateInBufferAllocation messages can have their
14502    /// buffers later added to the same StreamProcessor instance using the same
14503    /// buffer_lifetime_ordinal. This can be useful if the client wants to
14504    /// allocate buffers incrementally, or dynamically adjust the number of
14505    /// buffers, potentially while actively processing. See also the
14506    /// `buffer_lifetime_ordinal` field of this message.
14507    ///
14508    /// Server implementations may use sysmem to help verify buffer
14509    /// compatibility later when buffers are added with AddBuffer.
14510    pub fn r#participate_in_buffer_allocation(
14511        &self,
14512        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
14513    ) -> Result<(), fidl::Error> {
14514        self.client.send::<StreamProcessorParticipateInBufferAllocationRequest>(
14515            &mut payload,
14516            0x122be3b0096183cb,
14517            fidl::encoding::DynamicFlags::FLEXIBLE,
14518        )
14519    }
14520
14521    /// Add buffers previously created with the help of
14522    /// ParticipateInBufferAllocation.
14523    ///
14524    /// For input buffers, the client can send QueueInputFormatDetails or
14525    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
14526    /// buffer must be added before a valid QueueInputPacket can be sent. Most
14527    /// clients will want to continue quickly adding buffers up to at least
14528    /// buffer_count_for_server_current to avoid the codec potentially stalling,
14529    /// and typically a low number of buffers beyond that to keep the pipeline
14530    /// running smoothly. Input buffers beyond the first input buffer can be
14531    /// added after the first QueueInputPacket.
14532    ///
14533    /// Even if buffer_constraints_version_ordinal is current, the server must
14534    /// not close the channel if the buffer isn't consistent with the current
14535    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
14536    /// consistent StreamProcessor constraints). Instead, the server must send a
14537    /// new OnOutputConstraints. This simplifies some edge cases for some
14538    /// clients, particularly when a client can't reliably detect whether a
14539    /// newly-obtained buffer was actually allocated after
14540    /// buffer_constraints_version_ordinal changed, or may have been cached from
14541    /// before.
14542    ///
14543    /// The client can add additional buffers to the same port and
14544    /// buffer_lifetime_ordinal at any time using this message. If the
14545    /// buffer_lifetime_ordinal is no longer the most recent, the message will
14546    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
14547    /// message re. the same buffer will complete immediately.
14548    ///
14549    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
14550    /// by the sum of buffers added by all AddBuffer calls with the same
14551    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
14552    /// required to close the channel in this case if performance degradation or
14553    /// un-tested behavior would result from adding too many buffers.
14554    ///
14555    /// Switching to a new buffer_lifetime_ordinal starts the process of
14556    /// removing buffers associated with an old buffer_lifetime_ordinal.
14557    /// However, until the remove is complete, those buffers can still be used
14558    /// by the codec as normal. See also RemoveBuffer, which can be used to
14559    /// detect when removal is complete, regardless of whether the RemoveBuffer
14560    /// started the removal (including when not using dynamic buffers).
14561    ///
14562    /// The buffer stays added until removal later completes. The buffer remains
14563    /// added across potentially multiple buffer re-uses. Removal can be
14564    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
14565    /// The codec server can unilaterally initiate buffer removal; if the server
14566    /// does this, it must send a new buffer_constraints_version_ordinal with
14567    /// action_required true. Some other client-initiated messages can also
14568    /// begin buffer removal, such as CloseCurrentStream with
14569    /// release_input_buffers and/or release_output_buffers. The buffers are
14570    /// also automatically removed and released if the client closes the
14571    /// StreamProcessor client_end or the server closes the StreamProcessor
14572    /// server_end.
14573    ///
14574    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
14575    /// SetOutputBufferPartialSettings is not allowed while there are any
14576    /// buffers still active on the port. To successfully switch modes for a
14577    /// port, most clients will want to just start over with a new
14578    /// StreamProcessor instance. This can also be done reliably by first
14579    /// ensuring that every added buffer under the port up to "now" (including
14580    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14581    /// request. Only then is it known ok to switch modes for that port under
14582    /// the same StreamProcessor. Most clients will just use one way or the
14583    /// other to add buffers and never need to switch to the other way,
14584    /// especially within the same StreamProcessor.
14585    ///
14586    /// If a client might plausibly "spam" creation of many new
14587    /// buffer_lifetime_ordinal values without the buffers seeing any actual
14588    /// usage in between, the client should consider starting a Sync every few
14589    /// buffer_lifetime_ordinal(s) to fence cleanup of old
14590    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
14591    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
14592    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
14593    /// getting too far ahead of closing out old ones. The threshold of 16 is
14594    /// well below the enforcement threshold. Clients don't need to Sync if they
14595    /// won't be spamming new buffer_lifetime_ordinal values, or if added
14596    /// buffers will see at least some actual usage visible to the client before
14597    /// being replaced again.
14598    ///
14599    /// All buffers of the same port and buffer_lifetime_ordinal must share the
14600    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
14601    /// this in various ways. One way is to use ParticipateInBufferAllocation
14602    /// then AddBuffer for at least the first buffer, before
14603    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
14604    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
14605    /// and bump to the next odd buffer_lifetime_ordinal value for the
14606    /// AddBuffer.
14607    pub fn r#add_buffer(
14608        &self,
14609        mut payload: StreamProcessorAddBufferRequest,
14610    ) -> Result<(), fidl::Error> {
14611        self.client.send::<StreamProcessorAddBufferRequest>(
14612            &mut payload,
14613            0x6eca773e923e0ada,
14614            fidl::encoding::DynamicFlags::FLEXIBLE,
14615        )
14616    }
14617
14618    /// When using dynamic buffers, this call removes a buffer as soon as the
14619    /// buffer can be removed without adversely impacting any ongoing processing
14620    /// or an in-flight output packet referring to the buffer.
14621    ///
14622    /// If a client wants to remove a buffer with an in-flight output packet
14623    /// referring to the buffer, the client must RecycleOutputPacket for that
14624    /// in-flight output packet before the RemoveBuffer will complete.
14625    ///
14626    /// When using SetInputBufferPartialSettings /
14627    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
14628    /// the buffer. This call will complete when the buffer is done removing due
14629    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
14630    ///
14631    /// Until RemoveBuffer completes, the codec is still allowed to send
14632    /// OnOutputPacket messages referencing the buffer, and the codec may still
14633    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
14634    /// codec guarantees that no subsequent output packet will reference the
14635    /// buffer, and that the server holds no VMO handles to the buffer.
14636    ///
14637    /// The client may need to recycle an output packet before the RemoveBuffer
14638    /// call can complete. Clients should take care to avoid blocking packet
14639    /// recycling while the RemoveBuffer request is in progress, since this
14640    /// would create a potential deadlock.
14641    ///
14642    /// The server closing any VMO handles to the buffer prior to completing
14643    /// this call is important for the client's ability to prevent memory usage
14644    /// spikes.
14645    ///
14646    /// If the client has "paused" processing by not providing any more input,
14647    /// the client will potentially need to send CloseCurrentStream before
14648    /// RemoveBuffer will complete. When using dynamic buffers, setting
14649    /// release_input_buffers or release_output_buffers to true is not
14650    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
14651    /// specific buffer. When not using dynamic buffers, the client will need to
14652    /// set release_input_buffers or release_output_buffers to true, since
14653    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
14654    /// buffers. A current "paused" stream needs to be stopped because frames
14655    /// can be held as reference frames, and codecs are never reqiured to copy
14656    /// their output data.
14657    ///
14658    /// For any video decoder output buffers being removed while there's an
14659    /// active stream (being fed input or not), it's typically best for the
14660    /// client to assume that removal of a video decoder output buffer may take
14661    /// a very long duration. This is because bitstreams, especially
14662    /// non-standard-compliant bitstreams, but in some cases potentially even
14663    /// standard-compliant bitstreams, can keep a video decoder output buffer in
14664    /// the set of active reference frames (aka DPB) indefinitely. The server is
14665    /// not required to notice that a stream is not conforming to a bitstream
14666    /// standard in this regard.
14667    ///
14668    /// In the case of h.264 decode, a standard-complient bitstream will limit
14669    /// the reorder delay to no longer than the max DPB occupancy. However, a
14670    /// server is not required to detect or reject non-compliant streams that
14671    /// potentially keep a frame in the DPB for longer.
14672    ///
14673    /// For HEVC, the situation is similar to h.264 (IIUC).
14674    ///
14675    /// In the case of VP9, there is nothing in the bitstream spec that limits
14676    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
14677    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
14678    /// required to detect or mitigate this.
14679    ///
14680    /// Until this call completes, the server may still be using the buffer. For
14681    /// output buffers, the server can still send OnOutputPacket message(s) that
14682    /// references this buffer, but only up until the RemoveBuffer completion
14683    /// message is sent by the server. The client must continue to
14684    /// RecycleOutputPacket for packets that reference the buffer, until
14685    /// RemoveBuffer completes.
14686    ///
14687    /// When using dynamic buffers, upon receiving this message, the server will
14688    /// stop selecting the buffer for any new usage (as in, for any usage that
14689    /// moves the buffer from "free" to "not free" within the server). This
14690    /// applies even if the server has no other buffers available for use (aka
14691    /// no other "free" buffers). Any existing usage of the buffer is not ended
14692    /// early by this call alone.
14693    ///
14694    /// When not using dynamic buffers, upon receiving this message, the server
14695    /// will just remember to complete this call shortly after the buffer has
14696    /// completed removal triggered by some other cause (removal is not
14697    /// triggered/caused by this call).
14698    ///
14699    /// For video decoders, when using dynamic buffers, typically the client
14700    /// should take care to avoid removing too many output buffers for continued
14701    /// decode to be possible. If this occurs, the decoder will wait until the
14702    /// client adds another output buffer with AddBuffer. This can be a deadlock
14703    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
14704    /// frame reordering, sending a single AddBuffer doesn't necessarily
14705    /// guarantee another OnOutputPacket, since additional output buffers can be
14706    /// needed before the server can send OnOutputPacket.
14707    ///
14708    /// The client must not call RemoveBuffer on the same buffer more than once,
14709    /// whether overlapping in time or not. The server should enforce this when
14710    /// not enforcing would require tracking additional concurrent requests. The
14711    /// server is not required to enforce this when enforcing would use more
14712    /// server memory.
14713    ///
14714    /// The server is allowed to complete this request quickly with success for
14715    /// buffer_lifetime_ordinal and buffer_index combinations that were never
14716    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
14717    /// hasn't been started by the client yet (no removing potential future
14718    /// buffers).
14719    ///
14720    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
14721    /// combination may be re-used after completion of RemoveBuffer, but only if
14722    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
14723    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
14724    ///
14725    /// Assuming a valid historical buffer is specified, successful completion
14726    /// of this call means the buffer has been fully released by the server and
14727    /// won't be referenced in any subsequent OnOutputPacket.
14728    pub fn r#remove_buffer(
14729        &self,
14730        mut payload: StreamProcessorRemoveBufferRequest,
14731        ___deadline: zx::MonotonicInstant,
14732    ) -> Result<(), fidl::Error> {
14733        let _response = self.client.send_query::<
14734            StreamProcessorRemoveBufferRequest,
14735            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
14736            StreamProcessorMarker,
14737        >(
14738            &mut payload,
14739            0x40b967ffa6b2da43,
14740            fidl::encoding::DynamicFlags::FLEXIBLE,
14741            ___deadline,
14742        )?
14743        .into_result::<StreamProcessorMarker>("remove_buffer")?;
14744        Ok(_response)
14745    }
14746
14747    /// This informs the StreamProcessor that the client is prepared to handle
14748    /// output packets that specify a buffer with buffer_lifetime_ordinal older
14749    /// than the most recent buffer_lifetime_ordinal.
14750    ///
14751    /// If the client doesn't send this message, the StreamProcessor will omit
14752    /// any such output, even if
14753    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
14754    /// decoders such as VP9 decoders, not sending this message can result in
14755    /// output that isn't bistream spec compliant, and the output can be
14756    /// visually different than intended by the bitstream.
14757    ///
14758    /// Such streams are only possible with some bitstream formats (such as
14759    /// VP9), and are rare, but can happen and can be valid per the bitstream
14760    /// spec. For example, this can be specified by a VP9 bitstream using
14761    /// show_existing_frame to output an old-dimensions buffer after having
14762    /// already output a new-dimensions buffer.
14763    ///
14764    /// Most clients that send this message will also want to use RemoveBuffer
14765    /// to know when it becomes safe to stop tracking an old buffer.
14766    ///
14767    /// Most of the time this makes no difference as most bitstreams don't
14768    /// actually emit old buffers, even if the bitstream spec would allow it.
14769    /// Old output buffers are especially rare for RTC streams which typically
14770    /// don't have any frame reordering in the first place.
14771    ///
14772    /// In most video streaming scenarios that use dimension switching as part
14773    /// of their bitrate control strategy (among those that I've observed), at
14774    /// the StreamProcessor layer the new dimensions are part of a new stream
14775    /// instead of being spliced together as a continuation of the old stream.
14776    /// That said, using a continuation of the old stream is also a completely
14777    /// valid way to implement dimension switching. When a stream switch occurs
14778    /// as part of dimension switching, the decoder state is not retained and
14779    /// there won't be any old buffer(s) emitted after new buffer(s), since the
14780    /// new stream doesn't know anything about old buffers filled by the old
14781    /// stream.
14782    ///
14783    /// Clients which haven't tested their ability to handle old output buffers
14784    /// should not send this message. Clients decoding bitstreams like VP9 for
14785    /// decoder compliance testing purposes should send this message (and use a
14786    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
14787    /// Clients which are required to support old output frames and/or fully
14788    /// comply with a relevant bitstream spec should/must send this message, and
14789    /// should test using a test stream that outputs packets referencing an old
14790    /// output buffer.
14791    ///
14792    /// Sending this message more than once closes the channel. If sent, this
14793    /// message must be sent prior to the client establishing the first output
14794    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
14795    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
14796    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
14797    /// client when this message was not sent by the client.
14798    ///
14799    /// This message is only permitted when
14800    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
14801    /// is true.
14802    pub fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
14803        self.client.send::<fidl::encoding::EmptyPayload>(
14804            (),
14805            0x3aedefeedf3898b0,
14806            fidl::encoding::DynamicFlags::FLEXIBLE,
14807        )
14808    }
14809
14810    /// This informs the StreamProcessor that the client is prepared to handle
14811    /// output packets that specify the same buffer as another packet that's
14812    /// also concurrently in flight to the client (not yet recycled).
14813    ///
14814    /// Most bitstream formats don't do this. In formats that can do this such
14815    /// as VP9, most actual bitstreams don't do this.
14816    ///
14817    /// As an example, in VP9, a stream can cause the same output buffer to be
14818    /// used by another emitted output packet/frame by using show_existing_frame
14819    /// on the same VP9 reference/held frame slot more than once without
14820    /// decoding a new frame into that slot in between.
14821    ///
14822    /// Clients that need to achieve full bitstream spec compliance for such a
14823    /// bitstream format must send this message.
14824    ///
14825    /// If this message is not in effect, the server will omit any such output,
14826    /// which can result in output that is not compliant to the relevant
14827    /// bitstream spec, and which can be visually different than the stream
14828    /// intended.
14829    ///
14830    /// Sending this message more than once closes the channel. If sent, this
14831    /// message must be sent prior to the client establishing the first output
14832    /// buffer_lifetime_ordinal.
14833    ///
14834    /// This message is only permitted when
14835    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
14836    /// is true.
14837    pub fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
14838        self.client.send::<fidl::encoding::EmptyPayload>(
14839            (),
14840            0x244e9f43b29709e7,
14841            fidl::encoding::DynamicFlags::FLEXIBLE,
14842        )
14843    }
14844
14845    /// For video decoders, this forces the output buffers to be reallocated if
14846    /// the image size needs to change. This is wasteful as it forces extra
14847    /// buffer reallocations given typical video bitrate control strategies
14848    /// (applicable to both streaming and RTC) involving shifting the image
14849    /// dimensions up and down repeatedly as a logical video/stream plays,
14850    /// sometimes even if network conditions remain fairly stable. This extra
14851    /// buffer reallocation cost is incurred vs. baseline whether the dimension
14852    /// switching is achieved within a single StreamProcessor stream or by using
14853    /// a new StreamProcessor stream for new dimensions.
14854    ///
14855    /// A client should not send this message unless the client really must
14856    /// force the output buffers to be reallocated every time the output image
14857    /// size changes.
14858    ///
14859    /// Sending this message more than once closes the channel. If sent, this
14860    /// message must be sent prior to any SetInputBufferPartialSettings,
14861    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
14862    /// AddBuffer.
14863    ///
14864    /// This message is only permitted if this StreamProcessor is a video
14865    /// decoder.
14866    ///
14867    /// This message is only permitted when
14868    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
14869    /// is true.
14870    pub fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
14871        self.client.send::<fidl::encoding::EmptyPayload>(
14872            (),
14873            0x3994b040f91dc1e9,
14874            fidl::encoding::DynamicFlags::FLEXIBLE,
14875        )
14876    }
14877}
14878
14879#[cfg(target_os = "fuchsia")]
14880impl From<StreamProcessorSynchronousProxy> for zx::NullableHandle {
14881    fn from(value: StreamProcessorSynchronousProxy) -> Self {
14882        value.into_channel().into()
14883    }
14884}
14885
14886#[cfg(target_os = "fuchsia")]
14887impl From<fidl::Channel> for StreamProcessorSynchronousProxy {
14888    fn from(value: fidl::Channel) -> Self {
14889        Self::new(value)
14890    }
14891}
14892
14893#[cfg(target_os = "fuchsia")]
14894impl fidl::endpoints::FromClient for StreamProcessorSynchronousProxy {
14895    type Protocol = StreamProcessorMarker;
14896
14897    fn from_client(value: fidl::endpoints::ClientEnd<StreamProcessorMarker>) -> Self {
14898        Self::new(value.into_channel())
14899    }
14900}
14901
14902#[derive(Debug, Clone)]
14903pub struct StreamProcessorProxy {
14904    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
14905}
14906
14907impl fidl::endpoints::Proxy for StreamProcessorProxy {
14908    type Protocol = StreamProcessorMarker;
14909
14910    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
14911        Self::new(inner)
14912    }
14913
14914    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
14915        self.client.into_channel().map_err(|client| Self { client })
14916    }
14917
14918    fn as_channel(&self) -> &::fidl::AsyncChannel {
14919        self.client.as_channel()
14920    }
14921}
14922
14923impl StreamProcessorProxy {
14924    /// Create a new Proxy for fuchsia.media/StreamProcessor.
14925    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
14926        let protocol_name = <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
14927        Self { client: fidl::client::Client::new(channel, protocol_name) }
14928    }
14929
14930    /// Get a Stream of events from the remote end of the protocol.
14931    ///
14932    /// # Panics
14933    ///
14934    /// Panics if the event stream was already taken.
14935    pub fn take_event_stream(&self) -> StreamProcessorEventStream {
14936        StreamProcessorEventStream { event_receiver: self.client.take_event_receiver() }
14937    }
14938
14939    /// Permit the server to use OnStreamFailed() instead of the server just
14940    /// closing the whole StreamProcessor channel on stream failure.
14941    ///
14942    /// If the server hasn't seen this message by the time a stream fails, the
14943    /// server will close the StreamProcessor channel instead of sending
14944    /// OnStreamFailed().
14945    pub fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
14946        StreamProcessorProxyInterface::r#enable_on_stream_failed(self)
14947    }
14948
14949    /// When the client is not using dynamic buffers, a single
14950    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
14951    /// client-specified input settings and a BufferCollectionToken which the
14952    /// StreamProcessor will use to convey constraints to sysmem.  Both the
14953    /// client and the StreamProcessor will be informed of the allocated buffers
14954    /// directly by sysmem via their BufferCollection channel (not via the
14955    /// StreamProcessor channel).
14956    ///
14957    /// The client must not QueueInput...() until after sysmem informs the
14958    /// client that buffer allocation has completed and was successful.
14959    ///
14960    /// The server should be prepared to see QueueInput...() before the server
14961    /// has necessarily heard from sysmem that the buffers are allocated - the
14962    /// server must tolerate either ordering, as the QueueInput...() and
14963    /// notification of sysmem allocation completion arrive on different
14964    /// channels, so the client having heard that allocation is complete doesn't
14965    /// mean the server knows that allocation is complete yet.  However, the
14966    /// server can expect that allocation is in fact complete and can expect to
14967    /// get the allocation information from sysmem immediately upon requesting
14968    /// the information from sysmem.
14969    ///
14970    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
14971    /// while there are any buffers still active on the port. To successfully
14972    /// switch modes for a port, most clients will want to just start over with
14973    /// a new StreamProcessor instance. This can also be done reliably by first
14974    /// ensuring that every added buffer under the port up to "now" (including
14975    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
14976    /// request. Only then is it known ok to switch modes for that port under
14977    /// the same StreamProcessor. Most clients will just use one way or the
14978    /// other to add buffers and never need to switch to the other way,
14979    /// especially within the same StreamProcessor.
14980    pub fn r#set_input_buffer_partial_settings(
14981        &self,
14982        mut input_settings: StreamBufferPartialSettings,
14983    ) -> Result<(), fidl::Error> {
14984        StreamProcessorProxyInterface::r#set_input_buffer_partial_settings(self, input_settings)
14985    }
14986
14987    /// This is the replacement for SetOutputBufferSettings().
14988    ///
14989    /// When the client is using sysmem to allocate buffers, this message is
14990    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
14991    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
14992    /// with the client-specified output settings and a BufferCollectionToken
14993    /// which the StreamProcessor will use to convey constraints to sysmem. Both
14994    /// the client and the StreamProcessor will be informed of the allocated
14995    /// buffers directly by sysmem via their BufferCollection channel (not via
14996    /// the StreamProcessor channel).
14997    ///
14998    /// Configuring output buffers is _required_ after OnOutputConstraints() is
14999    /// received by the client with buffer_constraints_action_required true and
15000    /// stream_lifetime_ordinal equal to the client's current
15001    /// stream_lifetime_ordinal (even if there is an active stream), and is
15002    /// _permitted_ any time there is no current stream.
15003    ///
15004    /// Closing the current stream occurs on the StreamControl ordering domain,
15005    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
15006    /// subsequent Sync() completion must be received by the client before the
15007    /// client knows that there's no longer a current stream.
15008    ///
15009    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
15010    /// while there are any buffers still active on the port. To successfully
15011    /// switch modes for a port, most clients will want to just start over with
15012    /// a new StreamProcessor instance. This can also be done reliably by first
15013    /// ensuring that every added buffer under the port up to "now" (including
15014    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
15015    /// request. Only then is it known ok to switch modes for that port under
15016    /// the same StreamProcessor. Most clients will just use one way or the
15017    /// other to add buffers and never need to switch to the other way,
15018    /// especially not within the same StreamProcessor instance.
15019    ///
15020    /// See also CompleteOutputBufferPartialSettings().
15021    pub fn r#set_output_buffer_partial_settings(
15022        &self,
15023        mut output_settings: StreamBufferPartialSettings,
15024    ) -> Result<(), fidl::Error> {
15025        StreamProcessorProxyInterface::r#set_output_buffer_partial_settings(self, output_settings)
15026    }
15027
15028    /// After SetOutputBufferPartialSettings(), the server won't send
15029    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
15030    /// OnOutputEndOfStream() until after the client sends
15031    /// CompleteOutputBufferPartialSettings().
15032    ///
15033    /// This message isn't permitted after AddBuffer. When using dynamic buffers
15034    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
15035    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
15036    /// the case of OnOutputPacket there must also be at least one output buffer
15037    /// that's been added but not yet fully removed (RemoveBuffer not yet
15038    /// complete).
15039    ///
15040    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
15041    /// immediately after SetOutputBufferPartialSettings() - in that case the
15042    /// client needs to be prepared to receive output without knowing the buffer
15043    /// count or packet count yet - such clients may internally delay processing
15044    /// the received output until the client has heard from sysmem (which is
15045    /// when the client will learn the buffer count and packet count).
15046    ///
15047    /// Other clients may first wait for sysmem to allocate, prepare to receive
15048    /// output, and then send CompleteOutputBufferPartialSettings().
15049    pub fn r#complete_output_buffer_partial_settings(
15050        &self,
15051        mut buffer_lifetime_ordinal: u64,
15052    ) -> Result<(), fidl::Error> {
15053        StreamProcessorProxyInterface::r#complete_output_buffer_partial_settings(
15054            self,
15055            buffer_lifetime_ordinal,
15056        )
15057    }
15058
15059    /// This message is optional; a client isn't required to send this ever.
15060    ///
15061    /// Terminology note: In the name of this message, "flush" means flush
15062    /// through, sometimes called "drain". This messge does not discard. To
15063    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
15064    /// without first waiting for OnOutputEndOfStream of the old stream and
15065    /// without sending FlushEndOfStreamAndCloseStream.
15066    ///
15067    /// There is currently no way to cancel the flush effect of this message
15068    /// short of the client closing the StreamProcessor channel.
15069    ///
15070    /// This message is only valid after QueueInputEndOfStream() for this
15071    /// stream. The stream_lifetime_ordinal input parameter must match the
15072    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
15073    /// will close the channel.
15074    ///
15075    /// A client can use this message to flush through (drain, not discard) the
15076    /// last input data of a stream so that the stream processor server
15077    /// generates corresponding output data for all the input data before the
15078    /// server moves on to the next stream, without forcing the client to wait
15079    /// for OnOutputEndOfStream() before queueing data of another stream.
15080    ///
15081    /// The difference between QueueInputEndOfStream() and
15082    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
15083    /// from the client that there will not be any more input data for the
15084    /// stream (and this info is needed by some stream processors for the stream
15085    /// processor to ever emit the very last output data).  The
15086    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
15087    /// later completely discarding the rest of the current stream by closing
15088    /// the current stream (with or without a stream switch).  In contrast,
15089    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
15090    /// the previously-queued input data be processed including the logical
15091    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
15092    /// before moving on to any newer stream - this essentially changes the
15093    /// close-stream handling from discard to flush-through for this stream
15094    /// only.
15095    ///
15096    /// A client using this message can start providing input data for a new
15097    /// stream without that causing discard of old stream data.  That's the
15098    /// purpose of this message - to allow a client to flush through (not
15099    /// discard) the old stream's last data (instead of the default when closing
15100    /// or switching streams which is discard).
15101    ///
15102    /// Because the old stream is not done processing yet and the old stream's
15103    /// data is not being discarded, the client must be prepared to continue to
15104    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
15105    /// is done. The client will know the stream_lifetime_ordinal is done when
15106    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
15107    /// closes.
15108    pub fn r#flush_end_of_stream_and_close_stream(
15109        &self,
15110        mut stream_lifetime_ordinal: u64,
15111    ) -> Result<(), fidl::Error> {
15112        StreamProcessorProxyInterface::r#flush_end_of_stream_and_close_stream(
15113            self,
15114            stream_lifetime_ordinal,
15115        )
15116    }
15117
15118    /// This "closes" the current stream, leaving no current stream.  In
15119    /// addition, this message can optionally release (and unregister) input
15120    /// buffers or output buffers.
15121    ///
15122    /// If there has never been any active stream, the stream_lifetime_ordinal
15123    /// must be zero or the server will close the channel.  If there has been an
15124    /// active stream, the stream_lifetime_ordinal must be the most recent
15125    /// active stream whether that stream is still active or not.  Else the
15126    /// server will close the channel.
15127    ///
15128    /// Multiple of this message without any new active stream in between is not
15129    /// to be considered an error, which allows a client to use this message to
15130    /// close the current stream to stop wasting processing power on a stream
15131    /// the user no longer cares about, then later decide that buffers should be
15132    /// released and send this message again with release_input_buffers and/or
15133    /// release_output_buffers true to get the buffers released, if the client
15134    /// is interested in trying to avoid overlap in resource usage between old
15135    /// buffers and new buffers (not all clients are).
15136    ///
15137    /// See also Sync().
15138    pub fn r#close_current_stream(
15139        &self,
15140        mut stream_lifetime_ordinal: u64,
15141        mut release_input_buffers: bool,
15142        mut release_output_buffers: bool,
15143    ) -> Result<(), fidl::Error> {
15144        StreamProcessorProxyInterface::r#close_current_stream(
15145            self,
15146            stream_lifetime_ordinal,
15147            release_input_buffers,
15148            release_output_buffers,
15149        )
15150    }
15151
15152    /// On completion, all previous StreamProcessor calls have done what they're
15153    /// going to do server-side, _except_ for processing of data queued using
15154    /// QueueInputPacket().
15155    ///
15156    /// The main purpose of this call is to enable the client to wait until
15157    /// CloseCurrentStream() with release_input_buffers and/or
15158    /// release_output_buffers set to true to take effect, before the client
15159    /// allocates new buffers and re-sets-up input and/or output buffers.  This
15160    /// de-overlapping of resource usage can be worthwhile for media buffers
15161    /// which can consume resource types whose overall pools aren't necessarily
15162    /// vast in comparison to resources consumed.  Especially if a client is
15163    /// reconfiguring buffers multiple times.
15164    ///
15165    /// Note that Sync() prior to allocating new media buffers is not alone
15166    /// sufficient to achieve non-overlap of media buffer resource usage system
15167    /// wide, but it can be a useful part of achieving that.
15168    ///
15169    /// The Sync() transits the Output ordering domain and the StreamControl
15170    /// ordering domain, but not the InputData ordering domain.
15171    ///
15172    /// This request can be used to avoid hitting kMaxInFlightStreams which is
15173    /// presently 10.  A client that stays <= 8 in-flight streams will
15174    /// comfortably stay under the limit of 10.  While the protocol permits
15175    /// repeated SetInputBufferSettings() and the like, a client that spams the
15176    /// channel can expect that the channel will just close if the server or the
15177    /// channel itself gets too far behind.
15178    pub fn r#sync(
15179        &self,
15180    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15181        StreamProcessorProxyInterface::r#sync(self)
15182    }
15183
15184    /// After the client is done with an output packet, the client needs to tell
15185    /// the stream processor that the output packet can be re-used for more
15186    /// output, using this message.
15187    ///
15188    /// It's not permitted to recycle an output packet that's already free with
15189    /// the stream processor server.
15190    ///
15191    /// If a client is using EnableOldOutputBuffers, the client must recycle all
15192    /// packets when done with them, even those of old buffer_lifetime_ordinal.
15193    /// This is also permitted behavior for all clients.
15194    ///
15195    /// If a client is not using EnableOldOutputBuffers, the client may
15196    /// optionally omit this message for packets with an old
15197    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
15198    /// or implicit output buffer de-configuration don't need to be recycled if
15199    /// the client isn't using and won't be using EnableOldOutputBuffers.
15200    pub fn r#recycle_output_packet(
15201        &self,
15202        mut available_output_packet: &PacketHeader,
15203    ) -> Result<(), fidl::Error> {
15204        StreamProcessorProxyInterface::r#recycle_output_packet(self, available_output_packet)
15205    }
15206
15207    /// If the input format details are still the same as specified during
15208    /// StreamProcessor creation, this message is unnecessary and does not need
15209    /// to be sent.
15210    ///
15211    /// If the stream doesn't exist yet, this message creates the stream.
15212    ///
15213    /// The server won't send OnOutputConstraints() until after the client has
15214    /// sent at least one QueueInput* message.
15215    ///
15216    /// All servers must permit QueueInputFormatDetails() at the start of a
15217    /// stream without failing, as long as the new format is supported by the
15218    /// StreamProcessor instance. Technically this allows for a server to only
15219    /// support the exact input format set during StreamProcessor creation, and
15220    /// that is by design. A client that tries to switch formats and gets a
15221    /// StreamProcessor channel failure should try again one more time with a
15222    /// fresh StreamProcessor instance created with CodecFactory using the new
15223    /// input format during creation, before giving up.
15224    ///
15225    /// These format details override the format details specified during stream
15226    /// processor creation for this stream only. The next stream will default
15227    /// back to the format details set during stream processor creation.
15228    ///
15229    /// This message is permitted at the start of the first stream (just like at
15230    /// the start of any stream). The format specified need not match what was
15231    /// specified during stream processor creation, but if it doesn't match, the
15232    /// StreamProcessor channel might close as described above.
15233    pub fn r#queue_input_format_details(
15234        &self,
15235        mut stream_lifetime_ordinal: u64,
15236        mut format_details: &FormatDetails,
15237    ) -> Result<(), fidl::Error> {
15238        StreamProcessorProxyInterface::r#queue_input_format_details(
15239            self,
15240            stream_lifetime_ordinal,
15241            format_details,
15242        )
15243    }
15244
15245    /// This message queues input data to the stream processor for processing.
15246    ///
15247    /// If the stream doesn't exist yet, this message creates the new stream.
15248    ///
15249    /// The server won't send OnOutputConstraints() until after the client has
15250    /// sent at least one QueueInput* message.
15251    ///
15252    /// When using dynamic buffers the server can send OnOutputConstraints,
15253    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
15254    /// the first QueueInputPacket. In the case of OnOutputPacket there must
15255    /// also be at least one output buffer that's been added but not yet fully
15256    /// removed (RemoveBuffer not yet complete).
15257    ///
15258    /// The client must continue to deliver input data via this message even if
15259    /// the stream processor has not yet generated the first
15260    /// OnOutputConstraints, and even if the StreamProcessor is generating
15261    /// OnFreeInputPacket for previously-queued input packets.  The input data
15262    /// must continue as long as there are free packets to be assured that the
15263    /// server will ever generate the first OnOutputConstraints.
15264    ///
15265    /// The server will close the channel if this packet refers to an old
15266    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
15267    /// different dimensions to a video encoder can either (a) allocate buffers
15268    /// large enough to contain the range of needed image sizes and use those to
15269    /// deliver all the input images, (b) keep their own sets of buffers used
15270    /// for different image dimensions and re-add old buffers with AddBuffer,
15271    /// moving to a new buffer_lifetime_ordinal each time image dimensions
15272    /// change, or (c) allocate new buffers each time image dimensions change.
15273    /// The (a) option is preferred, for clients that have the flexibiilty to
15274    /// store images of varying dimensions in a single set of buffers. Clients
15275    /// that require each buffer to have a single image size can use option (b)
15276    /// or (c).
15277    pub fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
15278        StreamProcessorProxyInterface::r#queue_input_packet(self, packet)
15279    }
15280
15281    /// Inform the server that all QueueInputPacket() messages for this stream
15282    /// have been sent.
15283    ///
15284    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
15285    /// or StreamProcessor channel closing), there will later be a corresponding
15286    /// OnOutputEndOfStream().
15287    ///
15288    /// The corresponding OnOutputEndOfStream() message will be generated only
15289    /// if the server finishes processing the stream before the server sees the
15290    /// client close the stream (such as by starting a new stream). A way to
15291    /// force the server to finish the stream before closing is to use
15292    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
15293    /// any new stream. Another way to force the server to finish the stream
15294    /// before closing is to wait for the OnOutputEndOfStream() before taking
15295    /// any action that closes the stream.
15296    ///
15297    /// In addition to serving as an "EndOfStream" marker to make it obvious
15298    /// client-side when all input data has been processed, if a client never
15299    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
15300    /// result in all input data getting processed through to the output. Some
15301    /// stream processors have some internally-delayed data which only gets
15302    /// drained (pushed through) by additional input data _or_ by this
15303    /// EndOfStream marker. In that sense, this message can be viewed as a drain
15304    /// at InputData domain level, but the drain only takes effect if the stream
15305    /// processor even gets that far before the stream is just closed at
15306    /// StreamControl domain level. This message is not alone sufficient to act
15307    /// as an overall drain at StreamControl level. For that, send this message
15308    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
15309    /// becomes possible to queue input data for a new stream without causing
15310    /// discard of this older stream's data). Alternately, the client can wait
15311    /// for the OnOutputEndOfStream before closing the current stream.
15312    ///
15313    /// After a client sends QueueInputEndOfStream for a stream, if the client
15314    /// then sends for the same stream any of QueueInputPacket,
15315    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
15316    /// the StreamProcessor channel.
15317    pub fn r#queue_input_end_of_stream(
15318        &self,
15319        mut stream_lifetime_ordinal: u64,
15320    ) -> Result<(), fidl::Error> {
15321        StreamProcessorProxyInterface::r#queue_input_end_of_stream(self, stream_lifetime_ordinal)
15322    }
15323
15324    /// This message results in channel closure unless supports_dynamic_buffers
15325    /// is set to true.
15326    ///
15327    /// This participates in allocation of buffers to be used with AddBuffer
15328    /// later. The client can get VMO handles for these buffers by also
15329    /// participating in the sysmem allocation, using the client's own related
15330    /// sysmem token (associated with the same logical buffer collection). It's
15331    /// up to the client to separately set any constraints needed by the client
15332    /// using the client's own related sysmem token, if any.
15333    ///
15334    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
15335    /// SetOutputBufferPartialSettings. Servers must support those messages.
15336    ///
15337    /// In handling this message, if `allow_single_buffer` is set to true, the
15338    /// server must not constrain the number of buffers allocated. The server
15339    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
15340    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
15341    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
15342    /// same value if the intent is to allocate exactly that many buffers. If
15343    /// `allow_single_buffer` is un-set or set to false, the server will
15344    /// indicate needed buffer counts to sysmem.
15345    ///
15346    /// The server's BufferCollection channel (created from the passed-in
15347    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
15348    /// particular, the server shouldn't expect the BufferCollection channel to
15349    /// remain connected to sysmem beyond the server sending SetConstraints. For
15350    /// this reason, the server may not be able to call
15351    /// WaitForAllBuffersAllocated or similar, so the server should just send
15352    /// SetConstraints, Close, then close the server's BufferCollection
15353    /// client_end. This means the server in general shouldn't attempt to get
15354    /// VMO handles for these buffers while processing this message.
15355    ///
15356    /// The server should not assume that these buffers will necessarily ever be
15357    /// added with AddBuffer to this StreamProcessor instance or any other
15358    /// StreamProcessor instance (owned by the server or not). These buffers may
15359    /// instead be dropped, or as a less-common example, possibly added to a
15360    /// different codec served by a different server implementation which also
15361    /// participated in the same sysmem buffer collection allocation.
15362    ///
15363    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
15364    /// StreamProcessor instance of the same codec (same per CodecFactory) is
15365    /// likely to work, but using the same StreamProcessor instance is
15366    /// recommended when feasible.
15367    ///
15368    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
15369    /// a different StreamProcessor instance of the same codec (same per
15370    /// CodecFactory) can't (within reason) be made work in general, especially
15371    /// for video decoders. Therefore, for output buffers, the same
15372    /// StreamProcessor instance must be used for this message and AddBuffer.
15373    /// While a client may currently be able to get away with using different
15374    /// StreamProcessor instances for this message and AddBuffer for output
15375    /// buffers for some codecs, this may break at any time without it being
15376    /// considered a server-side bug.
15377    ///
15378    /// The allocated buffers can later be added using AddBuffer (piecemeal),
15379    /// and can be removed (piecemeal) using RemoveBuffer.
15380    ///
15381    /// Multiple different ParticipateInBufferAllocation messages can have their
15382    /// buffers later added to the same StreamProcessor instance using the same
15383    /// buffer_lifetime_ordinal. This can be useful if the client wants to
15384    /// allocate buffers incrementally, or dynamically adjust the number of
15385    /// buffers, potentially while actively processing. See also the
15386    /// `buffer_lifetime_ordinal` field of this message.
15387    ///
15388    /// Server implementations may use sysmem to help verify buffer
15389    /// compatibility later when buffers are added with AddBuffer.
15390    pub fn r#participate_in_buffer_allocation(
15391        &self,
15392        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
15393    ) -> Result<(), fidl::Error> {
15394        StreamProcessorProxyInterface::r#participate_in_buffer_allocation(self, payload)
15395    }
15396
15397    /// Add buffers previously created with the help of
15398    /// ParticipateInBufferAllocation.
15399    ///
15400    /// For input buffers, the client can send QueueInputFormatDetails or
15401    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
15402    /// buffer must be added before a valid QueueInputPacket can be sent. Most
15403    /// clients will want to continue quickly adding buffers up to at least
15404    /// buffer_count_for_server_current to avoid the codec potentially stalling,
15405    /// and typically a low number of buffers beyond that to keep the pipeline
15406    /// running smoothly. Input buffers beyond the first input buffer can be
15407    /// added after the first QueueInputPacket.
15408    ///
15409    /// Even if buffer_constraints_version_ordinal is current, the server must
15410    /// not close the channel if the buffer isn't consistent with the current
15411    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
15412    /// consistent StreamProcessor constraints). Instead, the server must send a
15413    /// new OnOutputConstraints. This simplifies some edge cases for some
15414    /// clients, particularly when a client can't reliably detect whether a
15415    /// newly-obtained buffer was actually allocated after
15416    /// buffer_constraints_version_ordinal changed, or may have been cached from
15417    /// before.
15418    ///
15419    /// The client can add additional buffers to the same port and
15420    /// buffer_lifetime_ordinal at any time using this message. If the
15421    /// buffer_lifetime_ordinal is no longer the most recent, the message will
15422    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
15423    /// message re. the same buffer will complete immediately.
15424    ///
15425    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
15426    /// by the sum of buffers added by all AddBuffer calls with the same
15427    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
15428    /// required to close the channel in this case if performance degradation or
15429    /// un-tested behavior would result from adding too many buffers.
15430    ///
15431    /// Switching to a new buffer_lifetime_ordinal starts the process of
15432    /// removing buffers associated with an old buffer_lifetime_ordinal.
15433    /// However, until the remove is complete, those buffers can still be used
15434    /// by the codec as normal. See also RemoveBuffer, which can be used to
15435    /// detect when removal is complete, regardless of whether the RemoveBuffer
15436    /// started the removal (including when not using dynamic buffers).
15437    ///
15438    /// The buffer stays added until removal later completes. The buffer remains
15439    /// added across potentially multiple buffer re-uses. Removal can be
15440    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
15441    /// The codec server can unilaterally initiate buffer removal; if the server
15442    /// does this, it must send a new buffer_constraints_version_ordinal with
15443    /// action_required true. Some other client-initiated messages can also
15444    /// begin buffer removal, such as CloseCurrentStream with
15445    /// release_input_buffers and/or release_output_buffers. The buffers are
15446    /// also automatically removed and released if the client closes the
15447    /// StreamProcessor client_end or the server closes the StreamProcessor
15448    /// server_end.
15449    ///
15450    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
15451    /// SetOutputBufferPartialSettings is not allowed while there are any
15452    /// buffers still active on the port. To successfully switch modes for a
15453    /// port, most clients will want to just start over with a new
15454    /// StreamProcessor instance. This can also be done reliably by first
15455    /// ensuring that every added buffer under the port up to "now" (including
15456    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
15457    /// request. Only then is it known ok to switch modes for that port under
15458    /// the same StreamProcessor. Most clients will just use one way or the
15459    /// other to add buffers and never need to switch to the other way,
15460    /// especially within the same StreamProcessor.
15461    ///
15462    /// If a client might plausibly "spam" creation of many new
15463    /// buffer_lifetime_ordinal values without the buffers seeing any actual
15464    /// usage in between, the client should consider starting a Sync every few
15465    /// buffer_lifetime_ordinal(s) to fence cleanup of old
15466    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
15467    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
15468    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
15469    /// getting too far ahead of closing out old ones. The threshold of 16 is
15470    /// well below the enforcement threshold. Clients don't need to Sync if they
15471    /// won't be spamming new buffer_lifetime_ordinal values, or if added
15472    /// buffers will see at least some actual usage visible to the client before
15473    /// being replaced again.
15474    ///
15475    /// All buffers of the same port and buffer_lifetime_ordinal must share the
15476    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
15477    /// this in various ways. One way is to use ParticipateInBufferAllocation
15478    /// then AddBuffer for at least the first buffer, before
15479    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
15480    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
15481    /// and bump to the next odd buffer_lifetime_ordinal value for the
15482    /// AddBuffer.
15483    pub fn r#add_buffer(
15484        &self,
15485        mut payload: StreamProcessorAddBufferRequest,
15486    ) -> Result<(), fidl::Error> {
15487        StreamProcessorProxyInterface::r#add_buffer(self, payload)
15488    }
15489
15490    /// When using dynamic buffers, this call removes a buffer as soon as the
15491    /// buffer can be removed without adversely impacting any ongoing processing
15492    /// or an in-flight output packet referring to the buffer.
15493    ///
15494    /// If a client wants to remove a buffer with an in-flight output packet
15495    /// referring to the buffer, the client must RecycleOutputPacket for that
15496    /// in-flight output packet before the RemoveBuffer will complete.
15497    ///
15498    /// When using SetInputBufferPartialSettings /
15499    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
15500    /// the buffer. This call will complete when the buffer is done removing due
15501    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
15502    ///
15503    /// Until RemoveBuffer completes, the codec is still allowed to send
15504    /// OnOutputPacket messages referencing the buffer, and the codec may still
15505    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
15506    /// codec guarantees that no subsequent output packet will reference the
15507    /// buffer, and that the server holds no VMO handles to the buffer.
15508    ///
15509    /// The client may need to recycle an output packet before the RemoveBuffer
15510    /// call can complete. Clients should take care to avoid blocking packet
15511    /// recycling while the RemoveBuffer request is in progress, since this
15512    /// would create a potential deadlock.
15513    ///
15514    /// The server closing any VMO handles to the buffer prior to completing
15515    /// this call is important for the client's ability to prevent memory usage
15516    /// spikes.
15517    ///
15518    /// If the client has "paused" processing by not providing any more input,
15519    /// the client will potentially need to send CloseCurrentStream before
15520    /// RemoveBuffer will complete. When using dynamic buffers, setting
15521    /// release_input_buffers or release_output_buffers to true is not
15522    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
15523    /// specific buffer. When not using dynamic buffers, the client will need to
15524    /// set release_input_buffers or release_output_buffers to true, since
15525    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
15526    /// buffers. A current "paused" stream needs to be stopped because frames
15527    /// can be held as reference frames, and codecs are never reqiured to copy
15528    /// their output data.
15529    ///
15530    /// For any video decoder output buffers being removed while there's an
15531    /// active stream (being fed input or not), it's typically best for the
15532    /// client to assume that removal of a video decoder output buffer may take
15533    /// a very long duration. This is because bitstreams, especially
15534    /// non-standard-compliant bitstreams, but in some cases potentially even
15535    /// standard-compliant bitstreams, can keep a video decoder output buffer in
15536    /// the set of active reference frames (aka DPB) indefinitely. The server is
15537    /// not required to notice that a stream is not conforming to a bitstream
15538    /// standard in this regard.
15539    ///
15540    /// In the case of h.264 decode, a standard-complient bitstream will limit
15541    /// the reorder delay to no longer than the max DPB occupancy. However, a
15542    /// server is not required to detect or reject non-compliant streams that
15543    /// potentially keep a frame in the DPB for longer.
15544    ///
15545    /// For HEVC, the situation is similar to h.264 (IIUC).
15546    ///
15547    /// In the case of VP9, there is nothing in the bitstream spec that limits
15548    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
15549    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
15550    /// required to detect or mitigate this.
15551    ///
15552    /// Until this call completes, the server may still be using the buffer. For
15553    /// output buffers, the server can still send OnOutputPacket message(s) that
15554    /// references this buffer, but only up until the RemoveBuffer completion
15555    /// message is sent by the server. The client must continue to
15556    /// RecycleOutputPacket for packets that reference the buffer, until
15557    /// RemoveBuffer completes.
15558    ///
15559    /// When using dynamic buffers, upon receiving this message, the server will
15560    /// stop selecting the buffer for any new usage (as in, for any usage that
15561    /// moves the buffer from "free" to "not free" within the server). This
15562    /// applies even if the server has no other buffers available for use (aka
15563    /// no other "free" buffers). Any existing usage of the buffer is not ended
15564    /// early by this call alone.
15565    ///
15566    /// When not using dynamic buffers, upon receiving this message, the server
15567    /// will just remember to complete this call shortly after the buffer has
15568    /// completed removal triggered by some other cause (removal is not
15569    /// triggered/caused by this call).
15570    ///
15571    /// For video decoders, when using dynamic buffers, typically the client
15572    /// should take care to avoid removing too many output buffers for continued
15573    /// decode to be possible. If this occurs, the decoder will wait until the
15574    /// client adds another output buffer with AddBuffer. This can be a deadlock
15575    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
15576    /// frame reordering, sending a single AddBuffer doesn't necessarily
15577    /// guarantee another OnOutputPacket, since additional output buffers can be
15578    /// needed before the server can send OnOutputPacket.
15579    ///
15580    /// The client must not call RemoveBuffer on the same buffer more than once,
15581    /// whether overlapping in time or not. The server should enforce this when
15582    /// not enforcing would require tracking additional concurrent requests. The
15583    /// server is not required to enforce this when enforcing would use more
15584    /// server memory.
15585    ///
15586    /// The server is allowed to complete this request quickly with success for
15587    /// buffer_lifetime_ordinal and buffer_index combinations that were never
15588    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
15589    /// hasn't been started by the client yet (no removing potential future
15590    /// buffers).
15591    ///
15592    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
15593    /// combination may be re-used after completion of RemoveBuffer, but only if
15594    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
15595    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
15596    ///
15597    /// Assuming a valid historical buffer is specified, successful completion
15598    /// of this call means the buffer has been fully released by the server and
15599    /// won't be referenced in any subsequent OnOutputPacket.
15600    pub fn r#remove_buffer(
15601        &self,
15602        mut payload: StreamProcessorRemoveBufferRequest,
15603    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
15604        StreamProcessorProxyInterface::r#remove_buffer(self, payload)
15605    }
15606
15607    /// This informs the StreamProcessor that the client is prepared to handle
15608    /// output packets that specify a buffer with buffer_lifetime_ordinal older
15609    /// than the most recent buffer_lifetime_ordinal.
15610    ///
15611    /// If the client doesn't send this message, the StreamProcessor will omit
15612    /// any such output, even if
15613    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
15614    /// decoders such as VP9 decoders, not sending this message can result in
15615    /// output that isn't bistream spec compliant, and the output can be
15616    /// visually different than intended by the bitstream.
15617    ///
15618    /// Such streams are only possible with some bitstream formats (such as
15619    /// VP9), and are rare, but can happen and can be valid per the bitstream
15620    /// spec. For example, this can be specified by a VP9 bitstream using
15621    /// show_existing_frame to output an old-dimensions buffer after having
15622    /// already output a new-dimensions buffer.
15623    ///
15624    /// Most clients that send this message will also want to use RemoveBuffer
15625    /// to know when it becomes safe to stop tracking an old buffer.
15626    ///
15627    /// Most of the time this makes no difference as most bitstreams don't
15628    /// actually emit old buffers, even if the bitstream spec would allow it.
15629    /// Old output buffers are especially rare for RTC streams which typically
15630    /// don't have any frame reordering in the first place.
15631    ///
15632    /// In most video streaming scenarios that use dimension switching as part
15633    /// of their bitrate control strategy (among those that I've observed), at
15634    /// the StreamProcessor layer the new dimensions are part of a new stream
15635    /// instead of being spliced together as a continuation of the old stream.
15636    /// That said, using a continuation of the old stream is also a completely
15637    /// valid way to implement dimension switching. When a stream switch occurs
15638    /// as part of dimension switching, the decoder state is not retained and
15639    /// there won't be any old buffer(s) emitted after new buffer(s), since the
15640    /// new stream doesn't know anything about old buffers filled by the old
15641    /// stream.
15642    ///
15643    /// Clients which haven't tested their ability to handle old output buffers
15644    /// should not send this message. Clients decoding bitstreams like VP9 for
15645    /// decoder compliance testing purposes should send this message (and use a
15646    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
15647    /// Clients which are required to support old output frames and/or fully
15648    /// comply with a relevant bitstream spec should/must send this message, and
15649    /// should test using a test stream that outputs packets referencing an old
15650    /// output buffer.
15651    ///
15652    /// Sending this message more than once closes the channel. If sent, this
15653    /// message must be sent prior to the client establishing the first output
15654    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
15655    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
15656    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
15657    /// client when this message was not sent by the client.
15658    ///
15659    /// This message is only permitted when
15660    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
15661    /// is true.
15662    pub fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
15663        StreamProcessorProxyInterface::r#enable_old_output_buffers(self)
15664    }
15665
15666    /// This informs the StreamProcessor that the client is prepared to handle
15667    /// output packets that specify the same buffer as another packet that's
15668    /// also concurrently in flight to the client (not yet recycled).
15669    ///
15670    /// Most bitstream formats don't do this. In formats that can do this such
15671    /// as VP9, most actual bitstreams don't do this.
15672    ///
15673    /// As an example, in VP9, a stream can cause the same output buffer to be
15674    /// used by another emitted output packet/frame by using show_existing_frame
15675    /// on the same VP9 reference/held frame slot more than once without
15676    /// decoding a new frame into that slot in between.
15677    ///
15678    /// Clients that need to achieve full bitstream spec compliance for such a
15679    /// bitstream format must send this message.
15680    ///
15681    /// If this message is not in effect, the server will omit any such output,
15682    /// which can result in output that is not compliant to the relevant
15683    /// bitstream spec, and which can be visually different than the stream
15684    /// intended.
15685    ///
15686    /// Sending this message more than once closes the channel. If sent, this
15687    /// message must be sent prior to the client establishing the first output
15688    /// buffer_lifetime_ordinal.
15689    ///
15690    /// This message is only permitted when
15691    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
15692    /// is true.
15693    pub fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
15694        StreamProcessorProxyInterface::r#enable_same_output_buffer_concurrently_in_flight(self)
15695    }
15696
15697    /// For video decoders, this forces the output buffers to be reallocated if
15698    /// the image size needs to change. This is wasteful as it forces extra
15699    /// buffer reallocations given typical video bitrate control strategies
15700    /// (applicable to both streaming and RTC) involving shifting the image
15701    /// dimensions up and down repeatedly as a logical video/stream plays,
15702    /// sometimes even if network conditions remain fairly stable. This extra
15703    /// buffer reallocation cost is incurred vs. baseline whether the dimension
15704    /// switching is achieved within a single StreamProcessor stream or by using
15705    /// a new StreamProcessor stream for new dimensions.
15706    ///
15707    /// A client should not send this message unless the client really must
15708    /// force the output buffers to be reallocated every time the output image
15709    /// size changes.
15710    ///
15711    /// Sending this message more than once closes the channel. If sent, this
15712    /// message must be sent prior to any SetInputBufferPartialSettings,
15713    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
15714    /// AddBuffer.
15715    ///
15716    /// This message is only permitted if this StreamProcessor is a video
15717    /// decoder.
15718    ///
15719    /// This message is only permitted when
15720    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
15721    /// is true.
15722    pub fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
15723        StreamProcessorProxyInterface::r#enable_force_output_buffers_fixed_image_size(self)
15724    }
15725}
15726
15727impl StreamProcessorProxyInterface for StreamProcessorProxy {
15728    fn r#enable_on_stream_failed(&self) -> Result<(), fidl::Error> {
15729        self.client.send::<fidl::encoding::EmptyPayload>(
15730            (),
15731            0x3940929617dbf02b,
15732            fidl::encoding::DynamicFlags::empty(),
15733        )
15734    }
15735
15736    fn r#set_input_buffer_partial_settings(
15737        &self,
15738        mut input_settings: StreamBufferPartialSettings,
15739    ) -> Result<(), fidl::Error> {
15740        self.client.send::<StreamProcessorSetInputBufferPartialSettingsRequest>(
15741            (&mut input_settings,),
15742            0xb02e0663a40e4c4,
15743            fidl::encoding::DynamicFlags::empty(),
15744        )
15745    }
15746
15747    fn r#set_output_buffer_partial_settings(
15748        &self,
15749        mut output_settings: StreamBufferPartialSettings,
15750    ) -> Result<(), fidl::Error> {
15751        self.client.send::<StreamProcessorSetOutputBufferPartialSettingsRequest>(
15752            (&mut output_settings,),
15753            0x118bb8c819a7bbbb,
15754            fidl::encoding::DynamicFlags::empty(),
15755        )
15756    }
15757
15758    fn r#complete_output_buffer_partial_settings(
15759        &self,
15760        mut buffer_lifetime_ordinal: u64,
15761    ) -> Result<(), fidl::Error> {
15762        self.client.send::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(
15763            (buffer_lifetime_ordinal,),
15764            0x50529e5c680ae3ab,
15765            fidl::encoding::DynamicFlags::empty(),
15766        )
15767    }
15768
15769    fn r#flush_end_of_stream_and_close_stream(
15770        &self,
15771        mut stream_lifetime_ordinal: u64,
15772    ) -> Result<(), fidl::Error> {
15773        self.client.send::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(
15774            (stream_lifetime_ordinal,),
15775            0x2b62c3e26d0667e6,
15776            fidl::encoding::DynamicFlags::empty(),
15777        )
15778    }
15779
15780    fn r#close_current_stream(
15781        &self,
15782        mut stream_lifetime_ordinal: u64,
15783        mut release_input_buffers: bool,
15784        mut release_output_buffers: bool,
15785    ) -> Result<(), fidl::Error> {
15786        self.client.send::<StreamProcessorCloseCurrentStreamRequest>(
15787            (stream_lifetime_ordinal, release_input_buffers, release_output_buffers),
15788            0x1d8a67522170ca07,
15789            fidl::encoding::DynamicFlags::empty(),
15790        )
15791    }
15792
15793    type SyncResponseFut =
15794        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15795    fn r#sync(&self) -> Self::SyncResponseFut {
15796        fn _decode(
15797            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15798        ) -> Result<(), fidl::Error> {
15799            let _response = fidl::client::decode_transaction_body::<
15800                fidl::encoding::EmptyPayload,
15801                fidl::encoding::DefaultFuchsiaResourceDialect,
15802                0x4b3e44300b0ec6aa,
15803            >(_buf?)?;
15804            Ok(_response)
15805        }
15806        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
15807            (),
15808            0x4b3e44300b0ec6aa,
15809            fidl::encoding::DynamicFlags::empty(),
15810            _decode,
15811        )
15812    }
15813
15814    fn r#recycle_output_packet(
15815        &self,
15816        mut available_output_packet: &PacketHeader,
15817    ) -> Result<(), fidl::Error> {
15818        self.client.send::<StreamProcessorRecycleOutputPacketRequest>(
15819            (available_output_packet,),
15820            0x32763632b94e0bd5,
15821            fidl::encoding::DynamicFlags::empty(),
15822        )
15823    }
15824
15825    fn r#queue_input_format_details(
15826        &self,
15827        mut stream_lifetime_ordinal: u64,
15828        mut format_details: &FormatDetails,
15829    ) -> Result<(), fidl::Error> {
15830        self.client.send::<StreamProcessorQueueInputFormatDetailsRequest>(
15831            (stream_lifetime_ordinal, format_details),
15832            0x170dc0979d52231,
15833            fidl::encoding::DynamicFlags::empty(),
15834        )
15835    }
15836
15837    fn r#queue_input_packet(&self, mut packet: &Packet) -> Result<(), fidl::Error> {
15838        self.client.send::<StreamProcessorQueueInputPacketRequest>(
15839            (packet,),
15840            0x47173d2652d9df3b,
15841            fidl::encoding::DynamicFlags::empty(),
15842        )
15843    }
15844
15845    fn r#queue_input_end_of_stream(
15846        &self,
15847        mut stream_lifetime_ordinal: u64,
15848    ) -> Result<(), fidl::Error> {
15849        self.client.send::<StreamProcessorQueueInputEndOfStreamRequest>(
15850            (stream_lifetime_ordinal,),
15851            0x2051b6ad00f20b37,
15852            fidl::encoding::DynamicFlags::empty(),
15853        )
15854    }
15855
15856    fn r#participate_in_buffer_allocation(
15857        &self,
15858        mut payload: StreamProcessorParticipateInBufferAllocationRequest,
15859    ) -> Result<(), fidl::Error> {
15860        self.client.send::<StreamProcessorParticipateInBufferAllocationRequest>(
15861            &mut payload,
15862            0x122be3b0096183cb,
15863            fidl::encoding::DynamicFlags::FLEXIBLE,
15864        )
15865    }
15866
15867    fn r#add_buffer(
15868        &self,
15869        mut payload: StreamProcessorAddBufferRequest,
15870    ) -> Result<(), fidl::Error> {
15871        self.client.send::<StreamProcessorAddBufferRequest>(
15872            &mut payload,
15873            0x6eca773e923e0ada,
15874            fidl::encoding::DynamicFlags::FLEXIBLE,
15875        )
15876    }
15877
15878    type RemoveBufferResponseFut =
15879        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
15880    fn r#remove_buffer(
15881        &self,
15882        mut payload: StreamProcessorRemoveBufferRequest,
15883    ) -> Self::RemoveBufferResponseFut {
15884        fn _decode(
15885            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
15886        ) -> Result<(), fidl::Error> {
15887            let _response = fidl::client::decode_transaction_body::<
15888                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
15889                fidl::encoding::DefaultFuchsiaResourceDialect,
15890                0x40b967ffa6b2da43,
15891            >(_buf?)?
15892            .into_result::<StreamProcessorMarker>("remove_buffer")?;
15893            Ok(_response)
15894        }
15895        self.client.send_query_and_decode::<StreamProcessorRemoveBufferRequest, ()>(
15896            &mut payload,
15897            0x40b967ffa6b2da43,
15898            fidl::encoding::DynamicFlags::FLEXIBLE,
15899            _decode,
15900        )
15901    }
15902
15903    fn r#enable_old_output_buffers(&self) -> Result<(), fidl::Error> {
15904        self.client.send::<fidl::encoding::EmptyPayload>(
15905            (),
15906            0x3aedefeedf3898b0,
15907            fidl::encoding::DynamicFlags::FLEXIBLE,
15908        )
15909    }
15910
15911    fn r#enable_same_output_buffer_concurrently_in_flight(&self) -> Result<(), fidl::Error> {
15912        self.client.send::<fidl::encoding::EmptyPayload>(
15913            (),
15914            0x244e9f43b29709e7,
15915            fidl::encoding::DynamicFlags::FLEXIBLE,
15916        )
15917    }
15918
15919    fn r#enable_force_output_buffers_fixed_image_size(&self) -> Result<(), fidl::Error> {
15920        self.client.send::<fidl::encoding::EmptyPayload>(
15921            (),
15922            0x3994b040f91dc1e9,
15923            fidl::encoding::DynamicFlags::FLEXIBLE,
15924        )
15925    }
15926}
15927
15928pub struct StreamProcessorEventStream {
15929    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
15930}
15931
15932impl std::marker::Unpin for StreamProcessorEventStream {}
15933
15934impl futures::stream::FusedStream for StreamProcessorEventStream {
15935    fn is_terminated(&self) -> bool {
15936        self.event_receiver.is_terminated()
15937    }
15938}
15939
15940impl futures::Stream for StreamProcessorEventStream {
15941    type Item = Result<StreamProcessorEvent, fidl::Error>;
15942
15943    fn poll_next(
15944        mut self: std::pin::Pin<&mut Self>,
15945        cx: &mut std::task::Context<'_>,
15946    ) -> std::task::Poll<Option<Self::Item>> {
15947        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
15948            &mut self.event_receiver,
15949            cx
15950        )?) {
15951            Some(buf) => std::task::Poll::Ready(Some(StreamProcessorEvent::decode(buf))),
15952            None => std::task::Poll::Ready(None),
15953        }
15954    }
15955}
15956
15957#[derive(Debug)]
15958pub enum StreamProcessorEvent {
15959    OnStreamFailed {
15960        stream_lifetime_ordinal: u64,
15961        error: StreamError,
15962    },
15963    OnInputConstraints {
15964        input_constraints: StreamBufferConstraints,
15965    },
15966    OnOutputConstraints {
15967        output_config: StreamOutputConstraints,
15968    },
15969    OnOutputFormat {
15970        output_format: StreamOutputFormat,
15971    },
15972    OnOutputPacket {
15973        output_packet: Packet,
15974        error_detected_before: bool,
15975        error_detected_during: bool,
15976    },
15977    OnOutputEndOfStream {
15978        stream_lifetime_ordinal: u64,
15979        error_detected_before: bool,
15980    },
15981    OnFreeInputPacket {
15982        free_input_packet: PacketHeader,
15983    },
15984    OnOutputTimestampHasNoOutput {
15985        payload: StreamProcessorOnOutputTimestampHasNoOutputRequest,
15986    },
15987    #[non_exhaustive]
15988    _UnknownEvent {
15989        /// Ordinal of the event that was sent.
15990        ordinal: u64,
15991    },
15992}
15993
15994impl StreamProcessorEvent {
15995    #[allow(irrefutable_let_patterns)]
15996    pub fn into_on_stream_failed(self) -> Option<(u64, StreamError)> {
15997        if let StreamProcessorEvent::OnStreamFailed { stream_lifetime_ordinal, error } = self {
15998            Some((stream_lifetime_ordinal, error))
15999        } else {
16000            None
16001        }
16002    }
16003    #[allow(irrefutable_let_patterns)]
16004    pub fn into_on_input_constraints(self) -> Option<StreamBufferConstraints> {
16005        if let StreamProcessorEvent::OnInputConstraints { input_constraints } = self {
16006            Some((input_constraints))
16007        } else {
16008            None
16009        }
16010    }
16011    #[allow(irrefutable_let_patterns)]
16012    pub fn into_on_output_constraints(self) -> Option<StreamOutputConstraints> {
16013        if let StreamProcessorEvent::OnOutputConstraints { output_config } = self {
16014            Some((output_config))
16015        } else {
16016            None
16017        }
16018    }
16019    #[allow(irrefutable_let_patterns)]
16020    pub fn into_on_output_format(self) -> Option<StreamOutputFormat> {
16021        if let StreamProcessorEvent::OnOutputFormat { output_format } = self {
16022            Some((output_format))
16023        } else {
16024            None
16025        }
16026    }
16027    #[allow(irrefutable_let_patterns)]
16028    pub fn into_on_output_packet(self) -> Option<(Packet, bool, bool)> {
16029        if let StreamProcessorEvent::OnOutputPacket {
16030            output_packet,
16031            error_detected_before,
16032            error_detected_during,
16033        } = self
16034        {
16035            Some((output_packet, error_detected_before, error_detected_during))
16036        } else {
16037            None
16038        }
16039    }
16040    #[allow(irrefutable_let_patterns)]
16041    pub fn into_on_output_end_of_stream(self) -> Option<(u64, bool)> {
16042        if let StreamProcessorEvent::OnOutputEndOfStream {
16043            stream_lifetime_ordinal,
16044            error_detected_before,
16045        } = self
16046        {
16047            Some((stream_lifetime_ordinal, error_detected_before))
16048        } else {
16049            None
16050        }
16051    }
16052    #[allow(irrefutable_let_patterns)]
16053    pub fn into_on_free_input_packet(self) -> Option<PacketHeader> {
16054        if let StreamProcessorEvent::OnFreeInputPacket { free_input_packet } = self {
16055            Some((free_input_packet))
16056        } else {
16057            None
16058        }
16059    }
16060    #[allow(irrefutable_let_patterns)]
16061    pub fn into_on_output_timestamp_has_no_output(
16062        self,
16063    ) -> Option<StreamProcessorOnOutputTimestampHasNoOutputRequest> {
16064        if let StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload } = self {
16065            Some((payload))
16066        } else {
16067            None
16068        }
16069    }
16070
16071    /// Decodes a message buffer as a [`StreamProcessorEvent`].
16072    fn decode(
16073        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
16074    ) -> Result<StreamProcessorEvent, fidl::Error> {
16075        let (bytes, _handles) = buf.split_mut();
16076        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16077        debug_assert_eq!(tx_header.tx_id, 0);
16078        match tx_header.ordinal {
16079            0x77ccf70bb061cf8e => {
16080                let mut out = fidl::new_empty!(
16081                    StreamProcessorOnStreamFailedRequest,
16082                    fidl::encoding::DefaultFuchsiaResourceDialect
16083                );
16084                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnStreamFailedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16085                Ok((StreamProcessorEvent::OnStreamFailed {
16086                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
16087                    error: out.error,
16088                }))
16089            }
16090            0x211da9966a8ca0 => {
16091                let mut out = fidl::new_empty!(
16092                    StreamProcessorOnInputConstraintsRequest,
16093                    fidl::encoding::DefaultFuchsiaResourceDialect
16094                );
16095                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnInputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16096                Ok((StreamProcessorEvent::OnInputConstraints {
16097                    input_constraints: out.input_constraints,
16098                }))
16099            }
16100            0x40d8234504c170f3 => {
16101                let mut out = fidl::new_empty!(
16102                    StreamProcessorOnOutputConstraintsRequest,
16103                    fidl::encoding::DefaultFuchsiaResourceDialect
16104                );
16105                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputConstraintsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16106                Ok((StreamProcessorEvent::OnOutputConstraints { output_config: out.output_config }))
16107            }
16108            0x131b77ae120360bc => {
16109                let mut out = fidl::new_empty!(
16110                    StreamProcessorOnOutputFormatRequest,
16111                    fidl::encoding::DefaultFuchsiaResourceDialect
16112                );
16113                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputFormatRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16114                Ok((StreamProcessorEvent::OnOutputFormat { output_format: out.output_format }))
16115            }
16116            0x5c2029be1090ce93 => {
16117                let mut out = fidl::new_empty!(
16118                    StreamProcessorOnOutputPacketRequest,
16119                    fidl::encoding::DefaultFuchsiaResourceDialect
16120                );
16121                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16122                Ok((StreamProcessorEvent::OnOutputPacket {
16123                    output_packet: out.output_packet,
16124                    error_detected_before: out.error_detected_before,
16125                    error_detected_during: out.error_detected_during,
16126                }))
16127            }
16128            0x3bb65d237cfa50e6 => {
16129                let mut out = fidl::new_empty!(
16130                    StreamProcessorOnOutputEndOfStreamRequest,
16131                    fidl::encoding::DefaultFuchsiaResourceDialect
16132                );
16133                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputEndOfStreamRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16134                Ok((StreamProcessorEvent::OnOutputEndOfStream {
16135                    stream_lifetime_ordinal: out.stream_lifetime_ordinal,
16136                    error_detected_before: out.error_detected_before,
16137                }))
16138            }
16139            0xeef799b28708bbd => {
16140                let mut out = fidl::new_empty!(
16141                    StreamProcessorOnFreeInputPacketRequest,
16142                    fidl::encoding::DefaultFuchsiaResourceDialect
16143                );
16144                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnFreeInputPacketRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16145                Ok((StreamProcessorEvent::OnFreeInputPacket {
16146                    free_input_packet: out.free_input_packet,
16147                }))
16148            }
16149            0x7436457799a25cd4 => {
16150                let mut out = fidl::new_empty!(
16151                    StreamProcessorOnOutputTimestampHasNoOutputRequest,
16152                    fidl::encoding::DefaultFuchsiaResourceDialect
16153                );
16154                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
16155                Ok((StreamProcessorEvent::OnOutputTimestampHasNoOutput { payload: out }))
16156            }
16157            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
16158                Ok(StreamProcessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
16159            }
16160            _ => Err(fidl::Error::UnknownOrdinal {
16161                ordinal: tx_header.ordinal,
16162                protocol_name:
16163                    <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16164            }),
16165        }
16166    }
16167}
16168
16169/// A Stream of incoming requests for fuchsia.media/StreamProcessor.
16170pub struct StreamProcessorRequestStream {
16171    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16172    is_terminated: bool,
16173}
16174
16175impl std::marker::Unpin for StreamProcessorRequestStream {}
16176
16177impl futures::stream::FusedStream for StreamProcessorRequestStream {
16178    fn is_terminated(&self) -> bool {
16179        self.is_terminated
16180    }
16181}
16182
16183impl fidl::endpoints::RequestStream for StreamProcessorRequestStream {
16184    type Protocol = StreamProcessorMarker;
16185    type ControlHandle = StreamProcessorControlHandle;
16186
16187    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
16188        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
16189    }
16190
16191    fn control_handle(&self) -> Self::ControlHandle {
16192        StreamProcessorControlHandle { inner: self.inner.clone() }
16193    }
16194
16195    fn into_inner(
16196        self,
16197    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
16198    {
16199        (self.inner, self.is_terminated)
16200    }
16201
16202    fn from_inner(
16203        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
16204        is_terminated: bool,
16205    ) -> Self {
16206        Self { inner, is_terminated }
16207    }
16208}
16209
16210impl futures::Stream for StreamProcessorRequestStream {
16211    type Item = Result<StreamProcessorRequest, fidl::Error>;
16212
16213    fn poll_next(
16214        mut self: std::pin::Pin<&mut Self>,
16215        cx: &mut std::task::Context<'_>,
16216    ) -> std::task::Poll<Option<Self::Item>> {
16217        let this = &mut *self;
16218        if this.inner.check_shutdown(cx) {
16219            this.is_terminated = true;
16220            return std::task::Poll::Ready(None);
16221        }
16222        if this.is_terminated {
16223            panic!("polled StreamProcessorRequestStream after completion");
16224        }
16225        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
16226            |bytes, handles| {
16227                match this.inner.channel().read_etc(cx, bytes, handles) {
16228                    std::task::Poll::Ready(Ok(())) => {}
16229                    std::task::Poll::Pending => return std::task::Poll::Pending,
16230                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
16231                        this.is_terminated = true;
16232                        return std::task::Poll::Ready(None);
16233                    }
16234                    std::task::Poll::Ready(Err(e)) => {
16235                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
16236                            e.into(),
16237                        ))));
16238                    }
16239                }
16240
16241                // A message has been received from the channel
16242                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
16243
16244                std::task::Poll::Ready(Some(match header.ordinal {
16245                    0x3940929617dbf02b => {
16246                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16247                        let mut req = fidl::new_empty!(
16248                            fidl::encoding::EmptyPayload,
16249                            fidl::encoding::DefaultFuchsiaResourceDialect
16250                        );
16251                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16252                        let control_handle =
16253                            StreamProcessorControlHandle { inner: this.inner.clone() };
16254                        Ok(StreamProcessorRequest::EnableOnStreamFailed { control_handle })
16255                    }
16256                    0xb02e0663a40e4c4 => {
16257                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16258                        let mut req = fidl::new_empty!(
16259                            StreamProcessorSetInputBufferPartialSettingsRequest,
16260                            fidl::encoding::DefaultFuchsiaResourceDialect
16261                        );
16262                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetInputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
16263                        let control_handle =
16264                            StreamProcessorControlHandle { inner: this.inner.clone() };
16265                        Ok(StreamProcessorRequest::SetInputBufferPartialSettings {
16266                            input_settings: req.input_settings,
16267
16268                            control_handle,
16269                        })
16270                    }
16271                    0x118bb8c819a7bbbb => {
16272                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16273                        let mut req = fidl::new_empty!(
16274                            StreamProcessorSetOutputBufferPartialSettingsRequest,
16275                            fidl::encoding::DefaultFuchsiaResourceDialect
16276                        );
16277                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorSetOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
16278                        let control_handle =
16279                            StreamProcessorControlHandle { inner: this.inner.clone() };
16280                        Ok(StreamProcessorRequest::SetOutputBufferPartialSettings {
16281                            output_settings: req.output_settings,
16282
16283                            control_handle,
16284                        })
16285                    }
16286                    0x50529e5c680ae3ab => {
16287                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16288                        let mut req = fidl::new_empty!(
16289                            StreamProcessorCompleteOutputBufferPartialSettingsRequest,
16290                            fidl::encoding::DefaultFuchsiaResourceDialect
16291                        );
16292                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCompleteOutputBufferPartialSettingsRequest>(&header, _body_bytes, handles, &mut req)?;
16293                        let control_handle =
16294                            StreamProcessorControlHandle { inner: this.inner.clone() };
16295                        Ok(StreamProcessorRequest::CompleteOutputBufferPartialSettings {
16296                            buffer_lifetime_ordinal: req.buffer_lifetime_ordinal,
16297
16298                            control_handle,
16299                        })
16300                    }
16301                    0x2b62c3e26d0667e6 => {
16302                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16303                        let mut req = fidl::new_empty!(
16304                            StreamProcessorFlushEndOfStreamAndCloseStreamRequest,
16305                            fidl::encoding::DefaultFuchsiaResourceDialect
16306                        );
16307                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorFlushEndOfStreamAndCloseStreamRequest>(&header, _body_bytes, handles, &mut req)?;
16308                        let control_handle =
16309                            StreamProcessorControlHandle { inner: this.inner.clone() };
16310                        Ok(StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
16311                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16312
16313                            control_handle,
16314                        })
16315                    }
16316                    0x1d8a67522170ca07 => {
16317                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16318                        let mut req = fidl::new_empty!(
16319                            StreamProcessorCloseCurrentStreamRequest,
16320                            fidl::encoding::DefaultFuchsiaResourceDialect
16321                        );
16322                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorCloseCurrentStreamRequest>(&header, _body_bytes, handles, &mut req)?;
16323                        let control_handle =
16324                            StreamProcessorControlHandle { inner: this.inner.clone() };
16325                        Ok(StreamProcessorRequest::CloseCurrentStream {
16326                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16327                            release_input_buffers: req.release_input_buffers,
16328                            release_output_buffers: req.release_output_buffers,
16329
16330                            control_handle,
16331                        })
16332                    }
16333                    0x4b3e44300b0ec6aa => {
16334                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16335                        let mut req = fidl::new_empty!(
16336                            fidl::encoding::EmptyPayload,
16337                            fidl::encoding::DefaultFuchsiaResourceDialect
16338                        );
16339                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16340                        let control_handle =
16341                            StreamProcessorControlHandle { inner: this.inner.clone() };
16342                        Ok(StreamProcessorRequest::Sync {
16343                            responder: StreamProcessorSyncResponder {
16344                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16345                                tx_id: header.tx_id,
16346                            },
16347                        })
16348                    }
16349                    0x32763632b94e0bd5 => {
16350                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16351                        let mut req = fidl::new_empty!(
16352                            StreamProcessorRecycleOutputPacketRequest,
16353                            fidl::encoding::DefaultFuchsiaResourceDialect
16354                        );
16355                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRecycleOutputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16356                        let control_handle =
16357                            StreamProcessorControlHandle { inner: this.inner.clone() };
16358                        Ok(StreamProcessorRequest::RecycleOutputPacket {
16359                            available_output_packet: req.available_output_packet,
16360
16361                            control_handle,
16362                        })
16363                    }
16364                    0x170dc0979d52231 => {
16365                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16366                        let mut req = fidl::new_empty!(
16367                            StreamProcessorQueueInputFormatDetailsRequest,
16368                            fidl::encoding::DefaultFuchsiaResourceDialect
16369                        );
16370                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputFormatDetailsRequest>(&header, _body_bytes, handles, &mut req)?;
16371                        let control_handle =
16372                            StreamProcessorControlHandle { inner: this.inner.clone() };
16373                        Ok(StreamProcessorRequest::QueueInputFormatDetails {
16374                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16375                            format_details: req.format_details,
16376
16377                            control_handle,
16378                        })
16379                    }
16380                    0x47173d2652d9df3b => {
16381                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16382                        let mut req = fidl::new_empty!(
16383                            StreamProcessorQueueInputPacketRequest,
16384                            fidl::encoding::DefaultFuchsiaResourceDialect
16385                        );
16386                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputPacketRequest>(&header, _body_bytes, handles, &mut req)?;
16387                        let control_handle =
16388                            StreamProcessorControlHandle { inner: this.inner.clone() };
16389                        Ok(StreamProcessorRequest::QueueInputPacket {
16390                            packet: req.packet,
16391
16392                            control_handle,
16393                        })
16394                    }
16395                    0x2051b6ad00f20b37 => {
16396                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16397                        let mut req = fidl::new_empty!(
16398                            StreamProcessorQueueInputEndOfStreamRequest,
16399                            fidl::encoding::DefaultFuchsiaResourceDialect
16400                        );
16401                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorQueueInputEndOfStreamRequest>(&header, _body_bytes, handles, &mut req)?;
16402                        let control_handle =
16403                            StreamProcessorControlHandle { inner: this.inner.clone() };
16404                        Ok(StreamProcessorRequest::QueueInputEndOfStream {
16405                            stream_lifetime_ordinal: req.stream_lifetime_ordinal,
16406
16407                            control_handle,
16408                        })
16409                    }
16410                    0x122be3b0096183cb => {
16411                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16412                        let mut req = fidl::new_empty!(
16413                            StreamProcessorParticipateInBufferAllocationRequest,
16414                            fidl::encoding::DefaultFuchsiaResourceDialect
16415                        );
16416                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorParticipateInBufferAllocationRequest>(&header, _body_bytes, handles, &mut req)?;
16417                        let control_handle =
16418                            StreamProcessorControlHandle { inner: this.inner.clone() };
16419                        Ok(StreamProcessorRequest::ParticipateInBufferAllocation {
16420                            payload: req,
16421                            control_handle,
16422                        })
16423                    }
16424                    0x6eca773e923e0ada => {
16425                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16426                        let mut req = fidl::new_empty!(
16427                            StreamProcessorAddBufferRequest,
16428                            fidl::encoding::DefaultFuchsiaResourceDialect
16429                        );
16430                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorAddBufferRequest>(&header, _body_bytes, handles, &mut req)?;
16431                        let control_handle =
16432                            StreamProcessorControlHandle { inner: this.inner.clone() };
16433                        Ok(StreamProcessorRequest::AddBuffer { payload: req, control_handle })
16434                    }
16435                    0x40b967ffa6b2da43 => {
16436                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
16437                        let mut req = fidl::new_empty!(
16438                            StreamProcessorRemoveBufferRequest,
16439                            fidl::encoding::DefaultFuchsiaResourceDialect
16440                        );
16441                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamProcessorRemoveBufferRequest>(&header, _body_bytes, handles, &mut req)?;
16442                        let control_handle =
16443                            StreamProcessorControlHandle { inner: this.inner.clone() };
16444                        Ok(StreamProcessorRequest::RemoveBuffer {
16445                            payload: req,
16446                            responder: StreamProcessorRemoveBufferResponder {
16447                                control_handle: std::mem::ManuallyDrop::new(control_handle),
16448                                tx_id: header.tx_id,
16449                            },
16450                        })
16451                    }
16452                    0x3aedefeedf3898b0 => {
16453                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16454                        let mut req = fidl::new_empty!(
16455                            fidl::encoding::EmptyPayload,
16456                            fidl::encoding::DefaultFuchsiaResourceDialect
16457                        );
16458                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16459                        let control_handle =
16460                            StreamProcessorControlHandle { inner: this.inner.clone() };
16461                        Ok(StreamProcessorRequest::EnableOldOutputBuffers { control_handle })
16462                    }
16463                    0x244e9f43b29709e7 => {
16464                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16465                        let mut req = fidl::new_empty!(
16466                            fidl::encoding::EmptyPayload,
16467                            fidl::encoding::DefaultFuchsiaResourceDialect
16468                        );
16469                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16470                        let control_handle =
16471                            StreamProcessorControlHandle { inner: this.inner.clone() };
16472                        Ok(StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
16473                            control_handle,
16474                        })
16475                    }
16476                    0x3994b040f91dc1e9 => {
16477                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
16478                        let mut req = fidl::new_empty!(
16479                            fidl::encoding::EmptyPayload,
16480                            fidl::encoding::DefaultFuchsiaResourceDialect
16481                        );
16482                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
16483                        let control_handle =
16484                            StreamProcessorControlHandle { inner: this.inner.clone() };
16485                        Ok(StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize {
16486                            control_handle,
16487                        })
16488                    }
16489                    _ if header.tx_id == 0
16490                        && header
16491                            .dynamic_flags()
16492                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
16493                    {
16494                        Ok(StreamProcessorRequest::_UnknownMethod {
16495                            ordinal: header.ordinal,
16496                            control_handle: StreamProcessorControlHandle {
16497                                inner: this.inner.clone(),
16498                            },
16499                            method_type: fidl::MethodType::OneWay,
16500                        })
16501                    }
16502                    _ if header
16503                        .dynamic_flags()
16504                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
16505                    {
16506                        this.inner.send_framework_err(
16507                            fidl::encoding::FrameworkErr::UnknownMethod,
16508                            header.tx_id,
16509                            header.ordinal,
16510                            header.dynamic_flags(),
16511                            (bytes, handles),
16512                        )?;
16513                        Ok(StreamProcessorRequest::_UnknownMethod {
16514                            ordinal: header.ordinal,
16515                            control_handle: StreamProcessorControlHandle {
16516                                inner: this.inner.clone(),
16517                            },
16518                            method_type: fidl::MethodType::TwoWay,
16519                        })
16520                    }
16521                    _ => Err(fidl::Error::UnknownOrdinal {
16522                        ordinal: header.ordinal,
16523                        protocol_name:
16524                            <StreamProcessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
16525                    }),
16526                }))
16527            },
16528        )
16529    }
16530}
16531
16532/// Overview of operation:
16533///
16534/// 1. Create
16535///   * create via CodecFactory - see CodecFactory
16536///   * create via LicenseSession - see LicenseSession
16537/// 2. Get input constraints
16538///   * OnInputConstraints() - sent unsolicited by stream processor shortly
16539///     after stream processor creation.
16540/// 3. Provide input buffers ()
16541///   * SetInputBufferPartialSettings()
16542///   * or AddBuffer, if StreamProcessor reported support for dynamic buffers
16543///     via CodecFactory - in this case, QueueInputFormatDetails and
16544///     QueueInputEndOfStream do not require a prior AddBuffer, but
16545///     QueueInputPacket still does.
16546/// 4. Deliver input data
16547///   * QueueInputPacket() + OnFreeInputPacket(), for as long as it takes,
16548///     possibly working through all input packets repeatedly before...
16549/// 5. Get output constraints and format
16550///   * OnOutputConstraints()
16551///   * This is not sent until after at least one QueueInput* message is sent by
16552///     the client, even if the underlying processor behind the StreamProcessor
16553///     doesn't fundamentally need any input data to determine its output
16554///     constraints.  This server behavior prevents clients taking an incorrect
16555///     dependency on the output constraints showing up before input is
16556///     delivered.
16557///   * A client must tolerate this arriving as late as after substantial input
16558///     data has been delivered, including lots of input packet recycling via
16559///     OnFreeInputPacket().
16560///   * This message can arrive more than once before the first output data.
16561/// 6. Provide output buffers
16562///   * SetOutputBufferPartialSettings() / CompleteOutputBufferPartialSettings()
16563/// 7. Data flows, with optional EndOfStream
16564///   * OnOutputPacket() / RecycleOutputPacket() / QueueInputPacket() /
16565///     OnFreeInputPacket() / QueueInputEndOfStream() / OnOutputEndOfStream()
16566///
16567/// Semi-trusted StreamProcessor server - SW decoders run in an isolate (with
16568/// very few capabilities) just in case the decoding SW has a vulnerability
16569/// which could be used to take over the StreamProcessor server.  Clients of the
16570/// stream processor interface using decoders and processing streams of separate
16571/// security contexts, to a greater extent than some other interfaces, need to
16572/// protect themselves against invalid server behavior, such as double-free of a
16573/// packet_index and any other invalid server behavior.  Having fed in
16574/// compressed data of one security context, don't place too much trust in a
16575/// single StreamProcessor instance to not mix data among any buffers that
16576/// StreamProcessor server has ever been told about.  Instead, create separate
16577/// StreamProcessor instances for use by security-separate client-side contexts.
16578/// While the picture for HW-based decoders looks somewhat different and is out
16579/// of scope of this paragraph, the client should always use separate
16580/// StreamProcessor instances for security-separate client-side contexts.
16581///
16582/// Descriptions of actions taken by methods of this protocol and the states of
16583/// things are given as if the methods are synchronously executed by the stream
16584/// processor server, but in reality, as is typical of FIDL interfaces, the
16585/// message processing is async.  The states described are to be read as the
16586/// state from the client's point of view unless otherwise stated.  Events
16587/// coming back from the server are of course delivered async, and a client that
16588/// processes more than one stream per StreamProcessor instance needs to care
16589/// whether a given event is from the current stream vs. some older
16590/// soon-to-be-gone stream.
16591///
16592/// The Sync() method's main purpose is to enable the client to robustly prevent
16593/// having both old and new buffers allocated in the system at the same time,
16594/// since media buffers can be significantly large, depending. The Sync() method
16595/// achieves this by only delivering it's response when all previous calls to
16596/// the StreamProcessor protocol have actually taken effect in the
16597/// StreamControl ordering domain. Sync() can also be used to wait for the
16598/// stream processor server to catch up if there's a possibility that a client
16599/// might otherwise get too far ahead of the StreamProcessor server, by for
16600/// example requesting creation of a large number of streams in a row.  It can
16601/// also be used during debugging to ensure that a stream processor server
16602/// hasn't gotten stuck.  Calling Sync() is entirely optional and never required
16603/// for correctness - only potentially required to de-overlap resource usage.
16604///
16605/// It's possible to re-use a StreamProcessor instance for another stream, and
16606/// doing so can sometimes skip over re-allocation of buffers. This can be a
16607/// useful thing to do for cases like seeking to a new location - at the
16608/// StreamProcessor interface that can look like switching to a new stream.
16609#[derive(Debug)]
16610pub enum StreamProcessorRequest {
16611    /// Permit the server to use OnStreamFailed() instead of the server just
16612    /// closing the whole StreamProcessor channel on stream failure.
16613    ///
16614    /// If the server hasn't seen this message by the time a stream fails, the
16615    /// server will close the StreamProcessor channel instead of sending
16616    /// OnStreamFailed().
16617    EnableOnStreamFailed { control_handle: StreamProcessorControlHandle },
16618    /// When the client is not using dynamic buffers, a single
16619    /// SetInputBufferPartialSettings() provides the StreamProcessor with the
16620    /// client-specified input settings and a BufferCollectionToken which the
16621    /// StreamProcessor will use to convey constraints to sysmem.  Both the
16622    /// client and the StreamProcessor will be informed of the allocated buffers
16623    /// directly by sysmem via their BufferCollection channel (not via the
16624    /// StreamProcessor channel).
16625    ///
16626    /// The client must not QueueInput...() until after sysmem informs the
16627    /// client that buffer allocation has completed and was successful.
16628    ///
16629    /// The server should be prepared to see QueueInput...() before the server
16630    /// has necessarily heard from sysmem that the buffers are allocated - the
16631    /// server must tolerate either ordering, as the QueueInput...() and
16632    /// notification of sysmem allocation completion arrive on different
16633    /// channels, so the client having heard that allocation is complete doesn't
16634    /// mean the server knows that allocation is complete yet.  However, the
16635    /// server can expect that allocation is in fact complete and can expect to
16636    /// get the allocation information from sysmem immediately upon requesting
16637    /// the information from sysmem.
16638    ///
16639    /// Mixing of AddBuffer and SetInputBufferPartialSettings is not allowed
16640    /// while there are any buffers still active on the port. To successfully
16641    /// switch modes for a port, most clients will want to just start over with
16642    /// a new StreamProcessor instance. This can also be done reliably by first
16643    /// ensuring that every added buffer under the port up to "now" (including
16644    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
16645    /// request. Only then is it known ok to switch modes for that port under
16646    /// the same StreamProcessor. Most clients will just use one way or the
16647    /// other to add buffers and never need to switch to the other way,
16648    /// especially within the same StreamProcessor.
16649    SetInputBufferPartialSettings {
16650        input_settings: StreamBufferPartialSettings,
16651        control_handle: StreamProcessorControlHandle,
16652    },
16653    /// This is the replacement for SetOutputBufferSettings().
16654    ///
16655    /// When the client is using sysmem to allocate buffers, this message is
16656    /// used instead of SetOutputBufferSettings()+AddOutputBuffer(). Instead, a
16657    /// single SetOutputBufferPartialSettings() provides the StreamProcessor
16658    /// with the client-specified output settings and a BufferCollectionToken
16659    /// which the StreamProcessor will use to convey constraints to sysmem. Both
16660    /// the client and the StreamProcessor will be informed of the allocated
16661    /// buffers directly by sysmem via their BufferCollection channel (not via
16662    /// the StreamProcessor channel).
16663    ///
16664    /// Configuring output buffers is _required_ after OnOutputConstraints() is
16665    /// received by the client with buffer_constraints_action_required true and
16666    /// stream_lifetime_ordinal equal to the client's current
16667    /// stream_lifetime_ordinal (even if there is an active stream), and is
16668    /// _permitted_ any time there is no current stream.
16669    ///
16670    /// Closing the current stream occurs on the StreamControl ordering domain,
16671    /// so after a CloseCurrentStream() or FlushEndOfStreamAndCloseStream(), a
16672    /// subsequent Sync() completion must be received by the client before the
16673    /// client knows that there's no longer a current stream.
16674    ///
16675    /// Mixing of AddBuffer and SetOutputBufferPartialSettings is not allowed
16676    /// while there are any buffers still active on the port. To successfully
16677    /// switch modes for a port, most clients will want to just start over with
16678    /// a new StreamProcessor instance. This can also be done reliably by first
16679    /// ensuring that every added buffer under the port up to "now" (including
16680    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
16681    /// request. Only then is it known ok to switch modes for that port under
16682    /// the same StreamProcessor. Most clients will just use one way or the
16683    /// other to add buffers and never need to switch to the other way,
16684    /// especially not within the same StreamProcessor instance.
16685    ///
16686    /// See also CompleteOutputBufferPartialSettings().
16687    SetOutputBufferPartialSettings {
16688        output_settings: StreamBufferPartialSettings,
16689        control_handle: StreamProcessorControlHandle,
16690    },
16691    /// After SetOutputBufferPartialSettings(), the server won't send
16692    /// OnOutputConstraints(), OnOutputFormat(), OnOutputPacket(), or
16693    /// OnOutputEndOfStream() until after the client sends
16694    /// CompleteOutputBufferPartialSettings().
16695    ///
16696    /// This message isn't permitted after AddBuffer. When using dynamic buffers
16697    /// the server can send OnOutputConstraints, OnOutputFormat, OnOutputPacket,
16698    /// or OnOutputEndOfStream at any time after the first QueueInputPacket. In
16699    /// the case of OnOutputPacket there must also be at least one output buffer
16700    /// that's been added but not yet fully removed (RemoveBuffer not yet
16701    /// complete).
16702    ///
16703    /// Some clients may be able to send CompleteOutputBufferPartialSettings()
16704    /// immediately after SetOutputBufferPartialSettings() - in that case the
16705    /// client needs to be prepared to receive output without knowing the buffer
16706    /// count or packet count yet - such clients may internally delay processing
16707    /// the received output until the client has heard from sysmem (which is
16708    /// when the client will learn the buffer count and packet count).
16709    ///
16710    /// Other clients may first wait for sysmem to allocate, prepare to receive
16711    /// output, and then send CompleteOutputBufferPartialSettings().
16712    CompleteOutputBufferPartialSettings {
16713        buffer_lifetime_ordinal: u64,
16714        control_handle: StreamProcessorControlHandle,
16715    },
16716    /// This message is optional; a client isn't required to send this ever.
16717    ///
16718    /// Terminology note: In the name of this message, "flush" means flush
16719    /// through, sometimes called "drain". This messge does not discard. To
16720    /// discard, just QueueInputPacket with a new stream_lifetime_ordinal
16721    /// without first waiting for OnOutputEndOfStream of the old stream and
16722    /// without sending FlushEndOfStreamAndCloseStream.
16723    ///
16724    /// There is currently no way to cancel the flush effect of this message
16725    /// short of the client closing the StreamProcessor channel.
16726    ///
16727    /// This message is only valid after QueueInputEndOfStream() for this
16728    /// stream. The stream_lifetime_ordinal input parameter must match the
16729    /// stream_lifetime_ordinal of the QueueInputEndOfStream(), else the server
16730    /// will close the channel.
16731    ///
16732    /// A client can use this message to flush through (drain, not discard) the
16733    /// last input data of a stream so that the stream processor server
16734    /// generates corresponding output data for all the input data before the
16735    /// server moves on to the next stream, without forcing the client to wait
16736    /// for OnOutputEndOfStream() before queueing data of another stream.
16737    ///
16738    /// The difference between QueueInputEndOfStream() and
16739    /// FlushEndOfStreamAndCloseStream():  QueueInputEndOfStream() is a promise
16740    /// from the client that there will not be any more input data for the
16741    /// stream (and this info is needed by some stream processors for the stream
16742    /// processor to ever emit the very last output data).  The
16743    /// QueueInputEndOfStream() having been sent doesn't prevent the client from
16744    /// later completely discarding the rest of the current stream by closing
16745    /// the current stream (with or without a stream switch).  In contrast,
16746    /// FlushEndOfStreamAndCloseStream() is a request from the client that all
16747    /// the previously-queued input data be processed including the logical
16748    /// "EndOfStream" showing up as OnOutputEndOfStream() (in success case)
16749    /// before moving on to any newer stream - this essentially changes the
16750    /// close-stream handling from discard to flush-through for this stream
16751    /// only.
16752    ///
16753    /// A client using this message can start providing input data for a new
16754    /// stream without that causing discard of old stream data.  That's the
16755    /// purpose of this message - to allow a client to flush through (not
16756    /// discard) the old stream's last data (instead of the default when closing
16757    /// or switching streams which is discard).
16758    ///
16759    /// Because the old stream is not done processing yet and the old stream's
16760    /// data is not being discarded, the client must be prepared to continue to
16761    /// process OnOutputConstraints() messages until the stream_lifetime_ordinal
16762    /// is done. The client will know the stream_lifetime_ordinal is done when
16763    /// OnOutputEndOfStream(), OnStreamFailed(), or the StreamProcessor channel
16764    /// closes.
16765    FlushEndOfStreamAndCloseStream {
16766        stream_lifetime_ordinal: u64,
16767        control_handle: StreamProcessorControlHandle,
16768    },
16769    /// This "closes" the current stream, leaving no current stream.  In
16770    /// addition, this message can optionally release (and unregister) input
16771    /// buffers or output buffers.
16772    ///
16773    /// If there has never been any active stream, the stream_lifetime_ordinal
16774    /// must be zero or the server will close the channel.  If there has been an
16775    /// active stream, the stream_lifetime_ordinal must be the most recent
16776    /// active stream whether that stream is still active or not.  Else the
16777    /// server will close the channel.
16778    ///
16779    /// Multiple of this message without any new active stream in between is not
16780    /// to be considered an error, which allows a client to use this message to
16781    /// close the current stream to stop wasting processing power on a stream
16782    /// the user no longer cares about, then later decide that buffers should be
16783    /// released and send this message again with release_input_buffers and/or
16784    /// release_output_buffers true to get the buffers released, if the client
16785    /// is interested in trying to avoid overlap in resource usage between old
16786    /// buffers and new buffers (not all clients are).
16787    ///
16788    /// See also Sync().
16789    CloseCurrentStream {
16790        stream_lifetime_ordinal: u64,
16791        release_input_buffers: bool,
16792        release_output_buffers: bool,
16793        control_handle: StreamProcessorControlHandle,
16794    },
16795    /// On completion, all previous StreamProcessor calls have done what they're
16796    /// going to do server-side, _except_ for processing of data queued using
16797    /// QueueInputPacket().
16798    ///
16799    /// The main purpose of this call is to enable the client to wait until
16800    /// CloseCurrentStream() with release_input_buffers and/or
16801    /// release_output_buffers set to true to take effect, before the client
16802    /// allocates new buffers and re-sets-up input and/or output buffers.  This
16803    /// de-overlapping of resource usage can be worthwhile for media buffers
16804    /// which can consume resource types whose overall pools aren't necessarily
16805    /// vast in comparison to resources consumed.  Especially if a client is
16806    /// reconfiguring buffers multiple times.
16807    ///
16808    /// Note that Sync() prior to allocating new media buffers is not alone
16809    /// sufficient to achieve non-overlap of media buffer resource usage system
16810    /// wide, but it can be a useful part of achieving that.
16811    ///
16812    /// The Sync() transits the Output ordering domain and the StreamControl
16813    /// ordering domain, but not the InputData ordering domain.
16814    ///
16815    /// This request can be used to avoid hitting kMaxInFlightStreams which is
16816    /// presently 10.  A client that stays <= 8 in-flight streams will
16817    /// comfortably stay under the limit of 10.  While the protocol permits
16818    /// repeated SetInputBufferSettings() and the like, a client that spams the
16819    /// channel can expect that the channel will just close if the server or the
16820    /// channel itself gets too far behind.
16821    Sync { responder: StreamProcessorSyncResponder },
16822    /// After the client is done with an output packet, the client needs to tell
16823    /// the stream processor that the output packet can be re-used for more
16824    /// output, using this message.
16825    ///
16826    /// It's not permitted to recycle an output packet that's already free with
16827    /// the stream processor server.
16828    ///
16829    /// If a client is using EnableOldOutputBuffers, the client must recycle all
16830    /// packets when done with them, even those of old buffer_lifetime_ordinal.
16831    /// This is also permitted behavior for all clients.
16832    ///
16833    /// If a client is not using EnableOldOutputBuffers, the client may
16834    /// optionally omit this message for packets with an old
16835    /// buffer_lifetime_ordinal. In other words, packets from before an explicit
16836    /// or implicit output buffer de-configuration don't need to be recycled if
16837    /// the client isn't using and won't be using EnableOldOutputBuffers.
16838    RecycleOutputPacket {
16839        available_output_packet: PacketHeader,
16840        control_handle: StreamProcessorControlHandle,
16841    },
16842    /// If the input format details are still the same as specified during
16843    /// StreamProcessor creation, this message is unnecessary and does not need
16844    /// to be sent.
16845    ///
16846    /// If the stream doesn't exist yet, this message creates the stream.
16847    ///
16848    /// The server won't send OnOutputConstraints() until after the client has
16849    /// sent at least one QueueInput* message.
16850    ///
16851    /// All servers must permit QueueInputFormatDetails() at the start of a
16852    /// stream without failing, as long as the new format is supported by the
16853    /// StreamProcessor instance. Technically this allows for a server to only
16854    /// support the exact input format set during StreamProcessor creation, and
16855    /// that is by design. A client that tries to switch formats and gets a
16856    /// StreamProcessor channel failure should try again one more time with a
16857    /// fresh StreamProcessor instance created with CodecFactory using the new
16858    /// input format during creation, before giving up.
16859    ///
16860    /// These format details override the format details specified during stream
16861    /// processor creation for this stream only. The next stream will default
16862    /// back to the format details set during stream processor creation.
16863    ///
16864    /// This message is permitted at the start of the first stream (just like at
16865    /// the start of any stream). The format specified need not match what was
16866    /// specified during stream processor creation, but if it doesn't match, the
16867    /// StreamProcessor channel might close as described above.
16868    QueueInputFormatDetails {
16869        stream_lifetime_ordinal: u64,
16870        format_details: FormatDetails,
16871        control_handle: StreamProcessorControlHandle,
16872    },
16873    /// This message queues input data to the stream processor for processing.
16874    ///
16875    /// If the stream doesn't exist yet, this message creates the new stream.
16876    ///
16877    /// The server won't send OnOutputConstraints() until after the client has
16878    /// sent at least one QueueInput* message.
16879    ///
16880    /// When using dynamic buffers the server can send OnOutputConstraints,
16881    /// OnOutputFormat, OnOutputPacket, or OnOutputEndOfStream at any time after
16882    /// the first QueueInputPacket. In the case of OnOutputPacket there must
16883    /// also be at least one output buffer that's been added but not yet fully
16884    /// removed (RemoveBuffer not yet complete).
16885    ///
16886    /// The client must continue to deliver input data via this message even if
16887    /// the stream processor has not yet generated the first
16888    /// OnOutputConstraints, and even if the StreamProcessor is generating
16889    /// OnFreeInputPacket for previously-queued input packets.  The input data
16890    /// must continue as long as there are free packets to be assured that the
16891    /// server will ever generate the first OnOutputConstraints.
16892    ///
16893    /// The server will close the channel if this packet refers to an old
16894    /// buffer_lifetime_ordinal. Clients that need to deliver input images of
16895    /// different dimensions to a video encoder can either (a) allocate buffers
16896    /// large enough to contain the range of needed image sizes and use those to
16897    /// deliver all the input images, (b) keep their own sets of buffers used
16898    /// for different image dimensions and re-add old buffers with AddBuffer,
16899    /// moving to a new buffer_lifetime_ordinal each time image dimensions
16900    /// change, or (c) allocate new buffers each time image dimensions change.
16901    /// The (a) option is preferred, for clients that have the flexibiilty to
16902    /// store images of varying dimensions in a single set of buffers. Clients
16903    /// that require each buffer to have a single image size can use option (b)
16904    /// or (c).
16905    QueueInputPacket { packet: Packet, control_handle: StreamProcessorControlHandle },
16906    /// Inform the server that all QueueInputPacket() messages for this stream
16907    /// have been sent.
16908    ///
16909    /// If the stream isn't closed first (by the client, or by OnStreamFailed(),
16910    /// or StreamProcessor channel closing), there will later be a corresponding
16911    /// OnOutputEndOfStream().
16912    ///
16913    /// The corresponding OnOutputEndOfStream() message will be generated only
16914    /// if the server finishes processing the stream before the server sees the
16915    /// client close the stream (such as by starting a new stream). A way to
16916    /// force the server to finish the stream before closing is to use
16917    /// FlushEndOfStreamAndCloseStream() after QueueInputEndOfStream() before
16918    /// any new stream. Another way to force the server to finish the stream
16919    /// before closing is to wait for the OnOutputEndOfStream() before taking
16920    /// any action that closes the stream.
16921    ///
16922    /// In addition to serving as an "EndOfStream" marker to make it obvious
16923    /// client-side when all input data has been processed, if a client never
16924    /// sends QueueInputEndOfStream, no amount of waiting will necessarily
16925    /// result in all input data getting processed through to the output. Some
16926    /// stream processors have some internally-delayed data which only gets
16927    /// drained (pushed through) by additional input data _or_ by this
16928    /// EndOfStream marker. In that sense, this message can be viewed as a drain
16929    /// at InputData domain level, but the drain only takes effect if the stream
16930    /// processor even gets that far before the stream is just closed at
16931    /// StreamControl domain level. This message is not alone sufficient to act
16932    /// as an overall drain at StreamControl level. For that, send this message
16933    /// first and then send FlushEndOfStreamAndCloseStream (at which point it
16934    /// becomes possible to queue input data for a new stream without causing
16935    /// discard of this older stream's data). Alternately, the client can wait
16936    /// for the OnOutputEndOfStream before closing the current stream.
16937    ///
16938    /// After a client sends QueueInputEndOfStream for a stream, if the client
16939    /// then sends for the same stream any of QueueInputPacket,
16940    /// QueueInputFormatDetails, QueueInputEndOfStream, the server will close
16941    /// the StreamProcessor channel.
16942    QueueInputEndOfStream {
16943        stream_lifetime_ordinal: u64,
16944        control_handle: StreamProcessorControlHandle,
16945    },
16946    /// This message results in channel closure unless supports_dynamic_buffers
16947    /// is set to true.
16948    ///
16949    /// This participates in allocation of buffers to be used with AddBuffer
16950    /// later. The client can get VMO handles for these buffers by also
16951    /// participating in the sysmem allocation, using the client's own related
16952    /// sysmem token (associated with the same logical buffer collection). It's
16953    /// up to the client to separately set any constraints needed by the client
16954    /// using the client's own related sysmem token, if any.
16955    ///
16956    /// Some clients may prefer to use SetInputBufferPartialSettings and/or
16957    /// SetOutputBufferPartialSettings. Servers must support those messages.
16958    ///
16959    /// In handling this message, if `allow_single_buffer` is set to true, the
16960    /// server must not constrain the number of buffers allocated. The server
16961    /// must set min_buffer_count to 1, and must leave max_buffer_count un-set
16962    /// or set it to 0xFFFFFFFF, and must leave all min_buffer_count_* fields
16963    /// un-set. The sender can set min_buffer_count and max_buffer_count to the
16964    /// same value if the intent is to allocate exactly that many buffers. If
16965    /// `allow_single_buffer` is un-set or set to false, the server will
16966    /// indicate needed buffer counts to sysmem.
16967    ///
16968    /// The server's BufferCollection channel (created from the passed-in
16969    /// sysmem2_token) may see ZX_CHANNEL_PEER_CLOSED at any time, but in
16970    /// particular, the server shouldn't expect the BufferCollection channel to
16971    /// remain connected to sysmem beyond the server sending SetConstraints. For
16972    /// this reason, the server may not be able to call
16973    /// WaitForAllBuffersAllocated or similar, so the server should just send
16974    /// SetConstraints, Close, then close the server's BufferCollection
16975    /// client_end. This means the server in general shouldn't attempt to get
16976    /// VMO handles for these buffers while processing this message.
16977    ///
16978    /// The server should not assume that these buffers will necessarily ever be
16979    /// added with AddBuffer to this StreamProcessor instance or any other
16980    /// StreamProcessor instance (owned by the server or not). These buffers may
16981    /// instead be dropped, or as a less-common example, possibly added to a
16982    /// different codec served by a different server implementation which also
16983    /// participated in the same sysmem buffer collection allocation.
16984    ///
16985    /// For input buffers, AddBuffer of the allocated buffer(s) to a different
16986    /// StreamProcessor instance of the same codec (same per CodecFactory) is
16987    /// likely to work, but using the same StreamProcessor instance is
16988    /// recommended when feasible.
16989    ///
16990    /// In contrast, for output buffers, AddBuffer of the allocated buffer(s) to
16991    /// a different StreamProcessor instance of the same codec (same per
16992    /// CodecFactory) can't (within reason) be made work in general, especially
16993    /// for video decoders. Therefore, for output buffers, the same
16994    /// StreamProcessor instance must be used for this message and AddBuffer.
16995    /// While a client may currently be able to get away with using different
16996    /// StreamProcessor instances for this message and AddBuffer for output
16997    /// buffers for some codecs, this may break at any time without it being
16998    /// considered a server-side bug.
16999    ///
17000    /// The allocated buffers can later be added using AddBuffer (piecemeal),
17001    /// and can be removed (piecemeal) using RemoveBuffer.
17002    ///
17003    /// Multiple different ParticipateInBufferAllocation messages can have their
17004    /// buffers later added to the same StreamProcessor instance using the same
17005    /// buffer_lifetime_ordinal. This can be useful if the client wants to
17006    /// allocate buffers incrementally, or dynamically adjust the number of
17007    /// buffers, potentially while actively processing. See also the
17008    /// `buffer_lifetime_ordinal` field of this message.
17009    ///
17010    /// Server implementations may use sysmem to help verify buffer
17011    /// compatibility later when buffers are added with AddBuffer.
17012    ParticipateInBufferAllocation {
17013        payload: StreamProcessorParticipateInBufferAllocationRequest,
17014        control_handle: StreamProcessorControlHandle,
17015    },
17016    /// Add buffers previously created with the help of
17017    /// ParticipateInBufferAllocation.
17018    ///
17019    /// For input buffers, the client can send QueueInputFormatDetails or
17020    /// QueueInputEndOfStream before any AddBuffer messages. At least one input
17021    /// buffer must be added before a valid QueueInputPacket can be sent. Most
17022    /// clients will want to continue quickly adding buffers up to at least
17023    /// buffer_count_for_server_current to avoid the codec potentially stalling,
17024    /// and typically a low number of buffers beyond that to keep the pipeline
17025    /// running smoothly. Input buffers beyond the first input buffer can be
17026    /// added after the first QueueInputPacket.
17027    ///
17028    /// Even if buffer_constraints_version_ordinal is current, the server must
17029    /// not close the channel if the buffer isn't consistent with the current
17030    /// buffer_constraints_version_ordinal (per sysmem GetVmoInfo given
17031    /// consistent StreamProcessor constraints). Instead, the server must send a
17032    /// new OnOutputConstraints. This simplifies some edge cases for some
17033    /// clients, particularly when a client can't reliably detect whether a
17034    /// newly-obtained buffer was actually allocated after
17035    /// buffer_constraints_version_ordinal changed, or may have been cached from
17036    /// before.
17037    ///
17038    /// The client can add additional buffers to the same port and
17039    /// buffer_lifetime_ordinal at any time using this message. If the
17040    /// buffer_lifetime_ordinal is no longer the most recent, the message will
17041    /// be ignored, the handle to the buffer dropped, and any later RemoveBuffer
17042    /// message re. the same buffer will complete immediately.
17043    ///
17044    /// If dynamic_buffers_input_max or dynamic_buffers_output_max is exceeded
17045    /// by the sum of buffers added by all AddBuffer calls with the same
17046    /// buffer_lifetime_ordinal, the server may close the channel. Servers are
17047    /// required to close the channel in this case if performance degradation or
17048    /// un-tested behavior would result from adding too many buffers.
17049    ///
17050    /// Switching to a new buffer_lifetime_ordinal starts the process of
17051    /// removing buffers associated with an old buffer_lifetime_ordinal.
17052    /// However, until the remove is complete, those buffers can still be used
17053    /// by the codec as normal. See also RemoveBuffer, which can be used to
17054    /// detect when removal is complete, regardless of whether the RemoveBuffer
17055    /// started the removal (including when not using dynamic buffers).
17056    ///
17057    /// The buffer stays added until removal later completes. The buffer remains
17058    /// added across potentially multiple buffer re-uses. Removal can be
17059    /// initiated (and/or confirmed/fenced) by the client using RemoveBuffer.
17060    /// The codec server can unilaterally initiate buffer removal; if the server
17061    /// does this, it must send a new buffer_constraints_version_ordinal with
17062    /// action_required true. Some other client-initiated messages can also
17063    /// begin buffer removal, such as CloseCurrentStream with
17064    /// release_input_buffers and/or release_output_buffers. The buffers are
17065    /// also automatically removed and released if the client closes the
17066    /// StreamProcessor client_end or the server closes the StreamProcessor
17067    /// server_end.
17068    ///
17069    /// Mixing of AddBuffer and SetInputBufferPartialSettings /
17070    /// SetOutputBufferPartialSettings is not allowed while there are any
17071    /// buffers still active on the port. To successfully switch modes for a
17072    /// port, most clients will want to just start over with a new
17073    /// StreamProcessor instance. This can also be done reliably by first
17074    /// ensuring that every added buffer under the port up to "now" (including
17075    /// those with older buffer_lifetime_ordinal) has completed a RemoveBuffer
17076    /// request. Only then is it known ok to switch modes for that port under
17077    /// the same StreamProcessor. Most clients will just use one way or the
17078    /// other to add buffers and never need to switch to the other way,
17079    /// especially within the same StreamProcessor.
17080    ///
17081    /// If a client might plausibly "spam" creation of many new
17082    /// buffer_lifetime_ordinal values without the buffers seeing any actual
17083    /// usage in between, the client should consider starting a Sync every few
17084    /// buffer_lifetime_ordinal(s) to fence cleanup of old
17085    /// buffer_lifetime_ordinal values, and avoid getting ahead of Sync
17086    /// completions by more than 16 buffer_lifetime_ordinal values. Else the
17087    /// channel may close from a backlog of new buffer_lifetime_ordinal(s)
17088    /// getting too far ahead of closing out old ones. The threshold of 16 is
17089    /// well below the enforcement threshold. Clients don't need to Sync if they
17090    /// won't be spamming new buffer_lifetime_ordinal values, or if added
17091    /// buffers will see at least some actual usage visible to the client before
17092    /// being replaced again.
17093    ///
17094    /// All buffers of the same port and buffer_lifetime_ordinal must share the
17095    /// same `[fuchsia.sysmem2/SingleBufferSetttings]`. The client can ensure
17096    /// this in various ways. One way is to use ParticipateInBufferAllocation
17097    /// then AddBuffer for at least the first buffer, before
17098    /// ParticipateInBufferAllocation for any subsequent buffers. Another way is
17099    /// to observe a mismatch in `SingleBufferSettings` before sending AddBuffer
17100    /// and bump to the next odd buffer_lifetime_ordinal value for the
17101    /// AddBuffer.
17102    AddBuffer {
17103        payload: StreamProcessorAddBufferRequest,
17104        control_handle: StreamProcessorControlHandle,
17105    },
17106    /// When using dynamic buffers, this call removes a buffer as soon as the
17107    /// buffer can be removed without adversely impacting any ongoing processing
17108    /// or an in-flight output packet referring to the buffer.
17109    ///
17110    /// If a client wants to remove a buffer with an in-flight output packet
17111    /// referring to the buffer, the client must RecycleOutputPacket for that
17112    /// in-flight output packet before the RemoveBuffer will complete.
17113    ///
17114    /// When using SetInputBufferPartialSettings /
17115    /// SetOutputBufferPartialSettings, this call doesn't initiate removal of
17116    /// the buffer. This call will complete when the buffer is done removing due
17117    /// to other reasons, such as a new buffer_lifetime_ordinal starting.
17118    ///
17119    /// Until RemoveBuffer completes, the codec is still allowed to send
17120    /// OnOutputPacket messages referencing the buffer, and the codec may still
17121    /// have a VMO handle open to the buffer. After RemoveBuffer completes, the
17122    /// codec guarantees that no subsequent output packet will reference the
17123    /// buffer, and that the server holds no VMO handles to the buffer.
17124    ///
17125    /// The client may need to recycle an output packet before the RemoveBuffer
17126    /// call can complete. Clients should take care to avoid blocking packet
17127    /// recycling while the RemoveBuffer request is in progress, since this
17128    /// would create a potential deadlock.
17129    ///
17130    /// The server closing any VMO handles to the buffer prior to completing
17131    /// this call is important for the client's ability to prevent memory usage
17132    /// spikes.
17133    ///
17134    /// If the client has "paused" processing by not providing any more input,
17135    /// the client will potentially need to send CloseCurrentStream before
17136    /// RemoveBuffer will complete. When using dynamic buffers, setting
17137    /// release_input_buffers or release_output_buffers to true is not
17138    /// necessary; the RemoveBuffer is explicitly telling the codec to release a
17139    /// specific buffer. When not using dynamic buffers, the client will need to
17140    /// set release_input_buffers or release_output_buffers to true, since
17141    /// RemoveBuffer alone doesn't initiate removal when not using dynamic
17142    /// buffers. A current "paused" stream needs to be stopped because frames
17143    /// can be held as reference frames, and codecs are never reqiured to copy
17144    /// their output data.
17145    ///
17146    /// For any video decoder output buffers being removed while there's an
17147    /// active stream (being fed input or not), it's typically best for the
17148    /// client to assume that removal of a video decoder output buffer may take
17149    /// a very long duration. This is because bitstreams, especially
17150    /// non-standard-compliant bitstreams, but in some cases potentially even
17151    /// standard-compliant bitstreams, can keep a video decoder output buffer in
17152    /// the set of active reference frames (aka DPB) indefinitely. The server is
17153    /// not required to notice that a stream is not conforming to a bitstream
17154    /// standard in this regard.
17155    ///
17156    /// In the case of h.264 decode, a standard-complient bitstream will limit
17157    /// the reorder delay to no longer than the max DPB occupancy. However, a
17158    /// server is not required to detect or reject non-compliant streams that
17159    /// potentially keep a frame in the DPB for longer.
17160    ///
17161    /// For HEVC, the situation is similar to h.264 (IIUC).
17162    ///
17163    /// In the case of VP9, there is nothing in the bitstream spec that limits
17164    /// the reorder delay (IIUC), meaning a frame can potentially stay in VP9's
17165    /// set of 8 reference frames (aka DPB) indefinitely. The server is not
17166    /// required to detect or mitigate this.
17167    ///
17168    /// Until this call completes, the server may still be using the buffer. For
17169    /// output buffers, the server can still send OnOutputPacket message(s) that
17170    /// references this buffer, but only up until the RemoveBuffer completion
17171    /// message is sent by the server. The client must continue to
17172    /// RecycleOutputPacket for packets that reference the buffer, until
17173    /// RemoveBuffer completes.
17174    ///
17175    /// When using dynamic buffers, upon receiving this message, the server will
17176    /// stop selecting the buffer for any new usage (as in, for any usage that
17177    /// moves the buffer from "free" to "not free" within the server). This
17178    /// applies even if the server has no other buffers available for use (aka
17179    /// no other "free" buffers). Any existing usage of the buffer is not ended
17180    /// early by this call alone.
17181    ///
17182    /// When not using dynamic buffers, upon receiving this message, the server
17183    /// will just remember to complete this call shortly after the buffer has
17184    /// completed removal triggered by some other cause (removal is not
17185    /// triggered/caused by this call).
17186    ///
17187    /// For video decoders, when using dynamic buffers, typically the client
17188    /// should take care to avoid removing too many output buffers for continued
17189    /// decode to be possible. If this occurs, the decoder will wait until the
17190    /// client adds another output buffer with AddBuffer. This can be a deadlock
17191    /// if the client never sends that AddBuffer. Due to DPB mechanism(s) and
17192    /// frame reordering, sending a single AddBuffer doesn't necessarily
17193    /// guarantee another OnOutputPacket, since additional output buffers can be
17194    /// needed before the server can send OnOutputPacket.
17195    ///
17196    /// The client must not call RemoveBuffer on the same buffer more than once,
17197    /// whether overlapping in time or not. The server should enforce this when
17198    /// not enforcing would require tracking additional concurrent requests. The
17199    /// server is not required to enforce this when enforcing would use more
17200    /// server memory.
17201    ///
17202    /// The server is allowed to complete this request quickly with success for
17203    /// buffer_lifetime_ordinal and buffer_index combinations that were never
17204    /// real buffers, but must close the channel if the buffer_lifetime_ordinal
17205    /// hasn't been started by the client yet (no removing potential future
17206    /// buffers).
17207    ///
17208    /// When using dynamic buffers, a buffer_lifetime_ordinal and buffer_index
17209    /// combination may be re-used after completion of RemoveBuffer, but only if
17210    /// the buffer_lifetime_ordinal is the current buffer_lifetime_ordinal. In
17211    /// other words, no adding buffers under an old buffer_lifetime_ordinal.
17212    ///
17213    /// Assuming a valid historical buffer is specified, successful completion
17214    /// of this call means the buffer has been fully released by the server and
17215    /// won't be referenced in any subsequent OnOutputPacket.
17216    RemoveBuffer {
17217        payload: StreamProcessorRemoveBufferRequest,
17218        responder: StreamProcessorRemoveBufferResponder,
17219    },
17220    /// This informs the StreamProcessor that the client is prepared to handle
17221    /// output packets that specify a buffer with buffer_lifetime_ordinal older
17222    /// than the most recent buffer_lifetime_ordinal.
17223    ///
17224    /// If the client doesn't send this message, the StreamProcessor will omit
17225    /// any such output, even if
17226    /// DetailedCodecDescription.supports_dynamic_buffers is true. For relevant
17227    /// decoders such as VP9 decoders, not sending this message can result in
17228    /// output that isn't bistream spec compliant, and the output can be
17229    /// visually different than intended by the bitstream.
17230    ///
17231    /// Such streams are only possible with some bitstream formats (such as
17232    /// VP9), and are rare, but can happen and can be valid per the bitstream
17233    /// spec. For example, this can be specified by a VP9 bitstream using
17234    /// show_existing_frame to output an old-dimensions buffer after having
17235    /// already output a new-dimensions buffer.
17236    ///
17237    /// Most clients that send this message will also want to use RemoveBuffer
17238    /// to know when it becomes safe to stop tracking an old buffer.
17239    ///
17240    /// Most of the time this makes no difference as most bitstreams don't
17241    /// actually emit old buffers, even if the bitstream spec would allow it.
17242    /// Old output buffers are especially rare for RTC streams which typically
17243    /// don't have any frame reordering in the first place.
17244    ///
17245    /// In most video streaming scenarios that use dimension switching as part
17246    /// of their bitrate control strategy (among those that I've observed), at
17247    /// the StreamProcessor layer the new dimensions are part of a new stream
17248    /// instead of being spliced together as a continuation of the old stream.
17249    /// That said, using a continuation of the old stream is also a completely
17250    /// valid way to implement dimension switching. When a stream switch occurs
17251    /// as part of dimension switching, the decoder state is not retained and
17252    /// there won't be any old buffer(s) emitted after new buffer(s), since the
17253    /// new stream doesn't know anything about old buffers filled by the old
17254    /// stream.
17255    ///
17256    /// Clients which haven't tested their ability to handle old output buffers
17257    /// should not send this message. Clients decoding bitstreams like VP9 for
17258    /// decoder compliance testing purposes should send this message (and use a
17259    /// VP9 decoder with DetailedCodecDescrption.supports_dynamic_buffers true).
17260    /// Clients which are required to support old output frames and/or fully
17261    /// comply with a relevant bitstream spec should/must send this message, and
17262    /// should test using a test stream that outputs packets referencing an old
17263    /// output buffer.
17264    ///
17265    /// Sending this message more than once closes the channel. If sent, this
17266    /// message must be sent prior to the client establishing the first output
17267    /// buffer_lifetime_ordinal. This requirement avoids ambiguity re. free/busy
17268    /// status of packets of old buffer_lifetime_ordinal(s), as the server can
17269    /// auto-recycle packets with old buffer_lifetime_ordinal on behalf of the
17270    /// client when this message was not sent by the client.
17271    ///
17272    /// This message is only permitted when
17273    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
17274    /// is true.
17275    EnableOldOutputBuffers { control_handle: StreamProcessorControlHandle },
17276    /// This informs the StreamProcessor that the client is prepared to handle
17277    /// output packets that specify the same buffer as another packet that's
17278    /// also concurrently in flight to the client (not yet recycled).
17279    ///
17280    /// Most bitstream formats don't do this. In formats that can do this such
17281    /// as VP9, most actual bitstreams don't do this.
17282    ///
17283    /// As an example, in VP9, a stream can cause the same output buffer to be
17284    /// used by another emitted output packet/frame by using show_existing_frame
17285    /// on the same VP9 reference/held frame slot more than once without
17286    /// decoding a new frame into that slot in between.
17287    ///
17288    /// Clients that need to achieve full bitstream spec compliance for such a
17289    /// bitstream format must send this message.
17290    ///
17291    /// If this message is not in effect, the server will omit any such output,
17292    /// which can result in output that is not compliant to the relevant
17293    /// bitstream spec, and which can be visually different than the stream
17294    /// intended.
17295    ///
17296    /// Sending this message more than once closes the channel. If sent, this
17297    /// message must be sent prior to the client establishing the first output
17298    /// buffer_lifetime_ordinal.
17299    ///
17300    /// This message is only permitted when
17301    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
17302    /// is true.
17303    EnableSameOutputBufferConcurrentlyInFlight { control_handle: StreamProcessorControlHandle },
17304    /// For video decoders, this forces the output buffers to be reallocated if
17305    /// the image size needs to change. This is wasteful as it forces extra
17306    /// buffer reallocations given typical video bitrate control strategies
17307    /// (applicable to both streaming and RTC) involving shifting the image
17308    /// dimensions up and down repeatedly as a logical video/stream plays,
17309    /// sometimes even if network conditions remain fairly stable. This extra
17310    /// buffer reallocation cost is incurred vs. baseline whether the dimension
17311    /// switching is achieved within a single StreamProcessor stream or by using
17312    /// a new StreamProcessor stream for new dimensions.
17313    ///
17314    /// A client should not send this message unless the client really must
17315    /// force the output buffers to be reallocated every time the output image
17316    /// size changes.
17317    ///
17318    /// Sending this message more than once closes the channel. If sent, this
17319    /// message must be sent prior to any SetInputBufferPartialSettings,
17320    /// SetOutputBufferPartialSettings, ParticipateInBufferAllocation, or
17321    /// AddBuffer.
17322    ///
17323    /// This message is only permitted if this StreamProcessor is a video
17324    /// decoder.
17325    ///
17326    /// This message is only permitted when
17327    /// `[fuchsia.mediacodec/CodecFactory.DetailedCodecDescription.supports_dynamic_buffers]`
17328    /// is true.
17329    EnableForceOutputBuffersFixedImageSize { control_handle: StreamProcessorControlHandle },
17330    /// An interaction was received which does not match any known method.
17331    #[non_exhaustive]
17332    _UnknownMethod {
17333        /// Ordinal of the method that was called.
17334        ordinal: u64,
17335        control_handle: StreamProcessorControlHandle,
17336        method_type: fidl::MethodType,
17337    },
17338}
17339
17340impl StreamProcessorRequest {
17341    #[allow(irrefutable_let_patterns)]
17342    pub fn into_enable_on_stream_failed(self) -> Option<(StreamProcessorControlHandle)> {
17343        if let StreamProcessorRequest::EnableOnStreamFailed { control_handle } = self {
17344            Some((control_handle))
17345        } else {
17346            None
17347        }
17348    }
17349
17350    #[allow(irrefutable_let_patterns)]
17351    pub fn into_set_input_buffer_partial_settings(
17352        self,
17353    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
17354        if let StreamProcessorRequest::SetInputBufferPartialSettings {
17355            input_settings,
17356            control_handle,
17357        } = self
17358        {
17359            Some((input_settings, control_handle))
17360        } else {
17361            None
17362        }
17363    }
17364
17365    #[allow(irrefutable_let_patterns)]
17366    pub fn into_set_output_buffer_partial_settings(
17367        self,
17368    ) -> Option<(StreamBufferPartialSettings, StreamProcessorControlHandle)> {
17369        if let StreamProcessorRequest::SetOutputBufferPartialSettings {
17370            output_settings,
17371            control_handle,
17372        } = self
17373        {
17374            Some((output_settings, control_handle))
17375        } else {
17376            None
17377        }
17378    }
17379
17380    #[allow(irrefutable_let_patterns)]
17381    pub fn into_complete_output_buffer_partial_settings(
17382        self,
17383    ) -> Option<(u64, StreamProcessorControlHandle)> {
17384        if let StreamProcessorRequest::CompleteOutputBufferPartialSettings {
17385            buffer_lifetime_ordinal,
17386            control_handle,
17387        } = self
17388        {
17389            Some((buffer_lifetime_ordinal, control_handle))
17390        } else {
17391            None
17392        }
17393    }
17394
17395    #[allow(irrefutable_let_patterns)]
17396    pub fn into_flush_end_of_stream_and_close_stream(
17397        self,
17398    ) -> Option<(u64, StreamProcessorControlHandle)> {
17399        if let StreamProcessorRequest::FlushEndOfStreamAndCloseStream {
17400            stream_lifetime_ordinal,
17401            control_handle,
17402        } = self
17403        {
17404            Some((stream_lifetime_ordinal, control_handle))
17405        } else {
17406            None
17407        }
17408    }
17409
17410    #[allow(irrefutable_let_patterns)]
17411    pub fn into_close_current_stream(
17412        self,
17413    ) -> Option<(u64, bool, bool, StreamProcessorControlHandle)> {
17414        if let StreamProcessorRequest::CloseCurrentStream {
17415            stream_lifetime_ordinal,
17416            release_input_buffers,
17417            release_output_buffers,
17418            control_handle,
17419        } = self
17420        {
17421            Some((
17422                stream_lifetime_ordinal,
17423                release_input_buffers,
17424                release_output_buffers,
17425                control_handle,
17426            ))
17427        } else {
17428            None
17429        }
17430    }
17431
17432    #[allow(irrefutable_let_patterns)]
17433    pub fn into_sync(self) -> Option<(StreamProcessorSyncResponder)> {
17434        if let StreamProcessorRequest::Sync { responder } = self { Some((responder)) } else { None }
17435    }
17436
17437    #[allow(irrefutable_let_patterns)]
17438    pub fn into_recycle_output_packet(
17439        self,
17440    ) -> Option<(PacketHeader, StreamProcessorControlHandle)> {
17441        if let StreamProcessorRequest::RecycleOutputPacket {
17442            available_output_packet,
17443            control_handle,
17444        } = self
17445        {
17446            Some((available_output_packet, control_handle))
17447        } else {
17448            None
17449        }
17450    }
17451
17452    #[allow(irrefutable_let_patterns)]
17453    pub fn into_queue_input_format_details(
17454        self,
17455    ) -> Option<(u64, FormatDetails, StreamProcessorControlHandle)> {
17456        if let StreamProcessorRequest::QueueInputFormatDetails {
17457            stream_lifetime_ordinal,
17458            format_details,
17459            control_handle,
17460        } = self
17461        {
17462            Some((stream_lifetime_ordinal, format_details, control_handle))
17463        } else {
17464            None
17465        }
17466    }
17467
17468    #[allow(irrefutable_let_patterns)]
17469    pub fn into_queue_input_packet(self) -> Option<(Packet, StreamProcessorControlHandle)> {
17470        if let StreamProcessorRequest::QueueInputPacket { packet, control_handle } = self {
17471            Some((packet, control_handle))
17472        } else {
17473            None
17474        }
17475    }
17476
17477    #[allow(irrefutable_let_patterns)]
17478    pub fn into_queue_input_end_of_stream(self) -> Option<(u64, StreamProcessorControlHandle)> {
17479        if let StreamProcessorRequest::QueueInputEndOfStream {
17480            stream_lifetime_ordinal,
17481            control_handle,
17482        } = self
17483        {
17484            Some((stream_lifetime_ordinal, control_handle))
17485        } else {
17486            None
17487        }
17488    }
17489
17490    #[allow(irrefutable_let_patterns)]
17491    pub fn into_participate_in_buffer_allocation(
17492        self,
17493    ) -> Option<(StreamProcessorParticipateInBufferAllocationRequest, StreamProcessorControlHandle)>
17494    {
17495        if let StreamProcessorRequest::ParticipateInBufferAllocation { payload, control_handle } =
17496            self
17497        {
17498            Some((payload, control_handle))
17499        } else {
17500            None
17501        }
17502    }
17503
17504    #[allow(irrefutable_let_patterns)]
17505    pub fn into_add_buffer(
17506        self,
17507    ) -> Option<(StreamProcessorAddBufferRequest, StreamProcessorControlHandle)> {
17508        if let StreamProcessorRequest::AddBuffer { payload, control_handle } = self {
17509            Some((payload, control_handle))
17510        } else {
17511            None
17512        }
17513    }
17514
17515    #[allow(irrefutable_let_patterns)]
17516    pub fn into_remove_buffer(
17517        self,
17518    ) -> Option<(StreamProcessorRemoveBufferRequest, StreamProcessorRemoveBufferResponder)> {
17519        if let StreamProcessorRequest::RemoveBuffer { payload, responder } = self {
17520            Some((payload, responder))
17521        } else {
17522            None
17523        }
17524    }
17525
17526    #[allow(irrefutable_let_patterns)]
17527    pub fn into_enable_old_output_buffers(self) -> Option<(StreamProcessorControlHandle)> {
17528        if let StreamProcessorRequest::EnableOldOutputBuffers { control_handle } = self {
17529            Some((control_handle))
17530        } else {
17531            None
17532        }
17533    }
17534
17535    #[allow(irrefutable_let_patterns)]
17536    pub fn into_enable_same_output_buffer_concurrently_in_flight(
17537        self,
17538    ) -> Option<(StreamProcessorControlHandle)> {
17539        if let StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight {
17540            control_handle,
17541        } = self
17542        {
17543            Some((control_handle))
17544        } else {
17545            None
17546        }
17547    }
17548
17549    #[allow(irrefutable_let_patterns)]
17550    pub fn into_enable_force_output_buffers_fixed_image_size(
17551        self,
17552    ) -> Option<(StreamProcessorControlHandle)> {
17553        if let StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { control_handle } =
17554            self
17555        {
17556            Some((control_handle))
17557        } else {
17558            None
17559        }
17560    }
17561
17562    /// Name of the method defined in FIDL
17563    pub fn method_name(&self) -> &'static str {
17564        match *self {
17565            StreamProcessorRequest::EnableOnStreamFailed { .. } => "enable_on_stream_failed",
17566            StreamProcessorRequest::SetInputBufferPartialSettings { .. } => {
17567                "set_input_buffer_partial_settings"
17568            }
17569            StreamProcessorRequest::SetOutputBufferPartialSettings { .. } => {
17570                "set_output_buffer_partial_settings"
17571            }
17572            StreamProcessorRequest::CompleteOutputBufferPartialSettings { .. } => {
17573                "complete_output_buffer_partial_settings"
17574            }
17575            StreamProcessorRequest::FlushEndOfStreamAndCloseStream { .. } => {
17576                "flush_end_of_stream_and_close_stream"
17577            }
17578            StreamProcessorRequest::CloseCurrentStream { .. } => "close_current_stream",
17579            StreamProcessorRequest::Sync { .. } => "sync",
17580            StreamProcessorRequest::RecycleOutputPacket { .. } => "recycle_output_packet",
17581            StreamProcessorRequest::QueueInputFormatDetails { .. } => "queue_input_format_details",
17582            StreamProcessorRequest::QueueInputPacket { .. } => "queue_input_packet",
17583            StreamProcessorRequest::QueueInputEndOfStream { .. } => "queue_input_end_of_stream",
17584            StreamProcessorRequest::ParticipateInBufferAllocation { .. } => {
17585                "participate_in_buffer_allocation"
17586            }
17587            StreamProcessorRequest::AddBuffer { .. } => "add_buffer",
17588            StreamProcessorRequest::RemoveBuffer { .. } => "remove_buffer",
17589            StreamProcessorRequest::EnableOldOutputBuffers { .. } => "enable_old_output_buffers",
17590            StreamProcessorRequest::EnableSameOutputBufferConcurrentlyInFlight { .. } => {
17591                "enable_same_output_buffer_concurrently_in_flight"
17592            }
17593            StreamProcessorRequest::EnableForceOutputBuffersFixedImageSize { .. } => {
17594                "enable_force_output_buffers_fixed_image_size"
17595            }
17596            StreamProcessorRequest::_UnknownMethod {
17597                method_type: fidl::MethodType::OneWay,
17598                ..
17599            } => "unknown one-way method",
17600            StreamProcessorRequest::_UnknownMethod {
17601                method_type: fidl::MethodType::TwoWay,
17602                ..
17603            } => "unknown two-way method",
17604        }
17605    }
17606}
17607
17608#[derive(Debug, Clone)]
17609pub struct StreamProcessorControlHandle {
17610    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
17611}
17612
17613impl StreamProcessorControlHandle {
17614    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
17615        self.inner.shutdown_with_epitaph(status.into())
17616    }
17617}
17618
17619impl fidl::endpoints::ControlHandle for StreamProcessorControlHandle {
17620    fn shutdown(&self) {
17621        self.inner.shutdown()
17622    }
17623
17624    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
17625        self.inner.shutdown_with_epitaph(status)
17626    }
17627
17628    fn is_closed(&self) -> bool {
17629        self.inner.channel().is_closed()
17630    }
17631    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
17632        self.inner.channel().on_closed()
17633    }
17634
17635    #[cfg(target_os = "fuchsia")]
17636    fn signal_peer(
17637        &self,
17638        clear_mask: zx::Signals,
17639        set_mask: zx::Signals,
17640    ) -> Result<(), zx_status::Status> {
17641        use fidl::Peered;
17642        self.inner.channel().signal_peer(clear_mask, set_mask)
17643    }
17644}
17645
17646impl StreamProcessorControlHandle {
17647    pub fn send_on_stream_failed(
17648        &self,
17649        mut stream_lifetime_ordinal: u64,
17650        mut error: StreamError,
17651    ) -> Result<(), fidl::Error> {
17652        self.inner.send::<StreamProcessorOnStreamFailedRequest>(
17653            (stream_lifetime_ordinal, error),
17654            0,
17655            0x77ccf70bb061cf8e,
17656            fidl::encoding::DynamicFlags::empty(),
17657        )
17658    }
17659
17660    pub fn send_on_input_constraints(
17661        &self,
17662        mut input_constraints: &StreamBufferConstraints,
17663    ) -> Result<(), fidl::Error> {
17664        self.inner.send::<StreamProcessorOnInputConstraintsRequest>(
17665            (input_constraints,),
17666            0,
17667            0x211da9966a8ca0,
17668            fidl::encoding::DynamicFlags::empty(),
17669        )
17670    }
17671
17672    pub fn send_on_output_constraints(
17673        &self,
17674        mut output_config: &StreamOutputConstraints,
17675    ) -> Result<(), fidl::Error> {
17676        self.inner.send::<StreamProcessorOnOutputConstraintsRequest>(
17677            (output_config,),
17678            0,
17679            0x40d8234504c170f3,
17680            fidl::encoding::DynamicFlags::empty(),
17681        )
17682    }
17683
17684    pub fn send_on_output_format(
17685        &self,
17686        mut output_format: &StreamOutputFormat,
17687    ) -> Result<(), fidl::Error> {
17688        self.inner.send::<StreamProcessorOnOutputFormatRequest>(
17689            (output_format,),
17690            0,
17691            0x131b77ae120360bc,
17692            fidl::encoding::DynamicFlags::empty(),
17693        )
17694    }
17695
17696    pub fn send_on_output_packet(
17697        &self,
17698        mut output_packet: &Packet,
17699        mut error_detected_before: bool,
17700        mut error_detected_during: bool,
17701    ) -> Result<(), fidl::Error> {
17702        self.inner.send::<StreamProcessorOnOutputPacketRequest>(
17703            (output_packet, error_detected_before, error_detected_during),
17704            0,
17705            0x5c2029be1090ce93,
17706            fidl::encoding::DynamicFlags::empty(),
17707        )
17708    }
17709
17710    pub fn send_on_output_end_of_stream(
17711        &self,
17712        mut stream_lifetime_ordinal: u64,
17713        mut error_detected_before: bool,
17714    ) -> Result<(), fidl::Error> {
17715        self.inner.send::<StreamProcessorOnOutputEndOfStreamRequest>(
17716            (stream_lifetime_ordinal, error_detected_before),
17717            0,
17718            0x3bb65d237cfa50e6,
17719            fidl::encoding::DynamicFlags::empty(),
17720        )
17721    }
17722
17723    pub fn send_on_free_input_packet(
17724        &self,
17725        mut free_input_packet: &PacketHeader,
17726    ) -> Result<(), fidl::Error> {
17727        self.inner.send::<StreamProcessorOnFreeInputPacketRequest>(
17728            (free_input_packet,),
17729            0,
17730            0xeef799b28708bbd,
17731            fidl::encoding::DynamicFlags::empty(),
17732        )
17733    }
17734
17735    pub fn send_on_output_timestamp_has_no_output(
17736        &self,
17737        mut payload: &StreamProcessorOnOutputTimestampHasNoOutputRequest,
17738    ) -> Result<(), fidl::Error> {
17739        self.inner.send::<StreamProcessorOnOutputTimestampHasNoOutputRequest>(
17740            payload,
17741            0,
17742            0x7436457799a25cd4,
17743            fidl::encoding::DynamicFlags::FLEXIBLE,
17744        )
17745    }
17746}
17747
17748#[must_use = "FIDL methods require a response to be sent"]
17749#[derive(Debug)]
17750pub struct StreamProcessorSyncResponder {
17751    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
17752    tx_id: u32,
17753}
17754
17755/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
17756/// if the responder is dropped without sending a response, so that the client
17757/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17758impl std::ops::Drop for StreamProcessorSyncResponder {
17759    fn drop(&mut self) {
17760        self.control_handle.shutdown();
17761        // Safety: drops once, never accessed again
17762        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17763    }
17764}
17765
17766impl fidl::endpoints::Responder for StreamProcessorSyncResponder {
17767    type ControlHandle = StreamProcessorControlHandle;
17768
17769    fn control_handle(&self) -> &StreamProcessorControlHandle {
17770        &self.control_handle
17771    }
17772
17773    fn drop_without_shutdown(mut self) {
17774        // Safety: drops once, never accessed again due to mem::forget
17775        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17776        // Prevent Drop from running (which would shut down the channel)
17777        std::mem::forget(self);
17778    }
17779}
17780
17781impl StreamProcessorSyncResponder {
17782    /// Sends a response to the FIDL transaction.
17783    ///
17784    /// Sets the channel to shutdown if an error occurs.
17785    pub fn send(self) -> Result<(), fidl::Error> {
17786        let _result = self.send_raw();
17787        if _result.is_err() {
17788            self.control_handle.shutdown();
17789        }
17790        self.drop_without_shutdown();
17791        _result
17792    }
17793
17794    /// Similar to "send" but does not shutdown the channel if an error occurs.
17795    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17796        let _result = self.send_raw();
17797        self.drop_without_shutdown();
17798        _result
17799    }
17800
17801    fn send_raw(&self) -> Result<(), fidl::Error> {
17802        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
17803            (),
17804            self.tx_id,
17805            0x4b3e44300b0ec6aa,
17806            fidl::encoding::DynamicFlags::empty(),
17807        )
17808    }
17809}
17810
17811#[must_use = "FIDL methods require a response to be sent"]
17812#[derive(Debug)]
17813pub struct StreamProcessorRemoveBufferResponder {
17814    control_handle: std::mem::ManuallyDrop<StreamProcessorControlHandle>,
17815    tx_id: u32,
17816}
17817
17818/// Set the the channel to be shutdown (see [`StreamProcessorControlHandle::shutdown`])
17819/// if the responder is dropped without sending a response, so that the client
17820/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
17821impl std::ops::Drop for StreamProcessorRemoveBufferResponder {
17822    fn drop(&mut self) {
17823        self.control_handle.shutdown();
17824        // Safety: drops once, never accessed again
17825        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17826    }
17827}
17828
17829impl fidl::endpoints::Responder for StreamProcessorRemoveBufferResponder {
17830    type ControlHandle = StreamProcessorControlHandle;
17831
17832    fn control_handle(&self) -> &StreamProcessorControlHandle {
17833        &self.control_handle
17834    }
17835
17836    fn drop_without_shutdown(mut self) {
17837        // Safety: drops once, never accessed again due to mem::forget
17838        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
17839        // Prevent Drop from running (which would shut down the channel)
17840        std::mem::forget(self);
17841    }
17842}
17843
17844impl StreamProcessorRemoveBufferResponder {
17845    /// Sends a response to the FIDL transaction.
17846    ///
17847    /// Sets the channel to shutdown if an error occurs.
17848    pub fn send(self) -> Result<(), fidl::Error> {
17849        let _result = self.send_raw();
17850        if _result.is_err() {
17851            self.control_handle.shutdown();
17852        }
17853        self.drop_without_shutdown();
17854        _result
17855    }
17856
17857    /// Similar to "send" but does not shutdown the channel if an error occurs.
17858    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
17859        let _result = self.send_raw();
17860        self.drop_without_shutdown();
17861        _result
17862    }
17863
17864    fn send_raw(&self) -> Result<(), fidl::Error> {
17865        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
17866            fidl::encoding::Flexible::new(()),
17867            self.tx_id,
17868            0x40b967ffa6b2da43,
17869            fidl::encoding::DynamicFlags::FLEXIBLE,
17870        )
17871    }
17872}
17873
17874#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
17875pub struct StreamSinkMarker;
17876
17877impl fidl::endpoints::ProtocolMarker for StreamSinkMarker {
17878    type Proxy = StreamSinkProxy;
17879    type RequestStream = StreamSinkRequestStream;
17880    #[cfg(target_os = "fuchsia")]
17881    type SynchronousProxy = StreamSinkSynchronousProxy;
17882
17883    const DEBUG_NAME: &'static str = "(anonymous) StreamSink";
17884}
17885
17886pub trait StreamSinkProxyInterface: Send + Sync {
17887    type SendPacketResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17888    fn r#send_packet(&self, packet: &StreamPacket) -> Self::SendPacketResponseFut;
17889    fn r#send_packet_no_reply(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
17890    fn r#end_of_stream(&self) -> Result<(), fidl::Error>;
17891    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
17892    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
17893    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
17894}
17895#[derive(Debug)]
17896#[cfg(target_os = "fuchsia")]
17897pub struct StreamSinkSynchronousProxy {
17898    client: fidl::client::sync::Client,
17899}
17900
17901#[cfg(target_os = "fuchsia")]
17902impl fidl::endpoints::SynchronousProxy for StreamSinkSynchronousProxy {
17903    type Proxy = StreamSinkProxy;
17904    type Protocol = StreamSinkMarker;
17905
17906    fn from_channel(inner: fidl::Channel) -> Self {
17907        Self::new(inner)
17908    }
17909
17910    fn into_channel(self) -> fidl::Channel {
17911        self.client.into_channel()
17912    }
17913
17914    fn as_channel(&self) -> &fidl::Channel {
17915        self.client.as_channel()
17916    }
17917}
17918
17919#[cfg(target_os = "fuchsia")]
17920impl StreamSinkSynchronousProxy {
17921    pub fn new(channel: fidl::Channel) -> Self {
17922        Self { client: fidl::client::sync::Client::new(channel) }
17923    }
17924
17925    pub fn into_channel(self) -> fidl::Channel {
17926        self.client.into_channel()
17927    }
17928
17929    /// Waits until an event arrives and returns it. It is safe for other
17930    /// threads to make concurrent requests while waiting for an event.
17931    pub fn wait_for_event(
17932        &self,
17933        deadline: zx::MonotonicInstant,
17934    ) -> Result<StreamSinkEvent, fidl::Error> {
17935        StreamSinkEvent::decode(self.client.wait_for_event::<StreamSinkMarker>(deadline)?)
17936    }
17937
17938    /// Sends a packet to the service. The response is sent when the service is
17939    /// done with the associated payload memory.
17940    ///
17941    /// `packet` must be valid for the current buffer set, otherwise the service
17942    /// will close the connection.
17943    pub fn r#send_packet(
17944        &self,
17945        mut packet: &StreamPacket,
17946        ___deadline: zx::MonotonicInstant,
17947    ) -> Result<(), fidl::Error> {
17948        let _response = self.client.send_query::<
17949            StreamSinkSendPacketRequest,
17950            fidl::encoding::EmptyPayload,
17951            StreamSinkMarker,
17952        >(
17953            (packet,),
17954            0x67cddd607442775f,
17955            fidl::encoding::DynamicFlags::empty(),
17956            ___deadline,
17957        )?;
17958        Ok(_response)
17959    }
17960
17961    /// Sends a packet to the service. This interface doesn't define how the
17962    /// client knows when the sink is done with the associated payload memory.
17963    /// The inheriting interface must define that.
17964    ///
17965    /// `packet` must be valid for the current buffer set, otherwise the service
17966    /// will close the connection.
17967    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
17968        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
17969            (packet,),
17970            0x8d9b8b413ceba9d,
17971            fidl::encoding::DynamicFlags::empty(),
17972        )
17973    }
17974
17975    /// Indicates the stream has ended. The precise semantics of this method are
17976    /// determined by the inheriting interface.
17977    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
17978        self.client.send::<fidl::encoding::EmptyPayload>(
17979            (),
17980            0x6180fd6f7e793b71,
17981            fidl::encoding::DynamicFlags::empty(),
17982        )
17983    }
17984
17985    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
17986    /// and not yet released. The response is sent after all packets have been
17987    /// released.
17988    pub fn r#discard_all_packets(
17989        &self,
17990        ___deadline: zx::MonotonicInstant,
17991    ) -> Result<(), fidl::Error> {
17992        let _response = self.client.send_query::<
17993            fidl::encoding::EmptyPayload,
17994            fidl::encoding::EmptyPayload,
17995            StreamSinkMarker,
17996        >(
17997            (),
17998            0x6f4dad7af2917665,
17999            fidl::encoding::DynamicFlags::empty(),
18000            ___deadline,
18001        )?;
18002        Ok(_response)
18003    }
18004
18005    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18006    /// and not yet released.
18007    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18008        self.client.send::<fidl::encoding::EmptyPayload>(
18009            (),
18010            0x50d36d0d23081bc4,
18011            fidl::encoding::DynamicFlags::empty(),
18012        )
18013    }
18014}
18015
18016#[cfg(target_os = "fuchsia")]
18017impl From<StreamSinkSynchronousProxy> for zx::NullableHandle {
18018    fn from(value: StreamSinkSynchronousProxy) -> Self {
18019        value.into_channel().into()
18020    }
18021}
18022
18023#[cfg(target_os = "fuchsia")]
18024impl From<fidl::Channel> for StreamSinkSynchronousProxy {
18025    fn from(value: fidl::Channel) -> Self {
18026        Self::new(value)
18027    }
18028}
18029
18030#[cfg(target_os = "fuchsia")]
18031impl fidl::endpoints::FromClient for StreamSinkSynchronousProxy {
18032    type Protocol = StreamSinkMarker;
18033
18034    fn from_client(value: fidl::endpoints::ClientEnd<StreamSinkMarker>) -> Self {
18035        Self::new(value.into_channel())
18036    }
18037}
18038
18039#[derive(Debug, Clone)]
18040pub struct StreamSinkProxy {
18041    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18042}
18043
18044impl fidl::endpoints::Proxy for StreamSinkProxy {
18045    type Protocol = StreamSinkMarker;
18046
18047    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18048        Self::new(inner)
18049    }
18050
18051    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18052        self.client.into_channel().map_err(|client| Self { client })
18053    }
18054
18055    fn as_channel(&self) -> &::fidl::AsyncChannel {
18056        self.client.as_channel()
18057    }
18058}
18059
18060impl StreamSinkProxy {
18061    /// Create a new Proxy for fuchsia.media/StreamSink.
18062    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18063        let protocol_name = <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18064        Self { client: fidl::client::Client::new(channel, protocol_name) }
18065    }
18066
18067    /// Get a Stream of events from the remote end of the protocol.
18068    ///
18069    /// # Panics
18070    ///
18071    /// Panics if the event stream was already taken.
18072    pub fn take_event_stream(&self) -> StreamSinkEventStream {
18073        StreamSinkEventStream { event_receiver: self.client.take_event_receiver() }
18074    }
18075
18076    /// Sends a packet to the service. The response is sent when the service is
18077    /// done with the associated payload memory.
18078    ///
18079    /// `packet` must be valid for the current buffer set, otherwise the service
18080    /// will close the connection.
18081    pub fn r#send_packet(
18082        &self,
18083        mut packet: &StreamPacket,
18084    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18085        StreamSinkProxyInterface::r#send_packet(self, packet)
18086    }
18087
18088    /// Sends a packet to the service. This interface doesn't define how the
18089    /// client knows when the sink is done with the associated payload memory.
18090    /// The inheriting interface must define that.
18091    ///
18092    /// `packet` must be valid for the current buffer set, otherwise the service
18093    /// will close the connection.
18094    pub fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18095        StreamSinkProxyInterface::r#send_packet_no_reply(self, packet)
18096    }
18097
18098    /// Indicates the stream has ended. The precise semantics of this method are
18099    /// determined by the inheriting interface.
18100    pub fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
18101        StreamSinkProxyInterface::r#end_of_stream(self)
18102    }
18103
18104    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18105    /// and not yet released. The response is sent after all packets have been
18106    /// released.
18107    pub fn r#discard_all_packets(
18108        &self,
18109    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18110        StreamSinkProxyInterface::r#discard_all_packets(self)
18111    }
18112
18113    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18114    /// and not yet released.
18115    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18116        StreamSinkProxyInterface::r#discard_all_packets_no_reply(self)
18117    }
18118}
18119
18120impl StreamSinkProxyInterface for StreamSinkProxy {
18121    type SendPacketResponseFut =
18122        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18123    fn r#send_packet(&self, mut packet: &StreamPacket) -> Self::SendPacketResponseFut {
18124        fn _decode(
18125            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18126        ) -> Result<(), fidl::Error> {
18127            let _response = fidl::client::decode_transaction_body::<
18128                fidl::encoding::EmptyPayload,
18129                fidl::encoding::DefaultFuchsiaResourceDialect,
18130                0x67cddd607442775f,
18131            >(_buf?)?;
18132            Ok(_response)
18133        }
18134        self.client.send_query_and_decode::<StreamSinkSendPacketRequest, ()>(
18135            (packet,),
18136            0x67cddd607442775f,
18137            fidl::encoding::DynamicFlags::empty(),
18138            _decode,
18139        )
18140    }
18141
18142    fn r#send_packet_no_reply(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18143        self.client.send::<StreamSinkSendPacketNoReplyRequest>(
18144            (packet,),
18145            0x8d9b8b413ceba9d,
18146            fidl::encoding::DynamicFlags::empty(),
18147        )
18148    }
18149
18150    fn r#end_of_stream(&self) -> Result<(), fidl::Error> {
18151        self.client.send::<fidl::encoding::EmptyPayload>(
18152            (),
18153            0x6180fd6f7e793b71,
18154            fidl::encoding::DynamicFlags::empty(),
18155        )
18156    }
18157
18158    type DiscardAllPacketsResponseFut =
18159        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18160    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
18161        fn _decode(
18162            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18163        ) -> Result<(), fidl::Error> {
18164            let _response = fidl::client::decode_transaction_body::<
18165                fidl::encoding::EmptyPayload,
18166                fidl::encoding::DefaultFuchsiaResourceDialect,
18167                0x6f4dad7af2917665,
18168            >(_buf?)?;
18169            Ok(_response)
18170        }
18171        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
18172            (),
18173            0x6f4dad7af2917665,
18174            fidl::encoding::DynamicFlags::empty(),
18175            _decode,
18176        )
18177    }
18178
18179    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18180        self.client.send::<fidl::encoding::EmptyPayload>(
18181            (),
18182            0x50d36d0d23081bc4,
18183            fidl::encoding::DynamicFlags::empty(),
18184        )
18185    }
18186}
18187
18188pub struct StreamSinkEventStream {
18189    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18190}
18191
18192impl std::marker::Unpin for StreamSinkEventStream {}
18193
18194impl futures::stream::FusedStream for StreamSinkEventStream {
18195    fn is_terminated(&self) -> bool {
18196        self.event_receiver.is_terminated()
18197    }
18198}
18199
18200impl futures::Stream for StreamSinkEventStream {
18201    type Item = Result<StreamSinkEvent, fidl::Error>;
18202
18203    fn poll_next(
18204        mut self: std::pin::Pin<&mut Self>,
18205        cx: &mut std::task::Context<'_>,
18206    ) -> std::task::Poll<Option<Self::Item>> {
18207        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18208            &mut self.event_receiver,
18209            cx
18210        )?) {
18211            Some(buf) => std::task::Poll::Ready(Some(StreamSinkEvent::decode(buf))),
18212            None => std::task::Poll::Ready(None),
18213        }
18214    }
18215}
18216
18217#[derive(Debug)]
18218pub enum StreamSinkEvent {}
18219
18220impl StreamSinkEvent {
18221    /// Decodes a message buffer as a [`StreamSinkEvent`].
18222    fn decode(
18223        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18224    ) -> Result<StreamSinkEvent, fidl::Error> {
18225        let (bytes, _handles) = buf.split_mut();
18226        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18227        debug_assert_eq!(tx_header.tx_id, 0);
18228        match tx_header.ordinal {
18229            _ => Err(fidl::Error::UnknownOrdinal {
18230                ordinal: tx_header.ordinal,
18231                protocol_name: <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18232            }),
18233        }
18234    }
18235}
18236
18237/// A Stream of incoming requests for fuchsia.media/StreamSink.
18238pub struct StreamSinkRequestStream {
18239    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18240    is_terminated: bool,
18241}
18242
18243impl std::marker::Unpin for StreamSinkRequestStream {}
18244
18245impl futures::stream::FusedStream for StreamSinkRequestStream {
18246    fn is_terminated(&self) -> bool {
18247        self.is_terminated
18248    }
18249}
18250
18251impl fidl::endpoints::RequestStream for StreamSinkRequestStream {
18252    type Protocol = StreamSinkMarker;
18253    type ControlHandle = StreamSinkControlHandle;
18254
18255    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18256        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18257    }
18258
18259    fn control_handle(&self) -> Self::ControlHandle {
18260        StreamSinkControlHandle { inner: self.inner.clone() }
18261    }
18262
18263    fn into_inner(
18264        self,
18265    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18266    {
18267        (self.inner, self.is_terminated)
18268    }
18269
18270    fn from_inner(
18271        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18272        is_terminated: bool,
18273    ) -> Self {
18274        Self { inner, is_terminated }
18275    }
18276}
18277
18278impl futures::Stream for StreamSinkRequestStream {
18279    type Item = Result<StreamSinkRequest, fidl::Error>;
18280
18281    fn poll_next(
18282        mut self: std::pin::Pin<&mut Self>,
18283        cx: &mut std::task::Context<'_>,
18284    ) -> std::task::Poll<Option<Self::Item>> {
18285        let this = &mut *self;
18286        if this.inner.check_shutdown(cx) {
18287            this.is_terminated = true;
18288            return std::task::Poll::Ready(None);
18289        }
18290        if this.is_terminated {
18291            panic!("polled StreamSinkRequestStream after completion");
18292        }
18293        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18294            |bytes, handles| {
18295                match this.inner.channel().read_etc(cx, bytes, handles) {
18296                    std::task::Poll::Ready(Ok(())) => {}
18297                    std::task::Poll::Pending => return std::task::Poll::Pending,
18298                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
18299                        this.is_terminated = true;
18300                        return std::task::Poll::Ready(None);
18301                    }
18302                    std::task::Poll::Ready(Err(e)) => {
18303                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
18304                            e.into(),
18305                        ))));
18306                    }
18307                }
18308
18309                // A message has been received from the channel
18310                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18311
18312                std::task::Poll::Ready(Some(match header.ordinal {
18313                    0x67cddd607442775f => {
18314                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18315                        let mut req = fidl::new_empty!(
18316                            StreamSinkSendPacketRequest,
18317                            fidl::encoding::DefaultFuchsiaResourceDialect
18318                        );
18319                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketRequest>(&header, _body_bytes, handles, &mut req)?;
18320                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18321                        Ok(StreamSinkRequest::SendPacket {
18322                            packet: req.packet,
18323
18324                            responder: StreamSinkSendPacketResponder {
18325                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18326                                tx_id: header.tx_id,
18327                            },
18328                        })
18329                    }
18330                    0x8d9b8b413ceba9d => {
18331                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18332                        let mut req = fidl::new_empty!(
18333                            StreamSinkSendPacketNoReplyRequest,
18334                            fidl::encoding::DefaultFuchsiaResourceDialect
18335                        );
18336                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSinkSendPacketNoReplyRequest>(&header, _body_bytes, handles, &mut req)?;
18337                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18338                        Ok(StreamSinkRequest::SendPacketNoReply {
18339                            packet: req.packet,
18340
18341                            control_handle,
18342                        })
18343                    }
18344                    0x6180fd6f7e793b71 => {
18345                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18346                        let mut req = fidl::new_empty!(
18347                            fidl::encoding::EmptyPayload,
18348                            fidl::encoding::DefaultFuchsiaResourceDialect
18349                        );
18350                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18351                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18352                        Ok(StreamSinkRequest::EndOfStream { control_handle })
18353                    }
18354                    0x6f4dad7af2917665 => {
18355                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
18356                        let mut req = fidl::new_empty!(
18357                            fidl::encoding::EmptyPayload,
18358                            fidl::encoding::DefaultFuchsiaResourceDialect
18359                        );
18360                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18361                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18362                        Ok(StreamSinkRequest::DiscardAllPackets {
18363                            responder: StreamSinkDiscardAllPacketsResponder {
18364                                control_handle: std::mem::ManuallyDrop::new(control_handle),
18365                                tx_id: header.tx_id,
18366                            },
18367                        })
18368                    }
18369                    0x50d36d0d23081bc4 => {
18370                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
18371                        let mut req = fidl::new_empty!(
18372                            fidl::encoding::EmptyPayload,
18373                            fidl::encoding::DefaultFuchsiaResourceDialect
18374                        );
18375                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
18376                        let control_handle = StreamSinkControlHandle { inner: this.inner.clone() };
18377                        Ok(StreamSinkRequest::DiscardAllPacketsNoReply { control_handle })
18378                    }
18379                    _ => Err(fidl::Error::UnknownOrdinal {
18380                        ordinal: header.ordinal,
18381                        protocol_name:
18382                            <StreamSinkMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18383                    }),
18384                }))
18385            },
18386        )
18387    }
18388}
18389
18390/// Consumes a stream of packets. This interface is typically inherited along
18391/// with `StreamBufferSet` to enable the transport of elementary streams from
18392/// clients to services.
18393#[derive(Debug)]
18394pub enum StreamSinkRequest {
18395    /// Sends a packet to the service. The response is sent when the service is
18396    /// done with the associated payload memory.
18397    ///
18398    /// `packet` must be valid for the current buffer set, otherwise the service
18399    /// will close the connection.
18400    SendPacket { packet: StreamPacket, responder: StreamSinkSendPacketResponder },
18401    /// Sends a packet to the service. This interface doesn't define how the
18402    /// client knows when the sink is done with the associated payload memory.
18403    /// The inheriting interface must define that.
18404    ///
18405    /// `packet` must be valid for the current buffer set, otherwise the service
18406    /// will close the connection.
18407    SendPacketNoReply { packet: StreamPacket, control_handle: StreamSinkControlHandle },
18408    /// Indicates the stream has ended. The precise semantics of this method are
18409    /// determined by the inheriting interface.
18410    EndOfStream { control_handle: StreamSinkControlHandle },
18411    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18412    /// and not yet released. The response is sent after all packets have been
18413    /// released.
18414    DiscardAllPackets { responder: StreamSinkDiscardAllPacketsResponder },
18415    /// Discards packets previously sent via `SendPacket` or `SendPacketNoReply`
18416    /// and not yet released.
18417    DiscardAllPacketsNoReply { control_handle: StreamSinkControlHandle },
18418}
18419
18420impl StreamSinkRequest {
18421    #[allow(irrefutable_let_patterns)]
18422    pub fn into_send_packet(self) -> Option<(StreamPacket, StreamSinkSendPacketResponder)> {
18423        if let StreamSinkRequest::SendPacket { packet, responder } = self {
18424            Some((packet, responder))
18425        } else {
18426            None
18427        }
18428    }
18429
18430    #[allow(irrefutable_let_patterns)]
18431    pub fn into_send_packet_no_reply(self) -> Option<(StreamPacket, StreamSinkControlHandle)> {
18432        if let StreamSinkRequest::SendPacketNoReply { packet, control_handle } = self {
18433            Some((packet, control_handle))
18434        } else {
18435            None
18436        }
18437    }
18438
18439    #[allow(irrefutable_let_patterns)]
18440    pub fn into_end_of_stream(self) -> Option<(StreamSinkControlHandle)> {
18441        if let StreamSinkRequest::EndOfStream { control_handle } = self {
18442            Some((control_handle))
18443        } else {
18444            None
18445        }
18446    }
18447
18448    #[allow(irrefutable_let_patterns)]
18449    pub fn into_discard_all_packets(self) -> Option<(StreamSinkDiscardAllPacketsResponder)> {
18450        if let StreamSinkRequest::DiscardAllPackets { responder } = self {
18451            Some((responder))
18452        } else {
18453            None
18454        }
18455    }
18456
18457    #[allow(irrefutable_let_patterns)]
18458    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSinkControlHandle)> {
18459        if let StreamSinkRequest::DiscardAllPacketsNoReply { control_handle } = self {
18460            Some((control_handle))
18461        } else {
18462            None
18463        }
18464    }
18465
18466    /// Name of the method defined in FIDL
18467    pub fn method_name(&self) -> &'static str {
18468        match *self {
18469            StreamSinkRequest::SendPacket { .. } => "send_packet",
18470            StreamSinkRequest::SendPacketNoReply { .. } => "send_packet_no_reply",
18471            StreamSinkRequest::EndOfStream { .. } => "end_of_stream",
18472            StreamSinkRequest::DiscardAllPackets { .. } => "discard_all_packets",
18473            StreamSinkRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
18474        }
18475    }
18476}
18477
18478#[derive(Debug, Clone)]
18479pub struct StreamSinkControlHandle {
18480    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18481}
18482
18483impl StreamSinkControlHandle {
18484    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
18485        self.inner.shutdown_with_epitaph(status.into())
18486    }
18487}
18488
18489impl fidl::endpoints::ControlHandle for StreamSinkControlHandle {
18490    fn shutdown(&self) {
18491        self.inner.shutdown()
18492    }
18493
18494    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
18495        self.inner.shutdown_with_epitaph(status)
18496    }
18497
18498    fn is_closed(&self) -> bool {
18499        self.inner.channel().is_closed()
18500    }
18501    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
18502        self.inner.channel().on_closed()
18503    }
18504
18505    #[cfg(target_os = "fuchsia")]
18506    fn signal_peer(
18507        &self,
18508        clear_mask: zx::Signals,
18509        set_mask: zx::Signals,
18510    ) -> Result<(), zx_status::Status> {
18511        use fidl::Peered;
18512        self.inner.channel().signal_peer(clear_mask, set_mask)
18513    }
18514}
18515
18516impl StreamSinkControlHandle {}
18517
18518#[must_use = "FIDL methods require a response to be sent"]
18519#[derive(Debug)]
18520pub struct StreamSinkSendPacketResponder {
18521    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
18522    tx_id: u32,
18523}
18524
18525/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
18526/// if the responder is dropped without sending a response, so that the client
18527/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18528impl std::ops::Drop for StreamSinkSendPacketResponder {
18529    fn drop(&mut self) {
18530        self.control_handle.shutdown();
18531        // Safety: drops once, never accessed again
18532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18533    }
18534}
18535
18536impl fidl::endpoints::Responder for StreamSinkSendPacketResponder {
18537    type ControlHandle = StreamSinkControlHandle;
18538
18539    fn control_handle(&self) -> &StreamSinkControlHandle {
18540        &self.control_handle
18541    }
18542
18543    fn drop_without_shutdown(mut self) {
18544        // Safety: drops once, never accessed again due to mem::forget
18545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18546        // Prevent Drop from running (which would shut down the channel)
18547        std::mem::forget(self);
18548    }
18549}
18550
18551impl StreamSinkSendPacketResponder {
18552    /// Sends a response to the FIDL transaction.
18553    ///
18554    /// Sets the channel to shutdown if an error occurs.
18555    pub fn send(self) -> Result<(), fidl::Error> {
18556        let _result = self.send_raw();
18557        if _result.is_err() {
18558            self.control_handle.shutdown();
18559        }
18560        self.drop_without_shutdown();
18561        _result
18562    }
18563
18564    /// Similar to "send" but does not shutdown the channel if an error occurs.
18565    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18566        let _result = self.send_raw();
18567        self.drop_without_shutdown();
18568        _result
18569    }
18570
18571    fn send_raw(&self) -> Result<(), fidl::Error> {
18572        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18573            (),
18574            self.tx_id,
18575            0x67cddd607442775f,
18576            fidl::encoding::DynamicFlags::empty(),
18577        )
18578    }
18579}
18580
18581#[must_use = "FIDL methods require a response to be sent"]
18582#[derive(Debug)]
18583pub struct StreamSinkDiscardAllPacketsResponder {
18584    control_handle: std::mem::ManuallyDrop<StreamSinkControlHandle>,
18585    tx_id: u32,
18586}
18587
18588/// Set the the channel to be shutdown (see [`StreamSinkControlHandle::shutdown`])
18589/// if the responder is dropped without sending a response, so that the client
18590/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
18591impl std::ops::Drop for StreamSinkDiscardAllPacketsResponder {
18592    fn drop(&mut self) {
18593        self.control_handle.shutdown();
18594        // Safety: drops once, never accessed again
18595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18596    }
18597}
18598
18599impl fidl::endpoints::Responder for StreamSinkDiscardAllPacketsResponder {
18600    type ControlHandle = StreamSinkControlHandle;
18601
18602    fn control_handle(&self) -> &StreamSinkControlHandle {
18603        &self.control_handle
18604    }
18605
18606    fn drop_without_shutdown(mut self) {
18607        // Safety: drops once, never accessed again due to mem::forget
18608        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
18609        // Prevent Drop from running (which would shut down the channel)
18610        std::mem::forget(self);
18611    }
18612}
18613
18614impl StreamSinkDiscardAllPacketsResponder {
18615    /// Sends a response to the FIDL transaction.
18616    ///
18617    /// Sets the channel to shutdown if an error occurs.
18618    pub fn send(self) -> Result<(), fidl::Error> {
18619        let _result = self.send_raw();
18620        if _result.is_err() {
18621            self.control_handle.shutdown();
18622        }
18623        self.drop_without_shutdown();
18624        _result
18625    }
18626
18627    /// Similar to "send" but does not shutdown the channel if an error occurs.
18628    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
18629        let _result = self.send_raw();
18630        self.drop_without_shutdown();
18631        _result
18632    }
18633
18634    fn send_raw(&self) -> Result<(), fidl::Error> {
18635        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
18636            (),
18637            self.tx_id,
18638            0x6f4dad7af2917665,
18639            fidl::encoding::DynamicFlags::empty(),
18640        )
18641    }
18642}
18643
18644#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
18645pub struct StreamSourceMarker;
18646
18647impl fidl::endpoints::ProtocolMarker for StreamSourceMarker {
18648    type Proxy = StreamSourceProxy;
18649    type RequestStream = StreamSourceRequestStream;
18650    #[cfg(target_os = "fuchsia")]
18651    type SynchronousProxy = StreamSourceSynchronousProxy;
18652
18653    const DEBUG_NAME: &'static str = "(anonymous) StreamSource";
18654}
18655
18656pub trait StreamSourceProxyInterface: Send + Sync {
18657    fn r#release_packet(&self, packet: &StreamPacket) -> Result<(), fidl::Error>;
18658    type DiscardAllPacketsResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
18659    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut;
18660    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error>;
18661}
18662#[derive(Debug)]
18663#[cfg(target_os = "fuchsia")]
18664pub struct StreamSourceSynchronousProxy {
18665    client: fidl::client::sync::Client,
18666}
18667
18668#[cfg(target_os = "fuchsia")]
18669impl fidl::endpoints::SynchronousProxy for StreamSourceSynchronousProxy {
18670    type Proxy = StreamSourceProxy;
18671    type Protocol = StreamSourceMarker;
18672
18673    fn from_channel(inner: fidl::Channel) -> Self {
18674        Self::new(inner)
18675    }
18676
18677    fn into_channel(self) -> fidl::Channel {
18678        self.client.into_channel()
18679    }
18680
18681    fn as_channel(&self) -> &fidl::Channel {
18682        self.client.as_channel()
18683    }
18684}
18685
18686#[cfg(target_os = "fuchsia")]
18687impl StreamSourceSynchronousProxy {
18688    pub fn new(channel: fidl::Channel) -> Self {
18689        Self { client: fidl::client::sync::Client::new(channel) }
18690    }
18691
18692    pub fn into_channel(self) -> fidl::Channel {
18693        self.client.into_channel()
18694    }
18695
18696    /// Waits until an event arrives and returns it. It is safe for other
18697    /// threads to make concurrent requests while waiting for an event.
18698    pub fn wait_for_event(
18699        &self,
18700        deadline: zx::MonotonicInstant,
18701    ) -> Result<StreamSourceEvent, fidl::Error> {
18702        StreamSourceEvent::decode(self.client.wait_for_event::<StreamSourceMarker>(deadline)?)
18703    }
18704
18705    /// Releases payload memory associated with a packet previously delivered
18706    /// via `OnPacketProduced`.
18707    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18708        self.client.send::<StreamSourceReleasePacketRequest>(
18709            (packet,),
18710            0x7a7b57f0f7d9e4bb,
18711            fidl::encoding::DynamicFlags::empty(),
18712        )
18713    }
18714
18715    pub fn r#discard_all_packets(
18716        &self,
18717        ___deadline: zx::MonotonicInstant,
18718    ) -> Result<(), fidl::Error> {
18719        let _response = self.client.send_query::<
18720            fidl::encoding::EmptyPayload,
18721            fidl::encoding::EmptyPayload,
18722            StreamSourceMarker,
18723        >(
18724            (),
18725            0x27afd605e97b09d2,
18726            fidl::encoding::DynamicFlags::empty(),
18727            ___deadline,
18728        )?;
18729        Ok(_response)
18730    }
18731
18732    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18733        self.client.send::<fidl::encoding::EmptyPayload>(
18734            (),
18735            0x35f9d721e905b831,
18736            fidl::encoding::DynamicFlags::empty(),
18737        )
18738    }
18739}
18740
18741#[cfg(target_os = "fuchsia")]
18742impl From<StreamSourceSynchronousProxy> for zx::NullableHandle {
18743    fn from(value: StreamSourceSynchronousProxy) -> Self {
18744        value.into_channel().into()
18745    }
18746}
18747
18748#[cfg(target_os = "fuchsia")]
18749impl From<fidl::Channel> for StreamSourceSynchronousProxy {
18750    fn from(value: fidl::Channel) -> Self {
18751        Self::new(value)
18752    }
18753}
18754
18755#[cfg(target_os = "fuchsia")]
18756impl fidl::endpoints::FromClient for StreamSourceSynchronousProxy {
18757    type Protocol = StreamSourceMarker;
18758
18759    fn from_client(value: fidl::endpoints::ClientEnd<StreamSourceMarker>) -> Self {
18760        Self::new(value.into_channel())
18761    }
18762}
18763
18764#[derive(Debug, Clone)]
18765pub struct StreamSourceProxy {
18766    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
18767}
18768
18769impl fidl::endpoints::Proxy for StreamSourceProxy {
18770    type Protocol = StreamSourceMarker;
18771
18772    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
18773        Self::new(inner)
18774    }
18775
18776    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
18777        self.client.into_channel().map_err(|client| Self { client })
18778    }
18779
18780    fn as_channel(&self) -> &::fidl::AsyncChannel {
18781        self.client.as_channel()
18782    }
18783}
18784
18785impl StreamSourceProxy {
18786    /// Create a new Proxy for fuchsia.media/StreamSource.
18787    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
18788        let protocol_name = <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
18789        Self { client: fidl::client::Client::new(channel, protocol_name) }
18790    }
18791
18792    /// Get a Stream of events from the remote end of the protocol.
18793    ///
18794    /// # Panics
18795    ///
18796    /// Panics if the event stream was already taken.
18797    pub fn take_event_stream(&self) -> StreamSourceEventStream {
18798        StreamSourceEventStream { event_receiver: self.client.take_event_receiver() }
18799    }
18800
18801    /// Releases payload memory associated with a packet previously delivered
18802    /// via `OnPacketProduced`.
18803    pub fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18804        StreamSourceProxyInterface::r#release_packet(self, packet)
18805    }
18806
18807    pub fn r#discard_all_packets(
18808        &self,
18809    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
18810        StreamSourceProxyInterface::r#discard_all_packets(self)
18811    }
18812
18813    pub fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18814        StreamSourceProxyInterface::r#discard_all_packets_no_reply(self)
18815    }
18816}
18817
18818impl StreamSourceProxyInterface for StreamSourceProxy {
18819    fn r#release_packet(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
18820        self.client.send::<StreamSourceReleasePacketRequest>(
18821            (packet,),
18822            0x7a7b57f0f7d9e4bb,
18823            fidl::encoding::DynamicFlags::empty(),
18824        )
18825    }
18826
18827    type DiscardAllPacketsResponseFut =
18828        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
18829    fn r#discard_all_packets(&self) -> Self::DiscardAllPacketsResponseFut {
18830        fn _decode(
18831            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
18832        ) -> Result<(), fidl::Error> {
18833            let _response = fidl::client::decode_transaction_body::<
18834                fidl::encoding::EmptyPayload,
18835                fidl::encoding::DefaultFuchsiaResourceDialect,
18836                0x27afd605e97b09d2,
18837            >(_buf?)?;
18838            Ok(_response)
18839        }
18840        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
18841            (),
18842            0x27afd605e97b09d2,
18843            fidl::encoding::DynamicFlags::empty(),
18844            _decode,
18845        )
18846    }
18847
18848    fn r#discard_all_packets_no_reply(&self) -> Result<(), fidl::Error> {
18849        self.client.send::<fidl::encoding::EmptyPayload>(
18850            (),
18851            0x35f9d721e905b831,
18852            fidl::encoding::DynamicFlags::empty(),
18853        )
18854    }
18855}
18856
18857pub struct StreamSourceEventStream {
18858    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
18859}
18860
18861impl std::marker::Unpin for StreamSourceEventStream {}
18862
18863impl futures::stream::FusedStream for StreamSourceEventStream {
18864    fn is_terminated(&self) -> bool {
18865        self.event_receiver.is_terminated()
18866    }
18867}
18868
18869impl futures::Stream for StreamSourceEventStream {
18870    type Item = Result<StreamSourceEvent, fidl::Error>;
18871
18872    fn poll_next(
18873        mut self: std::pin::Pin<&mut Self>,
18874        cx: &mut std::task::Context<'_>,
18875    ) -> std::task::Poll<Option<Self::Item>> {
18876        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
18877            &mut self.event_receiver,
18878            cx
18879        )?) {
18880            Some(buf) => std::task::Poll::Ready(Some(StreamSourceEvent::decode(buf))),
18881            None => std::task::Poll::Ready(None),
18882        }
18883    }
18884}
18885
18886#[derive(Debug)]
18887pub enum StreamSourceEvent {
18888    OnPacketProduced { packet: StreamPacket },
18889    OnEndOfStream {},
18890}
18891
18892impl StreamSourceEvent {
18893    #[allow(irrefutable_let_patterns)]
18894    pub fn into_on_packet_produced(self) -> Option<StreamPacket> {
18895        if let StreamSourceEvent::OnPacketProduced { packet } = self {
18896            Some((packet))
18897        } else {
18898            None
18899        }
18900    }
18901    #[allow(irrefutable_let_patterns)]
18902    pub fn into_on_end_of_stream(self) -> Option<()> {
18903        if let StreamSourceEvent::OnEndOfStream {} = self { Some(()) } else { None }
18904    }
18905
18906    /// Decodes a message buffer as a [`StreamSourceEvent`].
18907    fn decode(
18908        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
18909    ) -> Result<StreamSourceEvent, fidl::Error> {
18910        let (bytes, _handles) = buf.split_mut();
18911        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
18912        debug_assert_eq!(tx_header.tx_id, 0);
18913        match tx_header.ordinal {
18914            0x6bbe69746a3c8bd9 => {
18915                let mut out = fidl::new_empty!(
18916                    StreamSourceOnPacketProducedRequest,
18917                    fidl::encoding::DefaultFuchsiaResourceDialect
18918                );
18919                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceOnPacketProducedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
18920                Ok((StreamSourceEvent::OnPacketProduced { packet: out.packet }))
18921            }
18922            0x550e69b41d03e2c2 => {
18923                let mut out = fidl::new_empty!(
18924                    fidl::encoding::EmptyPayload,
18925                    fidl::encoding::DefaultFuchsiaResourceDialect
18926                );
18927                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&tx_header, _body_bytes, _handles, &mut out)?;
18928                Ok((StreamSourceEvent::OnEndOfStream {}))
18929            }
18930            _ => Err(fidl::Error::UnknownOrdinal {
18931                ordinal: tx_header.ordinal,
18932                protocol_name: <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
18933            }),
18934        }
18935    }
18936}
18937
18938/// A Stream of incoming requests for fuchsia.media/StreamSource.
18939pub struct StreamSourceRequestStream {
18940    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18941    is_terminated: bool,
18942}
18943
18944impl std::marker::Unpin for StreamSourceRequestStream {}
18945
18946impl futures::stream::FusedStream for StreamSourceRequestStream {
18947    fn is_terminated(&self) -> bool {
18948        self.is_terminated
18949    }
18950}
18951
18952impl fidl::endpoints::RequestStream for StreamSourceRequestStream {
18953    type Protocol = StreamSourceMarker;
18954    type ControlHandle = StreamSourceControlHandle;
18955
18956    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
18957        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
18958    }
18959
18960    fn control_handle(&self) -> Self::ControlHandle {
18961        StreamSourceControlHandle { inner: self.inner.clone() }
18962    }
18963
18964    fn into_inner(
18965        self,
18966    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
18967    {
18968        (self.inner, self.is_terminated)
18969    }
18970
18971    fn from_inner(
18972        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
18973        is_terminated: bool,
18974    ) -> Self {
18975        Self { inner, is_terminated }
18976    }
18977}
18978
18979impl futures::Stream for StreamSourceRequestStream {
18980    type Item = Result<StreamSourceRequest, fidl::Error>;
18981
18982    fn poll_next(
18983        mut self: std::pin::Pin<&mut Self>,
18984        cx: &mut std::task::Context<'_>,
18985    ) -> std::task::Poll<Option<Self::Item>> {
18986        let this = &mut *self;
18987        if this.inner.check_shutdown(cx) {
18988            this.is_terminated = true;
18989            return std::task::Poll::Ready(None);
18990        }
18991        if this.is_terminated {
18992            panic!("polled StreamSourceRequestStream after completion");
18993        }
18994        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
18995            |bytes, handles| {
18996                match this.inner.channel().read_etc(cx, bytes, handles) {
18997                    std::task::Poll::Ready(Ok(())) => {}
18998                    std::task::Poll::Pending => return std::task::Poll::Pending,
18999                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19000                        this.is_terminated = true;
19001                        return std::task::Poll::Ready(None);
19002                    }
19003                    std::task::Poll::Ready(Err(e)) => {
19004                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19005                            e.into(),
19006                        ))));
19007                    }
19008                }
19009
19010                // A message has been received from the channel
19011                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19012
19013                std::task::Poll::Ready(Some(match header.ordinal {
19014                    0x7a7b57f0f7d9e4bb => {
19015                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19016                        let mut req = fidl::new_empty!(
19017                            StreamSourceReleasePacketRequest,
19018                            fidl::encoding::DefaultFuchsiaResourceDialect
19019                        );
19020                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<StreamSourceReleasePacketRequest>(&header, _body_bytes, handles, &mut req)?;
19021                        let control_handle =
19022                            StreamSourceControlHandle { inner: this.inner.clone() };
19023                        Ok(StreamSourceRequest::ReleasePacket {
19024                            packet: req.packet,
19025
19026                            control_handle,
19027                        })
19028                    }
19029                    0x27afd605e97b09d2 => {
19030                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
19031                        let mut req = fidl::new_empty!(
19032                            fidl::encoding::EmptyPayload,
19033                            fidl::encoding::DefaultFuchsiaResourceDialect
19034                        );
19035                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
19036                        let control_handle =
19037                            StreamSourceControlHandle { inner: this.inner.clone() };
19038                        Ok(StreamSourceRequest::DiscardAllPackets {
19039                            responder: StreamSourceDiscardAllPacketsResponder {
19040                                control_handle: std::mem::ManuallyDrop::new(control_handle),
19041                                tx_id: header.tx_id,
19042                            },
19043                        })
19044                    }
19045                    0x35f9d721e905b831 => {
19046                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19047                        let mut req = fidl::new_empty!(
19048                            fidl::encoding::EmptyPayload,
19049                            fidl::encoding::DefaultFuchsiaResourceDialect
19050                        );
19051                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
19052                        let control_handle =
19053                            StreamSourceControlHandle { inner: this.inner.clone() };
19054                        Ok(StreamSourceRequest::DiscardAllPacketsNoReply { control_handle })
19055                    }
19056                    _ => Err(fidl::Error::UnknownOrdinal {
19057                        ordinal: header.ordinal,
19058                        protocol_name:
19059                            <StreamSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19060                    }),
19061                }))
19062            },
19063        )
19064    }
19065}
19066
19067/// Produces a stream of packets. This interface is typically inherited along
19068/// with `StreamBufferSet` to enable the transport of elementary streams from
19069/// services to clients.
19070#[derive(Debug)]
19071pub enum StreamSourceRequest {
19072    /// Releases payload memory associated with a packet previously delivered
19073    /// via `OnPacketProduced`.
19074    ReleasePacket {
19075        packet: StreamPacket,
19076        control_handle: StreamSourceControlHandle,
19077    },
19078    DiscardAllPackets {
19079        responder: StreamSourceDiscardAllPacketsResponder,
19080    },
19081    DiscardAllPacketsNoReply {
19082        control_handle: StreamSourceControlHandle,
19083    },
19084}
19085
19086impl StreamSourceRequest {
19087    #[allow(irrefutable_let_patterns)]
19088    pub fn into_release_packet(self) -> Option<(StreamPacket, StreamSourceControlHandle)> {
19089        if let StreamSourceRequest::ReleasePacket { packet, control_handle } = self {
19090            Some((packet, control_handle))
19091        } else {
19092            None
19093        }
19094    }
19095
19096    #[allow(irrefutable_let_patterns)]
19097    pub fn into_discard_all_packets(self) -> Option<(StreamSourceDiscardAllPacketsResponder)> {
19098        if let StreamSourceRequest::DiscardAllPackets { responder } = self {
19099            Some((responder))
19100        } else {
19101            None
19102        }
19103    }
19104
19105    #[allow(irrefutable_let_patterns)]
19106    pub fn into_discard_all_packets_no_reply(self) -> Option<(StreamSourceControlHandle)> {
19107        if let StreamSourceRequest::DiscardAllPacketsNoReply { control_handle } = self {
19108            Some((control_handle))
19109        } else {
19110            None
19111        }
19112    }
19113
19114    /// Name of the method defined in FIDL
19115    pub fn method_name(&self) -> &'static str {
19116        match *self {
19117            StreamSourceRequest::ReleasePacket { .. } => "release_packet",
19118            StreamSourceRequest::DiscardAllPackets { .. } => "discard_all_packets",
19119            StreamSourceRequest::DiscardAllPacketsNoReply { .. } => "discard_all_packets_no_reply",
19120        }
19121    }
19122}
19123
19124#[derive(Debug, Clone)]
19125pub struct StreamSourceControlHandle {
19126    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19127}
19128
19129impl StreamSourceControlHandle {
19130    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
19131        self.inner.shutdown_with_epitaph(status.into())
19132    }
19133}
19134
19135impl fidl::endpoints::ControlHandle for StreamSourceControlHandle {
19136    fn shutdown(&self) {
19137        self.inner.shutdown()
19138    }
19139
19140    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
19141        self.inner.shutdown_with_epitaph(status)
19142    }
19143
19144    fn is_closed(&self) -> bool {
19145        self.inner.channel().is_closed()
19146    }
19147    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19148        self.inner.channel().on_closed()
19149    }
19150
19151    #[cfg(target_os = "fuchsia")]
19152    fn signal_peer(
19153        &self,
19154        clear_mask: zx::Signals,
19155        set_mask: zx::Signals,
19156    ) -> Result<(), zx_status::Status> {
19157        use fidl::Peered;
19158        self.inner.channel().signal_peer(clear_mask, set_mask)
19159    }
19160}
19161
19162impl StreamSourceControlHandle {
19163    pub fn send_on_packet_produced(&self, mut packet: &StreamPacket) -> Result<(), fidl::Error> {
19164        self.inner.send::<StreamSourceOnPacketProducedRequest>(
19165            (packet,),
19166            0,
19167            0x6bbe69746a3c8bd9,
19168            fidl::encoding::DynamicFlags::empty(),
19169        )
19170    }
19171
19172    pub fn send_on_end_of_stream(&self) -> Result<(), fidl::Error> {
19173        self.inner.send::<fidl::encoding::EmptyPayload>(
19174            (),
19175            0,
19176            0x550e69b41d03e2c2,
19177            fidl::encoding::DynamicFlags::empty(),
19178        )
19179    }
19180}
19181
19182#[must_use = "FIDL methods require a response to be sent"]
19183#[derive(Debug)]
19184pub struct StreamSourceDiscardAllPacketsResponder {
19185    control_handle: std::mem::ManuallyDrop<StreamSourceControlHandle>,
19186    tx_id: u32,
19187}
19188
19189/// Set the the channel to be shutdown (see [`StreamSourceControlHandle::shutdown`])
19190/// if the responder is dropped without sending a response, so that the client
19191/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
19192impl std::ops::Drop for StreamSourceDiscardAllPacketsResponder {
19193    fn drop(&mut self) {
19194        self.control_handle.shutdown();
19195        // Safety: drops once, never accessed again
19196        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19197    }
19198}
19199
19200impl fidl::endpoints::Responder for StreamSourceDiscardAllPacketsResponder {
19201    type ControlHandle = StreamSourceControlHandle;
19202
19203    fn control_handle(&self) -> &StreamSourceControlHandle {
19204        &self.control_handle
19205    }
19206
19207    fn drop_without_shutdown(mut self) {
19208        // Safety: drops once, never accessed again due to mem::forget
19209        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
19210        // Prevent Drop from running (which would shut down the channel)
19211        std::mem::forget(self);
19212    }
19213}
19214
19215impl StreamSourceDiscardAllPacketsResponder {
19216    /// Sends a response to the FIDL transaction.
19217    ///
19218    /// Sets the channel to shutdown if an error occurs.
19219    pub fn send(self) -> Result<(), fidl::Error> {
19220        let _result = self.send_raw();
19221        if _result.is_err() {
19222            self.control_handle.shutdown();
19223        }
19224        self.drop_without_shutdown();
19225        _result
19226    }
19227
19228    /// Similar to "send" but does not shutdown the channel if an error occurs.
19229    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
19230        let _result = self.send_raw();
19231        self.drop_without_shutdown();
19232        _result
19233    }
19234
19235    fn send_raw(&self) -> Result<(), fidl::Error> {
19236        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
19237            (),
19238            self.tx_id,
19239            0x27afd605e97b09d2,
19240            fidl::encoding::DynamicFlags::empty(),
19241        )
19242    }
19243}
19244
19245#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19246pub struct Usage2AudioConsumerFactoryMarker;
19247
19248impl fidl::endpoints::ProtocolMarker for Usage2AudioConsumerFactoryMarker {
19249    type Proxy = Usage2AudioConsumerFactoryProxy;
19250    type RequestStream = Usage2AudioConsumerFactoryRequestStream;
19251    #[cfg(target_os = "fuchsia")]
19252    type SynchronousProxy = Usage2AudioConsumerFactorySynchronousProxy;
19253
19254    const DEBUG_NAME: &'static str = "fuchsia.media.Usage2AudioConsumerFactory";
19255}
19256impl fidl::endpoints::DiscoverableProtocolMarker for Usage2AudioConsumerFactoryMarker {}
19257
19258pub trait Usage2AudioConsumerFactoryProxyInterface: Send + Sync {
19259    fn r#create_audio_consumer(
19260        &self,
19261        usage: AudioRenderUsage2,
19262        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19263    ) -> Result<(), fidl::Error>;
19264}
19265#[derive(Debug)]
19266#[cfg(target_os = "fuchsia")]
19267pub struct Usage2AudioConsumerFactorySynchronousProxy {
19268    client: fidl::client::sync::Client,
19269}
19270
19271#[cfg(target_os = "fuchsia")]
19272impl fidl::endpoints::SynchronousProxy for Usage2AudioConsumerFactorySynchronousProxy {
19273    type Proxy = Usage2AudioConsumerFactoryProxy;
19274    type Protocol = Usage2AudioConsumerFactoryMarker;
19275
19276    fn from_channel(inner: fidl::Channel) -> Self {
19277        Self::new(inner)
19278    }
19279
19280    fn into_channel(self) -> fidl::Channel {
19281        self.client.into_channel()
19282    }
19283
19284    fn as_channel(&self) -> &fidl::Channel {
19285        self.client.as_channel()
19286    }
19287}
19288
19289#[cfg(target_os = "fuchsia")]
19290impl Usage2AudioConsumerFactorySynchronousProxy {
19291    pub fn new(channel: fidl::Channel) -> Self {
19292        Self { client: fidl::client::sync::Client::new(channel) }
19293    }
19294
19295    pub fn into_channel(self) -> fidl::Channel {
19296        self.client.into_channel()
19297    }
19298
19299    /// Waits until an event arrives and returns it. It is safe for other
19300    /// threads to make concurrent requests while waiting for an event.
19301    pub fn wait_for_event(
19302        &self,
19303        deadline: zx::MonotonicInstant,
19304    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
19305        Usage2AudioConsumerFactoryEvent::decode(
19306            self.client.wait_for_event::<Usage2AudioConsumerFactoryMarker>(deadline)?,
19307        )
19308    }
19309
19310    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
19311    /// Audio submitted to such a consumer is always rendered locally.
19312    pub fn r#create_audio_consumer(
19313        &self,
19314        mut usage: AudioRenderUsage2,
19315        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19316    ) -> Result<(), fidl::Error> {
19317        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
19318            (usage, audio_consumer_request),
19319            0x767722302a171873,
19320            fidl::encoding::DynamicFlags::FLEXIBLE,
19321        )
19322    }
19323}
19324
19325#[cfg(target_os = "fuchsia")]
19326impl From<Usage2AudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
19327    fn from(value: Usage2AudioConsumerFactorySynchronousProxy) -> Self {
19328        value.into_channel().into()
19329    }
19330}
19331
19332#[cfg(target_os = "fuchsia")]
19333impl From<fidl::Channel> for Usage2AudioConsumerFactorySynchronousProxy {
19334    fn from(value: fidl::Channel) -> Self {
19335        Self::new(value)
19336    }
19337}
19338
19339#[cfg(target_os = "fuchsia")]
19340impl fidl::endpoints::FromClient for Usage2AudioConsumerFactorySynchronousProxy {
19341    type Protocol = Usage2AudioConsumerFactoryMarker;
19342
19343    fn from_client(value: fidl::endpoints::ClientEnd<Usage2AudioConsumerFactoryMarker>) -> Self {
19344        Self::new(value.into_channel())
19345    }
19346}
19347
19348#[derive(Debug, Clone)]
19349pub struct Usage2AudioConsumerFactoryProxy {
19350    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19351}
19352
19353impl fidl::endpoints::Proxy for Usage2AudioConsumerFactoryProxy {
19354    type Protocol = Usage2AudioConsumerFactoryMarker;
19355
19356    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19357        Self::new(inner)
19358    }
19359
19360    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19361        self.client.into_channel().map_err(|client| Self { client })
19362    }
19363
19364    fn as_channel(&self) -> &::fidl::AsyncChannel {
19365        self.client.as_channel()
19366    }
19367}
19368
19369impl Usage2AudioConsumerFactoryProxy {
19370    /// Create a new Proxy for fuchsia.media/Usage2AudioConsumerFactory.
19371    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19372        let protocol_name =
19373            <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19374        Self { client: fidl::client::Client::new(channel, protocol_name) }
19375    }
19376
19377    /// Get a Stream of events from the remote end of the protocol.
19378    ///
19379    /// # Panics
19380    ///
19381    /// Panics if the event stream was already taken.
19382    pub fn take_event_stream(&self) -> Usage2AudioConsumerFactoryEventStream {
19383        Usage2AudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
19384    }
19385
19386    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
19387    /// Audio submitted to such a consumer is always rendered locally.
19388    pub fn r#create_audio_consumer(
19389        &self,
19390        mut usage: AudioRenderUsage2,
19391        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19392    ) -> Result<(), fidl::Error> {
19393        Usage2AudioConsumerFactoryProxyInterface::r#create_audio_consumer(
19394            self,
19395            usage,
19396            audio_consumer_request,
19397        )
19398    }
19399}
19400
19401impl Usage2AudioConsumerFactoryProxyInterface for Usage2AudioConsumerFactoryProxy {
19402    fn r#create_audio_consumer(
19403        &self,
19404        mut usage: AudioRenderUsage2,
19405        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19406    ) -> Result<(), fidl::Error> {
19407        self.client.send::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(
19408            (usage, audio_consumer_request),
19409            0x767722302a171873,
19410            fidl::encoding::DynamicFlags::FLEXIBLE,
19411        )
19412    }
19413}
19414
19415pub struct Usage2AudioConsumerFactoryEventStream {
19416    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19417}
19418
19419impl std::marker::Unpin for Usage2AudioConsumerFactoryEventStream {}
19420
19421impl futures::stream::FusedStream for Usage2AudioConsumerFactoryEventStream {
19422    fn is_terminated(&self) -> bool {
19423        self.event_receiver.is_terminated()
19424    }
19425}
19426
19427impl futures::Stream for Usage2AudioConsumerFactoryEventStream {
19428    type Item = Result<Usage2AudioConsumerFactoryEvent, fidl::Error>;
19429
19430    fn poll_next(
19431        mut self: std::pin::Pin<&mut Self>,
19432        cx: &mut std::task::Context<'_>,
19433    ) -> std::task::Poll<Option<Self::Item>> {
19434        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19435            &mut self.event_receiver,
19436            cx
19437        )?) {
19438            Some(buf) => std::task::Poll::Ready(Some(Usage2AudioConsumerFactoryEvent::decode(buf))),
19439            None => std::task::Poll::Ready(None),
19440        }
19441    }
19442}
19443
19444#[derive(Debug)]
19445pub enum Usage2AudioConsumerFactoryEvent {
19446    #[non_exhaustive]
19447    _UnknownEvent {
19448        /// Ordinal of the event that was sent.
19449        ordinal: u64,
19450    },
19451}
19452
19453impl Usage2AudioConsumerFactoryEvent {
19454    /// Decodes a message buffer as a [`Usage2AudioConsumerFactoryEvent`].
19455    fn decode(
19456        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19457    ) -> Result<Usage2AudioConsumerFactoryEvent, fidl::Error> {
19458        let (bytes, _handles) = buf.split_mut();
19459        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19460        debug_assert_eq!(tx_header.tx_id, 0);
19461        match tx_header.ordinal {
19462            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19463                Ok(Usage2AudioConsumerFactoryEvent::_UnknownEvent {
19464                    ordinal: tx_header.ordinal,
19465                })
19466            }
19467            _ => Err(fidl::Error::UnknownOrdinal {
19468                ordinal: tx_header.ordinal,
19469                protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19470            })
19471        }
19472    }
19473}
19474
19475/// A Stream of incoming requests for fuchsia.media/Usage2AudioConsumerFactory.
19476pub struct Usage2AudioConsumerFactoryRequestStream {
19477    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19478    is_terminated: bool,
19479}
19480
19481impl std::marker::Unpin for Usage2AudioConsumerFactoryRequestStream {}
19482
19483impl futures::stream::FusedStream for Usage2AudioConsumerFactoryRequestStream {
19484    fn is_terminated(&self) -> bool {
19485        self.is_terminated
19486    }
19487}
19488
19489impl fidl::endpoints::RequestStream for Usage2AudioConsumerFactoryRequestStream {
19490    type Protocol = Usage2AudioConsumerFactoryMarker;
19491    type ControlHandle = Usage2AudioConsumerFactoryControlHandle;
19492
19493    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19494        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19495    }
19496
19497    fn control_handle(&self) -> Self::ControlHandle {
19498        Usage2AudioConsumerFactoryControlHandle { inner: self.inner.clone() }
19499    }
19500
19501    fn into_inner(
19502        self,
19503    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19504    {
19505        (self.inner, self.is_terminated)
19506    }
19507
19508    fn from_inner(
19509        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19510        is_terminated: bool,
19511    ) -> Self {
19512        Self { inner, is_terminated }
19513    }
19514}
19515
19516impl futures::Stream for Usage2AudioConsumerFactoryRequestStream {
19517    type Item = Result<Usage2AudioConsumerFactoryRequest, fidl::Error>;
19518
19519    fn poll_next(
19520        mut self: std::pin::Pin<&mut Self>,
19521        cx: &mut std::task::Context<'_>,
19522    ) -> std::task::Poll<Option<Self::Item>> {
19523        let this = &mut *self;
19524        if this.inner.check_shutdown(cx) {
19525            this.is_terminated = true;
19526            return std::task::Poll::Ready(None);
19527        }
19528        if this.is_terminated {
19529            panic!("polled Usage2AudioConsumerFactoryRequestStream after completion");
19530        }
19531        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19532            |bytes, handles| {
19533                match this.inner.channel().read_etc(cx, bytes, handles) {
19534                    std::task::Poll::Ready(Ok(())) => {}
19535                    std::task::Poll::Pending => return std::task::Poll::Pending,
19536                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19537                        this.is_terminated = true;
19538                        return std::task::Poll::Ready(None);
19539                    }
19540                    std::task::Poll::Ready(Err(e)) => {
19541                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19542                            e.into(),
19543                        ))));
19544                    }
19545                }
19546
19547                // A message has been received from the channel
19548                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19549
19550                std::task::Poll::Ready(Some(match header.ordinal {
19551                0x767722302a171873 => {
19552                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19553                    let mut req = fidl::new_empty!(Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
19554                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
19555                    let control_handle = Usage2AudioConsumerFactoryControlHandle {
19556                        inner: this.inner.clone(),
19557                    };
19558                    Ok(Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
19559audio_consumer_request: req.audio_consumer_request,
19560
19561                        control_handle,
19562                    })
19563                }
19564                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19565                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19566                        ordinal: header.ordinal,
19567                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
19568                        method_type: fidl::MethodType::OneWay,
19569                    })
19570                }
19571                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
19572                    this.inner.send_framework_err(
19573                        fidl::encoding::FrameworkErr::UnknownMethod,
19574                        header.tx_id,
19575                        header.ordinal,
19576                        header.dynamic_flags(),
19577                        (bytes, handles),
19578                    )?;
19579                    Ok(Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19580                        ordinal: header.ordinal,
19581                        control_handle: Usage2AudioConsumerFactoryControlHandle { inner: this.inner.clone() },
19582                        method_type: fidl::MethodType::TwoWay,
19583                    })
19584                }
19585                _ => Err(fidl::Error::UnknownOrdinal {
19586                    ordinal: header.ordinal,
19587                    protocol_name: <Usage2AudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19588                }),
19589            }))
19590            },
19591        )
19592    }
19593}
19594
19595/// Interface for creating audio consumers for local rendering.
19596#[derive(Debug)]
19597pub enum Usage2AudioConsumerFactoryRequest {
19598    /// Creates an `AudioConsumer`, which is an interface for playing audio, given a usage value.
19599    /// Audio submitted to such a consumer is always rendered locally.
19600    CreateAudioConsumer {
19601        usage: AudioRenderUsage2,
19602        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19603        control_handle: Usage2AudioConsumerFactoryControlHandle,
19604    },
19605    /// An interaction was received which does not match any known method.
19606    #[non_exhaustive]
19607    _UnknownMethod {
19608        /// Ordinal of the method that was called.
19609        ordinal: u64,
19610        control_handle: Usage2AudioConsumerFactoryControlHandle,
19611        method_type: fidl::MethodType,
19612    },
19613}
19614
19615impl Usage2AudioConsumerFactoryRequest {
19616    #[allow(irrefutable_let_patterns)]
19617    pub fn into_create_audio_consumer(
19618        self,
19619    ) -> Option<(
19620        AudioRenderUsage2,
19621        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19622        Usage2AudioConsumerFactoryControlHandle,
19623    )> {
19624        if let Usage2AudioConsumerFactoryRequest::CreateAudioConsumer {
19625            usage,
19626            audio_consumer_request,
19627            control_handle,
19628        } = self
19629        {
19630            Some((usage, audio_consumer_request, control_handle))
19631        } else {
19632            None
19633        }
19634    }
19635
19636    /// Name of the method defined in FIDL
19637    pub fn method_name(&self) -> &'static str {
19638        match *self {
19639            Usage2AudioConsumerFactoryRequest::CreateAudioConsumer { .. } => {
19640                "create_audio_consumer"
19641            }
19642            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19643                method_type: fidl::MethodType::OneWay,
19644                ..
19645            } => "unknown one-way method",
19646            Usage2AudioConsumerFactoryRequest::_UnknownMethod {
19647                method_type: fidl::MethodType::TwoWay,
19648                ..
19649            } => "unknown two-way method",
19650        }
19651    }
19652}
19653
19654#[derive(Debug, Clone)]
19655pub struct Usage2AudioConsumerFactoryControlHandle {
19656    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19657}
19658
19659impl Usage2AudioConsumerFactoryControlHandle {
19660    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
19661        self.inner.shutdown_with_epitaph(status.into())
19662    }
19663}
19664
19665impl fidl::endpoints::ControlHandle for Usage2AudioConsumerFactoryControlHandle {
19666    fn shutdown(&self) {
19667        self.inner.shutdown()
19668    }
19669
19670    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
19671        self.inner.shutdown_with_epitaph(status)
19672    }
19673
19674    fn is_closed(&self) -> bool {
19675        self.inner.channel().is_closed()
19676    }
19677    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
19678        self.inner.channel().on_closed()
19679    }
19680
19681    #[cfg(target_os = "fuchsia")]
19682    fn signal_peer(
19683        &self,
19684        clear_mask: zx::Signals,
19685        set_mask: zx::Signals,
19686    ) -> Result<(), zx_status::Status> {
19687        use fidl::Peered;
19688        self.inner.channel().signal_peer(clear_mask, set_mask)
19689    }
19690}
19691
19692impl Usage2AudioConsumerFactoryControlHandle {}
19693
19694#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
19695pub struct UsageAudioConsumerFactoryMarker;
19696
19697impl fidl::endpoints::ProtocolMarker for UsageAudioConsumerFactoryMarker {
19698    type Proxy = UsageAudioConsumerFactoryProxy;
19699    type RequestStream = UsageAudioConsumerFactoryRequestStream;
19700    #[cfg(target_os = "fuchsia")]
19701    type SynchronousProxy = UsageAudioConsumerFactorySynchronousProxy;
19702
19703    const DEBUG_NAME: &'static str = "fuchsia.media.UsageAudioConsumerFactory";
19704}
19705impl fidl::endpoints::DiscoverableProtocolMarker for UsageAudioConsumerFactoryMarker {}
19706
19707pub trait UsageAudioConsumerFactoryProxyInterface: Send + Sync {
19708    fn r#create_audio_consumer(
19709        &self,
19710        usage: AudioRenderUsage,
19711        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19712    ) -> Result<(), fidl::Error>;
19713}
19714#[derive(Debug)]
19715#[cfg(target_os = "fuchsia")]
19716pub struct UsageAudioConsumerFactorySynchronousProxy {
19717    client: fidl::client::sync::Client,
19718}
19719
19720#[cfg(target_os = "fuchsia")]
19721impl fidl::endpoints::SynchronousProxy for UsageAudioConsumerFactorySynchronousProxy {
19722    type Proxy = UsageAudioConsumerFactoryProxy;
19723    type Protocol = UsageAudioConsumerFactoryMarker;
19724
19725    fn from_channel(inner: fidl::Channel) -> Self {
19726        Self::new(inner)
19727    }
19728
19729    fn into_channel(self) -> fidl::Channel {
19730        self.client.into_channel()
19731    }
19732
19733    fn as_channel(&self) -> &fidl::Channel {
19734        self.client.as_channel()
19735    }
19736}
19737
19738#[cfg(target_os = "fuchsia")]
19739impl UsageAudioConsumerFactorySynchronousProxy {
19740    pub fn new(channel: fidl::Channel) -> Self {
19741        Self { client: fidl::client::sync::Client::new(channel) }
19742    }
19743
19744    pub fn into_channel(self) -> fidl::Channel {
19745        self.client.into_channel()
19746    }
19747
19748    /// Waits until an event arrives and returns it. It is safe for other
19749    /// threads to make concurrent requests while waiting for an event.
19750    pub fn wait_for_event(
19751        &self,
19752        deadline: zx::MonotonicInstant,
19753    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
19754        UsageAudioConsumerFactoryEvent::decode(
19755            self.client.wait_for_event::<UsageAudioConsumerFactoryMarker>(deadline)?,
19756        )
19757    }
19758
19759    pub fn r#create_audio_consumer(
19760        &self,
19761        mut usage: AudioRenderUsage,
19762        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19763    ) -> Result<(), fidl::Error> {
19764        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
19765            (usage, audio_consumer_request),
19766            0x4d975ca9b8f625a3,
19767            fidl::encoding::DynamicFlags::empty(),
19768        )
19769    }
19770}
19771
19772#[cfg(target_os = "fuchsia")]
19773impl From<UsageAudioConsumerFactorySynchronousProxy> for zx::NullableHandle {
19774    fn from(value: UsageAudioConsumerFactorySynchronousProxy) -> Self {
19775        value.into_channel().into()
19776    }
19777}
19778
19779#[cfg(target_os = "fuchsia")]
19780impl From<fidl::Channel> for UsageAudioConsumerFactorySynchronousProxy {
19781    fn from(value: fidl::Channel) -> Self {
19782        Self::new(value)
19783    }
19784}
19785
19786#[cfg(target_os = "fuchsia")]
19787impl fidl::endpoints::FromClient for UsageAudioConsumerFactorySynchronousProxy {
19788    type Protocol = UsageAudioConsumerFactoryMarker;
19789
19790    fn from_client(value: fidl::endpoints::ClientEnd<UsageAudioConsumerFactoryMarker>) -> Self {
19791        Self::new(value.into_channel())
19792    }
19793}
19794
19795#[derive(Debug, Clone)]
19796pub struct UsageAudioConsumerFactoryProxy {
19797    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
19798}
19799
19800impl fidl::endpoints::Proxy for UsageAudioConsumerFactoryProxy {
19801    type Protocol = UsageAudioConsumerFactoryMarker;
19802
19803    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
19804        Self::new(inner)
19805    }
19806
19807    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
19808        self.client.into_channel().map_err(|client| Self { client })
19809    }
19810
19811    fn as_channel(&self) -> &::fidl::AsyncChannel {
19812        self.client.as_channel()
19813    }
19814}
19815
19816impl UsageAudioConsumerFactoryProxy {
19817    /// Create a new Proxy for fuchsia.media/UsageAudioConsumerFactory.
19818    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
19819        let protocol_name =
19820            <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
19821        Self { client: fidl::client::Client::new(channel, protocol_name) }
19822    }
19823
19824    /// Get a Stream of events from the remote end of the protocol.
19825    ///
19826    /// # Panics
19827    ///
19828    /// Panics if the event stream was already taken.
19829    pub fn take_event_stream(&self) -> UsageAudioConsumerFactoryEventStream {
19830        UsageAudioConsumerFactoryEventStream { event_receiver: self.client.take_event_receiver() }
19831    }
19832
19833    pub fn r#create_audio_consumer(
19834        &self,
19835        mut usage: AudioRenderUsage,
19836        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19837    ) -> Result<(), fidl::Error> {
19838        UsageAudioConsumerFactoryProxyInterface::r#create_audio_consumer(
19839            self,
19840            usage,
19841            audio_consumer_request,
19842        )
19843    }
19844}
19845
19846impl UsageAudioConsumerFactoryProxyInterface for UsageAudioConsumerFactoryProxy {
19847    fn r#create_audio_consumer(
19848        &self,
19849        mut usage: AudioRenderUsage,
19850        mut audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
19851    ) -> Result<(), fidl::Error> {
19852        self.client.send::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(
19853            (usage, audio_consumer_request),
19854            0x4d975ca9b8f625a3,
19855            fidl::encoding::DynamicFlags::empty(),
19856        )
19857    }
19858}
19859
19860pub struct UsageAudioConsumerFactoryEventStream {
19861    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
19862}
19863
19864impl std::marker::Unpin for UsageAudioConsumerFactoryEventStream {}
19865
19866impl futures::stream::FusedStream for UsageAudioConsumerFactoryEventStream {
19867    fn is_terminated(&self) -> bool {
19868        self.event_receiver.is_terminated()
19869    }
19870}
19871
19872impl futures::Stream for UsageAudioConsumerFactoryEventStream {
19873    type Item = Result<UsageAudioConsumerFactoryEvent, fidl::Error>;
19874
19875    fn poll_next(
19876        mut self: std::pin::Pin<&mut Self>,
19877        cx: &mut std::task::Context<'_>,
19878    ) -> std::task::Poll<Option<Self::Item>> {
19879        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
19880            &mut self.event_receiver,
19881            cx
19882        )?) {
19883            Some(buf) => std::task::Poll::Ready(Some(UsageAudioConsumerFactoryEvent::decode(buf))),
19884            None => std::task::Poll::Ready(None),
19885        }
19886    }
19887}
19888
19889#[derive(Debug)]
19890pub enum UsageAudioConsumerFactoryEvent {}
19891
19892impl UsageAudioConsumerFactoryEvent {
19893    /// Decodes a message buffer as a [`UsageAudioConsumerFactoryEvent`].
19894    fn decode(
19895        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
19896    ) -> Result<UsageAudioConsumerFactoryEvent, fidl::Error> {
19897        let (bytes, _handles) = buf.split_mut();
19898        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19899        debug_assert_eq!(tx_header.tx_id, 0);
19900        match tx_header.ordinal {
19901            _ => Err(fidl::Error::UnknownOrdinal {
19902                ordinal: tx_header.ordinal,
19903                protocol_name:
19904                    <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
19905            }),
19906        }
19907    }
19908}
19909
19910/// A Stream of incoming requests for fuchsia.media/UsageAudioConsumerFactory.
19911pub struct UsageAudioConsumerFactoryRequestStream {
19912    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19913    is_terminated: bool,
19914}
19915
19916impl std::marker::Unpin for UsageAudioConsumerFactoryRequestStream {}
19917
19918impl futures::stream::FusedStream for UsageAudioConsumerFactoryRequestStream {
19919    fn is_terminated(&self) -> bool {
19920        self.is_terminated
19921    }
19922}
19923
19924impl fidl::endpoints::RequestStream for UsageAudioConsumerFactoryRequestStream {
19925    type Protocol = UsageAudioConsumerFactoryMarker;
19926    type ControlHandle = UsageAudioConsumerFactoryControlHandle;
19927
19928    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
19929        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
19930    }
19931
19932    fn control_handle(&self) -> Self::ControlHandle {
19933        UsageAudioConsumerFactoryControlHandle { inner: self.inner.clone() }
19934    }
19935
19936    fn into_inner(
19937        self,
19938    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
19939    {
19940        (self.inner, self.is_terminated)
19941    }
19942
19943    fn from_inner(
19944        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
19945        is_terminated: bool,
19946    ) -> Self {
19947        Self { inner, is_terminated }
19948    }
19949}
19950
19951impl futures::Stream for UsageAudioConsumerFactoryRequestStream {
19952    type Item = Result<UsageAudioConsumerFactoryRequest, fidl::Error>;
19953
19954    fn poll_next(
19955        mut self: std::pin::Pin<&mut Self>,
19956        cx: &mut std::task::Context<'_>,
19957    ) -> std::task::Poll<Option<Self::Item>> {
19958        let this = &mut *self;
19959        if this.inner.check_shutdown(cx) {
19960            this.is_terminated = true;
19961            return std::task::Poll::Ready(None);
19962        }
19963        if this.is_terminated {
19964            panic!("polled UsageAudioConsumerFactoryRequestStream after completion");
19965        }
19966        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
19967            |bytes, handles| {
19968                match this.inner.channel().read_etc(cx, bytes, handles) {
19969                    std::task::Poll::Ready(Ok(())) => {}
19970                    std::task::Poll::Pending => return std::task::Poll::Pending,
19971                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
19972                        this.is_terminated = true;
19973                        return std::task::Poll::Ready(None);
19974                    }
19975                    std::task::Poll::Ready(Err(e)) => {
19976                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
19977                            e.into(),
19978                        ))));
19979                    }
19980                }
19981
19982                // A message has been received from the channel
19983                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
19984
19985                std::task::Poll::Ready(Some(match header.ordinal {
19986                0x4d975ca9b8f625a3 => {
19987                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
19988                    let mut req = fidl::new_empty!(UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
19989                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(&header, _body_bytes, handles, &mut req)?;
19990                    let control_handle = UsageAudioConsumerFactoryControlHandle {
19991                        inner: this.inner.clone(),
19992                    };
19993                    Ok(UsageAudioConsumerFactoryRequest::CreateAudioConsumer {usage: req.usage,
19994audio_consumer_request: req.audio_consumer_request,
19995
19996                        control_handle,
19997                    })
19998                }
19999                _ => Err(fidl::Error::UnknownOrdinal {
20000                    ordinal: header.ordinal,
20001                    protocol_name: <UsageAudioConsumerFactoryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20002                }),
20003            }))
20004            },
20005        )
20006    }
20007}
20008
20009/// Interface for creating audio consumers for local rendering.
20010#[derive(Debug)]
20011pub enum UsageAudioConsumerFactoryRequest {
20012    CreateAudioConsumer {
20013        usage: AudioRenderUsage,
20014        audio_consumer_request: fidl::endpoints::ServerEnd<AudioConsumerMarker>,
20015        control_handle: UsageAudioConsumerFactoryControlHandle,
20016    },
20017}
20018
20019impl UsageAudioConsumerFactoryRequest {
20020    #[allow(irrefutable_let_patterns)]
20021    pub fn into_create_audio_consumer(
20022        self,
20023    ) -> Option<(
20024        AudioRenderUsage,
20025        fidl::endpoints::ServerEnd<AudioConsumerMarker>,
20026        UsageAudioConsumerFactoryControlHandle,
20027    )> {
20028        if let UsageAudioConsumerFactoryRequest::CreateAudioConsumer {
20029            usage,
20030            audio_consumer_request,
20031            control_handle,
20032        } = self
20033        {
20034            Some((usage, audio_consumer_request, control_handle))
20035        } else {
20036            None
20037        }
20038    }
20039
20040    /// Name of the method defined in FIDL
20041    pub fn method_name(&self) -> &'static str {
20042        match *self {
20043            UsageAudioConsumerFactoryRequest::CreateAudioConsumer { .. } => "create_audio_consumer",
20044        }
20045    }
20046}
20047
20048#[derive(Debug, Clone)]
20049pub struct UsageAudioConsumerFactoryControlHandle {
20050    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20051}
20052
20053impl UsageAudioConsumerFactoryControlHandle {
20054    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
20055        self.inner.shutdown_with_epitaph(status.into())
20056    }
20057}
20058
20059impl fidl::endpoints::ControlHandle for UsageAudioConsumerFactoryControlHandle {
20060    fn shutdown(&self) {
20061        self.inner.shutdown()
20062    }
20063
20064    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
20065        self.inner.shutdown_with_epitaph(status)
20066    }
20067
20068    fn is_closed(&self) -> bool {
20069        self.inner.channel().is_closed()
20070    }
20071    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20072        self.inner.channel().on_closed()
20073    }
20074
20075    #[cfg(target_os = "fuchsia")]
20076    fn signal_peer(
20077        &self,
20078        clear_mask: zx::Signals,
20079        set_mask: zx::Signals,
20080    ) -> Result<(), zx_status::Status> {
20081        use fidl::Peered;
20082        self.inner.channel().signal_peer(clear_mask, set_mask)
20083    }
20084}
20085
20086impl UsageAudioConsumerFactoryControlHandle {}
20087
20088#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
20089pub struct UsageGainListenerMarker;
20090
20091impl fidl::endpoints::ProtocolMarker for UsageGainListenerMarker {
20092    type Proxy = UsageGainListenerProxy;
20093    type RequestStream = UsageGainListenerRequestStream;
20094    #[cfg(target_os = "fuchsia")]
20095    type SynchronousProxy = UsageGainListenerSynchronousProxy;
20096
20097    const DEBUG_NAME: &'static str = "(anonymous) UsageGainListener";
20098}
20099
20100pub trait UsageGainListenerProxyInterface: Send + Sync {
20101    type OnGainMuteChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
20102    fn r#on_gain_mute_changed(
20103        &self,
20104        muted: bool,
20105        gain_dbfs: f32,
20106    ) -> Self::OnGainMuteChangedResponseFut;
20107}
20108#[derive(Debug)]
20109#[cfg(target_os = "fuchsia")]
20110pub struct UsageGainListenerSynchronousProxy {
20111    client: fidl::client::sync::Client,
20112}
20113
20114#[cfg(target_os = "fuchsia")]
20115impl fidl::endpoints::SynchronousProxy for UsageGainListenerSynchronousProxy {
20116    type Proxy = UsageGainListenerProxy;
20117    type Protocol = UsageGainListenerMarker;
20118
20119    fn from_channel(inner: fidl::Channel) -> Self {
20120        Self::new(inner)
20121    }
20122
20123    fn into_channel(self) -> fidl::Channel {
20124        self.client.into_channel()
20125    }
20126
20127    fn as_channel(&self) -> &fidl::Channel {
20128        self.client.as_channel()
20129    }
20130}
20131
20132#[cfg(target_os = "fuchsia")]
20133impl UsageGainListenerSynchronousProxy {
20134    pub fn new(channel: fidl::Channel) -> Self {
20135        Self { client: fidl::client::sync::Client::new(channel) }
20136    }
20137
20138    pub fn into_channel(self) -> fidl::Channel {
20139        self.client.into_channel()
20140    }
20141
20142    /// Waits until an event arrives and returns it. It is safe for other
20143    /// threads to make concurrent requests while waiting for an event.
20144    pub fn wait_for_event(
20145        &self,
20146        deadline: zx::MonotonicInstant,
20147    ) -> Result<UsageGainListenerEvent, fidl::Error> {
20148        UsageGainListenerEvent::decode(
20149            self.client.wait_for_event::<UsageGainListenerMarker>(deadline)?,
20150        )
20151    }
20152
20153    /// Called immediately on connection and afterward any time
20154    /// the usage gain setting changes.
20155    ///
20156    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20157    /// events will eventually be disconnected.
20158    ///
20159    /// Note: This API does not have mute reporting implemented; `muted` is always false.
20160    pub fn r#on_gain_mute_changed(
20161        &self,
20162        mut muted: bool,
20163        mut gain_dbfs: f32,
20164        ___deadline: zx::MonotonicInstant,
20165    ) -> Result<(), fidl::Error> {
20166        let _response = self.client.send_query::<
20167            UsageGainListenerOnGainMuteChangedRequest,
20168            fidl::encoding::EmptyPayload,
20169            UsageGainListenerMarker,
20170        >(
20171            (muted, gain_dbfs,),
20172            0x681570258eac3a8d,
20173            fidl::encoding::DynamicFlags::empty(),
20174            ___deadline,
20175        )?;
20176        Ok(_response)
20177    }
20178}
20179
20180#[cfg(target_os = "fuchsia")]
20181impl From<UsageGainListenerSynchronousProxy> for zx::NullableHandle {
20182    fn from(value: UsageGainListenerSynchronousProxy) -> Self {
20183        value.into_channel().into()
20184    }
20185}
20186
20187#[cfg(target_os = "fuchsia")]
20188impl From<fidl::Channel> for UsageGainListenerSynchronousProxy {
20189    fn from(value: fidl::Channel) -> Self {
20190        Self::new(value)
20191    }
20192}
20193
20194#[cfg(target_os = "fuchsia")]
20195impl fidl::endpoints::FromClient for UsageGainListenerSynchronousProxy {
20196    type Protocol = UsageGainListenerMarker;
20197
20198    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainListenerMarker>) -> Self {
20199        Self::new(value.into_channel())
20200    }
20201}
20202
20203#[derive(Debug, Clone)]
20204pub struct UsageGainListenerProxy {
20205    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20206}
20207
20208impl fidl::endpoints::Proxy for UsageGainListenerProxy {
20209    type Protocol = UsageGainListenerMarker;
20210
20211    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20212        Self::new(inner)
20213    }
20214
20215    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20216        self.client.into_channel().map_err(|client| Self { client })
20217    }
20218
20219    fn as_channel(&self) -> &::fidl::AsyncChannel {
20220        self.client.as_channel()
20221    }
20222}
20223
20224impl UsageGainListenerProxy {
20225    /// Create a new Proxy for fuchsia.media/UsageGainListener.
20226    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20227        let protocol_name =
20228            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20229        Self { client: fidl::client::Client::new(channel, protocol_name) }
20230    }
20231
20232    /// Get a Stream of events from the remote end of the protocol.
20233    ///
20234    /// # Panics
20235    ///
20236    /// Panics if the event stream was already taken.
20237    pub fn take_event_stream(&self) -> UsageGainListenerEventStream {
20238        UsageGainListenerEventStream { event_receiver: self.client.take_event_receiver() }
20239    }
20240
20241    /// Called immediately on connection and afterward any time
20242    /// the usage gain setting changes.
20243    ///
20244    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20245    /// events will eventually be disconnected.
20246    ///
20247    /// Note: This API does not have mute reporting implemented; `muted` is always false.
20248    pub fn r#on_gain_mute_changed(
20249        &self,
20250        mut muted: bool,
20251        mut gain_dbfs: f32,
20252    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
20253        UsageGainListenerProxyInterface::r#on_gain_mute_changed(self, muted, gain_dbfs)
20254    }
20255}
20256
20257impl UsageGainListenerProxyInterface for UsageGainListenerProxy {
20258    type OnGainMuteChangedResponseFut =
20259        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
20260    fn r#on_gain_mute_changed(
20261        &self,
20262        mut muted: bool,
20263        mut gain_dbfs: f32,
20264    ) -> Self::OnGainMuteChangedResponseFut {
20265        fn _decode(
20266            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
20267        ) -> Result<(), fidl::Error> {
20268            let _response = fidl::client::decode_transaction_body::<
20269                fidl::encoding::EmptyPayload,
20270                fidl::encoding::DefaultFuchsiaResourceDialect,
20271                0x681570258eac3a8d,
20272            >(_buf?)?;
20273            Ok(_response)
20274        }
20275        self.client.send_query_and_decode::<UsageGainListenerOnGainMuteChangedRequest, ()>(
20276            (muted, gain_dbfs),
20277            0x681570258eac3a8d,
20278            fidl::encoding::DynamicFlags::empty(),
20279            _decode,
20280        )
20281    }
20282}
20283
20284pub struct UsageGainListenerEventStream {
20285    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20286}
20287
20288impl std::marker::Unpin for UsageGainListenerEventStream {}
20289
20290impl futures::stream::FusedStream for UsageGainListenerEventStream {
20291    fn is_terminated(&self) -> bool {
20292        self.event_receiver.is_terminated()
20293    }
20294}
20295
20296impl futures::Stream for UsageGainListenerEventStream {
20297    type Item = Result<UsageGainListenerEvent, fidl::Error>;
20298
20299    fn poll_next(
20300        mut self: std::pin::Pin<&mut Self>,
20301        cx: &mut std::task::Context<'_>,
20302    ) -> std::task::Poll<Option<Self::Item>> {
20303        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20304            &mut self.event_receiver,
20305            cx
20306        )?) {
20307            Some(buf) => std::task::Poll::Ready(Some(UsageGainListenerEvent::decode(buf))),
20308            None => std::task::Poll::Ready(None),
20309        }
20310    }
20311}
20312
20313#[derive(Debug)]
20314pub enum UsageGainListenerEvent {}
20315
20316impl UsageGainListenerEvent {
20317    /// Decodes a message buffer as a [`UsageGainListenerEvent`].
20318    fn decode(
20319        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20320    ) -> Result<UsageGainListenerEvent, fidl::Error> {
20321        let (bytes, _handles) = buf.split_mut();
20322        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20323        debug_assert_eq!(tx_header.tx_id, 0);
20324        match tx_header.ordinal {
20325            _ => Err(fidl::Error::UnknownOrdinal {
20326                ordinal: tx_header.ordinal,
20327                protocol_name:
20328                    <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20329            }),
20330        }
20331    }
20332}
20333
20334/// A Stream of incoming requests for fuchsia.media/UsageGainListener.
20335pub struct UsageGainListenerRequestStream {
20336    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20337    is_terminated: bool,
20338}
20339
20340impl std::marker::Unpin for UsageGainListenerRequestStream {}
20341
20342impl futures::stream::FusedStream for UsageGainListenerRequestStream {
20343    fn is_terminated(&self) -> bool {
20344        self.is_terminated
20345    }
20346}
20347
20348impl fidl::endpoints::RequestStream for UsageGainListenerRequestStream {
20349    type Protocol = UsageGainListenerMarker;
20350    type ControlHandle = UsageGainListenerControlHandle;
20351
20352    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20353        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20354    }
20355
20356    fn control_handle(&self) -> Self::ControlHandle {
20357        UsageGainListenerControlHandle { inner: self.inner.clone() }
20358    }
20359
20360    fn into_inner(
20361        self,
20362    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20363    {
20364        (self.inner, self.is_terminated)
20365    }
20366
20367    fn from_inner(
20368        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20369        is_terminated: bool,
20370    ) -> Self {
20371        Self { inner, is_terminated }
20372    }
20373}
20374
20375impl futures::Stream for UsageGainListenerRequestStream {
20376    type Item = Result<UsageGainListenerRequest, fidl::Error>;
20377
20378    fn poll_next(
20379        mut self: std::pin::Pin<&mut Self>,
20380        cx: &mut std::task::Context<'_>,
20381    ) -> std::task::Poll<Option<Self::Item>> {
20382        let this = &mut *self;
20383        if this.inner.check_shutdown(cx) {
20384            this.is_terminated = true;
20385            return std::task::Poll::Ready(None);
20386        }
20387        if this.is_terminated {
20388            panic!("polled UsageGainListenerRequestStream after completion");
20389        }
20390        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20391            |bytes, handles| {
20392                match this.inner.channel().read_etc(cx, bytes, handles) {
20393                    std::task::Poll::Ready(Ok(())) => {}
20394                    std::task::Poll::Pending => return std::task::Poll::Pending,
20395                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20396                        this.is_terminated = true;
20397                        return std::task::Poll::Ready(None);
20398                    }
20399                    std::task::Poll::Ready(Err(e)) => {
20400                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20401                            e.into(),
20402                        ))));
20403                    }
20404                }
20405
20406                // A message has been received from the channel
20407                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20408
20409                std::task::Poll::Ready(Some(match header.ordinal {
20410                    0x681570258eac3a8d => {
20411                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
20412                        let mut req = fidl::new_empty!(
20413                            UsageGainListenerOnGainMuteChangedRequest,
20414                            fidl::encoding::DefaultFuchsiaResourceDialect
20415                        );
20416                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainListenerOnGainMuteChangedRequest>(&header, _body_bytes, handles, &mut req)?;
20417                        let control_handle =
20418                            UsageGainListenerControlHandle { inner: this.inner.clone() };
20419                        Ok(UsageGainListenerRequest::OnGainMuteChanged {
20420                            muted: req.muted,
20421                            gain_dbfs: req.gain_dbfs,
20422
20423                            responder: UsageGainListenerOnGainMuteChangedResponder {
20424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
20425                                tx_id: header.tx_id,
20426                            },
20427                        })
20428                    }
20429                    _ => Err(fidl::Error::UnknownOrdinal {
20430                        ordinal: header.ordinal,
20431                        protocol_name:
20432                            <UsageGainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20433                    }),
20434                }))
20435            },
20436        )
20437    }
20438}
20439
20440/// A protocol for watching changes to usage gain settings.
20441///
20442/// The channel will close when the device is not present.
20443#[derive(Debug)]
20444pub enum UsageGainListenerRequest {
20445    /// Called immediately on connection and afterward any time
20446    /// the usage gain setting changes.
20447    ///
20448    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
20449    /// events will eventually be disconnected.
20450    ///
20451    /// Note: This API does not have mute reporting implemented; `muted` is always false.
20452    OnGainMuteChanged {
20453        muted: bool,
20454        gain_dbfs: f32,
20455        responder: UsageGainListenerOnGainMuteChangedResponder,
20456    },
20457}
20458
20459impl UsageGainListenerRequest {
20460    #[allow(irrefutable_let_patterns)]
20461    pub fn into_on_gain_mute_changed(
20462        self,
20463    ) -> Option<(bool, f32, UsageGainListenerOnGainMuteChangedResponder)> {
20464        if let UsageGainListenerRequest::OnGainMuteChanged { muted, gain_dbfs, responder } = self {
20465            Some((muted, gain_dbfs, responder))
20466        } else {
20467            None
20468        }
20469    }
20470
20471    /// Name of the method defined in FIDL
20472    pub fn method_name(&self) -> &'static str {
20473        match *self {
20474            UsageGainListenerRequest::OnGainMuteChanged { .. } => "on_gain_mute_changed",
20475        }
20476    }
20477}
20478
20479#[derive(Debug, Clone)]
20480pub struct UsageGainListenerControlHandle {
20481    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20482}
20483
20484impl UsageGainListenerControlHandle {
20485    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
20486        self.inner.shutdown_with_epitaph(status.into())
20487    }
20488}
20489
20490impl fidl::endpoints::ControlHandle for UsageGainListenerControlHandle {
20491    fn shutdown(&self) {
20492        self.inner.shutdown()
20493    }
20494
20495    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
20496        self.inner.shutdown_with_epitaph(status)
20497    }
20498
20499    fn is_closed(&self) -> bool {
20500        self.inner.channel().is_closed()
20501    }
20502    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
20503        self.inner.channel().on_closed()
20504    }
20505
20506    #[cfg(target_os = "fuchsia")]
20507    fn signal_peer(
20508        &self,
20509        clear_mask: zx::Signals,
20510        set_mask: zx::Signals,
20511    ) -> Result<(), zx_status::Status> {
20512        use fidl::Peered;
20513        self.inner.channel().signal_peer(clear_mask, set_mask)
20514    }
20515}
20516
20517impl UsageGainListenerControlHandle {}
20518
20519#[must_use = "FIDL methods require a response to be sent"]
20520#[derive(Debug)]
20521pub struct UsageGainListenerOnGainMuteChangedResponder {
20522    control_handle: std::mem::ManuallyDrop<UsageGainListenerControlHandle>,
20523    tx_id: u32,
20524}
20525
20526/// Set the the channel to be shutdown (see [`UsageGainListenerControlHandle::shutdown`])
20527/// if the responder is dropped without sending a response, so that the client
20528/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
20529impl std::ops::Drop for UsageGainListenerOnGainMuteChangedResponder {
20530    fn drop(&mut self) {
20531        self.control_handle.shutdown();
20532        // Safety: drops once, never accessed again
20533        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20534    }
20535}
20536
20537impl fidl::endpoints::Responder for UsageGainListenerOnGainMuteChangedResponder {
20538    type ControlHandle = UsageGainListenerControlHandle;
20539
20540    fn control_handle(&self) -> &UsageGainListenerControlHandle {
20541        &self.control_handle
20542    }
20543
20544    fn drop_without_shutdown(mut self) {
20545        // Safety: drops once, never accessed again due to mem::forget
20546        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
20547        // Prevent Drop from running (which would shut down the channel)
20548        std::mem::forget(self);
20549    }
20550}
20551
20552impl UsageGainListenerOnGainMuteChangedResponder {
20553    /// Sends a response to the FIDL transaction.
20554    ///
20555    /// Sets the channel to shutdown if an error occurs.
20556    pub fn send(self) -> Result<(), fidl::Error> {
20557        let _result = self.send_raw();
20558        if _result.is_err() {
20559            self.control_handle.shutdown();
20560        }
20561        self.drop_without_shutdown();
20562        _result
20563    }
20564
20565    /// Similar to "send" but does not shutdown the channel if an error occurs.
20566    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
20567        let _result = self.send_raw();
20568        self.drop_without_shutdown();
20569        _result
20570    }
20571
20572    fn send_raw(&self) -> Result<(), fidl::Error> {
20573        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
20574            (),
20575            self.tx_id,
20576            0x681570258eac3a8d,
20577            fidl::encoding::DynamicFlags::empty(),
20578        )
20579    }
20580}
20581
20582#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
20583pub struct UsageGainReporterMarker;
20584
20585impl fidl::endpoints::ProtocolMarker for UsageGainReporterMarker {
20586    type Proxy = UsageGainReporterProxy;
20587    type RequestStream = UsageGainReporterRequestStream;
20588    #[cfg(target_os = "fuchsia")]
20589    type SynchronousProxy = UsageGainReporterSynchronousProxy;
20590
20591    const DEBUG_NAME: &'static str = "fuchsia.media.UsageGainReporter";
20592}
20593impl fidl::endpoints::DiscoverableProtocolMarker for UsageGainReporterMarker {}
20594
20595pub trait UsageGainReporterProxyInterface: Send + Sync {
20596    fn r#register_listener(
20597        &self,
20598        device_unique_id: &str,
20599        usage: &Usage,
20600        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20601    ) -> Result<(), fidl::Error>;
20602    fn r#register_listener2(
20603        &self,
20604        device_unique_id: &str,
20605        usage: &Usage2,
20606        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20607    ) -> Result<(), fidl::Error>;
20608}
20609#[derive(Debug)]
20610#[cfg(target_os = "fuchsia")]
20611pub struct UsageGainReporterSynchronousProxy {
20612    client: fidl::client::sync::Client,
20613}
20614
20615#[cfg(target_os = "fuchsia")]
20616impl fidl::endpoints::SynchronousProxy for UsageGainReporterSynchronousProxy {
20617    type Proxy = UsageGainReporterProxy;
20618    type Protocol = UsageGainReporterMarker;
20619
20620    fn from_channel(inner: fidl::Channel) -> Self {
20621        Self::new(inner)
20622    }
20623
20624    fn into_channel(self) -> fidl::Channel {
20625        self.client.into_channel()
20626    }
20627
20628    fn as_channel(&self) -> &fidl::Channel {
20629        self.client.as_channel()
20630    }
20631}
20632
20633#[cfg(target_os = "fuchsia")]
20634impl UsageGainReporterSynchronousProxy {
20635    pub fn new(channel: fidl::Channel) -> Self {
20636        Self { client: fidl::client::sync::Client::new(channel) }
20637    }
20638
20639    pub fn into_channel(self) -> fidl::Channel {
20640        self.client.into_channel()
20641    }
20642
20643    /// Waits until an event arrives and returns it. It is safe for other
20644    /// threads to make concurrent requests while waiting for an event.
20645    pub fn wait_for_event(
20646        &self,
20647        deadline: zx::MonotonicInstant,
20648    ) -> Result<UsageGainReporterEvent, fidl::Error> {
20649        UsageGainReporterEvent::decode(
20650            self.client.wait_for_event::<UsageGainReporterMarker>(deadline)?,
20651        )
20652    }
20653
20654    /// Connects a listener to a stream of usage gain setting changes
20655    /// for `usage` on the device identified by `device_token`. Usage
20656    /// Gain is not set directly by any client; it is a translation of
20657    /// the usage volume setting for each device, summed with active
20658    /// muting/ducking gain adjustments.
20659    ///
20660    /// Devices may map the same volume level to different dbfs, so
20661    /// a `device_unique_id` is needed to identify the device.
20662    ///
20663    /// `AudioDeviceEnumerator` provides programmatic access to devices
20664    /// and their unique ids if it is necessary for a client to select
20665    /// an id at runtime.
20666    pub fn r#register_listener(
20667        &self,
20668        mut device_unique_id: &str,
20669        mut usage: &Usage,
20670        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20671    ) -> Result<(), fidl::Error> {
20672        self.client.send::<UsageGainReporterRegisterListenerRequest>(
20673            (device_unique_id, usage, usage_gain_listener),
20674            0x767107c168c226af,
20675            fidl::encoding::DynamicFlags::empty(),
20676        )
20677    }
20678
20679    /// Connects a listener to a stream of usage gain setting changes
20680    /// for `usage` on the device identified by `device_token`. Usage
20681    /// Gain is not set directly by any client; it is a translation of
20682    /// the usage volume setting for each device, summed with active
20683    /// muting/ducking gain adjustments.
20684    ///
20685    /// Devices may map the same volume level to different dbfs, so
20686    /// a `device_unique_id` is needed to identify the device.
20687    ///
20688    /// `AudioDeviceEnumerator` provides programmatic access to devices
20689    /// and their unique ids if it is necessary for a client to select
20690    /// an id at runtime.
20691    pub fn r#register_listener2(
20692        &self,
20693        mut device_unique_id: &str,
20694        mut usage: &Usage2,
20695        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20696    ) -> Result<(), fidl::Error> {
20697        self.client.send::<UsageGainReporterRegisterListener2Request>(
20698            (device_unique_id, usage, usage_gain_listener),
20699            0x760a8e1c5873629c,
20700            fidl::encoding::DynamicFlags::FLEXIBLE,
20701        )
20702    }
20703}
20704
20705#[cfg(target_os = "fuchsia")]
20706impl From<UsageGainReporterSynchronousProxy> for zx::NullableHandle {
20707    fn from(value: UsageGainReporterSynchronousProxy) -> Self {
20708        value.into_channel().into()
20709    }
20710}
20711
20712#[cfg(target_os = "fuchsia")]
20713impl From<fidl::Channel> for UsageGainReporterSynchronousProxy {
20714    fn from(value: fidl::Channel) -> Self {
20715        Self::new(value)
20716    }
20717}
20718
20719#[cfg(target_os = "fuchsia")]
20720impl fidl::endpoints::FromClient for UsageGainReporterSynchronousProxy {
20721    type Protocol = UsageGainReporterMarker;
20722
20723    fn from_client(value: fidl::endpoints::ClientEnd<UsageGainReporterMarker>) -> Self {
20724        Self::new(value.into_channel())
20725    }
20726}
20727
20728#[derive(Debug, Clone)]
20729pub struct UsageGainReporterProxy {
20730    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
20731}
20732
20733impl fidl::endpoints::Proxy for UsageGainReporterProxy {
20734    type Protocol = UsageGainReporterMarker;
20735
20736    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
20737        Self::new(inner)
20738    }
20739
20740    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
20741        self.client.into_channel().map_err(|client| Self { client })
20742    }
20743
20744    fn as_channel(&self) -> &::fidl::AsyncChannel {
20745        self.client.as_channel()
20746    }
20747}
20748
20749impl UsageGainReporterProxy {
20750    /// Create a new Proxy for fuchsia.media/UsageGainReporter.
20751    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
20752        let protocol_name =
20753            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
20754        Self { client: fidl::client::Client::new(channel, protocol_name) }
20755    }
20756
20757    /// Get a Stream of events from the remote end of the protocol.
20758    ///
20759    /// # Panics
20760    ///
20761    /// Panics if the event stream was already taken.
20762    pub fn take_event_stream(&self) -> UsageGainReporterEventStream {
20763        UsageGainReporterEventStream { event_receiver: self.client.take_event_receiver() }
20764    }
20765
20766    /// Connects a listener to a stream of usage gain setting changes
20767    /// for `usage` on the device identified by `device_token`. Usage
20768    /// Gain is not set directly by any client; it is a translation of
20769    /// the usage volume setting for each device, summed with active
20770    /// muting/ducking gain adjustments.
20771    ///
20772    /// Devices may map the same volume level to different dbfs, so
20773    /// a `device_unique_id` is needed to identify the device.
20774    ///
20775    /// `AudioDeviceEnumerator` provides programmatic access to devices
20776    /// and their unique ids if it is necessary for a client to select
20777    /// an id at runtime.
20778    pub fn r#register_listener(
20779        &self,
20780        mut device_unique_id: &str,
20781        mut usage: &Usage,
20782        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20783    ) -> Result<(), fidl::Error> {
20784        UsageGainReporterProxyInterface::r#register_listener(
20785            self,
20786            device_unique_id,
20787            usage,
20788            usage_gain_listener,
20789        )
20790    }
20791
20792    /// Connects a listener to a stream of usage gain setting changes
20793    /// for `usage` on the device identified by `device_token`. Usage
20794    /// Gain is not set directly by any client; it is a translation of
20795    /// the usage volume setting for each device, summed with active
20796    /// muting/ducking gain adjustments.
20797    ///
20798    /// Devices may map the same volume level to different dbfs, so
20799    /// a `device_unique_id` is needed to identify the device.
20800    ///
20801    /// `AudioDeviceEnumerator` provides programmatic access to devices
20802    /// and their unique ids if it is necessary for a client to select
20803    /// an id at runtime.
20804    pub fn r#register_listener2(
20805        &self,
20806        mut device_unique_id: &str,
20807        mut usage: &Usage2,
20808        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20809    ) -> Result<(), fidl::Error> {
20810        UsageGainReporterProxyInterface::r#register_listener2(
20811            self,
20812            device_unique_id,
20813            usage,
20814            usage_gain_listener,
20815        )
20816    }
20817}
20818
20819impl UsageGainReporterProxyInterface for UsageGainReporterProxy {
20820    fn r#register_listener(
20821        &self,
20822        mut device_unique_id: &str,
20823        mut usage: &Usage,
20824        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20825    ) -> Result<(), fidl::Error> {
20826        self.client.send::<UsageGainReporterRegisterListenerRequest>(
20827            (device_unique_id, usage, usage_gain_listener),
20828            0x767107c168c226af,
20829            fidl::encoding::DynamicFlags::empty(),
20830        )
20831    }
20832
20833    fn r#register_listener2(
20834        &self,
20835        mut device_unique_id: &str,
20836        mut usage: &Usage2,
20837        mut usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
20838    ) -> Result<(), fidl::Error> {
20839        self.client.send::<UsageGainReporterRegisterListener2Request>(
20840            (device_unique_id, usage, usage_gain_listener),
20841            0x760a8e1c5873629c,
20842            fidl::encoding::DynamicFlags::FLEXIBLE,
20843        )
20844    }
20845}
20846
20847pub struct UsageGainReporterEventStream {
20848    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
20849}
20850
20851impl std::marker::Unpin for UsageGainReporterEventStream {}
20852
20853impl futures::stream::FusedStream for UsageGainReporterEventStream {
20854    fn is_terminated(&self) -> bool {
20855        self.event_receiver.is_terminated()
20856    }
20857}
20858
20859impl futures::Stream for UsageGainReporterEventStream {
20860    type Item = Result<UsageGainReporterEvent, fidl::Error>;
20861
20862    fn poll_next(
20863        mut self: std::pin::Pin<&mut Self>,
20864        cx: &mut std::task::Context<'_>,
20865    ) -> std::task::Poll<Option<Self::Item>> {
20866        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
20867            &mut self.event_receiver,
20868            cx
20869        )?) {
20870            Some(buf) => std::task::Poll::Ready(Some(UsageGainReporterEvent::decode(buf))),
20871            None => std::task::Poll::Ready(None),
20872        }
20873    }
20874}
20875
20876#[derive(Debug)]
20877pub enum UsageGainReporterEvent {
20878    #[non_exhaustive]
20879    _UnknownEvent {
20880        /// Ordinal of the event that was sent.
20881        ordinal: u64,
20882    },
20883}
20884
20885impl UsageGainReporterEvent {
20886    /// Decodes a message buffer as a [`UsageGainReporterEvent`].
20887    fn decode(
20888        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
20889    ) -> Result<UsageGainReporterEvent, fidl::Error> {
20890        let (bytes, _handles) = buf.split_mut();
20891        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20892        debug_assert_eq!(tx_header.tx_id, 0);
20893        match tx_header.ordinal {
20894            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
20895                Ok(UsageGainReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
20896            }
20897            _ => Err(fidl::Error::UnknownOrdinal {
20898                ordinal: tx_header.ordinal,
20899                protocol_name:
20900                    <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
20901            }),
20902        }
20903    }
20904}
20905
20906/// A Stream of incoming requests for fuchsia.media/UsageGainReporter.
20907pub struct UsageGainReporterRequestStream {
20908    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20909    is_terminated: bool,
20910}
20911
20912impl std::marker::Unpin for UsageGainReporterRequestStream {}
20913
20914impl futures::stream::FusedStream for UsageGainReporterRequestStream {
20915    fn is_terminated(&self) -> bool {
20916        self.is_terminated
20917    }
20918}
20919
20920impl fidl::endpoints::RequestStream for UsageGainReporterRequestStream {
20921    type Protocol = UsageGainReporterMarker;
20922    type ControlHandle = UsageGainReporterControlHandle;
20923
20924    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
20925        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
20926    }
20927
20928    fn control_handle(&self) -> Self::ControlHandle {
20929        UsageGainReporterControlHandle { inner: self.inner.clone() }
20930    }
20931
20932    fn into_inner(
20933        self,
20934    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
20935    {
20936        (self.inner, self.is_terminated)
20937    }
20938
20939    fn from_inner(
20940        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
20941        is_terminated: bool,
20942    ) -> Self {
20943        Self { inner, is_terminated }
20944    }
20945}
20946
20947impl futures::Stream for UsageGainReporterRequestStream {
20948    type Item = Result<UsageGainReporterRequest, fidl::Error>;
20949
20950    fn poll_next(
20951        mut self: std::pin::Pin<&mut Self>,
20952        cx: &mut std::task::Context<'_>,
20953    ) -> std::task::Poll<Option<Self::Item>> {
20954        let this = &mut *self;
20955        if this.inner.check_shutdown(cx) {
20956            this.is_terminated = true;
20957            return std::task::Poll::Ready(None);
20958        }
20959        if this.is_terminated {
20960            panic!("polled UsageGainReporterRequestStream after completion");
20961        }
20962        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
20963            |bytes, handles| {
20964                match this.inner.channel().read_etc(cx, bytes, handles) {
20965                    std::task::Poll::Ready(Ok(())) => {}
20966                    std::task::Poll::Pending => return std::task::Poll::Pending,
20967                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
20968                        this.is_terminated = true;
20969                        return std::task::Poll::Ready(None);
20970                    }
20971                    std::task::Poll::Ready(Err(e)) => {
20972                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
20973                            e.into(),
20974                        ))));
20975                    }
20976                }
20977
20978                // A message has been received from the channel
20979                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
20980
20981                std::task::Poll::Ready(Some(match header.ordinal {
20982                    0x767107c168c226af => {
20983                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
20984                        let mut req = fidl::new_empty!(
20985                            UsageGainReporterRegisterListenerRequest,
20986                            fidl::encoding::DefaultFuchsiaResourceDialect
20987                        );
20988                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
20989                        let control_handle =
20990                            UsageGainReporterControlHandle { inner: this.inner.clone() };
20991                        Ok(UsageGainReporterRequest::RegisterListener {
20992                            device_unique_id: req.device_unique_id,
20993                            usage: req.usage,
20994                            usage_gain_listener: req.usage_gain_listener,
20995
20996                            control_handle,
20997                        })
20998                    }
20999                    0x760a8e1c5873629c => {
21000                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
21001                        let mut req = fidl::new_empty!(
21002                            UsageGainReporterRegisterListener2Request,
21003                            fidl::encoding::DefaultFuchsiaResourceDialect
21004                        );
21005                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageGainReporterRegisterListener2Request>(&header, _body_bytes, handles, &mut req)?;
21006                        let control_handle =
21007                            UsageGainReporterControlHandle { inner: this.inner.clone() };
21008                        Ok(UsageGainReporterRequest::RegisterListener2 {
21009                            device_unique_id: req.device_unique_id,
21010                            usage: req.usage,
21011                            usage_gain_listener: req.usage_gain_listener,
21012
21013                            control_handle,
21014                        })
21015                    }
21016                    _ if header.tx_id == 0
21017                        && header
21018                            .dynamic_flags()
21019                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
21020                    {
21021                        Ok(UsageGainReporterRequest::_UnknownMethod {
21022                            ordinal: header.ordinal,
21023                            control_handle: UsageGainReporterControlHandle {
21024                                inner: this.inner.clone(),
21025                            },
21026                            method_type: fidl::MethodType::OneWay,
21027                        })
21028                    }
21029                    _ if header
21030                        .dynamic_flags()
21031                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
21032                    {
21033                        this.inner.send_framework_err(
21034                            fidl::encoding::FrameworkErr::UnknownMethod,
21035                            header.tx_id,
21036                            header.ordinal,
21037                            header.dynamic_flags(),
21038                            (bytes, handles),
21039                        )?;
21040                        Ok(UsageGainReporterRequest::_UnknownMethod {
21041                            ordinal: header.ordinal,
21042                            control_handle: UsageGainReporterControlHandle {
21043                                inner: this.inner.clone(),
21044                            },
21045                            method_type: fidl::MethodType::TwoWay,
21046                        })
21047                    }
21048                    _ => Err(fidl::Error::UnknownOrdinal {
21049                        ordinal: header.ordinal,
21050                        protocol_name:
21051                            <UsageGainReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21052                    }),
21053                }))
21054            },
21055        )
21056    }
21057}
21058
21059/// A protocol for setting up watchers of usage gain.
21060#[derive(Debug)]
21061pub enum UsageGainReporterRequest {
21062    /// Connects a listener to a stream of usage gain setting changes
21063    /// for `usage` on the device identified by `device_token`. Usage
21064    /// Gain is not set directly by any client; it is a translation of
21065    /// the usage volume setting for each device, summed with active
21066    /// muting/ducking gain adjustments.
21067    ///
21068    /// Devices may map the same volume level to different dbfs, so
21069    /// a `device_unique_id` is needed to identify the device.
21070    ///
21071    /// `AudioDeviceEnumerator` provides programmatic access to devices
21072    /// and their unique ids if it is necessary for a client to select
21073    /// an id at runtime.
21074    RegisterListener {
21075        device_unique_id: String,
21076        usage: Usage,
21077        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
21078        control_handle: UsageGainReporterControlHandle,
21079    },
21080    /// Connects a listener to a stream of usage gain setting changes
21081    /// for `usage` on the device identified by `device_token`. Usage
21082    /// Gain is not set directly by any client; it is a translation of
21083    /// the usage volume setting for each device, summed with active
21084    /// muting/ducking gain adjustments.
21085    ///
21086    /// Devices may map the same volume level to different dbfs, so
21087    /// a `device_unique_id` is needed to identify the device.
21088    ///
21089    /// `AudioDeviceEnumerator` provides programmatic access to devices
21090    /// and their unique ids if it is necessary for a client to select
21091    /// an id at runtime.
21092    RegisterListener2 {
21093        device_unique_id: String,
21094        usage: Usage2,
21095        usage_gain_listener: fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
21096        control_handle: UsageGainReporterControlHandle,
21097    },
21098    /// An interaction was received which does not match any known method.
21099    #[non_exhaustive]
21100    _UnknownMethod {
21101        /// Ordinal of the method that was called.
21102        ordinal: u64,
21103        control_handle: UsageGainReporterControlHandle,
21104        method_type: fidl::MethodType,
21105    },
21106}
21107
21108impl UsageGainReporterRequest {
21109    #[allow(irrefutable_let_patterns)]
21110    pub fn into_register_listener(
21111        self,
21112    ) -> Option<(
21113        String,
21114        Usage,
21115        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
21116        UsageGainReporterControlHandle,
21117    )> {
21118        if let UsageGainReporterRequest::RegisterListener {
21119            device_unique_id,
21120            usage,
21121            usage_gain_listener,
21122            control_handle,
21123        } = self
21124        {
21125            Some((device_unique_id, usage, usage_gain_listener, control_handle))
21126        } else {
21127            None
21128        }
21129    }
21130
21131    #[allow(irrefutable_let_patterns)]
21132    pub fn into_register_listener2(
21133        self,
21134    ) -> Option<(
21135        String,
21136        Usage2,
21137        fidl::endpoints::ClientEnd<UsageGainListenerMarker>,
21138        UsageGainReporterControlHandle,
21139    )> {
21140        if let UsageGainReporterRequest::RegisterListener2 {
21141            device_unique_id,
21142            usage,
21143            usage_gain_listener,
21144            control_handle,
21145        } = self
21146        {
21147            Some((device_unique_id, usage, usage_gain_listener, control_handle))
21148        } else {
21149            None
21150        }
21151    }
21152
21153    /// Name of the method defined in FIDL
21154    pub fn method_name(&self) -> &'static str {
21155        match *self {
21156            UsageGainReporterRequest::RegisterListener { .. } => "register_listener",
21157            UsageGainReporterRequest::RegisterListener2 { .. } => "register_listener2",
21158            UsageGainReporterRequest::_UnknownMethod {
21159                method_type: fidl::MethodType::OneWay,
21160                ..
21161            } => "unknown one-way method",
21162            UsageGainReporterRequest::_UnknownMethod {
21163                method_type: fidl::MethodType::TwoWay,
21164                ..
21165            } => "unknown two-way method",
21166        }
21167    }
21168}
21169
21170#[derive(Debug, Clone)]
21171pub struct UsageGainReporterControlHandle {
21172    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21173}
21174
21175impl UsageGainReporterControlHandle {
21176    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
21177        self.inner.shutdown_with_epitaph(status.into())
21178    }
21179}
21180
21181impl fidl::endpoints::ControlHandle for UsageGainReporterControlHandle {
21182    fn shutdown(&self) {
21183        self.inner.shutdown()
21184    }
21185
21186    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
21187        self.inner.shutdown_with_epitaph(status)
21188    }
21189
21190    fn is_closed(&self) -> bool {
21191        self.inner.channel().is_closed()
21192    }
21193    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
21194        self.inner.channel().on_closed()
21195    }
21196
21197    #[cfg(target_os = "fuchsia")]
21198    fn signal_peer(
21199        &self,
21200        clear_mask: zx::Signals,
21201        set_mask: zx::Signals,
21202    ) -> Result<(), zx_status::Status> {
21203        use fidl::Peered;
21204        self.inner.channel().signal_peer(clear_mask, set_mask)
21205    }
21206}
21207
21208impl UsageGainReporterControlHandle {}
21209
21210#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
21211pub struct UsageReporterMarker;
21212
21213impl fidl::endpoints::ProtocolMarker for UsageReporterMarker {
21214    type Proxy = UsageReporterProxy;
21215    type RequestStream = UsageReporterRequestStream;
21216    #[cfg(target_os = "fuchsia")]
21217    type SynchronousProxy = UsageReporterSynchronousProxy;
21218
21219    const DEBUG_NAME: &'static str = "fuchsia.media.UsageReporter";
21220}
21221impl fidl::endpoints::DiscoverableProtocolMarker for UsageReporterMarker {}
21222
21223pub trait UsageReporterProxyInterface: Send + Sync {
21224    fn r#watch(
21225        &self,
21226        usage: &Usage,
21227        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21228    ) -> Result<(), fidl::Error>;
21229    fn r#watch2(
21230        &self,
21231        usage: &Usage2,
21232        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21233    ) -> Result<(), fidl::Error>;
21234}
21235#[derive(Debug)]
21236#[cfg(target_os = "fuchsia")]
21237pub struct UsageReporterSynchronousProxy {
21238    client: fidl::client::sync::Client,
21239}
21240
21241#[cfg(target_os = "fuchsia")]
21242impl fidl::endpoints::SynchronousProxy for UsageReporterSynchronousProxy {
21243    type Proxy = UsageReporterProxy;
21244    type Protocol = UsageReporterMarker;
21245
21246    fn from_channel(inner: fidl::Channel) -> Self {
21247        Self::new(inner)
21248    }
21249
21250    fn into_channel(self) -> fidl::Channel {
21251        self.client.into_channel()
21252    }
21253
21254    fn as_channel(&self) -> &fidl::Channel {
21255        self.client.as_channel()
21256    }
21257}
21258
21259#[cfg(target_os = "fuchsia")]
21260impl UsageReporterSynchronousProxy {
21261    pub fn new(channel: fidl::Channel) -> Self {
21262        Self { client: fidl::client::sync::Client::new(channel) }
21263    }
21264
21265    pub fn into_channel(self) -> fidl::Channel {
21266        self.client.into_channel()
21267    }
21268
21269    /// Waits until an event arrives and returns it. It is safe for other
21270    /// threads to make concurrent requests while waiting for an event.
21271    pub fn wait_for_event(
21272        &self,
21273        deadline: zx::MonotonicInstant,
21274    ) -> Result<UsageReporterEvent, fidl::Error> {
21275        UsageReporterEvent::decode(self.client.wait_for_event::<UsageReporterMarker>(deadline)?)
21276    }
21277
21278    pub fn r#watch(
21279        &self,
21280        mut usage: &Usage,
21281        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21282    ) -> Result<(), fidl::Error> {
21283        self.client.send::<UsageReporterWatchRequest>(
21284            (usage, usage_watcher),
21285            0x769e6fb17075c959,
21286            fidl::encoding::DynamicFlags::empty(),
21287        )
21288    }
21289
21290    pub fn r#watch2(
21291        &self,
21292        mut usage: &Usage2,
21293        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21294    ) -> Result<(), fidl::Error> {
21295        self.client.send::<UsageReporterWatch2Request>(
21296            (usage, usage_watcher),
21297            0x4a43c4c82f5d8ce8,
21298            fidl::encoding::DynamicFlags::FLEXIBLE,
21299        )
21300    }
21301}
21302
21303#[cfg(target_os = "fuchsia")]
21304impl From<UsageReporterSynchronousProxy> for zx::NullableHandle {
21305    fn from(value: UsageReporterSynchronousProxy) -> Self {
21306        value.into_channel().into()
21307    }
21308}
21309
21310#[cfg(target_os = "fuchsia")]
21311impl From<fidl::Channel> for UsageReporterSynchronousProxy {
21312    fn from(value: fidl::Channel) -> Self {
21313        Self::new(value)
21314    }
21315}
21316
21317#[cfg(target_os = "fuchsia")]
21318impl fidl::endpoints::FromClient for UsageReporterSynchronousProxy {
21319    type Protocol = UsageReporterMarker;
21320
21321    fn from_client(value: fidl::endpoints::ClientEnd<UsageReporterMarker>) -> Self {
21322        Self::new(value.into_channel())
21323    }
21324}
21325
21326#[derive(Debug, Clone)]
21327pub struct UsageReporterProxy {
21328    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
21329}
21330
21331impl fidl::endpoints::Proxy for UsageReporterProxy {
21332    type Protocol = UsageReporterMarker;
21333
21334    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
21335        Self::new(inner)
21336    }
21337
21338    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
21339        self.client.into_channel().map_err(|client| Self { client })
21340    }
21341
21342    fn as_channel(&self) -> &::fidl::AsyncChannel {
21343        self.client.as_channel()
21344    }
21345}
21346
21347impl UsageReporterProxy {
21348    /// Create a new Proxy for fuchsia.media/UsageReporter.
21349    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
21350        let protocol_name = <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
21351        Self { client: fidl::client::Client::new(channel, protocol_name) }
21352    }
21353
21354    /// Get a Stream of events from the remote end of the protocol.
21355    ///
21356    /// # Panics
21357    ///
21358    /// Panics if the event stream was already taken.
21359    pub fn take_event_stream(&self) -> UsageReporterEventStream {
21360        UsageReporterEventStream { event_receiver: self.client.take_event_receiver() }
21361    }
21362
21363    pub fn r#watch(
21364        &self,
21365        mut usage: &Usage,
21366        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21367    ) -> Result<(), fidl::Error> {
21368        UsageReporterProxyInterface::r#watch(self, usage, usage_watcher)
21369    }
21370
21371    pub fn r#watch2(
21372        &self,
21373        mut usage: &Usage2,
21374        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21375    ) -> Result<(), fidl::Error> {
21376        UsageReporterProxyInterface::r#watch2(self, usage, usage_watcher)
21377    }
21378}
21379
21380impl UsageReporterProxyInterface for UsageReporterProxy {
21381    fn r#watch(
21382        &self,
21383        mut usage: &Usage,
21384        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21385    ) -> Result<(), fidl::Error> {
21386        self.client.send::<UsageReporterWatchRequest>(
21387            (usage, usage_watcher),
21388            0x769e6fb17075c959,
21389            fidl::encoding::DynamicFlags::empty(),
21390        )
21391    }
21392
21393    fn r#watch2(
21394        &self,
21395        mut usage: &Usage2,
21396        mut usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21397    ) -> Result<(), fidl::Error> {
21398        self.client.send::<UsageReporterWatch2Request>(
21399            (usage, usage_watcher),
21400            0x4a43c4c82f5d8ce8,
21401            fidl::encoding::DynamicFlags::FLEXIBLE,
21402        )
21403    }
21404}
21405
21406pub struct UsageReporterEventStream {
21407    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
21408}
21409
21410impl std::marker::Unpin for UsageReporterEventStream {}
21411
21412impl futures::stream::FusedStream for UsageReporterEventStream {
21413    fn is_terminated(&self) -> bool {
21414        self.event_receiver.is_terminated()
21415    }
21416}
21417
21418impl futures::Stream for UsageReporterEventStream {
21419    type Item = Result<UsageReporterEvent, fidl::Error>;
21420
21421    fn poll_next(
21422        mut self: std::pin::Pin<&mut Self>,
21423        cx: &mut std::task::Context<'_>,
21424    ) -> std::task::Poll<Option<Self::Item>> {
21425        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
21426            &mut self.event_receiver,
21427            cx
21428        )?) {
21429            Some(buf) => std::task::Poll::Ready(Some(UsageReporterEvent::decode(buf))),
21430            None => std::task::Poll::Ready(None),
21431        }
21432    }
21433}
21434
21435#[derive(Debug)]
21436pub enum UsageReporterEvent {
21437    #[non_exhaustive]
21438    _UnknownEvent {
21439        /// Ordinal of the event that was sent.
21440        ordinal: u64,
21441    },
21442}
21443
21444impl UsageReporterEvent {
21445    /// Decodes a message buffer as a [`UsageReporterEvent`].
21446    fn decode(
21447        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
21448    ) -> Result<UsageReporterEvent, fidl::Error> {
21449        let (bytes, _handles) = buf.split_mut();
21450        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21451        debug_assert_eq!(tx_header.tx_id, 0);
21452        match tx_header.ordinal {
21453            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
21454                Ok(UsageReporterEvent::_UnknownEvent { ordinal: tx_header.ordinal })
21455            }
21456            _ => Err(fidl::Error::UnknownOrdinal {
21457                ordinal: tx_header.ordinal,
21458                protocol_name: <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21459            }),
21460        }
21461    }
21462}
21463
21464/// A Stream of incoming requests for fuchsia.media/UsageReporter.
21465pub struct UsageReporterRequestStream {
21466    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21467    is_terminated: bool,
21468}
21469
21470impl std::marker::Unpin for UsageReporterRequestStream {}
21471
21472impl futures::stream::FusedStream for UsageReporterRequestStream {
21473    fn is_terminated(&self) -> bool {
21474        self.is_terminated
21475    }
21476}
21477
21478impl fidl::endpoints::RequestStream for UsageReporterRequestStream {
21479    type Protocol = UsageReporterMarker;
21480    type ControlHandle = UsageReporterControlHandle;
21481
21482    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
21483        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
21484    }
21485
21486    fn control_handle(&self) -> Self::ControlHandle {
21487        UsageReporterControlHandle { inner: self.inner.clone() }
21488    }
21489
21490    fn into_inner(
21491        self,
21492    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
21493    {
21494        (self.inner, self.is_terminated)
21495    }
21496
21497    fn from_inner(
21498        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21499        is_terminated: bool,
21500    ) -> Self {
21501        Self { inner, is_terminated }
21502    }
21503}
21504
21505impl futures::Stream for UsageReporterRequestStream {
21506    type Item = Result<UsageReporterRequest, fidl::Error>;
21507
21508    fn poll_next(
21509        mut self: std::pin::Pin<&mut Self>,
21510        cx: &mut std::task::Context<'_>,
21511    ) -> std::task::Poll<Option<Self::Item>> {
21512        let this = &mut *self;
21513        if this.inner.check_shutdown(cx) {
21514            this.is_terminated = true;
21515            return std::task::Poll::Ready(None);
21516        }
21517        if this.is_terminated {
21518            panic!("polled UsageReporterRequestStream after completion");
21519        }
21520        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
21521            |bytes, handles| {
21522                match this.inner.channel().read_etc(cx, bytes, handles) {
21523                    std::task::Poll::Ready(Ok(())) => {}
21524                    std::task::Poll::Pending => return std::task::Poll::Pending,
21525                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
21526                        this.is_terminated = true;
21527                        return std::task::Poll::Ready(None);
21528                    }
21529                    std::task::Poll::Ready(Err(e)) => {
21530                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
21531                            e.into(),
21532                        ))));
21533                    }
21534                }
21535
21536                // A message has been received from the channel
21537                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21538
21539                std::task::Poll::Ready(Some(match header.ordinal {
21540                    0x769e6fb17075c959 => {
21541                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
21542                        let mut req = fidl::new_empty!(
21543                            UsageReporterWatchRequest,
21544                            fidl::encoding::DefaultFuchsiaResourceDialect
21545                        );
21546                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatchRequest>(&header, _body_bytes, handles, &mut req)?;
21547                        let control_handle =
21548                            UsageReporterControlHandle { inner: this.inner.clone() };
21549                        Ok(UsageReporterRequest::Watch {
21550                            usage: req.usage,
21551                            usage_watcher: req.usage_watcher,
21552
21553                            control_handle,
21554                        })
21555                    }
21556                    0x4a43c4c82f5d8ce8 => {
21557                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
21558                        let mut req = fidl::new_empty!(
21559                            UsageReporterWatch2Request,
21560                            fidl::encoding::DefaultFuchsiaResourceDialect
21561                        );
21562                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageReporterWatch2Request>(&header, _body_bytes, handles, &mut req)?;
21563                        let control_handle =
21564                            UsageReporterControlHandle { inner: this.inner.clone() };
21565                        Ok(UsageReporterRequest::Watch2 {
21566                            usage: req.usage,
21567                            usage_watcher: req.usage_watcher,
21568
21569                            control_handle,
21570                        })
21571                    }
21572                    _ if header.tx_id == 0
21573                        && header
21574                            .dynamic_flags()
21575                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
21576                    {
21577                        Ok(UsageReporterRequest::_UnknownMethod {
21578                            ordinal: header.ordinal,
21579                            control_handle: UsageReporterControlHandle {
21580                                inner: this.inner.clone(),
21581                            },
21582                            method_type: fidl::MethodType::OneWay,
21583                        })
21584                    }
21585                    _ if header
21586                        .dynamic_flags()
21587                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
21588                    {
21589                        this.inner.send_framework_err(
21590                            fidl::encoding::FrameworkErr::UnknownMethod,
21591                            header.tx_id,
21592                            header.ordinal,
21593                            header.dynamic_flags(),
21594                            (bytes, handles),
21595                        )?;
21596                        Ok(UsageReporterRequest::_UnknownMethod {
21597                            ordinal: header.ordinal,
21598                            control_handle: UsageReporterControlHandle {
21599                                inner: this.inner.clone(),
21600                            },
21601                            method_type: fidl::MethodType::TwoWay,
21602                        })
21603                    }
21604                    _ => Err(fidl::Error::UnknownOrdinal {
21605                        ordinal: header.ordinal,
21606                        protocol_name:
21607                            <UsageReporterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21608                    }),
21609                }))
21610            },
21611        )
21612    }
21613}
21614
21615/// A protocol for setting up watchers of audio usages.
21616#[derive(Debug)]
21617pub enum UsageReporterRequest {
21618    Watch {
21619        usage: Usage,
21620        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcherMarker>,
21621        control_handle: UsageReporterControlHandle,
21622    },
21623    Watch2 {
21624        usage: Usage2,
21625        usage_watcher: fidl::endpoints::ClientEnd<UsageWatcher2Marker>,
21626        control_handle: UsageReporterControlHandle,
21627    },
21628    /// An interaction was received which does not match any known method.
21629    #[non_exhaustive]
21630    _UnknownMethod {
21631        /// Ordinal of the method that was called.
21632        ordinal: u64,
21633        control_handle: UsageReporterControlHandle,
21634        method_type: fidl::MethodType,
21635    },
21636}
21637
21638impl UsageReporterRequest {
21639    #[allow(irrefutable_let_patterns)]
21640    pub fn into_watch(
21641        self,
21642    ) -> Option<(Usage, fidl::endpoints::ClientEnd<UsageWatcherMarker>, UsageReporterControlHandle)>
21643    {
21644        if let UsageReporterRequest::Watch { usage, usage_watcher, control_handle } = self {
21645            Some((usage, usage_watcher, control_handle))
21646        } else {
21647            None
21648        }
21649    }
21650
21651    #[allow(irrefutable_let_patterns)]
21652    pub fn into_watch2(
21653        self,
21654    ) -> Option<(Usage2, fidl::endpoints::ClientEnd<UsageWatcher2Marker>, UsageReporterControlHandle)>
21655    {
21656        if let UsageReporterRequest::Watch2 { usage, usage_watcher, control_handle } = self {
21657            Some((usage, usage_watcher, control_handle))
21658        } else {
21659            None
21660        }
21661    }
21662
21663    /// Name of the method defined in FIDL
21664    pub fn method_name(&self) -> &'static str {
21665        match *self {
21666            UsageReporterRequest::Watch { .. } => "watch",
21667            UsageReporterRequest::Watch2 { .. } => "watch2",
21668            UsageReporterRequest::_UnknownMethod {
21669                method_type: fidl::MethodType::OneWay, ..
21670            } => "unknown one-way method",
21671            UsageReporterRequest::_UnknownMethod {
21672                method_type: fidl::MethodType::TwoWay, ..
21673            } => "unknown two-way method",
21674        }
21675    }
21676}
21677
21678#[derive(Debug, Clone)]
21679pub struct UsageReporterControlHandle {
21680    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21681}
21682
21683impl UsageReporterControlHandle {
21684    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
21685        self.inner.shutdown_with_epitaph(status.into())
21686    }
21687}
21688
21689impl fidl::endpoints::ControlHandle for UsageReporterControlHandle {
21690    fn shutdown(&self) {
21691        self.inner.shutdown()
21692    }
21693
21694    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
21695        self.inner.shutdown_with_epitaph(status)
21696    }
21697
21698    fn is_closed(&self) -> bool {
21699        self.inner.channel().is_closed()
21700    }
21701    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
21702        self.inner.channel().on_closed()
21703    }
21704
21705    #[cfg(target_os = "fuchsia")]
21706    fn signal_peer(
21707        &self,
21708        clear_mask: zx::Signals,
21709        set_mask: zx::Signals,
21710    ) -> Result<(), zx_status::Status> {
21711        use fidl::Peered;
21712        self.inner.channel().signal_peer(clear_mask, set_mask)
21713    }
21714}
21715
21716impl UsageReporterControlHandle {}
21717
21718#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
21719pub struct UsageWatcherMarker;
21720
21721impl fidl::endpoints::ProtocolMarker for UsageWatcherMarker {
21722    type Proxy = UsageWatcherProxy;
21723    type RequestStream = UsageWatcherRequestStream;
21724    #[cfg(target_os = "fuchsia")]
21725    type SynchronousProxy = UsageWatcherSynchronousProxy;
21726
21727    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher";
21728}
21729
21730pub trait UsageWatcherProxyInterface: Send + Sync {
21731    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
21732    fn r#on_state_changed(
21733        &self,
21734        usage: &Usage,
21735        state: &UsageState,
21736    ) -> Self::OnStateChangedResponseFut;
21737}
21738#[derive(Debug)]
21739#[cfg(target_os = "fuchsia")]
21740pub struct UsageWatcherSynchronousProxy {
21741    client: fidl::client::sync::Client,
21742}
21743
21744#[cfg(target_os = "fuchsia")]
21745impl fidl::endpoints::SynchronousProxy for UsageWatcherSynchronousProxy {
21746    type Proxy = UsageWatcherProxy;
21747    type Protocol = UsageWatcherMarker;
21748
21749    fn from_channel(inner: fidl::Channel) -> Self {
21750        Self::new(inner)
21751    }
21752
21753    fn into_channel(self) -> fidl::Channel {
21754        self.client.into_channel()
21755    }
21756
21757    fn as_channel(&self) -> &fidl::Channel {
21758        self.client.as_channel()
21759    }
21760}
21761
21762#[cfg(target_os = "fuchsia")]
21763impl UsageWatcherSynchronousProxy {
21764    pub fn new(channel: fidl::Channel) -> Self {
21765        Self { client: fidl::client::sync::Client::new(channel) }
21766    }
21767
21768    pub fn into_channel(self) -> fidl::Channel {
21769        self.client.into_channel()
21770    }
21771
21772    /// Waits until an event arrives and returns it. It is safe for other
21773    /// threads to make concurrent requests while waiting for an event.
21774    pub fn wait_for_event(
21775        &self,
21776        deadline: zx::MonotonicInstant,
21777    ) -> Result<UsageWatcherEvent, fidl::Error> {
21778        UsageWatcherEvent::decode(self.client.wait_for_event::<UsageWatcherMarker>(deadline)?)
21779    }
21780
21781    /// Called on first connection and whenever the watched usage changes. The provided
21782    /// usage will always be the bound usage; it is provided so that an implementation of
21783    /// this protocol may be bound to more than one usage.
21784    ///
21785    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
21786    /// events will eventually be disconnected.
21787    pub fn r#on_state_changed(
21788        &self,
21789        mut usage: &Usage,
21790        mut state: &UsageState,
21791        ___deadline: zx::MonotonicInstant,
21792    ) -> Result<(), fidl::Error> {
21793        let _response = self.client.send_query::<
21794            UsageWatcherOnStateChangedRequest,
21795            fidl::encoding::EmptyPayload,
21796            UsageWatcherMarker,
21797        >(
21798            (usage, state,),
21799            0x5b955c5768ec75c5,
21800            fidl::encoding::DynamicFlags::empty(),
21801            ___deadline,
21802        )?;
21803        Ok(_response)
21804    }
21805}
21806
21807#[cfg(target_os = "fuchsia")]
21808impl From<UsageWatcherSynchronousProxy> for zx::NullableHandle {
21809    fn from(value: UsageWatcherSynchronousProxy) -> Self {
21810        value.into_channel().into()
21811    }
21812}
21813
21814#[cfg(target_os = "fuchsia")]
21815impl From<fidl::Channel> for UsageWatcherSynchronousProxy {
21816    fn from(value: fidl::Channel) -> Self {
21817        Self::new(value)
21818    }
21819}
21820
21821#[cfg(target_os = "fuchsia")]
21822impl fidl::endpoints::FromClient for UsageWatcherSynchronousProxy {
21823    type Protocol = UsageWatcherMarker;
21824
21825    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcherMarker>) -> Self {
21826        Self::new(value.into_channel())
21827    }
21828}
21829
21830#[derive(Debug, Clone)]
21831pub struct UsageWatcherProxy {
21832    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
21833}
21834
21835impl fidl::endpoints::Proxy for UsageWatcherProxy {
21836    type Protocol = UsageWatcherMarker;
21837
21838    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
21839        Self::new(inner)
21840    }
21841
21842    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
21843        self.client.into_channel().map_err(|client| Self { client })
21844    }
21845
21846    fn as_channel(&self) -> &::fidl::AsyncChannel {
21847        self.client.as_channel()
21848    }
21849}
21850
21851impl UsageWatcherProxy {
21852    /// Create a new Proxy for fuchsia.media/UsageWatcher.
21853    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
21854        let protocol_name = <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
21855        Self { client: fidl::client::Client::new(channel, protocol_name) }
21856    }
21857
21858    /// Get a Stream of events from the remote end of the protocol.
21859    ///
21860    /// # Panics
21861    ///
21862    /// Panics if the event stream was already taken.
21863    pub fn take_event_stream(&self) -> UsageWatcherEventStream {
21864        UsageWatcherEventStream { event_receiver: self.client.take_event_receiver() }
21865    }
21866
21867    /// Called on first connection and whenever the watched usage changes. The provided
21868    /// usage will always be the bound usage; it is provided so that an implementation of
21869    /// this protocol may be bound to more than one usage.
21870    ///
21871    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
21872    /// events will eventually be disconnected.
21873    pub fn r#on_state_changed(
21874        &self,
21875        mut usage: &Usage,
21876        mut state: &UsageState,
21877    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
21878        UsageWatcherProxyInterface::r#on_state_changed(self, usage, state)
21879    }
21880}
21881
21882impl UsageWatcherProxyInterface for UsageWatcherProxy {
21883    type OnStateChangedResponseFut =
21884        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
21885    fn r#on_state_changed(
21886        &self,
21887        mut usage: &Usage,
21888        mut state: &UsageState,
21889    ) -> Self::OnStateChangedResponseFut {
21890        fn _decode(
21891            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
21892        ) -> Result<(), fidl::Error> {
21893            let _response = fidl::client::decode_transaction_body::<
21894                fidl::encoding::EmptyPayload,
21895                fidl::encoding::DefaultFuchsiaResourceDialect,
21896                0x5b955c5768ec75c5,
21897            >(_buf?)?;
21898            Ok(_response)
21899        }
21900        self.client.send_query_and_decode::<UsageWatcherOnStateChangedRequest, ()>(
21901            (usage, state),
21902            0x5b955c5768ec75c5,
21903            fidl::encoding::DynamicFlags::empty(),
21904            _decode,
21905        )
21906    }
21907}
21908
21909pub struct UsageWatcherEventStream {
21910    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
21911}
21912
21913impl std::marker::Unpin for UsageWatcherEventStream {}
21914
21915impl futures::stream::FusedStream for UsageWatcherEventStream {
21916    fn is_terminated(&self) -> bool {
21917        self.event_receiver.is_terminated()
21918    }
21919}
21920
21921impl futures::Stream for UsageWatcherEventStream {
21922    type Item = Result<UsageWatcherEvent, fidl::Error>;
21923
21924    fn poll_next(
21925        mut self: std::pin::Pin<&mut Self>,
21926        cx: &mut std::task::Context<'_>,
21927    ) -> std::task::Poll<Option<Self::Item>> {
21928        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
21929            &mut self.event_receiver,
21930            cx
21931        )?) {
21932            Some(buf) => std::task::Poll::Ready(Some(UsageWatcherEvent::decode(buf))),
21933            None => std::task::Poll::Ready(None),
21934        }
21935    }
21936}
21937
21938#[derive(Debug)]
21939pub enum UsageWatcherEvent {}
21940
21941impl UsageWatcherEvent {
21942    /// Decodes a message buffer as a [`UsageWatcherEvent`].
21943    fn decode(
21944        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
21945    ) -> Result<UsageWatcherEvent, fidl::Error> {
21946        let (bytes, _handles) = buf.split_mut();
21947        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
21948        debug_assert_eq!(tx_header.tx_id, 0);
21949        match tx_header.ordinal {
21950            _ => Err(fidl::Error::UnknownOrdinal {
21951                ordinal: tx_header.ordinal,
21952                protocol_name: <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
21953            }),
21954        }
21955    }
21956}
21957
21958/// A Stream of incoming requests for fuchsia.media/UsageWatcher.
21959pub struct UsageWatcherRequestStream {
21960    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21961    is_terminated: bool,
21962}
21963
21964impl std::marker::Unpin for UsageWatcherRequestStream {}
21965
21966impl futures::stream::FusedStream for UsageWatcherRequestStream {
21967    fn is_terminated(&self) -> bool {
21968        self.is_terminated
21969    }
21970}
21971
21972impl fidl::endpoints::RequestStream for UsageWatcherRequestStream {
21973    type Protocol = UsageWatcherMarker;
21974    type ControlHandle = UsageWatcherControlHandle;
21975
21976    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
21977        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
21978    }
21979
21980    fn control_handle(&self) -> Self::ControlHandle {
21981        UsageWatcherControlHandle { inner: self.inner.clone() }
21982    }
21983
21984    fn into_inner(
21985        self,
21986    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
21987    {
21988        (self.inner, self.is_terminated)
21989    }
21990
21991    fn from_inner(
21992        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
21993        is_terminated: bool,
21994    ) -> Self {
21995        Self { inner, is_terminated }
21996    }
21997}
21998
21999impl futures::Stream for UsageWatcherRequestStream {
22000    type Item = Result<UsageWatcherRequest, fidl::Error>;
22001
22002    fn poll_next(
22003        mut self: std::pin::Pin<&mut Self>,
22004        cx: &mut std::task::Context<'_>,
22005    ) -> std::task::Poll<Option<Self::Item>> {
22006        let this = &mut *self;
22007        if this.inner.check_shutdown(cx) {
22008            this.is_terminated = true;
22009            return std::task::Poll::Ready(None);
22010        }
22011        if this.is_terminated {
22012            panic!("polled UsageWatcherRequestStream after completion");
22013        }
22014        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
22015            |bytes, handles| {
22016                match this.inner.channel().read_etc(cx, bytes, handles) {
22017                    std::task::Poll::Ready(Ok(())) => {}
22018                    std::task::Poll::Pending => return std::task::Poll::Pending,
22019                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
22020                        this.is_terminated = true;
22021                        return std::task::Poll::Ready(None);
22022                    }
22023                    std::task::Poll::Ready(Err(e)) => {
22024                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
22025                            e.into(),
22026                        ))));
22027                    }
22028                }
22029
22030                // A message has been received from the channel
22031                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
22032
22033                std::task::Poll::Ready(Some(match header.ordinal {
22034                    0x5b955c5768ec75c5 => {
22035                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
22036                        let mut req = fidl::new_empty!(
22037                            UsageWatcherOnStateChangedRequest,
22038                            fidl::encoding::DefaultFuchsiaResourceDialect
22039                        );
22040                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcherOnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
22041                        let control_handle =
22042                            UsageWatcherControlHandle { inner: this.inner.clone() };
22043                        Ok(UsageWatcherRequest::OnStateChanged {
22044                            usage: req.usage,
22045                            state: req.state,
22046
22047                            responder: UsageWatcherOnStateChangedResponder {
22048                                control_handle: std::mem::ManuallyDrop::new(control_handle),
22049                                tx_id: header.tx_id,
22050                            },
22051                        })
22052                    }
22053                    _ => Err(fidl::Error::UnknownOrdinal {
22054                        ordinal: header.ordinal,
22055                        protocol_name:
22056                            <UsageWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
22057                    }),
22058                }))
22059            },
22060        )
22061    }
22062}
22063
22064/// A protocol for listening to changes to the policy state of an audio usage.
22065///
22066/// User actions, such as lowering the volume or muting a stream, are not reflected in this API.
22067#[derive(Debug)]
22068pub enum UsageWatcherRequest {
22069    /// Called on first connection and whenever the watched usage changes. The provided
22070    /// usage will always be the bound usage; it is provided so that an implementation of
22071    /// this protocol may be bound to more than one usage.
22072    ///
22073    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22074    /// events will eventually be disconnected.
22075    OnStateChanged {
22076        usage: Usage,
22077        state: UsageState,
22078        responder: UsageWatcherOnStateChangedResponder,
22079    },
22080}
22081
22082impl UsageWatcherRequest {
22083    #[allow(irrefutable_let_patterns)]
22084    pub fn into_on_state_changed(
22085        self,
22086    ) -> Option<(Usage, UsageState, UsageWatcherOnStateChangedResponder)> {
22087        if let UsageWatcherRequest::OnStateChanged { usage, state, responder } = self {
22088            Some((usage, state, responder))
22089        } else {
22090            None
22091        }
22092    }
22093
22094    /// Name of the method defined in FIDL
22095    pub fn method_name(&self) -> &'static str {
22096        match *self {
22097            UsageWatcherRequest::OnStateChanged { .. } => "on_state_changed",
22098        }
22099    }
22100}
22101
22102#[derive(Debug, Clone)]
22103pub struct UsageWatcherControlHandle {
22104    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22105}
22106
22107impl UsageWatcherControlHandle {
22108    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
22109        self.inner.shutdown_with_epitaph(status.into())
22110    }
22111}
22112
22113impl fidl::endpoints::ControlHandle for UsageWatcherControlHandle {
22114    fn shutdown(&self) {
22115        self.inner.shutdown()
22116    }
22117
22118    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
22119        self.inner.shutdown_with_epitaph(status)
22120    }
22121
22122    fn is_closed(&self) -> bool {
22123        self.inner.channel().is_closed()
22124    }
22125    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
22126        self.inner.channel().on_closed()
22127    }
22128
22129    #[cfg(target_os = "fuchsia")]
22130    fn signal_peer(
22131        &self,
22132        clear_mask: zx::Signals,
22133        set_mask: zx::Signals,
22134    ) -> Result<(), zx_status::Status> {
22135        use fidl::Peered;
22136        self.inner.channel().signal_peer(clear_mask, set_mask)
22137    }
22138}
22139
22140impl UsageWatcherControlHandle {}
22141
22142#[must_use = "FIDL methods require a response to be sent"]
22143#[derive(Debug)]
22144pub struct UsageWatcherOnStateChangedResponder {
22145    control_handle: std::mem::ManuallyDrop<UsageWatcherControlHandle>,
22146    tx_id: u32,
22147}
22148
22149/// Set the the channel to be shutdown (see [`UsageWatcherControlHandle::shutdown`])
22150/// if the responder is dropped without sending a response, so that the client
22151/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
22152impl std::ops::Drop for UsageWatcherOnStateChangedResponder {
22153    fn drop(&mut self) {
22154        self.control_handle.shutdown();
22155        // Safety: drops once, never accessed again
22156        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22157    }
22158}
22159
22160impl fidl::endpoints::Responder for UsageWatcherOnStateChangedResponder {
22161    type ControlHandle = UsageWatcherControlHandle;
22162
22163    fn control_handle(&self) -> &UsageWatcherControlHandle {
22164        &self.control_handle
22165    }
22166
22167    fn drop_without_shutdown(mut self) {
22168        // Safety: drops once, never accessed again due to mem::forget
22169        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22170        // Prevent Drop from running (which would shut down the channel)
22171        std::mem::forget(self);
22172    }
22173}
22174
22175impl UsageWatcherOnStateChangedResponder {
22176    /// Sends a response to the FIDL transaction.
22177    ///
22178    /// Sets the channel to shutdown if an error occurs.
22179    pub fn send(self) -> Result<(), fidl::Error> {
22180        let _result = self.send_raw();
22181        if _result.is_err() {
22182            self.control_handle.shutdown();
22183        }
22184        self.drop_without_shutdown();
22185        _result
22186    }
22187
22188    /// Similar to "send" but does not shutdown the channel if an error occurs.
22189    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
22190        let _result = self.send_raw();
22191        self.drop_without_shutdown();
22192        _result
22193    }
22194
22195    fn send_raw(&self) -> Result<(), fidl::Error> {
22196        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
22197            (),
22198            self.tx_id,
22199            0x5b955c5768ec75c5,
22200            fidl::encoding::DynamicFlags::empty(),
22201        )
22202    }
22203}
22204
22205#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22206pub struct UsageWatcher2Marker;
22207
22208impl fidl::endpoints::ProtocolMarker for UsageWatcher2Marker {
22209    type Proxy = UsageWatcher2Proxy;
22210    type RequestStream = UsageWatcher2RequestStream;
22211    #[cfg(target_os = "fuchsia")]
22212    type SynchronousProxy = UsageWatcher2SynchronousProxy;
22213
22214    const DEBUG_NAME: &'static str = "(anonymous) UsageWatcher2";
22215}
22216
22217pub trait UsageWatcher2ProxyInterface: Send + Sync {
22218    type OnStateChangedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
22219    fn r#on_state_changed(
22220        &self,
22221        usage: &Usage2,
22222        state: &UsageState,
22223    ) -> Self::OnStateChangedResponseFut;
22224}
22225#[derive(Debug)]
22226#[cfg(target_os = "fuchsia")]
22227pub struct UsageWatcher2SynchronousProxy {
22228    client: fidl::client::sync::Client,
22229}
22230
22231#[cfg(target_os = "fuchsia")]
22232impl fidl::endpoints::SynchronousProxy for UsageWatcher2SynchronousProxy {
22233    type Proxy = UsageWatcher2Proxy;
22234    type Protocol = UsageWatcher2Marker;
22235
22236    fn from_channel(inner: fidl::Channel) -> Self {
22237        Self::new(inner)
22238    }
22239
22240    fn into_channel(self) -> fidl::Channel {
22241        self.client.into_channel()
22242    }
22243
22244    fn as_channel(&self) -> &fidl::Channel {
22245        self.client.as_channel()
22246    }
22247}
22248
22249#[cfg(target_os = "fuchsia")]
22250impl UsageWatcher2SynchronousProxy {
22251    pub fn new(channel: fidl::Channel) -> Self {
22252        Self { client: fidl::client::sync::Client::new(channel) }
22253    }
22254
22255    pub fn into_channel(self) -> fidl::Channel {
22256        self.client.into_channel()
22257    }
22258
22259    /// Waits until an event arrives and returns it. It is safe for other
22260    /// threads to make concurrent requests while waiting for an event.
22261    pub fn wait_for_event(
22262        &self,
22263        deadline: zx::MonotonicInstant,
22264    ) -> Result<UsageWatcher2Event, fidl::Error> {
22265        UsageWatcher2Event::decode(self.client.wait_for_event::<UsageWatcher2Marker>(deadline)?)
22266    }
22267
22268    /// Called on first connection and whenever the watched usage changes. The provided
22269    /// usage will always be the bound usage; it is provided so that an implementation of
22270    /// this protocol may be bound to more than one usage.
22271    ///
22272    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22273    /// events will eventually be disconnected.
22274    pub fn r#on_state_changed(
22275        &self,
22276        mut usage: &Usage2,
22277        mut state: &UsageState,
22278        ___deadline: zx::MonotonicInstant,
22279    ) -> Result<(), fidl::Error> {
22280        let _response = self.client.send_query::<
22281            UsageWatcher2OnStateChangedRequest,
22282            fidl::encoding::EmptyPayload,
22283            UsageWatcher2Marker,
22284        >(
22285            (usage, state,),
22286            0xca31a8b13c324d4,
22287            fidl::encoding::DynamicFlags::empty(),
22288            ___deadline,
22289        )?;
22290        Ok(_response)
22291    }
22292}
22293
22294#[cfg(target_os = "fuchsia")]
22295impl From<UsageWatcher2SynchronousProxy> for zx::NullableHandle {
22296    fn from(value: UsageWatcher2SynchronousProxy) -> Self {
22297        value.into_channel().into()
22298    }
22299}
22300
22301#[cfg(target_os = "fuchsia")]
22302impl From<fidl::Channel> for UsageWatcher2SynchronousProxy {
22303    fn from(value: fidl::Channel) -> Self {
22304        Self::new(value)
22305    }
22306}
22307
22308#[cfg(target_os = "fuchsia")]
22309impl fidl::endpoints::FromClient for UsageWatcher2SynchronousProxy {
22310    type Protocol = UsageWatcher2Marker;
22311
22312    fn from_client(value: fidl::endpoints::ClientEnd<UsageWatcher2Marker>) -> Self {
22313        Self::new(value.into_channel())
22314    }
22315}
22316
22317#[derive(Debug, Clone)]
22318pub struct UsageWatcher2Proxy {
22319    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
22320}
22321
22322impl fidl::endpoints::Proxy for UsageWatcher2Proxy {
22323    type Protocol = UsageWatcher2Marker;
22324
22325    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
22326        Self::new(inner)
22327    }
22328
22329    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
22330        self.client.into_channel().map_err(|client| Self { client })
22331    }
22332
22333    fn as_channel(&self) -> &::fidl::AsyncChannel {
22334        self.client.as_channel()
22335    }
22336}
22337
22338impl UsageWatcher2Proxy {
22339    /// Create a new Proxy for fuchsia.media/UsageWatcher2.
22340    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
22341        let protocol_name = <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
22342        Self { client: fidl::client::Client::new(channel, protocol_name) }
22343    }
22344
22345    /// Get a Stream of events from the remote end of the protocol.
22346    ///
22347    /// # Panics
22348    ///
22349    /// Panics if the event stream was already taken.
22350    pub fn take_event_stream(&self) -> UsageWatcher2EventStream {
22351        UsageWatcher2EventStream { event_receiver: self.client.take_event_receiver() }
22352    }
22353
22354    /// Called on first connection and whenever the watched usage changes. The provided
22355    /// usage will always be the bound usage; it is provided so that an implementation of
22356    /// this protocol may be bound to more than one usage.
22357    ///
22358    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22359    /// events will eventually be disconnected.
22360    pub fn r#on_state_changed(
22361        &self,
22362        mut usage: &Usage2,
22363        mut state: &UsageState,
22364    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
22365        UsageWatcher2ProxyInterface::r#on_state_changed(self, usage, state)
22366    }
22367}
22368
22369impl UsageWatcher2ProxyInterface for UsageWatcher2Proxy {
22370    type OnStateChangedResponseFut =
22371        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
22372    fn r#on_state_changed(
22373        &self,
22374        mut usage: &Usage2,
22375        mut state: &UsageState,
22376    ) -> Self::OnStateChangedResponseFut {
22377        fn _decode(
22378            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
22379        ) -> Result<(), fidl::Error> {
22380            let _response = fidl::client::decode_transaction_body::<
22381                fidl::encoding::EmptyPayload,
22382                fidl::encoding::DefaultFuchsiaResourceDialect,
22383                0xca31a8b13c324d4,
22384            >(_buf?)?;
22385            Ok(_response)
22386        }
22387        self.client.send_query_and_decode::<UsageWatcher2OnStateChangedRequest, ()>(
22388            (usage, state),
22389            0xca31a8b13c324d4,
22390            fidl::encoding::DynamicFlags::empty(),
22391            _decode,
22392        )
22393    }
22394}
22395
22396pub struct UsageWatcher2EventStream {
22397    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
22398}
22399
22400impl std::marker::Unpin for UsageWatcher2EventStream {}
22401
22402impl futures::stream::FusedStream for UsageWatcher2EventStream {
22403    fn is_terminated(&self) -> bool {
22404        self.event_receiver.is_terminated()
22405    }
22406}
22407
22408impl futures::Stream for UsageWatcher2EventStream {
22409    type Item = Result<UsageWatcher2Event, fidl::Error>;
22410
22411    fn poll_next(
22412        mut self: std::pin::Pin<&mut Self>,
22413        cx: &mut std::task::Context<'_>,
22414    ) -> std::task::Poll<Option<Self::Item>> {
22415        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
22416            &mut self.event_receiver,
22417            cx
22418        )?) {
22419            Some(buf) => std::task::Poll::Ready(Some(UsageWatcher2Event::decode(buf))),
22420            None => std::task::Poll::Ready(None),
22421        }
22422    }
22423}
22424
22425#[derive(Debug)]
22426pub enum UsageWatcher2Event {}
22427
22428impl UsageWatcher2Event {
22429    /// Decodes a message buffer as a [`UsageWatcher2Event`].
22430    fn decode(
22431        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
22432    ) -> Result<UsageWatcher2Event, fidl::Error> {
22433        let (bytes, _handles) = buf.split_mut();
22434        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
22435        debug_assert_eq!(tx_header.tx_id, 0);
22436        match tx_header.ordinal {
22437            _ => Err(fidl::Error::UnknownOrdinal {
22438                ordinal: tx_header.ordinal,
22439                protocol_name: <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
22440            }),
22441        }
22442    }
22443}
22444
22445/// A Stream of incoming requests for fuchsia.media/UsageWatcher2.
22446pub struct UsageWatcher2RequestStream {
22447    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22448    is_terminated: bool,
22449}
22450
22451impl std::marker::Unpin for UsageWatcher2RequestStream {}
22452
22453impl futures::stream::FusedStream for UsageWatcher2RequestStream {
22454    fn is_terminated(&self) -> bool {
22455        self.is_terminated
22456    }
22457}
22458
22459impl fidl::endpoints::RequestStream for UsageWatcher2RequestStream {
22460    type Protocol = UsageWatcher2Marker;
22461    type ControlHandle = UsageWatcher2ControlHandle;
22462
22463    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
22464        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
22465    }
22466
22467    fn control_handle(&self) -> Self::ControlHandle {
22468        UsageWatcher2ControlHandle { inner: self.inner.clone() }
22469    }
22470
22471    fn into_inner(
22472        self,
22473    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
22474    {
22475        (self.inner, self.is_terminated)
22476    }
22477
22478    fn from_inner(
22479        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22480        is_terminated: bool,
22481    ) -> Self {
22482        Self { inner, is_terminated }
22483    }
22484}
22485
22486impl futures::Stream for UsageWatcher2RequestStream {
22487    type Item = Result<UsageWatcher2Request, fidl::Error>;
22488
22489    fn poll_next(
22490        mut self: std::pin::Pin<&mut Self>,
22491        cx: &mut std::task::Context<'_>,
22492    ) -> std::task::Poll<Option<Self::Item>> {
22493        let this = &mut *self;
22494        if this.inner.check_shutdown(cx) {
22495            this.is_terminated = true;
22496            return std::task::Poll::Ready(None);
22497        }
22498        if this.is_terminated {
22499            panic!("polled UsageWatcher2RequestStream after completion");
22500        }
22501        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
22502            |bytes, handles| {
22503                match this.inner.channel().read_etc(cx, bytes, handles) {
22504                    std::task::Poll::Ready(Ok(())) => {}
22505                    std::task::Poll::Pending => return std::task::Poll::Pending,
22506                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
22507                        this.is_terminated = true;
22508                        return std::task::Poll::Ready(None);
22509                    }
22510                    std::task::Poll::Ready(Err(e)) => {
22511                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
22512                            e.into(),
22513                        ))));
22514                    }
22515                }
22516
22517                // A message has been received from the channel
22518                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
22519
22520                std::task::Poll::Ready(Some(match header.ordinal {
22521                    0xca31a8b13c324d4 => {
22522                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
22523                        let mut req = fidl::new_empty!(
22524                            UsageWatcher2OnStateChangedRequest,
22525                            fidl::encoding::DefaultFuchsiaResourceDialect
22526                        );
22527                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsageWatcher2OnStateChangedRequest>(&header, _body_bytes, handles, &mut req)?;
22528                        let control_handle =
22529                            UsageWatcher2ControlHandle { inner: this.inner.clone() };
22530                        Ok(UsageWatcher2Request::OnStateChanged {
22531                            usage: req.usage,
22532                            state: req.state,
22533
22534                            responder: UsageWatcher2OnStateChangedResponder {
22535                                control_handle: std::mem::ManuallyDrop::new(control_handle),
22536                                tx_id: header.tx_id,
22537                            },
22538                        })
22539                    }
22540                    _ => Err(fidl::Error::UnknownOrdinal {
22541                        ordinal: header.ordinal,
22542                        protocol_name:
22543                            <UsageWatcher2Marker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
22544                    }),
22545                }))
22546            },
22547        )
22548    }
22549}
22550
22551#[derive(Debug)]
22552pub enum UsageWatcher2Request {
22553    /// Called on first connection and whenever the watched usage changes. The provided
22554    /// usage will always be the bound usage; it is provided so that an implementation of
22555    /// this protocol may be bound to more than one usage.
22556    ///
22557    /// Clients must respond to acknowledge the event. Clients that do not acknowledge their
22558    /// events will eventually be disconnected.
22559    OnStateChanged {
22560        usage: Usage2,
22561        state: UsageState,
22562        responder: UsageWatcher2OnStateChangedResponder,
22563    },
22564}
22565
22566impl UsageWatcher2Request {
22567    #[allow(irrefutable_let_patterns)]
22568    pub fn into_on_state_changed(
22569        self,
22570    ) -> Option<(Usage2, UsageState, UsageWatcher2OnStateChangedResponder)> {
22571        if let UsageWatcher2Request::OnStateChanged { usage, state, responder } = self {
22572            Some((usage, state, responder))
22573        } else {
22574            None
22575        }
22576    }
22577
22578    /// Name of the method defined in FIDL
22579    pub fn method_name(&self) -> &'static str {
22580        match *self {
22581            UsageWatcher2Request::OnStateChanged { .. } => "on_state_changed",
22582        }
22583    }
22584}
22585
22586#[derive(Debug, Clone)]
22587pub struct UsageWatcher2ControlHandle {
22588    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
22589}
22590
22591impl UsageWatcher2ControlHandle {
22592    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
22593        self.inner.shutdown_with_epitaph(status.into())
22594    }
22595}
22596
22597impl fidl::endpoints::ControlHandle for UsageWatcher2ControlHandle {
22598    fn shutdown(&self) {
22599        self.inner.shutdown()
22600    }
22601
22602    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
22603        self.inner.shutdown_with_epitaph(status)
22604    }
22605
22606    fn is_closed(&self) -> bool {
22607        self.inner.channel().is_closed()
22608    }
22609    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
22610        self.inner.channel().on_closed()
22611    }
22612
22613    #[cfg(target_os = "fuchsia")]
22614    fn signal_peer(
22615        &self,
22616        clear_mask: zx::Signals,
22617        set_mask: zx::Signals,
22618    ) -> Result<(), zx_status::Status> {
22619        use fidl::Peered;
22620        self.inner.channel().signal_peer(clear_mask, set_mask)
22621    }
22622}
22623
22624impl UsageWatcher2ControlHandle {}
22625
22626#[must_use = "FIDL methods require a response to be sent"]
22627#[derive(Debug)]
22628pub struct UsageWatcher2OnStateChangedResponder {
22629    control_handle: std::mem::ManuallyDrop<UsageWatcher2ControlHandle>,
22630    tx_id: u32,
22631}
22632
22633/// Set the the channel to be shutdown (see [`UsageWatcher2ControlHandle::shutdown`])
22634/// if the responder is dropped without sending a response, so that the client
22635/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
22636impl std::ops::Drop for UsageWatcher2OnStateChangedResponder {
22637    fn drop(&mut self) {
22638        self.control_handle.shutdown();
22639        // Safety: drops once, never accessed again
22640        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22641    }
22642}
22643
22644impl fidl::endpoints::Responder for UsageWatcher2OnStateChangedResponder {
22645    type ControlHandle = UsageWatcher2ControlHandle;
22646
22647    fn control_handle(&self) -> &UsageWatcher2ControlHandle {
22648        &self.control_handle
22649    }
22650
22651    fn drop_without_shutdown(mut self) {
22652        // Safety: drops once, never accessed again due to mem::forget
22653        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
22654        // Prevent Drop from running (which would shut down the channel)
22655        std::mem::forget(self);
22656    }
22657}
22658
22659impl UsageWatcher2OnStateChangedResponder {
22660    /// Sends a response to the FIDL transaction.
22661    ///
22662    /// Sets the channel to shutdown if an error occurs.
22663    pub fn send(self) -> Result<(), fidl::Error> {
22664        let _result = self.send_raw();
22665        if _result.is_err() {
22666            self.control_handle.shutdown();
22667        }
22668        self.drop_without_shutdown();
22669        _result
22670    }
22671
22672    /// Similar to "send" but does not shutdown the channel if an error occurs.
22673    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
22674        let _result = self.send_raw();
22675        self.drop_without_shutdown();
22676        _result
22677    }
22678
22679    fn send_raw(&self) -> Result<(), fidl::Error> {
22680        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
22681            (),
22682            self.tx_id,
22683            0xca31a8b13c324d4,
22684            fidl::encoding::DynamicFlags::empty(),
22685        )
22686    }
22687}
22688
22689mod internal {
22690    use super::*;
22691
22692    impl fidl::encoding::ResourceTypeMarker for AudioCapturerBindGainControlRequest {
22693        type Borrowed<'a> = &'a mut Self;
22694        fn take_or_borrow<'a>(
22695            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22696        ) -> Self::Borrowed<'a> {
22697            value
22698        }
22699    }
22700
22701    unsafe impl fidl::encoding::TypeMarker for AudioCapturerBindGainControlRequest {
22702        type Owned = Self;
22703
22704        #[inline(always)]
22705        fn inline_align(_context: fidl::encoding::Context) -> usize {
22706            4
22707        }
22708
22709        #[inline(always)]
22710        fn inline_size(_context: fidl::encoding::Context) -> usize {
22711            4
22712        }
22713    }
22714
22715    unsafe impl
22716        fidl::encoding::Encode<
22717            AudioCapturerBindGainControlRequest,
22718            fidl::encoding::DefaultFuchsiaResourceDialect,
22719        > for &mut AudioCapturerBindGainControlRequest
22720    {
22721        #[inline]
22722        unsafe fn encode(
22723            self,
22724            encoder: &mut fidl::encoding::Encoder<
22725                '_,
22726                fidl::encoding::DefaultFuchsiaResourceDialect,
22727            >,
22728            offset: usize,
22729            _depth: fidl::encoding::Depth,
22730        ) -> fidl::Result<()> {
22731            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
22732            // Delegate to tuple encoding.
22733            fidl::encoding::Encode::<
22734                AudioCapturerBindGainControlRequest,
22735                fidl::encoding::DefaultFuchsiaResourceDialect,
22736            >::encode(
22737                (<fidl::encoding::Endpoint<
22738                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22739                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22740                    &mut self.gain_control_request,
22741                ),),
22742                encoder,
22743                offset,
22744                _depth,
22745            )
22746        }
22747    }
22748    unsafe impl<
22749        T0: fidl::encoding::Encode<
22750                fidl::encoding::Endpoint<
22751                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22752                >,
22753                fidl::encoding::DefaultFuchsiaResourceDialect,
22754            >,
22755    >
22756        fidl::encoding::Encode<
22757            AudioCapturerBindGainControlRequest,
22758            fidl::encoding::DefaultFuchsiaResourceDialect,
22759        > for (T0,)
22760    {
22761        #[inline]
22762        unsafe fn encode(
22763            self,
22764            encoder: &mut fidl::encoding::Encoder<
22765                '_,
22766                fidl::encoding::DefaultFuchsiaResourceDialect,
22767            >,
22768            offset: usize,
22769            depth: fidl::encoding::Depth,
22770        ) -> fidl::Result<()> {
22771            encoder.debug_check_bounds::<AudioCapturerBindGainControlRequest>(offset);
22772            // Zero out padding regions. There's no need to apply masks
22773            // because the unmasked parts will be overwritten by fields.
22774            // Write the fields.
22775            self.0.encode(encoder, offset + 0, depth)?;
22776            Ok(())
22777        }
22778    }
22779
22780    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22781        for AudioCapturerBindGainControlRequest
22782    {
22783        #[inline(always)]
22784        fn new_empty() -> Self {
22785            Self {
22786                gain_control_request: fidl::new_empty!(
22787                    fidl::encoding::Endpoint<
22788                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22789                    >,
22790                    fidl::encoding::DefaultFuchsiaResourceDialect
22791                ),
22792            }
22793        }
22794
22795        #[inline]
22796        unsafe fn decode(
22797            &mut self,
22798            decoder: &mut fidl::encoding::Decoder<
22799                '_,
22800                fidl::encoding::DefaultFuchsiaResourceDialect,
22801            >,
22802            offset: usize,
22803            _depth: fidl::encoding::Depth,
22804        ) -> fidl::Result<()> {
22805            decoder.debug_check_bounds::<Self>(offset);
22806            // Verify that padding bytes are zero.
22807            fidl::decode!(
22808                fidl::encoding::Endpoint<
22809                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
22810                >,
22811                fidl::encoding::DefaultFuchsiaResourceDialect,
22812                &mut self.gain_control_request,
22813                decoder,
22814                offset + 0,
22815                _depth
22816            )?;
22817            Ok(())
22818        }
22819    }
22820
22821    impl fidl::encoding::ResourceTypeMarker for AudioCapturerGetReferenceClockResponse {
22822        type Borrowed<'a> = &'a mut Self;
22823        fn take_or_borrow<'a>(
22824            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22825        ) -> Self::Borrowed<'a> {
22826            value
22827        }
22828    }
22829
22830    unsafe impl fidl::encoding::TypeMarker for AudioCapturerGetReferenceClockResponse {
22831        type Owned = Self;
22832
22833        #[inline(always)]
22834        fn inline_align(_context: fidl::encoding::Context) -> usize {
22835            4
22836        }
22837
22838        #[inline(always)]
22839        fn inline_size(_context: fidl::encoding::Context) -> usize {
22840            4
22841        }
22842    }
22843
22844    unsafe impl
22845        fidl::encoding::Encode<
22846            AudioCapturerGetReferenceClockResponse,
22847            fidl::encoding::DefaultFuchsiaResourceDialect,
22848        > for &mut AudioCapturerGetReferenceClockResponse
22849    {
22850        #[inline]
22851        unsafe fn encode(
22852            self,
22853            encoder: &mut fidl::encoding::Encoder<
22854                '_,
22855                fidl::encoding::DefaultFuchsiaResourceDialect,
22856            >,
22857            offset: usize,
22858            _depth: fidl::encoding::Depth,
22859        ) -> fidl::Result<()> {
22860            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
22861            // Delegate to tuple encoding.
22862            fidl::encoding::Encode::<
22863                AudioCapturerGetReferenceClockResponse,
22864                fidl::encoding::DefaultFuchsiaResourceDialect,
22865            >::encode(
22866                (<fidl::encoding::HandleType<
22867                    fidl::Clock,
22868                    { fidl::ObjectType::CLOCK.into_raw() },
22869                    2147483648,
22870                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22871                    &mut self.reference_clock,
22872                ),),
22873                encoder,
22874                offset,
22875                _depth,
22876            )
22877        }
22878    }
22879    unsafe impl<
22880        T0: fidl::encoding::Encode<
22881                fidl::encoding::HandleType<
22882                    fidl::Clock,
22883                    { fidl::ObjectType::CLOCK.into_raw() },
22884                    2147483648,
22885                >,
22886                fidl::encoding::DefaultFuchsiaResourceDialect,
22887            >,
22888    >
22889        fidl::encoding::Encode<
22890            AudioCapturerGetReferenceClockResponse,
22891            fidl::encoding::DefaultFuchsiaResourceDialect,
22892        > for (T0,)
22893    {
22894        #[inline]
22895        unsafe fn encode(
22896            self,
22897            encoder: &mut fidl::encoding::Encoder<
22898                '_,
22899                fidl::encoding::DefaultFuchsiaResourceDialect,
22900            >,
22901            offset: usize,
22902            depth: fidl::encoding::Depth,
22903        ) -> fidl::Result<()> {
22904            encoder.debug_check_bounds::<AudioCapturerGetReferenceClockResponse>(offset);
22905            // Zero out padding regions. There's no need to apply masks
22906            // because the unmasked parts will be overwritten by fields.
22907            // Write the fields.
22908            self.0.encode(encoder, offset + 0, depth)?;
22909            Ok(())
22910        }
22911    }
22912
22913    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
22914        for AudioCapturerGetReferenceClockResponse
22915    {
22916        #[inline(always)]
22917        fn new_empty() -> Self {
22918            Self {
22919                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
22920            }
22921        }
22922
22923        #[inline]
22924        unsafe fn decode(
22925            &mut self,
22926            decoder: &mut fidl::encoding::Decoder<
22927                '_,
22928                fidl::encoding::DefaultFuchsiaResourceDialect,
22929            >,
22930            offset: usize,
22931            _depth: fidl::encoding::Depth,
22932        ) -> fidl::Result<()> {
22933            decoder.debug_check_bounds::<Self>(offset);
22934            // Verify that padding bytes are zero.
22935            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
22936            Ok(())
22937        }
22938    }
22939
22940    impl fidl::encoding::ResourceTypeMarker for AudioCapturerSetReferenceClockRequest {
22941        type Borrowed<'a> = &'a mut Self;
22942        fn take_or_borrow<'a>(
22943            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
22944        ) -> Self::Borrowed<'a> {
22945            value
22946        }
22947    }
22948
22949    unsafe impl fidl::encoding::TypeMarker for AudioCapturerSetReferenceClockRequest {
22950        type Owned = Self;
22951
22952        #[inline(always)]
22953        fn inline_align(_context: fidl::encoding::Context) -> usize {
22954            4
22955        }
22956
22957        #[inline(always)]
22958        fn inline_size(_context: fidl::encoding::Context) -> usize {
22959            4
22960        }
22961    }
22962
22963    unsafe impl
22964        fidl::encoding::Encode<
22965            AudioCapturerSetReferenceClockRequest,
22966            fidl::encoding::DefaultFuchsiaResourceDialect,
22967        > for &mut AudioCapturerSetReferenceClockRequest
22968    {
22969        #[inline]
22970        unsafe fn encode(
22971            self,
22972            encoder: &mut fidl::encoding::Encoder<
22973                '_,
22974                fidl::encoding::DefaultFuchsiaResourceDialect,
22975            >,
22976            offset: usize,
22977            _depth: fidl::encoding::Depth,
22978        ) -> fidl::Result<()> {
22979            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
22980            // Delegate to tuple encoding.
22981            fidl::encoding::Encode::<
22982                AudioCapturerSetReferenceClockRequest,
22983                fidl::encoding::DefaultFuchsiaResourceDialect,
22984            >::encode(
22985                (<fidl::encoding::Optional<
22986                    fidl::encoding::HandleType<
22987                        fidl::Clock,
22988                        { fidl::ObjectType::CLOCK.into_raw() },
22989                        2147483648,
22990                    >,
22991                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
22992                    &mut self.reference_clock,
22993                ),),
22994                encoder,
22995                offset,
22996                _depth,
22997            )
22998        }
22999    }
23000    unsafe impl<
23001        T0: fidl::encoding::Encode<
23002                fidl::encoding::Optional<
23003                    fidl::encoding::HandleType<
23004                        fidl::Clock,
23005                        { fidl::ObjectType::CLOCK.into_raw() },
23006                        2147483648,
23007                    >,
23008                >,
23009                fidl::encoding::DefaultFuchsiaResourceDialect,
23010            >,
23011    >
23012        fidl::encoding::Encode<
23013            AudioCapturerSetReferenceClockRequest,
23014            fidl::encoding::DefaultFuchsiaResourceDialect,
23015        > for (T0,)
23016    {
23017        #[inline]
23018        unsafe fn encode(
23019            self,
23020            encoder: &mut fidl::encoding::Encoder<
23021                '_,
23022                fidl::encoding::DefaultFuchsiaResourceDialect,
23023            >,
23024            offset: usize,
23025            depth: fidl::encoding::Depth,
23026        ) -> fidl::Result<()> {
23027            encoder.debug_check_bounds::<AudioCapturerSetReferenceClockRequest>(offset);
23028            // Zero out padding regions. There's no need to apply masks
23029            // because the unmasked parts will be overwritten by fields.
23030            // Write the fields.
23031            self.0.encode(encoder, offset + 0, depth)?;
23032            Ok(())
23033        }
23034    }
23035
23036    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23037        for AudioCapturerSetReferenceClockRequest
23038    {
23039        #[inline(always)]
23040        fn new_empty() -> Self {
23041            Self {
23042                reference_clock: fidl::new_empty!(
23043                    fidl::encoding::Optional<
23044                        fidl::encoding::HandleType<
23045                            fidl::Clock,
23046                            { fidl::ObjectType::CLOCK.into_raw() },
23047                            2147483648,
23048                        >,
23049                    >,
23050                    fidl::encoding::DefaultFuchsiaResourceDialect
23051                ),
23052            }
23053        }
23054
23055        #[inline]
23056        unsafe fn decode(
23057            &mut self,
23058            decoder: &mut fidl::encoding::Decoder<
23059                '_,
23060                fidl::encoding::DefaultFuchsiaResourceDialect,
23061            >,
23062            offset: usize,
23063            _depth: fidl::encoding::Depth,
23064        ) -> fidl::Result<()> {
23065            decoder.debug_check_bounds::<Self>(offset);
23066            // Verify that padding bytes are zero.
23067            fidl::decode!(
23068                fidl::encoding::Optional<
23069                    fidl::encoding::HandleType<
23070                        fidl::Clock,
23071                        { fidl::ObjectType::CLOCK.into_raw() },
23072                        2147483648,
23073                    >,
23074                >,
23075                fidl::encoding::DefaultFuchsiaResourceDialect,
23076                &mut self.reference_clock,
23077                decoder,
23078                offset + 0,
23079                _depth
23080            )?;
23081            Ok(())
23082        }
23083    }
23084
23085    impl fidl::encoding::ResourceTypeMarker for AudioConsumerBindVolumeControlRequest {
23086        type Borrowed<'a> = &'a mut Self;
23087        fn take_or_borrow<'a>(
23088            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23089        ) -> Self::Borrowed<'a> {
23090            value
23091        }
23092    }
23093
23094    unsafe impl fidl::encoding::TypeMarker for AudioConsumerBindVolumeControlRequest {
23095        type Owned = Self;
23096
23097        #[inline(always)]
23098        fn inline_align(_context: fidl::encoding::Context) -> usize {
23099            4
23100        }
23101
23102        #[inline(always)]
23103        fn inline_size(_context: fidl::encoding::Context) -> usize {
23104            4
23105        }
23106    }
23107
23108    unsafe impl
23109        fidl::encoding::Encode<
23110            AudioConsumerBindVolumeControlRequest,
23111            fidl::encoding::DefaultFuchsiaResourceDialect,
23112        > for &mut AudioConsumerBindVolumeControlRequest
23113    {
23114        #[inline]
23115        unsafe fn encode(
23116            self,
23117            encoder: &mut fidl::encoding::Encoder<
23118                '_,
23119                fidl::encoding::DefaultFuchsiaResourceDialect,
23120            >,
23121            offset: usize,
23122            _depth: fidl::encoding::Depth,
23123        ) -> fidl::Result<()> {
23124            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
23125            // Delegate to tuple encoding.
23126            fidl::encoding::Encode::<
23127                AudioConsumerBindVolumeControlRequest,
23128                fidl::encoding::DefaultFuchsiaResourceDialect,
23129            >::encode(
23130                (<fidl::encoding::Endpoint<
23131                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23132                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23133                    &mut self.volume_control_request,
23134                ),),
23135                encoder,
23136                offset,
23137                _depth,
23138            )
23139        }
23140    }
23141    unsafe impl<
23142        T0: fidl::encoding::Encode<
23143                fidl::encoding::Endpoint<
23144                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23145                >,
23146                fidl::encoding::DefaultFuchsiaResourceDialect,
23147            >,
23148    >
23149        fidl::encoding::Encode<
23150            AudioConsumerBindVolumeControlRequest,
23151            fidl::encoding::DefaultFuchsiaResourceDialect,
23152        > for (T0,)
23153    {
23154        #[inline]
23155        unsafe fn encode(
23156            self,
23157            encoder: &mut fidl::encoding::Encoder<
23158                '_,
23159                fidl::encoding::DefaultFuchsiaResourceDialect,
23160            >,
23161            offset: usize,
23162            depth: fidl::encoding::Depth,
23163        ) -> fidl::Result<()> {
23164            encoder.debug_check_bounds::<AudioConsumerBindVolumeControlRequest>(offset);
23165            // Zero out padding regions. There's no need to apply masks
23166            // because the unmasked parts will be overwritten by fields.
23167            // Write the fields.
23168            self.0.encode(encoder, offset + 0, depth)?;
23169            Ok(())
23170        }
23171    }
23172
23173    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23174        for AudioConsumerBindVolumeControlRequest
23175    {
23176        #[inline(always)]
23177        fn new_empty() -> Self {
23178            Self {
23179                volume_control_request: fidl::new_empty!(
23180                    fidl::encoding::Endpoint<
23181                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23182                    >,
23183                    fidl::encoding::DefaultFuchsiaResourceDialect
23184                ),
23185            }
23186        }
23187
23188        #[inline]
23189        unsafe fn decode(
23190            &mut self,
23191            decoder: &mut fidl::encoding::Decoder<
23192                '_,
23193                fidl::encoding::DefaultFuchsiaResourceDialect,
23194            >,
23195            offset: usize,
23196            _depth: fidl::encoding::Depth,
23197        ) -> fidl::Result<()> {
23198            decoder.debug_check_bounds::<Self>(offset);
23199            // Verify that padding bytes are zero.
23200            fidl::decode!(
23201                fidl::encoding::Endpoint<
23202                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23203                >,
23204                fidl::encoding::DefaultFuchsiaResourceDialect,
23205                &mut self.volume_control_request,
23206                decoder,
23207                offset + 0,
23208                _depth
23209            )?;
23210            Ok(())
23211        }
23212    }
23213
23214    impl fidl::encoding::ResourceTypeMarker for AudioConsumerCreateStreamSinkRequest {
23215        type Borrowed<'a> = &'a mut Self;
23216        fn take_or_borrow<'a>(
23217            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23218        ) -> Self::Borrowed<'a> {
23219            value
23220        }
23221    }
23222
23223    unsafe impl fidl::encoding::TypeMarker for AudioConsumerCreateStreamSinkRequest {
23224        type Owned = Self;
23225
23226        #[inline(always)]
23227        fn inline_align(_context: fidl::encoding::Context) -> usize {
23228            8
23229        }
23230
23231        #[inline(always)]
23232        fn inline_size(_context: fidl::encoding::Context) -> usize {
23233            48
23234        }
23235    }
23236
23237    unsafe impl
23238        fidl::encoding::Encode<
23239            AudioConsumerCreateStreamSinkRequest,
23240            fidl::encoding::DefaultFuchsiaResourceDialect,
23241        > for &mut AudioConsumerCreateStreamSinkRequest
23242    {
23243        #[inline]
23244        unsafe fn encode(
23245            self,
23246            encoder: &mut fidl::encoding::Encoder<
23247                '_,
23248                fidl::encoding::DefaultFuchsiaResourceDialect,
23249            >,
23250            offset: usize,
23251            _depth: fidl::encoding::Depth,
23252        ) -> fidl::Result<()> {
23253            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
23254            // Delegate to tuple encoding.
23255            fidl::encoding::Encode::<AudioConsumerCreateStreamSinkRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23256                (
23257                    <fidl::encoding::Vector<fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.buffers),
23258                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
23259                    <fidl::encoding::Boxed<Compression> as fidl::encoding::ValueTypeMarker>::borrow(&self.compression),
23260                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stream_sink_request),
23261                ),
23262                encoder, offset, _depth
23263            )
23264        }
23265    }
23266    unsafe impl<
23267        T0: fidl::encoding::Encode<
23268                fidl::encoding::Vector<
23269                    fidl::encoding::HandleType<
23270                        fidl::Vmo,
23271                        { fidl::ObjectType::VMO.into_raw() },
23272                        2147483648,
23273                    >,
23274                    16,
23275                >,
23276                fidl::encoding::DefaultFuchsiaResourceDialect,
23277            >,
23278        T1: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
23279        T2: fidl::encoding::Encode<
23280                fidl::encoding::Boxed<Compression>,
23281                fidl::encoding::DefaultFuchsiaResourceDialect,
23282            >,
23283        T3: fidl::encoding::Encode<
23284                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
23285                fidl::encoding::DefaultFuchsiaResourceDialect,
23286            >,
23287    >
23288        fidl::encoding::Encode<
23289            AudioConsumerCreateStreamSinkRequest,
23290            fidl::encoding::DefaultFuchsiaResourceDialect,
23291        > for (T0, T1, T2, T3)
23292    {
23293        #[inline]
23294        unsafe fn encode(
23295            self,
23296            encoder: &mut fidl::encoding::Encoder<
23297                '_,
23298                fidl::encoding::DefaultFuchsiaResourceDialect,
23299            >,
23300            offset: usize,
23301            depth: fidl::encoding::Depth,
23302        ) -> fidl::Result<()> {
23303            encoder.debug_check_bounds::<AudioConsumerCreateStreamSinkRequest>(offset);
23304            // Zero out padding regions. There's no need to apply masks
23305            // because the unmasked parts will be overwritten by fields.
23306            unsafe {
23307                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
23308                (ptr as *mut u64).write_unaligned(0);
23309            }
23310            unsafe {
23311                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
23312                (ptr as *mut u64).write_unaligned(0);
23313            }
23314            // Write the fields.
23315            self.0.encode(encoder, offset + 0, depth)?;
23316            self.1.encode(encoder, offset + 16, depth)?;
23317            self.2.encode(encoder, offset + 32, depth)?;
23318            self.3.encode(encoder, offset + 40, depth)?;
23319            Ok(())
23320        }
23321    }
23322
23323    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23324        for AudioConsumerCreateStreamSinkRequest
23325    {
23326        #[inline(always)]
23327        fn new_empty() -> Self {
23328            Self {
23329                buffers: fidl::new_empty!(
23330                    fidl::encoding::Vector<
23331                        fidl::encoding::HandleType<
23332                            fidl::Vmo,
23333                            { fidl::ObjectType::VMO.into_raw() },
23334                            2147483648,
23335                        >,
23336                        16,
23337                    >,
23338                    fidl::encoding::DefaultFuchsiaResourceDialect
23339                ),
23340                stream_type: fidl::new_empty!(
23341                    AudioStreamType,
23342                    fidl::encoding::DefaultFuchsiaResourceDialect
23343                ),
23344                compression: fidl::new_empty!(
23345                    fidl::encoding::Boxed<Compression>,
23346                    fidl::encoding::DefaultFuchsiaResourceDialect
23347                ),
23348                stream_sink_request: fidl::new_empty!(
23349                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
23350                    fidl::encoding::DefaultFuchsiaResourceDialect
23351                ),
23352            }
23353        }
23354
23355        #[inline]
23356        unsafe fn decode(
23357            &mut self,
23358            decoder: &mut fidl::encoding::Decoder<
23359                '_,
23360                fidl::encoding::DefaultFuchsiaResourceDialect,
23361            >,
23362            offset: usize,
23363            _depth: fidl::encoding::Depth,
23364        ) -> fidl::Result<()> {
23365            decoder.debug_check_bounds::<Self>(offset);
23366            // Verify that padding bytes are zero.
23367            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
23368            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23369            let mask = 0xffffffff00000000u64;
23370            let maskedval = padval & mask;
23371            if maskedval != 0 {
23372                return Err(fidl::Error::NonZeroPadding {
23373                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
23374                });
23375            }
23376            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
23377            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23378            let mask = 0xffffffff00000000u64;
23379            let maskedval = padval & mask;
23380            if maskedval != 0 {
23381                return Err(fidl::Error::NonZeroPadding {
23382                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
23383                });
23384            }
23385            fidl::decode!(
23386                fidl::encoding::Vector<
23387                    fidl::encoding::HandleType<
23388                        fidl::Vmo,
23389                        { fidl::ObjectType::VMO.into_raw() },
23390                        2147483648,
23391                    >,
23392                    16,
23393                >,
23394                fidl::encoding::DefaultFuchsiaResourceDialect,
23395                &mut self.buffers,
23396                decoder,
23397                offset + 0,
23398                _depth
23399            )?;
23400            fidl::decode!(
23401                AudioStreamType,
23402                fidl::encoding::DefaultFuchsiaResourceDialect,
23403                &mut self.stream_type,
23404                decoder,
23405                offset + 16,
23406                _depth
23407            )?;
23408            fidl::decode!(
23409                fidl::encoding::Boxed<Compression>,
23410                fidl::encoding::DefaultFuchsiaResourceDialect,
23411                &mut self.compression,
23412                decoder,
23413                offset + 32,
23414                _depth
23415            )?;
23416            fidl::decode!(
23417                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<StreamSinkMarker>>,
23418                fidl::encoding::DefaultFuchsiaResourceDialect,
23419                &mut self.stream_sink_request,
23420                decoder,
23421                offset + 40,
23422                _depth
23423            )?;
23424            Ok(())
23425        }
23426    }
23427
23428    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControl2Request {
23429        type Borrowed<'a> = &'a mut Self;
23430        fn take_or_borrow<'a>(
23431            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23432        ) -> Self::Borrowed<'a> {
23433            value
23434        }
23435    }
23436
23437    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControl2Request {
23438        type Owned = Self;
23439
23440        #[inline(always)]
23441        fn inline_align(_context: fidl::encoding::Context) -> usize {
23442            8
23443        }
23444
23445        #[inline(always)]
23446        fn inline_size(_context: fidl::encoding::Context) -> usize {
23447            24
23448        }
23449    }
23450
23451    unsafe impl
23452        fidl::encoding::Encode<
23453            AudioCoreBindUsageVolumeControl2Request,
23454            fidl::encoding::DefaultFuchsiaResourceDialect,
23455        > for &mut AudioCoreBindUsageVolumeControl2Request
23456    {
23457        #[inline]
23458        unsafe fn encode(
23459            self,
23460            encoder: &mut fidl::encoding::Encoder<
23461                '_,
23462                fidl::encoding::DefaultFuchsiaResourceDialect,
23463            >,
23464            offset: usize,
23465            _depth: fidl::encoding::Depth,
23466        ) -> fidl::Result<()> {
23467            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
23468            // Delegate to tuple encoding.
23469            fidl::encoding::Encode::<
23470                AudioCoreBindUsageVolumeControl2Request,
23471                fidl::encoding::DefaultFuchsiaResourceDialect,
23472            >::encode(
23473                (
23474                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23475                    <fidl::encoding::Endpoint<
23476                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23477                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23478                        &mut self.volume_control,
23479                    ),
23480                ),
23481                encoder,
23482                offset,
23483                _depth,
23484            )
23485        }
23486    }
23487    unsafe impl<
23488        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
23489        T1: fidl::encoding::Encode<
23490                fidl::encoding::Endpoint<
23491                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23492                >,
23493                fidl::encoding::DefaultFuchsiaResourceDialect,
23494            >,
23495    >
23496        fidl::encoding::Encode<
23497            AudioCoreBindUsageVolumeControl2Request,
23498            fidl::encoding::DefaultFuchsiaResourceDialect,
23499        > for (T0, T1)
23500    {
23501        #[inline]
23502        unsafe fn encode(
23503            self,
23504            encoder: &mut fidl::encoding::Encoder<
23505                '_,
23506                fidl::encoding::DefaultFuchsiaResourceDialect,
23507            >,
23508            offset: usize,
23509            depth: fidl::encoding::Depth,
23510        ) -> fidl::Result<()> {
23511            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControl2Request>(offset);
23512            // Zero out padding regions. There's no need to apply masks
23513            // because the unmasked parts will be overwritten by fields.
23514            unsafe {
23515                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
23516                (ptr as *mut u64).write_unaligned(0);
23517            }
23518            // Write the fields.
23519            self.0.encode(encoder, offset + 0, depth)?;
23520            self.1.encode(encoder, offset + 16, depth)?;
23521            Ok(())
23522        }
23523    }
23524
23525    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23526        for AudioCoreBindUsageVolumeControl2Request
23527    {
23528        #[inline(always)]
23529        fn new_empty() -> Self {
23530            Self {
23531                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
23532                volume_control: fidl::new_empty!(
23533                    fidl::encoding::Endpoint<
23534                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23535                    >,
23536                    fidl::encoding::DefaultFuchsiaResourceDialect
23537                ),
23538            }
23539        }
23540
23541        #[inline]
23542        unsafe fn decode(
23543            &mut self,
23544            decoder: &mut fidl::encoding::Decoder<
23545                '_,
23546                fidl::encoding::DefaultFuchsiaResourceDialect,
23547            >,
23548            offset: usize,
23549            _depth: fidl::encoding::Depth,
23550        ) -> fidl::Result<()> {
23551            decoder.debug_check_bounds::<Self>(offset);
23552            // Verify that padding bytes are zero.
23553            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
23554            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23555            let mask = 0xffffffff00000000u64;
23556            let maskedval = padval & mask;
23557            if maskedval != 0 {
23558                return Err(fidl::Error::NonZeroPadding {
23559                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
23560                });
23561            }
23562            fidl::decode!(
23563                Usage2,
23564                fidl::encoding::DefaultFuchsiaResourceDialect,
23565                &mut self.usage,
23566                decoder,
23567                offset + 0,
23568                _depth
23569            )?;
23570            fidl::decode!(
23571                fidl::encoding::Endpoint<
23572                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23573                >,
23574                fidl::encoding::DefaultFuchsiaResourceDialect,
23575                &mut self.volume_control,
23576                decoder,
23577                offset + 16,
23578                _depth
23579            )?;
23580            Ok(())
23581        }
23582    }
23583
23584    impl fidl::encoding::ResourceTypeMarker for AudioCoreBindUsageVolumeControlRequest {
23585        type Borrowed<'a> = &'a mut Self;
23586        fn take_or_borrow<'a>(
23587            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23588        ) -> Self::Borrowed<'a> {
23589            value
23590        }
23591    }
23592
23593    unsafe impl fidl::encoding::TypeMarker for AudioCoreBindUsageVolumeControlRequest {
23594        type Owned = Self;
23595
23596        #[inline(always)]
23597        fn inline_align(_context: fidl::encoding::Context) -> usize {
23598            8
23599        }
23600
23601        #[inline(always)]
23602        fn inline_size(_context: fidl::encoding::Context) -> usize {
23603            24
23604        }
23605    }
23606
23607    unsafe impl
23608        fidl::encoding::Encode<
23609            AudioCoreBindUsageVolumeControlRequest,
23610            fidl::encoding::DefaultFuchsiaResourceDialect,
23611        > for &mut AudioCoreBindUsageVolumeControlRequest
23612    {
23613        #[inline]
23614        unsafe fn encode(
23615            self,
23616            encoder: &mut fidl::encoding::Encoder<
23617                '_,
23618                fidl::encoding::DefaultFuchsiaResourceDialect,
23619            >,
23620            offset: usize,
23621            _depth: fidl::encoding::Depth,
23622        ) -> fidl::Result<()> {
23623            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
23624            // Delegate to tuple encoding.
23625            fidl::encoding::Encode::<
23626                AudioCoreBindUsageVolumeControlRequest,
23627                fidl::encoding::DefaultFuchsiaResourceDialect,
23628            >::encode(
23629                (
23630                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
23631                    <fidl::encoding::Endpoint<
23632                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23633                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
23634                        &mut self.volume_control,
23635                    ),
23636                ),
23637                encoder,
23638                offset,
23639                _depth,
23640            )
23641        }
23642    }
23643    unsafe impl<
23644        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
23645        T1: fidl::encoding::Encode<
23646                fidl::encoding::Endpoint<
23647                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23648                >,
23649                fidl::encoding::DefaultFuchsiaResourceDialect,
23650            >,
23651    >
23652        fidl::encoding::Encode<
23653            AudioCoreBindUsageVolumeControlRequest,
23654            fidl::encoding::DefaultFuchsiaResourceDialect,
23655        > for (T0, T1)
23656    {
23657        #[inline]
23658        unsafe fn encode(
23659            self,
23660            encoder: &mut fidl::encoding::Encoder<
23661                '_,
23662                fidl::encoding::DefaultFuchsiaResourceDialect,
23663            >,
23664            offset: usize,
23665            depth: fidl::encoding::Depth,
23666        ) -> fidl::Result<()> {
23667            encoder.debug_check_bounds::<AudioCoreBindUsageVolumeControlRequest>(offset);
23668            // Zero out padding regions. There's no need to apply masks
23669            // because the unmasked parts will be overwritten by fields.
23670            unsafe {
23671                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
23672                (ptr as *mut u64).write_unaligned(0);
23673            }
23674            // Write the fields.
23675            self.0.encode(encoder, offset + 0, depth)?;
23676            self.1.encode(encoder, offset + 16, depth)?;
23677            Ok(())
23678        }
23679    }
23680
23681    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23682        for AudioCoreBindUsageVolumeControlRequest
23683    {
23684        #[inline(always)]
23685        fn new_empty() -> Self {
23686            Self {
23687                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
23688                volume_control: fidl::new_empty!(
23689                    fidl::encoding::Endpoint<
23690                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23691                    >,
23692                    fidl::encoding::DefaultFuchsiaResourceDialect
23693                ),
23694            }
23695        }
23696
23697        #[inline]
23698        unsafe fn decode(
23699            &mut self,
23700            decoder: &mut fidl::encoding::Decoder<
23701                '_,
23702                fidl::encoding::DefaultFuchsiaResourceDialect,
23703            >,
23704            offset: usize,
23705            _depth: fidl::encoding::Depth,
23706        ) -> fidl::Result<()> {
23707            decoder.debug_check_bounds::<Self>(offset);
23708            // Verify that padding bytes are zero.
23709            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
23710            let padval = unsafe { (ptr as *const u64).read_unaligned() };
23711            let mask = 0xffffffff00000000u64;
23712            let maskedval = padval & mask;
23713            if maskedval != 0 {
23714                return Err(fidl::Error::NonZeroPadding {
23715                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
23716                });
23717            }
23718            fidl::decode!(
23719                Usage,
23720                fidl::encoding::DefaultFuchsiaResourceDialect,
23721                &mut self.usage,
23722                decoder,
23723                offset + 0,
23724                _depth
23725            )?;
23726            fidl::decode!(
23727                fidl::encoding::Endpoint<
23728                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::VolumeControlMarker>,
23729                >,
23730                fidl::encoding::DefaultFuchsiaResourceDialect,
23731                &mut self.volume_control,
23732                decoder,
23733                offset + 16,
23734                _depth
23735            )?;
23736            Ok(())
23737        }
23738    }
23739
23740    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerRequest {
23741        type Borrowed<'a> = &'a mut Self;
23742        fn take_or_borrow<'a>(
23743            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23744        ) -> Self::Borrowed<'a> {
23745            value
23746        }
23747    }
23748
23749    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerRequest {
23750        type Owned = Self;
23751
23752        #[inline(always)]
23753        fn inline_align(_context: fidl::encoding::Context) -> usize {
23754            4
23755        }
23756
23757        #[inline(always)]
23758        fn inline_size(_context: fidl::encoding::Context) -> usize {
23759            8
23760        }
23761    }
23762
23763    unsafe impl
23764        fidl::encoding::Encode<
23765            AudioCoreCreateAudioCapturerRequest,
23766            fidl::encoding::DefaultFuchsiaResourceDialect,
23767        > for &mut AudioCoreCreateAudioCapturerRequest
23768    {
23769        #[inline]
23770        unsafe fn encode(
23771            self,
23772            encoder: &mut fidl::encoding::Encoder<
23773                '_,
23774                fidl::encoding::DefaultFuchsiaResourceDialect,
23775            >,
23776            offset: usize,
23777            _depth: fidl::encoding::Depth,
23778        ) -> fidl::Result<()> {
23779            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
23780            // Delegate to tuple encoding.
23781            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23782                (
23783                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
23784                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_in_request),
23785                ),
23786                encoder, offset, _depth
23787            )
23788        }
23789    }
23790    unsafe impl<
23791        T0: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
23792        T1: fidl::encoding::Encode<
23793                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23794                fidl::encoding::DefaultFuchsiaResourceDialect,
23795            >,
23796    >
23797        fidl::encoding::Encode<
23798            AudioCoreCreateAudioCapturerRequest,
23799            fidl::encoding::DefaultFuchsiaResourceDialect,
23800        > for (T0, T1)
23801    {
23802        #[inline]
23803        unsafe fn encode(
23804            self,
23805            encoder: &mut fidl::encoding::Encoder<
23806                '_,
23807                fidl::encoding::DefaultFuchsiaResourceDialect,
23808            >,
23809            offset: usize,
23810            depth: fidl::encoding::Depth,
23811        ) -> fidl::Result<()> {
23812            encoder.debug_check_bounds::<AudioCoreCreateAudioCapturerRequest>(offset);
23813            // Zero out padding regions. There's no need to apply masks
23814            // because the unmasked parts will be overwritten by fields.
23815            unsafe {
23816                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
23817                (ptr as *mut u32).write_unaligned(0);
23818            }
23819            // Write the fields.
23820            self.0.encode(encoder, offset + 0, depth)?;
23821            self.1.encode(encoder, offset + 4, depth)?;
23822            Ok(())
23823        }
23824    }
23825
23826    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23827        for AudioCoreCreateAudioCapturerRequest
23828    {
23829        #[inline(always)]
23830        fn new_empty() -> Self {
23831            Self {
23832                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
23833                audio_in_request: fidl::new_empty!(
23834                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23835                    fidl::encoding::DefaultFuchsiaResourceDialect
23836                ),
23837            }
23838        }
23839
23840        #[inline]
23841        unsafe fn decode(
23842            &mut self,
23843            decoder: &mut fidl::encoding::Decoder<
23844                '_,
23845                fidl::encoding::DefaultFuchsiaResourceDialect,
23846            >,
23847            offset: usize,
23848            _depth: fidl::encoding::Depth,
23849        ) -> fidl::Result<()> {
23850            decoder.debug_check_bounds::<Self>(offset);
23851            // Verify that padding bytes are zero.
23852            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
23853            let padval = unsafe { (ptr as *const u32).read_unaligned() };
23854            let mask = 0xffffff00u32;
23855            let maskedval = padval & mask;
23856            if maskedval != 0 {
23857                return Err(fidl::Error::NonZeroPadding {
23858                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
23859                });
23860            }
23861            fidl::decode!(
23862                bool,
23863                fidl::encoding::DefaultFuchsiaResourceDialect,
23864                &mut self.loopback,
23865                decoder,
23866                offset + 0,
23867                _depth
23868            )?;
23869            fidl::decode!(
23870                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23871                fidl::encoding::DefaultFuchsiaResourceDialect,
23872                &mut self.audio_in_request,
23873                decoder,
23874                offset + 4,
23875                _depth
23876            )?;
23877            Ok(())
23878        }
23879    }
23880
23881    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
23882        type Borrowed<'a> = &'a mut Self;
23883        fn take_or_borrow<'a>(
23884            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
23885        ) -> Self::Borrowed<'a> {
23886            value
23887        }
23888    }
23889
23890    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioCapturerWithConfigurationRequest {
23891        type Owned = Self;
23892
23893        #[inline(always)]
23894        fn inline_align(_context: fidl::encoding::Context) -> usize {
23895            8
23896        }
23897
23898        #[inline(always)]
23899        fn inline_size(_context: fidl::encoding::Context) -> usize {
23900            40
23901        }
23902    }
23903
23904    unsafe impl
23905        fidl::encoding::Encode<
23906            AudioCoreCreateAudioCapturerWithConfigurationRequest,
23907            fidl::encoding::DefaultFuchsiaResourceDialect,
23908        > for &mut AudioCoreCreateAudioCapturerWithConfigurationRequest
23909    {
23910        #[inline]
23911        unsafe fn encode(
23912            self,
23913            encoder: &mut fidl::encoding::Encoder<
23914                '_,
23915                fidl::encoding::DefaultFuchsiaResourceDialect,
23916            >,
23917            offset: usize,
23918            _depth: fidl::encoding::Depth,
23919        ) -> fidl::Result<()> {
23920            encoder
23921                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
23922            // Delegate to tuple encoding.
23923            fidl::encoding::Encode::<AudioCoreCreateAudioCapturerWithConfigurationRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
23924                (
23925                    <AudioStreamType as fidl::encoding::ValueTypeMarker>::borrow(&self.stream_type),
23926                    <AudioCapturerConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
23927                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
23928                ),
23929                encoder, offset, _depth
23930            )
23931        }
23932    }
23933    unsafe impl<
23934        T0: fidl::encoding::Encode<AudioStreamType, fidl::encoding::DefaultFuchsiaResourceDialect>,
23935        T1: fidl::encoding::Encode<
23936                AudioCapturerConfiguration,
23937                fidl::encoding::DefaultFuchsiaResourceDialect,
23938            >,
23939        T2: fidl::encoding::Encode<
23940                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23941                fidl::encoding::DefaultFuchsiaResourceDialect,
23942            >,
23943    >
23944        fidl::encoding::Encode<
23945            AudioCoreCreateAudioCapturerWithConfigurationRequest,
23946            fidl::encoding::DefaultFuchsiaResourceDialect,
23947        > for (T0, T1, T2)
23948    {
23949        #[inline]
23950        unsafe fn encode(
23951            self,
23952            encoder: &mut fidl::encoding::Encoder<
23953                '_,
23954                fidl::encoding::DefaultFuchsiaResourceDialect,
23955            >,
23956            offset: usize,
23957            depth: fidl::encoding::Depth,
23958        ) -> fidl::Result<()> {
23959            encoder
23960                .debug_check_bounds::<AudioCoreCreateAudioCapturerWithConfigurationRequest>(offset);
23961            // Zero out padding regions. There's no need to apply masks
23962            // because the unmasked parts will be overwritten by fields.
23963            unsafe {
23964                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
23965                (ptr as *mut u64).write_unaligned(0);
23966            }
23967            unsafe {
23968                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
23969                (ptr as *mut u64).write_unaligned(0);
23970            }
23971            // Write the fields.
23972            self.0.encode(encoder, offset + 0, depth)?;
23973            self.1.encode(encoder, offset + 16, depth)?;
23974            self.2.encode(encoder, offset + 32, depth)?;
23975            Ok(())
23976        }
23977    }
23978
23979    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
23980        for AudioCoreCreateAudioCapturerWithConfigurationRequest
23981    {
23982        #[inline(always)]
23983        fn new_empty() -> Self {
23984            Self {
23985                stream_type: fidl::new_empty!(
23986                    AudioStreamType,
23987                    fidl::encoding::DefaultFuchsiaResourceDialect
23988                ),
23989                configuration: fidl::new_empty!(
23990                    AudioCapturerConfiguration,
23991                    fidl::encoding::DefaultFuchsiaResourceDialect
23992                ),
23993                audio_capturer_request: fidl::new_empty!(
23994                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
23995                    fidl::encoding::DefaultFuchsiaResourceDialect
23996                ),
23997            }
23998        }
23999
24000        #[inline]
24001        unsafe fn decode(
24002            &mut self,
24003            decoder: &mut fidl::encoding::Decoder<
24004                '_,
24005                fidl::encoding::DefaultFuchsiaResourceDialect,
24006            >,
24007            offset: usize,
24008            _depth: fidl::encoding::Depth,
24009        ) -> fidl::Result<()> {
24010            decoder.debug_check_bounds::<Self>(offset);
24011            // Verify that padding bytes are zero.
24012            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
24013            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24014            let mask = 0xffffffff00000000u64;
24015            let maskedval = padval & mask;
24016            if maskedval != 0 {
24017                return Err(fidl::Error::NonZeroPadding {
24018                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
24019                });
24020            }
24021            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
24022            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24023            let mask = 0xffffffff00000000u64;
24024            let maskedval = padval & mask;
24025            if maskedval != 0 {
24026                return Err(fidl::Error::NonZeroPadding {
24027                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
24028                });
24029            }
24030            fidl::decode!(
24031                AudioStreamType,
24032                fidl::encoding::DefaultFuchsiaResourceDialect,
24033                &mut self.stream_type,
24034                decoder,
24035                offset + 0,
24036                _depth
24037            )?;
24038            fidl::decode!(
24039                AudioCapturerConfiguration,
24040                fidl::encoding::DefaultFuchsiaResourceDialect,
24041                &mut self.configuration,
24042                decoder,
24043                offset + 16,
24044                _depth
24045            )?;
24046            fidl::decode!(
24047                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24048                fidl::encoding::DefaultFuchsiaResourceDialect,
24049                &mut self.audio_capturer_request,
24050                decoder,
24051                offset + 32,
24052                _depth
24053            )?;
24054            Ok(())
24055        }
24056    }
24057
24058    impl fidl::encoding::ResourceTypeMarker for AudioCoreCreateAudioRendererRequest {
24059        type Borrowed<'a> = &'a mut Self;
24060        fn take_or_borrow<'a>(
24061            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24062        ) -> Self::Borrowed<'a> {
24063            value
24064        }
24065    }
24066
24067    unsafe impl fidl::encoding::TypeMarker for AudioCoreCreateAudioRendererRequest {
24068        type Owned = Self;
24069
24070        #[inline(always)]
24071        fn inline_align(_context: fidl::encoding::Context) -> usize {
24072            4
24073        }
24074
24075        #[inline(always)]
24076        fn inline_size(_context: fidl::encoding::Context) -> usize {
24077            4
24078        }
24079    }
24080
24081    unsafe impl
24082        fidl::encoding::Encode<
24083            AudioCoreCreateAudioRendererRequest,
24084            fidl::encoding::DefaultFuchsiaResourceDialect,
24085        > for &mut AudioCoreCreateAudioRendererRequest
24086    {
24087        #[inline]
24088        unsafe fn encode(
24089            self,
24090            encoder: &mut fidl::encoding::Encoder<
24091                '_,
24092                fidl::encoding::DefaultFuchsiaResourceDialect,
24093            >,
24094            offset: usize,
24095            _depth: fidl::encoding::Depth,
24096        ) -> fidl::Result<()> {
24097            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
24098            // Delegate to tuple encoding.
24099            fidl::encoding::Encode::<AudioCoreCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24100                (
24101                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_out_request),
24102                ),
24103                encoder, offset, _depth
24104            )
24105        }
24106    }
24107    unsafe impl<
24108        T0: fidl::encoding::Encode<
24109                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24110                fidl::encoding::DefaultFuchsiaResourceDialect,
24111            >,
24112    >
24113        fidl::encoding::Encode<
24114            AudioCoreCreateAudioRendererRequest,
24115            fidl::encoding::DefaultFuchsiaResourceDialect,
24116        > for (T0,)
24117    {
24118        #[inline]
24119        unsafe fn encode(
24120            self,
24121            encoder: &mut fidl::encoding::Encoder<
24122                '_,
24123                fidl::encoding::DefaultFuchsiaResourceDialect,
24124            >,
24125            offset: usize,
24126            depth: fidl::encoding::Depth,
24127        ) -> fidl::Result<()> {
24128            encoder.debug_check_bounds::<AudioCoreCreateAudioRendererRequest>(offset);
24129            // Zero out padding regions. There's no need to apply masks
24130            // because the unmasked parts will be overwritten by fields.
24131            // Write the fields.
24132            self.0.encode(encoder, offset + 0, depth)?;
24133            Ok(())
24134        }
24135    }
24136
24137    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24138        for AudioCoreCreateAudioRendererRequest
24139    {
24140        #[inline(always)]
24141        fn new_empty() -> Self {
24142            Self {
24143                audio_out_request: fidl::new_empty!(
24144                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24145                    fidl::encoding::DefaultFuchsiaResourceDialect
24146                ),
24147            }
24148        }
24149
24150        #[inline]
24151        unsafe fn decode(
24152            &mut self,
24153            decoder: &mut fidl::encoding::Decoder<
24154                '_,
24155                fidl::encoding::DefaultFuchsiaResourceDialect,
24156            >,
24157            offset: usize,
24158            _depth: fidl::encoding::Depth,
24159        ) -> fidl::Result<()> {
24160            decoder.debug_check_bounds::<Self>(offset);
24161            // Verify that padding bytes are zero.
24162            fidl::decode!(
24163                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24164                fidl::encoding::DefaultFuchsiaResourceDialect,
24165                &mut self.audio_out_request,
24166                decoder,
24167                offset + 0,
24168                _depth
24169            )?;
24170            Ok(())
24171        }
24172    }
24173
24174    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioCapturerRequest {
24175        type Borrowed<'a> = &'a mut Self;
24176        fn take_or_borrow<'a>(
24177            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24178        ) -> Self::Borrowed<'a> {
24179            value
24180        }
24181    }
24182
24183    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioCapturerRequest {
24184        type Owned = Self;
24185
24186        #[inline(always)]
24187        fn inline_align(_context: fidl::encoding::Context) -> usize {
24188            4
24189        }
24190
24191        #[inline(always)]
24192        fn inline_size(_context: fidl::encoding::Context) -> usize {
24193            8
24194        }
24195    }
24196
24197    unsafe impl
24198        fidl::encoding::Encode<
24199            AudioCreateAudioCapturerRequest,
24200            fidl::encoding::DefaultFuchsiaResourceDialect,
24201        > for &mut AudioCreateAudioCapturerRequest
24202    {
24203        #[inline]
24204        unsafe fn encode(
24205            self,
24206            encoder: &mut fidl::encoding::Encoder<
24207                '_,
24208                fidl::encoding::DefaultFuchsiaResourceDialect,
24209            >,
24210            offset: usize,
24211            _depth: fidl::encoding::Depth,
24212        ) -> fidl::Result<()> {
24213            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
24214            // Delegate to tuple encoding.
24215            fidl::encoding::Encode::<AudioCreateAudioCapturerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24216                (
24217                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_capturer_request),
24218                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.loopback),
24219                ),
24220                encoder, offset, _depth
24221            )
24222        }
24223    }
24224    unsafe impl<
24225        T0: fidl::encoding::Encode<
24226                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24227                fidl::encoding::DefaultFuchsiaResourceDialect,
24228            >,
24229        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
24230    >
24231        fidl::encoding::Encode<
24232            AudioCreateAudioCapturerRequest,
24233            fidl::encoding::DefaultFuchsiaResourceDialect,
24234        > for (T0, T1)
24235    {
24236        #[inline]
24237        unsafe fn encode(
24238            self,
24239            encoder: &mut fidl::encoding::Encoder<
24240                '_,
24241                fidl::encoding::DefaultFuchsiaResourceDialect,
24242            >,
24243            offset: usize,
24244            depth: fidl::encoding::Depth,
24245        ) -> fidl::Result<()> {
24246            encoder.debug_check_bounds::<AudioCreateAudioCapturerRequest>(offset);
24247            // Zero out padding regions. There's no need to apply masks
24248            // because the unmasked parts will be overwritten by fields.
24249            unsafe {
24250                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(4);
24251                (ptr as *mut u32).write_unaligned(0);
24252            }
24253            // Write the fields.
24254            self.0.encode(encoder, offset + 0, depth)?;
24255            self.1.encode(encoder, offset + 4, depth)?;
24256            Ok(())
24257        }
24258    }
24259
24260    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24261        for AudioCreateAudioCapturerRequest
24262    {
24263        #[inline(always)]
24264        fn new_empty() -> Self {
24265            Self {
24266                audio_capturer_request: fidl::new_empty!(
24267                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24268                    fidl::encoding::DefaultFuchsiaResourceDialect
24269                ),
24270                loopback: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
24271            }
24272        }
24273
24274        #[inline]
24275        unsafe fn decode(
24276            &mut self,
24277            decoder: &mut fidl::encoding::Decoder<
24278                '_,
24279                fidl::encoding::DefaultFuchsiaResourceDialect,
24280            >,
24281            offset: usize,
24282            _depth: fidl::encoding::Depth,
24283        ) -> fidl::Result<()> {
24284            decoder.debug_check_bounds::<Self>(offset);
24285            // Verify that padding bytes are zero.
24286            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(4) };
24287            let padval = unsafe { (ptr as *const u32).read_unaligned() };
24288            let mask = 0xffffff00u32;
24289            let maskedval = padval & mask;
24290            if maskedval != 0 {
24291                return Err(fidl::Error::NonZeroPadding {
24292                    padding_start: offset + 4 + ((mask as u64).trailing_zeros() / 8) as usize,
24293                });
24294            }
24295            fidl::decode!(
24296                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioCapturerMarker>>,
24297                fidl::encoding::DefaultFuchsiaResourceDialect,
24298                &mut self.audio_capturer_request,
24299                decoder,
24300                offset + 0,
24301                _depth
24302            )?;
24303            fidl::decode!(
24304                bool,
24305                fidl::encoding::DefaultFuchsiaResourceDialect,
24306                &mut self.loopback,
24307                decoder,
24308                offset + 4,
24309                _depth
24310            )?;
24311            Ok(())
24312        }
24313    }
24314
24315    impl fidl::encoding::ResourceTypeMarker for AudioCreateAudioRendererRequest {
24316        type Borrowed<'a> = &'a mut Self;
24317        fn take_or_borrow<'a>(
24318            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24319        ) -> Self::Borrowed<'a> {
24320            value
24321        }
24322    }
24323
24324    unsafe impl fidl::encoding::TypeMarker for AudioCreateAudioRendererRequest {
24325        type Owned = Self;
24326
24327        #[inline(always)]
24328        fn inline_align(_context: fidl::encoding::Context) -> usize {
24329            4
24330        }
24331
24332        #[inline(always)]
24333        fn inline_size(_context: fidl::encoding::Context) -> usize {
24334            4
24335        }
24336    }
24337
24338    unsafe impl
24339        fidl::encoding::Encode<
24340            AudioCreateAudioRendererRequest,
24341            fidl::encoding::DefaultFuchsiaResourceDialect,
24342        > for &mut AudioCreateAudioRendererRequest
24343    {
24344        #[inline]
24345        unsafe fn encode(
24346            self,
24347            encoder: &mut fidl::encoding::Encoder<
24348                '_,
24349                fidl::encoding::DefaultFuchsiaResourceDialect,
24350            >,
24351            offset: usize,
24352            _depth: fidl::encoding::Depth,
24353        ) -> fidl::Result<()> {
24354            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
24355            // Delegate to tuple encoding.
24356            fidl::encoding::Encode::<AudioCreateAudioRendererRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
24357                (
24358                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_renderer_request),
24359                ),
24360                encoder, offset, _depth
24361            )
24362        }
24363    }
24364    unsafe impl<
24365        T0: fidl::encoding::Encode<
24366                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24367                fidl::encoding::DefaultFuchsiaResourceDialect,
24368            >,
24369    >
24370        fidl::encoding::Encode<
24371            AudioCreateAudioRendererRequest,
24372            fidl::encoding::DefaultFuchsiaResourceDialect,
24373        > for (T0,)
24374    {
24375        #[inline]
24376        unsafe fn encode(
24377            self,
24378            encoder: &mut fidl::encoding::Encoder<
24379                '_,
24380                fidl::encoding::DefaultFuchsiaResourceDialect,
24381            >,
24382            offset: usize,
24383            depth: fidl::encoding::Depth,
24384        ) -> fidl::Result<()> {
24385            encoder.debug_check_bounds::<AudioCreateAudioRendererRequest>(offset);
24386            // Zero out padding regions. There's no need to apply masks
24387            // because the unmasked parts will be overwritten by fields.
24388            // Write the fields.
24389            self.0.encode(encoder, offset + 0, depth)?;
24390            Ok(())
24391        }
24392    }
24393
24394    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24395        for AudioCreateAudioRendererRequest
24396    {
24397        #[inline(always)]
24398        fn new_empty() -> Self {
24399            Self {
24400                audio_renderer_request: fidl::new_empty!(
24401                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24402                    fidl::encoding::DefaultFuchsiaResourceDialect
24403                ),
24404            }
24405        }
24406
24407        #[inline]
24408        unsafe fn decode(
24409            &mut self,
24410            decoder: &mut fidl::encoding::Decoder<
24411                '_,
24412                fidl::encoding::DefaultFuchsiaResourceDialect,
24413            >,
24414            offset: usize,
24415            _depth: fidl::encoding::Depth,
24416        ) -> fidl::Result<()> {
24417            decoder.debug_check_bounds::<Self>(offset);
24418            // Verify that padding bytes are zero.
24419            fidl::decode!(
24420                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioRendererMarker>>,
24421                fidl::encoding::DefaultFuchsiaResourceDialect,
24422                &mut self.audio_renderer_request,
24423                decoder,
24424                offset + 0,
24425                _depth
24426            )?;
24427            Ok(())
24428        }
24429    }
24430
24431    impl fidl::encoding::ResourceTypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
24432        type Borrowed<'a> = &'a mut Self;
24433        fn take_or_borrow<'a>(
24434            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24435        ) -> Self::Borrowed<'a> {
24436            value
24437        }
24438    }
24439
24440    unsafe impl fidl::encoding::TypeMarker for AudioDeviceEnumeratorAddDeviceByChannelRequest {
24441        type Owned = Self;
24442
24443        #[inline(always)]
24444        fn inline_align(_context: fidl::encoding::Context) -> usize {
24445            8
24446        }
24447
24448        #[inline(always)]
24449        fn inline_size(_context: fidl::encoding::Context) -> usize {
24450            24
24451        }
24452    }
24453
24454    unsafe impl
24455        fidl::encoding::Encode<
24456            AudioDeviceEnumeratorAddDeviceByChannelRequest,
24457            fidl::encoding::DefaultFuchsiaResourceDialect,
24458        > for &mut AudioDeviceEnumeratorAddDeviceByChannelRequest
24459    {
24460        #[inline]
24461        unsafe fn encode(
24462            self,
24463            encoder: &mut fidl::encoding::Encoder<
24464                '_,
24465                fidl::encoding::DefaultFuchsiaResourceDialect,
24466            >,
24467            offset: usize,
24468            _depth: fidl::encoding::Depth,
24469        ) -> fidl::Result<()> {
24470            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
24471            // Delegate to tuple encoding.
24472            fidl::encoding::Encode::<
24473                AudioDeviceEnumeratorAddDeviceByChannelRequest,
24474                fidl::encoding::DefaultFuchsiaResourceDialect,
24475            >::encode(
24476                (
24477                    <fidl::encoding::BoundedString<256> as fidl::encoding::ValueTypeMarker>::borrow(
24478                        &self.device_name,
24479                    ),
24480                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.is_input),
24481                    <fidl::encoding::Endpoint<
24482                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24483                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24484                        &mut self.channel
24485                    ),
24486                ),
24487                encoder,
24488                offset,
24489                _depth,
24490            )
24491        }
24492    }
24493    unsafe impl<
24494        T0: fidl::encoding::Encode<
24495                fidl::encoding::BoundedString<256>,
24496                fidl::encoding::DefaultFuchsiaResourceDialect,
24497            >,
24498        T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
24499        T2: fidl::encoding::Encode<
24500                fidl::encoding::Endpoint<
24501                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24502                >,
24503                fidl::encoding::DefaultFuchsiaResourceDialect,
24504            >,
24505    >
24506        fidl::encoding::Encode<
24507            AudioDeviceEnumeratorAddDeviceByChannelRequest,
24508            fidl::encoding::DefaultFuchsiaResourceDialect,
24509        > for (T0, T1, T2)
24510    {
24511        #[inline]
24512        unsafe fn encode(
24513            self,
24514            encoder: &mut fidl::encoding::Encoder<
24515                '_,
24516                fidl::encoding::DefaultFuchsiaResourceDialect,
24517            >,
24518            offset: usize,
24519            depth: fidl::encoding::Depth,
24520        ) -> fidl::Result<()> {
24521            encoder.debug_check_bounds::<AudioDeviceEnumeratorAddDeviceByChannelRequest>(offset);
24522            // Zero out padding regions. There's no need to apply masks
24523            // because the unmasked parts will be overwritten by fields.
24524            unsafe {
24525                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
24526                (ptr as *mut u64).write_unaligned(0);
24527            }
24528            // Write the fields.
24529            self.0.encode(encoder, offset + 0, depth)?;
24530            self.1.encode(encoder, offset + 16, depth)?;
24531            self.2.encode(encoder, offset + 20, depth)?;
24532            Ok(())
24533        }
24534    }
24535
24536    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24537        for AudioDeviceEnumeratorAddDeviceByChannelRequest
24538    {
24539        #[inline(always)]
24540        fn new_empty() -> Self {
24541            Self {
24542                device_name: fidl::new_empty!(
24543                    fidl::encoding::BoundedString<256>,
24544                    fidl::encoding::DefaultFuchsiaResourceDialect
24545                ),
24546                is_input: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
24547                channel: fidl::new_empty!(
24548                    fidl::encoding::Endpoint<
24549                        fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24550                    >,
24551                    fidl::encoding::DefaultFuchsiaResourceDialect
24552                ),
24553            }
24554        }
24555
24556        #[inline]
24557        unsafe fn decode(
24558            &mut self,
24559            decoder: &mut fidl::encoding::Decoder<
24560                '_,
24561                fidl::encoding::DefaultFuchsiaResourceDialect,
24562            >,
24563            offset: usize,
24564            _depth: fidl::encoding::Depth,
24565        ) -> fidl::Result<()> {
24566            decoder.debug_check_bounds::<Self>(offset);
24567            // Verify that padding bytes are zero.
24568            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
24569            let padval = unsafe { (ptr as *const u64).read_unaligned() };
24570            let mask = 0xffffff00u64;
24571            let maskedval = padval & mask;
24572            if maskedval != 0 {
24573                return Err(fidl::Error::NonZeroPadding {
24574                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
24575                });
24576            }
24577            fidl::decode!(
24578                fidl::encoding::BoundedString<256>,
24579                fidl::encoding::DefaultFuchsiaResourceDialect,
24580                &mut self.device_name,
24581                decoder,
24582                offset + 0,
24583                _depth
24584            )?;
24585            fidl::decode!(
24586                bool,
24587                fidl::encoding::DefaultFuchsiaResourceDialect,
24588                &mut self.is_input,
24589                decoder,
24590                offset + 16,
24591                _depth
24592            )?;
24593            fidl::decode!(
24594                fidl::encoding::Endpoint<
24595                    fidl::endpoints::ClientEnd<fidl_fuchsia_hardware_audio::StreamConfigMarker>,
24596                >,
24597                fidl::encoding::DefaultFuchsiaResourceDialect,
24598                &mut self.channel,
24599                decoder,
24600                offset + 20,
24601                _depth
24602            )?;
24603            Ok(())
24604        }
24605    }
24606
24607    impl fidl::encoding::ResourceTypeMarker for AudioRendererBindGainControlRequest {
24608        type Borrowed<'a> = &'a mut Self;
24609        fn take_or_borrow<'a>(
24610            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24611        ) -> Self::Borrowed<'a> {
24612            value
24613        }
24614    }
24615
24616    unsafe impl fidl::encoding::TypeMarker for AudioRendererBindGainControlRequest {
24617        type Owned = Self;
24618
24619        #[inline(always)]
24620        fn inline_align(_context: fidl::encoding::Context) -> usize {
24621            4
24622        }
24623
24624        #[inline(always)]
24625        fn inline_size(_context: fidl::encoding::Context) -> usize {
24626            4
24627        }
24628    }
24629
24630    unsafe impl
24631        fidl::encoding::Encode<
24632            AudioRendererBindGainControlRequest,
24633            fidl::encoding::DefaultFuchsiaResourceDialect,
24634        > for &mut AudioRendererBindGainControlRequest
24635    {
24636        #[inline]
24637        unsafe fn encode(
24638            self,
24639            encoder: &mut fidl::encoding::Encoder<
24640                '_,
24641                fidl::encoding::DefaultFuchsiaResourceDialect,
24642            >,
24643            offset: usize,
24644            _depth: fidl::encoding::Depth,
24645        ) -> fidl::Result<()> {
24646            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
24647            // Delegate to tuple encoding.
24648            fidl::encoding::Encode::<
24649                AudioRendererBindGainControlRequest,
24650                fidl::encoding::DefaultFuchsiaResourceDialect,
24651            >::encode(
24652                (<fidl::encoding::Endpoint<
24653                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24654                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24655                    &mut self.gain_control_request,
24656                ),),
24657                encoder,
24658                offset,
24659                _depth,
24660            )
24661        }
24662    }
24663    unsafe impl<
24664        T0: fidl::encoding::Encode<
24665                fidl::encoding::Endpoint<
24666                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24667                >,
24668                fidl::encoding::DefaultFuchsiaResourceDialect,
24669            >,
24670    >
24671        fidl::encoding::Encode<
24672            AudioRendererBindGainControlRequest,
24673            fidl::encoding::DefaultFuchsiaResourceDialect,
24674        > for (T0,)
24675    {
24676        #[inline]
24677        unsafe fn encode(
24678            self,
24679            encoder: &mut fidl::encoding::Encoder<
24680                '_,
24681                fidl::encoding::DefaultFuchsiaResourceDialect,
24682            >,
24683            offset: usize,
24684            depth: fidl::encoding::Depth,
24685        ) -> fidl::Result<()> {
24686            encoder.debug_check_bounds::<AudioRendererBindGainControlRequest>(offset);
24687            // Zero out padding regions. There's no need to apply masks
24688            // because the unmasked parts will be overwritten by fields.
24689            // Write the fields.
24690            self.0.encode(encoder, offset + 0, depth)?;
24691            Ok(())
24692        }
24693    }
24694
24695    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24696        for AudioRendererBindGainControlRequest
24697    {
24698        #[inline(always)]
24699        fn new_empty() -> Self {
24700            Self {
24701                gain_control_request: fidl::new_empty!(
24702                    fidl::encoding::Endpoint<
24703                        fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24704                    >,
24705                    fidl::encoding::DefaultFuchsiaResourceDialect
24706                ),
24707            }
24708        }
24709
24710        #[inline]
24711        unsafe fn decode(
24712            &mut self,
24713            decoder: &mut fidl::encoding::Decoder<
24714                '_,
24715                fidl::encoding::DefaultFuchsiaResourceDialect,
24716            >,
24717            offset: usize,
24718            _depth: fidl::encoding::Depth,
24719        ) -> fidl::Result<()> {
24720            decoder.debug_check_bounds::<Self>(offset);
24721            // Verify that padding bytes are zero.
24722            fidl::decode!(
24723                fidl::encoding::Endpoint<
24724                    fidl::endpoints::ServerEnd<fidl_fuchsia_media_audio::GainControlMarker>,
24725                >,
24726                fidl::encoding::DefaultFuchsiaResourceDialect,
24727                &mut self.gain_control_request,
24728                decoder,
24729                offset + 0,
24730                _depth
24731            )?;
24732            Ok(())
24733        }
24734    }
24735
24736    impl fidl::encoding::ResourceTypeMarker for AudioRendererGetReferenceClockResponse {
24737        type Borrowed<'a> = &'a mut Self;
24738        fn take_or_borrow<'a>(
24739            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24740        ) -> Self::Borrowed<'a> {
24741            value
24742        }
24743    }
24744
24745    unsafe impl fidl::encoding::TypeMarker for AudioRendererGetReferenceClockResponse {
24746        type Owned = Self;
24747
24748        #[inline(always)]
24749        fn inline_align(_context: fidl::encoding::Context) -> usize {
24750            4
24751        }
24752
24753        #[inline(always)]
24754        fn inline_size(_context: fidl::encoding::Context) -> usize {
24755            4
24756        }
24757    }
24758
24759    unsafe impl
24760        fidl::encoding::Encode<
24761            AudioRendererGetReferenceClockResponse,
24762            fidl::encoding::DefaultFuchsiaResourceDialect,
24763        > for &mut AudioRendererGetReferenceClockResponse
24764    {
24765        #[inline]
24766        unsafe fn encode(
24767            self,
24768            encoder: &mut fidl::encoding::Encoder<
24769                '_,
24770                fidl::encoding::DefaultFuchsiaResourceDialect,
24771            >,
24772            offset: usize,
24773            _depth: fidl::encoding::Depth,
24774        ) -> fidl::Result<()> {
24775            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
24776            // Delegate to tuple encoding.
24777            fidl::encoding::Encode::<
24778                AudioRendererGetReferenceClockResponse,
24779                fidl::encoding::DefaultFuchsiaResourceDialect,
24780            >::encode(
24781                (<fidl::encoding::HandleType<
24782                    fidl::Clock,
24783                    { fidl::ObjectType::CLOCK.into_raw() },
24784                    2147483648,
24785                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24786                    &mut self.reference_clock,
24787                ),),
24788                encoder,
24789                offset,
24790                _depth,
24791            )
24792        }
24793    }
24794    unsafe impl<
24795        T0: fidl::encoding::Encode<
24796                fidl::encoding::HandleType<
24797                    fidl::Clock,
24798                    { fidl::ObjectType::CLOCK.into_raw() },
24799                    2147483648,
24800                >,
24801                fidl::encoding::DefaultFuchsiaResourceDialect,
24802            >,
24803    >
24804        fidl::encoding::Encode<
24805            AudioRendererGetReferenceClockResponse,
24806            fidl::encoding::DefaultFuchsiaResourceDialect,
24807        > for (T0,)
24808    {
24809        #[inline]
24810        unsafe fn encode(
24811            self,
24812            encoder: &mut fidl::encoding::Encoder<
24813                '_,
24814                fidl::encoding::DefaultFuchsiaResourceDialect,
24815            >,
24816            offset: usize,
24817            depth: fidl::encoding::Depth,
24818        ) -> fidl::Result<()> {
24819            encoder.debug_check_bounds::<AudioRendererGetReferenceClockResponse>(offset);
24820            // Zero out padding regions. There's no need to apply masks
24821            // because the unmasked parts will be overwritten by fields.
24822            // Write the fields.
24823            self.0.encode(encoder, offset + 0, depth)?;
24824            Ok(())
24825        }
24826    }
24827
24828    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24829        for AudioRendererGetReferenceClockResponse
24830    {
24831        #[inline(always)]
24832        fn new_empty() -> Self {
24833            Self {
24834                reference_clock: fidl::new_empty!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
24835            }
24836        }
24837
24838        #[inline]
24839        unsafe fn decode(
24840            &mut self,
24841            decoder: &mut fidl::encoding::Decoder<
24842                '_,
24843                fidl::encoding::DefaultFuchsiaResourceDialect,
24844            >,
24845            offset: usize,
24846            _depth: fidl::encoding::Depth,
24847        ) -> fidl::Result<()> {
24848            decoder.debug_check_bounds::<Self>(offset);
24849            // Verify that padding bytes are zero.
24850            fidl::decode!(fidl::encoding::HandleType<fidl::Clock, { fidl::ObjectType::CLOCK.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference_clock, decoder, offset + 0, _depth)?;
24851            Ok(())
24852        }
24853    }
24854
24855    impl fidl::encoding::ResourceTypeMarker for AudioRendererSetReferenceClockRequest {
24856        type Borrowed<'a> = &'a mut Self;
24857        fn take_or_borrow<'a>(
24858            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
24859        ) -> Self::Borrowed<'a> {
24860            value
24861        }
24862    }
24863
24864    unsafe impl fidl::encoding::TypeMarker for AudioRendererSetReferenceClockRequest {
24865        type Owned = Self;
24866
24867        #[inline(always)]
24868        fn inline_align(_context: fidl::encoding::Context) -> usize {
24869            4
24870        }
24871
24872        #[inline(always)]
24873        fn inline_size(_context: fidl::encoding::Context) -> usize {
24874            4
24875        }
24876    }
24877
24878    unsafe impl
24879        fidl::encoding::Encode<
24880            AudioRendererSetReferenceClockRequest,
24881            fidl::encoding::DefaultFuchsiaResourceDialect,
24882        > for &mut AudioRendererSetReferenceClockRequest
24883    {
24884        #[inline]
24885        unsafe fn encode(
24886            self,
24887            encoder: &mut fidl::encoding::Encoder<
24888                '_,
24889                fidl::encoding::DefaultFuchsiaResourceDialect,
24890            >,
24891            offset: usize,
24892            _depth: fidl::encoding::Depth,
24893        ) -> fidl::Result<()> {
24894            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
24895            // Delegate to tuple encoding.
24896            fidl::encoding::Encode::<
24897                AudioRendererSetReferenceClockRequest,
24898                fidl::encoding::DefaultFuchsiaResourceDialect,
24899            >::encode(
24900                (<fidl::encoding::Optional<
24901                    fidl::encoding::HandleType<
24902                        fidl::Clock,
24903                        { fidl::ObjectType::CLOCK.into_raw() },
24904                        2147483648,
24905                    >,
24906                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
24907                    &mut self.reference_clock,
24908                ),),
24909                encoder,
24910                offset,
24911                _depth,
24912            )
24913        }
24914    }
24915    unsafe impl<
24916        T0: fidl::encoding::Encode<
24917                fidl::encoding::Optional<
24918                    fidl::encoding::HandleType<
24919                        fidl::Clock,
24920                        { fidl::ObjectType::CLOCK.into_raw() },
24921                        2147483648,
24922                    >,
24923                >,
24924                fidl::encoding::DefaultFuchsiaResourceDialect,
24925            >,
24926    >
24927        fidl::encoding::Encode<
24928            AudioRendererSetReferenceClockRequest,
24929            fidl::encoding::DefaultFuchsiaResourceDialect,
24930        > for (T0,)
24931    {
24932        #[inline]
24933        unsafe fn encode(
24934            self,
24935            encoder: &mut fidl::encoding::Encoder<
24936                '_,
24937                fidl::encoding::DefaultFuchsiaResourceDialect,
24938            >,
24939            offset: usize,
24940            depth: fidl::encoding::Depth,
24941        ) -> fidl::Result<()> {
24942            encoder.debug_check_bounds::<AudioRendererSetReferenceClockRequest>(offset);
24943            // Zero out padding regions. There's no need to apply masks
24944            // because the unmasked parts will be overwritten by fields.
24945            // Write the fields.
24946            self.0.encode(encoder, offset + 0, depth)?;
24947            Ok(())
24948        }
24949    }
24950
24951    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
24952        for AudioRendererSetReferenceClockRequest
24953    {
24954        #[inline(always)]
24955        fn new_empty() -> Self {
24956            Self {
24957                reference_clock: fidl::new_empty!(
24958                    fidl::encoding::Optional<
24959                        fidl::encoding::HandleType<
24960                            fidl::Clock,
24961                            { fidl::ObjectType::CLOCK.into_raw() },
24962                            2147483648,
24963                        >,
24964                    >,
24965                    fidl::encoding::DefaultFuchsiaResourceDialect
24966                ),
24967            }
24968        }
24969
24970        #[inline]
24971        unsafe fn decode(
24972            &mut self,
24973            decoder: &mut fidl::encoding::Decoder<
24974                '_,
24975                fidl::encoding::DefaultFuchsiaResourceDialect,
24976            >,
24977            offset: usize,
24978            _depth: fidl::encoding::Depth,
24979        ) -> fidl::Result<()> {
24980            decoder.debug_check_bounds::<Self>(offset);
24981            // Verify that padding bytes are zero.
24982            fidl::decode!(
24983                fidl::encoding::Optional<
24984                    fidl::encoding::HandleType<
24985                        fidl::Clock,
24986                        { fidl::ObjectType::CLOCK.into_raw() },
24987                        2147483648,
24988                    >,
24989                >,
24990                fidl::encoding::DefaultFuchsiaResourceDialect,
24991                &mut self.reference_clock,
24992                decoder,
24993                offset + 0,
24994                _depth
24995            )?;
24996            Ok(())
24997        }
24998    }
24999
25000    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
25001        type Borrowed<'a> = &'a mut Self;
25002        fn take_or_borrow<'a>(
25003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25004        ) -> Self::Borrowed<'a> {
25005            value
25006        }
25007    }
25008
25009    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterHandlerWithCapacityRequest {
25010        type Owned = Self;
25011
25012        #[inline(always)]
25013        fn inline_align(_context: fidl::encoding::Context) -> usize {
25014            8
25015        }
25016
25017        #[inline(always)]
25018        fn inline_size(_context: fidl::encoding::Context) -> usize {
25019            40
25020        }
25021    }
25022
25023    unsafe impl
25024        fidl::encoding::Encode<
25025            ProfileProviderRegisterHandlerWithCapacityRequest,
25026            fidl::encoding::DefaultFuchsiaResourceDialect,
25027        > for &mut ProfileProviderRegisterHandlerWithCapacityRequest
25028    {
25029        #[inline]
25030        unsafe fn encode(
25031            self,
25032            encoder: &mut fidl::encoding::Encoder<
25033                '_,
25034                fidl::encoding::DefaultFuchsiaResourceDialect,
25035            >,
25036            offset: usize,
25037            _depth: fidl::encoding::Depth,
25038        ) -> fidl::Result<()> {
25039            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
25040            // Delegate to tuple encoding.
25041            fidl::encoding::Encode::<
25042                ProfileProviderRegisterHandlerWithCapacityRequest,
25043                fidl::encoding::DefaultFuchsiaResourceDialect,
25044            >::encode(
25045                (
25046                    <fidl::encoding::HandleType<
25047                        fidl::Thread,
25048                        { fidl::ObjectType::THREAD.into_raw() },
25049                        2147483648,
25050                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25051                        &mut self.thread_handle,
25052                    ),
25053                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
25054                        &self.name,
25055                    ),
25056                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.period),
25057                    <f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.capacity),
25058                ),
25059                encoder,
25060                offset,
25061                _depth,
25062            )
25063        }
25064    }
25065    unsafe impl<
25066        T0: fidl::encoding::Encode<
25067                fidl::encoding::HandleType<
25068                    fidl::Thread,
25069                    { fidl::ObjectType::THREAD.into_raw() },
25070                    2147483648,
25071                >,
25072                fidl::encoding::DefaultFuchsiaResourceDialect,
25073            >,
25074        T1: fidl::encoding::Encode<
25075                fidl::encoding::BoundedString<64>,
25076                fidl::encoding::DefaultFuchsiaResourceDialect,
25077            >,
25078        T2: fidl::encoding::Encode<i64, fidl::encoding::DefaultFuchsiaResourceDialect>,
25079        T3: fidl::encoding::Encode<f32, fidl::encoding::DefaultFuchsiaResourceDialect>,
25080    >
25081        fidl::encoding::Encode<
25082            ProfileProviderRegisterHandlerWithCapacityRequest,
25083            fidl::encoding::DefaultFuchsiaResourceDialect,
25084        > for (T0, T1, T2, T3)
25085    {
25086        #[inline]
25087        unsafe fn encode(
25088            self,
25089            encoder: &mut fidl::encoding::Encoder<
25090                '_,
25091                fidl::encoding::DefaultFuchsiaResourceDialect,
25092            >,
25093            offset: usize,
25094            depth: fidl::encoding::Depth,
25095        ) -> fidl::Result<()> {
25096            encoder.debug_check_bounds::<ProfileProviderRegisterHandlerWithCapacityRequest>(offset);
25097            // Zero out padding regions. There's no need to apply masks
25098            // because the unmasked parts will be overwritten by fields.
25099            unsafe {
25100                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
25101                (ptr as *mut u64).write_unaligned(0);
25102            }
25103            unsafe {
25104                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
25105                (ptr as *mut u64).write_unaligned(0);
25106            }
25107            // Write the fields.
25108            self.0.encode(encoder, offset + 0, depth)?;
25109            self.1.encode(encoder, offset + 8, depth)?;
25110            self.2.encode(encoder, offset + 24, depth)?;
25111            self.3.encode(encoder, offset + 32, depth)?;
25112            Ok(())
25113        }
25114    }
25115
25116    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25117        for ProfileProviderRegisterHandlerWithCapacityRequest
25118    {
25119        #[inline(always)]
25120        fn new_empty() -> Self {
25121            Self {
25122                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25123                name: fidl::new_empty!(
25124                    fidl::encoding::BoundedString<64>,
25125                    fidl::encoding::DefaultFuchsiaResourceDialect
25126                ),
25127                period: fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect),
25128                capacity: fidl::new_empty!(f32, fidl::encoding::DefaultFuchsiaResourceDialect),
25129            }
25130        }
25131
25132        #[inline]
25133        unsafe fn decode(
25134            &mut self,
25135            decoder: &mut fidl::encoding::Decoder<
25136                '_,
25137                fidl::encoding::DefaultFuchsiaResourceDialect,
25138            >,
25139            offset: usize,
25140            _depth: fidl::encoding::Depth,
25141        ) -> fidl::Result<()> {
25142            decoder.debug_check_bounds::<Self>(offset);
25143            // Verify that padding bytes are zero.
25144            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
25145            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25146            let mask = 0xffffffff00000000u64;
25147            let maskedval = padval & mask;
25148            if maskedval != 0 {
25149                return Err(fidl::Error::NonZeroPadding {
25150                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
25151                });
25152            }
25153            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
25154            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25155            let mask = 0xffffffff00000000u64;
25156            let maskedval = padval & mask;
25157            if maskedval != 0 {
25158                return Err(fidl::Error::NonZeroPadding {
25159                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
25160                });
25161            }
25162            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
25163            fidl::decode!(
25164                fidl::encoding::BoundedString<64>,
25165                fidl::encoding::DefaultFuchsiaResourceDialect,
25166                &mut self.name,
25167                decoder,
25168                offset + 8,
25169                _depth
25170            )?;
25171            fidl::decode!(
25172                i64,
25173                fidl::encoding::DefaultFuchsiaResourceDialect,
25174                &mut self.period,
25175                decoder,
25176                offset + 24,
25177                _depth
25178            )?;
25179            fidl::decode!(
25180                f32,
25181                fidl::encoding::DefaultFuchsiaResourceDialect,
25182                &mut self.capacity,
25183                decoder,
25184                offset + 32,
25185                _depth
25186            )?;
25187            Ok(())
25188        }
25189    }
25190
25191    impl fidl::encoding::ResourceTypeMarker for ProfileProviderRegisterMemoryRangeRequest {
25192        type Borrowed<'a> = &'a mut Self;
25193        fn take_or_borrow<'a>(
25194            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25195        ) -> Self::Borrowed<'a> {
25196            value
25197        }
25198    }
25199
25200    unsafe impl fidl::encoding::TypeMarker for ProfileProviderRegisterMemoryRangeRequest {
25201        type Owned = Self;
25202
25203        #[inline(always)]
25204        fn inline_align(_context: fidl::encoding::Context) -> usize {
25205            8
25206        }
25207
25208        #[inline(always)]
25209        fn inline_size(_context: fidl::encoding::Context) -> usize {
25210            24
25211        }
25212    }
25213
25214    unsafe impl
25215        fidl::encoding::Encode<
25216            ProfileProviderRegisterMemoryRangeRequest,
25217            fidl::encoding::DefaultFuchsiaResourceDialect,
25218        > for &mut ProfileProviderRegisterMemoryRangeRequest
25219    {
25220        #[inline]
25221        unsafe fn encode(
25222            self,
25223            encoder: &mut fidl::encoding::Encoder<
25224                '_,
25225                fidl::encoding::DefaultFuchsiaResourceDialect,
25226            >,
25227            offset: usize,
25228            _depth: fidl::encoding::Depth,
25229        ) -> fidl::Result<()> {
25230            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
25231            // Delegate to tuple encoding.
25232            fidl::encoding::Encode::<
25233                ProfileProviderRegisterMemoryRangeRequest,
25234                fidl::encoding::DefaultFuchsiaResourceDialect,
25235            >::encode(
25236                (
25237                    <fidl::encoding::HandleType<
25238                        fidl::Vmar,
25239                        { fidl::ObjectType::VMAR.into_raw() },
25240                        2147483648,
25241                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25242                        &mut self.vmar_handle
25243                    ),
25244                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
25245                        &self.name,
25246                    ),
25247                ),
25248                encoder,
25249                offset,
25250                _depth,
25251            )
25252        }
25253    }
25254    unsafe impl<
25255        T0: fidl::encoding::Encode<
25256                fidl::encoding::HandleType<
25257                    fidl::Vmar,
25258                    { fidl::ObjectType::VMAR.into_raw() },
25259                    2147483648,
25260                >,
25261                fidl::encoding::DefaultFuchsiaResourceDialect,
25262            >,
25263        T1: fidl::encoding::Encode<
25264                fidl::encoding::BoundedString<64>,
25265                fidl::encoding::DefaultFuchsiaResourceDialect,
25266            >,
25267    >
25268        fidl::encoding::Encode<
25269            ProfileProviderRegisterMemoryRangeRequest,
25270            fidl::encoding::DefaultFuchsiaResourceDialect,
25271        > for (T0, T1)
25272    {
25273        #[inline]
25274        unsafe fn encode(
25275            self,
25276            encoder: &mut fidl::encoding::Encoder<
25277                '_,
25278                fidl::encoding::DefaultFuchsiaResourceDialect,
25279            >,
25280            offset: usize,
25281            depth: fidl::encoding::Depth,
25282        ) -> fidl::Result<()> {
25283            encoder.debug_check_bounds::<ProfileProviderRegisterMemoryRangeRequest>(offset);
25284            // Zero out padding regions. There's no need to apply masks
25285            // because the unmasked parts will be overwritten by fields.
25286            unsafe {
25287                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
25288                (ptr as *mut u64).write_unaligned(0);
25289            }
25290            // Write the fields.
25291            self.0.encode(encoder, offset + 0, depth)?;
25292            self.1.encode(encoder, offset + 8, depth)?;
25293            Ok(())
25294        }
25295    }
25296
25297    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25298        for ProfileProviderRegisterMemoryRangeRequest
25299    {
25300        #[inline(always)]
25301        fn new_empty() -> Self {
25302            Self {
25303                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25304                name: fidl::new_empty!(
25305                    fidl::encoding::BoundedString<64>,
25306                    fidl::encoding::DefaultFuchsiaResourceDialect
25307                ),
25308            }
25309        }
25310
25311        #[inline]
25312        unsafe fn decode(
25313            &mut self,
25314            decoder: &mut fidl::encoding::Decoder<
25315                '_,
25316                fidl::encoding::DefaultFuchsiaResourceDialect,
25317            >,
25318            offset: usize,
25319            _depth: fidl::encoding::Depth,
25320        ) -> fidl::Result<()> {
25321            decoder.debug_check_bounds::<Self>(offset);
25322            // Verify that padding bytes are zero.
25323            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
25324            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25325            let mask = 0xffffffff00000000u64;
25326            let maskedval = padval & mask;
25327            if maskedval != 0 {
25328                return Err(fidl::Error::NonZeroPadding {
25329                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
25330                });
25331            }
25332            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
25333            fidl::decode!(
25334                fidl::encoding::BoundedString<64>,
25335                fidl::encoding::DefaultFuchsiaResourceDialect,
25336                &mut self.name,
25337                decoder,
25338                offset + 8,
25339                _depth
25340            )?;
25341            Ok(())
25342        }
25343    }
25344
25345    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterHandlerRequest {
25346        type Borrowed<'a> = &'a mut Self;
25347        fn take_or_borrow<'a>(
25348            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25349        ) -> Self::Borrowed<'a> {
25350            value
25351        }
25352    }
25353
25354    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterHandlerRequest {
25355        type Owned = Self;
25356
25357        #[inline(always)]
25358        fn inline_align(_context: fidl::encoding::Context) -> usize {
25359            8
25360        }
25361
25362        #[inline(always)]
25363        fn inline_size(_context: fidl::encoding::Context) -> usize {
25364            24
25365        }
25366    }
25367
25368    unsafe impl
25369        fidl::encoding::Encode<
25370            ProfileProviderUnregisterHandlerRequest,
25371            fidl::encoding::DefaultFuchsiaResourceDialect,
25372        > for &mut ProfileProviderUnregisterHandlerRequest
25373    {
25374        #[inline]
25375        unsafe fn encode(
25376            self,
25377            encoder: &mut fidl::encoding::Encoder<
25378                '_,
25379                fidl::encoding::DefaultFuchsiaResourceDialect,
25380            >,
25381            offset: usize,
25382            _depth: fidl::encoding::Depth,
25383        ) -> fidl::Result<()> {
25384            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
25385            // Delegate to tuple encoding.
25386            fidl::encoding::Encode::<
25387                ProfileProviderUnregisterHandlerRequest,
25388                fidl::encoding::DefaultFuchsiaResourceDialect,
25389            >::encode(
25390                (
25391                    <fidl::encoding::HandleType<
25392                        fidl::Thread,
25393                        { fidl::ObjectType::THREAD.into_raw() },
25394                        2147483648,
25395                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25396                        &mut self.thread_handle,
25397                    ),
25398                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
25399                        &self.name,
25400                    ),
25401                ),
25402                encoder,
25403                offset,
25404                _depth,
25405            )
25406        }
25407    }
25408    unsafe impl<
25409        T0: fidl::encoding::Encode<
25410                fidl::encoding::HandleType<
25411                    fidl::Thread,
25412                    { fidl::ObjectType::THREAD.into_raw() },
25413                    2147483648,
25414                >,
25415                fidl::encoding::DefaultFuchsiaResourceDialect,
25416            >,
25417        T1: fidl::encoding::Encode<
25418                fidl::encoding::BoundedString<64>,
25419                fidl::encoding::DefaultFuchsiaResourceDialect,
25420            >,
25421    >
25422        fidl::encoding::Encode<
25423            ProfileProviderUnregisterHandlerRequest,
25424            fidl::encoding::DefaultFuchsiaResourceDialect,
25425        > for (T0, T1)
25426    {
25427        #[inline]
25428        unsafe fn encode(
25429            self,
25430            encoder: &mut fidl::encoding::Encoder<
25431                '_,
25432                fidl::encoding::DefaultFuchsiaResourceDialect,
25433            >,
25434            offset: usize,
25435            depth: fidl::encoding::Depth,
25436        ) -> fidl::Result<()> {
25437            encoder.debug_check_bounds::<ProfileProviderUnregisterHandlerRequest>(offset);
25438            // Zero out padding regions. There's no need to apply masks
25439            // because the unmasked parts will be overwritten by fields.
25440            unsafe {
25441                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
25442                (ptr as *mut u64).write_unaligned(0);
25443            }
25444            // Write the fields.
25445            self.0.encode(encoder, offset + 0, depth)?;
25446            self.1.encode(encoder, offset + 8, depth)?;
25447            Ok(())
25448        }
25449    }
25450
25451    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25452        for ProfileProviderUnregisterHandlerRequest
25453    {
25454        #[inline(always)]
25455        fn new_empty() -> Self {
25456            Self {
25457                thread_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25458                name: fidl::new_empty!(
25459                    fidl::encoding::BoundedString<64>,
25460                    fidl::encoding::DefaultFuchsiaResourceDialect
25461                ),
25462            }
25463        }
25464
25465        #[inline]
25466        unsafe fn decode(
25467            &mut self,
25468            decoder: &mut fidl::encoding::Decoder<
25469                '_,
25470                fidl::encoding::DefaultFuchsiaResourceDialect,
25471            >,
25472            offset: usize,
25473            _depth: fidl::encoding::Depth,
25474        ) -> fidl::Result<()> {
25475            decoder.debug_check_bounds::<Self>(offset);
25476            // Verify that padding bytes are zero.
25477            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
25478            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25479            let mask = 0xffffffff00000000u64;
25480            let maskedval = padval & mask;
25481            if maskedval != 0 {
25482                return Err(fidl::Error::NonZeroPadding {
25483                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
25484                });
25485            }
25486            fidl::decode!(fidl::encoding::HandleType<fidl::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.thread_handle, decoder, offset + 0, _depth)?;
25487            fidl::decode!(
25488                fidl::encoding::BoundedString<64>,
25489                fidl::encoding::DefaultFuchsiaResourceDialect,
25490                &mut self.name,
25491                decoder,
25492                offset + 8,
25493                _depth
25494            )?;
25495            Ok(())
25496        }
25497    }
25498
25499    impl fidl::encoding::ResourceTypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
25500        type Borrowed<'a> = &'a mut Self;
25501        fn take_or_borrow<'a>(
25502            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25503        ) -> Self::Borrowed<'a> {
25504            value
25505        }
25506    }
25507
25508    unsafe impl fidl::encoding::TypeMarker for ProfileProviderUnregisterMemoryRangeRequest {
25509        type Owned = Self;
25510
25511        #[inline(always)]
25512        fn inline_align(_context: fidl::encoding::Context) -> usize {
25513            4
25514        }
25515
25516        #[inline(always)]
25517        fn inline_size(_context: fidl::encoding::Context) -> usize {
25518            4
25519        }
25520    }
25521
25522    unsafe impl
25523        fidl::encoding::Encode<
25524            ProfileProviderUnregisterMemoryRangeRequest,
25525            fidl::encoding::DefaultFuchsiaResourceDialect,
25526        > for &mut ProfileProviderUnregisterMemoryRangeRequest
25527    {
25528        #[inline]
25529        unsafe fn encode(
25530            self,
25531            encoder: &mut fidl::encoding::Encoder<
25532                '_,
25533                fidl::encoding::DefaultFuchsiaResourceDialect,
25534            >,
25535            offset: usize,
25536            _depth: fidl::encoding::Depth,
25537        ) -> fidl::Result<()> {
25538            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
25539            // Delegate to tuple encoding.
25540            fidl::encoding::Encode::<
25541                ProfileProviderUnregisterMemoryRangeRequest,
25542                fidl::encoding::DefaultFuchsiaResourceDialect,
25543            >::encode(
25544                (<fidl::encoding::HandleType<
25545                    fidl::Vmar,
25546                    { fidl::ObjectType::VMAR.into_raw() },
25547                    2147483648,
25548                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25549                    &mut self.vmar_handle
25550                ),),
25551                encoder,
25552                offset,
25553                _depth,
25554            )
25555        }
25556    }
25557    unsafe impl<
25558        T0: fidl::encoding::Encode<
25559                fidl::encoding::HandleType<
25560                    fidl::Vmar,
25561                    { fidl::ObjectType::VMAR.into_raw() },
25562                    2147483648,
25563                >,
25564                fidl::encoding::DefaultFuchsiaResourceDialect,
25565            >,
25566    >
25567        fidl::encoding::Encode<
25568            ProfileProviderUnregisterMemoryRangeRequest,
25569            fidl::encoding::DefaultFuchsiaResourceDialect,
25570        > for (T0,)
25571    {
25572        #[inline]
25573        unsafe fn encode(
25574            self,
25575            encoder: &mut fidl::encoding::Encoder<
25576                '_,
25577                fidl::encoding::DefaultFuchsiaResourceDialect,
25578            >,
25579            offset: usize,
25580            depth: fidl::encoding::Depth,
25581        ) -> fidl::Result<()> {
25582            encoder.debug_check_bounds::<ProfileProviderUnregisterMemoryRangeRequest>(offset);
25583            // Zero out padding regions. There's no need to apply masks
25584            // because the unmasked parts will be overwritten by fields.
25585            // Write the fields.
25586            self.0.encode(encoder, offset + 0, depth)?;
25587            Ok(())
25588        }
25589    }
25590
25591    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25592        for ProfileProviderUnregisterMemoryRangeRequest
25593    {
25594        #[inline(always)]
25595        fn new_empty() -> Self {
25596            Self {
25597                vmar_handle: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25598            }
25599        }
25600
25601        #[inline]
25602        unsafe fn decode(
25603            &mut self,
25604            decoder: &mut fidl::encoding::Decoder<
25605                '_,
25606                fidl::encoding::DefaultFuchsiaResourceDialect,
25607            >,
25608            offset: usize,
25609            _depth: fidl::encoding::Depth,
25610        ) -> fidl::Result<()> {
25611            decoder.debug_check_bounds::<Self>(offset);
25612            // Verify that padding bytes are zero.
25613            fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmar_handle, decoder, offset + 0, _depth)?;
25614            Ok(())
25615        }
25616    }
25617
25618    impl fidl::encoding::ResourceTypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
25619        type Borrowed<'a> = &'a mut Self;
25620        fn take_or_borrow<'a>(
25621            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25622        ) -> Self::Borrowed<'a> {
25623            value
25624        }
25625    }
25626
25627    unsafe impl fidl::encoding::TypeMarker for SessionAudioConsumerFactoryCreateAudioConsumerRequest {
25628        type Owned = Self;
25629
25630        #[inline(always)]
25631        fn inline_align(_context: fidl::encoding::Context) -> usize {
25632            8
25633        }
25634
25635        #[inline(always)]
25636        fn inline_size(_context: fidl::encoding::Context) -> usize {
25637            16
25638        }
25639    }
25640
25641    unsafe impl
25642        fidl::encoding::Encode<
25643            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
25644            fidl::encoding::DefaultFuchsiaResourceDialect,
25645        > for &mut SessionAudioConsumerFactoryCreateAudioConsumerRequest
25646    {
25647        #[inline]
25648        unsafe fn encode(
25649            self,
25650            encoder: &mut fidl::encoding::Encoder<
25651                '_,
25652                fidl::encoding::DefaultFuchsiaResourceDialect,
25653            >,
25654            offset: usize,
25655            _depth: fidl::encoding::Depth,
25656        ) -> fidl::Result<()> {
25657            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
25658                offset,
25659            );
25660            // Delegate to tuple encoding.
25661            fidl::encoding::Encode::<SessionAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
25662                (
25663                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.session_id),
25664                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
25665                ),
25666                encoder, offset, _depth
25667            )
25668        }
25669    }
25670    unsafe impl<
25671        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
25672        T1: fidl::encoding::Encode<
25673                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
25674                fidl::encoding::DefaultFuchsiaResourceDialect,
25675            >,
25676    >
25677        fidl::encoding::Encode<
25678            SessionAudioConsumerFactoryCreateAudioConsumerRequest,
25679            fidl::encoding::DefaultFuchsiaResourceDialect,
25680        > for (T0, T1)
25681    {
25682        #[inline]
25683        unsafe fn encode(
25684            self,
25685            encoder: &mut fidl::encoding::Encoder<
25686                '_,
25687                fidl::encoding::DefaultFuchsiaResourceDialect,
25688            >,
25689            offset: usize,
25690            depth: fidl::encoding::Depth,
25691        ) -> fidl::Result<()> {
25692            encoder.debug_check_bounds::<SessionAudioConsumerFactoryCreateAudioConsumerRequest>(
25693                offset,
25694            );
25695            // Zero out padding regions. There's no need to apply masks
25696            // because the unmasked parts will be overwritten by fields.
25697            unsafe {
25698                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
25699                (ptr as *mut u64).write_unaligned(0);
25700            }
25701            // Write the fields.
25702            self.0.encode(encoder, offset + 0, depth)?;
25703            self.1.encode(encoder, offset + 8, depth)?;
25704            Ok(())
25705        }
25706    }
25707
25708    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25709        for SessionAudioConsumerFactoryCreateAudioConsumerRequest
25710    {
25711        #[inline(always)]
25712        fn new_empty() -> Self {
25713            Self {
25714                session_id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
25715                audio_consumer_request: fidl::new_empty!(
25716                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
25717                    fidl::encoding::DefaultFuchsiaResourceDialect
25718                ),
25719            }
25720        }
25721
25722        #[inline]
25723        unsafe fn decode(
25724            &mut self,
25725            decoder: &mut fidl::encoding::Decoder<
25726                '_,
25727                fidl::encoding::DefaultFuchsiaResourceDialect,
25728            >,
25729            offset: usize,
25730            _depth: fidl::encoding::Depth,
25731        ) -> fidl::Result<()> {
25732            decoder.debug_check_bounds::<Self>(offset);
25733            // Verify that padding bytes are zero.
25734            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
25735            let padval = unsafe { (ptr as *const u64).read_unaligned() };
25736            let mask = 0xffffffff00000000u64;
25737            let maskedval = padval & mask;
25738            if maskedval != 0 {
25739                return Err(fidl::Error::NonZeroPadding {
25740                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
25741                });
25742            }
25743            fidl::decode!(
25744                u64,
25745                fidl::encoding::DefaultFuchsiaResourceDialect,
25746                &mut self.session_id,
25747                decoder,
25748                offset + 0,
25749                _depth
25750            )?;
25751            fidl::decode!(
25752                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
25753                fidl::encoding::DefaultFuchsiaResourceDialect,
25754                &mut self.audio_consumer_request,
25755                decoder,
25756                offset + 8,
25757                _depth
25758            )?;
25759            Ok(())
25760        }
25761    }
25762
25763    impl fidl::encoding::ResourceTypeMarker for StreamBufferSetAddPayloadBufferRequest {
25764        type Borrowed<'a> = &'a mut Self;
25765        fn take_or_borrow<'a>(
25766            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25767        ) -> Self::Borrowed<'a> {
25768            value
25769        }
25770    }
25771
25772    unsafe impl fidl::encoding::TypeMarker for StreamBufferSetAddPayloadBufferRequest {
25773        type Owned = Self;
25774
25775        #[inline(always)]
25776        fn inline_align(_context: fidl::encoding::Context) -> usize {
25777            4
25778        }
25779
25780        #[inline(always)]
25781        fn inline_size(_context: fidl::encoding::Context) -> usize {
25782            8
25783        }
25784    }
25785
25786    unsafe impl
25787        fidl::encoding::Encode<
25788            StreamBufferSetAddPayloadBufferRequest,
25789            fidl::encoding::DefaultFuchsiaResourceDialect,
25790        > for &mut StreamBufferSetAddPayloadBufferRequest
25791    {
25792        #[inline]
25793        unsafe fn encode(
25794            self,
25795            encoder: &mut fidl::encoding::Encoder<
25796                '_,
25797                fidl::encoding::DefaultFuchsiaResourceDialect,
25798            >,
25799            offset: usize,
25800            _depth: fidl::encoding::Depth,
25801        ) -> fidl::Result<()> {
25802            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
25803            // Delegate to tuple encoding.
25804            fidl::encoding::Encode::<
25805                StreamBufferSetAddPayloadBufferRequest,
25806                fidl::encoding::DefaultFuchsiaResourceDialect,
25807            >::encode(
25808                (
25809                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
25810                    <fidl::encoding::HandleType<
25811                        fidl::Vmo,
25812                        { fidl::ObjectType::VMO.into_raw() },
25813                        2147483648,
25814                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
25815                        &mut self.payload_buffer,
25816                    ),
25817                ),
25818                encoder,
25819                offset,
25820                _depth,
25821            )
25822        }
25823    }
25824    unsafe impl<
25825        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
25826        T1: fidl::encoding::Encode<
25827                fidl::encoding::HandleType<
25828                    fidl::Vmo,
25829                    { fidl::ObjectType::VMO.into_raw() },
25830                    2147483648,
25831                >,
25832                fidl::encoding::DefaultFuchsiaResourceDialect,
25833            >,
25834    >
25835        fidl::encoding::Encode<
25836            StreamBufferSetAddPayloadBufferRequest,
25837            fidl::encoding::DefaultFuchsiaResourceDialect,
25838        > for (T0, T1)
25839    {
25840        #[inline]
25841        unsafe fn encode(
25842            self,
25843            encoder: &mut fidl::encoding::Encoder<
25844                '_,
25845                fidl::encoding::DefaultFuchsiaResourceDialect,
25846            >,
25847            offset: usize,
25848            depth: fidl::encoding::Depth,
25849        ) -> fidl::Result<()> {
25850            encoder.debug_check_bounds::<StreamBufferSetAddPayloadBufferRequest>(offset);
25851            // Zero out padding regions. There's no need to apply masks
25852            // because the unmasked parts will be overwritten by fields.
25853            // Write the fields.
25854            self.0.encode(encoder, offset + 0, depth)?;
25855            self.1.encode(encoder, offset + 4, depth)?;
25856            Ok(())
25857        }
25858    }
25859
25860    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25861        for StreamBufferSetAddPayloadBufferRequest
25862    {
25863        #[inline(always)]
25864        fn new_empty() -> Self {
25865            Self {
25866                id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
25867                payload_buffer: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
25868            }
25869        }
25870
25871        #[inline]
25872        unsafe fn decode(
25873            &mut self,
25874            decoder: &mut fidl::encoding::Decoder<
25875                '_,
25876                fidl::encoding::DefaultFuchsiaResourceDialect,
25877            >,
25878            offset: usize,
25879            _depth: fidl::encoding::Depth,
25880        ) -> fidl::Result<()> {
25881            decoder.debug_check_bounds::<Self>(offset);
25882            // Verify that padding bytes are zero.
25883            fidl::decode!(
25884                u32,
25885                fidl::encoding::DefaultFuchsiaResourceDialect,
25886                &mut self.id,
25887                decoder,
25888                offset + 0,
25889                _depth
25890            )?;
25891            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.payload_buffer, decoder, offset + 4, _depth)?;
25892            Ok(())
25893        }
25894    }
25895
25896    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
25897        type Borrowed<'a> = &'a mut Self;
25898        fn take_or_borrow<'a>(
25899            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
25900        ) -> Self::Borrowed<'a> {
25901            value
25902        }
25903    }
25904
25905    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetInputBufferPartialSettingsRequest {
25906        type Owned = Self;
25907
25908        #[inline(always)]
25909        fn inline_align(_context: fidl::encoding::Context) -> usize {
25910            8
25911        }
25912
25913        #[inline(always)]
25914        fn inline_size(_context: fidl::encoding::Context) -> usize {
25915            16
25916        }
25917    }
25918
25919    unsafe impl
25920        fidl::encoding::Encode<
25921            StreamProcessorSetInputBufferPartialSettingsRequest,
25922            fidl::encoding::DefaultFuchsiaResourceDialect,
25923        > for &mut StreamProcessorSetInputBufferPartialSettingsRequest
25924    {
25925        #[inline]
25926        unsafe fn encode(
25927            self,
25928            encoder: &mut fidl::encoding::Encoder<
25929                '_,
25930                fidl::encoding::DefaultFuchsiaResourceDialect,
25931            >,
25932            offset: usize,
25933            _depth: fidl::encoding::Depth,
25934        ) -> fidl::Result<()> {
25935            encoder
25936                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
25937            // Delegate to tuple encoding.
25938            fidl::encoding::Encode::<StreamProcessorSetInputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
25939                (
25940                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.input_settings),
25941                ),
25942                encoder, offset, _depth
25943            )
25944        }
25945    }
25946    unsafe impl<
25947        T0: fidl::encoding::Encode<
25948                StreamBufferPartialSettings,
25949                fidl::encoding::DefaultFuchsiaResourceDialect,
25950            >,
25951    >
25952        fidl::encoding::Encode<
25953            StreamProcessorSetInputBufferPartialSettingsRequest,
25954            fidl::encoding::DefaultFuchsiaResourceDialect,
25955        > for (T0,)
25956    {
25957        #[inline]
25958        unsafe fn encode(
25959            self,
25960            encoder: &mut fidl::encoding::Encoder<
25961                '_,
25962                fidl::encoding::DefaultFuchsiaResourceDialect,
25963            >,
25964            offset: usize,
25965            depth: fidl::encoding::Depth,
25966        ) -> fidl::Result<()> {
25967            encoder
25968                .debug_check_bounds::<StreamProcessorSetInputBufferPartialSettingsRequest>(offset);
25969            // Zero out padding regions. There's no need to apply masks
25970            // because the unmasked parts will be overwritten by fields.
25971            // Write the fields.
25972            self.0.encode(encoder, offset + 0, depth)?;
25973            Ok(())
25974        }
25975    }
25976
25977    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
25978        for StreamProcessorSetInputBufferPartialSettingsRequest
25979    {
25980        #[inline(always)]
25981        fn new_empty() -> Self {
25982            Self {
25983                input_settings: fidl::new_empty!(
25984                    StreamBufferPartialSettings,
25985                    fidl::encoding::DefaultFuchsiaResourceDialect
25986                ),
25987            }
25988        }
25989
25990        #[inline]
25991        unsafe fn decode(
25992            &mut self,
25993            decoder: &mut fidl::encoding::Decoder<
25994                '_,
25995                fidl::encoding::DefaultFuchsiaResourceDialect,
25996            >,
25997            offset: usize,
25998            _depth: fidl::encoding::Depth,
25999        ) -> fidl::Result<()> {
26000            decoder.debug_check_bounds::<Self>(offset);
26001            // Verify that padding bytes are zero.
26002            fidl::decode!(
26003                StreamBufferPartialSettings,
26004                fidl::encoding::DefaultFuchsiaResourceDialect,
26005                &mut self.input_settings,
26006                decoder,
26007                offset + 0,
26008                _depth
26009            )?;
26010            Ok(())
26011        }
26012    }
26013
26014    impl fidl::encoding::ResourceTypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
26015        type Borrowed<'a> = &'a mut Self;
26016        fn take_or_borrow<'a>(
26017            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26018        ) -> Self::Borrowed<'a> {
26019            value
26020        }
26021    }
26022
26023    unsafe impl fidl::encoding::TypeMarker for StreamProcessorSetOutputBufferPartialSettingsRequest {
26024        type Owned = Self;
26025
26026        #[inline(always)]
26027        fn inline_align(_context: fidl::encoding::Context) -> usize {
26028            8
26029        }
26030
26031        #[inline(always)]
26032        fn inline_size(_context: fidl::encoding::Context) -> usize {
26033            16
26034        }
26035    }
26036
26037    unsafe impl
26038        fidl::encoding::Encode<
26039            StreamProcessorSetOutputBufferPartialSettingsRequest,
26040            fidl::encoding::DefaultFuchsiaResourceDialect,
26041        > for &mut StreamProcessorSetOutputBufferPartialSettingsRequest
26042    {
26043        #[inline]
26044        unsafe fn encode(
26045            self,
26046            encoder: &mut fidl::encoding::Encoder<
26047                '_,
26048                fidl::encoding::DefaultFuchsiaResourceDialect,
26049            >,
26050            offset: usize,
26051            _depth: fidl::encoding::Depth,
26052        ) -> fidl::Result<()> {
26053            encoder
26054                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
26055            // Delegate to tuple encoding.
26056            fidl::encoding::Encode::<StreamProcessorSetOutputBufferPartialSettingsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26057                (
26058                    <StreamBufferPartialSettings as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.output_settings),
26059                ),
26060                encoder, offset, _depth
26061            )
26062        }
26063    }
26064    unsafe impl<
26065        T0: fidl::encoding::Encode<
26066                StreamBufferPartialSettings,
26067                fidl::encoding::DefaultFuchsiaResourceDialect,
26068            >,
26069    >
26070        fidl::encoding::Encode<
26071            StreamProcessorSetOutputBufferPartialSettingsRequest,
26072            fidl::encoding::DefaultFuchsiaResourceDialect,
26073        > for (T0,)
26074    {
26075        #[inline]
26076        unsafe fn encode(
26077            self,
26078            encoder: &mut fidl::encoding::Encoder<
26079                '_,
26080                fidl::encoding::DefaultFuchsiaResourceDialect,
26081            >,
26082            offset: usize,
26083            depth: fidl::encoding::Depth,
26084        ) -> fidl::Result<()> {
26085            encoder
26086                .debug_check_bounds::<StreamProcessorSetOutputBufferPartialSettingsRequest>(offset);
26087            // Zero out padding regions. There's no need to apply masks
26088            // because the unmasked parts will be overwritten by fields.
26089            // Write the fields.
26090            self.0.encode(encoder, offset + 0, depth)?;
26091            Ok(())
26092        }
26093    }
26094
26095    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26096        for StreamProcessorSetOutputBufferPartialSettingsRequest
26097    {
26098        #[inline(always)]
26099        fn new_empty() -> Self {
26100            Self {
26101                output_settings: fidl::new_empty!(
26102                    StreamBufferPartialSettings,
26103                    fidl::encoding::DefaultFuchsiaResourceDialect
26104                ),
26105            }
26106        }
26107
26108        #[inline]
26109        unsafe fn decode(
26110            &mut self,
26111            decoder: &mut fidl::encoding::Decoder<
26112                '_,
26113                fidl::encoding::DefaultFuchsiaResourceDialect,
26114            >,
26115            offset: usize,
26116            _depth: fidl::encoding::Depth,
26117        ) -> fidl::Result<()> {
26118            decoder.debug_check_bounds::<Self>(offset);
26119            // Verify that padding bytes are zero.
26120            fidl::decode!(
26121                StreamBufferPartialSettings,
26122                fidl::encoding::DefaultFuchsiaResourceDialect,
26123                &mut self.output_settings,
26124                decoder,
26125                offset + 0,
26126                _depth
26127            )?;
26128            Ok(())
26129        }
26130    }
26131
26132    impl fidl::encoding::ResourceTypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
26133        type Borrowed<'a> = &'a mut Self;
26134        fn take_or_borrow<'a>(
26135            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26136        ) -> Self::Borrowed<'a> {
26137            value
26138        }
26139    }
26140
26141    unsafe impl fidl::encoding::TypeMarker for Usage2AudioConsumerFactoryCreateAudioConsumerRequest {
26142        type Owned = Self;
26143
26144        #[inline(always)]
26145        fn inline_align(_context: fidl::encoding::Context) -> usize {
26146            4
26147        }
26148
26149        #[inline(always)]
26150        fn inline_size(_context: fidl::encoding::Context) -> usize {
26151            8
26152        }
26153    }
26154
26155    unsafe impl
26156        fidl::encoding::Encode<
26157            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
26158            fidl::encoding::DefaultFuchsiaResourceDialect,
26159        > for &mut Usage2AudioConsumerFactoryCreateAudioConsumerRequest
26160    {
26161        #[inline]
26162        unsafe fn encode(
26163            self,
26164            encoder: &mut fidl::encoding::Encoder<
26165                '_,
26166                fidl::encoding::DefaultFuchsiaResourceDialect,
26167            >,
26168            offset: usize,
26169            _depth: fidl::encoding::Depth,
26170        ) -> fidl::Result<()> {
26171            encoder
26172                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26173            // Delegate to tuple encoding.
26174            fidl::encoding::Encode::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26175                (
26176                    <AudioRenderUsage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26177                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
26178                ),
26179                encoder, offset, _depth
26180            )
26181        }
26182    }
26183    unsafe impl<
26184        T0: fidl::encoding::Encode<AudioRenderUsage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
26185        T1: fidl::encoding::Encode<
26186                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26187                fidl::encoding::DefaultFuchsiaResourceDialect,
26188            >,
26189    >
26190        fidl::encoding::Encode<
26191            Usage2AudioConsumerFactoryCreateAudioConsumerRequest,
26192            fidl::encoding::DefaultFuchsiaResourceDialect,
26193        > for (T0, T1)
26194    {
26195        #[inline]
26196        unsafe fn encode(
26197            self,
26198            encoder: &mut fidl::encoding::Encoder<
26199                '_,
26200                fidl::encoding::DefaultFuchsiaResourceDialect,
26201            >,
26202            offset: usize,
26203            depth: fidl::encoding::Depth,
26204        ) -> fidl::Result<()> {
26205            encoder
26206                .debug_check_bounds::<Usage2AudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26207            // Zero out padding regions. There's no need to apply masks
26208            // because the unmasked parts will be overwritten by fields.
26209            // Write the fields.
26210            self.0.encode(encoder, offset + 0, depth)?;
26211            self.1.encode(encoder, offset + 4, depth)?;
26212            Ok(())
26213        }
26214    }
26215
26216    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26217        for Usage2AudioConsumerFactoryCreateAudioConsumerRequest
26218    {
26219        #[inline(always)]
26220        fn new_empty() -> Self {
26221            Self {
26222                usage: fidl::new_empty!(
26223                    AudioRenderUsage2,
26224                    fidl::encoding::DefaultFuchsiaResourceDialect
26225                ),
26226                audio_consumer_request: fidl::new_empty!(
26227                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26228                    fidl::encoding::DefaultFuchsiaResourceDialect
26229                ),
26230            }
26231        }
26232
26233        #[inline]
26234        unsafe fn decode(
26235            &mut self,
26236            decoder: &mut fidl::encoding::Decoder<
26237                '_,
26238                fidl::encoding::DefaultFuchsiaResourceDialect,
26239            >,
26240            offset: usize,
26241            _depth: fidl::encoding::Depth,
26242        ) -> fidl::Result<()> {
26243            decoder.debug_check_bounds::<Self>(offset);
26244            // Verify that padding bytes are zero.
26245            fidl::decode!(
26246                AudioRenderUsage2,
26247                fidl::encoding::DefaultFuchsiaResourceDialect,
26248                &mut self.usage,
26249                decoder,
26250                offset + 0,
26251                _depth
26252            )?;
26253            fidl::decode!(
26254                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26255                fidl::encoding::DefaultFuchsiaResourceDialect,
26256                &mut self.audio_consumer_request,
26257                decoder,
26258                offset + 4,
26259                _depth
26260            )?;
26261            Ok(())
26262        }
26263    }
26264
26265    impl fidl::encoding::ResourceTypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
26266        type Borrowed<'a> = &'a mut Self;
26267        fn take_or_borrow<'a>(
26268            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26269        ) -> Self::Borrowed<'a> {
26270            value
26271        }
26272    }
26273
26274    unsafe impl fidl::encoding::TypeMarker for UsageAudioConsumerFactoryCreateAudioConsumerRequest {
26275        type Owned = Self;
26276
26277        #[inline(always)]
26278        fn inline_align(_context: fidl::encoding::Context) -> usize {
26279            4
26280        }
26281
26282        #[inline(always)]
26283        fn inline_size(_context: fidl::encoding::Context) -> usize {
26284            8
26285        }
26286    }
26287
26288    unsafe impl
26289        fidl::encoding::Encode<
26290            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
26291            fidl::encoding::DefaultFuchsiaResourceDialect,
26292        > for &mut UsageAudioConsumerFactoryCreateAudioConsumerRequest
26293    {
26294        #[inline]
26295        unsafe fn encode(
26296            self,
26297            encoder: &mut fidl::encoding::Encoder<
26298                '_,
26299                fidl::encoding::DefaultFuchsiaResourceDialect,
26300            >,
26301            offset: usize,
26302            _depth: fidl::encoding::Depth,
26303        ) -> fidl::Result<()> {
26304            encoder
26305                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26306            // Delegate to tuple encoding.
26307            fidl::encoding::Encode::<UsageAudioConsumerFactoryCreateAudioConsumerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26308                (
26309                    <AudioRenderUsage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26310                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.audio_consumer_request),
26311                ),
26312                encoder, offset, _depth
26313            )
26314        }
26315    }
26316    unsafe impl<
26317        T0: fidl::encoding::Encode<AudioRenderUsage, fidl::encoding::DefaultFuchsiaResourceDialect>,
26318        T1: fidl::encoding::Encode<
26319                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26320                fidl::encoding::DefaultFuchsiaResourceDialect,
26321            >,
26322    >
26323        fidl::encoding::Encode<
26324            UsageAudioConsumerFactoryCreateAudioConsumerRequest,
26325            fidl::encoding::DefaultFuchsiaResourceDialect,
26326        > for (T0, T1)
26327    {
26328        #[inline]
26329        unsafe fn encode(
26330            self,
26331            encoder: &mut fidl::encoding::Encoder<
26332                '_,
26333                fidl::encoding::DefaultFuchsiaResourceDialect,
26334            >,
26335            offset: usize,
26336            depth: fidl::encoding::Depth,
26337        ) -> fidl::Result<()> {
26338            encoder
26339                .debug_check_bounds::<UsageAudioConsumerFactoryCreateAudioConsumerRequest>(offset);
26340            // Zero out padding regions. There's no need to apply masks
26341            // because the unmasked parts will be overwritten by fields.
26342            // Write the fields.
26343            self.0.encode(encoder, offset + 0, depth)?;
26344            self.1.encode(encoder, offset + 4, depth)?;
26345            Ok(())
26346        }
26347    }
26348
26349    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26350        for UsageAudioConsumerFactoryCreateAudioConsumerRequest
26351    {
26352        #[inline(always)]
26353        fn new_empty() -> Self {
26354            Self {
26355                usage: fidl::new_empty!(
26356                    AudioRenderUsage,
26357                    fidl::encoding::DefaultFuchsiaResourceDialect
26358                ),
26359                audio_consumer_request: fidl::new_empty!(
26360                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26361                    fidl::encoding::DefaultFuchsiaResourceDialect
26362                ),
26363            }
26364        }
26365
26366        #[inline]
26367        unsafe fn decode(
26368            &mut self,
26369            decoder: &mut fidl::encoding::Decoder<
26370                '_,
26371                fidl::encoding::DefaultFuchsiaResourceDialect,
26372            >,
26373            offset: usize,
26374            _depth: fidl::encoding::Depth,
26375        ) -> fidl::Result<()> {
26376            decoder.debug_check_bounds::<Self>(offset);
26377            // Verify that padding bytes are zero.
26378            fidl::decode!(
26379                AudioRenderUsage,
26380                fidl::encoding::DefaultFuchsiaResourceDialect,
26381                &mut self.usage,
26382                decoder,
26383                offset + 0,
26384                _depth
26385            )?;
26386            fidl::decode!(
26387                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<AudioConsumerMarker>>,
26388                fidl::encoding::DefaultFuchsiaResourceDialect,
26389                &mut self.audio_consumer_request,
26390                decoder,
26391                offset + 4,
26392                _depth
26393            )?;
26394            Ok(())
26395        }
26396    }
26397
26398    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListener2Request {
26399        type Borrowed<'a> = &'a mut Self;
26400        fn take_or_borrow<'a>(
26401            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26402        ) -> Self::Borrowed<'a> {
26403            value
26404        }
26405    }
26406
26407    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListener2Request {
26408        type Owned = Self;
26409
26410        #[inline(always)]
26411        fn inline_align(_context: fidl::encoding::Context) -> usize {
26412            8
26413        }
26414
26415        #[inline(always)]
26416        fn inline_size(_context: fidl::encoding::Context) -> usize {
26417            40
26418        }
26419    }
26420
26421    unsafe impl
26422        fidl::encoding::Encode<
26423            UsageGainReporterRegisterListener2Request,
26424            fidl::encoding::DefaultFuchsiaResourceDialect,
26425        > for &mut UsageGainReporterRegisterListener2Request
26426    {
26427        #[inline]
26428        unsafe fn encode(
26429            self,
26430            encoder: &mut fidl::encoding::Encoder<
26431                '_,
26432                fidl::encoding::DefaultFuchsiaResourceDialect,
26433            >,
26434            offset: usize,
26435            _depth: fidl::encoding::Depth,
26436        ) -> fidl::Result<()> {
26437            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
26438            // Delegate to tuple encoding.
26439            fidl::encoding::Encode::<UsageGainReporterRegisterListener2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26440                (
26441                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
26442                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26443                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
26444                ),
26445                encoder, offset, _depth
26446            )
26447        }
26448    }
26449    unsafe impl<
26450        T0: fidl::encoding::Encode<
26451                fidl::encoding::BoundedString<36>,
26452                fidl::encoding::DefaultFuchsiaResourceDialect,
26453            >,
26454        T1: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
26455        T2: fidl::encoding::Encode<
26456                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26457                fidl::encoding::DefaultFuchsiaResourceDialect,
26458            >,
26459    >
26460        fidl::encoding::Encode<
26461            UsageGainReporterRegisterListener2Request,
26462            fidl::encoding::DefaultFuchsiaResourceDialect,
26463        > for (T0, T1, T2)
26464    {
26465        #[inline]
26466        unsafe fn encode(
26467            self,
26468            encoder: &mut fidl::encoding::Encoder<
26469                '_,
26470                fidl::encoding::DefaultFuchsiaResourceDialect,
26471            >,
26472            offset: usize,
26473            depth: fidl::encoding::Depth,
26474        ) -> fidl::Result<()> {
26475            encoder.debug_check_bounds::<UsageGainReporterRegisterListener2Request>(offset);
26476            // Zero out padding regions. There's no need to apply masks
26477            // because the unmasked parts will be overwritten by fields.
26478            unsafe {
26479                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
26480                (ptr as *mut u64).write_unaligned(0);
26481            }
26482            // Write the fields.
26483            self.0.encode(encoder, offset + 0, depth)?;
26484            self.1.encode(encoder, offset + 16, depth)?;
26485            self.2.encode(encoder, offset + 32, depth)?;
26486            Ok(())
26487        }
26488    }
26489
26490    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26491        for UsageGainReporterRegisterListener2Request
26492    {
26493        #[inline(always)]
26494        fn new_empty() -> Self {
26495            Self {
26496                device_unique_id: fidl::new_empty!(
26497                    fidl::encoding::BoundedString<36>,
26498                    fidl::encoding::DefaultFuchsiaResourceDialect
26499                ),
26500                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
26501                usage_gain_listener: fidl::new_empty!(
26502                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26503                    fidl::encoding::DefaultFuchsiaResourceDialect
26504                ),
26505            }
26506        }
26507
26508        #[inline]
26509        unsafe fn decode(
26510            &mut self,
26511            decoder: &mut fidl::encoding::Decoder<
26512                '_,
26513                fidl::encoding::DefaultFuchsiaResourceDialect,
26514            >,
26515            offset: usize,
26516            _depth: fidl::encoding::Depth,
26517        ) -> fidl::Result<()> {
26518            decoder.debug_check_bounds::<Self>(offset);
26519            // Verify that padding bytes are zero.
26520            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
26521            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26522            let mask = 0xffffffff00000000u64;
26523            let maskedval = padval & mask;
26524            if maskedval != 0 {
26525                return Err(fidl::Error::NonZeroPadding {
26526                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
26527                });
26528            }
26529            fidl::decode!(
26530                fidl::encoding::BoundedString<36>,
26531                fidl::encoding::DefaultFuchsiaResourceDialect,
26532                &mut self.device_unique_id,
26533                decoder,
26534                offset + 0,
26535                _depth
26536            )?;
26537            fidl::decode!(
26538                Usage2,
26539                fidl::encoding::DefaultFuchsiaResourceDialect,
26540                &mut self.usage,
26541                decoder,
26542                offset + 16,
26543                _depth
26544            )?;
26545            fidl::decode!(
26546                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26547                fidl::encoding::DefaultFuchsiaResourceDialect,
26548                &mut self.usage_gain_listener,
26549                decoder,
26550                offset + 32,
26551                _depth
26552            )?;
26553            Ok(())
26554        }
26555    }
26556
26557    impl fidl::encoding::ResourceTypeMarker for UsageGainReporterRegisterListenerRequest {
26558        type Borrowed<'a> = &'a mut Self;
26559        fn take_or_borrow<'a>(
26560            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26561        ) -> Self::Borrowed<'a> {
26562            value
26563        }
26564    }
26565
26566    unsafe impl fidl::encoding::TypeMarker for UsageGainReporterRegisterListenerRequest {
26567        type Owned = Self;
26568
26569        #[inline(always)]
26570        fn inline_align(_context: fidl::encoding::Context) -> usize {
26571            8
26572        }
26573
26574        #[inline(always)]
26575        fn inline_size(_context: fidl::encoding::Context) -> usize {
26576            40
26577        }
26578    }
26579
26580    unsafe impl
26581        fidl::encoding::Encode<
26582            UsageGainReporterRegisterListenerRequest,
26583            fidl::encoding::DefaultFuchsiaResourceDialect,
26584        > for &mut UsageGainReporterRegisterListenerRequest
26585    {
26586        #[inline]
26587        unsafe fn encode(
26588            self,
26589            encoder: &mut fidl::encoding::Encoder<
26590                '_,
26591                fidl::encoding::DefaultFuchsiaResourceDialect,
26592            >,
26593            offset: usize,
26594            _depth: fidl::encoding::Depth,
26595        ) -> fidl::Result<()> {
26596            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
26597            // Delegate to tuple encoding.
26598            fidl::encoding::Encode::<UsageGainReporterRegisterListenerRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26599                (
26600                    <fidl::encoding::BoundedString<36> as fidl::encoding::ValueTypeMarker>::borrow(&self.device_unique_id),
26601                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26602                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_gain_listener),
26603                ),
26604                encoder, offset, _depth
26605            )
26606        }
26607    }
26608    unsafe impl<
26609        T0: fidl::encoding::Encode<
26610                fidl::encoding::BoundedString<36>,
26611                fidl::encoding::DefaultFuchsiaResourceDialect,
26612            >,
26613        T1: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
26614        T2: fidl::encoding::Encode<
26615                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26616                fidl::encoding::DefaultFuchsiaResourceDialect,
26617            >,
26618    >
26619        fidl::encoding::Encode<
26620            UsageGainReporterRegisterListenerRequest,
26621            fidl::encoding::DefaultFuchsiaResourceDialect,
26622        > for (T0, T1, T2)
26623    {
26624        #[inline]
26625        unsafe fn encode(
26626            self,
26627            encoder: &mut fidl::encoding::Encoder<
26628                '_,
26629                fidl::encoding::DefaultFuchsiaResourceDialect,
26630            >,
26631            offset: usize,
26632            depth: fidl::encoding::Depth,
26633        ) -> fidl::Result<()> {
26634            encoder.debug_check_bounds::<UsageGainReporterRegisterListenerRequest>(offset);
26635            // Zero out padding regions. There's no need to apply masks
26636            // because the unmasked parts will be overwritten by fields.
26637            unsafe {
26638                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
26639                (ptr as *mut u64).write_unaligned(0);
26640            }
26641            // Write the fields.
26642            self.0.encode(encoder, offset + 0, depth)?;
26643            self.1.encode(encoder, offset + 16, depth)?;
26644            self.2.encode(encoder, offset + 32, depth)?;
26645            Ok(())
26646        }
26647    }
26648
26649    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26650        for UsageGainReporterRegisterListenerRequest
26651    {
26652        #[inline(always)]
26653        fn new_empty() -> Self {
26654            Self {
26655                device_unique_id: fidl::new_empty!(
26656                    fidl::encoding::BoundedString<36>,
26657                    fidl::encoding::DefaultFuchsiaResourceDialect
26658                ),
26659                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
26660                usage_gain_listener: fidl::new_empty!(
26661                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26662                    fidl::encoding::DefaultFuchsiaResourceDialect
26663                ),
26664            }
26665        }
26666
26667        #[inline]
26668        unsafe fn decode(
26669            &mut self,
26670            decoder: &mut fidl::encoding::Decoder<
26671                '_,
26672                fidl::encoding::DefaultFuchsiaResourceDialect,
26673            >,
26674            offset: usize,
26675            _depth: fidl::encoding::Depth,
26676        ) -> fidl::Result<()> {
26677            decoder.debug_check_bounds::<Self>(offset);
26678            // Verify that padding bytes are zero.
26679            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
26680            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26681            let mask = 0xffffffff00000000u64;
26682            let maskedval = padval & mask;
26683            if maskedval != 0 {
26684                return Err(fidl::Error::NonZeroPadding {
26685                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
26686                });
26687            }
26688            fidl::decode!(
26689                fidl::encoding::BoundedString<36>,
26690                fidl::encoding::DefaultFuchsiaResourceDialect,
26691                &mut self.device_unique_id,
26692                decoder,
26693                offset + 0,
26694                _depth
26695            )?;
26696            fidl::decode!(
26697                Usage,
26698                fidl::encoding::DefaultFuchsiaResourceDialect,
26699                &mut self.usage,
26700                decoder,
26701                offset + 16,
26702                _depth
26703            )?;
26704            fidl::decode!(
26705                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageGainListenerMarker>>,
26706                fidl::encoding::DefaultFuchsiaResourceDialect,
26707                &mut self.usage_gain_listener,
26708                decoder,
26709                offset + 32,
26710                _depth
26711            )?;
26712            Ok(())
26713        }
26714    }
26715
26716    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatch2Request {
26717        type Borrowed<'a> = &'a mut Self;
26718        fn take_or_borrow<'a>(
26719            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26720        ) -> Self::Borrowed<'a> {
26721            value
26722        }
26723    }
26724
26725    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatch2Request {
26726        type Owned = Self;
26727
26728        #[inline(always)]
26729        fn inline_align(_context: fidl::encoding::Context) -> usize {
26730            8
26731        }
26732
26733        #[inline(always)]
26734        fn inline_size(_context: fidl::encoding::Context) -> usize {
26735            24
26736        }
26737    }
26738
26739    unsafe impl
26740        fidl::encoding::Encode<
26741            UsageReporterWatch2Request,
26742            fidl::encoding::DefaultFuchsiaResourceDialect,
26743        > for &mut UsageReporterWatch2Request
26744    {
26745        #[inline]
26746        unsafe fn encode(
26747            self,
26748            encoder: &mut fidl::encoding::Encoder<
26749                '_,
26750                fidl::encoding::DefaultFuchsiaResourceDialect,
26751            >,
26752            offset: usize,
26753            _depth: fidl::encoding::Depth,
26754        ) -> fidl::Result<()> {
26755            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
26756            // Delegate to tuple encoding.
26757            fidl::encoding::Encode::<UsageReporterWatch2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26758                (
26759                    <Usage2 as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26760                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
26761                ),
26762                encoder, offset, _depth
26763            )
26764        }
26765    }
26766    unsafe impl<
26767        T0: fidl::encoding::Encode<Usage2, fidl::encoding::DefaultFuchsiaResourceDialect>,
26768        T1: fidl::encoding::Encode<
26769                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
26770                fidl::encoding::DefaultFuchsiaResourceDialect,
26771            >,
26772    >
26773        fidl::encoding::Encode<
26774            UsageReporterWatch2Request,
26775            fidl::encoding::DefaultFuchsiaResourceDialect,
26776        > for (T0, T1)
26777    {
26778        #[inline]
26779        unsafe fn encode(
26780            self,
26781            encoder: &mut fidl::encoding::Encoder<
26782                '_,
26783                fidl::encoding::DefaultFuchsiaResourceDialect,
26784            >,
26785            offset: usize,
26786            depth: fidl::encoding::Depth,
26787        ) -> fidl::Result<()> {
26788            encoder.debug_check_bounds::<UsageReporterWatch2Request>(offset);
26789            // Zero out padding regions. There's no need to apply masks
26790            // because the unmasked parts will be overwritten by fields.
26791            unsafe {
26792                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
26793                (ptr as *mut u64).write_unaligned(0);
26794            }
26795            // Write the fields.
26796            self.0.encode(encoder, offset + 0, depth)?;
26797            self.1.encode(encoder, offset + 16, depth)?;
26798            Ok(())
26799        }
26800    }
26801
26802    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26803        for UsageReporterWatch2Request
26804    {
26805        #[inline(always)]
26806        fn new_empty() -> Self {
26807            Self {
26808                usage: fidl::new_empty!(Usage2, fidl::encoding::DefaultFuchsiaResourceDialect),
26809                usage_watcher: fidl::new_empty!(
26810                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
26811                    fidl::encoding::DefaultFuchsiaResourceDialect
26812                ),
26813            }
26814        }
26815
26816        #[inline]
26817        unsafe fn decode(
26818            &mut self,
26819            decoder: &mut fidl::encoding::Decoder<
26820                '_,
26821                fidl::encoding::DefaultFuchsiaResourceDialect,
26822            >,
26823            offset: usize,
26824            _depth: fidl::encoding::Depth,
26825        ) -> fidl::Result<()> {
26826            decoder.debug_check_bounds::<Self>(offset);
26827            // Verify that padding bytes are zero.
26828            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
26829            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26830            let mask = 0xffffffff00000000u64;
26831            let maskedval = padval & mask;
26832            if maskedval != 0 {
26833                return Err(fidl::Error::NonZeroPadding {
26834                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
26835                });
26836            }
26837            fidl::decode!(
26838                Usage2,
26839                fidl::encoding::DefaultFuchsiaResourceDialect,
26840                &mut self.usage,
26841                decoder,
26842                offset + 0,
26843                _depth
26844            )?;
26845            fidl::decode!(
26846                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcher2Marker>>,
26847                fidl::encoding::DefaultFuchsiaResourceDialect,
26848                &mut self.usage_watcher,
26849                decoder,
26850                offset + 16,
26851                _depth
26852            )?;
26853            Ok(())
26854        }
26855    }
26856
26857    impl fidl::encoding::ResourceTypeMarker for UsageReporterWatchRequest {
26858        type Borrowed<'a> = &'a mut Self;
26859        fn take_or_borrow<'a>(
26860            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
26861        ) -> Self::Borrowed<'a> {
26862            value
26863        }
26864    }
26865
26866    unsafe impl fidl::encoding::TypeMarker for UsageReporterWatchRequest {
26867        type Owned = Self;
26868
26869        #[inline(always)]
26870        fn inline_align(_context: fidl::encoding::Context) -> usize {
26871            8
26872        }
26873
26874        #[inline(always)]
26875        fn inline_size(_context: fidl::encoding::Context) -> usize {
26876            24
26877        }
26878    }
26879
26880    unsafe impl
26881        fidl::encoding::Encode<
26882            UsageReporterWatchRequest,
26883            fidl::encoding::DefaultFuchsiaResourceDialect,
26884        > for &mut UsageReporterWatchRequest
26885    {
26886        #[inline]
26887        unsafe fn encode(
26888            self,
26889            encoder: &mut fidl::encoding::Encoder<
26890                '_,
26891                fidl::encoding::DefaultFuchsiaResourceDialect,
26892            >,
26893            offset: usize,
26894            _depth: fidl::encoding::Depth,
26895        ) -> fidl::Result<()> {
26896            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
26897            // Delegate to tuple encoding.
26898            fidl::encoding::Encode::<UsageReporterWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
26899                (
26900                    <Usage as fidl::encoding::ValueTypeMarker>::borrow(&self.usage),
26901                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.usage_watcher),
26902                ),
26903                encoder, offset, _depth
26904            )
26905        }
26906    }
26907    unsafe impl<
26908        T0: fidl::encoding::Encode<Usage, fidl::encoding::DefaultFuchsiaResourceDialect>,
26909        T1: fidl::encoding::Encode<
26910                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
26911                fidl::encoding::DefaultFuchsiaResourceDialect,
26912            >,
26913    >
26914        fidl::encoding::Encode<
26915            UsageReporterWatchRequest,
26916            fidl::encoding::DefaultFuchsiaResourceDialect,
26917        > for (T0, T1)
26918    {
26919        #[inline]
26920        unsafe fn encode(
26921            self,
26922            encoder: &mut fidl::encoding::Encoder<
26923                '_,
26924                fidl::encoding::DefaultFuchsiaResourceDialect,
26925            >,
26926            offset: usize,
26927            depth: fidl::encoding::Depth,
26928        ) -> fidl::Result<()> {
26929            encoder.debug_check_bounds::<UsageReporterWatchRequest>(offset);
26930            // Zero out padding regions. There's no need to apply masks
26931            // because the unmasked parts will be overwritten by fields.
26932            unsafe {
26933                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
26934                (ptr as *mut u64).write_unaligned(0);
26935            }
26936            // Write the fields.
26937            self.0.encode(encoder, offset + 0, depth)?;
26938            self.1.encode(encoder, offset + 16, depth)?;
26939            Ok(())
26940        }
26941    }
26942
26943    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
26944        for UsageReporterWatchRequest
26945    {
26946        #[inline(always)]
26947        fn new_empty() -> Self {
26948            Self {
26949                usage: fidl::new_empty!(Usage, fidl::encoding::DefaultFuchsiaResourceDialect),
26950                usage_watcher: fidl::new_empty!(
26951                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
26952                    fidl::encoding::DefaultFuchsiaResourceDialect
26953                ),
26954            }
26955        }
26956
26957        #[inline]
26958        unsafe fn decode(
26959            &mut self,
26960            decoder: &mut fidl::encoding::Decoder<
26961                '_,
26962                fidl::encoding::DefaultFuchsiaResourceDialect,
26963            >,
26964            offset: usize,
26965            _depth: fidl::encoding::Depth,
26966        ) -> fidl::Result<()> {
26967            decoder.debug_check_bounds::<Self>(offset);
26968            // Verify that padding bytes are zero.
26969            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
26970            let padval = unsafe { (ptr as *const u64).read_unaligned() };
26971            let mask = 0xffffffff00000000u64;
26972            let maskedval = padval & mask;
26973            if maskedval != 0 {
26974                return Err(fidl::Error::NonZeroPadding {
26975                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
26976                });
26977            }
26978            fidl::decode!(
26979                Usage,
26980                fidl::encoding::DefaultFuchsiaResourceDialect,
26981                &mut self.usage,
26982                decoder,
26983                offset + 0,
26984                _depth
26985            )?;
26986            fidl::decode!(
26987                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsageWatcherMarker>>,
26988                fidl::encoding::DefaultFuchsiaResourceDialect,
26989                &mut self.usage_watcher,
26990                decoder,
26991                offset + 16,
26992                _depth
26993            )?;
26994            Ok(())
26995        }
26996    }
26997
26998    impl StreamBufferPartialSettings {
26999        #[inline(always)]
27000        fn max_ordinal_present(&self) -> u64 {
27001            if let Some(_) = self.sysmem2_token {
27002                return 7;
27003            }
27004            if let Some(_) = self.sysmem_token {
27005                return 6;
27006            }
27007            if let Some(_) = self.packet_count_for_client {
27008                return 5;
27009            }
27010            if let Some(_) = self.packet_count_for_server {
27011                return 4;
27012            }
27013            if let Some(_) = self.single_buffer_mode {
27014                return 3;
27015            }
27016            if let Some(_) = self.buffer_constraints_version_ordinal {
27017                return 2;
27018            }
27019            if let Some(_) = self.buffer_lifetime_ordinal {
27020                return 1;
27021            }
27022            0
27023        }
27024    }
27025
27026    impl fidl::encoding::ResourceTypeMarker for StreamBufferPartialSettings {
27027        type Borrowed<'a> = &'a mut Self;
27028        fn take_or_borrow<'a>(
27029            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
27030        ) -> Self::Borrowed<'a> {
27031            value
27032        }
27033    }
27034
27035    unsafe impl fidl::encoding::TypeMarker for StreamBufferPartialSettings {
27036        type Owned = Self;
27037
27038        #[inline(always)]
27039        fn inline_align(_context: fidl::encoding::Context) -> usize {
27040            8
27041        }
27042
27043        #[inline(always)]
27044        fn inline_size(_context: fidl::encoding::Context) -> usize {
27045            16
27046        }
27047    }
27048
27049    unsafe impl
27050        fidl::encoding::Encode<
27051            StreamBufferPartialSettings,
27052            fidl::encoding::DefaultFuchsiaResourceDialect,
27053        > for &mut StreamBufferPartialSettings
27054    {
27055        unsafe fn encode(
27056            self,
27057            encoder: &mut fidl::encoding::Encoder<
27058                '_,
27059                fidl::encoding::DefaultFuchsiaResourceDialect,
27060            >,
27061            offset: usize,
27062            mut depth: fidl::encoding::Depth,
27063        ) -> fidl::Result<()> {
27064            encoder.debug_check_bounds::<StreamBufferPartialSettings>(offset);
27065            // Vector header
27066            let max_ordinal: u64 = self.max_ordinal_present();
27067            encoder.write_num(max_ordinal, offset);
27068            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
27069            // Calling encoder.out_of_line_offset(0) is not allowed.
27070            if max_ordinal == 0 {
27071                return Ok(());
27072            }
27073            depth.increment()?;
27074            let envelope_size = 8;
27075            let bytes_len = max_ordinal as usize * envelope_size;
27076            #[allow(unused_variables)]
27077            let offset = encoder.out_of_line_offset(bytes_len);
27078            let mut _prev_end_offset: usize = 0;
27079            if 1 > max_ordinal {
27080                return Ok(());
27081            }
27082
27083            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27084            // are envelope_size bytes.
27085            let cur_offset: usize = (1 - 1) * envelope_size;
27086
27087            // Zero reserved fields.
27088            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27089
27090            // Safety:
27091            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27092            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27093            //   envelope_size bytes, there is always sufficient room.
27094            fidl::encoding::encode_in_envelope_optional::<
27095                u64,
27096                fidl::encoding::DefaultFuchsiaResourceDialect,
27097            >(
27098                self.buffer_lifetime_ordinal
27099                    .as_ref()
27100                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27101                encoder,
27102                offset + cur_offset,
27103                depth,
27104            )?;
27105
27106            _prev_end_offset = cur_offset + envelope_size;
27107            if 2 > max_ordinal {
27108                return Ok(());
27109            }
27110
27111            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27112            // are envelope_size bytes.
27113            let cur_offset: usize = (2 - 1) * envelope_size;
27114
27115            // Zero reserved fields.
27116            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27117
27118            // Safety:
27119            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27120            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27121            //   envelope_size bytes, there is always sufficient room.
27122            fidl::encoding::encode_in_envelope_optional::<
27123                u64,
27124                fidl::encoding::DefaultFuchsiaResourceDialect,
27125            >(
27126                self.buffer_constraints_version_ordinal
27127                    .as_ref()
27128                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27129                encoder,
27130                offset + cur_offset,
27131                depth,
27132            )?;
27133
27134            _prev_end_offset = cur_offset + envelope_size;
27135            if 3 > max_ordinal {
27136                return Ok(());
27137            }
27138
27139            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27140            // are envelope_size bytes.
27141            let cur_offset: usize = (3 - 1) * envelope_size;
27142
27143            // Zero reserved fields.
27144            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27145
27146            // Safety:
27147            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27148            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27149            //   envelope_size bytes, there is always sufficient room.
27150            fidl::encoding::encode_in_envelope_optional::<
27151                bool,
27152                fidl::encoding::DefaultFuchsiaResourceDialect,
27153            >(
27154                self.single_buffer_mode
27155                    .as_ref()
27156                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
27157                encoder,
27158                offset + cur_offset,
27159                depth,
27160            )?;
27161
27162            _prev_end_offset = cur_offset + envelope_size;
27163            if 4 > max_ordinal {
27164                return Ok(());
27165            }
27166
27167            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27168            // are envelope_size bytes.
27169            let cur_offset: usize = (4 - 1) * envelope_size;
27170
27171            // Zero reserved fields.
27172            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27173
27174            // Safety:
27175            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27176            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27177            //   envelope_size bytes, there is always sufficient room.
27178            fidl::encoding::encode_in_envelope_optional::<
27179                u32,
27180                fidl::encoding::DefaultFuchsiaResourceDialect,
27181            >(
27182                self.packet_count_for_server
27183                    .as_ref()
27184                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
27185                encoder,
27186                offset + cur_offset,
27187                depth,
27188            )?;
27189
27190            _prev_end_offset = cur_offset + envelope_size;
27191            if 5 > max_ordinal {
27192                return Ok(());
27193            }
27194
27195            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27196            // are envelope_size bytes.
27197            let cur_offset: usize = (5 - 1) * envelope_size;
27198
27199            // Zero reserved fields.
27200            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27201
27202            // Safety:
27203            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27204            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27205            //   envelope_size bytes, there is always sufficient room.
27206            fidl::encoding::encode_in_envelope_optional::<
27207                u32,
27208                fidl::encoding::DefaultFuchsiaResourceDialect,
27209            >(
27210                self.packet_count_for_client
27211                    .as_ref()
27212                    .map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
27213                encoder,
27214                offset + cur_offset,
27215                depth,
27216            )?;
27217
27218            _prev_end_offset = cur_offset + envelope_size;
27219            if 6 > max_ordinal {
27220                return Ok(());
27221            }
27222
27223            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27224            // are envelope_size bytes.
27225            let cur_offset: usize = (6 - 1) * envelope_size;
27226
27227            // Zero reserved fields.
27228            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27229
27230            // Safety:
27231            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27232            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27233            //   envelope_size bytes, there is always sufficient room.
27234            fidl::encoding::encode_in_envelope_optional::<
27235                fidl::encoding::Endpoint<
27236                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
27237                >,
27238                fidl::encoding::DefaultFuchsiaResourceDialect,
27239            >(
27240                self.sysmem_token.as_mut().map(
27241                    <fidl::encoding::Endpoint<
27242                        fidl::endpoints::ClientEnd<
27243                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
27244                        >,
27245                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
27246                ),
27247                encoder,
27248                offset + cur_offset,
27249                depth,
27250            )?;
27251
27252            _prev_end_offset = cur_offset + envelope_size;
27253            if 7 > max_ordinal {
27254                return Ok(());
27255            }
27256
27257            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27258            // are envelope_size bytes.
27259            let cur_offset: usize = (7 - 1) * envelope_size;
27260
27261            // Zero reserved fields.
27262            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27263
27264            // Safety:
27265            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27266            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27267            //   envelope_size bytes, there is always sufficient room.
27268            fidl::encoding::encode_in_envelope_optional::<
27269                fidl::encoding::Endpoint<
27270                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
27271                >,
27272                fidl::encoding::DefaultFuchsiaResourceDialect,
27273            >(
27274                self.sysmem2_token.as_mut().map(
27275                    <fidl::encoding::Endpoint<
27276                        fidl::endpoints::ClientEnd<
27277                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
27278                        >,
27279                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
27280                ),
27281                encoder,
27282                offset + cur_offset,
27283                depth,
27284            )?;
27285
27286            _prev_end_offset = cur_offset + envelope_size;
27287
27288            Ok(())
27289        }
27290    }
27291
27292    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
27293        for StreamBufferPartialSettings
27294    {
27295        #[inline(always)]
27296        fn new_empty() -> Self {
27297            Self::default()
27298        }
27299
27300        unsafe fn decode(
27301            &mut self,
27302            decoder: &mut fidl::encoding::Decoder<
27303                '_,
27304                fidl::encoding::DefaultFuchsiaResourceDialect,
27305            >,
27306            offset: usize,
27307            mut depth: fidl::encoding::Depth,
27308        ) -> fidl::Result<()> {
27309            decoder.debug_check_bounds::<Self>(offset);
27310            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
27311                None => return Err(fidl::Error::NotNullable),
27312                Some(len) => len,
27313            };
27314            // Calling decoder.out_of_line_offset(0) is not allowed.
27315            if len == 0 {
27316                return Ok(());
27317            };
27318            depth.increment()?;
27319            let envelope_size = 8;
27320            let bytes_len = len * envelope_size;
27321            let offset = decoder.out_of_line_offset(bytes_len)?;
27322            // Decode the envelope for each type.
27323            let mut _next_ordinal_to_read = 0;
27324            let mut next_offset = offset;
27325            let end_offset = offset + bytes_len;
27326            _next_ordinal_to_read += 1;
27327            if next_offset >= end_offset {
27328                return Ok(());
27329            }
27330
27331            // Decode unknown envelopes for gaps in ordinals.
27332            while _next_ordinal_to_read < 1 {
27333                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27334                _next_ordinal_to_read += 1;
27335                next_offset += envelope_size;
27336            }
27337
27338            let next_out_of_line = decoder.next_out_of_line();
27339            let handles_before = decoder.remaining_handles();
27340            if let Some((inlined, num_bytes, num_handles)) =
27341                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27342            {
27343                let member_inline_size =
27344                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27345                if inlined != (member_inline_size <= 4) {
27346                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27347                }
27348                let inner_offset;
27349                let mut inner_depth = depth.clone();
27350                if inlined {
27351                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27352                    inner_offset = next_offset;
27353                } else {
27354                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27355                    inner_depth.increment()?;
27356                }
27357                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
27358                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
27359                });
27360                fidl::decode!(
27361                    u64,
27362                    fidl::encoding::DefaultFuchsiaResourceDialect,
27363                    val_ref,
27364                    decoder,
27365                    inner_offset,
27366                    inner_depth
27367                )?;
27368                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27369                {
27370                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27371                }
27372                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27373                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27374                }
27375            }
27376
27377            next_offset += envelope_size;
27378            _next_ordinal_to_read += 1;
27379            if next_offset >= end_offset {
27380                return Ok(());
27381            }
27382
27383            // Decode unknown envelopes for gaps in ordinals.
27384            while _next_ordinal_to_read < 2 {
27385                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27386                _next_ordinal_to_read += 1;
27387                next_offset += envelope_size;
27388            }
27389
27390            let next_out_of_line = decoder.next_out_of_line();
27391            let handles_before = decoder.remaining_handles();
27392            if let Some((inlined, num_bytes, num_handles)) =
27393                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27394            {
27395                let member_inline_size =
27396                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27397                if inlined != (member_inline_size <= 4) {
27398                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27399                }
27400                let inner_offset;
27401                let mut inner_depth = depth.clone();
27402                if inlined {
27403                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27404                    inner_offset = next_offset;
27405                } else {
27406                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27407                    inner_depth.increment()?;
27408                }
27409                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
27410                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
27411                });
27412                fidl::decode!(
27413                    u64,
27414                    fidl::encoding::DefaultFuchsiaResourceDialect,
27415                    val_ref,
27416                    decoder,
27417                    inner_offset,
27418                    inner_depth
27419                )?;
27420                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27421                {
27422                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27423                }
27424                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27425                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27426                }
27427            }
27428
27429            next_offset += envelope_size;
27430            _next_ordinal_to_read += 1;
27431            if next_offset >= end_offset {
27432                return Ok(());
27433            }
27434
27435            // Decode unknown envelopes for gaps in ordinals.
27436            while _next_ordinal_to_read < 3 {
27437                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27438                _next_ordinal_to_read += 1;
27439                next_offset += envelope_size;
27440            }
27441
27442            let next_out_of_line = decoder.next_out_of_line();
27443            let handles_before = decoder.remaining_handles();
27444            if let Some((inlined, num_bytes, num_handles)) =
27445                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27446            {
27447                let member_inline_size =
27448                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27449                if inlined != (member_inline_size <= 4) {
27450                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27451                }
27452                let inner_offset;
27453                let mut inner_depth = depth.clone();
27454                if inlined {
27455                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27456                    inner_offset = next_offset;
27457                } else {
27458                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27459                    inner_depth.increment()?;
27460                }
27461                let val_ref = self.single_buffer_mode.get_or_insert_with(|| {
27462                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
27463                });
27464                fidl::decode!(
27465                    bool,
27466                    fidl::encoding::DefaultFuchsiaResourceDialect,
27467                    val_ref,
27468                    decoder,
27469                    inner_offset,
27470                    inner_depth
27471                )?;
27472                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27473                {
27474                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27475                }
27476                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27477                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27478                }
27479            }
27480
27481            next_offset += envelope_size;
27482            _next_ordinal_to_read += 1;
27483            if next_offset >= end_offset {
27484                return Ok(());
27485            }
27486
27487            // Decode unknown envelopes for gaps in ordinals.
27488            while _next_ordinal_to_read < 4 {
27489                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27490                _next_ordinal_to_read += 1;
27491                next_offset += envelope_size;
27492            }
27493
27494            let next_out_of_line = decoder.next_out_of_line();
27495            let handles_before = decoder.remaining_handles();
27496            if let Some((inlined, num_bytes, num_handles)) =
27497                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27498            {
27499                let member_inline_size =
27500                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27501                if inlined != (member_inline_size <= 4) {
27502                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27503                }
27504                let inner_offset;
27505                let mut inner_depth = depth.clone();
27506                if inlined {
27507                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27508                    inner_offset = next_offset;
27509                } else {
27510                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27511                    inner_depth.increment()?;
27512                }
27513                let val_ref = self.packet_count_for_server.get_or_insert_with(|| {
27514                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
27515                });
27516                fidl::decode!(
27517                    u32,
27518                    fidl::encoding::DefaultFuchsiaResourceDialect,
27519                    val_ref,
27520                    decoder,
27521                    inner_offset,
27522                    inner_depth
27523                )?;
27524                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27525                {
27526                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27527                }
27528                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27529                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27530                }
27531            }
27532
27533            next_offset += envelope_size;
27534            _next_ordinal_to_read += 1;
27535            if next_offset >= end_offset {
27536                return Ok(());
27537            }
27538
27539            // Decode unknown envelopes for gaps in ordinals.
27540            while _next_ordinal_to_read < 5 {
27541                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27542                _next_ordinal_to_read += 1;
27543                next_offset += envelope_size;
27544            }
27545
27546            let next_out_of_line = decoder.next_out_of_line();
27547            let handles_before = decoder.remaining_handles();
27548            if let Some((inlined, num_bytes, num_handles)) =
27549                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27550            {
27551                let member_inline_size =
27552                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
27553                if inlined != (member_inline_size <= 4) {
27554                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27555                }
27556                let inner_offset;
27557                let mut inner_depth = depth.clone();
27558                if inlined {
27559                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27560                    inner_offset = next_offset;
27561                } else {
27562                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27563                    inner_depth.increment()?;
27564                }
27565                let val_ref = self.packet_count_for_client.get_or_insert_with(|| {
27566                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
27567                });
27568                fidl::decode!(
27569                    u32,
27570                    fidl::encoding::DefaultFuchsiaResourceDialect,
27571                    val_ref,
27572                    decoder,
27573                    inner_offset,
27574                    inner_depth
27575                )?;
27576                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27577                {
27578                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27579                }
27580                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27581                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27582                }
27583            }
27584
27585            next_offset += envelope_size;
27586            _next_ordinal_to_read += 1;
27587            if next_offset >= end_offset {
27588                return Ok(());
27589            }
27590
27591            // Decode unknown envelopes for gaps in ordinals.
27592            while _next_ordinal_to_read < 6 {
27593                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27594                _next_ordinal_to_read += 1;
27595                next_offset += envelope_size;
27596            }
27597
27598            let next_out_of_line = decoder.next_out_of_line();
27599            let handles_before = decoder.remaining_handles();
27600            if let Some((inlined, num_bytes, num_handles)) =
27601                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27602            {
27603                let member_inline_size = <fidl::encoding::Endpoint<
27604                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
27605                > as fidl::encoding::TypeMarker>::inline_size(
27606                    decoder.context
27607                );
27608                if inlined != (member_inline_size <= 4) {
27609                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27610                }
27611                let inner_offset;
27612                let mut inner_depth = depth.clone();
27613                if inlined {
27614                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27615                    inner_offset = next_offset;
27616                } else {
27617                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27618                    inner_depth.increment()?;
27619                }
27620                let val_ref = self.sysmem_token.get_or_insert_with(|| {
27621                    fidl::new_empty!(
27622                        fidl::encoding::Endpoint<
27623                            fidl::endpoints::ClientEnd<
27624                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
27625                            >,
27626                        >,
27627                        fidl::encoding::DefaultFuchsiaResourceDialect
27628                    )
27629                });
27630                fidl::decode!(
27631                    fidl::encoding::Endpoint<
27632                        fidl::endpoints::ClientEnd<
27633                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
27634                        >,
27635                    >,
27636                    fidl::encoding::DefaultFuchsiaResourceDialect,
27637                    val_ref,
27638                    decoder,
27639                    inner_offset,
27640                    inner_depth
27641                )?;
27642                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27643                {
27644                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27645                }
27646                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27647                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27648                }
27649            }
27650
27651            next_offset += envelope_size;
27652            _next_ordinal_to_read += 1;
27653            if next_offset >= end_offset {
27654                return Ok(());
27655            }
27656
27657            // Decode unknown envelopes for gaps in ordinals.
27658            while _next_ordinal_to_read < 7 {
27659                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27660                _next_ordinal_to_read += 1;
27661                next_offset += envelope_size;
27662            }
27663
27664            let next_out_of_line = decoder.next_out_of_line();
27665            let handles_before = decoder.remaining_handles();
27666            if let Some((inlined, num_bytes, num_handles)) =
27667                fidl::encoding::decode_envelope_header(decoder, next_offset)?
27668            {
27669                let member_inline_size = <fidl::encoding::Endpoint<
27670                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
27671                > as fidl::encoding::TypeMarker>::inline_size(
27672                    decoder.context
27673                );
27674                if inlined != (member_inline_size <= 4) {
27675                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
27676                }
27677                let inner_offset;
27678                let mut inner_depth = depth.clone();
27679                if inlined {
27680                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
27681                    inner_offset = next_offset;
27682                } else {
27683                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
27684                    inner_depth.increment()?;
27685                }
27686                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
27687                    fidl::new_empty!(
27688                        fidl::encoding::Endpoint<
27689                            fidl::endpoints::ClientEnd<
27690                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
27691                            >,
27692                        >,
27693                        fidl::encoding::DefaultFuchsiaResourceDialect
27694                    )
27695                });
27696                fidl::decode!(
27697                    fidl::encoding::Endpoint<
27698                        fidl::endpoints::ClientEnd<
27699                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
27700                        >,
27701                    >,
27702                    fidl::encoding::DefaultFuchsiaResourceDialect,
27703                    val_ref,
27704                    decoder,
27705                    inner_offset,
27706                    inner_depth
27707                )?;
27708                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
27709                {
27710                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
27711                }
27712                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
27713                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
27714                }
27715            }
27716
27717            next_offset += envelope_size;
27718
27719            // Decode the remaining unknown envelopes.
27720            while next_offset < end_offset {
27721                _next_ordinal_to_read += 1;
27722                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27723                next_offset += envelope_size;
27724            }
27725
27726            Ok(())
27727        }
27728    }
27729
27730    impl StreamProcessorAddBufferRequest {
27731        #[inline(always)]
27732        fn max_ordinal_present(&self) -> u64 {
27733            if let Some(_) = self.buffer {
27734                return 5;
27735            }
27736            if let Some(_) = self.buffer_index {
27737                return 4;
27738            }
27739            if let Some(_) = self.buffer_lifetime_ordinal {
27740                return 3;
27741            }
27742            if let Some(_) = self.buffer_constraints_version_ordinal {
27743                return 2;
27744            }
27745            if let Some(_) = self.port {
27746                return 1;
27747            }
27748            0
27749        }
27750    }
27751
27752    impl fidl::encoding::ResourceTypeMarker for StreamProcessorAddBufferRequest {
27753        type Borrowed<'a> = &'a mut Self;
27754        fn take_or_borrow<'a>(
27755            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
27756        ) -> Self::Borrowed<'a> {
27757            value
27758        }
27759    }
27760
27761    unsafe impl fidl::encoding::TypeMarker for StreamProcessorAddBufferRequest {
27762        type Owned = Self;
27763
27764        #[inline(always)]
27765        fn inline_align(_context: fidl::encoding::Context) -> usize {
27766            8
27767        }
27768
27769        #[inline(always)]
27770        fn inline_size(_context: fidl::encoding::Context) -> usize {
27771            16
27772        }
27773    }
27774
27775    unsafe impl
27776        fidl::encoding::Encode<
27777            StreamProcessorAddBufferRequest,
27778            fidl::encoding::DefaultFuchsiaResourceDialect,
27779        > for &mut StreamProcessorAddBufferRequest
27780    {
27781        unsafe fn encode(
27782            self,
27783            encoder: &mut fidl::encoding::Encoder<
27784                '_,
27785                fidl::encoding::DefaultFuchsiaResourceDialect,
27786            >,
27787            offset: usize,
27788            mut depth: fidl::encoding::Depth,
27789        ) -> fidl::Result<()> {
27790            encoder.debug_check_bounds::<StreamProcessorAddBufferRequest>(offset);
27791            // Vector header
27792            let max_ordinal: u64 = self.max_ordinal_present();
27793            encoder.write_num(max_ordinal, offset);
27794            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
27795            // Calling encoder.out_of_line_offset(0) is not allowed.
27796            if max_ordinal == 0 {
27797                return Ok(());
27798            }
27799            depth.increment()?;
27800            let envelope_size = 8;
27801            let bytes_len = max_ordinal as usize * envelope_size;
27802            #[allow(unused_variables)]
27803            let offset = encoder.out_of_line_offset(bytes_len);
27804            let mut _prev_end_offset: usize = 0;
27805            if 1 > max_ordinal {
27806                return Ok(());
27807            }
27808
27809            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27810            // are envelope_size bytes.
27811            let cur_offset: usize = (1 - 1) * envelope_size;
27812
27813            // Zero reserved fields.
27814            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27815
27816            // Safety:
27817            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27818            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27819            //   envelope_size bytes, there is always sufficient room.
27820            fidl::encoding::encode_in_envelope_optional::<
27821                Port,
27822                fidl::encoding::DefaultFuchsiaResourceDialect,
27823            >(
27824                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
27825                encoder,
27826                offset + cur_offset,
27827                depth,
27828            )?;
27829
27830            _prev_end_offset = cur_offset + envelope_size;
27831            if 2 > max_ordinal {
27832                return Ok(());
27833            }
27834
27835            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27836            // are envelope_size bytes.
27837            let cur_offset: usize = (2 - 1) * envelope_size;
27838
27839            // Zero reserved fields.
27840            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27841
27842            // Safety:
27843            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27844            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27845            //   envelope_size bytes, there is always sufficient room.
27846            fidl::encoding::encode_in_envelope_optional::<
27847                u64,
27848                fidl::encoding::DefaultFuchsiaResourceDialect,
27849            >(
27850                self.buffer_constraints_version_ordinal
27851                    .as_ref()
27852                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27853                encoder,
27854                offset + cur_offset,
27855                depth,
27856            )?;
27857
27858            _prev_end_offset = cur_offset + envelope_size;
27859            if 3 > max_ordinal {
27860                return Ok(());
27861            }
27862
27863            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27864            // are envelope_size bytes.
27865            let cur_offset: usize = (3 - 1) * envelope_size;
27866
27867            // Zero reserved fields.
27868            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27869
27870            // Safety:
27871            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27872            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27873            //   envelope_size bytes, there is always sufficient room.
27874            fidl::encoding::encode_in_envelope_optional::<
27875                u64,
27876                fidl::encoding::DefaultFuchsiaResourceDialect,
27877            >(
27878                self.buffer_lifetime_ordinal
27879                    .as_ref()
27880                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
27881                encoder,
27882                offset + cur_offset,
27883                depth,
27884            )?;
27885
27886            _prev_end_offset = cur_offset + envelope_size;
27887            if 4 > max_ordinal {
27888                return Ok(());
27889            }
27890
27891            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27892            // are envelope_size bytes.
27893            let cur_offset: usize = (4 - 1) * envelope_size;
27894
27895            // Zero reserved fields.
27896            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27897
27898            // Safety:
27899            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27900            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27901            //   envelope_size bytes, there is always sufficient room.
27902            fidl::encoding::encode_in_envelope_optional::<
27903                u32,
27904                fidl::encoding::DefaultFuchsiaResourceDialect,
27905            >(
27906                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
27907                encoder,
27908                offset + cur_offset,
27909                depth,
27910            )?;
27911
27912            _prev_end_offset = cur_offset + envelope_size;
27913            if 5 > max_ordinal {
27914                return Ok(());
27915            }
27916
27917            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
27918            // are envelope_size bytes.
27919            let cur_offset: usize = (5 - 1) * envelope_size;
27920
27921            // Zero reserved fields.
27922            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
27923
27924            // Safety:
27925            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
27926            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
27927            //   envelope_size bytes, there is always sufficient room.
27928            fidl::encoding::encode_in_envelope_optional::<
27929                fidl::encoding::HandleType<
27930                    fidl::Vmo,
27931                    { fidl::ObjectType::VMO.into_raw() },
27932                    2147483648,
27933                >,
27934                fidl::encoding::DefaultFuchsiaResourceDialect,
27935            >(
27936                self.buffer.as_mut().map(
27937                    <fidl::encoding::HandleType<
27938                        fidl::Vmo,
27939                        { fidl::ObjectType::VMO.into_raw() },
27940                        2147483648,
27941                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
27942                ),
27943                encoder,
27944                offset + cur_offset,
27945                depth,
27946            )?;
27947
27948            _prev_end_offset = cur_offset + envelope_size;
27949
27950            Ok(())
27951        }
27952    }
27953
27954    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
27955        for StreamProcessorAddBufferRequest
27956    {
27957        #[inline(always)]
27958        fn new_empty() -> Self {
27959            Self::default()
27960        }
27961
27962        unsafe fn decode(
27963            &mut self,
27964            decoder: &mut fidl::encoding::Decoder<
27965                '_,
27966                fidl::encoding::DefaultFuchsiaResourceDialect,
27967            >,
27968            offset: usize,
27969            mut depth: fidl::encoding::Depth,
27970        ) -> fidl::Result<()> {
27971            decoder.debug_check_bounds::<Self>(offset);
27972            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
27973                None => return Err(fidl::Error::NotNullable),
27974                Some(len) => len,
27975            };
27976            // Calling decoder.out_of_line_offset(0) is not allowed.
27977            if len == 0 {
27978                return Ok(());
27979            };
27980            depth.increment()?;
27981            let envelope_size = 8;
27982            let bytes_len = len * envelope_size;
27983            let offset = decoder.out_of_line_offset(bytes_len)?;
27984            // Decode the envelope for each type.
27985            let mut _next_ordinal_to_read = 0;
27986            let mut next_offset = offset;
27987            let end_offset = offset + bytes_len;
27988            _next_ordinal_to_read += 1;
27989            if next_offset >= end_offset {
27990                return Ok(());
27991            }
27992
27993            // Decode unknown envelopes for gaps in ordinals.
27994            while _next_ordinal_to_read < 1 {
27995                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
27996                _next_ordinal_to_read += 1;
27997                next_offset += envelope_size;
27998            }
27999
28000            let next_out_of_line = decoder.next_out_of_line();
28001            let handles_before = decoder.remaining_handles();
28002            if let Some((inlined, num_bytes, num_handles)) =
28003                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28004            {
28005                let member_inline_size =
28006                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28007                if inlined != (member_inline_size <= 4) {
28008                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28009                }
28010                let inner_offset;
28011                let mut inner_depth = depth.clone();
28012                if inlined {
28013                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28014                    inner_offset = next_offset;
28015                } else {
28016                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28017                    inner_depth.increment()?;
28018                }
28019                let val_ref = self.port.get_or_insert_with(|| {
28020                    fidl::new_empty!(Port, fidl::encoding::DefaultFuchsiaResourceDialect)
28021                });
28022                fidl::decode!(
28023                    Port,
28024                    fidl::encoding::DefaultFuchsiaResourceDialect,
28025                    val_ref,
28026                    decoder,
28027                    inner_offset,
28028                    inner_depth
28029                )?;
28030                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28031                {
28032                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28033                }
28034                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28035                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28036                }
28037            }
28038
28039            next_offset += envelope_size;
28040            _next_ordinal_to_read += 1;
28041            if next_offset >= end_offset {
28042                return Ok(());
28043            }
28044
28045            // Decode unknown envelopes for gaps in ordinals.
28046            while _next_ordinal_to_read < 2 {
28047                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28048                _next_ordinal_to_read += 1;
28049                next_offset += envelope_size;
28050            }
28051
28052            let next_out_of_line = decoder.next_out_of_line();
28053            let handles_before = decoder.remaining_handles();
28054            if let Some((inlined, num_bytes, num_handles)) =
28055                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28056            {
28057                let member_inline_size =
28058                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28059                if inlined != (member_inline_size <= 4) {
28060                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28061                }
28062                let inner_offset;
28063                let mut inner_depth = depth.clone();
28064                if inlined {
28065                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28066                    inner_offset = next_offset;
28067                } else {
28068                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28069                    inner_depth.increment()?;
28070                }
28071                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
28072                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28073                });
28074                fidl::decode!(
28075                    u64,
28076                    fidl::encoding::DefaultFuchsiaResourceDialect,
28077                    val_ref,
28078                    decoder,
28079                    inner_offset,
28080                    inner_depth
28081                )?;
28082                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28083                {
28084                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28085                }
28086                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28087                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28088                }
28089            }
28090
28091            next_offset += envelope_size;
28092            _next_ordinal_to_read += 1;
28093            if next_offset >= end_offset {
28094                return Ok(());
28095            }
28096
28097            // Decode unknown envelopes for gaps in ordinals.
28098            while _next_ordinal_to_read < 3 {
28099                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28100                _next_ordinal_to_read += 1;
28101                next_offset += envelope_size;
28102            }
28103
28104            let next_out_of_line = decoder.next_out_of_line();
28105            let handles_before = decoder.remaining_handles();
28106            if let Some((inlined, num_bytes, num_handles)) =
28107                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28108            {
28109                let member_inline_size =
28110                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28111                if inlined != (member_inline_size <= 4) {
28112                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28113                }
28114                let inner_offset;
28115                let mut inner_depth = depth.clone();
28116                if inlined {
28117                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28118                    inner_offset = next_offset;
28119                } else {
28120                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28121                    inner_depth.increment()?;
28122                }
28123                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
28124                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28125                });
28126                fidl::decode!(
28127                    u64,
28128                    fidl::encoding::DefaultFuchsiaResourceDialect,
28129                    val_ref,
28130                    decoder,
28131                    inner_offset,
28132                    inner_depth
28133                )?;
28134                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28135                {
28136                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28137                }
28138                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28139                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28140                }
28141            }
28142
28143            next_offset += envelope_size;
28144            _next_ordinal_to_read += 1;
28145            if next_offset >= end_offset {
28146                return Ok(());
28147            }
28148
28149            // Decode unknown envelopes for gaps in ordinals.
28150            while _next_ordinal_to_read < 4 {
28151                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28152                _next_ordinal_to_read += 1;
28153                next_offset += envelope_size;
28154            }
28155
28156            let next_out_of_line = decoder.next_out_of_line();
28157            let handles_before = decoder.remaining_handles();
28158            if let Some((inlined, num_bytes, num_handles)) =
28159                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28160            {
28161                let member_inline_size =
28162                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28163                if inlined != (member_inline_size <= 4) {
28164                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28165                }
28166                let inner_offset;
28167                let mut inner_depth = depth.clone();
28168                if inlined {
28169                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28170                    inner_offset = next_offset;
28171                } else {
28172                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28173                    inner_depth.increment()?;
28174                }
28175                let val_ref = self.buffer_index.get_or_insert_with(|| {
28176                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
28177                });
28178                fidl::decode!(
28179                    u32,
28180                    fidl::encoding::DefaultFuchsiaResourceDialect,
28181                    val_ref,
28182                    decoder,
28183                    inner_offset,
28184                    inner_depth
28185                )?;
28186                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28187                {
28188                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28189                }
28190                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28191                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28192                }
28193            }
28194
28195            next_offset += envelope_size;
28196            _next_ordinal_to_read += 1;
28197            if next_offset >= end_offset {
28198                return Ok(());
28199            }
28200
28201            // Decode unknown envelopes for gaps in ordinals.
28202            while _next_ordinal_to_read < 5 {
28203                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28204                _next_ordinal_to_read += 1;
28205                next_offset += envelope_size;
28206            }
28207
28208            let next_out_of_line = decoder.next_out_of_line();
28209            let handles_before = decoder.remaining_handles();
28210            if let Some((inlined, num_bytes, num_handles)) =
28211                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28212            {
28213                let member_inline_size = <fidl::encoding::HandleType<
28214                    fidl::Vmo,
28215                    { fidl::ObjectType::VMO.into_raw() },
28216                    2147483648,
28217                > as fidl::encoding::TypeMarker>::inline_size(
28218                    decoder.context
28219                );
28220                if inlined != (member_inline_size <= 4) {
28221                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28222                }
28223                let inner_offset;
28224                let mut inner_depth = depth.clone();
28225                if inlined {
28226                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28227                    inner_offset = next_offset;
28228                } else {
28229                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28230                    inner_depth.increment()?;
28231                }
28232                let val_ref =
28233                self.buffer.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
28234                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
28235                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28236                {
28237                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28238                }
28239                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28240                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28241                }
28242            }
28243
28244            next_offset += envelope_size;
28245
28246            // Decode the remaining unknown envelopes.
28247            while next_offset < end_offset {
28248                _next_ordinal_to_read += 1;
28249                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28250                next_offset += envelope_size;
28251            }
28252
28253            Ok(())
28254        }
28255    }
28256
28257    impl StreamProcessorParticipateInBufferAllocationRequest {
28258        #[inline(always)]
28259        fn max_ordinal_present(&self) -> u64 {
28260            if let Some(_) = self.allow_single_buffer {
28261                return 5;
28262            }
28263            if let Some(_) = self.buffer_lifetime_ordinal {
28264                return 4;
28265            }
28266            if let Some(_) = self.sysmem2_token {
28267                return 3;
28268            }
28269            if let Some(_) = self.buffer_constraints_version_ordinal {
28270                return 2;
28271            }
28272            if let Some(_) = self.port {
28273                return 1;
28274            }
28275            0
28276        }
28277    }
28278
28279    impl fidl::encoding::ResourceTypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
28280        type Borrowed<'a> = &'a mut Self;
28281        fn take_or_borrow<'a>(
28282            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
28283        ) -> Self::Borrowed<'a> {
28284            value
28285        }
28286    }
28287
28288    unsafe impl fidl::encoding::TypeMarker for StreamProcessorParticipateInBufferAllocationRequest {
28289        type Owned = Self;
28290
28291        #[inline(always)]
28292        fn inline_align(_context: fidl::encoding::Context) -> usize {
28293            8
28294        }
28295
28296        #[inline(always)]
28297        fn inline_size(_context: fidl::encoding::Context) -> usize {
28298            16
28299        }
28300    }
28301
28302    unsafe impl
28303        fidl::encoding::Encode<
28304            StreamProcessorParticipateInBufferAllocationRequest,
28305            fidl::encoding::DefaultFuchsiaResourceDialect,
28306        > for &mut StreamProcessorParticipateInBufferAllocationRequest
28307    {
28308        unsafe fn encode(
28309            self,
28310            encoder: &mut fidl::encoding::Encoder<
28311                '_,
28312                fidl::encoding::DefaultFuchsiaResourceDialect,
28313            >,
28314            offset: usize,
28315            mut depth: fidl::encoding::Depth,
28316        ) -> fidl::Result<()> {
28317            encoder
28318                .debug_check_bounds::<StreamProcessorParticipateInBufferAllocationRequest>(offset);
28319            // Vector header
28320            let max_ordinal: u64 = self.max_ordinal_present();
28321            encoder.write_num(max_ordinal, offset);
28322            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
28323            // Calling encoder.out_of_line_offset(0) is not allowed.
28324            if max_ordinal == 0 {
28325                return Ok(());
28326            }
28327            depth.increment()?;
28328            let envelope_size = 8;
28329            let bytes_len = max_ordinal as usize * envelope_size;
28330            #[allow(unused_variables)]
28331            let offset = encoder.out_of_line_offset(bytes_len);
28332            let mut _prev_end_offset: usize = 0;
28333            if 1 > max_ordinal {
28334                return Ok(());
28335            }
28336
28337            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28338            // are envelope_size bytes.
28339            let cur_offset: usize = (1 - 1) * envelope_size;
28340
28341            // Zero reserved fields.
28342            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28343
28344            // Safety:
28345            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28346            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28347            //   envelope_size bytes, there is always sufficient room.
28348            fidl::encoding::encode_in_envelope_optional::<
28349                Port,
28350                fidl::encoding::DefaultFuchsiaResourceDialect,
28351            >(
28352                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
28353                encoder,
28354                offset + cur_offset,
28355                depth,
28356            )?;
28357
28358            _prev_end_offset = cur_offset + envelope_size;
28359            if 2 > max_ordinal {
28360                return Ok(());
28361            }
28362
28363            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28364            // are envelope_size bytes.
28365            let cur_offset: usize = (2 - 1) * envelope_size;
28366
28367            // Zero reserved fields.
28368            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28369
28370            // Safety:
28371            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28372            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28373            //   envelope_size bytes, there is always sufficient room.
28374            fidl::encoding::encode_in_envelope_optional::<
28375                u64,
28376                fidl::encoding::DefaultFuchsiaResourceDialect,
28377            >(
28378                self.buffer_constraints_version_ordinal
28379                    .as_ref()
28380                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
28381                encoder,
28382                offset + cur_offset,
28383                depth,
28384            )?;
28385
28386            _prev_end_offset = cur_offset + envelope_size;
28387            if 3 > max_ordinal {
28388                return Ok(());
28389            }
28390
28391            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28392            // are envelope_size bytes.
28393            let cur_offset: usize = (3 - 1) * envelope_size;
28394
28395            // Zero reserved fields.
28396            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28397
28398            // Safety:
28399            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28400            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28401            //   envelope_size bytes, there is always sufficient room.
28402            fidl::encoding::encode_in_envelope_optional::<
28403                fidl::encoding::Endpoint<
28404                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
28405                >,
28406                fidl::encoding::DefaultFuchsiaResourceDialect,
28407            >(
28408                self.sysmem2_token.as_mut().map(
28409                    <fidl::encoding::Endpoint<
28410                        fidl::endpoints::ClientEnd<
28411                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
28412                        >,
28413                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
28414                ),
28415                encoder,
28416                offset + cur_offset,
28417                depth,
28418            )?;
28419
28420            _prev_end_offset = cur_offset + envelope_size;
28421            if 4 > max_ordinal {
28422                return Ok(());
28423            }
28424
28425            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28426            // are envelope_size bytes.
28427            let cur_offset: usize = (4 - 1) * envelope_size;
28428
28429            // Zero reserved fields.
28430            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28431
28432            // Safety:
28433            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28434            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28435            //   envelope_size bytes, there is always sufficient room.
28436            fidl::encoding::encode_in_envelope_optional::<
28437                u64,
28438                fidl::encoding::DefaultFuchsiaResourceDialect,
28439            >(
28440                self.buffer_lifetime_ordinal
28441                    .as_ref()
28442                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
28443                encoder,
28444                offset + cur_offset,
28445                depth,
28446            )?;
28447
28448            _prev_end_offset = cur_offset + envelope_size;
28449            if 5 > max_ordinal {
28450                return Ok(());
28451            }
28452
28453            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28454            // are envelope_size bytes.
28455            let cur_offset: usize = (5 - 1) * envelope_size;
28456
28457            // Zero reserved fields.
28458            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28459
28460            // Safety:
28461            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28462            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28463            //   envelope_size bytes, there is always sufficient room.
28464            fidl::encoding::encode_in_envelope_optional::<
28465                bool,
28466                fidl::encoding::DefaultFuchsiaResourceDialect,
28467            >(
28468                self.allow_single_buffer
28469                    .as_ref()
28470                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
28471                encoder,
28472                offset + cur_offset,
28473                depth,
28474            )?;
28475
28476            _prev_end_offset = cur_offset + envelope_size;
28477
28478            Ok(())
28479        }
28480    }
28481
28482    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
28483        for StreamProcessorParticipateInBufferAllocationRequest
28484    {
28485        #[inline(always)]
28486        fn new_empty() -> Self {
28487            Self::default()
28488        }
28489
28490        unsafe fn decode(
28491            &mut self,
28492            decoder: &mut fidl::encoding::Decoder<
28493                '_,
28494                fidl::encoding::DefaultFuchsiaResourceDialect,
28495            >,
28496            offset: usize,
28497            mut depth: fidl::encoding::Depth,
28498        ) -> fidl::Result<()> {
28499            decoder.debug_check_bounds::<Self>(offset);
28500            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
28501                None => return Err(fidl::Error::NotNullable),
28502                Some(len) => len,
28503            };
28504            // Calling decoder.out_of_line_offset(0) is not allowed.
28505            if len == 0 {
28506                return Ok(());
28507            };
28508            depth.increment()?;
28509            let envelope_size = 8;
28510            let bytes_len = len * envelope_size;
28511            let offset = decoder.out_of_line_offset(bytes_len)?;
28512            // Decode the envelope for each type.
28513            let mut _next_ordinal_to_read = 0;
28514            let mut next_offset = offset;
28515            let end_offset = offset + bytes_len;
28516            _next_ordinal_to_read += 1;
28517            if next_offset >= end_offset {
28518                return Ok(());
28519            }
28520
28521            // Decode unknown envelopes for gaps in ordinals.
28522            while _next_ordinal_to_read < 1 {
28523                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28524                _next_ordinal_to_read += 1;
28525                next_offset += envelope_size;
28526            }
28527
28528            let next_out_of_line = decoder.next_out_of_line();
28529            let handles_before = decoder.remaining_handles();
28530            if let Some((inlined, num_bytes, num_handles)) =
28531                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28532            {
28533                let member_inline_size =
28534                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28535                if inlined != (member_inline_size <= 4) {
28536                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28537                }
28538                let inner_offset;
28539                let mut inner_depth = depth.clone();
28540                if inlined {
28541                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28542                    inner_offset = next_offset;
28543                } else {
28544                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28545                    inner_depth.increment()?;
28546                }
28547                let val_ref = self.port.get_or_insert_with(|| {
28548                    fidl::new_empty!(Port, fidl::encoding::DefaultFuchsiaResourceDialect)
28549                });
28550                fidl::decode!(
28551                    Port,
28552                    fidl::encoding::DefaultFuchsiaResourceDialect,
28553                    val_ref,
28554                    decoder,
28555                    inner_offset,
28556                    inner_depth
28557                )?;
28558                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28559                {
28560                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28561                }
28562                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28563                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28564                }
28565            }
28566
28567            next_offset += envelope_size;
28568            _next_ordinal_to_read += 1;
28569            if next_offset >= end_offset {
28570                return Ok(());
28571            }
28572
28573            // Decode unknown envelopes for gaps in ordinals.
28574            while _next_ordinal_to_read < 2 {
28575                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28576                _next_ordinal_to_read += 1;
28577                next_offset += envelope_size;
28578            }
28579
28580            let next_out_of_line = decoder.next_out_of_line();
28581            let handles_before = decoder.remaining_handles();
28582            if let Some((inlined, num_bytes, num_handles)) =
28583                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28584            {
28585                let member_inline_size =
28586                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28587                if inlined != (member_inline_size <= 4) {
28588                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28589                }
28590                let inner_offset;
28591                let mut inner_depth = depth.clone();
28592                if inlined {
28593                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28594                    inner_offset = next_offset;
28595                } else {
28596                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28597                    inner_depth.increment()?;
28598                }
28599                let val_ref = self.buffer_constraints_version_ordinal.get_or_insert_with(|| {
28600                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28601                });
28602                fidl::decode!(
28603                    u64,
28604                    fidl::encoding::DefaultFuchsiaResourceDialect,
28605                    val_ref,
28606                    decoder,
28607                    inner_offset,
28608                    inner_depth
28609                )?;
28610                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28611                {
28612                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28613                }
28614                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28615                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28616                }
28617            }
28618
28619            next_offset += envelope_size;
28620            _next_ordinal_to_read += 1;
28621            if next_offset >= end_offset {
28622                return Ok(());
28623            }
28624
28625            // Decode unknown envelopes for gaps in ordinals.
28626            while _next_ordinal_to_read < 3 {
28627                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28628                _next_ordinal_to_read += 1;
28629                next_offset += envelope_size;
28630            }
28631
28632            let next_out_of_line = decoder.next_out_of_line();
28633            let handles_before = decoder.remaining_handles();
28634            if let Some((inlined, num_bytes, num_handles)) =
28635                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28636            {
28637                let member_inline_size = <fidl::encoding::Endpoint<
28638                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
28639                > as fidl::encoding::TypeMarker>::inline_size(
28640                    decoder.context
28641                );
28642                if inlined != (member_inline_size <= 4) {
28643                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28644                }
28645                let inner_offset;
28646                let mut inner_depth = depth.clone();
28647                if inlined {
28648                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28649                    inner_offset = next_offset;
28650                } else {
28651                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28652                    inner_depth.increment()?;
28653                }
28654                let val_ref = self.sysmem2_token.get_or_insert_with(|| {
28655                    fidl::new_empty!(
28656                        fidl::encoding::Endpoint<
28657                            fidl::endpoints::ClientEnd<
28658                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
28659                            >,
28660                        >,
28661                        fidl::encoding::DefaultFuchsiaResourceDialect
28662                    )
28663                });
28664                fidl::decode!(
28665                    fidl::encoding::Endpoint<
28666                        fidl::endpoints::ClientEnd<
28667                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
28668                        >,
28669                    >,
28670                    fidl::encoding::DefaultFuchsiaResourceDialect,
28671                    val_ref,
28672                    decoder,
28673                    inner_offset,
28674                    inner_depth
28675                )?;
28676                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28677                {
28678                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28679                }
28680                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28681                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28682                }
28683            }
28684
28685            next_offset += envelope_size;
28686            _next_ordinal_to_read += 1;
28687            if next_offset >= end_offset {
28688                return Ok(());
28689            }
28690
28691            // Decode unknown envelopes for gaps in ordinals.
28692            while _next_ordinal_to_read < 4 {
28693                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28694                _next_ordinal_to_read += 1;
28695                next_offset += envelope_size;
28696            }
28697
28698            let next_out_of_line = decoder.next_out_of_line();
28699            let handles_before = decoder.remaining_handles();
28700            if let Some((inlined, num_bytes, num_handles)) =
28701                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28702            {
28703                let member_inline_size =
28704                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28705                if inlined != (member_inline_size <= 4) {
28706                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28707                }
28708                let inner_offset;
28709                let mut inner_depth = depth.clone();
28710                if inlined {
28711                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28712                    inner_offset = next_offset;
28713                } else {
28714                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28715                    inner_depth.increment()?;
28716                }
28717                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
28718                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
28719                });
28720                fidl::decode!(
28721                    u64,
28722                    fidl::encoding::DefaultFuchsiaResourceDialect,
28723                    val_ref,
28724                    decoder,
28725                    inner_offset,
28726                    inner_depth
28727                )?;
28728                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28729                {
28730                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28731                }
28732                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28733                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28734                }
28735            }
28736
28737            next_offset += envelope_size;
28738            _next_ordinal_to_read += 1;
28739            if next_offset >= end_offset {
28740                return Ok(());
28741            }
28742
28743            // Decode unknown envelopes for gaps in ordinals.
28744            while _next_ordinal_to_read < 5 {
28745                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28746                _next_ordinal_to_read += 1;
28747                next_offset += envelope_size;
28748            }
28749
28750            let next_out_of_line = decoder.next_out_of_line();
28751            let handles_before = decoder.remaining_handles();
28752            if let Some((inlined, num_bytes, num_handles)) =
28753                fidl::encoding::decode_envelope_header(decoder, next_offset)?
28754            {
28755                let member_inline_size =
28756                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
28757                if inlined != (member_inline_size <= 4) {
28758                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
28759                }
28760                let inner_offset;
28761                let mut inner_depth = depth.clone();
28762                if inlined {
28763                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
28764                    inner_offset = next_offset;
28765                } else {
28766                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
28767                    inner_depth.increment()?;
28768                }
28769                let val_ref = self.allow_single_buffer.get_or_insert_with(|| {
28770                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
28771                });
28772                fidl::decode!(
28773                    bool,
28774                    fidl::encoding::DefaultFuchsiaResourceDialect,
28775                    val_ref,
28776                    decoder,
28777                    inner_offset,
28778                    inner_depth
28779                )?;
28780                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
28781                {
28782                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
28783                }
28784                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
28785                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
28786                }
28787            }
28788
28789            next_offset += envelope_size;
28790
28791            // Decode the remaining unknown envelopes.
28792            while next_offset < end_offset {
28793                _next_ordinal_to_read += 1;
28794                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28795                next_offset += envelope_size;
28796            }
28797
28798            Ok(())
28799        }
28800    }
28801
28802    impl StreamProcessorRemoveBufferRequest {
28803        #[inline(always)]
28804        fn max_ordinal_present(&self) -> u64 {
28805            if let Some(_) = self.buffer_index {
28806                return 3;
28807            }
28808            if let Some(_) = self.buffer_lifetime_ordinal {
28809                return 2;
28810            }
28811            if let Some(_) = self.port {
28812                return 1;
28813            }
28814            0
28815        }
28816    }
28817
28818    impl fidl::encoding::ResourceTypeMarker for StreamProcessorRemoveBufferRequest {
28819        type Borrowed<'a> = &'a mut Self;
28820        fn take_or_borrow<'a>(
28821            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
28822        ) -> Self::Borrowed<'a> {
28823            value
28824        }
28825    }
28826
28827    unsafe impl fidl::encoding::TypeMarker for StreamProcessorRemoveBufferRequest {
28828        type Owned = Self;
28829
28830        #[inline(always)]
28831        fn inline_align(_context: fidl::encoding::Context) -> usize {
28832            8
28833        }
28834
28835        #[inline(always)]
28836        fn inline_size(_context: fidl::encoding::Context) -> usize {
28837            16
28838        }
28839    }
28840
28841    unsafe impl
28842        fidl::encoding::Encode<
28843            StreamProcessorRemoveBufferRequest,
28844            fidl::encoding::DefaultFuchsiaResourceDialect,
28845        > for &mut StreamProcessorRemoveBufferRequest
28846    {
28847        unsafe fn encode(
28848            self,
28849            encoder: &mut fidl::encoding::Encoder<
28850                '_,
28851                fidl::encoding::DefaultFuchsiaResourceDialect,
28852            >,
28853            offset: usize,
28854            mut depth: fidl::encoding::Depth,
28855        ) -> fidl::Result<()> {
28856            encoder.debug_check_bounds::<StreamProcessorRemoveBufferRequest>(offset);
28857            // Vector header
28858            let max_ordinal: u64 = self.max_ordinal_present();
28859            encoder.write_num(max_ordinal, offset);
28860            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
28861            // Calling encoder.out_of_line_offset(0) is not allowed.
28862            if max_ordinal == 0 {
28863                return Ok(());
28864            }
28865            depth.increment()?;
28866            let envelope_size = 8;
28867            let bytes_len = max_ordinal as usize * envelope_size;
28868            #[allow(unused_variables)]
28869            let offset = encoder.out_of_line_offset(bytes_len);
28870            let mut _prev_end_offset: usize = 0;
28871            if 1 > max_ordinal {
28872                return Ok(());
28873            }
28874
28875            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28876            // are envelope_size bytes.
28877            let cur_offset: usize = (1 - 1) * envelope_size;
28878
28879            // Zero reserved fields.
28880            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28881
28882            // Safety:
28883            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28884            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28885            //   envelope_size bytes, there is always sufficient room.
28886            fidl::encoding::encode_in_envelope_optional::<
28887                Port,
28888                fidl::encoding::DefaultFuchsiaResourceDialect,
28889            >(
28890                self.port.as_ref().map(<Port as fidl::encoding::ValueTypeMarker>::borrow),
28891                encoder,
28892                offset + cur_offset,
28893                depth,
28894            )?;
28895
28896            _prev_end_offset = cur_offset + envelope_size;
28897            if 2 > max_ordinal {
28898                return Ok(());
28899            }
28900
28901            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28902            // are envelope_size bytes.
28903            let cur_offset: usize = (2 - 1) * envelope_size;
28904
28905            // Zero reserved fields.
28906            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28907
28908            // Safety:
28909            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28910            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28911            //   envelope_size bytes, there is always sufficient room.
28912            fidl::encoding::encode_in_envelope_optional::<
28913                u64,
28914                fidl::encoding::DefaultFuchsiaResourceDialect,
28915            >(
28916                self.buffer_lifetime_ordinal
28917                    .as_ref()
28918                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
28919                encoder,
28920                offset + cur_offset,
28921                depth,
28922            )?;
28923
28924            _prev_end_offset = cur_offset + envelope_size;
28925            if 3 > max_ordinal {
28926                return Ok(());
28927            }
28928
28929            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
28930            // are envelope_size bytes.
28931            let cur_offset: usize = (3 - 1) * envelope_size;
28932
28933            // Zero reserved fields.
28934            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
28935
28936            // Safety:
28937            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
28938            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
28939            //   envelope_size bytes, there is always sufficient room.
28940            fidl::encoding::encode_in_envelope_optional::<
28941                u32,
28942                fidl::encoding::DefaultFuchsiaResourceDialect,
28943            >(
28944                self.buffer_index.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
28945                encoder,
28946                offset + cur_offset,
28947                depth,
28948            )?;
28949
28950            _prev_end_offset = cur_offset + envelope_size;
28951
28952            Ok(())
28953        }
28954    }
28955
28956    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
28957        for StreamProcessorRemoveBufferRequest
28958    {
28959        #[inline(always)]
28960        fn new_empty() -> Self {
28961            Self::default()
28962        }
28963
28964        unsafe fn decode(
28965            &mut self,
28966            decoder: &mut fidl::encoding::Decoder<
28967                '_,
28968                fidl::encoding::DefaultFuchsiaResourceDialect,
28969            >,
28970            offset: usize,
28971            mut depth: fidl::encoding::Depth,
28972        ) -> fidl::Result<()> {
28973            decoder.debug_check_bounds::<Self>(offset);
28974            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
28975                None => return Err(fidl::Error::NotNullable),
28976                Some(len) => len,
28977            };
28978            // Calling decoder.out_of_line_offset(0) is not allowed.
28979            if len == 0 {
28980                return Ok(());
28981            };
28982            depth.increment()?;
28983            let envelope_size = 8;
28984            let bytes_len = len * envelope_size;
28985            let offset = decoder.out_of_line_offset(bytes_len)?;
28986            // Decode the envelope for each type.
28987            let mut _next_ordinal_to_read = 0;
28988            let mut next_offset = offset;
28989            let end_offset = offset + bytes_len;
28990            _next_ordinal_to_read += 1;
28991            if next_offset >= end_offset {
28992                return Ok(());
28993            }
28994
28995            // Decode unknown envelopes for gaps in ordinals.
28996            while _next_ordinal_to_read < 1 {
28997                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
28998                _next_ordinal_to_read += 1;
28999                next_offset += envelope_size;
29000            }
29001
29002            let next_out_of_line = decoder.next_out_of_line();
29003            let handles_before = decoder.remaining_handles();
29004            if let Some((inlined, num_bytes, num_handles)) =
29005                fidl::encoding::decode_envelope_header(decoder, next_offset)?
29006            {
29007                let member_inline_size =
29008                    <Port as fidl::encoding::TypeMarker>::inline_size(decoder.context);
29009                if inlined != (member_inline_size <= 4) {
29010                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
29011                }
29012                let inner_offset;
29013                let mut inner_depth = depth.clone();
29014                if inlined {
29015                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
29016                    inner_offset = next_offset;
29017                } else {
29018                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
29019                    inner_depth.increment()?;
29020                }
29021                let val_ref = self.port.get_or_insert_with(|| {
29022                    fidl::new_empty!(Port, fidl::encoding::DefaultFuchsiaResourceDialect)
29023                });
29024                fidl::decode!(
29025                    Port,
29026                    fidl::encoding::DefaultFuchsiaResourceDialect,
29027                    val_ref,
29028                    decoder,
29029                    inner_offset,
29030                    inner_depth
29031                )?;
29032                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
29033                {
29034                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
29035                }
29036                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
29037                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
29038                }
29039            }
29040
29041            next_offset += envelope_size;
29042            _next_ordinal_to_read += 1;
29043            if next_offset >= end_offset {
29044                return Ok(());
29045            }
29046
29047            // Decode unknown envelopes for gaps in ordinals.
29048            while _next_ordinal_to_read < 2 {
29049                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
29050                _next_ordinal_to_read += 1;
29051                next_offset += envelope_size;
29052            }
29053
29054            let next_out_of_line = decoder.next_out_of_line();
29055            let handles_before = decoder.remaining_handles();
29056            if let Some((inlined, num_bytes, num_handles)) =
29057                fidl::encoding::decode_envelope_header(decoder, next_offset)?
29058            {
29059                let member_inline_size =
29060                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
29061                if inlined != (member_inline_size <= 4) {
29062                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
29063                }
29064                let inner_offset;
29065                let mut inner_depth = depth.clone();
29066                if inlined {
29067                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
29068                    inner_offset = next_offset;
29069                } else {
29070                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
29071                    inner_depth.increment()?;
29072                }
29073                let val_ref = self.buffer_lifetime_ordinal.get_or_insert_with(|| {
29074                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
29075                });
29076                fidl::decode!(
29077                    u64,
29078                    fidl::encoding::DefaultFuchsiaResourceDialect,
29079                    val_ref,
29080                    decoder,
29081                    inner_offset,
29082                    inner_depth
29083                )?;
29084                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
29085                {
29086                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
29087                }
29088                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
29089                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
29090                }
29091            }
29092
29093            next_offset += envelope_size;
29094            _next_ordinal_to_read += 1;
29095            if next_offset >= end_offset {
29096                return Ok(());
29097            }
29098
29099            // Decode unknown envelopes for gaps in ordinals.
29100            while _next_ordinal_to_read < 3 {
29101                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
29102                _next_ordinal_to_read += 1;
29103                next_offset += envelope_size;
29104            }
29105
29106            let next_out_of_line = decoder.next_out_of_line();
29107            let handles_before = decoder.remaining_handles();
29108            if let Some((inlined, num_bytes, num_handles)) =
29109                fidl::encoding::decode_envelope_header(decoder, next_offset)?
29110            {
29111                let member_inline_size =
29112                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
29113                if inlined != (member_inline_size <= 4) {
29114                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
29115                }
29116                let inner_offset;
29117                let mut inner_depth = depth.clone();
29118                if inlined {
29119                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
29120                    inner_offset = next_offset;
29121                } else {
29122                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
29123                    inner_depth.increment()?;
29124                }
29125                let val_ref = self.buffer_index.get_or_insert_with(|| {
29126                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
29127                });
29128                fidl::decode!(
29129                    u32,
29130                    fidl::encoding::DefaultFuchsiaResourceDialect,
29131                    val_ref,
29132                    decoder,
29133                    inner_offset,
29134                    inner_depth
29135                )?;
29136                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
29137                {
29138                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
29139                }
29140                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
29141                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
29142                }
29143            }
29144
29145            next_offset += envelope_size;
29146
29147            // Decode the remaining unknown envelopes.
29148            while next_offset < end_offset {
29149                _next_ordinal_to_read += 1;
29150                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
29151                next_offset += envelope_size;
29152            }
29153
29154            Ok(())
29155        }
29156    }
29157}