Skip to main content

fidl_fuchsia_pkg_rewrite/
fidl_fuchsia_pkg_rewrite.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_pkg_rewrite_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct EditTransactionListDynamicRequest {
16    pub iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for EditTransactionListDynamicRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct EngineListRequest {
26    pub iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for EngineListRequest {}
30
31#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
32pub struct EngineListStaticRequest {
33    pub iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
34}
35
36impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for EngineListStaticRequest {}
37
38#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
39pub struct EngineStartEditTransactionRequest {
40    pub transaction: fidl::endpoints::ServerEnd<EditTransactionMarker>,
41}
42
43impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
44    for EngineStartEditTransactionRequest
45{
46}
47
48#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
49pub struct EditTransactionMarker;
50
51impl fidl::endpoints::ProtocolMarker for EditTransactionMarker {
52    type Proxy = EditTransactionProxy;
53    type RequestStream = EditTransactionRequestStream;
54    #[cfg(target_os = "fuchsia")]
55    type SynchronousProxy = EditTransactionSynchronousProxy;
56
57    const DEBUG_NAME: &'static str = "(anonymous) EditTransaction";
58}
59pub type EditTransactionAddResult = Result<(), i32>;
60pub type EditTransactionCommitResult = Result<(), i32>;
61
62pub trait EditTransactionProxyInterface: Send + Sync {
63    fn r#list_dynamic(
64        &self,
65        iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
66    ) -> Result<(), fidl::Error>;
67    fn r#reset_all(&self) -> Result<(), fidl::Error>;
68    type AddResponseFut: std::future::Future<Output = Result<EditTransactionAddResult, fidl::Error>>
69        + Send;
70    fn r#add(&self, rule: &Rule) -> Self::AddResponseFut;
71    type CommitResponseFut: std::future::Future<Output = Result<EditTransactionCommitResult, fidl::Error>>
72        + Send;
73    fn r#commit(&self) -> Self::CommitResponseFut;
74}
75#[derive(Debug)]
76#[cfg(target_os = "fuchsia")]
77pub struct EditTransactionSynchronousProxy {
78    client: fidl::client::sync::Client,
79}
80
81#[cfg(target_os = "fuchsia")]
82impl fidl::endpoints::SynchronousProxy for EditTransactionSynchronousProxy {
83    type Proxy = EditTransactionProxy;
84    type Protocol = EditTransactionMarker;
85
86    fn from_channel(inner: fidl::Channel) -> Self {
87        Self::new(inner)
88    }
89
90    fn into_channel(self) -> fidl::Channel {
91        self.client.into_channel()
92    }
93
94    fn as_channel(&self) -> &fidl::Channel {
95        self.client.as_channel()
96    }
97}
98
99#[cfg(target_os = "fuchsia")]
100impl EditTransactionSynchronousProxy {
101    pub fn new(channel: fidl::Channel) -> Self {
102        Self { client: fidl::client::sync::Client::new(channel) }
103    }
104
105    pub fn into_channel(self) -> fidl::Channel {
106        self.client.into_channel()
107    }
108
109    /// Waits until an event arrives and returns it. It is safe for other
110    /// threads to make concurrent requests while waiting for an event.
111    pub fn wait_for_event(
112        &self,
113        deadline: zx::MonotonicInstant,
114    ) -> Result<EditTransactionEvent, fidl::Error> {
115        EditTransactionEvent::decode(self.client.wait_for_event::<EditTransactionMarker>(deadline)?)
116    }
117
118    /// Returns an iterator over all dynamic (editable) rewrite rules. The
119    /// iterator will reflect any changes made to the rewrite rules so far in
120    /// this transaction.
121    ///
122    /// + request `iterator` a request for an iterator.
123    pub fn r#list_dynamic(
124        &self,
125        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
126    ) -> Result<(), fidl::Error> {
127        self.client.send::<EditTransactionListDynamicRequest>(
128            (iterator,),
129            0x37862a86b057cb49,
130            fidl::encoding::DynamicFlags::empty(),
131        )
132    }
133
134    /// Removes all dynamically configured rewrite rules, leaving only any
135    /// statically configured rules.
136    pub fn r#reset_all(&self) -> Result<(), fidl::Error> {
137        self.client.send::<fidl::encoding::EmptyPayload>(
138            (),
139            0x41e518acd0864a90,
140            fidl::encoding::DynamicFlags::empty(),
141        )
142    }
143
144    /// Adds a rewrite rule with highest priority. If `rule` already exists, this
145    /// API will prioritize it over other rules.
146    ///
147    /// + request `rule` the rewrite rule to persist.
148    /// * error a zx_status value indicating failure. One of the following:
149    ///     * `ZX_ERR_INVALID_ARGS` if `url` is not a valid `fuchsia-pkg://`
150    ///      URL. See [`fuchsia-pkg URL`].
151    ///
152    /// [`fuchsia-pkg URL`]:
153    ///    https://fuchsia.dev/fuchsia-src/concepts/storage/package_url
154    pub fn r#add(
155        &self,
156        mut rule: &Rule,
157        ___deadline: zx::MonotonicInstant,
158    ) -> Result<EditTransactionAddResult, fidl::Error> {
159        let _response = self.client.send_query::<
160            EditTransactionAddRequest,
161            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
162            EditTransactionMarker,
163        >(
164            (rule,),
165            0x56a2b5fe92ca5db6,
166            fidl::encoding::DynamicFlags::empty(),
167            ___deadline,
168        )?;
169        Ok(_response.map(|x| x))
170    }
171
172    /// Commits this transaction, or detect another transaction that committed
173    /// before this one.
174    ///
175    /// * error a zx_status value indicating failure. One of the following:
176    ///     * `ZX_ERR_UNAVAILABLE` if another transaction committed before this one.
177    ///     * `ZX_ERR_ACCESS_DENIED` if editing dynamic rewrite rules is permanently disabled.
178    pub fn r#commit(
179        &self,
180        ___deadline: zx::MonotonicInstant,
181    ) -> Result<EditTransactionCommitResult, fidl::Error> {
182        let _response = self.client.send_query::<
183            fidl::encoding::EmptyPayload,
184            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
185            EditTransactionMarker,
186        >(
187            (),
188            0x3ca50fc9c13341fb,
189            fidl::encoding::DynamicFlags::empty(),
190            ___deadline,
191        )?;
192        Ok(_response.map(|x| x))
193    }
194}
195
196#[cfg(target_os = "fuchsia")]
197impl From<EditTransactionSynchronousProxy> for zx::NullableHandle {
198    fn from(value: EditTransactionSynchronousProxy) -> Self {
199        value.into_channel().into()
200    }
201}
202
203#[cfg(target_os = "fuchsia")]
204impl From<fidl::Channel> for EditTransactionSynchronousProxy {
205    fn from(value: fidl::Channel) -> Self {
206        Self::new(value)
207    }
208}
209
210#[cfg(target_os = "fuchsia")]
211impl fidl::endpoints::FromClient for EditTransactionSynchronousProxy {
212    type Protocol = EditTransactionMarker;
213
214    fn from_client(value: fidl::endpoints::ClientEnd<EditTransactionMarker>) -> Self {
215        Self::new(value.into_channel())
216    }
217}
218
219#[derive(Debug, Clone)]
220pub struct EditTransactionProxy {
221    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
222}
223
224impl fidl::endpoints::Proxy for EditTransactionProxy {
225    type Protocol = EditTransactionMarker;
226
227    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
228        Self::new(inner)
229    }
230
231    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
232        self.client.into_channel().map_err(|client| Self { client })
233    }
234
235    fn as_channel(&self) -> &::fidl::AsyncChannel {
236        self.client.as_channel()
237    }
238}
239
240impl EditTransactionProxy {
241    /// Create a new Proxy for fuchsia.pkg.rewrite/EditTransaction.
242    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
243        let protocol_name = <EditTransactionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
244        Self { client: fidl::client::Client::new(channel, protocol_name) }
245    }
246
247    /// Get a Stream of events from the remote end of the protocol.
248    ///
249    /// # Panics
250    ///
251    /// Panics if the event stream was already taken.
252    pub fn take_event_stream(&self) -> EditTransactionEventStream {
253        EditTransactionEventStream { event_receiver: self.client.take_event_receiver() }
254    }
255
256    /// Returns an iterator over all dynamic (editable) rewrite rules. The
257    /// iterator will reflect any changes made to the rewrite rules so far in
258    /// this transaction.
259    ///
260    /// + request `iterator` a request for an iterator.
261    pub fn r#list_dynamic(
262        &self,
263        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
264    ) -> Result<(), fidl::Error> {
265        EditTransactionProxyInterface::r#list_dynamic(self, iterator)
266    }
267
268    /// Removes all dynamically configured rewrite rules, leaving only any
269    /// statically configured rules.
270    pub fn r#reset_all(&self) -> Result<(), fidl::Error> {
271        EditTransactionProxyInterface::r#reset_all(self)
272    }
273
274    /// Adds a rewrite rule with highest priority. If `rule` already exists, this
275    /// API will prioritize it over other rules.
276    ///
277    /// + request `rule` the rewrite rule to persist.
278    /// * error a zx_status value indicating failure. One of the following:
279    ///     * `ZX_ERR_INVALID_ARGS` if `url` is not a valid `fuchsia-pkg://`
280    ///      URL. See [`fuchsia-pkg URL`].
281    ///
282    /// [`fuchsia-pkg URL`]:
283    ///    https://fuchsia.dev/fuchsia-src/concepts/storage/package_url
284    pub fn r#add(
285        &self,
286        mut rule: &Rule,
287    ) -> fidl::client::QueryResponseFut<
288        EditTransactionAddResult,
289        fidl::encoding::DefaultFuchsiaResourceDialect,
290    > {
291        EditTransactionProxyInterface::r#add(self, rule)
292    }
293
294    /// Commits this transaction, or detect another transaction that committed
295    /// before this one.
296    ///
297    /// * error a zx_status value indicating failure. One of the following:
298    ///     * `ZX_ERR_UNAVAILABLE` if another transaction committed before this one.
299    ///     * `ZX_ERR_ACCESS_DENIED` if editing dynamic rewrite rules is permanently disabled.
300    pub fn r#commit(
301        &self,
302    ) -> fidl::client::QueryResponseFut<
303        EditTransactionCommitResult,
304        fidl::encoding::DefaultFuchsiaResourceDialect,
305    > {
306        EditTransactionProxyInterface::r#commit(self)
307    }
308}
309
310impl EditTransactionProxyInterface for EditTransactionProxy {
311    fn r#list_dynamic(
312        &self,
313        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
314    ) -> Result<(), fidl::Error> {
315        self.client.send::<EditTransactionListDynamicRequest>(
316            (iterator,),
317            0x37862a86b057cb49,
318            fidl::encoding::DynamicFlags::empty(),
319        )
320    }
321
322    fn r#reset_all(&self) -> Result<(), fidl::Error> {
323        self.client.send::<fidl::encoding::EmptyPayload>(
324            (),
325            0x41e518acd0864a90,
326            fidl::encoding::DynamicFlags::empty(),
327        )
328    }
329
330    type AddResponseFut = fidl::client::QueryResponseFut<
331        EditTransactionAddResult,
332        fidl::encoding::DefaultFuchsiaResourceDialect,
333    >;
334    fn r#add(&self, mut rule: &Rule) -> Self::AddResponseFut {
335        fn _decode(
336            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
337        ) -> Result<EditTransactionAddResult, fidl::Error> {
338            let _response = fidl::client::decode_transaction_body::<
339                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
340                fidl::encoding::DefaultFuchsiaResourceDialect,
341                0x56a2b5fe92ca5db6,
342            >(_buf?)?;
343            Ok(_response.map(|x| x))
344        }
345        self.client.send_query_and_decode::<EditTransactionAddRequest, EditTransactionAddResult>(
346            (rule,),
347            0x56a2b5fe92ca5db6,
348            fidl::encoding::DynamicFlags::empty(),
349            _decode,
350        )
351    }
352
353    type CommitResponseFut = fidl::client::QueryResponseFut<
354        EditTransactionCommitResult,
355        fidl::encoding::DefaultFuchsiaResourceDialect,
356    >;
357    fn r#commit(&self) -> Self::CommitResponseFut {
358        fn _decode(
359            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
360        ) -> Result<EditTransactionCommitResult, fidl::Error> {
361            let _response = fidl::client::decode_transaction_body::<
362                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
363                fidl::encoding::DefaultFuchsiaResourceDialect,
364                0x3ca50fc9c13341fb,
365            >(_buf?)?;
366            Ok(_response.map(|x| x))
367        }
368        self.client
369            .send_query_and_decode::<fidl::encoding::EmptyPayload, EditTransactionCommitResult>(
370                (),
371                0x3ca50fc9c13341fb,
372                fidl::encoding::DynamicFlags::empty(),
373                _decode,
374            )
375    }
376}
377
378pub struct EditTransactionEventStream {
379    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
380}
381
382impl std::marker::Unpin for EditTransactionEventStream {}
383
384impl futures::stream::FusedStream for EditTransactionEventStream {
385    fn is_terminated(&self) -> bool {
386        self.event_receiver.is_terminated()
387    }
388}
389
390impl futures::Stream for EditTransactionEventStream {
391    type Item = Result<EditTransactionEvent, fidl::Error>;
392
393    fn poll_next(
394        mut self: std::pin::Pin<&mut Self>,
395        cx: &mut std::task::Context<'_>,
396    ) -> std::task::Poll<Option<Self::Item>> {
397        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
398            &mut self.event_receiver,
399            cx
400        )?) {
401            Some(buf) => std::task::Poll::Ready(Some(EditTransactionEvent::decode(buf))),
402            None => std::task::Poll::Ready(None),
403        }
404    }
405}
406
407#[derive(Debug)]
408pub enum EditTransactionEvent {}
409
410impl EditTransactionEvent {
411    /// Decodes a message buffer as a [`EditTransactionEvent`].
412    fn decode(
413        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
414    ) -> Result<EditTransactionEvent, fidl::Error> {
415        let (bytes, _handles) = buf.split_mut();
416        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
417        debug_assert_eq!(tx_header.tx_id, 0);
418        match tx_header.ordinal {
419            _ => Err(fidl::Error::UnknownOrdinal {
420                ordinal: tx_header.ordinal,
421                protocol_name:
422                    <EditTransactionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
423            }),
424        }
425    }
426}
427
428/// A Stream of incoming requests for fuchsia.pkg.rewrite/EditTransaction.
429pub struct EditTransactionRequestStream {
430    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
431    is_terminated: bool,
432}
433
434impl std::marker::Unpin for EditTransactionRequestStream {}
435
436impl futures::stream::FusedStream for EditTransactionRequestStream {
437    fn is_terminated(&self) -> bool {
438        self.is_terminated
439    }
440}
441
442impl fidl::endpoints::RequestStream for EditTransactionRequestStream {
443    type Protocol = EditTransactionMarker;
444    type ControlHandle = EditTransactionControlHandle;
445
446    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
447        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
448    }
449
450    fn control_handle(&self) -> Self::ControlHandle {
451        EditTransactionControlHandle { inner: self.inner.clone() }
452    }
453
454    fn into_inner(
455        self,
456    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
457    {
458        (self.inner, self.is_terminated)
459    }
460
461    fn from_inner(
462        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
463        is_terminated: bool,
464    ) -> Self {
465        Self { inner, is_terminated }
466    }
467}
468
469impl futures::Stream for EditTransactionRequestStream {
470    type Item = Result<EditTransactionRequest, fidl::Error>;
471
472    fn poll_next(
473        mut self: std::pin::Pin<&mut Self>,
474        cx: &mut std::task::Context<'_>,
475    ) -> std::task::Poll<Option<Self::Item>> {
476        let this = &mut *self;
477        if this.inner.check_shutdown(cx) {
478            this.is_terminated = true;
479            return std::task::Poll::Ready(None);
480        }
481        if this.is_terminated {
482            panic!("polled EditTransactionRequestStream after completion");
483        }
484        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
485            |bytes, handles| {
486                match this.inner.channel().read_etc(cx, bytes, handles) {
487                    std::task::Poll::Ready(Ok(())) => {}
488                    std::task::Poll::Pending => return std::task::Poll::Pending,
489                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
490                        this.is_terminated = true;
491                        return std::task::Poll::Ready(None);
492                    }
493                    std::task::Poll::Ready(Err(e)) => {
494                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
495                            e.into(),
496                        ))));
497                    }
498                }
499
500                // A message has been received from the channel
501                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
502
503                std::task::Poll::Ready(Some(match header.ordinal {
504                    0x37862a86b057cb49 => {
505                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
506                        let mut req = fidl::new_empty!(
507                            EditTransactionListDynamicRequest,
508                            fidl::encoding::DefaultFuchsiaResourceDialect
509                        );
510                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EditTransactionListDynamicRequest>(&header, _body_bytes, handles, &mut req)?;
511                        let control_handle =
512                            EditTransactionControlHandle { inner: this.inner.clone() };
513                        Ok(EditTransactionRequest::ListDynamic {
514                            iterator: req.iterator,
515
516                            control_handle,
517                        })
518                    }
519                    0x41e518acd0864a90 => {
520                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
521                        let mut req = fidl::new_empty!(
522                            fidl::encoding::EmptyPayload,
523                            fidl::encoding::DefaultFuchsiaResourceDialect
524                        );
525                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
526                        let control_handle =
527                            EditTransactionControlHandle { inner: this.inner.clone() };
528                        Ok(EditTransactionRequest::ResetAll { control_handle })
529                    }
530                    0x56a2b5fe92ca5db6 => {
531                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
532                        let mut req = fidl::new_empty!(
533                            EditTransactionAddRequest,
534                            fidl::encoding::DefaultFuchsiaResourceDialect
535                        );
536                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EditTransactionAddRequest>(&header, _body_bytes, handles, &mut req)?;
537                        let control_handle =
538                            EditTransactionControlHandle { inner: this.inner.clone() };
539                        Ok(EditTransactionRequest::Add {
540                            rule: req.rule,
541
542                            responder: EditTransactionAddResponder {
543                                control_handle: std::mem::ManuallyDrop::new(control_handle),
544                                tx_id: header.tx_id,
545                            },
546                        })
547                    }
548                    0x3ca50fc9c13341fb => {
549                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
550                        let mut req = fidl::new_empty!(
551                            fidl::encoding::EmptyPayload,
552                            fidl::encoding::DefaultFuchsiaResourceDialect
553                        );
554                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
555                        let control_handle =
556                            EditTransactionControlHandle { inner: this.inner.clone() };
557                        Ok(EditTransactionRequest::Commit {
558                            responder: EditTransactionCommitResponder {
559                                control_handle: std::mem::ManuallyDrop::new(control_handle),
560                                tx_id: header.tx_id,
561                            },
562                        })
563                    }
564                    _ => Err(fidl::Error::UnknownOrdinal {
565                        ordinal: header.ordinal,
566                        protocol_name:
567                            <EditTransactionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
568                    }),
569                }))
570            },
571        )
572    }
573}
574
575/// A unit of editing for rewrite rules.
576#[derive(Debug)]
577pub enum EditTransactionRequest {
578    /// Returns an iterator over all dynamic (editable) rewrite rules. The
579    /// iterator will reflect any changes made to the rewrite rules so far in
580    /// this transaction.
581    ///
582    /// + request `iterator` a request for an iterator.
583    ListDynamic {
584        iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
585        control_handle: EditTransactionControlHandle,
586    },
587    /// Removes all dynamically configured rewrite rules, leaving only any
588    /// statically configured rules.
589    ResetAll { control_handle: EditTransactionControlHandle },
590    /// Adds a rewrite rule with highest priority. If `rule` already exists, this
591    /// API will prioritize it over other rules.
592    ///
593    /// + request `rule` the rewrite rule to persist.
594    /// * error a zx_status value indicating failure. One of the following:
595    ///     * `ZX_ERR_INVALID_ARGS` if `url` is not a valid `fuchsia-pkg://`
596    ///      URL. See [`fuchsia-pkg URL`].
597    ///
598    /// [`fuchsia-pkg URL`]:
599    ///    https://fuchsia.dev/fuchsia-src/concepts/storage/package_url
600    Add { rule: Rule, responder: EditTransactionAddResponder },
601    /// Commits this transaction, or detect another transaction that committed
602    /// before this one.
603    ///
604    /// * error a zx_status value indicating failure. One of the following:
605    ///     * `ZX_ERR_UNAVAILABLE` if another transaction committed before this one.
606    ///     * `ZX_ERR_ACCESS_DENIED` if editing dynamic rewrite rules is permanently disabled.
607    Commit { responder: EditTransactionCommitResponder },
608}
609
610impl EditTransactionRequest {
611    #[allow(irrefutable_let_patterns)]
612    pub fn into_list_dynamic(
613        self,
614    ) -> Option<(fidl::endpoints::ServerEnd<RuleIteratorMarker>, EditTransactionControlHandle)>
615    {
616        if let EditTransactionRequest::ListDynamic { iterator, control_handle } = self {
617            Some((iterator, control_handle))
618        } else {
619            None
620        }
621    }
622
623    #[allow(irrefutable_let_patterns)]
624    pub fn into_reset_all(self) -> Option<(EditTransactionControlHandle)> {
625        if let EditTransactionRequest::ResetAll { control_handle } = self {
626            Some((control_handle))
627        } else {
628            None
629        }
630    }
631
632    #[allow(irrefutable_let_patterns)]
633    pub fn into_add(self) -> Option<(Rule, EditTransactionAddResponder)> {
634        if let EditTransactionRequest::Add { rule, responder } = self {
635            Some((rule, responder))
636        } else {
637            None
638        }
639    }
640
641    #[allow(irrefutable_let_patterns)]
642    pub fn into_commit(self) -> Option<(EditTransactionCommitResponder)> {
643        if let EditTransactionRequest::Commit { responder } = self {
644            Some((responder))
645        } else {
646            None
647        }
648    }
649
650    /// Name of the method defined in FIDL
651    pub fn method_name(&self) -> &'static str {
652        match *self {
653            EditTransactionRequest::ListDynamic { .. } => "list_dynamic",
654            EditTransactionRequest::ResetAll { .. } => "reset_all",
655            EditTransactionRequest::Add { .. } => "add",
656            EditTransactionRequest::Commit { .. } => "commit",
657        }
658    }
659}
660
661#[derive(Debug, Clone)]
662pub struct EditTransactionControlHandle {
663    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
664}
665
666impl EditTransactionControlHandle {
667    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
668        self.inner.shutdown_with_epitaph(status.into())
669    }
670}
671
672impl fidl::endpoints::ControlHandle for EditTransactionControlHandle {
673    fn shutdown(&self) {
674        self.inner.shutdown()
675    }
676
677    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
678        self.inner.shutdown_with_epitaph(status)
679    }
680
681    fn is_closed(&self) -> bool {
682        self.inner.channel().is_closed()
683    }
684    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
685        self.inner.channel().on_closed()
686    }
687
688    #[cfg(target_os = "fuchsia")]
689    fn signal_peer(
690        &self,
691        clear_mask: zx::Signals,
692        set_mask: zx::Signals,
693    ) -> Result<(), zx_status::Status> {
694        use fidl::Peered;
695        self.inner.channel().signal_peer(clear_mask, set_mask)
696    }
697}
698
699impl EditTransactionControlHandle {}
700
701#[must_use = "FIDL methods require a response to be sent"]
702#[derive(Debug)]
703pub struct EditTransactionAddResponder {
704    control_handle: std::mem::ManuallyDrop<EditTransactionControlHandle>,
705    tx_id: u32,
706}
707
708/// Set the the channel to be shutdown (see [`EditTransactionControlHandle::shutdown`])
709/// if the responder is dropped without sending a response, so that the client
710/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
711impl std::ops::Drop for EditTransactionAddResponder {
712    fn drop(&mut self) {
713        self.control_handle.shutdown();
714        // Safety: drops once, never accessed again
715        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
716    }
717}
718
719impl fidl::endpoints::Responder for EditTransactionAddResponder {
720    type ControlHandle = EditTransactionControlHandle;
721
722    fn control_handle(&self) -> &EditTransactionControlHandle {
723        &self.control_handle
724    }
725
726    fn drop_without_shutdown(mut self) {
727        // Safety: drops once, never accessed again due to mem::forget
728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
729        // Prevent Drop from running (which would shut down the channel)
730        std::mem::forget(self);
731    }
732}
733
734impl EditTransactionAddResponder {
735    /// Sends a response to the FIDL transaction.
736    ///
737    /// Sets the channel to shutdown if an error occurs.
738    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
739        let _result = self.send_raw(result);
740        if _result.is_err() {
741            self.control_handle.shutdown();
742        }
743        self.drop_without_shutdown();
744        _result
745    }
746
747    /// Similar to "send" but does not shutdown the channel if an error occurs.
748    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
749        let _result = self.send_raw(result);
750        self.drop_without_shutdown();
751        _result
752    }
753
754    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
755        self.control_handle
756            .inner
757            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
758                result,
759                self.tx_id,
760                0x56a2b5fe92ca5db6,
761                fidl::encoding::DynamicFlags::empty(),
762            )
763    }
764}
765
766#[must_use = "FIDL methods require a response to be sent"]
767#[derive(Debug)]
768pub struct EditTransactionCommitResponder {
769    control_handle: std::mem::ManuallyDrop<EditTransactionControlHandle>,
770    tx_id: u32,
771}
772
773/// Set the the channel to be shutdown (see [`EditTransactionControlHandle::shutdown`])
774/// if the responder is dropped without sending a response, so that the client
775/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
776impl std::ops::Drop for EditTransactionCommitResponder {
777    fn drop(&mut self) {
778        self.control_handle.shutdown();
779        // Safety: drops once, never accessed again
780        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
781    }
782}
783
784impl fidl::endpoints::Responder for EditTransactionCommitResponder {
785    type ControlHandle = EditTransactionControlHandle;
786
787    fn control_handle(&self) -> &EditTransactionControlHandle {
788        &self.control_handle
789    }
790
791    fn drop_without_shutdown(mut self) {
792        // Safety: drops once, never accessed again due to mem::forget
793        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
794        // Prevent Drop from running (which would shut down the channel)
795        std::mem::forget(self);
796    }
797}
798
799impl EditTransactionCommitResponder {
800    /// Sends a response to the FIDL transaction.
801    ///
802    /// Sets the channel to shutdown if an error occurs.
803    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
804        let _result = self.send_raw(result);
805        if _result.is_err() {
806            self.control_handle.shutdown();
807        }
808        self.drop_without_shutdown();
809        _result
810    }
811
812    /// Similar to "send" but does not shutdown the channel if an error occurs.
813    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
814        let _result = self.send_raw(result);
815        self.drop_without_shutdown();
816        _result
817    }
818
819    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
820        self.control_handle
821            .inner
822            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
823                result,
824                self.tx_id,
825                0x3ca50fc9c13341fb,
826                fidl::encoding::DynamicFlags::empty(),
827            )
828    }
829}
830
831#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
832pub struct EngineMarker;
833
834impl fidl::endpoints::ProtocolMarker for EngineMarker {
835    type Proxy = EngineProxy;
836    type RequestStream = EngineRequestStream;
837    #[cfg(target_os = "fuchsia")]
838    type SynchronousProxy = EngineSynchronousProxy;
839
840    const DEBUG_NAME: &'static str = "fuchsia.pkg.rewrite.Engine";
841}
842impl fidl::endpoints::DiscoverableProtocolMarker for EngineMarker {}
843pub type EngineTestApplyResult = Result<String, i32>;
844
845pub trait EngineProxyInterface: Send + Sync {
846    fn r#start_edit_transaction(
847        &self,
848        transaction: fidl::endpoints::ServerEnd<EditTransactionMarker>,
849    ) -> Result<(), fidl::Error>;
850    fn r#list(
851        &self,
852        iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
853    ) -> Result<(), fidl::Error>;
854    fn r#list_static(
855        &self,
856        iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
857    ) -> Result<(), fidl::Error>;
858    type TestApplyResponseFut: std::future::Future<Output = Result<EngineTestApplyResult, fidl::Error>>
859        + Send;
860    fn r#test_apply(&self, url: &str) -> Self::TestApplyResponseFut;
861}
862#[derive(Debug)]
863#[cfg(target_os = "fuchsia")]
864pub struct EngineSynchronousProxy {
865    client: fidl::client::sync::Client,
866}
867
868#[cfg(target_os = "fuchsia")]
869impl fidl::endpoints::SynchronousProxy for EngineSynchronousProxy {
870    type Proxy = EngineProxy;
871    type Protocol = EngineMarker;
872
873    fn from_channel(inner: fidl::Channel) -> Self {
874        Self::new(inner)
875    }
876
877    fn into_channel(self) -> fidl::Channel {
878        self.client.into_channel()
879    }
880
881    fn as_channel(&self) -> &fidl::Channel {
882        self.client.as_channel()
883    }
884}
885
886#[cfg(target_os = "fuchsia")]
887impl EngineSynchronousProxy {
888    pub fn new(channel: fidl::Channel) -> Self {
889        Self { client: fidl::client::sync::Client::new(channel) }
890    }
891
892    pub fn into_channel(self) -> fidl::Channel {
893        self.client.into_channel()
894    }
895
896    /// Waits until an event arrives and returns it. It is safe for other
897    /// threads to make concurrent requests while waiting for an event.
898    pub fn wait_for_event(
899        &self,
900        deadline: zx::MonotonicInstant,
901    ) -> Result<EngineEvent, fidl::Error> {
902        EngineEvent::decode(self.client.wait_for_event::<EngineMarker>(deadline)?)
903    }
904
905    /// Begins a rule edit transaction.
906    ///
907    /// + request `transaction` a request for an [`EditTransaction`].
908    pub fn r#start_edit_transaction(
909        &self,
910        mut transaction: fidl::endpoints::ServerEnd<EditTransactionMarker>,
911    ) -> Result<(), fidl::Error> {
912        self.client.send::<EngineStartEditTransactionRequest>(
913            (transaction,),
914            0x6f649b7dbbc904fb,
915            fidl::encoding::DynamicFlags::empty(),
916        )
917    }
918
919    /// Returns an iterator over all rewrite rules.
920    ///
921    /// + request `iterator` a request for an iterator.
922    pub fn r#list(
923        &self,
924        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
925    ) -> Result<(), fidl::Error> {
926        self.client.send::<EngineListRequest>(
927            (iterator,),
928            0xccbc8b5cb10ad14,
929            fidl::encoding::DynamicFlags::empty(),
930        )
931    }
932
933    /// Returns an iterator over all static (immutable) rewrite rules. These
934    /// rules are handled as lower priority than dynamic rules and cannot be
935    /// modified (although they can be overridden) by [`EditTransaction`]s.
936    ///
937    /// + request `iterator` a request for an iterator.
938    pub fn r#list_static(
939        &self,
940        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
941    ) -> Result<(), fidl::Error> {
942        self.client.send::<EngineListStaticRequest>(
943            (iterator,),
944            0x5416f92d0bac1b30,
945            fidl::encoding::DynamicFlags::empty(),
946        )
947    }
948
949    /// Rewrites the given `url` with the current rewrite rule set, returning the
950    /// `rewritten` url.  If no rules match or a rule matches but performs an
951    /// identity transformation, this API returns `url` unchanged.
952    ///
953    /// This API is intended only for reflecting on rule side effects. Using
954    /// this API to pre-apply the rules, then passing the result to
955    /// [`fuchsia.pkg/PackageResolver.Resolve`] would apply the rules twice.
956    ///
957    /// + request `url` the url to rewrite.
958    /// - response `rewritten` the rewritten url.
959    /// * error a zx_status value indicating failure. One of the following:
960    ///     * `ZX_ERR_INVALID_ARGS` if `url` is not a valid `fuchsia-pkg://`
961    ///       URL. See [`fuchsia-pkg URL`].
962    ///
963    /// [`fuchsia-pkg URL`]:
964    ///    https://fuchsia.dev/fuchsia-src/concepts/storage/package_url
965    pub fn r#test_apply(
966        &self,
967        mut url: &str,
968        ___deadline: zx::MonotonicInstant,
969    ) -> Result<EngineTestApplyResult, fidl::Error> {
970        let _response = self.client.send_query::<
971            EngineTestApplyRequest,
972            fidl::encoding::ResultType<EngineTestApplyResponse, i32>,
973            EngineMarker,
974        >(
975            (url,),
976            0xc8826a2b36fca39,
977            fidl::encoding::DynamicFlags::empty(),
978            ___deadline,
979        )?;
980        Ok(_response.map(|x| x.rewritten))
981    }
982}
983
984#[cfg(target_os = "fuchsia")]
985impl From<EngineSynchronousProxy> for zx::NullableHandle {
986    fn from(value: EngineSynchronousProxy) -> Self {
987        value.into_channel().into()
988    }
989}
990
991#[cfg(target_os = "fuchsia")]
992impl From<fidl::Channel> for EngineSynchronousProxy {
993    fn from(value: fidl::Channel) -> Self {
994        Self::new(value)
995    }
996}
997
998#[cfg(target_os = "fuchsia")]
999impl fidl::endpoints::FromClient for EngineSynchronousProxy {
1000    type Protocol = EngineMarker;
1001
1002    fn from_client(value: fidl::endpoints::ClientEnd<EngineMarker>) -> Self {
1003        Self::new(value.into_channel())
1004    }
1005}
1006
1007#[derive(Debug, Clone)]
1008pub struct EngineProxy {
1009    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1010}
1011
1012impl fidl::endpoints::Proxy for EngineProxy {
1013    type Protocol = EngineMarker;
1014
1015    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1016        Self::new(inner)
1017    }
1018
1019    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1020        self.client.into_channel().map_err(|client| Self { client })
1021    }
1022
1023    fn as_channel(&self) -> &::fidl::AsyncChannel {
1024        self.client.as_channel()
1025    }
1026}
1027
1028impl EngineProxy {
1029    /// Create a new Proxy for fuchsia.pkg.rewrite/Engine.
1030    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1031        let protocol_name = <EngineMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1032        Self { client: fidl::client::Client::new(channel, protocol_name) }
1033    }
1034
1035    /// Get a Stream of events from the remote end of the protocol.
1036    ///
1037    /// # Panics
1038    ///
1039    /// Panics if the event stream was already taken.
1040    pub fn take_event_stream(&self) -> EngineEventStream {
1041        EngineEventStream { event_receiver: self.client.take_event_receiver() }
1042    }
1043
1044    /// Begins a rule edit transaction.
1045    ///
1046    /// + request `transaction` a request for an [`EditTransaction`].
1047    pub fn r#start_edit_transaction(
1048        &self,
1049        mut transaction: fidl::endpoints::ServerEnd<EditTransactionMarker>,
1050    ) -> Result<(), fidl::Error> {
1051        EngineProxyInterface::r#start_edit_transaction(self, transaction)
1052    }
1053
1054    /// Returns an iterator over all rewrite rules.
1055    ///
1056    /// + request `iterator` a request for an iterator.
1057    pub fn r#list(
1058        &self,
1059        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
1060    ) -> Result<(), fidl::Error> {
1061        EngineProxyInterface::r#list(self, iterator)
1062    }
1063
1064    /// Returns an iterator over all static (immutable) rewrite rules. These
1065    /// rules are handled as lower priority than dynamic rules and cannot be
1066    /// modified (although they can be overridden) by [`EditTransaction`]s.
1067    ///
1068    /// + request `iterator` a request for an iterator.
1069    pub fn r#list_static(
1070        &self,
1071        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
1072    ) -> Result<(), fidl::Error> {
1073        EngineProxyInterface::r#list_static(self, iterator)
1074    }
1075
1076    /// Rewrites the given `url` with the current rewrite rule set, returning the
1077    /// `rewritten` url.  If no rules match or a rule matches but performs an
1078    /// identity transformation, this API returns `url` unchanged.
1079    ///
1080    /// This API is intended only for reflecting on rule side effects. Using
1081    /// this API to pre-apply the rules, then passing the result to
1082    /// [`fuchsia.pkg/PackageResolver.Resolve`] would apply the rules twice.
1083    ///
1084    /// + request `url` the url to rewrite.
1085    /// - response `rewritten` the rewritten url.
1086    /// * error a zx_status value indicating failure. One of the following:
1087    ///     * `ZX_ERR_INVALID_ARGS` if `url` is not a valid `fuchsia-pkg://`
1088    ///       URL. See [`fuchsia-pkg URL`].
1089    ///
1090    /// [`fuchsia-pkg URL`]:
1091    ///    https://fuchsia.dev/fuchsia-src/concepts/storage/package_url
1092    pub fn r#test_apply(
1093        &self,
1094        mut url: &str,
1095    ) -> fidl::client::QueryResponseFut<
1096        EngineTestApplyResult,
1097        fidl::encoding::DefaultFuchsiaResourceDialect,
1098    > {
1099        EngineProxyInterface::r#test_apply(self, url)
1100    }
1101}
1102
1103impl EngineProxyInterface for EngineProxy {
1104    fn r#start_edit_transaction(
1105        &self,
1106        mut transaction: fidl::endpoints::ServerEnd<EditTransactionMarker>,
1107    ) -> Result<(), fidl::Error> {
1108        self.client.send::<EngineStartEditTransactionRequest>(
1109            (transaction,),
1110            0x6f649b7dbbc904fb,
1111            fidl::encoding::DynamicFlags::empty(),
1112        )
1113    }
1114
1115    fn r#list(
1116        &self,
1117        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
1118    ) -> Result<(), fidl::Error> {
1119        self.client.send::<EngineListRequest>(
1120            (iterator,),
1121            0xccbc8b5cb10ad14,
1122            fidl::encoding::DynamicFlags::empty(),
1123        )
1124    }
1125
1126    fn r#list_static(
1127        &self,
1128        mut iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
1129    ) -> Result<(), fidl::Error> {
1130        self.client.send::<EngineListStaticRequest>(
1131            (iterator,),
1132            0x5416f92d0bac1b30,
1133            fidl::encoding::DynamicFlags::empty(),
1134        )
1135    }
1136
1137    type TestApplyResponseFut = fidl::client::QueryResponseFut<
1138        EngineTestApplyResult,
1139        fidl::encoding::DefaultFuchsiaResourceDialect,
1140    >;
1141    fn r#test_apply(&self, mut url: &str) -> Self::TestApplyResponseFut {
1142        fn _decode(
1143            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1144        ) -> Result<EngineTestApplyResult, fidl::Error> {
1145            let _response = fidl::client::decode_transaction_body::<
1146                fidl::encoding::ResultType<EngineTestApplyResponse, i32>,
1147                fidl::encoding::DefaultFuchsiaResourceDialect,
1148                0xc8826a2b36fca39,
1149            >(_buf?)?;
1150            Ok(_response.map(|x| x.rewritten))
1151        }
1152        self.client.send_query_and_decode::<EngineTestApplyRequest, EngineTestApplyResult>(
1153            (url,),
1154            0xc8826a2b36fca39,
1155            fidl::encoding::DynamicFlags::empty(),
1156            _decode,
1157        )
1158    }
1159}
1160
1161pub struct EngineEventStream {
1162    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1163}
1164
1165impl std::marker::Unpin for EngineEventStream {}
1166
1167impl futures::stream::FusedStream for EngineEventStream {
1168    fn is_terminated(&self) -> bool {
1169        self.event_receiver.is_terminated()
1170    }
1171}
1172
1173impl futures::Stream for EngineEventStream {
1174    type Item = Result<EngineEvent, fidl::Error>;
1175
1176    fn poll_next(
1177        mut self: std::pin::Pin<&mut Self>,
1178        cx: &mut std::task::Context<'_>,
1179    ) -> std::task::Poll<Option<Self::Item>> {
1180        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1181            &mut self.event_receiver,
1182            cx
1183        )?) {
1184            Some(buf) => std::task::Poll::Ready(Some(EngineEvent::decode(buf))),
1185            None => std::task::Poll::Ready(None),
1186        }
1187    }
1188}
1189
1190#[derive(Debug)]
1191pub enum EngineEvent {}
1192
1193impl EngineEvent {
1194    /// Decodes a message buffer as a [`EngineEvent`].
1195    fn decode(
1196        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1197    ) -> Result<EngineEvent, fidl::Error> {
1198        let (bytes, _handles) = buf.split_mut();
1199        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1200        debug_assert_eq!(tx_header.tx_id, 0);
1201        match tx_header.ordinal {
1202            _ => Err(fidl::Error::UnknownOrdinal {
1203                ordinal: tx_header.ordinal,
1204                protocol_name: <EngineMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1205            }),
1206        }
1207    }
1208}
1209
1210/// A Stream of incoming requests for fuchsia.pkg.rewrite/Engine.
1211pub struct EngineRequestStream {
1212    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1213    is_terminated: bool,
1214}
1215
1216impl std::marker::Unpin for EngineRequestStream {}
1217
1218impl futures::stream::FusedStream for EngineRequestStream {
1219    fn is_terminated(&self) -> bool {
1220        self.is_terminated
1221    }
1222}
1223
1224impl fidl::endpoints::RequestStream for EngineRequestStream {
1225    type Protocol = EngineMarker;
1226    type ControlHandle = EngineControlHandle;
1227
1228    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1229        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1230    }
1231
1232    fn control_handle(&self) -> Self::ControlHandle {
1233        EngineControlHandle { inner: self.inner.clone() }
1234    }
1235
1236    fn into_inner(
1237        self,
1238    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1239    {
1240        (self.inner, self.is_terminated)
1241    }
1242
1243    fn from_inner(
1244        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1245        is_terminated: bool,
1246    ) -> Self {
1247        Self { inner, is_terminated }
1248    }
1249}
1250
1251impl futures::Stream for EngineRequestStream {
1252    type Item = Result<EngineRequest, fidl::Error>;
1253
1254    fn poll_next(
1255        mut self: std::pin::Pin<&mut Self>,
1256        cx: &mut std::task::Context<'_>,
1257    ) -> std::task::Poll<Option<Self::Item>> {
1258        let this = &mut *self;
1259        if this.inner.check_shutdown(cx) {
1260            this.is_terminated = true;
1261            return std::task::Poll::Ready(None);
1262        }
1263        if this.is_terminated {
1264            panic!("polled EngineRequestStream after completion");
1265        }
1266        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1267            |bytes, handles| {
1268                match this.inner.channel().read_etc(cx, bytes, handles) {
1269                    std::task::Poll::Ready(Ok(())) => {}
1270                    std::task::Poll::Pending => return std::task::Poll::Pending,
1271                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1272                        this.is_terminated = true;
1273                        return std::task::Poll::Ready(None);
1274                    }
1275                    std::task::Poll::Ready(Err(e)) => {
1276                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1277                            e.into(),
1278                        ))));
1279                    }
1280                }
1281
1282                // A message has been received from the channel
1283                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1284
1285                std::task::Poll::Ready(Some(match header.ordinal {
1286                    0x6f649b7dbbc904fb => {
1287                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1288                        let mut req = fidl::new_empty!(
1289                            EngineStartEditTransactionRequest,
1290                            fidl::encoding::DefaultFuchsiaResourceDialect
1291                        );
1292                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EngineStartEditTransactionRequest>(&header, _body_bytes, handles, &mut req)?;
1293                        let control_handle = EngineControlHandle { inner: this.inner.clone() };
1294                        Ok(EngineRequest::StartEditTransaction {
1295                            transaction: req.transaction,
1296
1297                            control_handle,
1298                        })
1299                    }
1300                    0xccbc8b5cb10ad14 => {
1301                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1302                        let mut req = fidl::new_empty!(
1303                            EngineListRequest,
1304                            fidl::encoding::DefaultFuchsiaResourceDialect
1305                        );
1306                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EngineListRequest>(&header, _body_bytes, handles, &mut req)?;
1307                        let control_handle = EngineControlHandle { inner: this.inner.clone() };
1308                        Ok(EngineRequest::List { iterator: req.iterator, control_handle })
1309                    }
1310                    0x5416f92d0bac1b30 => {
1311                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1312                        let mut req = fidl::new_empty!(
1313                            EngineListStaticRequest,
1314                            fidl::encoding::DefaultFuchsiaResourceDialect
1315                        );
1316                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EngineListStaticRequest>(&header, _body_bytes, handles, &mut req)?;
1317                        let control_handle = EngineControlHandle { inner: this.inner.clone() };
1318                        Ok(EngineRequest::ListStatic { iterator: req.iterator, control_handle })
1319                    }
1320                    0xc8826a2b36fca39 => {
1321                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1322                        let mut req = fidl::new_empty!(
1323                            EngineTestApplyRequest,
1324                            fidl::encoding::DefaultFuchsiaResourceDialect
1325                        );
1326                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EngineTestApplyRequest>(&header, _body_bytes, handles, &mut req)?;
1327                        let control_handle = EngineControlHandle { inner: this.inner.clone() };
1328                        Ok(EngineRequest::TestApply {
1329                            url: req.url,
1330
1331                            responder: EngineTestApplyResponder {
1332                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1333                                tx_id: header.tx_id,
1334                            },
1335                        })
1336                    }
1337                    _ => Err(fidl::Error::UnknownOrdinal {
1338                        ordinal: header.ordinal,
1339                        protocol_name:
1340                            <EngineMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1341                    }),
1342                }))
1343            },
1344        )
1345    }
1346}
1347
1348/// This manages fuchsia-pkg:// rewrite rules.
1349///
1350/// When a package resolver is asked to resolve a fuchsia-pkg URL, it must first
1351/// iterate through its sequence of rewrite rules (given by [`List`]). The
1352/// rewrite engine will rewrite the given URL with the first rule that:
1353/// * matches the given URL
1354/// * produces a valid URL when applied to the given URL
1355///
1356/// If no rules match, the URL is resolved as-is.
1357///
1358/// This is intended to be implemented by package resolver components,
1359/// and used by repository administration tools.
1360#[derive(Debug)]
1361pub enum EngineRequest {
1362    /// Begins a rule edit transaction.
1363    ///
1364    /// + request `transaction` a request for an [`EditTransaction`].
1365    StartEditTransaction {
1366        transaction: fidl::endpoints::ServerEnd<EditTransactionMarker>,
1367        control_handle: EngineControlHandle,
1368    },
1369    /// Returns an iterator over all rewrite rules.
1370    ///
1371    /// + request `iterator` a request for an iterator.
1372    List {
1373        iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
1374        control_handle: EngineControlHandle,
1375    },
1376    /// Returns an iterator over all static (immutable) rewrite rules. These
1377    /// rules are handled as lower priority than dynamic rules and cannot be
1378    /// modified (although they can be overridden) by [`EditTransaction`]s.
1379    ///
1380    /// + request `iterator` a request for an iterator.
1381    ListStatic {
1382        iterator: fidl::endpoints::ServerEnd<RuleIteratorMarker>,
1383        control_handle: EngineControlHandle,
1384    },
1385    /// Rewrites the given `url` with the current rewrite rule set, returning the
1386    /// `rewritten` url.  If no rules match or a rule matches but performs an
1387    /// identity transformation, this API returns `url` unchanged.
1388    ///
1389    /// This API is intended only for reflecting on rule side effects. Using
1390    /// this API to pre-apply the rules, then passing the result to
1391    /// [`fuchsia.pkg/PackageResolver.Resolve`] would apply the rules twice.
1392    ///
1393    /// + request `url` the url to rewrite.
1394    /// - response `rewritten` the rewritten url.
1395    /// * error a zx_status value indicating failure. One of the following:
1396    ///     * `ZX_ERR_INVALID_ARGS` if `url` is not a valid `fuchsia-pkg://`
1397    ///       URL. See [`fuchsia-pkg URL`].
1398    ///
1399    /// [`fuchsia-pkg URL`]:
1400    ///    https://fuchsia.dev/fuchsia-src/concepts/storage/package_url
1401    TestApply { url: String, responder: EngineTestApplyResponder },
1402}
1403
1404impl EngineRequest {
1405    #[allow(irrefutable_let_patterns)]
1406    pub fn into_start_edit_transaction(
1407        self,
1408    ) -> Option<(fidl::endpoints::ServerEnd<EditTransactionMarker>, EngineControlHandle)> {
1409        if let EngineRequest::StartEditTransaction { transaction, control_handle } = self {
1410            Some((transaction, control_handle))
1411        } else {
1412            None
1413        }
1414    }
1415
1416    #[allow(irrefutable_let_patterns)]
1417    pub fn into_list(
1418        self,
1419    ) -> Option<(fidl::endpoints::ServerEnd<RuleIteratorMarker>, EngineControlHandle)> {
1420        if let EngineRequest::List { iterator, control_handle } = self {
1421            Some((iterator, control_handle))
1422        } else {
1423            None
1424        }
1425    }
1426
1427    #[allow(irrefutable_let_patterns)]
1428    pub fn into_list_static(
1429        self,
1430    ) -> Option<(fidl::endpoints::ServerEnd<RuleIteratorMarker>, EngineControlHandle)> {
1431        if let EngineRequest::ListStatic { iterator, control_handle } = self {
1432            Some((iterator, control_handle))
1433        } else {
1434            None
1435        }
1436    }
1437
1438    #[allow(irrefutable_let_patterns)]
1439    pub fn into_test_apply(self) -> Option<(String, EngineTestApplyResponder)> {
1440        if let EngineRequest::TestApply { url, responder } = self {
1441            Some((url, responder))
1442        } else {
1443            None
1444        }
1445    }
1446
1447    /// Name of the method defined in FIDL
1448    pub fn method_name(&self) -> &'static str {
1449        match *self {
1450            EngineRequest::StartEditTransaction { .. } => "start_edit_transaction",
1451            EngineRequest::List { .. } => "list",
1452            EngineRequest::ListStatic { .. } => "list_static",
1453            EngineRequest::TestApply { .. } => "test_apply",
1454        }
1455    }
1456}
1457
1458#[derive(Debug, Clone)]
1459pub struct EngineControlHandle {
1460    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1461}
1462
1463impl EngineControlHandle {
1464    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1465        self.inner.shutdown_with_epitaph(status.into())
1466    }
1467}
1468
1469impl fidl::endpoints::ControlHandle for EngineControlHandle {
1470    fn shutdown(&self) {
1471        self.inner.shutdown()
1472    }
1473
1474    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1475        self.inner.shutdown_with_epitaph(status)
1476    }
1477
1478    fn is_closed(&self) -> bool {
1479        self.inner.channel().is_closed()
1480    }
1481    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1482        self.inner.channel().on_closed()
1483    }
1484
1485    #[cfg(target_os = "fuchsia")]
1486    fn signal_peer(
1487        &self,
1488        clear_mask: zx::Signals,
1489        set_mask: zx::Signals,
1490    ) -> Result<(), zx_status::Status> {
1491        use fidl::Peered;
1492        self.inner.channel().signal_peer(clear_mask, set_mask)
1493    }
1494}
1495
1496impl EngineControlHandle {}
1497
1498#[must_use = "FIDL methods require a response to be sent"]
1499#[derive(Debug)]
1500pub struct EngineTestApplyResponder {
1501    control_handle: std::mem::ManuallyDrop<EngineControlHandle>,
1502    tx_id: u32,
1503}
1504
1505/// Set the the channel to be shutdown (see [`EngineControlHandle::shutdown`])
1506/// if the responder is dropped without sending a response, so that the client
1507/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1508impl std::ops::Drop for EngineTestApplyResponder {
1509    fn drop(&mut self) {
1510        self.control_handle.shutdown();
1511        // Safety: drops once, never accessed again
1512        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1513    }
1514}
1515
1516impl fidl::endpoints::Responder for EngineTestApplyResponder {
1517    type ControlHandle = EngineControlHandle;
1518
1519    fn control_handle(&self) -> &EngineControlHandle {
1520        &self.control_handle
1521    }
1522
1523    fn drop_without_shutdown(mut self) {
1524        // Safety: drops once, never accessed again due to mem::forget
1525        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1526        // Prevent Drop from running (which would shut down the channel)
1527        std::mem::forget(self);
1528    }
1529}
1530
1531impl EngineTestApplyResponder {
1532    /// Sends a response to the FIDL transaction.
1533    ///
1534    /// Sets the channel to shutdown if an error occurs.
1535    pub fn send(self, mut result: Result<&str, i32>) -> Result<(), fidl::Error> {
1536        let _result = self.send_raw(result);
1537        if _result.is_err() {
1538            self.control_handle.shutdown();
1539        }
1540        self.drop_without_shutdown();
1541        _result
1542    }
1543
1544    /// Similar to "send" but does not shutdown the channel if an error occurs.
1545    pub fn send_no_shutdown_on_err(self, mut result: Result<&str, i32>) -> Result<(), fidl::Error> {
1546        let _result = self.send_raw(result);
1547        self.drop_without_shutdown();
1548        _result
1549    }
1550
1551    fn send_raw(&self, mut result: Result<&str, i32>) -> Result<(), fidl::Error> {
1552        self.control_handle.inner.send::<fidl::encoding::ResultType<EngineTestApplyResponse, i32>>(
1553            result.map(|rewritten| (rewritten,)),
1554            self.tx_id,
1555            0xc8826a2b36fca39,
1556            fidl::encoding::DynamicFlags::empty(),
1557        )
1558    }
1559}
1560
1561#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1562pub struct RuleIteratorMarker;
1563
1564impl fidl::endpoints::ProtocolMarker for RuleIteratorMarker {
1565    type Proxy = RuleIteratorProxy;
1566    type RequestStream = RuleIteratorRequestStream;
1567    #[cfg(target_os = "fuchsia")]
1568    type SynchronousProxy = RuleIteratorSynchronousProxy;
1569
1570    const DEBUG_NAME: &'static str = "(anonymous) RuleIterator";
1571}
1572
1573pub trait RuleIteratorProxyInterface: Send + Sync {
1574    type NextResponseFut: std::future::Future<Output = Result<Vec<Rule>, fidl::Error>> + Send;
1575    fn r#next(&self) -> Self::NextResponseFut;
1576}
1577#[derive(Debug)]
1578#[cfg(target_os = "fuchsia")]
1579pub struct RuleIteratorSynchronousProxy {
1580    client: fidl::client::sync::Client,
1581}
1582
1583#[cfg(target_os = "fuchsia")]
1584impl fidl::endpoints::SynchronousProxy for RuleIteratorSynchronousProxy {
1585    type Proxy = RuleIteratorProxy;
1586    type Protocol = RuleIteratorMarker;
1587
1588    fn from_channel(inner: fidl::Channel) -> Self {
1589        Self::new(inner)
1590    }
1591
1592    fn into_channel(self) -> fidl::Channel {
1593        self.client.into_channel()
1594    }
1595
1596    fn as_channel(&self) -> &fidl::Channel {
1597        self.client.as_channel()
1598    }
1599}
1600
1601#[cfg(target_os = "fuchsia")]
1602impl RuleIteratorSynchronousProxy {
1603    pub fn new(channel: fidl::Channel) -> Self {
1604        Self { client: fidl::client::sync::Client::new(channel) }
1605    }
1606
1607    pub fn into_channel(self) -> fidl::Channel {
1608        self.client.into_channel()
1609    }
1610
1611    /// Waits until an event arrives and returns it. It is safe for other
1612    /// threads to make concurrent requests while waiting for an event.
1613    pub fn wait_for_event(
1614        &self,
1615        deadline: zx::MonotonicInstant,
1616    ) -> Result<RuleIteratorEvent, fidl::Error> {
1617        RuleIteratorEvent::decode(self.client.wait_for_event::<RuleIteratorMarker>(deadline)?)
1618    }
1619
1620    /// Advances the iterator and returns the next batch of rules.
1621    ///
1622    /// - response `rules` a vector of [`Rule`] rules. Will return an empty
1623    ///    vector and then close the channel when there are no more rules.
1624    pub fn r#next(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<Rule>, fidl::Error> {
1625        let _response = self.client.send_query::<
1626            fidl::encoding::EmptyPayload,
1627            RuleIteratorNextResponse,
1628            RuleIteratorMarker,
1629        >(
1630            (),
1631            0x1007ff472e2fcd45,
1632            fidl::encoding::DynamicFlags::empty(),
1633            ___deadline,
1634        )?;
1635        Ok(_response.rules)
1636    }
1637}
1638
1639#[cfg(target_os = "fuchsia")]
1640impl From<RuleIteratorSynchronousProxy> for zx::NullableHandle {
1641    fn from(value: RuleIteratorSynchronousProxy) -> Self {
1642        value.into_channel().into()
1643    }
1644}
1645
1646#[cfg(target_os = "fuchsia")]
1647impl From<fidl::Channel> for RuleIteratorSynchronousProxy {
1648    fn from(value: fidl::Channel) -> Self {
1649        Self::new(value)
1650    }
1651}
1652
1653#[cfg(target_os = "fuchsia")]
1654impl fidl::endpoints::FromClient for RuleIteratorSynchronousProxy {
1655    type Protocol = RuleIteratorMarker;
1656
1657    fn from_client(value: fidl::endpoints::ClientEnd<RuleIteratorMarker>) -> Self {
1658        Self::new(value.into_channel())
1659    }
1660}
1661
1662#[derive(Debug, Clone)]
1663pub struct RuleIteratorProxy {
1664    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1665}
1666
1667impl fidl::endpoints::Proxy for RuleIteratorProxy {
1668    type Protocol = RuleIteratorMarker;
1669
1670    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1671        Self::new(inner)
1672    }
1673
1674    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1675        self.client.into_channel().map_err(|client| Self { client })
1676    }
1677
1678    fn as_channel(&self) -> &::fidl::AsyncChannel {
1679        self.client.as_channel()
1680    }
1681}
1682
1683impl RuleIteratorProxy {
1684    /// Create a new Proxy for fuchsia.pkg.rewrite/RuleIterator.
1685    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1686        let protocol_name = <RuleIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1687        Self { client: fidl::client::Client::new(channel, protocol_name) }
1688    }
1689
1690    /// Get a Stream of events from the remote end of the protocol.
1691    ///
1692    /// # Panics
1693    ///
1694    /// Panics if the event stream was already taken.
1695    pub fn take_event_stream(&self) -> RuleIteratorEventStream {
1696        RuleIteratorEventStream { event_receiver: self.client.take_event_receiver() }
1697    }
1698
1699    /// Advances the iterator and returns the next batch of rules.
1700    ///
1701    /// - response `rules` a vector of [`Rule`] rules. Will return an empty
1702    ///    vector and then close the channel when there are no more rules.
1703    pub fn r#next(
1704        &self,
1705    ) -> fidl::client::QueryResponseFut<Vec<Rule>, fidl::encoding::DefaultFuchsiaResourceDialect>
1706    {
1707        RuleIteratorProxyInterface::r#next(self)
1708    }
1709}
1710
1711impl RuleIteratorProxyInterface for RuleIteratorProxy {
1712    type NextResponseFut =
1713        fidl::client::QueryResponseFut<Vec<Rule>, fidl::encoding::DefaultFuchsiaResourceDialect>;
1714    fn r#next(&self) -> Self::NextResponseFut {
1715        fn _decode(
1716            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1717        ) -> Result<Vec<Rule>, fidl::Error> {
1718            let _response = fidl::client::decode_transaction_body::<
1719                RuleIteratorNextResponse,
1720                fidl::encoding::DefaultFuchsiaResourceDialect,
1721                0x1007ff472e2fcd45,
1722            >(_buf?)?;
1723            Ok(_response.rules)
1724        }
1725        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Rule>>(
1726            (),
1727            0x1007ff472e2fcd45,
1728            fidl::encoding::DynamicFlags::empty(),
1729            _decode,
1730        )
1731    }
1732}
1733
1734pub struct RuleIteratorEventStream {
1735    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1736}
1737
1738impl std::marker::Unpin for RuleIteratorEventStream {}
1739
1740impl futures::stream::FusedStream for RuleIteratorEventStream {
1741    fn is_terminated(&self) -> bool {
1742        self.event_receiver.is_terminated()
1743    }
1744}
1745
1746impl futures::Stream for RuleIteratorEventStream {
1747    type Item = Result<RuleIteratorEvent, fidl::Error>;
1748
1749    fn poll_next(
1750        mut self: std::pin::Pin<&mut Self>,
1751        cx: &mut std::task::Context<'_>,
1752    ) -> std::task::Poll<Option<Self::Item>> {
1753        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1754            &mut self.event_receiver,
1755            cx
1756        )?) {
1757            Some(buf) => std::task::Poll::Ready(Some(RuleIteratorEvent::decode(buf))),
1758            None => std::task::Poll::Ready(None),
1759        }
1760    }
1761}
1762
1763#[derive(Debug)]
1764pub enum RuleIteratorEvent {}
1765
1766impl RuleIteratorEvent {
1767    /// Decodes a message buffer as a [`RuleIteratorEvent`].
1768    fn decode(
1769        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1770    ) -> Result<RuleIteratorEvent, fidl::Error> {
1771        let (bytes, _handles) = buf.split_mut();
1772        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1773        debug_assert_eq!(tx_header.tx_id, 0);
1774        match tx_header.ordinal {
1775            _ => Err(fidl::Error::UnknownOrdinal {
1776                ordinal: tx_header.ordinal,
1777                protocol_name: <RuleIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1778            }),
1779        }
1780    }
1781}
1782
1783/// A Stream of incoming requests for fuchsia.pkg.rewrite/RuleIterator.
1784pub struct RuleIteratorRequestStream {
1785    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1786    is_terminated: bool,
1787}
1788
1789impl std::marker::Unpin for RuleIteratorRequestStream {}
1790
1791impl futures::stream::FusedStream for RuleIteratorRequestStream {
1792    fn is_terminated(&self) -> bool {
1793        self.is_terminated
1794    }
1795}
1796
1797impl fidl::endpoints::RequestStream for RuleIteratorRequestStream {
1798    type Protocol = RuleIteratorMarker;
1799    type ControlHandle = RuleIteratorControlHandle;
1800
1801    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1802        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1803    }
1804
1805    fn control_handle(&self) -> Self::ControlHandle {
1806        RuleIteratorControlHandle { inner: self.inner.clone() }
1807    }
1808
1809    fn into_inner(
1810        self,
1811    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1812    {
1813        (self.inner, self.is_terminated)
1814    }
1815
1816    fn from_inner(
1817        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1818        is_terminated: bool,
1819    ) -> Self {
1820        Self { inner, is_terminated }
1821    }
1822}
1823
1824impl futures::Stream for RuleIteratorRequestStream {
1825    type Item = Result<RuleIteratorRequest, fidl::Error>;
1826
1827    fn poll_next(
1828        mut self: std::pin::Pin<&mut Self>,
1829        cx: &mut std::task::Context<'_>,
1830    ) -> std::task::Poll<Option<Self::Item>> {
1831        let this = &mut *self;
1832        if this.inner.check_shutdown(cx) {
1833            this.is_terminated = true;
1834            return std::task::Poll::Ready(None);
1835        }
1836        if this.is_terminated {
1837            panic!("polled RuleIteratorRequestStream after completion");
1838        }
1839        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1840            |bytes, handles| {
1841                match this.inner.channel().read_etc(cx, bytes, handles) {
1842                    std::task::Poll::Ready(Ok(())) => {}
1843                    std::task::Poll::Pending => return std::task::Poll::Pending,
1844                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1845                        this.is_terminated = true;
1846                        return std::task::Poll::Ready(None);
1847                    }
1848                    std::task::Poll::Ready(Err(e)) => {
1849                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1850                            e.into(),
1851                        ))));
1852                    }
1853                }
1854
1855                // A message has been received from the channel
1856                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1857
1858                std::task::Poll::Ready(Some(match header.ordinal {
1859                    0x1007ff472e2fcd45 => {
1860                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1861                        let mut req = fidl::new_empty!(
1862                            fidl::encoding::EmptyPayload,
1863                            fidl::encoding::DefaultFuchsiaResourceDialect
1864                        );
1865                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1866                        let control_handle =
1867                            RuleIteratorControlHandle { inner: this.inner.clone() };
1868                        Ok(RuleIteratorRequest::Next {
1869                            responder: RuleIteratorNextResponder {
1870                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1871                                tx_id: header.tx_id,
1872                            },
1873                        })
1874                    }
1875                    _ => Err(fidl::Error::UnknownOrdinal {
1876                        ordinal: header.ordinal,
1877                        protocol_name:
1878                            <RuleIteratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1879                    }),
1880                }))
1881            },
1882        )
1883    }
1884}
1885
1886/// The iterator over all the rewrite rules defined in a [`Engine`].
1887#[derive(Debug)]
1888pub enum RuleIteratorRequest {
1889    /// Advances the iterator and returns the next batch of rules.
1890    ///
1891    /// - response `rules` a vector of [`Rule`] rules. Will return an empty
1892    ///    vector and then close the channel when there are no more rules.
1893    Next { responder: RuleIteratorNextResponder },
1894}
1895
1896impl RuleIteratorRequest {
1897    #[allow(irrefutable_let_patterns)]
1898    pub fn into_next(self) -> Option<(RuleIteratorNextResponder)> {
1899        if let RuleIteratorRequest::Next { responder } = self { Some((responder)) } else { None }
1900    }
1901
1902    /// Name of the method defined in FIDL
1903    pub fn method_name(&self) -> &'static str {
1904        match *self {
1905            RuleIteratorRequest::Next { .. } => "next",
1906        }
1907    }
1908}
1909
1910#[derive(Debug, Clone)]
1911pub struct RuleIteratorControlHandle {
1912    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1913}
1914
1915impl RuleIteratorControlHandle {
1916    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1917        self.inner.shutdown_with_epitaph(status.into())
1918    }
1919}
1920
1921impl fidl::endpoints::ControlHandle for RuleIteratorControlHandle {
1922    fn shutdown(&self) {
1923        self.inner.shutdown()
1924    }
1925
1926    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1927        self.inner.shutdown_with_epitaph(status)
1928    }
1929
1930    fn is_closed(&self) -> bool {
1931        self.inner.channel().is_closed()
1932    }
1933    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1934        self.inner.channel().on_closed()
1935    }
1936
1937    #[cfg(target_os = "fuchsia")]
1938    fn signal_peer(
1939        &self,
1940        clear_mask: zx::Signals,
1941        set_mask: zx::Signals,
1942    ) -> Result<(), zx_status::Status> {
1943        use fidl::Peered;
1944        self.inner.channel().signal_peer(clear_mask, set_mask)
1945    }
1946}
1947
1948impl RuleIteratorControlHandle {}
1949
1950#[must_use = "FIDL methods require a response to be sent"]
1951#[derive(Debug)]
1952pub struct RuleIteratorNextResponder {
1953    control_handle: std::mem::ManuallyDrop<RuleIteratorControlHandle>,
1954    tx_id: u32,
1955}
1956
1957/// Set the the channel to be shutdown (see [`RuleIteratorControlHandle::shutdown`])
1958/// if the responder is dropped without sending a response, so that the client
1959/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1960impl std::ops::Drop for RuleIteratorNextResponder {
1961    fn drop(&mut self) {
1962        self.control_handle.shutdown();
1963        // Safety: drops once, never accessed again
1964        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1965    }
1966}
1967
1968impl fidl::endpoints::Responder for RuleIteratorNextResponder {
1969    type ControlHandle = RuleIteratorControlHandle;
1970
1971    fn control_handle(&self) -> &RuleIteratorControlHandle {
1972        &self.control_handle
1973    }
1974
1975    fn drop_without_shutdown(mut self) {
1976        // Safety: drops once, never accessed again due to mem::forget
1977        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1978        // Prevent Drop from running (which would shut down the channel)
1979        std::mem::forget(self);
1980    }
1981}
1982
1983impl RuleIteratorNextResponder {
1984    /// Sends a response to the FIDL transaction.
1985    ///
1986    /// Sets the channel to shutdown if an error occurs.
1987    pub fn send(self, mut rules: &[Rule]) -> Result<(), fidl::Error> {
1988        let _result = self.send_raw(rules);
1989        if _result.is_err() {
1990            self.control_handle.shutdown();
1991        }
1992        self.drop_without_shutdown();
1993        _result
1994    }
1995
1996    /// Similar to "send" but does not shutdown the channel if an error occurs.
1997    pub fn send_no_shutdown_on_err(self, mut rules: &[Rule]) -> Result<(), fidl::Error> {
1998        let _result = self.send_raw(rules);
1999        self.drop_without_shutdown();
2000        _result
2001    }
2002
2003    fn send_raw(&self, mut rules: &[Rule]) -> Result<(), fidl::Error> {
2004        self.control_handle.inner.send::<RuleIteratorNextResponse>(
2005            (rules,),
2006            self.tx_id,
2007            0x1007ff472e2fcd45,
2008            fidl::encoding::DynamicFlags::empty(),
2009        )
2010    }
2011}
2012
2013mod internal {
2014    use super::*;
2015
2016    impl fidl::encoding::ResourceTypeMarker for EditTransactionListDynamicRequest {
2017        type Borrowed<'a> = &'a mut Self;
2018        fn take_or_borrow<'a>(
2019            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2020        ) -> Self::Borrowed<'a> {
2021            value
2022        }
2023    }
2024
2025    unsafe impl fidl::encoding::TypeMarker for EditTransactionListDynamicRequest {
2026        type Owned = Self;
2027
2028        #[inline(always)]
2029        fn inline_align(_context: fidl::encoding::Context) -> usize {
2030            4
2031        }
2032
2033        #[inline(always)]
2034        fn inline_size(_context: fidl::encoding::Context) -> usize {
2035            4
2036        }
2037    }
2038
2039    unsafe impl
2040        fidl::encoding::Encode<
2041            EditTransactionListDynamicRequest,
2042            fidl::encoding::DefaultFuchsiaResourceDialect,
2043        > for &mut EditTransactionListDynamicRequest
2044    {
2045        #[inline]
2046        unsafe fn encode(
2047            self,
2048            encoder: &mut fidl::encoding::Encoder<
2049                '_,
2050                fidl::encoding::DefaultFuchsiaResourceDialect,
2051            >,
2052            offset: usize,
2053            _depth: fidl::encoding::Depth,
2054        ) -> fidl::Result<()> {
2055            encoder.debug_check_bounds::<EditTransactionListDynamicRequest>(offset);
2056            // Delegate to tuple encoding.
2057            fidl::encoding::Encode::<EditTransactionListDynamicRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2058                (
2059                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
2060                ),
2061                encoder, offset, _depth
2062            )
2063        }
2064    }
2065    unsafe impl<
2066        T0: fidl::encoding::Encode<
2067                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2068                fidl::encoding::DefaultFuchsiaResourceDialect,
2069            >,
2070    >
2071        fidl::encoding::Encode<
2072            EditTransactionListDynamicRequest,
2073            fidl::encoding::DefaultFuchsiaResourceDialect,
2074        > for (T0,)
2075    {
2076        #[inline]
2077        unsafe fn encode(
2078            self,
2079            encoder: &mut fidl::encoding::Encoder<
2080                '_,
2081                fidl::encoding::DefaultFuchsiaResourceDialect,
2082            >,
2083            offset: usize,
2084            depth: fidl::encoding::Depth,
2085        ) -> fidl::Result<()> {
2086            encoder.debug_check_bounds::<EditTransactionListDynamicRequest>(offset);
2087            // Zero out padding regions. There's no need to apply masks
2088            // because the unmasked parts will be overwritten by fields.
2089            // Write the fields.
2090            self.0.encode(encoder, offset + 0, depth)?;
2091            Ok(())
2092        }
2093    }
2094
2095    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2096        for EditTransactionListDynamicRequest
2097    {
2098        #[inline(always)]
2099        fn new_empty() -> Self {
2100            Self {
2101                iterator: fidl::new_empty!(
2102                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2103                    fidl::encoding::DefaultFuchsiaResourceDialect
2104                ),
2105            }
2106        }
2107
2108        #[inline]
2109        unsafe fn decode(
2110            &mut self,
2111            decoder: &mut fidl::encoding::Decoder<
2112                '_,
2113                fidl::encoding::DefaultFuchsiaResourceDialect,
2114            >,
2115            offset: usize,
2116            _depth: fidl::encoding::Depth,
2117        ) -> fidl::Result<()> {
2118            decoder.debug_check_bounds::<Self>(offset);
2119            // Verify that padding bytes are zero.
2120            fidl::decode!(
2121                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2122                fidl::encoding::DefaultFuchsiaResourceDialect,
2123                &mut self.iterator,
2124                decoder,
2125                offset + 0,
2126                _depth
2127            )?;
2128            Ok(())
2129        }
2130    }
2131
2132    impl fidl::encoding::ResourceTypeMarker for EngineListRequest {
2133        type Borrowed<'a> = &'a mut Self;
2134        fn take_or_borrow<'a>(
2135            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2136        ) -> Self::Borrowed<'a> {
2137            value
2138        }
2139    }
2140
2141    unsafe impl fidl::encoding::TypeMarker for EngineListRequest {
2142        type Owned = Self;
2143
2144        #[inline(always)]
2145        fn inline_align(_context: fidl::encoding::Context) -> usize {
2146            4
2147        }
2148
2149        #[inline(always)]
2150        fn inline_size(_context: fidl::encoding::Context) -> usize {
2151            4
2152        }
2153    }
2154
2155    unsafe impl
2156        fidl::encoding::Encode<EngineListRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2157        for &mut EngineListRequest
2158    {
2159        #[inline]
2160        unsafe fn encode(
2161            self,
2162            encoder: &mut fidl::encoding::Encoder<
2163                '_,
2164                fidl::encoding::DefaultFuchsiaResourceDialect,
2165            >,
2166            offset: usize,
2167            _depth: fidl::encoding::Depth,
2168        ) -> fidl::Result<()> {
2169            encoder.debug_check_bounds::<EngineListRequest>(offset);
2170            // Delegate to tuple encoding.
2171            fidl::encoding::Encode::<EngineListRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2172                (
2173                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
2174                ),
2175                encoder, offset, _depth
2176            )
2177        }
2178    }
2179    unsafe impl<
2180        T0: fidl::encoding::Encode<
2181                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2182                fidl::encoding::DefaultFuchsiaResourceDialect,
2183            >,
2184    > fidl::encoding::Encode<EngineListRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2185        for (T0,)
2186    {
2187        #[inline]
2188        unsafe fn encode(
2189            self,
2190            encoder: &mut fidl::encoding::Encoder<
2191                '_,
2192                fidl::encoding::DefaultFuchsiaResourceDialect,
2193            >,
2194            offset: usize,
2195            depth: fidl::encoding::Depth,
2196        ) -> fidl::Result<()> {
2197            encoder.debug_check_bounds::<EngineListRequest>(offset);
2198            // Zero out padding regions. There's no need to apply masks
2199            // because the unmasked parts will be overwritten by fields.
2200            // Write the fields.
2201            self.0.encode(encoder, offset + 0, depth)?;
2202            Ok(())
2203        }
2204    }
2205
2206    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2207        for EngineListRequest
2208    {
2209        #[inline(always)]
2210        fn new_empty() -> Self {
2211            Self {
2212                iterator: fidl::new_empty!(
2213                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2214                    fidl::encoding::DefaultFuchsiaResourceDialect
2215                ),
2216            }
2217        }
2218
2219        #[inline]
2220        unsafe fn decode(
2221            &mut self,
2222            decoder: &mut fidl::encoding::Decoder<
2223                '_,
2224                fidl::encoding::DefaultFuchsiaResourceDialect,
2225            >,
2226            offset: usize,
2227            _depth: fidl::encoding::Depth,
2228        ) -> fidl::Result<()> {
2229            decoder.debug_check_bounds::<Self>(offset);
2230            // Verify that padding bytes are zero.
2231            fidl::decode!(
2232                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2233                fidl::encoding::DefaultFuchsiaResourceDialect,
2234                &mut self.iterator,
2235                decoder,
2236                offset + 0,
2237                _depth
2238            )?;
2239            Ok(())
2240        }
2241    }
2242
2243    impl fidl::encoding::ResourceTypeMarker for EngineListStaticRequest {
2244        type Borrowed<'a> = &'a mut Self;
2245        fn take_or_borrow<'a>(
2246            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2247        ) -> Self::Borrowed<'a> {
2248            value
2249        }
2250    }
2251
2252    unsafe impl fidl::encoding::TypeMarker for EngineListStaticRequest {
2253        type Owned = Self;
2254
2255        #[inline(always)]
2256        fn inline_align(_context: fidl::encoding::Context) -> usize {
2257            4
2258        }
2259
2260        #[inline(always)]
2261        fn inline_size(_context: fidl::encoding::Context) -> usize {
2262            4
2263        }
2264    }
2265
2266    unsafe impl
2267        fidl::encoding::Encode<
2268            EngineListStaticRequest,
2269            fidl::encoding::DefaultFuchsiaResourceDialect,
2270        > for &mut EngineListStaticRequest
2271    {
2272        #[inline]
2273        unsafe fn encode(
2274            self,
2275            encoder: &mut fidl::encoding::Encoder<
2276                '_,
2277                fidl::encoding::DefaultFuchsiaResourceDialect,
2278            >,
2279            offset: usize,
2280            _depth: fidl::encoding::Depth,
2281        ) -> fidl::Result<()> {
2282            encoder.debug_check_bounds::<EngineListStaticRequest>(offset);
2283            // Delegate to tuple encoding.
2284            fidl::encoding::Encode::<EngineListStaticRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2285                (
2286                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iterator),
2287                ),
2288                encoder, offset, _depth
2289            )
2290        }
2291    }
2292    unsafe impl<
2293        T0: fidl::encoding::Encode<
2294                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2295                fidl::encoding::DefaultFuchsiaResourceDialect,
2296            >,
2297    >
2298        fidl::encoding::Encode<
2299            EngineListStaticRequest,
2300            fidl::encoding::DefaultFuchsiaResourceDialect,
2301        > for (T0,)
2302    {
2303        #[inline]
2304        unsafe fn encode(
2305            self,
2306            encoder: &mut fidl::encoding::Encoder<
2307                '_,
2308                fidl::encoding::DefaultFuchsiaResourceDialect,
2309            >,
2310            offset: usize,
2311            depth: fidl::encoding::Depth,
2312        ) -> fidl::Result<()> {
2313            encoder.debug_check_bounds::<EngineListStaticRequest>(offset);
2314            // Zero out padding regions. There's no need to apply masks
2315            // because the unmasked parts will be overwritten by fields.
2316            // Write the fields.
2317            self.0.encode(encoder, offset + 0, depth)?;
2318            Ok(())
2319        }
2320    }
2321
2322    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2323        for EngineListStaticRequest
2324    {
2325        #[inline(always)]
2326        fn new_empty() -> Self {
2327            Self {
2328                iterator: fidl::new_empty!(
2329                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2330                    fidl::encoding::DefaultFuchsiaResourceDialect
2331                ),
2332            }
2333        }
2334
2335        #[inline]
2336        unsafe fn decode(
2337            &mut self,
2338            decoder: &mut fidl::encoding::Decoder<
2339                '_,
2340                fidl::encoding::DefaultFuchsiaResourceDialect,
2341            >,
2342            offset: usize,
2343            _depth: fidl::encoding::Depth,
2344        ) -> fidl::Result<()> {
2345            decoder.debug_check_bounds::<Self>(offset);
2346            // Verify that padding bytes are zero.
2347            fidl::decode!(
2348                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<RuleIteratorMarker>>,
2349                fidl::encoding::DefaultFuchsiaResourceDialect,
2350                &mut self.iterator,
2351                decoder,
2352                offset + 0,
2353                _depth
2354            )?;
2355            Ok(())
2356        }
2357    }
2358
2359    impl fidl::encoding::ResourceTypeMarker for EngineStartEditTransactionRequest {
2360        type Borrowed<'a> = &'a mut Self;
2361        fn take_or_borrow<'a>(
2362            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2363        ) -> Self::Borrowed<'a> {
2364            value
2365        }
2366    }
2367
2368    unsafe impl fidl::encoding::TypeMarker for EngineStartEditTransactionRequest {
2369        type Owned = Self;
2370
2371        #[inline(always)]
2372        fn inline_align(_context: fidl::encoding::Context) -> usize {
2373            4
2374        }
2375
2376        #[inline(always)]
2377        fn inline_size(_context: fidl::encoding::Context) -> usize {
2378            4
2379        }
2380    }
2381
2382    unsafe impl
2383        fidl::encoding::Encode<
2384            EngineStartEditTransactionRequest,
2385            fidl::encoding::DefaultFuchsiaResourceDialect,
2386        > for &mut EngineStartEditTransactionRequest
2387    {
2388        #[inline]
2389        unsafe fn encode(
2390            self,
2391            encoder: &mut fidl::encoding::Encoder<
2392                '_,
2393                fidl::encoding::DefaultFuchsiaResourceDialect,
2394            >,
2395            offset: usize,
2396            _depth: fidl::encoding::Depth,
2397        ) -> fidl::Result<()> {
2398            encoder.debug_check_bounds::<EngineStartEditTransactionRequest>(offset);
2399            // Delegate to tuple encoding.
2400            fidl::encoding::Encode::<EngineStartEditTransactionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2401                (
2402                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EditTransactionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.transaction),
2403                ),
2404                encoder, offset, _depth
2405            )
2406        }
2407    }
2408    unsafe impl<
2409        T0: fidl::encoding::Encode<
2410                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EditTransactionMarker>>,
2411                fidl::encoding::DefaultFuchsiaResourceDialect,
2412            >,
2413    >
2414        fidl::encoding::Encode<
2415            EngineStartEditTransactionRequest,
2416            fidl::encoding::DefaultFuchsiaResourceDialect,
2417        > for (T0,)
2418    {
2419        #[inline]
2420        unsafe fn encode(
2421            self,
2422            encoder: &mut fidl::encoding::Encoder<
2423                '_,
2424                fidl::encoding::DefaultFuchsiaResourceDialect,
2425            >,
2426            offset: usize,
2427            depth: fidl::encoding::Depth,
2428        ) -> fidl::Result<()> {
2429            encoder.debug_check_bounds::<EngineStartEditTransactionRequest>(offset);
2430            // Zero out padding regions. There's no need to apply masks
2431            // because the unmasked parts will be overwritten by fields.
2432            // Write the fields.
2433            self.0.encode(encoder, offset + 0, depth)?;
2434            Ok(())
2435        }
2436    }
2437
2438    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2439        for EngineStartEditTransactionRequest
2440    {
2441        #[inline(always)]
2442        fn new_empty() -> Self {
2443            Self {
2444                transaction: fidl::new_empty!(
2445                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EditTransactionMarker>>,
2446                    fidl::encoding::DefaultFuchsiaResourceDialect
2447                ),
2448            }
2449        }
2450
2451        #[inline]
2452        unsafe fn decode(
2453            &mut self,
2454            decoder: &mut fidl::encoding::Decoder<
2455                '_,
2456                fidl::encoding::DefaultFuchsiaResourceDialect,
2457            >,
2458            offset: usize,
2459            _depth: fidl::encoding::Depth,
2460        ) -> fidl::Result<()> {
2461            decoder.debug_check_bounds::<Self>(offset);
2462            // Verify that padding bytes are zero.
2463            fidl::decode!(
2464                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<EditTransactionMarker>>,
2465                fidl::encoding::DefaultFuchsiaResourceDialect,
2466                &mut self.transaction,
2467                decoder,
2468                offset + 0,
2469                _depth
2470            )?;
2471            Ok(())
2472        }
2473    }
2474}