Struct nannou::osc::send::Sender [] [src]

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

A type used for sending OSC packets.

Methods

impl<M> Sender<M>
[src]

[src]

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

impl Sender<Unconnected>
[src]

[src]

Creates a new Sender with the UDP socket bound to the given address. Note: this is not the target address, rather it is the address of the socket used by the Sender to send packets. Use the bind constructor instead if you would like the Sender's socket bound to the default address.

extern crate nannou;

use nannou::osc::Sender;

fn main() {
    let tx = Sender::bind_to("0.0.0.0:0").expect("Couldn't bind socket to the address");
}

The returned Sender is Unconnected, meaning that it is not currently connected to a specific target address. This means that the target address will have to be specified when calling send. To connect the Sender to a specific target address, use the connect builder method which will return a Sender in the Connected mode.

[src]

The same as bind_to but assumes the default_sender_socket_addr_v4 socket address.

[src]

Connects the Sender's UDP socket to the given target, remote address.

The returned Sender will only send packets to the specified address.

Returns an error if some IO error occurred.

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

extern crate nannou;

use nannou::osc::Sender;

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

[src]

Sends the given packet on the Senders socket to the given address.

The given packet can be of any type that can be converted directly into a Packet. This includes Message, Bundle and (String, Vec<Type>) (which will be interpreted as a Message).

On success, returns the number of bytes written.

This will return a CommunicationError if:

  • The given packet fails to be encoded to bytes
  • The IP version of the local socket does not match that returned from addr or
  • The inner UdpSocket::send_to call fails.

impl Sender<Connected>
[src]

[src]

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

[src]

Sends the given packet on the Senders socket to the connected address.

On success, returns the number of bytes written.

This will return a CommunicationError if:

  • The given packet fails to be encoded to bytes
  • The IP version of the local socket does not match the connected socket or
  • The inner UdpSocket::send call fails.

Trait Implementations

Auto Trait Implementations

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

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