Struct nannou::osc::recv::Receiver [] [src]

pub struct Receiver<M = Unconnected> { /* fields omitted */ }

A type used for receiving OSC packets.

Methods

impl<M> Receiver<M>
[src]

[src]

The socket address that this Receiver's socket was created from.

impl Receiver<Unconnected>
[src]

[src]

Create a Receiver that listen for OSC packets on the given address.

extern crate nannou;

use nannou::osc::Receiver;

fn main() {
    let rx = Receiver::bind_to("127.0.0.1:34254").expect("Couldn't bind socket to address");
}

[src]

The same as bind_to, but allows for manually specifying the MTU (aka "maximum transition unit").

The MTU is the maximum UDP packet size in bytes that the Receiver's UDP socket will receive before returning an error.

By default this is DEFAULT_MTU.

extern crate nannou;

use nannou::osc::Receiver;

fn main() {
    let rx = Receiver::bind_to_with_mtu("127.0.0.1:34254", 60_000)
        .expect("Couldn't bind socket to address");
}

[src]

The same as bind_to, but assumes that the IP address is 0.0.0.0.

The resulting socket address will be 0.0.0.0:<port>.

extern crate nannou;

use nannou::osc::Receiver;

fn main() {
    let rx = Receiver::bind(34254).expect("Couldn't bind socket to default address");
}

[src]

The same as bind_to_with_mtu, but assumes that the IP address is 0.0.0.0.

The resulting socket address will be 0.0.0.0:<port>.

extern crate nannou;

use nannou::osc::Receiver;

fn main() {
    let port = 34254;
    let mtu = 60_000;
    let rx = Receiver::bind_with_mtu(port, mtu).expect("Couldn't bind to default address");
}

[src]

Connects the Receiver's UDP socket to the given remote address.

This applies filters so that only data from the given address is received.

**Panic!**s if the given addr cannot resolve to a valid SocketAddr.

extern crate nannou;

use nannou::osc::Receiver;

fn main() {
    let tx = Receiver::bind(34254)
        .expect("Couldn't bind to default socket")
        .connect("127.0.0.1:34255")
        .expect("Couldn't connect to socket at address");
}

[src]

Waits for the next OSC packet to be received and returns it along with the source address.

If the socket is currently in non-blocking mode, this method will first switch the socket to blocking.

This will return a CommunicationError if:

  • Switching the socket from "non_blocking" to "blocking" fails,
  • The Mutex around the inner buffer (used to collect bytes) was poisoned,
  • The MTU was not large enough to receive a UDP packet,
  • The inner UdpSocket::recv call fails or
  • The socket received some bytes that could not be decoded into an OSC Packet.

[src]

Checks for a pending OSC packet and returns Ok(Some) if there is one waiting along with the source address.

If there are no packets waiting (or if the inner UDP socket's recv method returns an error) this will immediately return with Ok(None).

If the socket is currently in blocking mode, this method will first switch the socket to non-blocking.

This will return a CommunicationError if:

  • Switching the socket from "blocking" to "non_blocking" fails,
  • The Mutex around the inner buffer (used to collect bytes) was poisoned,
  • The socket received some bytes that could not be decoded into an OSC Packet.

Important traits for Iter<'a, Connected>
[src]

An iterator yielding OSC Packets along with their source address.

Each call to next will block until the next packet is received or until some error occurs.

Important traits for TryIter<'a, Connected>
[src]

An iterator yielding OSC Packets along with their source address.

Each call to next will only return Some while there are pending packets and will return None otherwise.

impl Receiver<Connected>
[src]

[src]

Returns the address of the socket to which the Receiver is Connected.

[src]

Waits for the next OSC packet to be received and returns it.

If the socket is currently in non-blocking mode, this method will first switch the socket to blocking.

This will return a CommunicationError if:

  • Switching the socket from "non_blocking" to "blocking" fails,
  • The Mutex around the inner buffer (used to collect bytes) was poisoned,
  • The MTU was not large enough to receive a UDP packet,
  • The inner UdpSocket::recv call fails or
  • The socket received some bytes that could not be decoded into an OSC Packet.

[src]

Checks for a pending OSC packet and returns Ok(Some) if there is one waiting.

If there are no packets waiting (or if the inner UDP socket's recv method returns an error) this will immediately return with Ok(None).

If the socket is currently in blocking mode, this method will first switch the socket to non-blocking.

This will return a CommunicationError if:

  • Switching the socket from "blocking" to "non_blocking" fails,
  • The Mutex around the inner buffer (used to collect bytes) was poisoned,
  • The socket received some bytes that could not be decoded into an OSC Packet.

Important traits for Iter<'a, Connected>
[src]

An iterator yielding OSC Packets.

Each call to next will block until the next packet is received or until some error occurs.

Important traits for TryIter<'a, Connected>
[src]

An iterator yielding OSC Packets.

Each call to next will only return Some while there are pending packets and will return None otherwise.

Trait Implementations

Auto Trait Implementations

impl<M> Send for Receiver<M> where
    M: Send

impl<M> Sync for Receiver<M> where
    M: Sync