Skip to content

Commit

Permalink
Remove deprecated APIs (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhickman authored Oct 23, 2024
1 parent 27144b0 commit 11a6460
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 0 additions & 16 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P>(path: P, options: &fs::OpenOptions) -> Result<Self, io::Error>
where
P: Into<PathBuf>,
{
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).
Expand Down
14 changes: 8 additions & 6 deletions src/open_options.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -67,12 +70,11 @@ impl OpenOptions {
where
P: Into<PathBuf>,
{
// 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)),
}
}
}

Expand Down
10 changes: 0 additions & 10 deletions src/tokio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,6 @@ pub async fn symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> 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<Path>, dst: impl AsRef<Path>) -> io::Result<()> {
symlink_dir(src, dst).await
}

/// Creates a new directory symlink on the filesystem.
///
/// Wrapper for [`tokio::fs::symlink_dir`].
Expand Down

0 comments on commit 11a6460

Please sign in to comment.