dev-tool

Crates.iodev-tool
lib.rsdev-tool
version0.1.12
created_at2025-08-29 08:55:55.872917+00
updated_at2025-09-17 01:28:14.732459+00
descriptiondev-tool(变更为mitoo)是一个Rust工具包类库,对文件、加密解密、转码、正则、线程池、sqlite等方法进行封装,组成各种Util工具类。
homepage
repositoryhttps://gitee.com/ranfusheng/mitoo.git
max_upload_size
id1815563
size176,718
(TheoryDance)

documentation

https://crates.io/crates/mitoo

README

dev-tool

介绍

dev-tool 是一个Rust工具包类库,对配置读取、文件操作、加解密、转码、正则、线程等方法进行封装,自定义或集成各种Util工具类。

dev-tool 后续变更为 mitoo

模块说明

  • conf_util 读取配置文件
  • date_util 日期及时间工具
  • file_util 文件操作工具
  • stream_util 流操作工具(TODO)
  • io_util io工具(TODO)
  • log_util 日志工具
  • re_util工具 正则工具
  • secure_util 常规加解密工具,含摘要算法等处理
  • thread_util 线程工具
  • sqlite_util SQLite数据库操作工具

示例一:conf_util 配置使用说明

实现了json与yaml,作为配置使用,用户是知道配置的内容及格式的,当多层配置时,可以直接通过x.y.z.w方式直接对应的数据,具体使用如下:

特别注意:不管是对象,还是数组,都是直接通过点操作的,如 obj.children.name 其中obj是对象,children是一个数组,name是children中对象的一个属性,当obj.children.name获取的是children数组中所有对象的name值。

use dev_tool::YamlWrapper;

#[test]
fn test_config_util() {
    let wrapper = JsonWrapper::new("docs/config.yaml").unwrap(); // yaml配置
    // let warpper = YamlWrapper::from_string("......").unwrap();

    // 注意: 这里面的children是一个数组,不管是数组还是对象,都是通过点来操作
    let x = wrapper.get("address.children.name");
    // address.children.name = [String("r"), String("s")]
    println!("address.children.name = {:?}", x);
    println!("=============================================================");

    // 作为配置使用,正常是知晓需要
    let x = wrapper.get_one("address.x.y").as_str().unwrap();
    // address.x.y = hello, json!
    println!("address.x.y = {}", x);
}

示例二:sqlite 数据库读取

// 注意:这里需引入了两个FromSqliteRow,一个用于注解,一个用于扩写后的代码使用
use dev_tool::sqlite_util::{FromSqliteRow, SqliteClient};
use from_sqlite_row_macro::FromSqliteRow;
 
// 假设存在一个 users 表,定义对应的结构体
#[derive(Debug, FromSqliteRow)]
struct User {
    id: i64, // 不要使用i32(其没有实现对应的trait)
    name: String,
}
 
#[test]
fn it_works() {
    let client = SqliteClient::new("test.db").expect("Failed to create SqliteUtil");
    let user_results = client.query::<User>("SELECT id, name FROM users");
    println!("User results: {:?}", user_results);
    for item in user_results {
        println!("id = {}, name = {}", item.id, item.name);
    }
}

安装教程

cargo add mitoo

参与贡献

  1. Fork 本仓库

  2. 新建 Feat_xxx 分支

  3. 提交代码

  4. 新建 Pull Request

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/
Commit count: 0

cargo fmt