Skip to content

Commit

Permalink
fix(sync): Added the feature flags for compilation without the async …
Browse files Browse the repository at this point in the history
…runtime. Fixes #64. (#65)

BREAKING CHANGE: this bumps the MSRV to 1.70.0

---------

Co-authored-by: Kat Marchán <kzm@zkat.tech>
  • Loading branch information
kinire98 and zkat authored Feb 12, 2024
1 parent 0ac9fb8 commit ffa1ab7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [1.67.0, stable]
rust: [1.70.0, stable]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
Expand Down
7 changes: 3 additions & 4 deletions src/content/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use std::pin::Pin;
#[cfg(any(feature = "async-std", feature = "tokio"))]
use std::task::{Context, Poll};

#[cfg(feature = "async-std")]
use futures::io::AsyncReadExt;
#[cfg(feature = "tokio")]
use tokio::io::AsyncReadExt;
#[cfg(any(feature = "async-std", feature = "tokio"))]
use crate::async_lib::AsyncReadExt;

use ssri::{Algorithm, Integrity, IntegrityChecker};

Expand Down Expand Up @@ -162,6 +160,7 @@ pub fn reflink(cache: &Path, sri: &Integrity, to: &Path) -> Result<()> {
reflink_unchecked(cache, sri, to)
}

#[cfg(any(feature = "async-std", feature = "tokio"))]
pub async fn reflink_async(cache: &Path, sri: &Integrity, to: &Path) -> Result<()> {
let mut reader = open_async(cache, sri.clone()).await?;
let mut buf = [0u8; 1024 * 8];
Expand Down
3 changes: 3 additions & 0 deletions src/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ where
/// Ok(())
/// }
/// ```
#[cfg(any(feature = "async-std", feature = "tokio"))]
pub async fn reflink<P, K, Q>(cache: P, key: K, to: Q) -> Result<()>
where
P: AsRef<Path>,
Expand Down Expand Up @@ -355,6 +356,7 @@ where
/// Ok(())
/// }
/// ```
#[cfg(any(feature = "async-std", feature = "tokio"))]
pub async fn reflink_unchecked<P, K, Q>(cache: P, key: K, to: Q) -> Result<()>
where
P: AsRef<Path>,
Expand Down Expand Up @@ -391,6 +393,7 @@ where
/// Ok(())
/// }
/// ```
#[cfg(any(feature = "async-std", feature = "tokio"))]
pub async fn reflink_hash<P, Q>(cache: P, sri: &Integrity, to: Q) -> Result<()>
where
P: AsRef<Path>,
Expand Down
1 change: 1 addition & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ impl RemoveOpts {
}

/// Removes an individual index metadata entry. The associated content will be left in the cache.
#[cfg(any(feature = "async-std", feature = "tokio"))]
pub async fn remove<P, K>(self, cache: P, key: K) -> Result<()>
where
P: AsRef<Path>,
Expand Down
7 changes: 2 additions & 5 deletions src/linkto.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[cfg(any(feature = "async-std", feature = "tokio"))]
use crate::async_lib::AsyncRead;
#[cfg(any(feature = "async-std", feature = "tokio"))]
use crate::async_lib::AsyncReadExt;
use crate::content::linkto;
use crate::errors::{Error, IoErrorExt, Result};
use crate::{index, WriteOpts};
Expand All @@ -11,11 +13,6 @@ use std::pin::Pin;
#[cfg(any(feature = "async-std", feature = "tokio"))]
use std::task::{Context as TaskContext, Poll};

#[cfg(feature = "async-std")]
use futures::io::AsyncReadExt;
#[cfg(feature = "tokio")]
use tokio::io::AsyncReadExt;

const BUF_SIZE: usize = 16 * 1024;
const PROBE_SIZE: usize = 8;

Expand Down

0 comments on commit ffa1ab7

Please sign in to comment.