pub struct Socket(/* private fields */);Expand description
An object representing a Zircon socket.
As essentially a subtype of Handle, it can be freely interconverted.
Implementations§
Source§impl Socket
impl Socket
Sourcepub fn create() -> Result<(Socket, Socket), Status>
pub fn create() -> Result<(Socket, Socket), Status>
Create a socket, accessed through a pair of endpoints. Data written into one may be read from the other.
Wraps zx_socket_create.
Sourcepub fn write(&self, bytes: &[u8]) -> Result<usize, Status>
pub fn write(&self, bytes: &[u8]) -> Result<usize, Status>
Write the given bytes into the socket. Return value (on success) is number of bytes actually written.
Wraps zx_socket_write.
Sourcepub fn read(&self, bytes: &mut [u8]) -> Result<usize, Status>
pub fn read(&self, bytes: &mut [u8]) -> Result<usize, Status>
Read the given bytes from the socket. Return value (on success) is number of bytes actually read.
Wraps zx_socket_read.
Sourcepub fn half_close(&self) -> Result<(), Status>
pub fn half_close(&self) -> Result<(), Status>
Close half of the socket, so attempts by the other side to write will fail.
Implements the ZX_SOCKET_HALF_CLOSE option of
zx_socket_write.
pub fn outstanding_read_bytes(&self) -> Result<usize, Status>
Trait Implementations§
Source§impl AsHandleRef for Socket
impl AsHandleRef for Socket
Source§fn as_handle_ref(&self) -> HandleRef<'_>
fn as_handle_ref(&self) -> HandleRef<'_>
Get a reference to the handle. One important use of such a reference is
for
object_wait_many.Source§fn raw_handle(&self) -> zx_handle_t
fn raw_handle(&self) -> zx_handle_t
Interpret the reference as a raw handle (an integer type). Two distinct
handles will have different raw values (so it can perhaps be used as a
key in a data structure).
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>
Set and clear userspace-accessible signal bits on an object. Wraps the
zx_object_signal
syscall.
Source§fn wait_handle(
&self,
signals: Signals,
deadline: Time,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Time, ) -> Result<Signals, Status>
Waits on a handle. Wraps the
zx_object_wait_one
syscall.
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>
Causes packet delivery on the given port when the object changes state and matches signals.
zx_object_wait_async
syscall.
Source§impl HandleBased for Socket
impl HandleBased for Socket
Source§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
Duplicate a handle, possibly reducing the rights available. Wraps the
zx_handle_duplicate
syscall.
Source§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
Create a replacement for a handle, possibly reducing the rights available. This invalidates
the original handle. Wraps the
zx_handle_replace
syscall.
Source§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
Converts the value into its inner handle. Read more
Source§fn into_raw(self) -> zx_handle_t
fn into_raw(self) -> zx_handle_t
Converts the handle into it’s raw representation. Read more
Source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
Creates an instance of this type from a handle. Read more
Source§fn into_handle_based<H: HandleBased>(self) -> H
fn into_handle_based<H: HandleBased>(self) -> H
Creates an instance of another handle-based type from this value’s inner handle.
Source§fn from_handle_based<H: HandleBased>(h: H) -> Self
fn from_handle_based<H: HandleBased>(h: H) -> Self
Creates an instance of this type from the inner handle of another
handle-based type.
Source§impl Peered for Socket
impl Peered for Socket
Source§fn signal_peer(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_peer( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Set and clear userspace-accessible signal bits on the object’s peer. Wraps the
zx_object_signal_peer
syscall.
impl Eq for Socket
impl StructuralPartialEq for Socket
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more