{"id":16270789,"url":"https://github.com/fboulnois/include_dir_as_map","last_synced_at":"2025-10-03T00:31:29.922Z","repository":{"id":194137077,"uuid":"690325016","full_name":"fboulnois/include_dir_as_map","owner":"fboulnois","description":"Embed files from a directory in a rust binary as a hashmap","archived":false,"fork":false,"pushed_at":"2023-11-25T19:51:24.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T21:33:28.425Z","etag":null,"topics":["actix","actix-web","embed","rust","rust-lang","static-server","web"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fboulnois.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-12T01:28:28.000Z","updated_at":"2024-05-19T07:25:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d588fa2-c8d4-4262-a75e-a4072a4d95e9","html_url":"https://github.com/fboulnois/include_dir_as_map","commit_stats":null,"previous_names":["fboulnois/include_dir_as_map"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Finclude_dir_as_map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Finclude_dir_as_map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Finclude_dir_as_map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Finclude_dir_as_map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fboulnois","download_url":"https://codeload.github.com/fboulnois/include_dir_as_map/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235053760,"owners_count":18928440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actix","actix-web","embed","rust","rust-lang","static-server","web"],"created_at":"2024-10-10T18:11:37.774Z","updated_at":"2025-10-03T00:31:29.574Z","avatar_url":"https://github.com/fboulnois.png","language":"Rust","readme":"# include_dir_as_map\n\nA procedural macro which embeds files from a directory into the rust binary as\na hashmap. This can be used to embed assets such as images, html, css, and js.\n\n`include_dir_as_map` extends `include_str!()` and `include_bytes!()` and is\nsimilar to [`include_dir`](https://github.com/Michael-F-Bryan/include_dir).\n\n## Usage\n\nInclude the following section in `Cargo.toml`:\n\n```toml\n[dependencies]\ninclude_dir_as_map=\"1\"\n```\n\nIn your rust code, include the following:\n\n```rust ignore\n// DirMap is an alias for HashMap\u003cString, Vec\u003cu8\u003e\u003e\nuse include_dir_as_map::{include_dir_as_map, DirMap};\n\n// Environment variables will be expanded at compile time\nlet dirmap: DirMap = include_dir_as_map!(\"$CARGO_MANIFEST_DIR\");\nlet bytes = dirmap.get(\"Cargo.toml\")?;\n```\n\nAll paths are relative to the embedded directory, so if `root` contains files\n`root/foo.txt` and `root/next/bar.txt`, then `include_dir_as_map!(\"root\")` will\nresult in a hashmap with keys `foo.txt` and `next/bar.txt`.\n\n## Features\n\nBy default, the files are read from the filesystem at runtime in debug mode for\ncompilation speed. To override this behavior, enable the `always-embed` feature\nin `Cargo.toml`:\n\n```toml\n[dependencies]\ninclude_dir_as_map={ version=\"1\", features=[ \"always-embed\" ] }\n```\n\n## Examples\n\nSee the `examples/` directory for more examples:\n\n* [Hello World](examples/example-hello-world)\n* [Actix Web](examples/example-actix-web)\n\n## Development\n\n### Building\n\nTo build the library and examples:\n\n```sh\ncargo build --workspace\n```\n\n### Testing\n\nTo test the library and procedural macro:\n\n```sh\ncargo test --workspace\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboulnois%2Finclude_dir_as_map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffboulnois%2Finclude_dir_as_map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboulnois%2Finclude_dir_as_map/lists"}