fidl_fuchsia_pkg_garbagecollector/
fidl_fuchsia_pkg_garbagecollector.rs1#![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_garbagecollector__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ManagerMarker;
16
17impl fidl::endpoints::ProtocolMarker for ManagerMarker {
18 type Proxy = ManagerProxy;
19 type RequestStream = ManagerRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ManagerSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.pkg.garbagecollector.Manager";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ManagerMarker {}
26pub type ManagerGcResult = Result<(), GcError>;
27
28pub trait ManagerProxyInterface: Send + Sync {
29 type GcResponseFut: std::future::Future<Output = Result<ManagerGcResult, fidl::Error>> + Send;
30 fn r#gc(&self) -> Self::GcResponseFut;
31}
32#[derive(Debug)]
33#[cfg(target_os = "fuchsia")]
34pub struct ManagerSynchronousProxy {
35 client: fidl::client::sync::Client,
36}
37
38#[cfg(target_os = "fuchsia")]
39impl fidl::endpoints::SynchronousProxy for ManagerSynchronousProxy {
40 type Proxy = ManagerProxy;
41 type Protocol = ManagerMarker;
42
43 fn from_channel(inner: fidl::Channel) -> Self {
44 Self::new(inner)
45 }
46
47 fn into_channel(self) -> fidl::Channel {
48 self.client.into_channel()
49 }
50
51 fn as_channel(&self) -> &fidl::Channel {
52 self.client.as_channel()
53 }
54}
55
56#[cfg(target_os = "fuchsia")]
57impl ManagerSynchronousProxy {
58 pub fn new(channel: fidl::Channel) -> Self {
59 let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
60 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
61 }
62
63 pub fn into_channel(self) -> fidl::Channel {
64 self.client.into_channel()
65 }
66
67 pub fn wait_for_event(
70 &self,
71 deadline: zx::MonotonicInstant,
72 ) -> Result<ManagerEvent, fidl::Error> {
73 ManagerEvent::decode(self.client.wait_for_event(deadline)?)
74 }
75
76 pub fn r#gc(&self, ___deadline: zx::MonotonicInstant) -> Result<ManagerGcResult, fidl::Error> {
79 let _response = self.client.send_query::<
80 fidl::encoding::EmptyPayload,
81 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, GcError>,
82 >(
83 (),
84 0x68a3c8b241ab99ce,
85 fidl::encoding::DynamicFlags::FLEXIBLE,
86 ___deadline,
87 )?
88 .into_result::<ManagerMarker>("gc")?;
89 Ok(_response.map(|x| x))
90 }
91}
92
93#[cfg(target_os = "fuchsia")]
94impl From<ManagerSynchronousProxy> for zx::NullableHandle {
95 fn from(value: ManagerSynchronousProxy) -> Self {
96 value.into_channel().into()
97 }
98}
99
100#[cfg(target_os = "fuchsia")]
101impl From<fidl::Channel> for ManagerSynchronousProxy {
102 fn from(value: fidl::Channel) -> Self {
103 Self::new(value)
104 }
105}
106
107#[cfg(target_os = "fuchsia")]
108impl fidl::endpoints::FromClient for ManagerSynchronousProxy {
109 type Protocol = ManagerMarker;
110
111 fn from_client(value: fidl::endpoints::ClientEnd<ManagerMarker>) -> Self {
112 Self::new(value.into_channel())
113 }
114}
115
116#[derive(Debug, Clone)]
117pub struct ManagerProxy {
118 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
119}
120
121impl fidl::endpoints::Proxy for ManagerProxy {
122 type Protocol = ManagerMarker;
123
124 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
125 Self::new(inner)
126 }
127
128 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
129 self.client.into_channel().map_err(|client| Self { client })
130 }
131
132 fn as_channel(&self) -> &::fidl::AsyncChannel {
133 self.client.as_channel()
134 }
135}
136
137impl ManagerProxy {
138 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
140 let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
141 Self { client: fidl::client::Client::new(channel, protocol_name) }
142 }
143
144 pub fn take_event_stream(&self) -> ManagerEventStream {
150 ManagerEventStream { event_receiver: self.client.take_event_receiver() }
151 }
152
153 pub fn r#gc(
156 &self,
157 ) -> fidl::client::QueryResponseFut<
158 ManagerGcResult,
159 fidl::encoding::DefaultFuchsiaResourceDialect,
160 > {
161 ManagerProxyInterface::r#gc(self)
162 }
163}
164
165impl ManagerProxyInterface for ManagerProxy {
166 type GcResponseFut = fidl::client::QueryResponseFut<
167 ManagerGcResult,
168 fidl::encoding::DefaultFuchsiaResourceDialect,
169 >;
170 fn r#gc(&self) -> Self::GcResponseFut {
171 fn _decode(
172 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
173 ) -> Result<ManagerGcResult, fidl::Error> {
174 let _response = fidl::client::decode_transaction_body::<
175 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, GcError>,
176 fidl::encoding::DefaultFuchsiaResourceDialect,
177 0x68a3c8b241ab99ce,
178 >(_buf?)?
179 .into_result::<ManagerMarker>("gc")?;
180 Ok(_response.map(|x| x))
181 }
182 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ManagerGcResult>(
183 (),
184 0x68a3c8b241ab99ce,
185 fidl::encoding::DynamicFlags::FLEXIBLE,
186 _decode,
187 )
188 }
189}
190
191pub struct ManagerEventStream {
192 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
193}
194
195impl std::marker::Unpin for ManagerEventStream {}
196
197impl futures::stream::FusedStream for ManagerEventStream {
198 fn is_terminated(&self) -> bool {
199 self.event_receiver.is_terminated()
200 }
201}
202
203impl futures::Stream for ManagerEventStream {
204 type Item = Result<ManagerEvent, fidl::Error>;
205
206 fn poll_next(
207 mut self: std::pin::Pin<&mut Self>,
208 cx: &mut std::task::Context<'_>,
209 ) -> std::task::Poll<Option<Self::Item>> {
210 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
211 &mut self.event_receiver,
212 cx
213 )?) {
214 Some(buf) => std::task::Poll::Ready(Some(ManagerEvent::decode(buf))),
215 None => std::task::Poll::Ready(None),
216 }
217 }
218}
219
220#[derive(Debug)]
221pub enum ManagerEvent {
222 #[non_exhaustive]
223 _UnknownEvent {
224 ordinal: u64,
226 },
227}
228
229impl ManagerEvent {
230 fn decode(
232 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
233 ) -> Result<ManagerEvent, fidl::Error> {
234 let (bytes, _handles) = buf.split_mut();
235 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
236 debug_assert_eq!(tx_header.tx_id, 0);
237 match tx_header.ordinal {
238 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
239 Ok(ManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
240 }
241 _ => Err(fidl::Error::UnknownOrdinal {
242 ordinal: tx_header.ordinal,
243 protocol_name: <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
244 }),
245 }
246 }
247}
248
249pub struct ManagerRequestStream {
251 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
252 is_terminated: bool,
253}
254
255impl std::marker::Unpin for ManagerRequestStream {}
256
257impl futures::stream::FusedStream for ManagerRequestStream {
258 fn is_terminated(&self) -> bool {
259 self.is_terminated
260 }
261}
262
263impl fidl::endpoints::RequestStream for ManagerRequestStream {
264 type Protocol = ManagerMarker;
265 type ControlHandle = ManagerControlHandle;
266
267 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
268 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
269 }
270
271 fn control_handle(&self) -> Self::ControlHandle {
272 ManagerControlHandle { inner: self.inner.clone() }
273 }
274
275 fn into_inner(
276 self,
277 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
278 {
279 (self.inner, self.is_terminated)
280 }
281
282 fn from_inner(
283 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
284 is_terminated: bool,
285 ) -> Self {
286 Self { inner, is_terminated }
287 }
288}
289
290impl futures::Stream for ManagerRequestStream {
291 type Item = Result<ManagerRequest, fidl::Error>;
292
293 fn poll_next(
294 mut self: std::pin::Pin<&mut Self>,
295 cx: &mut std::task::Context<'_>,
296 ) -> std::task::Poll<Option<Self::Item>> {
297 let this = &mut *self;
298 if this.inner.check_shutdown(cx) {
299 this.is_terminated = true;
300 return std::task::Poll::Ready(None);
301 }
302 if this.is_terminated {
303 panic!("polled ManagerRequestStream after completion");
304 }
305 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
306 |bytes, handles| {
307 match this.inner.channel().read_etc(cx, bytes, handles) {
308 std::task::Poll::Ready(Ok(())) => {}
309 std::task::Poll::Pending => return std::task::Poll::Pending,
310 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
311 this.is_terminated = true;
312 return std::task::Poll::Ready(None);
313 }
314 std::task::Poll::Ready(Err(e)) => {
315 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
316 e.into(),
317 ))));
318 }
319 }
320
321 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
323
324 std::task::Poll::Ready(Some(match header.ordinal {
325 0x68a3c8b241ab99ce => {
326 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
327 let mut req = fidl::new_empty!(
328 fidl::encoding::EmptyPayload,
329 fidl::encoding::DefaultFuchsiaResourceDialect
330 );
331 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
332 let control_handle = ManagerControlHandle { inner: this.inner.clone() };
333 Ok(ManagerRequest::Gc {
334 responder: ManagerGcResponder {
335 control_handle: std::mem::ManuallyDrop::new(control_handle),
336 tx_id: header.tx_id,
337 },
338 })
339 }
340 _ if header.tx_id == 0
341 && header
342 .dynamic_flags()
343 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
344 {
345 Ok(ManagerRequest::_UnknownMethod {
346 ordinal: header.ordinal,
347 control_handle: ManagerControlHandle { inner: this.inner.clone() },
348 method_type: fidl::MethodType::OneWay,
349 })
350 }
351 _ if header
352 .dynamic_flags()
353 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
354 {
355 this.inner.send_framework_err(
356 fidl::encoding::FrameworkErr::UnknownMethod,
357 header.tx_id,
358 header.ordinal,
359 header.dynamic_flags(),
360 (bytes, handles),
361 )?;
362 Ok(ManagerRequest::_UnknownMethod {
363 ordinal: header.ordinal,
364 control_handle: ManagerControlHandle { inner: this.inner.clone() },
365 method_type: fidl::MethodType::TwoWay,
366 })
367 }
368 _ => Err(fidl::Error::UnknownOrdinal {
369 ordinal: header.ordinal,
370 protocol_name:
371 <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
372 }),
373 }))
374 },
375 )
376 }
377}
378
379#[derive(Debug)]
381pub enum ManagerRequest {
382 Gc { responder: ManagerGcResponder },
385 #[non_exhaustive]
387 _UnknownMethod {
388 ordinal: u64,
390 control_handle: ManagerControlHandle,
391 method_type: fidl::MethodType,
392 },
393}
394
395impl ManagerRequest {
396 #[allow(irrefutable_let_patterns)]
397 pub fn into_gc(self) -> Option<(ManagerGcResponder)> {
398 if let ManagerRequest::Gc { responder } = self { Some((responder)) } else { None }
399 }
400
401 pub fn method_name(&self) -> &'static str {
403 match *self {
404 ManagerRequest::Gc { .. } => "gc",
405 ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
406 "unknown one-way method"
407 }
408 ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
409 "unknown two-way method"
410 }
411 }
412 }
413}
414
415#[derive(Debug, Clone)]
416pub struct ManagerControlHandle {
417 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
418}
419
420impl fidl::endpoints::ControlHandle for ManagerControlHandle {
421 fn shutdown(&self) {
422 self.inner.shutdown()
423 }
424
425 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
426 self.inner.shutdown_with_epitaph(status)
427 }
428
429 fn is_closed(&self) -> bool {
430 self.inner.channel().is_closed()
431 }
432 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
433 self.inner.channel().on_closed()
434 }
435
436 #[cfg(target_os = "fuchsia")]
437 fn signal_peer(
438 &self,
439 clear_mask: zx::Signals,
440 set_mask: zx::Signals,
441 ) -> Result<(), zx_status::Status> {
442 use fidl::Peered;
443 self.inner.channel().signal_peer(clear_mask, set_mask)
444 }
445}
446
447impl ManagerControlHandle {}
448
449#[must_use = "FIDL methods require a response to be sent"]
450#[derive(Debug)]
451pub struct ManagerGcResponder {
452 control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
453 tx_id: u32,
454}
455
456impl std::ops::Drop for ManagerGcResponder {
460 fn drop(&mut self) {
461 self.control_handle.shutdown();
462 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
464 }
465}
466
467impl fidl::endpoints::Responder for ManagerGcResponder {
468 type ControlHandle = ManagerControlHandle;
469
470 fn control_handle(&self) -> &ManagerControlHandle {
471 &self.control_handle
472 }
473
474 fn drop_without_shutdown(mut self) {
475 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
477 std::mem::forget(self);
479 }
480}
481
482impl ManagerGcResponder {
483 pub fn send(self, mut result: Result<(), GcError>) -> Result<(), fidl::Error> {
487 let _result = self.send_raw(result);
488 if _result.is_err() {
489 self.control_handle.shutdown();
490 }
491 self.drop_without_shutdown();
492 _result
493 }
494
495 pub fn send_no_shutdown_on_err(
497 self,
498 mut result: Result<(), GcError>,
499 ) -> Result<(), fidl::Error> {
500 let _result = self.send_raw(result);
501 self.drop_without_shutdown();
502 _result
503 }
504
505 fn send_raw(&self, mut result: Result<(), GcError>) -> Result<(), fidl::Error> {
506 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
507 fidl::encoding::EmptyStruct,
508 GcError,
509 >>(
510 fidl::encoding::FlexibleResult::new(result),
511 self.tx_id,
512 0x68a3c8b241ab99ce,
513 fidl::encoding::DynamicFlags::FLEXIBLE,
514 )
515 }
516}
517
518mod internal {
519 use super::*;
520}