Struct fuchsia_async::Socket
source · pub struct Socket(/* private fields */);
Expand description
An I/O object representing a Socket
.
Implementations§
source§impl Socket
impl Socket
sourcepub fn from_socket(socket: Socket) -> Result<Self, Status>
pub fn from_socket(socket: Socket) -> Result<Self, Status>
Create a new Socket
from a previously-created zx::Socket
.
sourcepub fn into_zx_socket(self) -> Socket
pub fn into_zx_socket(self) -> Socket
Consumes self
and returns the underlying zx::Socket
.
sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns true if the socket received the OBJECT_PEER_CLOSED
signal.
sourcepub fn on_closed(&self) -> OnSignals<'_> ⓘ
pub fn on_closed(&self) -> OnSignals<'_> ⓘ
Returns a future that completes when the socket received the OBJECT_PEER_CLOSED
signal.
sourcepub 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.
sourcepub 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.
sourcepub 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.
sourcepub 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.
sourcepub fn as_datagram_stream<'a>(&'a self) -> DatagramStream<&'a Self>
pub fn as_datagram_stream<'a>(&'a self) -> DatagramStream<&'a Self>
Use this socket as a stream of Result<Vec<u8>, zx::Status>
datagrams.
Note: multiple concurrent streams from the same socket are not supported.
sourcepub fn into_datagram_stream(self) -> DatagramStream<Self>
pub fn into_datagram_stream(self) -> DatagramStream<Self>
Convert this socket into a stream of Result<Vec<u8>, zx::Status>
datagrams.
Trait Implementations§
source§impl AsHandleRef for Socket
impl AsHandleRef for Socket
source§fn as_handle_ref(&self) -> HandleRef<'_>
fn as_handle_ref(&self) -> HandleRef<'_>
object_wait_many
.§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals ) -> Result<(), Status>
§fn wait_handle(
&self,
signals: Signals,
deadline: Time
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Time ) -> Result<Signals, Status>
§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>
§fn get_name(&self) -> Result<CString, Status>
fn get_name(&self) -> Result<CString, Status>
§fn set_name(&self, name: &CStr) -> Result<(), Status>
fn set_name(&self, name: &CStr) -> Result<(), Status>
§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
source§impl<'a> AsyncRead for &'a Socket
impl<'a> AsyncRead for &'a Socket
source§impl AsyncRead for Socket
impl AsyncRead for Socket
source§impl<'a> AsyncWrite for &'a Socket
impl<'a> AsyncWrite for &'a Socket
source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>
buf
into the object. Read moresource§fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
source§impl AsyncWrite for Socket
impl AsyncWrite for Socket
source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8] ) -> Poll<Result<usize>>
buf
into the object. Read moresource§fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<()>>
source§impl ReadableHandle for Socket
impl ReadableHandle for Socket
source§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 moresource§impl WritableHandle for Socket
impl WritableHandle for Socket
source§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 moreAuto Trait Implementations§
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