[][src]Struct abbegm::sync_peer::EgmPeer

pub struct EgmPeer { /* fields omitted */ }

Blocking EGM peer for sending and receiving messages over UDP.

Implementations

impl EgmPeer[src]

pub fn new(socket: UdpSocket) -> Self[src]

Wrap an existing UDP socket in a peer.

If you want to use the EgmPeer::recv and EgmPeer::send functions, you should use an already connected socket. Otherwise, you can only use EgmPeer::recv_from and EgmPeer::send_to.

pub fn bind(addrs: impl ToSocketAddrs) -> Result<Self>[src]

Create an EGM peer on a newly bound UDP socket.

The socket will not be connected to a remote peer, so you can only use EgmPeer::recv_from and EgmPeer::send_to.

pub fn socket(&self) -> &UdpSocket[src]

Get a shared reference to the inner socket.

pub fn socket_mut(&mut self) -> &mut UdpSocket[src]

Get an exclusive reference to the inner socket.

pub fn into_socket(self) -> UdpSocket[src]

Consume self and get the inner socket.

pub fn recv(&mut self) -> Result<EgmRobot, ReceiveError>[src]

Receive a message from the remote address to which the inner socket is connected.

To use this function, you must pass an already connected socket to EgmPeer::new. If the peer was created with an unconnected socket, this function will panic.

pub fn recv_from(&mut self) -> Result<(EgmRobot, SocketAddr), ReceiveError>[src]

Receive a message from any remote address.

pub fn purge_recv_queue(&mut self) -> Result<()>[src]

Purge all messages from the socket read queue.

Useful to ignore old messages when the socket has been left unpolled for a while.

This will leave the socket in blocking mode when the purging is done.

pub fn send(&mut self, msg: &EgmSensor) -> Result<(), SendError>[src]

Send a message to the remote address to which the inner socket is connected.

To use this function, you must pass an already connected socket to EgmPeer::new. If the peer was created with an unconnected socket, this function will panic.

pub fn send_to(
    &mut self,
    msg: &EgmSensor,
    target: &SocketAddr
) -> Result<(), SendError>
[src]

Send a message to the specified address.

Trait Implementations

impl Debug for EgmPeer[src]

Auto Trait Implementations

impl RefUnwindSafe for EgmPeer

impl Send for EgmPeer

impl Sync for EgmPeer

impl Unpin for EgmPeer

impl UnwindSafe for EgmPeer

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,