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