From 11a64603d1dff63df4af57c82d554dd3ae4f302f Mon Sep 17 00:00:00 2001 From: Andrew Hickman Date: Wed, 23 Oct 2024 21:48:45 +0100 Subject: [PATCH] Remove deprecated APIs (#66) --- CHANGELOG.md | 2 ++ src/file.rs | 16 ---------------- src/open_options.rs | 14 ++++++++------ src/tokio/mod.rs | 10 ---------- 4 files changed, 10 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84d3fa6..93c5d05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ * The `io_safety` feature flag has been removed, and this functionality is now always enabled on Rust versions which support it (1.63.0 and greater). +* Removed deprecated APIs: `File::from_options`, `tokio::symlink` + ## 2.11.0 * Added the first line of the standard library documentation to each function's rustdocs, to make them more useful in IDEs ([#50](https://github.com/andrewhickman/fs-err/issues/45)) diff --git a/src/file.rs b/src/file.rs index 4040524..fafc830 100644 --- a/src/file.rs +++ b/src/file.rs @@ -57,22 +57,6 @@ impl File { } } - /// Wrapper for [`OpenOptions::open`](https://doc.rust-lang.org/stable/std/fs/struct.OpenOptions.html#method.open). - /// - /// This takes [`&std::fs::OpenOptions`](https://doc.rust-lang.org/stable/std/fs/struct.OpenOptions.html), - /// not [`crate::OpenOptions`]. - #[deprecated = "use fs_err::OpenOptions::open instead"] - pub fn from_options

(path: P, options: &fs::OpenOptions) -> Result - where - P: Into, - { - let path = path.into(); - match options.open(&path) { - Ok(file) => Ok(File::from_parts(file, path)), - Err(source) => Err(Error::build(source, ErrorKind::OpenFile, path)), - } - } - /// Attempts to sync all OS-internal metadata to disk. /// /// Wrapper for [`File::sync_all`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.sync_all). diff --git a/src/open_options.rs b/src/open_options.rs index 903606f..e34f9c7 100644 --- a/src/open_options.rs +++ b/src/open_options.rs @@ -1,4 +1,7 @@ use std::{fs, io, path::PathBuf}; + +use crate::errors::{Error, ErrorKind}; + #[derive(Clone, Debug)] /// Wrapper around [`std::fs::OpenOptions`](https://doc.rust-lang.org/std/fs/struct.OpenOptions.html) pub struct OpenOptions(fs::OpenOptions); @@ -67,12 +70,11 @@ impl OpenOptions { where P: Into, { - // We have to either duplicate the logic or call the deprecated method here. - // We can't let the deprecated function call this method, because we can't construct - // `&fs_err::OpenOptions` from `&fs::OpenOptions` without cloning - // (although cloning would probably be cheap). - #[allow(deprecated)] - crate::File::from_options(path.into(), self.options()) + let path = path.into(); + match self.0.open(&path) { + Ok(file) => Ok(crate::File::from_parts(file, path)), + Err(source) => Err(Error::build(source, ErrorKind::OpenFile, path)), + } } } diff --git a/src/tokio/mod.rs b/src/tokio/mod.rs index aee743b..4044095 100644 --- a/src/tokio/mod.rs +++ b/src/tokio/mod.rs @@ -198,16 +198,6 @@ pub async fn symlink(src: impl AsRef, dst: impl AsRef) -> io::Result .map_err(|err| SourceDestError::build(err, SourceDestErrorKind::Symlink, src, dst)) } -/// Creates a new directory symlink on the filesystem. -/// -/// Wrapper for [`tokio::fs::symlink_dir`]. -#[cfg(windows)] -#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))] -#[deprecated = "use fs_err::tokio::symlink_dir instead"] -pub async fn symlink(src: impl AsRef, dst: impl AsRef) -> io::Result<()> { - symlink_dir(src, dst).await -} - /// Creates a new directory symlink on the filesystem. /// /// Wrapper for [`tokio::fs::symlink_dir`].