mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
fs: update to use std::future (#1269)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
use super::blocking_io;
|
||||
use futures::{Future, Poll};
|
||||
use std::fs::{self, Metadata};
|
||||
use std::future::Future;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
use std::pin::Pin;
|
||||
use std::task::Context;
|
||||
use std::task::Poll;
|
||||
|
||||
/// Queries the file system metadata for a path.
|
||||
pub fn metadata<P>(path: P) -> MetadataFuture<P>
|
||||
@@ -34,10 +37,9 @@ impl<P> Future for MetadataFuture<P>
|
||||
where
|
||||
P: AsRef<Path> + Send + 'static,
|
||||
{
|
||||
type Item = Metadata;
|
||||
type Error = io::Error;
|
||||
type Output = io::Result<Metadata>;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
blocking_io(|| fs::metadata(&self.path))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user