Vendor asic-rs 0.8.1 (280 crates, offline builds) + wxWidgets 3.3.3 (pristine + patch queue); UI spec + ADR-0003; M1 on asic-rs
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"ef6710a065ae47d9654e8178dbd90dc171640a9f4bb38c6a2b6a540d8bdd438c","CHANGELOG.md":"9c7e0ea6eb4a284f20727b5f3d657666107fc2fc39c6bfdac433ba1fdc4fa253","Cargo.lock":"d87d451a1ae6e41fb9ca48f5eae80d963faed9e40509382254d60e58c65414b8","Cargo.toml":"67f128aec53f122e7b063b4707bebbf44e606418068d08785e4dd3cf185052fd","Cargo.toml.orig":"ed1df4369e8b23b775407785a734da8c5521043172d80be67b7651dbaa48a56d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"88d1e3160df48926ad3310a8ec5699b502889565908f1be7e77cd21282c7a709","README.md":"5a7f048730d9cadc4d3ba7d4e635a28b4681e8e7bee276d914cc088855fdc4e0","src/level.rs":"e2d1fc5ee3bf231c793d5efaa8380a91e5441cfca763e83856a248ca3bbda6ce","src/lib.rs":"27b464912255d96a69c9fcaa50ad413beb8187a291ad0c30bfa7a05f93c58b75","src/unshared.rs":"02114ed14f0c8026516355d10bdbe4f2e45610d6545e402878addabeade11504","src/util.rs":"452adb6d2ea030d8e55aba3575dcdf7ad9c3ac5f1529280773940ef955fb4f1a"},"package":"6e8ccc4ea9f6acc32d102c0f6d471d11d913ad15f20c04de743374861fa1d414"}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "a867d186019e1df2d29859be9478b77661ba3484"
|
||||
},
|
||||
"path_in_vcs": "crates/compression-core"
|
||||
}
|
||||
Vendored
+75
@@ -0,0 +1,75 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.4.33](https://github.com/Nullus157/async-compression/compare/compression-core-v0.4.32...compression-core-v0.4.33) - 2026-09-02
|
||||
|
||||
### Other
|
||||
|
||||
- Fix safety contract on assume_init, use asserts ([#479](https://github.com/Nullus157/async-compression/pull/479))
|
||||
- Enforce WriteBuffer bounds checks in release builds ([#477](https://github.com/Nullus157/async-compression/pull/477))
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix `WriteBuffer::assume_init` to track initialization relative to the written position without adding overlapping calls, and enforce bounds checks for initialization setters in release builds ([#475](https://github.com/Nullus157/async-compression/issues/475)).
|
||||
- Enforce `WriteBuffer::advance` and `WriteBuffer::written` initialization checks in release builds to prevent safe access to uninitialized memory ([#477](https://github.com/Nullus157/async-compression/pull/477)).
|
||||
|
||||
## [0.4.32](https://github.com/Nullus157/async-compression/compare/compression-core-v0.4.31...compression-core-v0.4.32) - 2026-04-21
|
||||
|
||||
### Other
|
||||
|
||||
- Include license files in published crates ([#467](https://github.com/Nullus157/async-compression/pull/467))
|
||||
|
||||
## [0.4.31](https://github.com/Nullus157/async-compression/compare/compression-core-v0.4.30...compression-core-v0.4.31) - 2025-11-21
|
||||
|
||||
### Added
|
||||
|
||||
- Add uninitialized output buffer support ([#414](https://github.com/Nullus157/async-compression/pull/414))
|
||||
|
||||
## [0.4.30](https://github.com/Nullus157/async-compression/compare/compression-core-v0.4.29...compression-core-v0.4.30) - 2025-11-06
|
||||
|
||||
### Other
|
||||
|
||||
- Simplify `WriteBuffer`: Rm `unwritten_initialized_mut` ([#413](https://github.com/Nullus157/async-compression/pull/413))
|
||||
- Implement new traits `DecodeV2`/`EncodeV2` ([#398](https://github.com/Nullus157/async-compression/pull/398))
|
||||
- Disable nightly feature `doc_auto_cfg` on docsrs ([#392](https://github.com/Nullus157/async-compression/pull/392))
|
||||
|
||||
## [0.4.29](https://github.com/Nullus157/async-compression/compare/compression-core-v0.4.28...compression-core-v0.4.29) - 2025-08-28
|
||||
|
||||
### Other
|
||||
|
||||
- Update Deps.rs badge ([#380](https://github.com/Nullus157/async-compression/pull/380))
|
||||
- move async-compression to crates/ ([#379](https://github.com/Nullus157/async-compression/pull/379))
|
||||
- Refactor compression_core::util ([#373](https://github.com/Nullus157/async-compression/pull/373))
|
||||
|
||||
## [0.4.28](https://github.com/Nullus157/async-compression/compare/compression-core-v0.4.27...compression-core-v0.4.28) - 2025-08-23
|
||||
|
||||
### Fixed
|
||||
|
||||
- fix wasi ci testing and update doc in README ([#367](https://github.com/Nullus157/async-compression/pull/367))
|
||||
|
||||
### Other
|
||||
|
||||
- Have separate package.version field for compression-* ([#369](https://github.com/Nullus157/async-compression/pull/369))
|
||||
- Separate codecs as a separate crate, allow direct configuration ([#363](https://github.com/Nullus157/async-compression/pull/363))
|
||||
- Release async-compression 0.4.8 ([#265](https://github.com/Nullus157/async-compression/pull/265))
|
||||
- prepare release 0.4.7
|
||||
- prepare release 0.4.6
|
||||
- prepare release 0.4.3
|
||||
- *(async-compression)* prepare release 0.4.2
|
||||
- prepare release 0.4.1 ([#236](https://github.com/Nullus157/async-compression/pull/236))
|
||||
- prepare async-compression release 0.4.0
|
||||
- add deps and license badge
|
||||
- remove references to old `stream` crate feature
|
||||
- update repo links
|
||||
- Update references to master branch
|
||||
- Enable testing with all possible feature sets
|
||||
- Update links in readme for repo location
|
||||
- Mention features for local testing
|
||||
- Update README.md
|
||||
- Add licenses and trivial readme
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "compression-core"
|
||||
version = "0.4.33"
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2018"
|
||||
name = "compression-core"
|
||||
version = "0.4.33"
|
||||
authors = [
|
||||
"Wim Looman <wim@nemo157.com>",
|
||||
"Allen Bui <fairingrey@gmail.com>",
|
||||
]
|
||||
build = false
|
||||
autolib = false
|
||||
autobins = false
|
||||
autoexamples = false
|
||||
autotests = false
|
||||
autobenches = false
|
||||
description = """
|
||||
Abstractions for compression algorithms.
|
||||
"""
|
||||
readme = "README.md"
|
||||
categories = [
|
||||
"compression",
|
||||
"asynchronous",
|
||||
]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/Nullus157/async-compression"
|
||||
resolver = "2"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
[lib]
|
||||
name = "compression_core"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints.rust]
|
||||
rust_2018_idioms = "deny"
|
||||
|
||||
[lints.rust.missing_debug_implementations]
|
||||
level = "deny"
|
||||
priority = -1
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
[package]
|
||||
name = "compression-core"
|
||||
version = "0.4.33"
|
||||
description = """
|
||||
Abstractions for compression algorithms.
|
||||
"""
|
||||
authors.workspace = true
|
||||
categories.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
readme = "../../README.md"
|
||||
repository.workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
[dependencies]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 the rustasync developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
# async-compression
|
||||
|
||||
[![crates.io version][1]][2] ![build status][3]
|
||||
[![downloads][5]][6] [![docs.rs docs][7]][8]
|
||||
![MIT or Apache 2.0 licensed][9]
|
||||
[![dependency status][10]][11]
|
||||
|
||||
This crate provides adaptors between compression crates and Rust's modern
|
||||
asynchronous IO types.
|
||||
|
||||
- [Documentation][8]
|
||||
- [Crates.io][2]
|
||||
- [Releases][releases]
|
||||
|
||||
## Development
|
||||
|
||||
When developing you will need to enable appropriate features for the different
|
||||
test cases to run, the simplest is `cargo test --all-features`, but you can
|
||||
enable different subsets of features as appropriate for the code you are
|
||||
testing to avoid compiling all dependencies, e.g. `cargo test --features
|
||||
tokio,gzip`.
|
||||
|
||||
To prepare for a pull request, you can run several other checks:
|
||||
|
||||
1. `fmt`
|
||||
|
||||
```bash
|
||||
cargo fmt --all
|
||||
cargo clippy --no-deps
|
||||
```
|
||||
|
||||
2. `build`
|
||||
|
||||
```bash
|
||||
cargo build --lib --all-features
|
||||
```
|
||||
|
||||
3. `nextest`
|
||||
|
||||
```bash
|
||||
cargo --locked nextest run --workspace --all-features
|
||||
```
|
||||
|
||||
4. `hack check`
|
||||
|
||||
```bash
|
||||
cargo hack check --workspace --feature-powerset --all-targets --skip 'all,all-algorithms,all-implementations'
|
||||
```
|
||||
|
||||
5. `wasm32` - Linux only
|
||||
|
||||
```bash
|
||||
gh release download --repo WebAssembly/wasi-sdk --pattern 'wasi-sysroot-*.tar.gz'
|
||||
mkdir -p wasi-sysroot
|
||||
tar xf wasi-sysroot-*.tar.gz --strip-components=1 -C wasi-sysroot
|
||||
|
||||
rustup target add wasm32-wasip1-threads
|
||||
|
||||
export "CFLAGS_wasm32_wasip1_threads=--sysroot=\"${PWD}/wasi-sysroot\" -I\"${PWD}/wasi-sysroot/include/wasm32-wasip1-threads\" -L-I\"${PWD}/wasi-sysroot/lib/wasm32-wasip1-threads\""
|
||||
cargo build --lib --features all-implementations,brotli,bzip2,deflate,gzip,lz4,lzma,xz,zlib,zstd,deflate64 --target wasm32-wasip1-threads
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Licensed under either of
|
||||
|
||||
- [Apache License, Version 2.0](LICENSE-APACHE)
|
||||
- [MIT license](LICENSE-MIT)
|
||||
|
||||
at your option.
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in the work by you shall be dual licensed as above, without any
|
||||
additional terms or conditions.
|
||||
|
||||
[1]: https://img.shields.io/crates/v/async-compression.svg?style=flat-square
|
||||
[2]: https://crates.io/crates/async-compression
|
||||
[3]: https://img.shields.io/github/actions/workflow/status/Nullus157/async-compression/base.yml?style=flat-square
|
||||
[5]: https://img.shields.io/crates/d/async-compression.svg?style=flat-square
|
||||
[6]: https://crates.io/crates/async-compression
|
||||
[7]: https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square
|
||||
[8]: https://docs.rs/async-compression
|
||||
[9]: https://img.shields.io/crates/l/async-compression.svg?style=flat-square
|
||||
[10]: https://deps.rs/crate/async-compression/latest/status.svg?style=flat-square
|
||||
[11]: https://deps.rs/crate/async-compression
|
||||
[releases]: https://github.com/Nullus157/async-compression/releases
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
/// Level of compression data should be compressed with.
|
||||
#[non_exhaustive]
|
||||
#[derive(Default, Clone, Copy, Debug)]
|
||||
pub enum Level {
|
||||
/// Fastest quality of compression, usually produces bigger size.
|
||||
Fastest,
|
||||
|
||||
/// Best quality of compression, usually produces the smallest size.
|
||||
Best,
|
||||
|
||||
/// Default quality of compression defined by the selected compression algorithm.
|
||||
#[default]
|
||||
Default,
|
||||
|
||||
/// Precise quality based on the underlying compression algorithms' qualities. The
|
||||
/// interpretation of this depends on the algorithm chosen and the specific implementation
|
||||
/// backing it. Qualities are implicitly clamped to the algorithm's maximum.
|
||||
Precise(i32),
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
//! Abstractions for compression algorithms.
|
||||
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
mod level;
|
||||
pub mod unshared;
|
||||
pub mod util;
|
||||
|
||||
pub use level::Level;
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#![allow(dead_code)] // unused without any features
|
||||
|
||||
use core::fmt::{self, Debug};
|
||||
|
||||
/// Wraps a type and only allows unique borrowing.
|
||||
///
|
||||
/// The main use case is to wrap a `!Sync` type and implement `Sync` for it as this type blocks
|
||||
/// having multiple shared references to the inner value.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// We must be careful when accessing `inner`, there must be no way to create a shared reference to
|
||||
/// it from a shared reference to an `Unshared`, as that would allow creating shared references on
|
||||
/// multiple threads.
|
||||
///
|
||||
/// As an example deriving or implementing `Clone` is impossible, two threads could attempt to
|
||||
/// clone a shared `Unshared<T>` reference which would result in accessing the same inner value
|
||||
/// concurrently.
|
||||
pub struct Unshared<T> {
|
||||
inner: T,
|
||||
}
|
||||
|
||||
impl<T> From<T> for Unshared<T> {
|
||||
fn from(inner: T) -> Self {
|
||||
Unshared { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Unshared<T> {
|
||||
/// Constructs a new `Unshared` from `inner`.
|
||||
pub fn new(inner: T) -> Self {
|
||||
Self::from(inner)
|
||||
}
|
||||
|
||||
/// Returns a unique reference to the inner `T`.
|
||||
pub fn get_mut(&mut self) -> &mut T {
|
||||
&mut self.inner
|
||||
}
|
||||
}
|
||||
|
||||
/// Safety: See comments on main docs for `Unshared`
|
||||
unsafe impl<T> Sync for Unshared<T> {}
|
||||
|
||||
impl<T> Debug for Unshared<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct(core::any::type_name::<T>()).finish()
|
||||
}
|
||||
}
|
||||
Vendored
+390
@@ -0,0 +1,390 @@
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
pub const fn _assert_send<T: Send>() {}
|
||||
pub const fn _assert_sync<T: Sync>() {}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PartialBuffer<B> {
|
||||
buffer: B,
|
||||
index: usize,
|
||||
}
|
||||
|
||||
impl<B: AsRef<[u8]>> PartialBuffer<B> {
|
||||
pub fn new(buffer: B) -> Self {
|
||||
Self { buffer, index: 0 }
|
||||
}
|
||||
|
||||
pub fn written(&self) -> &[u8] {
|
||||
&self.buffer.as_ref()[..self.index]
|
||||
}
|
||||
|
||||
/// Convenient method for `.writen().len()`
|
||||
pub fn written_len(&self) -> usize {
|
||||
self.index
|
||||
}
|
||||
|
||||
pub fn unwritten(&self) -> &[u8] {
|
||||
&self.buffer.as_ref()[self.index..]
|
||||
}
|
||||
|
||||
pub fn advance(&mut self, amount: usize) {
|
||||
self.index += amount;
|
||||
debug_assert!(self.index <= self.buffer.as_ref().len());
|
||||
}
|
||||
|
||||
pub fn get_mut(&mut self) -> &mut B {
|
||||
&mut self.buffer
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> B {
|
||||
self.buffer
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: AsRef<[u8]> + AsMut<[u8]>> PartialBuffer<B> {
|
||||
pub fn unwritten_mut(&mut self) -> &mut [u8] {
|
||||
&mut self.buffer.as_mut()[self.index..]
|
||||
}
|
||||
|
||||
pub fn copy_unwritten_from<C: AsRef<[u8]>>(&mut self, other: &mut PartialBuffer<C>) -> usize {
|
||||
let len = self.unwritten().len().min(other.unwritten().len());
|
||||
|
||||
self.unwritten_mut()[..len].copy_from_slice(&other.unwritten()[..len]);
|
||||
|
||||
self.advance(len);
|
||||
other.advance(len);
|
||||
len
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: AsRef<[u8]> + Default> PartialBuffer<B> {
|
||||
pub fn take(&mut self) -> Self {
|
||||
std::mem::take(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: AsRef<[u8]> + AsMut<[u8]>> From<B> for PartialBuffer<B> {
|
||||
fn from(buffer: B) -> Self {
|
||||
Self::new(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
/// Write buffer for compression-codecs.
|
||||
///
|
||||
/// Currently it only supports initialized buffer, but will support uninitialized
|
||||
/// buffer soon.
|
||||
///
|
||||
/// # Layout
|
||||
///
|
||||
/// ```text
|
||||
/// | buffer |
|
||||
/// | written and initialized | unwritten but initialized | unwritten and uninitialized
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct WriteBuffer<'a> {
|
||||
buffer: &'a mut [MaybeUninit<u8>],
|
||||
index: usize,
|
||||
initialized: usize,
|
||||
}
|
||||
|
||||
impl<'a> WriteBuffer<'a> {
|
||||
pub fn new_initialized(buffer: &'a mut [u8]) -> Self {
|
||||
Self {
|
||||
initialized: buffer.len(),
|
||||
// Safety: with initialized set to len of the buffer,
|
||||
// `WriteBuffer` would treat it as a `&mut [u8]`.
|
||||
buffer: unsafe { &mut *(buffer as *mut [u8] as *mut _) },
|
||||
index: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_uninitialized(buffer: &'a mut [MaybeUninit<u8>]) -> Self {
|
||||
Self {
|
||||
buffer,
|
||||
index: 0,
|
||||
initialized: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn capacity(&self) -> usize {
|
||||
self.buffer.len()
|
||||
}
|
||||
|
||||
pub fn as_mut_ptr(&mut self) -> *mut u8 {
|
||||
self.buffer.as_mut_ptr() as *mut _
|
||||
}
|
||||
|
||||
pub fn initialized_len(&self) -> usize {
|
||||
self.initialized
|
||||
}
|
||||
|
||||
pub fn written(&self) -> &[u8] {
|
||||
assert!(self.index <= self.initialized);
|
||||
|
||||
// Safety: All bytes in the returned slice are initialized.
|
||||
unsafe { &*(&self.buffer[..self.index] as *const _ as *const [u8]) }
|
||||
}
|
||||
|
||||
/// Convenient method for `.writen().len()`
|
||||
pub fn written_len(&self) -> usize {
|
||||
self.index
|
||||
}
|
||||
|
||||
/// Buffer has no spare space to write any data
|
||||
pub fn has_no_spare_space(&self) -> bool {
|
||||
self.index == self.buffer.len()
|
||||
}
|
||||
|
||||
/// Initialize all uninitialized, unwritten part to initialized, unwritten part
|
||||
/// Return all unwritten part
|
||||
pub fn initialize_unwritten(&mut self) -> &mut [u8] {
|
||||
self.buffer[self.initialized..]
|
||||
.iter_mut()
|
||||
.for_each(|maybe_uninit| {
|
||||
maybe_uninit.write(0);
|
||||
});
|
||||
self.initialized = self.buffer.len();
|
||||
|
||||
unsafe { &mut *(&mut self.buffer[self.index..] as *mut _ as *mut [u8]) }
|
||||
}
|
||||
|
||||
/// Advance written index within initialized part.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `amount` exceeds the number of initialized, unwritten bytes.
|
||||
pub fn advance(&mut self, amount: usize) {
|
||||
// Check the remaining lengths to avoid overflowing `self.index + amount`.
|
||||
assert!(amount <= self.buffer.len() - self.index);
|
||||
assert!(amount <= self.initialized - self.index);
|
||||
|
||||
self.index += amount;
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
self.index = 0;
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the unwritten part of the buffer without
|
||||
/// ensuring that it has been fully initialized.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must not de-initialize portions of the buffer that have already
|
||||
/// been initialized.
|
||||
///
|
||||
/// This includes any bytes in the region returned by this function.
|
||||
pub unsafe fn unwritten_mut(&mut self) -> &mut [MaybeUninit<u8>] {
|
||||
&mut self.buffer[self.index..]
|
||||
}
|
||||
|
||||
/// Asserts that the first `n` unwritten bytes of the buffer are initialized,
|
||||
/// starting at [`WriteBuffer::written_len`].
|
||||
///
|
||||
/// [`WriteBuffer`] assumes that bytes are never de-initialized, so this method
|
||||
/// does nothing when called with fewer bytes than are already known to be initialized.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `n` exceeds the number of unwritten bytes.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that the first `n` unwritten bytes of the buffer have already been initialized.
|
||||
pub unsafe fn assume_init(&mut self, n: usize) {
|
||||
// Check the remaining length to avoid overflowing `self.index + n`.
|
||||
assert!(n <= self.buffer.len() - self.index);
|
||||
|
||||
self.initialized = self.initialized.max(self.index + n);
|
||||
}
|
||||
|
||||
/// Convenient function combining [`WriteBuffer::assume_init`] and [`WriteBuffer::advance`].
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `n` exceeds the number of unwritten bytes.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that the first `n` unwritten bytes of the buffer have already been initialized.
|
||||
pub unsafe fn assume_init_and_advance(&mut self, n: usize) {
|
||||
assert!(n <= self.buffer.len() - self.index);
|
||||
|
||||
self.index += n;
|
||||
self.initialized = self.initialized.max(self.index);
|
||||
}
|
||||
|
||||
/// Convenient function combining [`WriteBuffer::assume_init`] and [`WriteBuffer::advance`],
|
||||
/// works similar to [`Vec::set_len`].
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `n` exceeds the buffer's capacity.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must ensure that first `n` bytes of the buffer have already been initialized.
|
||||
pub unsafe fn set_written_and_initialized_len(&mut self, n: usize) {
|
||||
assert!(n <= self.buffer.len());
|
||||
|
||||
self.index = n;
|
||||
self.initialized = self.initialized.max(n);
|
||||
}
|
||||
|
||||
pub fn copy_unwritten_from<C: AsRef<[u8]>>(&mut self, other: &mut PartialBuffer<C>) -> usize {
|
||||
fn inner(this: &mut WriteBuffer<'_>, input: &[u8]) -> usize {
|
||||
// Safety: We will never ever write uninitialized bytes into it
|
||||
let out = unsafe { this.unwritten_mut() };
|
||||
|
||||
let len = out.len().min(input.len());
|
||||
|
||||
out[..len]
|
||||
.iter_mut()
|
||||
.zip(&input[..len])
|
||||
.for_each(|(maybe_uninit, byte)| {
|
||||
maybe_uninit.write(*byte);
|
||||
});
|
||||
|
||||
// Safety: We have written `len` bytes of initialized data into it
|
||||
unsafe { this.assume_init_and_advance(len) };
|
||||
len
|
||||
}
|
||||
|
||||
let len = inner(self, other.unwritten());
|
||||
other.advance(len);
|
||||
|
||||
len
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{PartialBuffer, WriteBuffer};
|
||||
use std::{
|
||||
mem::MaybeUninit,
|
||||
panic::{catch_unwind, AssertUnwindSafe},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn advance_within_initialized_buffer() {
|
||||
let mut storage = [1, 2, 3, 4];
|
||||
let mut output = WriteBuffer::new_initialized(&mut storage);
|
||||
|
||||
output.advance(0);
|
||||
assert!(output.written().is_empty());
|
||||
output.advance(2);
|
||||
assert_eq!(output.written(), &[1, 2]);
|
||||
output.advance(2);
|
||||
assert_eq!(output.written(), &[1, 2, 3, 4]);
|
||||
output.advance(0);
|
||||
assert_eq!(output.written(), &[1, 2, 3, 4]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn advance_into_uninitialized_buffer_panics() {
|
||||
let mut allocation = Vec::<u8>::with_capacity(8);
|
||||
let mut output = WriteBuffer::new_uninitialized(&mut allocation.spare_capacity_mut()[..8]);
|
||||
|
||||
output.advance(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn advance_past_initialized_preserves_written_data() {
|
||||
let mut storage = [MaybeUninit::uninit(); 4];
|
||||
let mut output = WriteBuffer::new_uninitialized(&mut storage);
|
||||
output.copy_unwritten_from(&mut PartialBuffer::new(&[1, 2][..]));
|
||||
output.reset();
|
||||
output.advance(1);
|
||||
|
||||
let result = catch_unwind(AssertUnwindSafe(|| output.advance(2)));
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(output.written(), &[1]);
|
||||
output.advance(1);
|
||||
assert_eq!(output.written(), &[1, 2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn advance_past_capacity_panics() {
|
||||
let mut storage = [0; 4];
|
||||
let mut output = WriteBuffer::new_initialized(&mut storage);
|
||||
output.advance(4);
|
||||
|
||||
output.advance(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn advance_overflow_panics() {
|
||||
let mut storage = [0; 4];
|
||||
let mut output = WriteBuffer::new_initialized(&mut storage);
|
||||
output.advance(1);
|
||||
|
||||
output.advance(usize::MAX);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assume_init_is_not_additive() {
|
||||
let mut storage = [MaybeUninit::new(1); 6];
|
||||
let mut output = WriteBuffer::new_uninitialized(&mut storage);
|
||||
|
||||
for n in [4, 2, 4, 0] {
|
||||
// Safety: All bytes in storage are initialized.
|
||||
unsafe { output.assume_init(n) };
|
||||
assert_eq!(output.initialized_len(), 4);
|
||||
assert_eq!(output.written_len(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assume_init_starts_at_written_len() {
|
||||
let mut storage = [MaybeUninit::new(1); 6];
|
||||
let mut output = WriteBuffer::new_uninitialized(&mut storage);
|
||||
|
||||
// Safety: All bytes in storage are initialized.
|
||||
unsafe { output.assume_init(4) };
|
||||
output.advance(2);
|
||||
// Safety: All bytes in storage are initialized.
|
||||
unsafe { output.assume_init(3) };
|
||||
assert_eq!(output.initialized_len(), 5);
|
||||
assert_eq!(output.written_len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn assume_init_overflow_panics() {
|
||||
let mut storage = [1; 4];
|
||||
let mut output = WriteBuffer::new_initialized(&mut storage);
|
||||
output.advance(1);
|
||||
|
||||
// Safety: Initialized storage; the invalid length must panic before use.
|
||||
unsafe { output.assume_init(usize::MAX) };
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn assume_init_and_advance_overflow_panics() {
|
||||
let mut storage = [1; 4];
|
||||
let mut output = WriteBuffer::new_initialized(&mut storage);
|
||||
output.advance(1);
|
||||
|
||||
// Safety: Initialized storage; the invalid length must panic before use.
|
||||
unsafe { output.assume_init_and_advance(usize::MAX) };
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn set_written_and_initialized_len_past_capacity_panics() {
|
||||
let mut storage = [1; 4];
|
||||
let mut output = WriteBuffer::new_initialized(&mut storage);
|
||||
|
||||
// Safety: Initialized storage; the invalid length must panic before use.
|
||||
unsafe { output.set_written_and_initialized_len(5) };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user