summaryrefslogtreecommitdiffstats
path: root/tokio/src/fs
AgeCommit message (Collapse)Author
2020-11-12fs: small documentation fixes (#3133)Nylonicious
2020-10-20fs: flush on shutdown (#3009)Zahari Dichev
Fixes: #2950
2020-10-12rt: Remove `threaded_scheduler()` and `basic_scheduler()` (#2876)Lucio Franco
Co-authored-by: Alice Ryhl <alice@ryhl.io> Co-authored-by: Carl Lerche <me@carllerche.com>
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-08fs: add os::windows::OpenOptionsExt (#2923)Taiki Endo
2020-10-08io: remove Poll from the AsyncSeek::start_seek return value (#2885)Zahari Dichev
2020-10-08fs: switch to our own DirEntryExt trait (#2921)Taiki Endo
2020-10-05fs: seal OpenOptionsExt and DirBuilderExt (#2909)Taiki Endo
2020-10-01chore: make #[doc(hidden)] apis private (#2901)Alice Ryhl
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-31docs: use intra-links in the docs (#2575)xliiv
2020-05-21io: remove zeroing for AsyncRead implementors (#2525)Mikail Bagishov
2020-05-21fs: implement OpenOptionsExt for OpenOptions (#2515)Charles Hovine
Trait OpenOptionsExt is now implemented for fs::OpenOption. In order to access the underlying std::fs::OpenOptions wrapped in tokio's OpenOption, an as_inner_mut method was added to OpenOption, only visible to the parent module. Fixes: #2366
2020-05-21fs: add DirBuilder (#2524)Dmitri Shkurski
The initial idea was to implement a thin wrapper around an internally held `std::fs::DirBuilder` instance. This, however, didn't work due to `std::fs::DirBuilder` not having a Copy/Clone traits implemented, which are necessary for constructing an instance to move-capture it into a closure. Instead, we mirror `std::fs::DirBuilder` configuration by storing the `recursive` and (unix-only) `mode` parameters locally, which are then used to construct an `std::fs::DirBuilder` instance on-the-fly. This commit also mirrors the (unix-only) DirBuilderExt trait from std. Fixes: #2369
2020-04-23docs: make it easier to discover extension traits (#2434)Alice Ryhl
Refs: #2307
2020-04-12docs: replace some html links with rustdoc paths (#2381)xliiv
Included changes - all simple references like `<type>.<name>.html` for these types - enum - fn - struct - trait - type - simple references for methods, like struct.DelayQueue.html#method.poll Refs: #1473
2020-04-02fs: Copy file permissions (#2354)Kevin Leimkuhler
Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
2020-01-24fs: add fs::copy (#2079)Dominic
Provides an asynchronous version of `std::fs::copy`. Closes: #2076
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-18stream: add `next` and `map` utility fn (#1962)Artem Vorotnikov
Introduces `StreamExt` trait. This trait will be used to add utility functions to make working with streams easier. This patch includes two functions: * `next`: a future returning the item in the stream. * `map`: transform each item in the stream.
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-27doc: misc API documentation fixes (#1834)Oleg Nosov
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-21runtime: cleanup and add config options (#1807)Carl Lerche
* runtime: cleanup and add config options This patch finishes the cleanup as part of the transition to Tokio 0.2. A number of changes were made to take advantage of having all Tokio types in a single crate. Also, fixes using Tokio types from `spawn_blocking`. * Many threads, one resource driver Previously, in the threaded scheduler, a resource driver (mio::Poll / timer combo) was created per thread. This was more or less fine, except it required balancing across the available drivers. When using a resource driver from **outside** of the thread pool, balancing is tricky. The change was original done to avoid having a dedicated driver thread. Now, instead of creating many resource drivers, a single resource driver is used. Each scheduler thread will attempt to "lock" the resource driver before parking on it. If the resource driver is already locked, the thread uses a condition variable to park. Contention should remain low as, under load, the scheduler avoids using the drivers. * Add configuration options to enable I/O / time New configuration options are added to `runtime::Builder` to allow enabling I/O and time drivers on a runtime instance basis. This is useful when wanting to create lightweight runtime instances to execute compute only tasks. * Bug fixes The condition variable parker is updated to the same algorithm used in `std`. This is motivated by some potential deadlock cases discovered by `loom`. The basic scheduler is fixed to fairly schedule tasks. `push_front` was accidentally used instead of `push_back`. I/O, time, and spawning now work from within `spawn_blocking` closures. * Misc cleanup The threaded scheduler is no longer generic over `P :Park`. Instead, it is hard coded to a specific parker. Tests, including loom tests, are updated to use `Runtime` directly. This provides greater coverage. The `blocking` module is moved back into `runtime` as all usage is within `runtime` itself.
2019-11-20Fix doc links (#1799)Pen Tree
Link fix only. After this fix, `cargo doc --package` succeeds.
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-11-05runtime: combine `executor` and `runtime` mods (#1734)Carl Lerche
Now, all types are under `runtime`. `executor::util` is moved to a top level `util` module.
2019-10-28executor: move into `tokio` crate (#1702)Carl Lerche
A step towards collapsing Tokio sub crates into a single `tokio` crate (#1318). The executor 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-27Fix docs links: Redux (#1698)Geoff Shannon
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.