You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Initial plan
* Add zstd compression support
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Add test coverage for DynamicFile compression methods and fix clippy warning
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Fix clippy warnings and add explicit test coverage for DynamicFile compression methods
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Fix dynamic tests to handle both always-embed and debug modes correctly
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Format code with cargo fmt
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Make zstd compression an optional feature
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Add comprehensive tests for optional zstd feature
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
* Make compression-zstd opt-in and add documentation
Changes:
- Remove compression-zstd from default features (requires C bindings)
- Add comprehensive documentation for zstd compression feature
- Document compression functions and config methods
- Reorganize README features section for clarity
The zstd feature is now opt-in due to its C library dependency,
which may not be compatible with all build environments.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: SeriousBug <1008124+SeriousBug@users.noreply.github.com>
Co-authored-by: Kaan Barmore-Genc <kaan@bgenc.dev>
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+28-7Lines changed: 28 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ executable in exchange for better performance at runtime. In particular:
24
24
or decompress anything at runtime.
25
25
- If the compression makes little difference, for example a jpeg file won't
26
26
compress much further if at all, then the compressed version is not included.
27
-
- You can also disable this behavior by adding an attribute `#[gzip = false]` and `#[br = false]`
27
+
- You can also disable this behavior by adding an attribute `#[gzip = false]`, `#[br = false]`, or `#[zstd = false]`
28
28
When disabled, the compressed files won't be included for that embed.
29
29
- Some metadata that is useful for web headers like `ETag` and `Last-Modified`
30
30
are computed ahead of time and embedded into the executable. This makes it
@@ -68,17 +68,19 @@ The path for the `folder` is resolved relative to where `Cargo.toml` is.
68
68
69
69
### Disabling compression
70
70
71
-
You can add `#[gzip = false]`and/or `#[br = false]` attributes to your embed to
72
-
disable gzipand brotli compression for the files in that embed.
71
+
You can add `#[gzip = false]`, `#[br = false]`, and/or `#[zstd = false]` attributes to your embed to
72
+
disable gzip, brotli, and/or zstd compression for the files in that embed.
73
73
`rust-embed-for-web` will only include compressed files where the compression
74
74
actually makes files smaller so files that won't compress well like images or
75
75
archives already don't include their compressed versions. However you can
76
76
77
77
## Features
78
78
79
-
Both of the following features are enabled by default.
79
+
### Default Features
80
80
81
-
### `interpolate-folder-path`
81
+
The following features are enabled by default.
82
+
83
+
#### `interpolate-folder-path`
82
84
83
85
Allow environment variables and `~`s to be used in the `folder` path. Example:
84
86
@@ -91,7 +93,7 @@ struct Asset;
91
93
`~` will expand into your home folder, and `${PROJECT_NAME}` will expand into
92
94
the value of the `PROJECT_NAME` environment variable.
93
95
94
-
### `include-exclude`
96
+
####`include-exclude`
95
97
96
98
You can filter which files are embedded by adding one or more `#[include = "*.txt"]` and `#[exclude = "*.jpg"]` attributes.
97
99
Matching is done on relative file paths --the paths you use for the `.get` call-- via [`globset`](https://docs.rs/globset/latest/globset/).
@@ -111,7 +113,26 @@ For example, if you wanted to exclude all `.svg` files except for one named
111
113
structAssets;
112
114
```
113
115
114
-
### `prefix`
116
+
### Optional Features
117
+
118
+
#### `compression-zstd`
119
+
120
+
Enables zstd compression support for embedded files. When enabled, files will be compressed with zstd (in addition to gzip and brotli), allowing you to serve zstd-compressed content to clients that support it.
121
+
122
+
**Note:** This feature is **not enabled by default** because the `zstd` crate uses C bindings, which may not be compatible with all build environments.
123
+
124
+
To enable zstd compression, add this to your `Cargo.toml`:
125
+
126
+
```toml
127
+
[dependencies]
128
+
rust-embed-for-web = { version = "11.2.1", features = ["compression-zstd"] }
129
+
```
130
+
131
+
You can also disable zstd compression for specific embeds using the `#[zstd = false]` attribute as described in the "Disabling compression" section above.
132
+
133
+
### Other Configuration
134
+
135
+
#### `prefix`
115
136
116
137
You can specify a prefix, which will be added to the path of the files. For example:
0 commit comments