Sha256: cb2e0954f1e33adb168759d25cb4ab1b6883afbf147e05fae1cc991625160fdd

Contents?: true

Size: 749 Bytes

Versions: 5

Compression:

Stored size: 749 Bytes

Contents

use crate::fs::asyncify;

use std::io;
use std::path::Path;

/// Returns `Ok(true)` if the path points at an existing entity.
///
/// This function will traverse symbolic links to query information about the
/// destination file. In case of broken symbolic links this will return `Ok(false)`.
///
/// This is the async equivalent of [`std::path::Path::try_exists`][std].
///
/// [std]: fn@std::path::Path::try_exists
///
/// # Examples
///
/// ```no_run
/// use tokio::fs;
///
/// # async fn dox() -> std::io::Result<()> {
/// fs::try_exists("foo.txt").await?;
/// # Ok(())
/// # }
/// ```
pub async fn try_exists(path: impl AsRef<Path>) -> io::Result<bool> {
    let path = path.as_ref().to_owned();
    asyncify(move || path.try_exists()).await
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/fs/try_exists.rs
wasmtime-28.0.0 ./ext/cargo-vendor/tokio-1.43.0/src/fs/try_exists.rs
wasmtime-27.0.0 ./ext/cargo-vendor/tokio-1.41.1/src/fs/try_exists.rs
wasmtime-26.0.0 ./ext/cargo-vendor/tokio-1.41.0/src/fs/try_exists.rs
wasmtime-25.0.2 ./ext/cargo-vendor/tokio-1.40.0/src/fs/try_exists.rs