Struct libmapper_rs::device::Device

source ·
pub struct Device<'a> { /* private fields */ }
Expand description

A device is libmapper’s connection to the distributed graph. Each device is a collection of signal instances and their metadata.

§Examples

use libmapper_rs::device::Device;
// you can create a device with Device::create
let dev = Device::create("rust");
// you have to poll a device occasionally to make things happen
loop {
    dev.poll_and_block(10); // poll in 10ms intervals
    if dev.is_ready() {
       break;
    }
}
// create signals, etc...

Implementations§

source§

impl Device<'_>

source

pub fn create(name: &str) -> Device<'_>

Create a new device with the given name. The device will use it’s own connection to the graph.

Before calling any other methods on the device, you should poll it until it is ready.

§Notes

If you plan on creating multiple devices, consider using (Device::create_from_graph)Device::create_from_graph instead to pool resources.

Examples found in repository?
examples/device.rs (line 5)
3
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    println!("Using libmapper version {} ", libmapper_rs::get_mapper_version());
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
}
More examples
Hide additional examples
examples/vector_signal.rs (line 6)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_vector_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT, 2);
    let debug_sig = dev.create_vector_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN, 2);
    loop {
        dev.poll_and_block(100);
        let time = (SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64;

        let values = [time.sin(), time.cos()];
        sig.set_value(&values).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value::<f64>().unwrap().0
            );
        }
    }
}
examples/maps.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig_a =
        dev.create_signal::<i32>("output", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
    let sig_b = dev.create_signal::<i32>("input", libmapper_rs::constants::mpr_dir::MPR_DIR_IN);
    let map = Map::create(&sig_a, &sig_b);
    map.push();
    loop {
        dev.poll_and_block(100);
        if map.is_ready() {
            break;
        }
    }
    println!("Map created!");
    for i in 0..100 {
        sig_a.set_value_single(&i).unwrap();
        dev.poll_and_block(10);
        let val = sig_b
            .get_value_single::<i32>()
            .expect("Signal didn't send!");
        println!("Sent: {}, Received: {}", i, val.0);
        assert_eq!(i, val.0)
    }
}
examples/signal.rs (line 6)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT);
    sig.set_property(mpr_prop::MPR_PROP_MIN, -1.0);
    sig.set_property(mpr_prop::MPR_PROP_MAX, 1.0);
    
    let debug_sig = dev.create_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN);

    assert!(debug_sig.get_property::<f64>(mpr_prop::MPR_PROP_MIN).is_none());
    loop {
        dev.poll_and_block(100);
        let time = ((SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64)
            .sin();
        sig.set_value_single(&time).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value_single::<f64>().unwrap()
            );
        }
    }
}
source

pub fn create_from_graph<'a>(name: &str, graph: &'a Graph) -> Device<'a>

Create a new device with a shared graph. Sharing a graph between devices allows them to pool some resources and networking, potentially improving performance.

Examples found in repository?
examples/segfault.rs (line 36)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
fn main() {
  let graph = Arc::new(Graph::create());
  let counter: Arc<AtomicU64> = Arc::new(AtomicU64::new(0));

  let mut threads = Vec::<JoinHandle<()>>::new();

  {
    // spawn a thread to poll the graph
    let graph = Arc::clone(&graph);
    let thread = std::thread::spawn(move || {
      loop {
        graph.poll();
      }
    });
    threads.push(thread);
  }

  let mut num_workers = 10;
  let arg = env::args().skip(1).next();
  if arg.is_some() {
    num_workers = arg.unwrap().parse::<i32>().unwrap_or(10);
  }

  // spawn n threads creating then deleting devices at random
  for _ in 0..num_workers {
    let graph = graph.clone();
    let id_counter = counter.clone();
    let thread = std::thread::spawn(move || {
      let name = format!("rust_{:?}", thread::current().id());
      loop {
        let _dev = libmapper_rs::device::Device::create_from_graph(&name, &graph);
        loop {
          _dev.poll();
          if _dev.is_ready() {
            break;
          }
        }
        let signal = _dev.create_signal::<f32>("test_sig", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
        thread::sleep(std::time::Duration::from_millis(id_counter.fetch_add(1, Ordering::SeqCst) as u64));
        drop(signal);
        drop(_dev);
      }
    });
    threads.push(thread);
  }

  for thread in threads {
    thread.join().unwrap();
  }
}
source§

impl Device<'_>

source

pub fn poll(&self)

Poll the device without blocking

§Notes

You may want to use poll_all in a multithreaded enviroment, when using non-blocking polling libmapper will use a heuristic to determine how many messages to parse at once for performance. If you don’t care how long this function will take to run, call Device::poll_all.

Examples found in repository?
examples/segfault.rs (line 38)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
fn main() {
  let graph = Arc::new(Graph::create());
  let counter: Arc<AtomicU64> = Arc::new(AtomicU64::new(0));

  let mut threads = Vec::<JoinHandle<()>>::new();

  {
    // spawn a thread to poll the graph
    let graph = Arc::clone(&graph);
    let thread = std::thread::spawn(move || {
      loop {
        graph.poll();
      }
    });
    threads.push(thread);
  }

  let mut num_workers = 10;
  let arg = env::args().skip(1).next();
  if arg.is_some() {
    num_workers = arg.unwrap().parse::<i32>().unwrap_or(10);
  }

  // spawn n threads creating then deleting devices at random
  for _ in 0..num_workers {
    let graph = graph.clone();
    let id_counter = counter.clone();
    let thread = std::thread::spawn(move || {
      let name = format!("rust_{:?}", thread::current().id());
      loop {
        let _dev = libmapper_rs::device::Device::create_from_graph(&name, &graph);
        loop {
          _dev.poll();
          if _dev.is_ready() {
            break;
          }
        }
        let signal = _dev.create_signal::<f32>("test_sig", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
        thread::sleep(std::time::Duration::from_millis(id_counter.fetch_add(1, Ordering::SeqCst) as u64));
        drop(signal);
        drop(_dev);
      }
    });
    threads.push(thread);
  }

  for thread in threads {
    thread.join().unwrap();
  }
}
source

pub fn poll_all(&self)

Processes all messages in the device’s queue, no matter how long it takes. If using dedicated threads to poll devices this is probably what you want to use instead of poll

source

pub fn poll_and_block(&self, time: u32)

Blocks the current thread for time milliseconds. Use this function instead of sleeping in a loop.

Examples found in repository?
examples/device.rs (line 7)
3
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    println!("Using libmapper version {} ", libmapper_rs::get_mapper_version());
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
}
More examples
Hide additional examples
examples/vector_signal.rs (line 8)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_vector_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT, 2);
    let debug_sig = dev.create_vector_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN, 2);
    loop {
        dev.poll_and_block(100);
        let time = (SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64;

        let values = [time.sin(), time.cos()];
        sig.set_value(&values).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value::<f64>().unwrap().0
            );
        }
    }
}
examples/maps.rs (line 6)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig_a =
        dev.create_signal::<i32>("output", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
    let sig_b = dev.create_signal::<i32>("input", libmapper_rs::constants::mpr_dir::MPR_DIR_IN);
    let map = Map::create(&sig_a, &sig_b);
    map.push();
    loop {
        dev.poll_and_block(100);
        if map.is_ready() {
            break;
        }
    }
    println!("Map created!");
    for i in 0..100 {
        sig_a.set_value_single(&i).unwrap();
        dev.poll_and_block(10);
        let val = sig_b
            .get_value_single::<i32>()
            .expect("Signal didn't send!");
        println!("Sent: {}, Received: {}", i, val.0);
        assert_eq!(i, val.0)
    }
}
examples/signal.rs (line 8)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT);
    sig.set_property(mpr_prop::MPR_PROP_MIN, -1.0);
    sig.set_property(mpr_prop::MPR_PROP_MAX, 1.0);
    
    let debug_sig = dev.create_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN);

    assert!(debug_sig.get_property::<f64>(mpr_prop::MPR_PROP_MIN).is_none());
    loop {
        dev.poll_and_block(100);
        let time = ((SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64)
            .sin();
        sig.set_value_single(&time).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value_single::<f64>().unwrap()
            );
        }
    }
}
source§

impl Device<'_>

source

pub fn is_ready(&self) -> bool

Tests if the device is ready to use. Do not try to call any other methods until this returns true.

Examples found in repository?
examples/device.rs (line 8)
3
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    println!("Using libmapper version {} ", libmapper_rs::get_mapper_version());
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
}
More examples
Hide additional examples
examples/vector_signal.rs (line 9)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_vector_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT, 2);
    let debug_sig = dev.create_vector_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN, 2);
    loop {
        dev.poll_and_block(100);
        let time = (SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64;

        let values = [time.sin(), time.cos()];
        sig.set_value(&values).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value::<f64>().unwrap().0
            );
        }
    }
}
examples/maps.rs (line 7)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig_a =
        dev.create_signal::<i32>("output", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
    let sig_b = dev.create_signal::<i32>("input", libmapper_rs::constants::mpr_dir::MPR_DIR_IN);
    let map = Map::create(&sig_a, &sig_b);
    map.push();
    loop {
        dev.poll_and_block(100);
        if map.is_ready() {
            break;
        }
    }
    println!("Map created!");
    for i in 0..100 {
        sig_a.set_value_single(&i).unwrap();
        dev.poll_and_block(10);
        let val = sig_b
            .get_value_single::<i32>()
            .expect("Signal didn't send!");
        println!("Sent: {}, Received: {}", i, val.0);
        assert_eq!(i, val.0)
    }
}
examples/signal.rs (line 9)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT);
    sig.set_property(mpr_prop::MPR_PROP_MIN, -1.0);
    sig.set_property(mpr_prop::MPR_PROP_MAX, 1.0);
    
    let debug_sig = dev.create_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN);

    assert!(debug_sig.get_property::<f64>(mpr_prop::MPR_PROP_MIN).is_none());
    loop {
        dev.poll_and_block(100);
        let time = ((SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64)
            .sin();
        sig.set_value_single(&time).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value_single::<f64>().unwrap()
            );
        }
    }
}
examples/segfault.rs (line 39)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
fn main() {
  let graph = Arc::new(Graph::create());
  let counter: Arc<AtomicU64> = Arc::new(AtomicU64::new(0));

  let mut threads = Vec::<JoinHandle<()>>::new();

  {
    // spawn a thread to poll the graph
    let graph = Arc::clone(&graph);
    let thread = std::thread::spawn(move || {
      loop {
        graph.poll();
      }
    });
    threads.push(thread);
  }

  let mut num_workers = 10;
  let arg = env::args().skip(1).next();
  if arg.is_some() {
    num_workers = arg.unwrap().parse::<i32>().unwrap_or(10);
  }

  // spawn n threads creating then deleting devices at random
  for _ in 0..num_workers {
    let graph = graph.clone();
    let id_counter = counter.clone();
    let thread = std::thread::spawn(move || {
      let name = format!("rust_{:?}", thread::current().id());
      loop {
        let _dev = libmapper_rs::device::Device::create_from_graph(&name, &graph);
        loop {
          _dev.poll();
          if _dev.is_ready() {
            break;
          }
        }
        let signal = _dev.create_signal::<f32>("test_sig", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
        thread::sleep(std::time::Duration::from_millis(id_counter.fetch_add(1, Ordering::SeqCst) as u64));
        drop(signal);
        drop(_dev);
      }
    });
    threads.push(thread);
  }

  for thread in threads {
    thread.join().unwrap();
  }
}
source§

impl<'a> Device<'a>

source

pub fn get_graph(&self) -> Option<&'a Graph>

Get the shared graph used by this device. If the device was created with Device::create this will return None.

source§

impl Device<'_>

source

pub fn has_shared_graph(&self) -> bool

Check if the device was created with a shared graph.

source

pub fn create_signal<T: MappableType + Copy>( &self, name: &str, direction: mpr_dir, ) -> Signal

Create a signal with the given name and direction.

§Notes
  • The signal will have a vector length of 1 (i.e. single value).
  • The passed generic parameter controls what type of data the signal will hold.
§Examples
use libmapper_rs::device::Device;
use libmapper_rs::constants::mpr_dir;
fn setup_signals(dev: &Device) {
    // create an outgoing signal that outputs a single f64 value
    let sig = dev.create_signal::<f64>("test_signal", mpr_dir::MPR_DIR_OUT);
}
Examples found in repository?
examples/maps.rs (line 14)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig_a =
        dev.create_signal::<i32>("output", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
    let sig_b = dev.create_signal::<i32>("input", libmapper_rs::constants::mpr_dir::MPR_DIR_IN);
    let map = Map::create(&sig_a, &sig_b);
    map.push();
    loop {
        dev.poll_and_block(100);
        if map.is_ready() {
            break;
        }
    }
    println!("Map created!");
    for i in 0..100 {
        sig_a.set_value_single(&i).unwrap();
        dev.poll_and_block(10);
        let val = sig_b
            .get_value_single::<i32>()
            .expect("Signal didn't send!");
        println!("Sent: {}, Received: {}", i, val.0);
        assert_eq!(i, val.0)
    }
}
More examples
Hide additional examples
examples/signal.rs (line 15)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT);
    sig.set_property(mpr_prop::MPR_PROP_MIN, -1.0);
    sig.set_property(mpr_prop::MPR_PROP_MAX, 1.0);
    
    let debug_sig = dev.create_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN);

    assert!(debug_sig.get_property::<f64>(mpr_prop::MPR_PROP_MIN).is_none());
    loop {
        dev.poll_and_block(100);
        let time = ((SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64)
            .sin();
        sig.set_value_single(&time).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value_single::<f64>().unwrap()
            );
        }
    }
}
examples/segfault.rs (line 43)
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
fn main() {
  let graph = Arc::new(Graph::create());
  let counter: Arc<AtomicU64> = Arc::new(AtomicU64::new(0));

  let mut threads = Vec::<JoinHandle<()>>::new();

  {
    // spawn a thread to poll the graph
    let graph = Arc::clone(&graph);
    let thread = std::thread::spawn(move || {
      loop {
        graph.poll();
      }
    });
    threads.push(thread);
  }

  let mut num_workers = 10;
  let arg = env::args().skip(1).next();
  if arg.is_some() {
    num_workers = arg.unwrap().parse::<i32>().unwrap_or(10);
  }

  // spawn n threads creating then deleting devices at random
  for _ in 0..num_workers {
    let graph = graph.clone();
    let id_counter = counter.clone();
    let thread = std::thread::spawn(move || {
      let name = format!("rust_{:?}", thread::current().id());
      loop {
        let _dev = libmapper_rs::device::Device::create_from_graph(&name, &graph);
        loop {
          _dev.poll();
          if _dev.is_ready() {
            break;
          }
        }
        let signal = _dev.create_signal::<f32>("test_sig", libmapper_rs::constants::mpr_dir::MPR_DIR_OUT);
        thread::sleep(std::time::Duration::from_millis(id_counter.fetch_add(1, Ordering::SeqCst) as u64));
        drop(signal);
        drop(_dev);
      }
    });
    threads.push(thread);
  }

  for thread in threads {
    thread.join().unwrap();
  }
}
source

pub fn create_vector_signal<T: MappableType + Copy>( &self, name: &str, direction: mpr_dir, vector_length: u32, ) -> Signal

Create a signal with the given name, direction, and vector length.

§Notes
  • The passed generic parameter controls what type of data the signal will hold.
Examples found in repository?
examples/vector_signal.rs (line 15)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
fn main() {
    let dev = Device::create("rustmapper");
    loop {
        dev.poll_and_block(10);
        if dev.is_ready() {
            break;
        }
    }

    println!("Device became ready!");
    let mut sig = dev.create_vector_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT, 2);
    let debug_sig = dev.create_vector_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN, 2);
    loop {
        dev.poll_and_block(100);
        let time = (SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_millis() as u64) as f64
            / 1000f64;

        let values = [time.sin(), time.cos()];
        sig.set_value(&values).unwrap();
        if debug_sig.get_status().was_set_remote() {
            println!(
                "Received debug message: {:?}",
                debug_sig.get_value::<f64>().unwrap().0
            );
        }
    }
}

Trait Implementations§

source§

impl AsMprObject for Device<'_>

source§

impl Drop for Device<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Device<'_>

source§

impl Sync for Device<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for Device<'a>

§

impl<'a> RefUnwindSafe for Device<'a>

§

impl<'a> Unpin for Device<'a>

§

impl<'a> UnwindSafe for Device<'a>

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) -> Option<T>
where T: MappableType + Default + 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 None.
source§

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

§

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

§

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.