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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
454 self.inner.shutdown_with_epitaph(status)
455 }
456
457 fn is_closed(&self) -> bool {
458 self.inner.channel().is_closed()
459 }
460 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
461 self.inner.channel().on_closed()
462 }
463
464 #[cfg(target_os = "fuchsia")]
465 fn signal_peer(
466 &self,
467 clear_mask: zx::Signals,
468 set_mask: zx::Signals,
469 ) -> Result<(), zx_status::Status> {
470 use fidl::Peered;
471 self.inner.channel().signal_peer(clear_mask, set_mask)
472 }
473}
474
475impl SessionManagerControlHandle {}
476
477#[must_use = "FIDL methods require a response to be sent"]
478#[derive(Debug)]
479pub struct SessionManagerHasPrimaryConnectedResponder {
480 control_handle: std::mem::ManuallyDrop<SessionManagerControlHandle>,
481 tx_id: u32,
482}
483
484impl std::ops::Drop for SessionManagerHasPrimaryConnectedResponder {
488 fn drop(&mut self) {
489 self.control_handle.shutdown();
490 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
492 }
493}
494
495impl fidl::endpoints::Responder for SessionManagerHasPrimaryConnectedResponder {
496 type ControlHandle = SessionManagerControlHandle;
497
498 fn control_handle(&self) -> &SessionManagerControlHandle {
499 &self.control_handle
500 }
501
502 fn drop_without_shutdown(mut self) {
503 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
505 std::mem::forget(self);
507 }
508}
509
510impl SessionManagerHasPrimaryConnectedResponder {
511 pub fn send(self, mut connected: bool) -> Result<(), fidl::Error> {
515 let _result = self.send_raw(connected);
516 if _result.is_err() {
517 self.control_handle.shutdown();
518 }
519 self.drop_without_shutdown();
520 _result
521 }
522
523 pub fn send_no_shutdown_on_err(self, mut connected: bool) -> Result<(), fidl::Error> {
525 let _result = self.send_raw(connected);
526 self.drop_without_shutdown();
527 _result
528 }
529
530 fn send_raw(&self, mut connected: bool) -> Result<(), fidl::Error> {
531 self.control_handle.inner.send::<SessionManagerHasPrimaryConnectedResponse>(
532 (connected,),
533 self.tx_id,
534 0x723fdb4c1469fa36,
535 fidl::encoding::DynamicFlags::empty(),
536 )
537 }
538}
539
540mod internal {
541 use super::*;
542
543 impl fidl::encoding::ResourceTypeMarker for SessionManagerCreateSessionRequest {
544 type Borrowed<'a> = &'a mut Self;
545 fn take_or_borrow<'a>(
546 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
547 ) -> Self::Borrowed<'a> {
548 value
549 }
550 }
551
552 unsafe impl fidl::encoding::TypeMarker for SessionManagerCreateSessionRequest {
553 type Owned = Self;
554
555 #[inline(always)]
556 fn inline_align(_context: fidl::encoding::Context) -> usize {
557 4
558 }
559
560 #[inline(always)]
561 fn inline_size(_context: fidl::encoding::Context) -> usize {
562 4
563 }
564 }
565
566 unsafe impl
567 fidl::encoding::Encode<
568 SessionManagerCreateSessionRequest,
569 fidl::encoding::DefaultFuchsiaResourceDialect,
570 > for &mut SessionManagerCreateSessionRequest
571 {
572 #[inline]
573 unsafe fn encode(
574 self,
575 encoder: &mut fidl::encoding::Encoder<
576 '_,
577 fidl::encoding::DefaultFuchsiaResourceDialect,
578 >,
579 offset: usize,
580 _depth: fidl::encoding::Depth,
581 ) -> fidl::Result<()> {
582 encoder.debug_check_bounds::<SessionManagerCreateSessionRequest>(offset);
583 fidl::encoding::Encode::<
585 SessionManagerCreateSessionRequest,
586 fidl::encoding::DefaultFuchsiaResourceDialect,
587 >::encode(
588 (<fidl::encoding::Endpoint<
589 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
590 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
591 &mut self.session
592 ),),
593 encoder,
594 offset,
595 _depth,
596 )
597 }
598 }
599 unsafe impl<
600 T0: fidl::encoding::Encode<
601 fidl::encoding::Endpoint<
602 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
603 >,
604 fidl::encoding::DefaultFuchsiaResourceDialect,
605 >,
606 >
607 fidl::encoding::Encode<
608 SessionManagerCreateSessionRequest,
609 fidl::encoding::DefaultFuchsiaResourceDialect,
610 > for (T0,)
611 {
612 #[inline]
613 unsafe fn encode(
614 self,
615 encoder: &mut fidl::encoding::Encoder<
616 '_,
617 fidl::encoding::DefaultFuchsiaResourceDialect,
618 >,
619 offset: usize,
620 depth: fidl::encoding::Depth,
621 ) -> fidl::Result<()> {
622 encoder.debug_check_bounds::<SessionManagerCreateSessionRequest>(offset);
623 self.0.encode(encoder, offset + 0, depth)?;
627 Ok(())
628 }
629 }
630
631 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
632 for SessionManagerCreateSessionRequest
633 {
634 #[inline(always)]
635 fn new_empty() -> Self {
636 Self {
637 session: fidl::new_empty!(
638 fidl::encoding::Endpoint<
639 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
640 >,
641 fidl::encoding::DefaultFuchsiaResourceDialect
642 ),
643 }
644 }
645
646 #[inline]
647 unsafe fn decode(
648 &mut self,
649 decoder: &mut fidl::encoding::Decoder<
650 '_,
651 fidl::encoding::DefaultFuchsiaResourceDialect,
652 >,
653 offset: usize,
654 _depth: fidl::encoding::Depth,
655 ) -> fidl::Result<()> {
656 decoder.debug_check_bounds::<Self>(offset);
657 fidl::decode!(
659 fidl::encoding::Endpoint<
660 fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_pty::DeviceMarker>,
661 >,
662 fidl::encoding::DefaultFuchsiaResourceDialect,
663 &mut self.session,
664 decoder,
665 offset + 0,
666 _depth
667 )?;
668 Ok(())
669 }
670 }
671}