• Stars
    star
    223
  • Rank 173,042 (Top 4 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The logical evolution of the include_str macro for embedding a directory tree into your binary.

include_dir

Continuous Integration license Crates.io Docs.rs

An evolution of the include_str!() and include_bytes!() macros for embedding an entire directory tree into your binary.

Rendered Documentation:

Getting Started

The include_dir!() macro works very similarly to the normal include_str!() and include_bytes!() macros. You pass the macro a file path and assign the returned value to some static variable.

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());
    }
}

Features

  • Embed a directory tree into your binary at compile time
  • Find a file in the embedded directory
  • Search for files using a glob pattern (requires the globs feature)
  • File metadata (requires the metadata feature)

To-Do list:

  • Compression?

More Repositories

1

mdbook-epub

An experimental mdbook backend for creating EPUB documents.
Rust
329
star
2

rust-ffi-guide

A guide for doing FFI using Rust
Rust
271
star
3

arcs

A Rust CAD System
Rust
245
star
4

mdbook-linkcheck

A backend for `mdbook` which will check your links for you.
Rust
109
star
5

plugins_in_rust

Implementing plugins with dynamically loaded libraries and Rust
Rust
102
star
6

gcode-rs

A streaming gcode parser built with embedded applications in mind
G-code
79
star
7

ffi_helpers

A crate to make working with FFI code easier.
Rust
54
star
8

constraints

An experiment in writing algebraic constraint solvers for 3D CAD
Rust
49
star
9

markedit

A library for manipulating unstructured Markdown documents.
Rust
49
star
10

latex-rs

An ergonomic library for programatically generating LaTeX documents and reports.
Rust
47
star
11

noise-gate

A simple Noise Gate algorithm for splitting an audio stream into chunks based on volume/silence
Rust
44
star
12

adventures-in-motion-control

A realistic simulator for a 3D printer motion controller
Rust
31
star
13

gcodes

A basic C# gcode parser and interpreter
C#
30
star
14

scad-rs

A Rust implementation of the OpenSCAD virtual machine.
Rust
25
star
15

lastpass

An unofficial interface to the LastPass API.
Rust
25
star
16

linkcheck

A library for extracting and validating links.
Rust
22
star
17

const-arrayvec

An implementation of the arrayvec crate using const generics
Rust
19
star
18

adventures.michaelfbryan.com

A simple blog for documenting my thoughts and adventures
HTML
15
star
19

iec

A proof-of-concept IEC 61131-3 Compiler.
Rust
15
star
20

rust-closures-and-ffi

Rust
14
star
21

static-analyser-in-rust

An experiment in using literate programming to write a static analysis tool in Rust
Python
14
star
22

repo-backup

A small tool for downloading all your GitHub repositories locally.
Rust
14
star
23

ffi-helpers

Miscellaneous helpers for handling errors in a FFI context
Rust
13
star
24

tinyvm-rs

An incremental port of jakogut/tinyvm to Rust
Rust
13
star
25

github-template

A template project for use with cargo-generate
Rust
12
star
26

calc

Create your own JIT compiled calculator in Rust using LLVM and inkwell.
Rust
11
star
27

non-trivial-macros

Rust
10
star
28

thin-trait-objects

Rust
9
star
29

chmlib

Rust bindings to the CHMLib C library
Rust
8
star
30

mdbook-docker-image

A docker image with `mdbook` and common plugins.
Dockerfile
8
star
31

kaleidoscope

Yet another implementation of the LLVM Kaleidoscope tutorial, in Rust.
Rust
8
star
32

wit-lsp

A Language Server implementation for the WIT interface definition language
Rust
7
star
33

deserializing-binary-data-files

Rust
6
star
34

mcc

A toy compiler for a subset of the C programming language.
Rust
6
star
35

sum_type

A convenience macro for creating a wrapper enum which may be one of several distinct types
Rust
6
star
36

rustc-internal-docs

Internal documentation for the Rust compiler including librustc, liballoc, libstd and friends
Rust
5
star
37

spider_board

A blackboard scraper for Curtin University students
Python
4
star
38

unsafe-tips-and-tricks

Miscellaneous tips and tricks I've picked up in my time writing unsafe Rust code
Rust
4
star
39

aioscraper

A web scraper building on top of Python's asyncio library
Python
3
star
40

cdir

Continuous Deployment in Rust
Rust
3
star
41

workflow-timer

Keep an eye on how long your GitHub Actions jobs are taking.
TypeScript
3
star
42

mdbook-test

An experimental backend for testing an mdbook document
Rust
3
star
43

keep-a-changelog-parser

A parser for the Keep-A-Changelog format
Rust
3
star
44

MIPS

A MIPS emulator written in Rust
Rust
2
star
45

cargo-metrics

A small guide to using `rustc` for building tools to analyse Rust code.
Rust
2
star
46

pid

Rust
2
star
47

libloading-bindgen

Rust
2
star
48

dotfiles

Configuration files specific to my Arch Linux installation.
Python
2
star
49

sched

Cron for Humans... In Rust!
Rust
2
star
50

cheat-sheets

A bunch of super useful snippets and notes
TeX
2
star
51

iec-parser

Rust
2
star
52

lib3mf

Rust
2
star
53

serde-spanned

Rust
2
star
54

modern-webassembly

Code to accompany my Using WebAssembly in the Modern World article.
Rust
2
star
55

stateful-native-library

Rust
2
star
56

advent-of-code-2020

Rust
1
star
57

xsd-rs

Generate Rust types from an XML Schema.
C#
1
star
58

accel-stepper

A mirror of the accel-stepper crate
Rust
1
star
59

anpp-ts

A TypeScript port of the Advanced Navigation Packet Protocol
TypeScript
1
star
60

stepperfin

Proof-of-concept 3D printer firmware written on top of the Rust embedded-hal.
Rust
1
star
61

backlight

A simple Linux utility for changing your laptop screen's brightness
Rust
1
star
62

cheesecake_kwalitee_index

A system that evaluates the kwalitee of all the packages on PyPI
Python
1
star
63

io-callisto

A space-based realtime strategy game focused on territorial expansion, colonialism, and defence.
TypeScript
1
star
64

sieve-of-zakiya

An attempt at implementing the Segmented Sieve of Zakiya in Rust.
Forth
1
star
65

mdbook-html

An alternate HTML backend for mdbook.
Rust
1
star
66

ansible_setup

The setup I use for my home computers and web server
HTML
1
star
67

llvm-config

An interface to the llvm-config tool from Rust
Rust
1
star
68

blog

A blog created using Pelican, sitting at http://michaelfbryan.com/
CSS
1
star
69

airbrush

Rust
1
star
70

wasmer-borealis

Rust
1
star
71

mini_wiki

A lightweight wiki framework designed created using Flask
Python
1
star
72

irc_bot

A proof-of-concept IRC bot built using the actor model
Rust
1
star
73

futhark-rs

Utilities for embedding Futhark code in Rust projects.
Rust
1
star
74

json-stream

Rust
1
star
75

create-a-botnet

Rust
1
star
76

wasm-game-of-life

An implementation of Conway's Game of Life using Rust and WASM
Rust
1
star
77

cxx-experiment

Rust
1
star
78

json-eater

Rust
1
star
79

github-workspace-template

A template project for creating a workspace project use with cargo-generate
Rust
1
star