~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


cba24b8a pyrossh

7 months ago
improve docs
Files changed (1) hide show
  1. README.md +9 -23
README.md CHANGED
@@ -76,50 +76,37 @@ If the feature `debug-embed` is enabled or the binary compiled in release mode a
76
76
  Otherwise the files are listed from the file system on each call.
77
77
 
78
78
  ## Attributes
79
- ### `prefix`
79
+ `prefix`
80
80
 
81
81
  You can add `#[prefix = "my_prefix/"]` to the `RustEmbed` struct to add a prefix
82
82
  to all of the file paths. This prefix will be required on `get` calls, and will
83
83
  be included in the file paths returned by `iter`.
84
84
 
85
- ### `metadata_only`
85
+ `metadata_only`
86
86
 
87
87
  You can add `#[metadata_only = true]` to the `RustEmbed` struct to exclude file contents from the
88
88
  binary. Only file paths and metadata will be embedded.
89
89
 
90
- ### `allow_missing`
90
+ `allow_missing`
91
91
 
92
92
  You can add `#[allow_missing = true]` to the `RustEmbed` struct to allow the embedded folder to be missing.
93
93
  In that case, RustEmbed will be empty.
94
94
 
95
95
  ## Features
96
96
 
97
- ### `debug-embed`
98
-
99
- Always embed the files in the binary, even in debug mode.
97
+ * `debug-embed`: Always embed the files in the binary, even in debug mode.
100
-
101
- ### `interpolate-folder-path`
102
-
103
- Allow environment variables to be used in the `folder` path. Example:
98
+ * `interpolate-folder-path`: Allow environment variables to be used in the `folder` path.
104
-
105
99
  ```rust
106
100
  #[derive(Embed)]
107
101
  #[folder = "$CARGO_MANIFEST_DIR/foo"]
108
102
  struct Asset;
109
103
  ```
110
-
111
104
  This will pull the `foo` directory relative to your `Cargo.toml` file.
112
105
 
113
- ### `compression`
114
-
115
- Compress each file when embedding into the binary. Compression is done via [include-flate](https://crates.io/crates/include-flate).
106
+ * `compression`: Compress each file when embedding into the binary. Compression is done via [include-flate](https://crates.io/crates/include-flate).
116
-
117
- ### `include-exclude`
118
- Filter files to be embedded with multiple `#[include = "*.txt"]` and `#[exclude = "*.jpg"]` attributes.
119
- Matching is done on relative file paths, via [globset](https://crates.io/crates/globset).
120
- `exclude` attributes have higher priority than `include` attributes.
121
- Example:
122
107
 
108
+ * `include-exclude`: Filter files to be embedded with multiple `#[include = "*.txt"]` and `#[exclude = "*.jpg"]` attributes.
109
+ Matching is done on relative file paths, via [globset](https://crates.io/crates/globset). `exclude` attributes have higher priority than `include` attributes.
123
110
  ```rust
124
111
  use rust_embed::Embed;
125
112
 
@@ -131,8 +118,7 @@ use rust_embed::Embed;
131
118
  struct Asset;
132
119
  ```
133
120
 
134
- ### `deterministic-timestamps`
135
- Overwrite embedded files' timestamps with `0` to preserve deterministic builds with `debug-embed` or release mode
121
+ * `deterministic-timestamps`: Overwrite embedded files' timestamps with `0` to preserve deterministic builds with `debug-embed` or release mode
136
122
 
137
123
  ## Usage
138
124