Skip to main content

Socket

Struct Socket 

pub(crate) struct Socket(OwnedFd);
Expand description

Client socket on the IPC router.

The router assigns a port when the socket is created.

Tuple Fields§

§0: OwnedFd

Implementations§

§

impl Socket

pub(crate) fn new() -> Result<Self>

pub(crate) fn into_async(self) -> Result<AsyncFd<Self>>

Registers the socket with the tokio reactor for reading.

The router never reports a socket as writable. Flow control resumes with a message instead.

§Panics

Panics if called outside of a tokio runtime.

pub(crate) fn bind_control_port(&self) -> Result<()>

Turns the socket into a control port, which receives a message for every server that is added or removed.

pub(crate) fn lookup( &self, service: u32, filter: Filter, ) -> Result<impl ExactSizeIterator<Item = Server> + use<>>

Returns the servers of a QMI service.

pub(crate) fn connect(&self, to: Port) -> Result<()>

Connects the socket to a server. Self::send then sends to it.

Only a connected socket reports a hang up (POLLHUP | POLLERR). See ServiceWatcher::wait_removed for when the router reports it.

pub(crate) fn send(&self, packet: &[u8]) -> Result<()>

Sends a packet to the connected server without blocking.

Fails with io::ErrorKind::WouldBlock if flow control stops sending. Until irsc_util has loaded the IPC security rules, the router blocks the call while it holds the socket lock, even though the call is non-blocking. The wait is uninterruptible and never ends if irsc_util doesn’t run.

pub(crate) fn try_recv(&self) -> Result<Received>

Reads the next packet without blocking.

Fails with io::ErrorKind::WouldBlock if no packet is queued.

pub(crate) fn try_recv_control(&self, buf: &mut [u8]) -> Result<Option<usize>>

Reads the next control message into buf without blocking and returns its length.

Returns None for a packet that isn’t a control message, which has no sender, or that doesn’t fit into buf. The packet is dropped. Fails with io::ErrorKind::WouldBlock if no packet is queued.

fn next_packet_len(&self) -> Result<usize>

Returns the size of the next queued packet, or 0 if there is none.

fn recv<B: Buffer<u8>>(&self, buf: B) -> Result<(B::Output, Option<Port>)>

Reads a packet and returns the sender, if the router reports one.

A resume TX message has no payload.

Trait Implementations§

§

impl AsRawFd for Socket

§

fn as_raw_fd(&self) -> RawFd

Extracts the raw file descriptor. Read more
§

impl Debug for Socket

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more