File: notifications.rs

package info (click to toggle)
thunderbird 1%3A140.4.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,609,432 kB
  • sloc: cpp: 7,672,442; javascript: 5,901,613; ansic: 3,898,954; python: 1,413,343; xml: 653,997; asm: 462,286; java: 180,927; sh: 113,489; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (31 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download | duplicates (22)
1
2
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
extern crate core_foundation;
extern crate coremidi;

use coremidi::{Client, Notification};

use core_foundation::runloop::{kCFRunLoopDefaultMode, CFRunLoopRunInMode};

fn main() {
    println!("Logging MIDI Client Notifications");
    println!("Will Quit Automatically After 10 Seconds");
    println!();

    let _client = Client::new_with_notifications("example-client", print_notification).unwrap();

    // As the MIDIClientCreate docs say (https://developer.apple.com/documentation/coremidi/1495360-midiclientcreate),
    // notifications will be delivered on the run loop that was current when
    // Client was created.
    //
    // In order to actually receive the notifications, a run loop must be
    // running. Since this sample app does not use an app framework like
    // UIApplication or NSApplication, it does not have a run loop running yet.
    // So we start one that lasts for 10 seconds with the following line.
    //
    // You may not have to do this in your app - see https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html#//apple_ref/doc/uid/10000057i-CH16-SW24
    // for information about when run loops are running automatically.
    unsafe { CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10.0, 0) };
}

fn print_notification(notification: &Notification) {
    println!("Received Notification: {:?} \r", notification);
}