Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for tokio #121

Open
wants to merge 23 commits into
base: sync-async
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2afb5a1
Add sync feature to Cargo.toml
SapryWenInera May 12, 2024
e0b6be7
Add initial error message for when io logic is missing do to feature …
SapryWenInera May 12, 2024
975fbec
Add sync and tokio features and sync is on default
SapryWenInera May 13, 2024
c056382
Add compile error for missing/conflicting features
SapryWenInera May 13, 2024
8afd567
Begin async support on spec module
SapryWenInera May 13, 2024
5f548a3
Merge remote-tracking branch 'upstream/master' into async_pr
SapryWenInera May 13, 2024
45f918c
Move synchronous code into sync submodule
SapryWenInera May 14, 2024
aae1098
Merge branch 'master' into async_pr
Pr0methean May 16, 2024
a14f6a7
Merge branch 'master' into async_pr
Pr0methean May 17, 2024
62788e2
docs: Add `package.metadata.docs.rs`
sorairolake May 18, 2024
933ccc4
Enable deflate-zlib as well, and keep deflate64 separate
Pr0methean May 18, 2024
57eaa50
ci(fuzz): Update seed corpora
Pr0methean May 18, 2024
4b295d3
Merge pull request #135 from sorairolake/docsrs
Pr0methean May 18, 2024
dc83532
Merge branch 'zip-rs:master' into async_pr
SapryWenInera May 18, 2024
af5752b
Add sync feature to Cargo.toml
SapryWenInera May 12, 2024
f871fff
Add initial error message for when io logic is missing do to feature …
SapryWenInera May 12, 2024
951184a
Add sync and tokio features and sync is on default
SapryWenInera May 13, 2024
ff97edd
Add compile error for missing/conflicting features
SapryWenInera May 13, 2024
8129f2e
Finished rebasing to upstream/sync-async branch
SapryWenInera May 18, 2024
e5af56f
Begin async support on spec module
SapryWenInera May 13, 2024
c95da50
Move synchronous code into sync submodule
SapryWenInera May 14, 2024
2e6053e
Updated CI
SapryWenInera May 29, 2024
794a1d0
Sync feature enablement
SapryWenInera May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
rustalias: [stable, nightly, msrv]
feature_flag: ["--all-features", "--no-default-features", ""]
feature_flag: ["--no-default-features --features sync_all", "--no-default-features --features tokio_all", "--no-default-features --features sync", "--no-default-features --features tokio", ""]
Copy link
Member

@Pr0methean Pr0methean May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make it possible to build with both sync and tokio? To do this, you can invoke the traits with an explicit self parameter, e.g. Read::read_exact(self, buf) and AsyncRead::read_exact(self, buf) instead of self.read_exact(buf). Since methods with the same name don't conflict when they're specified in different traits, this should be the only change needed.

Copy link
Member

@Pr0methean Pr0methean Jun 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I found a crate that does something similar to this, but with proc macros: https://crates.io/crates/async-generic. Looks like it may still be worth layering a few regular macros on top, for when async-generic functions call other async-generic functions.

include:
- rustalias: stable
rust: stable
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ deflate-zlib-ng = ["flate2/zlib-ng", "_deflate-any"]
deflate-zopfli = ["zopfli", "_deflate-any"]
lzma = ["lzma-rs/stream"]
sync = []
sync_all = ["aes-crypto", "chrono", "deflate", "deflate-miniz", "deflate-zlib", "deflate-zlib-ng", "deflate-zopfli", "lzma", "sync","time"]
tokio_all = ["aes-crypto", "chrono", "deflate", "deflate-miniz", "deflate-zlib", "deflate-zlib-ng", "deflate-zopfli", "lzma","time", "tokio"]
tokio = ["tokio/io-util"]
unreserved = []
default = [
Expand Down
2 changes: 2 additions & 0 deletions src/read.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Types for reading ZIP archives

/// Module for code with synchronous logic
#[cfg(feature = "sync")]
pub mod sync;

/// Module for code with asynchronous logic
#[cfg(feature = "tokio")]
pub mod tokio;

#[cfg(feature = "aes-crypto")]
Expand Down
1 change: 1 addition & 0 deletions src/read/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::fs;
use std::io::{self, Read};
use std::path::{Path, PathBuf};

#[cfg(feature = "sync")]
use super::sync::{central_header_to_zip_file_inner, read_zipfile_from_stream};

/// Stream decoder for zip.
Expand Down
1 change: 1 addition & 0 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#[cfg(feature = "aes-crypto")]
use crate::aes::AesWriter;
use crate::compression::CompressionMethod;
#[cfg(feature = "sync")]
use crate::read::{sync::find_content, ZipArchive, ZipFile, ZipFileReader};
use crate::result::{ZipError, ZipResult};
use crate::spec;
Expand Down