Struct nannou_osc::recv::Receiver[][src]

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

A type used for receiving OSC packets.

Implementations

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

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

use nannou_osc::Receiver;

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

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.

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");
}

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>.

use nannou_osc::Receiver;

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

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>.

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");
}

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.

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");
}

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.

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).

When called, this method will pop a message from the receiver’s queue.

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.

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.

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.

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

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.

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.

An iterator yielding OSC Packets.

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

An iterator yielding OSC Packets.

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.