前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Rust日报】2022-02-07 《Rust 编码规范》更新到 V0.2 版本

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

作者头像
MikeLoveRust
发布2022-03-24 13:11:24
4510
发布2022-03-24 13:11:24
举报
文章被收录于专栏:Rust语言学习交流

《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的调度。也可以在一个瞬间安排任务,或者在固定的时间内重复它们。

代码语言:javascript
复制
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小白

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-02-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Rust语言学习交流 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 《Rust 编码规范》更新到 V0.2 版本
  • Rust 的热加载
  • CADBase 平台发布
  • rust-protobuf: 过去,现在和未来
  • ttokio-cron-scheduler: 0.4 版本发布
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档