【Rust日报】2022-02-07 《Rust 编码规范》更新到 V0.2 版本

《Rust 编码规范》更新到 V0.2 版本

由 张汉东 老师编写的《Rust 编码规范》更新到 V0.2 , 欢迎大家持续评审、补充和参考

原文链接:https://rust-coding-guidelines.github.io/rust-coding-guidelines-zh/

Rust 的热加载

本文探讨了 Rust 中的热加载在 windows 和 Linux 上的不同差异.

原文链接:https://johnaustin.io/articles/2022/hot-reloading-rust

CADBase 平台发布

经过4年的设计和开发,我们团队很高兴地宣布CADBase项目正式启动(https://cadbase.rs/)。

CADBase设计用于存放图纸和相关材料(标准、供应商、支持文件)的信息。

资源的主要部分是包含以下数据的组件页面:

  • 组件的基本信息、特性和相关文件。

  • 修改组件的参数和相关文件。

  • CAD和其他程序解决方案的文件集。

  • 组件相关材料信息: 标准、供应商、目录、关键词。

原文链接:https://www.reddit.com/r/rust/comments/slv1d7/announcing_cadbase_platform_we_use_crates_actix/

rust-protobuf: 过去,现在和未来

rust-protobuf 是作者 7 年前开始的 Rust protobuf 的实现. 在 Rust 中使用过 protobuf的人都知道, 存在着两个实现,一个是 rust-protobuf, 另外是一个 Prost 为基础的其他实现. 两个实现都有各自的优缺点. 作者同时也表达了自己未来对该库的迷茫.

也许未来,多个 protobuf 的实现会合并也不一定.

原文链接:https://github.com/stepancheg/rust-protobuf/blob/master/doc/past-present-future.md

ttokio-cron-scheduler: 0.4 版本发布

在异步 tokio 环境中使用类似cron的调度。也可以在一个瞬间安排任务,或者在固定的时间内重复它们。

use tokio_cron_scheduler::{JobScheduler, JobToRun, Job};

#[tokio::main]
async fn main() {
    let mut sched = JobScheduler::new();
  
    sched.add(Job::new("1/10 * * * * *", |uuid, l| {
        println!("I run every 10 seconds");
    }).unwrap());

    sched.add(Job::new_async("1/7 * * * * *", |uuid, l| Box::pin( async {
        println!("I run async every 7 seconds");
    })).unwrap());

    sched.add(Job::new("1/30 * * * * *", |uuid, l| {
        println!("I run every 30 seconds");
    }).unwrap());
  
    sched.add(
      Job::new_one_shot(Duration::from_secs(18), |_uuid, _l| {
        println!("{:?} I'm only run once", chrono::Utc::now());
      }).unwrap()
    );

    let mut jj = Job::new_repeated(Duration::from_secs(8), |_uuid, _l| {
      println!("{:?} I'm repeated every 8 seconds", chrono::Utc::now());
    }).unwrap();
    sched.add(jj);
  
    jj.on_start_notification_add(Box::new(|job_id, notification_id, type_of_notification| {
      Box::pin(async move {
        println!("Job {:?} was started, notification {:?} ran ({:?})", job_id, notification_id, type_of_notification);
      })
    }));

    jj.on_stop_notification_add(Box::new(|job_id, notification_id, type_of_notification| {
      Box::pin(async move {
        println!("Job {:?} was completed, notification {:?} ran ({:?})", job_id, notification_id, type_of_notification);
      })
    }));
    
    jj.on_removed_notification_add(Box::new(|job_id, notification_id, type_of_notification| {
      Box::pin(async move {
        println!("Job {:?} was removed, notification {:?} ran ({:?})", job_id, notification_id, type_of_notification);
      })
    }));

    let five_s_job = Job::new("1/5 * * * * *", |_uuid, _l| {
      println!("{:?} I run every 5 seconds", chrono::Utc::now());
    })
            .unwrap();
    sched.add(five_s_job);
  
    let four_s_job_async = Job::new_async("1/4 * * * * *", |_uuid, _l| Box::pin(async move {
      println!("{:?} I run async every 4 seconds", chrono::Utc::now());
    })).unwrap();
    sched.add(four_s_job_async);
  
    sched.add(
      Job::new("1/30 * * * * *", |_uuid, _l| {
        println!("{:?} I run every 30 seconds", chrono::Utc::now());
      })
              .unwrap(),
    );
  
    sched.add(
      Job::new_one_shot(Duration::from_secs(18), |_uuid, _l| {
        println!("{:?} I'm only run once", chrono::Utc::now());
      }).unwrap()
    );
  
    sched.add(
      Job::new_one_shot_async(Duration::from_secs(16), |_uuid, _l| Box::pin( async move {
        println!("{:?} I'm only run once async", chrono::Utc::now());
      })).unwrap()
    );
  
    let jj = Job::new_repeated(Duration::from_secs(8), |_uuid, _l| {
      println!("{:?} I'm repeated every 8 seconds", chrono::Utc::now());
    }).unwrap();
    sched.add(jj);
  
    let jja = Job::new_repeated_async(Duration::from_secs(7), |_uuid, _l| Box::pin(async move {
      println!("{:?} I'm repeated async every 7 seconds", chrono::Utc::now());
    })).unwrap();
    sched.add(jja);

    sched.start().await;
}

原文链接:https://github.com/mvniekerk/tokio-cron-scheduler/releases/tag/0.4

--

From 日报小组 BobQin,FBI小白

社区学习交流平台订阅:

  • Rustcc论坛: 支持rss

  • 微信公众号:Rust语言中文社区

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值