| // WARNING: This file is machine generated by fidlgen. |
| |
| #![allow( |
| unused_parens, // one-element-tuple-case is not a tuple |
| unused_mut, // not all args require mutation, but many do |
| nonstandard_style, // auto-caps does its best, but is not always successful |
| )] |
| #![recursion_limit = "512"] |
| |
| #[cfg(target_os = "fuchsia")] |
| #[allow(unused_imports)] |
| use fuchsia_zircon as zx; |
| |
| #[allow(unused_imports)] |
| use { |
| bitflags::bitflags, |
| fidl::{ |
| client::{decode_transaction_body_fut, QueryResponseFut}, |
| encoding::{Decodable as _, Encodable as _}, |
| fidl_empty_struct, fidl_flexible_bits, fidl_flexible_enum, fidl_strict_bits, |
| fidl_strict_enum, fidl_struct, fidl_struct_copy, fidl_table, fidl_xunion, |
| wrap_handle_metadata, |
| }, |
| fuchsia_zircon_status as zx_status, |
| futures::future::{self, MaybeDone, TryFutureExt}, |
| }; |
| |
| const _FIDL_TRACE_BINDINGS_RUST: u32 = 6; |
| |
| #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| pub struct Testing { |
| pub u1: u64, |
| pub u2: Vec<u64>, |
| pub u3: [u64; 1], |
| pub u4: Vec<Vec<u64>>, |
| pub u5: Vec<[u64; 1]>, |
| pub u6: [Vec<u64>; 4], |
| pub u7: [[u64; 1]; 4], |
| pub v1: Option<Vec<u64>>, |
| pub v2: Vec<Option<Vec<u64>>>, |
| pub v3: [Option<Vec<u64>>; 4], |
| pub a1: [u64; 1], |
| pub a2: Vec<[u64; 1]>, |
| pub a3: [[u64; 1]; 4], |
| pub p1: fidl::endpoints::ServerEnd<MyProtocolMarker>, |
| pub p2: Vec<fidl::endpoints::ServerEnd<MyProtocolMarker>>, |
| pub p3: [fidl::endpoints::ServerEnd<MyProtocolMarker>; 4], |
| pub r1: Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>, |
| pub r2: Vec<Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>>, |
| pub r3: [Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>; 4], |
| pub b1: Vec<u8>, |
| pub b2: Vec<Vec<u8>>, |
| pub b3: [Vec<u8>; 4], |
| pub s1: String, |
| pub s2: Vec<String>, |
| pub s3: [String; 4], |
| pub vv1: Vec<u64>, |
| pub vv2: Vec<Vec<u64>>, |
| pub vv3: [Vec<u64>; 3], |
| pub aa1: [u64; 2], |
| pub aa2: Vec<[u64; 2]>, |
| pub aa3: [[u64; 2]; 3], |
| pub rr1: fidl::endpoints::ServerEnd<MyProtocolMarker>, |
| pub rr2: Vec<fidl::endpoints::ServerEnd<MyProtocolMarker>>, |
| pub rr3: [fidl::endpoints::ServerEnd<MyProtocolMarker>; 3], |
| } |
| |
| fidl_struct! { |
| name: Testing, |
| members: [ |
| u1 { |
| ty: u64, |
| offset_v1: 0, |
| }, |
| u2 { |
| ty: Vec<u64>, |
| offset_v1: 8, |
| }, |
| u3 { |
| ty: [u64; 1], |
| offset_v1: 24, |
| }, |
| u4 { |
| ty: Vec<Vec<u64>>, |
| offset_v1: 32, |
| }, |
| u5 { |
| ty: Vec<[u64; 1]>, |
| offset_v1: 48, |
| }, |
| u6 { |
| ty: [Vec<u64>; 4], |
| offset_v1: 64, |
| }, |
| u7 { |
| ty: [[u64; 1]; 4], |
| offset_v1: 128, |
| }, |
| v1 { |
| ty: Option<Vec<u64>>, |
| offset_v1: 160, |
| }, |
| v2 { |
| ty: Vec<Option<Vec<u64>>>, |
| offset_v1: 176, |
| }, |
| v3 { |
| ty: [Option<Vec<u64>>; 4], |
| offset_v1: 192, |
| }, |
| a1 { |
| ty: [u64; 1], |
| offset_v1: 256, |
| }, |
| a2 { |
| ty: Vec<[u64; 1]>, |
| offset_v1: 264, |
| }, |
| a3 { |
| ty: [[u64; 1]; 4], |
| offset_v1: 280, |
| }, |
| p1 { |
| ty: fidl::endpoints::ServerEnd<MyProtocolMarker>, |
| offset_v1: 312, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| p2 { |
| ty: Vec<fidl::endpoints::ServerEnd<MyProtocolMarker>>, |
| offset_v1: 320, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| p3 { |
| ty: [fidl::endpoints::ServerEnd<MyProtocolMarker>; 4], |
| offset_v1: 336, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| r1 { |
| ty: Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>, |
| offset_v1: 352, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| r2 { |
| ty: Vec<Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>>, |
| offset_v1: 360, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| r3 { |
| ty: [Option<fidl::endpoints::ServerEnd<MyProtocolMarker>>; 4], |
| offset_v1: 376, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| b1 { |
| ty: Vec<u8>, |
| offset_v1: 392, |
| }, |
| b2 { |
| ty: Vec<Vec<u8>>, |
| offset_v1: 408, |
| }, |
| b3 { |
| ty: [Vec<u8>; 4], |
| offset_v1: 424, |
| }, |
| s1 { |
| ty: String, |
| offset_v1: 488, |
| }, |
| s2 { |
| ty: Vec<String>, |
| offset_v1: 504, |
| }, |
| s3 { |
| ty: [String; 4], |
| offset_v1: 520, |
| }, |
| vv1 { |
| ty: Vec<u64>, |
| offset_v1: 584, |
| }, |
| vv2 { |
| ty: Vec<Vec<u64>>, |
| offset_v1: 600, |
| }, |
| vv3 { |
| ty: [Vec<u64>; 3], |
| offset_v1: 616, |
| }, |
| aa1 { |
| ty: [u64; 2], |
| offset_v1: 664, |
| }, |
| aa2 { |
| ty: Vec<[u64; 2]>, |
| offset_v1: 680, |
| }, |
| aa3 { |
| ty: [[u64; 2]; 3], |
| offset_v1: 696, |
| }, |
| rr1 { |
| ty: fidl::endpoints::ServerEnd<MyProtocolMarker>, |
| offset_v1: 744, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| rr2 { |
| ty: Vec<fidl::endpoints::ServerEnd<MyProtocolMarker>>, |
| offset_v1: 752, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| rr3 { |
| ty: [fidl::endpoints::ServerEnd<MyProtocolMarker>; 3], |
| offset_v1: 768, |
| handle_metadata: { |
| handle_subtype: fidl::ObjectType::CHANNEL, |
| handle_rights: fidl::Rights::CHANNEL_DEFAULT, |
| }, |
| }, |
| ], |
| padding: [ |
| { |
| ty: u64, |
| offset: 312, |
| mask: 0xffffffff00000000u64, |
| }, |
| { |
| ty: u64, |
| offset: 352, |
| mask: 0xffffffff00000000u64, |
| }, |
| { |
| ty: u64, |
| offset: 744, |
| mask: 0xffffffff00000000u64, |
| }, |
| { |
| ty: u64, |
| offset: 776, |
| mask: 0xffffffff00000000u64, |
| },], |
| size_v1: 784, |
| align_v1: 8, |
| } |
| |
| #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| pub struct MyProtocolMarker; |
| |
| impl fidl::endpoints::ServiceMarker for MyProtocolMarker { |
| type Proxy = MyProtocolProxy; |
| type RequestStream = MyProtocolRequestStream; |
| const DEBUG_NAME: &'static str = "(anonymous) MyProtocol"; |
| } |
| |
| pub trait MyProtocolProxyInterface: Send + Sync {} |
| |
| #[derive(Debug)] |
| #[cfg(target_os = "fuchsia")] |
| pub struct MyProtocolSynchronousProxy { |
| client: fidl::client::sync::Client, |
| } |
| |
| #[cfg(target_os = "fuchsia")] |
| impl MyProtocolSynchronousProxy { |
| pub fn new(channel: fidl::Channel) -> Self { |
| let service_name = <MyProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME; |
| Self { client: fidl::client::sync::Client::new(channel, service_name) } |
| } |
| |
| pub fn into_channel(self) -> fidl::Channel { |
| self.client.into_channel() |
| } |
| } |
| |
| #[derive(Debug, Clone)] |
| pub struct MyProtocolProxy { |
| client: fidl::client::Client, |
| } |
| |
| impl fidl::endpoints::Proxy for MyProtocolProxy { |
| type Service = MyProtocolMarker; |
| |
| fn from_channel(inner: fidl::AsyncChannel) -> Self { |
| Self::new(inner) |
| } |
| |
| fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> { |
| self.client.into_channel().map_err(|client| Self { client }) |
| } |
| |
| fn as_channel(&self) -> &::fidl::AsyncChannel { |
| self.client.as_channel() |
| } |
| } |
| |
| impl MyProtocolProxy { |
| /// Create a new Proxy for MyProtocol |
| pub fn new(channel: fidl::AsyncChannel) -> Self { |
| let service_name = <MyProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME; |
| Self { client: fidl::client::Client::new(channel, service_name) } |
| } |
| |
| /// Get a Stream of events from the remote end of the MyProtocol protocol |
| /// |
| /// # Panics |
| /// |
| /// Panics if the event stream was already taken. |
| pub fn take_event_stream(&self) -> MyProtocolEventStream { |
| MyProtocolEventStream { event_receiver: self.client.take_event_receiver() } |
| } |
| } |
| |
| impl MyProtocolProxyInterface for MyProtocolProxy {} |
| |
| pub struct MyProtocolEventStream { |
| event_receiver: fidl::client::EventReceiver, |
| } |
| |
| impl std::marker::Unpin for MyProtocolEventStream {} |
| |
| impl futures::stream::FusedStream for MyProtocolEventStream { |
| fn is_terminated(&self) -> bool { |
| self.event_receiver.is_terminated() |
| } |
| } |
| |
| impl futures::Stream for MyProtocolEventStream { |
| type Item = Result<MyProtocolEvent, fidl::Error>; |
| |
| fn poll_next( |
| mut self: std::pin::Pin<&mut Self>, |
| cx: &mut std::task::Context<'_>, |
| ) -> std::task::Poll<Option<Self::Item>> { |
| let mut buf = match futures::ready!(futures::stream::StreamExt::poll_next_unpin( |
| &mut self.event_receiver, |
| cx |
| )?) { |
| Some(buf) => buf, |
| None => return std::task::Poll::Ready(None), |
| }; |
| let (bytes, _handles) = buf.split_mut(); |
| let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?; |
| |
| std::task::Poll::Ready(Some(match tx_header.ordinal() { |
| _ => Err(fidl::Error::UnknownOrdinal { |
| ordinal: tx_header.ordinal(), |
| service_name: <MyProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME, |
| }), |
| })) |
| } |
| } |
| |
| #[derive(Debug)] |
| pub enum MyProtocolEvent {} |
| |
| impl MyProtocolEvent {} |
| |
| /// A type which can be used to send responses and events into a borrowed channel. |
| /// |
| /// Note: this should only be used when the channel must be temporarily |
| /// borrowed. For a typical sending of events, use the send_ methods |
| /// on the ControlHandle types, which can be acquired through a |
| /// RequestStream or Responder type. |
| #[deprecated(note = "Use MyProtocolRequestStream / Responder instead")] |
| pub struct MyProtocolServerSender<'a> { |
| // Some protocols don't define events which would render this channel unused. |
| #[allow(dead_code)] |
| channel: &'a fidl::Channel, |
| } |
| |
| #[allow(deprecated)] |
| impl<'a> MyProtocolServerSender<'a> { |
| pub fn new(channel: &'a fidl::Channel) -> Self { |
| Self { channel } |
| } |
| } |
| |
| /// A Stream of incoming requests for MyProtocol |
| pub struct MyProtocolRequestStream { |
| inner: std::sync::Arc<fidl::ServeInner>, |
| is_terminated: bool, |
| } |
| |
| impl std::marker::Unpin for MyProtocolRequestStream {} |
| |
| impl futures::stream::FusedStream for MyProtocolRequestStream { |
| fn is_terminated(&self) -> bool { |
| self.is_terminated |
| } |
| } |
| |
| impl fidl::endpoints::RequestStream for MyProtocolRequestStream { |
| type Service = MyProtocolMarker; |
| |
| /// Consume a channel to make a MyProtocolRequestStream |
| fn from_channel(channel: fidl::AsyncChannel) -> Self { |
| Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false } |
| } |
| |
| /// ControlHandle for the remote connection |
| type ControlHandle = MyProtocolControlHandle; |
| |
| /// ControlHandle for the remote connection |
| fn control_handle(&self) -> Self::ControlHandle { |
| MyProtocolControlHandle { inner: self.inner.clone() } |
| } |
| |
| fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) { |
| (self.inner, self.is_terminated) |
| } |
| |
| fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self { |
| Self { inner, is_terminated } |
| } |
| } |
| |
| impl futures::Stream for MyProtocolRequestStream { |
| type Item = Result<MyProtocolRequest, fidl::Error>; |
| |
| fn poll_next( |
| mut self: std::pin::Pin<&mut Self>, |
| cx: &mut std::task::Context<'_>, |
| ) -> std::task::Poll<Option<Self::Item>> { |
| let this = &mut *self; |
| if this.inner.poll_shutdown(cx) { |
| this.is_terminated = true; |
| return std::task::Poll::Ready(None); |
| } |
| if this.is_terminated { |
| panic!("polled MyProtocolRequestStream after completion"); |
| } |
| fidl::encoding::with_tls_decode_buf(|bytes, handles| { |
| match this.inner.channel().read_etc(cx, bytes, handles) { |
| std::task::Poll::Ready(Ok(())) => {} |
| std::task::Poll::Pending => return std::task::Poll::Pending, |
| std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => { |
| this.is_terminated = true; |
| return std::task::Poll::Ready(None); |
| } |
| std::task::Poll::Ready(Err(e)) => { |
| return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e)))) |
| } |
| } |
| |
| // A message has been received from the channel |
| let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?; |
| if !header.is_compatible() { |
| return std::task::Poll::Ready(Some(Err(fidl::Error::IncompatibleMagicNumber( |
| header.magic_number(), |
| )))); |
| } |
| |
| std::task::Poll::Ready(Some(match header.ordinal() { |
| _ => Err(fidl::Error::UnknownOrdinal { |
| ordinal: header.ordinal(), |
| service_name: <MyProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME, |
| }), |
| })) |
| }) |
| } |
| } |
| |
| /// Represents a single request. |
| /// RequestMessages should only be used for manual deserialization when higher level |
| /// structs such as RequestStream cannot be used. One usually would only encounter |
| /// such scenarios when working with legacy FIDL code (prior to FIDL generated client/server bindings). |
| #[derive(Debug)] |
| #[deprecated(note = "Use MyProtocolRequest instead")] |
| pub enum MyProtocolRequestMessage {} |
| |
| #[allow(deprecated)] |
| impl MyProtocolRequestMessage { |
| pub fn decode( |
| bytes: &[u8], |
| _handles: &mut [fidl::HandleInfo], |
| ) -> Result<MyProtocolRequestMessage, fidl::Error> { |
| let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?; |
| |
| match header.ordinal() { |
| _ => Err(fidl::Error::UnknownOrdinal { |
| ordinal: header.ordinal(), |
| service_name: <MyProtocolMarker as fidl::endpoints::ServiceMarker>::DEBUG_NAME, |
| }), |
| } |
| } |
| } |
| #[derive(Debug)] |
| pub enum MyProtocolRequest {} |
| |
| impl MyProtocolRequest { |
| /// Name of the method defined in FIDL |
| pub fn method_name(&self) -> &'static str { |
| match *self {} |
| } |
| } |
| |
| pub struct MyProtocolEncoder; |
| |
| impl MyProtocolEncoder {} |
| |
| #[derive(Debug, Clone)] |
| pub struct MyProtocolControlHandle { |
| inner: std::sync::Arc<fidl::ServeInner>, |
| } |
| |
| impl MyProtocolControlHandle { |
| /// Set the server to shutdown. The underlying channel is only closed the |
| /// next time the stream is polled. |
| pub fn shutdown(&self) { |
| self.inner.shutdown() |
| } |
| |
| pub fn shutdown_with_epitaph(&self, status: zx_status::Status) { |
| self.inner.shutdown_with_epitaph(status) |
| } |
| } |