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 _};
10pub use fidl_fuchsia_virtualconsole__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct SessionManagerCreateSessionRequest {
16 pub session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for SessionManagerCreateSessionRequest
21{
22}
23
24#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
25pub struct SessionManagerMarker;
26
27impl fidl::endpoints::ProtocolMarker for SessionManagerMarker {
28 type Proxy = SessionManagerProxy;
29 type RequestStream = SessionManagerRequestStream;
30 #[cfg(target_os = "fuchsia")]
31 type SynchronousProxy = SessionManagerSynchronousProxy;
32
33 const DEBUG_NAME: &'static str = "fuchsia.virtualconsole.SessionManager";
34}
35impl fidl::endpoints::DiscoverableProtocolMarker for SessionManagerMarker {}
36
37pub trait SessionManagerProxyInterface: Send + Sync {
38 fn r#create_session(
39 &self,
40 session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
41 ) -> Result<(), fidl::Error>;
42 type HasPrimaryConnectedResponseFut: std::future::Future<Output = Result<bool, fidl::Error>>
43 + Send;
44 fn r#has_primary_connected(&self) -> Self::HasPrimaryConnectedResponseFut;
45}
46#[derive(Debug)]
47#[cfg(target_os = "fuchsia")]
48pub struct SessionManagerSynchronousProxy {
49 client: fidl::client::sync::Client,
50}
51
52#[cfg(target_os = "fuchsia")]
53impl fidl::endpoints::SynchronousProxy for SessionManagerSynchronousProxy {
54 type Proxy = SessionManagerProxy;
55 type Protocol = SessionManagerMarker;
56
57 fn from_channel(inner: fidl::Channel) -> Self {
58 Self::new(inner)
59 }
60
61 fn into_channel(self) -> fidl::Channel {
62 self.client.into_channel()
63 }
64
65 fn as_channel(&self) -> &fidl::Channel {
66 self.client.as_channel()
67 }
68}
69
70#[cfg(target_os = "fuchsia")]
71impl SessionManagerSynchronousProxy {
72 pub fn new(channel: fidl::Channel) -> Self {
73 let protocol_name = <SessionManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
74 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
75 }
76
77 pub fn into_channel(self) -> fidl::Channel {
78 self.client.into_channel()
79 }
80
81 pub fn wait_for_event(
84 &self,
85 deadline: zx::MonotonicInstant,
86 ) -> Result<SessionManagerEvent, fidl::Error> {
87 SessionManagerEvent::decode(self.client.wait_for_event(deadline)?)
88 }
89
90 pub fn r#create_session(
92 &self,
93 mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
94 ) -> Result<(), fidl::Error> {
95 self.client.send::<SessionManagerCreateSessionRequest>(
96 (session,),
97 0x70a8a74a19cc4b52,
98 fidl::encoding::DynamicFlags::empty(),
99 )
100 }
101
102 pub fn r#has_primary_connected(
104 &self,
105 ___deadline: zx::MonotonicInstant,
106 ) -> Result<bool, fidl::Error> {
107 let _response = self
108 .client
109 .send_query::<fidl::encoding::EmptyPayload, SessionManagerHasPrimaryConnectedResponse>(
110 (),
111 0x723fdb4c1469fa36,
112 fidl::encoding::DynamicFlags::empty(),
113 ___deadline,
114 )?;
115 Ok(_response.connected)
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<SessionManagerSynchronousProxy> for zx::NullableHandle {
121 fn from(value: SessionManagerSynchronousProxy) -> Self {
122 value.into_channel().into()
123 }
124}
125
126#[cfg(target_os = "fuchsia")]
127impl From<fidl::Channel> for SessionManagerSynchronousProxy {
128 fn from(value: fidl::Channel) -> Self {
129 Self::new(value)
130 }
131}
132
133#[cfg(target_os = "fuchsia")]
134impl fidl::endpoints::FromClient for SessionManagerSynchronousProxy {
135 type Protocol = SessionManagerMarker;
136
137 fn from_client(value: fidl::endpoints::ClientEnd<SessionManagerMarker>) -> Self {
138 Self::new(value.into_channel())
139 }
140}
141
142#[derive(Debug, Clone)]
143pub struct SessionManagerProxy {
144 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
145}
146
147impl fidl::endpoints::Proxy for SessionManagerProxy {
148 type Protocol = SessionManagerMarker;
149
150 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
151 Self::new(inner)
152 }
153
154 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
155 self.client.into_channel().map_err(|client| Self { client })
156 }
157
158 fn as_channel(&self) -> &::fidl::AsyncChannel {
159 self.client.as_channel()
160 }
161}
162
163impl SessionManagerProxy {
164 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
166 let protocol_name = <SessionManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
167 Self { client: fidl::client::Client::new(channel, protocol_name) }
168 }
169
170 pub fn take_event_stream(&self) -> SessionManagerEventStream {
176 SessionManagerEventStream { event_receiver: self.client.take_event_receiver() }
177 }
178
179 pub fn r#create_session(
181 &self,
182 mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
183 ) -> Result<(), fidl::Error> {
184 SessionManagerProxyInterface::r#create_session(self, session)
185 }
186
187 pub fn r#has_primary_connected(
189 &self,
190 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
191 SessionManagerProxyInterface::r#has_primary_connected(self)
192 }
193}
194
195impl SessionManagerProxyInterface for SessionManagerProxy {
196 fn r#create_session(
197 &self,
198 mut session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
199 ) -> Result<(), fidl::Error> {
200 self.client.send::<SessionManagerCreateSessionRequest>(
201 (session,),
202 0x70a8a74a19cc4b52,
203 fidl::encoding::DynamicFlags::empty(),
204 )
205 }
206
207 type HasPrimaryConnectedResponseFut =
208 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
209 fn r#has_primary_connected(&self) -> Self::HasPrimaryConnectedResponseFut {
210 fn _decode(
211 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
212 ) -> Result<bool, fidl::Error> {
213 let _response = fidl::client::decode_transaction_body::<
214 SessionManagerHasPrimaryConnectedResponse,
215 fidl::encoding::DefaultFuchsiaResourceDialect,
216 0x723fdb4c1469fa36,
217 >(_buf?)?;
218 Ok(_response.connected)
219 }
220 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
221 (),
222 0x723fdb4c1469fa36,
223 fidl::encoding::DynamicFlags::empty(),
224 _decode,
225 )
226 }
227}
228
229pub struct SessionManagerEventStream {
230 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
231}
232
233impl std::marker::Unpin for SessionManagerEventStream {}
234
235impl futures::stream::FusedStream for SessionManagerEventStream {
236 fn is_terminated(&self) -> bool {
237 self.event_receiver.is_terminated()
238 }
239}
240
241impl futures::Stream for SessionManagerEventStream {
242 type Item = Result<SessionManagerEvent, fidl::Error>;
243
244 fn poll_next(
245 mut self: std::pin::Pin<&mut Self>,
246 cx: &mut std::task::Context<'_>,
247 ) -> std::task::Poll<Option<Self::Item>> {
248 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
249 &mut self.event_receiver,
250 cx
251 )?) {
252 Some(buf) => std::task::Poll::Ready(Some(SessionManagerEvent::decode(buf))),
253 None => std::task::Poll::Ready(None),
254 }
255 }
256}
257
258#[derive(Debug)]
259pub enum SessionManagerEvent {}
260
261impl SessionManagerEvent {
262 fn decode(
264 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
265 ) -> Result<SessionManagerEvent, fidl::Error> {
266 let (bytes, _handles) = buf.split_mut();
267 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
268 debug_assert_eq!(tx_header.tx_id, 0);
269 match tx_header.ordinal {
270 _ => Err(fidl::Error::UnknownOrdinal {
271 ordinal: tx_header.ordinal,
272 protocol_name:
273 <SessionManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
274 }),
275 }
276 }
277}
278
279pub struct SessionManagerRequestStream {
281 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
282 is_terminated: bool,
283}
284
285impl std::marker::Unpin for SessionManagerRequestStream {}
286
287impl futures::stream::FusedStream for SessionManagerRequestStream {
288 fn is_terminated(&self) -> bool {
289 self.is_terminated
290 }
291}
292
293impl fidl::endpoints::RequestStream for SessionManagerRequestStream {
294 type Protocol = SessionManagerMarker;
295 type ControlHandle = SessionManagerControlHandle;
296
297 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
298 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
299 }
300
301 fn control_handle(&self) -> Self::ControlHandle {
302 SessionManagerControlHandle { inner: self.inner.clone() }
303 }
304
305 fn into_inner(
306 self,
307 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
308 {
309 (self.inner, self.is_terminated)
310 }
311
312 fn from_inner(
313 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
314 is_terminated: bool,
315 ) -> Self {
316 Self { inner, is_terminated }
317 }
318}
319
320impl futures::Stream for SessionManagerRequestStream {
321 type Item = Result<SessionManagerRequest, fidl::Error>;
322
323 fn poll_next(
324 mut self: std::pin::Pin<&mut Self>,
325 cx: &mut std::task::Context<'_>,
326 ) -> std::task::Poll<Option<Self::Item>> {
327 let this = &mut *self;
328 if this.inner.check_shutdown(cx) {
329 this.is_terminated = true;
330 return std::task::Poll::Ready(None);
331 }
332 if this.is_terminated {
333 panic!("polled SessionManagerRequestStream after completion");
334 }
335 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
336 |bytes, handles| {
337 match this.inner.channel().read_etc(cx, bytes, handles) {
338 std::task::Poll::Ready(Ok(())) => {}
339 std::task::Poll::Pending => return std::task::Poll::Pending,
340 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
341 this.is_terminated = true;
342 return std::task::Poll::Ready(None);
343 }
344 std::task::Poll::Ready(Err(e)) => {
345 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
346 e.into(),
347 ))));
348 }
349 }
350
351 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
353
354 std::task::Poll::Ready(Some(match header.ordinal {
355 0x70a8a74a19cc4b52 => {
356 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
357 let mut req = fidl::new_empty!(
358 SessionManagerCreateSessionRequest,
359 fidl::encoding::DefaultFuchsiaResourceDialect
360 );
361 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionManagerCreateSessionRequest>(&header, _body_bytes, handles, &mut req)?;
362 let control_handle =
363 SessionManagerControlHandle { inner: this.inner.clone() };
364 Ok(SessionManagerRequest::CreateSession {
365 session: req.session,
366
367 control_handle,
368 })
369 }
370 0x723fdb4c1469fa36 => {
371 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
372 let mut req = fidl::new_empty!(
373 fidl::encoding::EmptyPayload,
374 fidl::encoding::DefaultFuchsiaResourceDialect
375 );
376 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
377 let control_handle =
378 SessionManagerControlHandle { inner: this.inner.clone() };
379 Ok(SessionManagerRequest::HasPrimaryConnected {
380 responder: SessionManagerHasPrimaryConnectedResponder {
381 control_handle: std::mem::ManuallyDrop::new(control_handle),
382 tx_id: header.tx_id,
383 },
384 })
385 }
386 _ => Err(fidl::Error::UnknownOrdinal {
387 ordinal: header.ordinal,
388 protocol_name:
389 <SessionManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
390 }),
391 }))
392 },
393 )
394 }
395}
396
397#[derive(Debug)]
399pub enum SessionManagerRequest {
400 CreateSession {
402 session: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
403 control_handle: SessionManagerControlHandle,
404 },
405 HasPrimaryConnected { responder: SessionManagerHasPrimaryConnectedResponder },
407}
408
409impl SessionManagerRequest {
410 #[allow(irrefutable_let_patterns)]
411 pub fn into_create_session(
412 self,
413 ) -> Option<(
414 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
415 SessionManagerControlHandle,
416 )> {
417 if let SessionManagerRequest::CreateSession { session, control_handle } = self {
418 Some((session, control_handle))
419 } else {
420 None
421 }
422 }
423
424 #[allow(irrefutable_let_patterns)]
425 pub fn into_has_primary_connected(
426 self,
427 ) -> Option<(SessionManagerHasPrimaryConnectedResponder)> {
428 if let SessionManagerRequest::HasPrimaryConnected { responder } = self {
429 Some((responder))
430 } else {
431 None
432 }
433 }
434
435 pub fn method_name(&self) -> &'static str {
437 match *self {
438 SessionManagerRequest::CreateSession { .. } => "create_session",
439 SessionManagerRequest::HasPrimaryConnected { .. } => "has_primary_connected",
440 }
441 }
442}
443
444#[derive(Debug, Clone)]
445pub struct SessionManagerControlHandle {
446 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
447}
448
449impl fidl::endpoints::ControlHandle for SessionManagerControlHandle {
450 fn shutdown(&self) {
451 self.inner.shutdown()
452 }
453
454 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
455 self.inner.shutdown_with_epitaph(status)
456 }
457
458 fn is_closed(&self) -> bool {
459 self.inner.channel().is_closed()
460 }
461 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
462 self.inner.channel().on_closed()
463 }
464
465 #[cfg(target_os = "fuchsia")]
466 fn signal_peer(
467 &self,
468 clear_mask: zx::Signals,
469 set_mask: zx::Signals,
470 ) -> Result<(), zx_status::Status> {
471 use fidl::Peered;
472 self.inner.channel().signal_peer(clear_mask, set_mask)
473 }
474}
475
476impl SessionManagerControlHandle {}
477
478#[must_use = "FIDL methods require a response to be sent"]
479#[derive(Debug)]
480pub struct SessionManagerHasPrimaryConnectedResponder {
481 control_handle: std::mem::ManuallyDrop<SessionManagerControlHandle>,
482 tx_id: u32,
483}
484
485impl std::ops::Drop for SessionManagerHasPrimaryConnectedResponder {
489 fn drop(&mut self) {
490 self.control_handle.shutdown();
491 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
493 }
494}
495
496impl fidl::endpoints::Responder for SessionManagerHasPrimaryConnectedResponder {
497 type ControlHandle = SessionManagerControlHandle;
498
499 fn control_handle(&self) -> &SessionManagerControlHandle {
500 &self.control_handle
501 }
502
503 fn drop_without_shutdown(mut self) {
504 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
506 std::mem::forget(self);
508 }
509}
510
511impl SessionManagerHasPrimaryConnectedResponder {
512 pub fn send(self, mut connected: bool) -> Result<(), fidl::Error> {
516 let _result = self.send_raw(connected);
517 if _result.is_err() {
518 self.control_handle.shutdown();
519 }
520 self.drop_without_shutdown();
521 _result
522 }
523
524 pub fn send_no_shutdown_on_err(self, mut connected: bool) -> Result<(), fidl::Error> {
526 let _result = self.send_raw(connected);
527 self.drop_without_shutdown();
528 _result
529 }
530
531 fn send_raw(&self, mut connected: bool) -> Result<(), fidl::Error> {
532 self.control_handle.inner.send::<SessionManagerHasPrimaryConnectedResponse>(
533 (connected,),
534 self.tx_id,
535 0x723fdb4c1469fa36,
536 fidl::encoding::DynamicFlags::empty(),
537 )
538 }
539}
540
541mod internal {
542 use super::*;
543
544 impl fidl::encoding::ResourceTypeMarker for SessionManagerCreateSessionRequest {
545 type Borrowed<'a> = &'a mut Self;
546 fn take_or_borrow<'a>(
547 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
548 ) -> Self::Borrowed<'a> {
549 value
550 }
551 }
552
553 unsafe impl fidl::encoding::TypeMarker for SessionManagerCreateSessionRequest {
554 type Owned = Self;
555
556 #[inline(always)]
557 fn inline_align(_context: fidl::encoding::Context) -> usize {
558 4
559 }
560
561 #[inline(always)]
562 fn inline_size(_context: fidl::encoding::Context) -> usize {
563 4
564 }
565 }
566
567 unsafe impl
568 fidl::encoding::Encode<
569 SessionManagerCreateSessionRequest,
570 fidl::encoding::DefaultFuchsiaResourceDialect,
571 > for &mut SessionManagerCreateSessionRequest
572 {
573 #[inline]
574 unsafe fn encode(
575 self,
576 encoder: &mut fidl::encoding::Encoder<
577 '_,
578 fidl::encoding::DefaultFuchsiaResourceDialect,
579 >,
580 offset: usize,
581 _depth: fidl::encoding::Depth,
582 ) -> fidl::Result<()> {
583 encoder.debug_check_bounds::<SessionManagerCreateSessionRequest>(offset);
584 fidl::encoding::Encode::<
586 SessionManagerCreateSessionRequest,
587 fidl::encoding::DefaultFuchsiaResourceDialect,
588 >::encode(
589 (<fidl::encoding::Endpoint<
590 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
591 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
592 &mut self.session
593 ),),
594 encoder,
595 offset,
596 _depth,
597 )
598 }
599 }
600 unsafe impl<
601 T0: fidl::encoding::Encode<
602 fidl::encoding::Endpoint<
603 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
604 >,
605 fidl::encoding::DefaultFuchsiaResourceDialect,
606 >,
607 >
608 fidl::encoding::Encode<
609 SessionManagerCreateSessionRequest,
610 fidl::encoding::DefaultFuchsiaResourceDialect,
611 > for (T0,)
612 {
613 #[inline]
614 unsafe fn encode(
615 self,
616 encoder: &mut fidl::encoding::Encoder<
617 '_,
618 fidl::encoding::DefaultFuchsiaResourceDialect,
619 >,
620 offset: usize,
621 depth: fidl::encoding::Depth,
622 ) -> fidl::Result<()> {
623 encoder.debug_check_bounds::<SessionManagerCreateSessionRequest>(offset);
624 self.0.encode(encoder, offset + 0, depth)?;
628 Ok(())
629 }
630 }
631
632 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
633 for SessionManagerCreateSessionRequest
634 {
635 #[inline(always)]
636 fn new_empty() -> Self {
637 Self {
638 session: fidl::new_empty!(
639 fidl::encoding::Endpoint<
640 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
641 >,
642 fidl::encoding::DefaultFuchsiaResourceDialect
643 ),
644 }
645 }
646
647 #[inline]
648 unsafe fn decode(
649 &mut self,
650 decoder: &mut fidl::encoding::Decoder<
651 '_,
652 fidl::encoding::DefaultFuchsiaResourceDialect,
653 >,
654 offset: usize,
655 _depth: fidl::encoding::Depth,
656 ) -> fidl::Result<()> {
657 decoder.debug_check_bounds::<Self>(offset);
658 fidl::decode!(
660 fidl::encoding::Endpoint<
661 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
662 >,
663 fidl::encoding::DefaultFuchsiaResourceDialect,
664 &mut self.session,
665 decoder,
666 offset + 0,
667 _depth
668 )?;
669 Ok(())
670 }
671 }
672}