[][src]Struct abbegm::tokio_peer::EgmPeer

pub struct EgmPeer { /* fields omitted */ }

Asynchronous EGM peer capable of sending and receiving messages.

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 async 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 bind_sync(addrs: impl ToSocketAddrs) -> Result<Self>[src]

Synchronously create an EGM peer on a newly bound UDP socket.

This function allows you to create the peer synchronously, but use an asynchronous API for communicating with the robot. This can be useful if you want to perform initialization of your application synchronously.

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 async fn recv<'_>(&'_ 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 async fn recv_from<'_>(
    &'_ self
) -> Result<(EgmRobot, SocketAddr), ReceiveError>
[src]

Receive a message from any remote address.

pub async fn purge_read_queue<'_>(&'_ self) -> Result<()>[src]

Purge all messages from the socket read queue.

pub async 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 async 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>,