Skip to main content

RawCommandClient

Struct RawCommandClient 

Source
pub struct RawCommandClient { /* private fields */ }
Available on crate feature net only.
Expand description

An unrestricted command-channel UDP client. Raw operations intentionally live on this distinct type. The safe client can be converted into it only by consuming the idle client with CommandClient::into_raw. A raw client can transmit arbitrary bytes, receive from any peer, and change socket options; those operations carry no command validation or transaction guarantee.

Implementations§

Source§

impl RawCommandClient

Source

pub fn bind(interface: Ipv4Addr, server: SocketAddrV4) -> Result<Self>

Binds an unrestricted command socket to interface and records the default destination server.

§Errors

Returns the operating-system error from binding the socket.

Source

pub fn server(&self) -> SocketAddr

The configured default destination.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

The local address selected for this socket.

§Errors

Returns the operating-system error from querying the socket.

Source

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

Sends arbitrary bytes to the configured default destination.

§Errors

Returns the operating-system send error.

Source

pub fn send_to(&self, datagram: &[u8], destination: SocketAddr) -> Result<usize>

Sends arbitrary bytes to any destination.

§Errors

Returns the operating-system send error.

Source

pub fn recv(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>

Receives arbitrary bytes and returns their source address.

§Errors

Returns the operating-system receive error.

Source

pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>

Changes raw receive blocking behavior.

§Errors

Returns the operating-system error from changing the socket mode.

Source

pub fn set_read_timeout(&self, timeout: Option<Duration>) -> Result<()>

Changes the raw receive timeout.

§Errors

Returns the operating-system error from changing the timeout.

Source

pub fn set_write_timeout(&self, timeout: Option<Duration>) -> Result<()>

Changes the raw send timeout.

§Errors

Returns the operating-system error from changing the timeout.

Source

pub fn read_timeout(&self) -> Result<Option<Duration>>

Reads the current raw receive timeout.

§Errors

Returns the operating-system error from querying the timeout.

Source

pub fn write_timeout(&self) -> Result<Option<Duration>>

Reads the current raw send timeout.

§Errors

Returns the operating-system error from querying the timeout.

Trait Implementations§

Source§

impl Debug for RawCommandClient

Source§

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.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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, !>

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.