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