Struct fidl::handle::AsyncSocket
pub struct AsyncSocket(/* private fields */);
Expand description
An I/O object representing a Socket
.
Implementations§
§impl Socket
impl Socket
pub fn from_socket(socket: Socket) -> Socket
pub fn from_socket(socket: Socket) -> Socket
Create a new Socket
from a previously-created zx::Socket
.
§Panics
If called outside the context of an active async executor.
pub fn into_zx_socket(self) -> Socket
pub fn into_zx_socket(self) -> Socket
Consumes self
and returns the underlying zx::Socket
.
pub fn on_closed(&self) -> OnSignals<'_, Unowned<'_, Handle>> ⓘ
pub fn on_closed(&self) -> OnSignals<'_, Unowned<'_, Handle>> ⓘ
Returns a future that completes when the socket received the OBJECT_PEER_CLOSED
signal.
pub fn poll_read_ref(
&self,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<usize, Status>>
pub fn poll_read_ref( &self, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<usize, Status>>
Attempt to read from the socket, registering for wakeup if the socket doesn’t have any
contents available. Used internally in the AsyncRead
implementation, exposed for users
who know the concrete type they’re using and don’t want to pin the socket.
pub fn poll_write_ref(
&self,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Status>>
pub fn poll_write_ref( &self, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Status>>
Attempt to write into the socket, registering for wakeup if the socket is not ready. Used
internally in the AsyncWrite
implementation, exposed for users who know the concrete type
they’re using and don’t want to pin the socket.
pub fn poll_datagram(
&self,
cx: &mut Context<'_>,
out: &mut Vec<u8>,
) -> Poll<Result<usize, Status>>
pub fn poll_datagram( &self, cx: &mut Context<'_>, out: &mut Vec<u8>, ) -> Poll<Result<usize, Status>>
Polls for the next data on the socket, appending it to the end of |out| if it has arrived. Not very useful for a non-datagram socket as it will return all available data on the socket.
pub async fn read_datagram<'a>(
&'a self,
out: &'a mut Vec<u8>,
) -> Result<usize, Status>
pub async fn read_datagram<'a>( &'a self, out: &'a mut Vec<u8>, ) -> Result<usize, Status>
Reads the next datagram that becomes available onto the end of |out|. Note: Using this multiple times concurrently is an error and the first one will never complete.
pub fn as_datagram_stream<'a>(&'a self) -> DatagramStream<&'a Socket>
pub fn as_datagram_stream<'a>(&'a self) -> DatagramStream<&'a Socket>
Use this socket as a stream of Result<Vec<u8>, zx::Status>
datagrams.
Note: multiple concurrent streams from the same socket are not supported.
pub fn into_datagram_stream(self) -> DatagramStream<Socket>
pub fn into_datagram_stream(self) -> DatagramStream<Socket>
Convert this socket into a stream of Result<Vec<u8>, zx::Status>
datagrams.
Trait Implementations§
§impl AsHandleRef for Socket
impl AsHandleRef for Socket
§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.source§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
source§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
source§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> Result<Signals, Status>
source§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
source§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
source§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
source§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
source§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
§impl<'a> AsyncRead for &'a Socket
impl<'a> AsyncRead for &'a Socket
§impl AsyncRead for Socket
impl AsyncRead for Socket
§impl<'a> AsyncWrite for &'a Socket
impl<'a> AsyncWrite for &'a Socket
§fn poll_write(
self: Pin<&mut &'a Socket>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut &'a Socket>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf
into the object. Read more§fn poll_flush(
self: Pin<&mut &'a Socket>,
_: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut &'a Socket>, _: &mut Context<'_>, ) -> Poll<Result<(), Error>>
§impl AsyncWrite for Socket
impl AsyncWrite for Socket
§fn poll_write(
self: Pin<&mut Socket>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Socket>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf
into the object. Read more§fn poll_flush(
self: Pin<&mut Socket>,
_: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Socket>, _: &mut Context<'_>, ) -> Poll<Result<(), Error>>
§impl ReadableHandle for Socket
impl ReadableHandle for Socket
§fn poll_readable(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<ReadableState, Status>>
fn poll_readable( &self, cx: &mut Context<'_>, ) -> Poll<Result<ReadableState, Status>>
Ready
with the readable
state. If the implementor returns Pending, it should first ensure that
need_readable
is called. Read more§fn need_readable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
fn need_readable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
OBJECT_READABLE
or OBJECT_PEER_CLOSED
signal. This can return
Poll::Ready if the object has already been signaled in which case the
waker will not be woken and it is the caller’s responsibility to not
lose the signal.§impl WritableHandle for Socket
impl WritableHandle for Socket
§fn poll_writable(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<WritableState, Status>>
fn poll_writable( &self, cx: &mut Context<'_>, ) -> Poll<Result<WritableState, Status>>
Ready
with the writable
state. If the implementor returns Pending, it should first ensure that
need_writable
is called. Read more§fn need_writable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
fn need_writable(&self, cx: &mut Context<'_>) -> Poll<Result<(), Status>>
OBJECT_WRITABLE
or OBJECT_PEER_CLOSED
signal. This can return
Poll::Ready if the object has already been signaled in which case the
waker will not be woken and it is the caller’s responsibility to not
lose the signal.Auto Trait Implementations§
impl Freeze for Socket
impl !RefUnwindSafe for Socket
impl Send for Socket
impl Sync for Socket
impl Unpin for Socket
impl !UnwindSafe for Socket
Blanket Implementations§
§impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere
R: AsyncRead + ?Sized,
§fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R>where
Self: Sized,
R: AsyncRead,
§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> Read<'a, Self>where
Self: Unpin,
buf
in asynchronous
manner, returning a future type. Read more§fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
fn read_vectored<'a>(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>],
) -> ReadVectored<'a, Self>where
Self: Unpin,
AsyncRead
into bufs
using vectored
IO operations. Read more§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExact<'a, Self>where
Self: Unpin,
buf
,
returning an error if end of file (EOF) is hit sooner. Read more§fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
fn read_to_end<'a>(&'a mut self, buf: &'a mut Vec<u8>) -> ReadToEnd<'a, Self>where
Self: Unpin,
AsyncRead
. Read more§fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
fn read_to_string<'a>(
&'a mut self,
buf: &'a mut String,
) -> ReadToString<'a, Self>where
Self: Unpin,
AsyncRead
. Read more§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
§fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self>where
Self: Unpin,
AsyncWrite
. Read more§fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
fn close(&mut self) -> Close<'_, Self>where
Self: Unpin,
AsyncWrite
.§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self>where
Self: Unpin,
buf
into the object. Read more§fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
fn write_vectored<'a>(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> WriteVectored<'a, Self>where
Self: Unpin,
bufs
into the object using vectored
IO operations. Read more