summaryrefslogtreecommitdiffstats
path: root/tokio/src/fs/file.rs
AgeCommit message (Collapse)Author
2020-10-20fs: flush on shutdown (#3009)Zahari Dichev
Fixes: #2950
2020-10-09fs: future proof `File` (#2930)Carl Lerche
Changes inherent methods to take `&self` instead of `&mut self`. This brings the API in line with `std`. This patch is implemented by using a `tokio::sync::Mutex` to guard the internal `File` state. This is not an ideal implementation strategy doesn't make a big impact compared to having to dispatch operations to a background thread followed by a blocking syscall. In the future, the implementation can be improved as we explore async file-system APIs provided by the operating-system (iocp / io_uring). Closes #2927
2020-10-08io: remove Poll from the AsyncSeek::start_seek return value (#2885)Zahari Dichev
2020-09-05fs: remove File::seek (#2810)Zahari Dichev
Fixes: #1993 Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
2020-08-28fs: implement FromRawFd & FromRawHandle for File (#2792)Nikolai Vazquez
2020-08-13io: change AsyncRead to use a ReadBuf (#2758)Sean McArthur
Works towards #2716. Changes the argument to `AsyncRead::poll_read` to take a `ReadBuf` struct that safely manages writes to uninitialized memory.
2020-08-11fs: add comment explaing File flush is a no-op (#2761)Kruno Tomola Fabro
Signed-off-by: Kruno Tomola Fabro <krunotf@gmail.com>
2020-05-21io: remove zeroing for AsyncRead implementors (#2525)Mikail Bagishov
2020-04-23docs: make it easier to discover extension traits (#2434)Alice Ryhl
Refs: #2307
2020-01-24docs: use third form in API docs (#2027)Oleg Nosov
2020-01-08Fix Seek adapter and AsyncSeek error handling for FileJeb Rosen
* io: Fix the Seek adapter and add a tested example. If the first 'AsyncRead::start_seek' call returns Ready, 'AsyncRead::poll_complete' will be called. Previously, a start_seek that immediately returned 'Ready' would cause the Seek adapter to return 'Pending' without registering a Waker. * fs: Do not return write errors from methods on AsyncSeek. Write errors should only be returned on subsequent writes or on flush. Also copy the last_write_err assert from 'poll_read' to both 'start_seek' and 'poll_complete' for consistency.
2019-12-22doc: fill out `fs` and remove html links (#2015)Carl Lerche
also add an async version of `fs::canonicalize`
2019-12-19fs: add deprecated fs::File::seek fn (#1991)Carl Lerche
This fixes an API compatibility regression when `AsyncSeek` was added. Fixes: #1989
2019-12-10io: add AsyncSeek trait (#1924)Michael Howell
Co-authored-by: Taiki Endo <te316e89@gmail.com>
2019-11-28fs: add File::into_std and File::try_into_std methods (#1856)Bartek Iwańczuk
In version 0.1 there was File::into_std method that destructured tokio_fs::File into std::fs:File. That method was lacking in version 0.2. Fixes: #1852
2019-11-26fs: impl AsRawFd / AsRawHandle for File (#1827)Carl Lerche
This provides the ability to get the raw OS handle for a `File`. The `Into*` variant cannot be provided as `File` needs to maintain ownership of the `File`. The actual handle may have been moved to a background thread.
2019-11-16io: expose std{in, out, err} under io feature (#1759)Taiki Endo
This exposes `std{in, out, err}` under io feature by moving `fs::blocking` module into `io::blocking`. As `fs` feature depends on `io-trait` feature, `fs` implementations can always access `io` module.
2019-11-15Limit `futures` dependency to `Stream` via feature flag (#1774)Carl Lerche
In an effort to reach API stability, the `tokio` crate is shedding its _public_ dependencies on crates that are either a) do not provide a stable (1.0+) release with longevity guarantees or b) match the `tokio` release cadence. Of course, implementing `std` traits fits the requirements. The on exception, for now, is the `Stream` trait found in `futures_core`. It is expected that this trait will not change much and be moved into `std. Since Tokio is not yet going reaching 1.0, I feel that it is acceptable to maintain a dependency on this trait given how foundational it is. Since the `Stream` implementation is optional, types that are logically streams provide `async fn next_*` functions to obtain the next value. Avoiding the `next()` name prevents fn conflicts with `StreamExt::next()`. Additionally, some misc cleanup is also done: - `tokio::io::io` -> `tokio::io::util`. - `delay` -> `delay_until`. - `Timeout::new` -> `timeout(...)`. - `signal::ctrl_c()` returns a future instead of a stream. - `{tcp,unix}::Incoming` is removed (due to lack of `Stream` trait). - `time::Throttle` is removed (due to lack of `Stream` trait). - Fix: `mpsc::UnboundedSender::send(&self)` (no more conflict with `Sink` fns).
2019-11-12reorganize modules (#1766)Carl Lerche
This patch started as an effort to make `time::Timer` private. However, in an effort to get the build compiling again, more and more changes were made. This probably should have been broken up, but here we are. I will attempt to summarize the changes here. * Feature flags are reorganized to make clearer. `net-driver` becomes `io-driver`. `rt-current-thread` becomes `rt-core`. * The `Runtime` can be created without any executor. This replaces `enter`. It also allows creating I/O / time drivers that are standalone. * `tokio::timer` is renamed to `tokio::time`. This brings it in line with `std`. * `tokio::timer::Timer` is renamed to `Driver` and made private. * The `clock` module is removed. Instead, an `Instant` type is provided. This type defaults to calling `std::time::Instant`. A `test-util` feature flag can be used to enable hooking into time. * The `blocking` module is moved to the top level and is cleaned up. * The `task` module is moved to the top level. * The thread-pool's in-place blocking implementation is cleaned up. * `runtime::Spawner` is renamed to `runtime::Handle` and can be used to "enter" a runtime context.
2019-10-26chore: use argument position impl trait (#1690)Linus Färnstrand
2019-10-26io: move into `tokio` crate (#1691)Carl Lerche
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The `io` implementation is now provided by the main `tokio` crate. Functionality can be opted out of by using the various net related feature flags.
2019-10-21fs: move into `tokio` (#1672)Carl Lerche
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The `fs` implementation is now provided by the main `tokio` crate. The `fs` functionality may still be excluded from the build by skipping the `fs` feature flag.