Signal

Struct Signal 

Source
pub struct Signal { /* private fields */ }

Implementations§

Source§

impl Signal

Source

pub fn get_status(&self) -> SignalStatus

Get the status of the signal instance. Calling this function will reset the flags was_set_remote and was_set_local and return their pre-reset values.

§Examples

Use this function to check if you should push or read data from the signal:

use libmapper_rs::device::Device;
use libmapper_rs::signal::Signal;
use std::time::Duration;
fn main_loop(dev: &Device, sig: &mut Signal, value: &mut f64) {
    loop {
       dev.poll_and_block(Duration::from_millis(10));
 
       if sig.get_status().was_set_remote() { // check if there's a new value waiting for us
         let (new_value, _) = sig.get_value_single::<f64>().unwrap();
         *value = new_value;
       } else {
         sig.set_value_single(value);
       }
    }
}
Source

pub fn get_data_type(&self) -> mpr_type

Get the type of data this signal is storing.

Source

pub fn get_vector_length(&self) -> u32

Get the length of the vector this signal is storing. This will be how long the slice returned from Signal::get_value is.

If this is 1, you should use Signal::get_value_single instead.

Source§

impl Signal

Source

pub fn set_value_single<T: MappableType + Copy>( &mut self, value: &T, ) -> Result<(), SignalError>

Set the value of the signal. This function will return SignalError::WrongType if the passed generic type doesn’t match the signal’s type.

If this signal is a vector, only the first element of the vector will be set.

Source

pub fn get_value_single<T: MappableType + Copy>( &self, ) -> Result<(T, u64), SignalError>

Get the value of the signal. This function will return SignalError::WrongType if the passed generic type doesn’t match the signal’s type.

If this signal is a vector, only the first element of the vector will be returned.

Source

pub fn get_value<T: MappableType + Copy>( &self, ) -> Result<(Vec<T>, u64), SignalError>

Get the value of the signal. This function will return SignalError::WrongType if the passed generic type doesn’t match the signal’s type.

The length of the returned slice will be equal to the value returned by get_vector_length.

Source

pub fn set_value<T: MappableType + Copy>( &mut self, values: &[T], ) -> Result<(), SignalError>

Set the value of the signal. This function will return SignalError::WrongType if the passed generic type doesn’t match the signal’s type.

The length of the slice must be equal to the value returned by get_vector_length. If the lengths are not equal this function return an Err of SignalError::WrongLengthArg.

Source

pub fn get_direction(&self) -> mpr_dir

Get the direction of the signal. This value determines how signal data can flow to/from this signal.

For example, you cannot map to a signal with direction MPR_DIR_OUT.

Trait Implementations§

Source§

impl AsMprObject for Signal

Source§

impl Drop for Signal

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Signal

Source§

impl Sync for Signal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<A> MapperObject for A
where A: AsMprObject,

Source§

fn get_type(&self) -> mpr_type

Get the mpr_type representing this object
Source§

fn set_property<T>(&self, property: mpr_prop, value: T)
where T: MappableType,

Set a property on this object to a numerical value
Source§

fn set_property_str(&self, property: mpr_prop, value: &str)

Set a property on this object to a string value
Source§

fn get_property<T>(&self, property: mpr_prop) -> Result<T, PropertyError>
where T: MappableType + Copy,

Get the value of a property by it’s key from this object. If the property does not exist, or if the type is not matched, this function will return an error.
Source§

fn get_property_str(&self, property: mpr_prop) -> Result<String, PropertyError>

Get the value of a string property by it’s key from this object. If the property does not exist, or if the type is not matched, this function will return an error.
Source§

fn set_custom_property<T>(&self, property: &str, value: T, publish: bool)
where T: MappableType,

Set a user-defined property to the specified value. The property is identified by a unique, case-sensitive string key. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.