Struct async_osc::OscSocket[][src]

pub struct OscSocket { /* fields omitted */ }

A UDP socket to send and receive OSC messages.

Implementations

impl OscSocket[src]

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

Creates a new OSC socket from a async_std::net::UdpSocket.

pub async fn bind<A: ToSocketAddrs>(addr: A) -> Result<Self, Error>[src]

Creates an OSC socket from the given address.

Binding with a port number of 0 will request that the OS assigns a port to this socket. The port allocated can be queried via local_addr method.

pub async fn connect<A: ToSocketAddrs>(&self, addrs: A) -> Result<(), Error>[src]

Connects the UDP socket to a remote address.

When connected, only messages from this address will be received and the send method will use the specified address for sending.

Examples

use async_osc::{prelude::*, OscSocket, OscMessage};

let socket = OscSocket::bind("127.0.0.1:0").await?;
socket.connect("127.0.0.1:8080").await?;

pub async fn send_to<A: ToSocketAddrs, P: IntoOscPacket>(
    &self,
    packet: P,
    addrs: A
) -> Result<(), Error>
[src]

Sends an OSC packet on the socket to the given address.

Examples

use async_osc::{prelude::*, OscSocket, OscMessage};

let socket = OscSocket::bind("127.0.0.1:0").await?;
let addr = "127.0.0.1:5010";
let message = OscMessage::new("/volume", (0.8,));
socket.send_to(message, &addr).await?;

pub async fn send<P: IntoOscPacket>(&self, packet: P) -> Result<(), Error>[src]

Sends a packet on the socket to the remote address to which it is connected.

The connect method will connect this socket to a remote address. This method will fail if the socket is not connected.

Examples

use async_osc::{prelude::*, OscSocket, OscMessage};

let socket = OscSocket::bind("127.0.0.1:34254").await?;
socket.connect("127.0.0.1:8080").await?;
socket.send(("/volume", (1.0f32,))).await?;

pub fn sender(&self) -> OscSender[src]

Create a standalone sender for this socket.

The sender can be moved to other threads or tasks.

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

Get a reference to the underling UdpSocket.

pub fn local_addr(&self) -> Result<SocketAddr, Error>[src]

Returns the local address that this socket is bound to.

This can be useful, for example, when binding to port 0 to figure out which port was actually bound.

Trait Implementations

impl Debug for OscSocket[src]

impl Stream for OscSocket[src]

type Item = Result<(OscPacket, SocketAddr), Error>

Values yielded by the stream.

Auto Trait Implementations

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<I> IntoStream for I where
    I: Stream, 
[src]

type Item = <I as Stream>::Item

The type of the elements being iterated over.

type IntoStream = I

Which kind of stream are we turning this into?

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<S> StreamExt for S where
    S: Stream + ?Sized
[src]

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<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future