#directory #embed #assets #directory-tree #file-metadata #glob-pattern #include

comfy_include_dir

将目录内容嵌入到您的二进制文件中

1 个不稳定版本

0.7.3 2023年9月24日

#1439开发工具

Download history 73/week @ 2024-03-11 106/week @ 2024-03-18 84/week @ 2024-03-25 100/week @ 2024-04-01 78/week @ 2024-04-08 105/week @ 2024-04-15 136/week @ 2024-04-22 152/week @ 2024-04-29 101/week @ 2024-05-06 109/week @ 2024-05-13 174/week @ 2024-05-20 86/week @ 2024-05-27 72/week @ 2024-06-03 58/week @ 2024-06-10 82/week @ 2024-06-17 84/week @ 2024-06-24

每月 309 次下载
4 个开源包中使用 (通过 comfy-core)

MIT 协议

18KB
266

include_dir

Continuous Integration license Crates.io Docs.rs

include_str!()include_bytes!() 宏的进化,可以将整个目录树嵌入到您的二进制文件中。

渲染文档

入门指南

include_dir!() 宏的工作方式与正常的 include_str!()include_bytes!() 宏非常相似。您将文件路径传递给宏,并将返回值赋给某个 static 变量。

use include_dir::{include_dir, Dir};

static PROJECT_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR");

// of course, you can retrieve a file by its full path
let lib_rs = PROJECT_DIR.get_file("src/lib.rs").unwrap();

// you can also inspect the file's contents
let body = lib_rs.contents_utf8().unwrap();
assert!(body.contains("SOME_INTERESTING_STRING"));

// you can search for files (and directories) using glob patterns
#[cfg(feature = "glob")]
{
    let glob = "**/*.rs";
    for entry in PROJECT_DIR.find(glob).unwrap() {
        println!("Found {}", entry.path().display());
    }
}

功能

  • 在编译时将目录树嵌入到您的二进制文件中
  • 在嵌入的目录中查找文件
  • 使用glob模式搜索文件(需要 globs 功能)
  • 文件元数据(需要 metadata 功能)

待办事项清单

  • 压缩?

依赖项

~94KB