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