xq_notification 0.0.1

通知的封装
Documentation
  • Coverage
  • 85.71%
    6 out of 7 items documented1 out of 5 items with examples
  • Size
  • Source code size: 13.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.89 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SyKingW

xq-notification-rs

rust 通知封装

使用介绍

Cargo.toml

serde_json = "^1.0"
xq_notification = "*"

示例代码

use std::{thread};
use xq_notification::notification::NotificationManager;
use serde_json;

fn main() {
    // 第一个通知
    thread::spawn(move || match NotificationManager::observe("test") {
        Some(r) => loop {
            match r.recv() {
                Ok(_) => {
                    // 接收到通知
                }
                Err(_) => {
                    break;
                }
            }
        },
        None => {}
    }); 

    // 第二个通知
    thread::spawn(move || match NotificationManager::observe("test") {
        Some(r) => loop {
            match r.recv() {
                Ok(_) => {
                    // 接收到通知
                }
                Err(_) => {
                    break;
                }
            }
        },
        None => {}
    });

    // 发送通知
    for i in 0..10000 {
        NotificationManager::publish("test", serde_json::Value::String(format!("{}", i)));
    }

}