Trait OscMessageExt

Source
pub trait OscMessageExt {
    // Required methods
    fn new<T>(addr: impl ToString, args: T) -> Self
       where T: IntoOscArgs;
    fn starts_with(&self, prefix: &str) -> bool;
    fn as_tuple(&self) -> (&str, &[OscType]);
}
Expand description

Extension methods for the rosc::OscMessage type.

Required Methods§

Source

fn new<T>(addr: impl ToString, args: T) -> Self
where T: IntoOscArgs,

Create a new OscMessage from an address and args. The args can either be specified as a Vec<[OscType], or as a tuple of regular Rust types that can be converted into OscType.

Source

fn starts_with(&self, prefix: &str) -> bool

Returns true if the address starts with the given prefix.

Returns false otherwise.

Source

fn as_tuple(&self) -> (&str, &[OscType])

Get a reference to the message in tuple form.

This is useful for pattern matching. Example:

let message = OscMessage::new("/foo", vec![
    OscType::Float(1.0), OscType::String("bar".into())
]);

match message.as_tuple() {
    ("foo", &[OscType::Float(val), OscType::String(ref text)]) => {
        eprintln!("Got foo message with args: {}, {}", val, text);
    },
    _ => {}
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§