From ffa1ab7254e0b051e6d65fe16b71ab44be04c968 Mon Sep 17 00:00:00 2001 From: Iker Nieto <93119213+kinire98@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:55:58 +0100 Subject: [PATCH] fix(sync): Added the feature flags for compilation without the async runtime. Fixes #64. (#65) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING CHANGE: this bumps the MSRV to 1.70.0 --------- Co-authored-by: Kat Marchán --- .github/workflows/ci.yml | 2 +- src/content/read.rs | 7 +++---- src/get.rs | 3 +++ src/index.rs | 1 + src/linkto.rs | 7 ++----- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6dda61..ac1c4f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/src/content/read.rs b/src/content/read.rs index 759a6f6..39efbdb 100644 --- a/src/content/read.rs +++ b/src/content/read.rs @@ -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}; @@ -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]; diff --git a/src/get.rs b/src/get.rs index a43f49c..374a154 100644 --- a/src/get.rs +++ b/src/get.rs @@ -319,6 +319,7 @@ where /// Ok(()) /// } /// ``` +#[cfg(any(feature = "async-std", feature = "tokio"))] pub async fn reflink(cache: P, key: K, to: Q) -> Result<()> where P: AsRef, @@ -355,6 +356,7 @@ where /// Ok(()) /// } /// ``` +#[cfg(any(feature = "async-std", feature = "tokio"))] pub async fn reflink_unchecked(cache: P, key: K, to: Q) -> Result<()> where P: AsRef, @@ -391,6 +393,7 @@ where /// Ok(()) /// } /// ``` +#[cfg(any(feature = "async-std", feature = "tokio"))] pub async fn reflink_hash(cache: P, sri: &Integrity, to: Q) -> Result<()> where P: AsRef, diff --git a/src/index.rs b/src/index.rs index 8852107..c89bcad 100644 --- a/src/index.rs +++ b/src/index.rs @@ -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(self, cache: P, key: K) -> Result<()> where P: AsRef, diff --git a/src/linkto.rs b/src/linkto.rs index 9f7f877..62feb0f 100644 --- a/src/linkto.rs +++ b/src/linkto.rs @@ -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}; @@ -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;