summaryrefslogtreecommitdiffstats
path: root/tokio-util/src/codec
AgeCommit message (Collapse)Author
2020-12-03util: add writev-aware `poll_write_buf` (#3156)Eliza Weisman
## Motivation In Tokio 0.2, `AsyncRead` and `AsyncWrite` had `poll_write_buf` and `poll_read_buf` methods for reading and writing to implementers of `bytes` `Buf` and `BufMut` traits. In 0.3, these were removed, but `poll_read_buf` was added as a free function in `tokio-util`. However, there is currently no `poll_write_buf`. Now that `AsyncWrite` has regained support for vectored writes in #3149, there's a lot of potential benefit in having a `poll_write_buf` that uses vectored writes when supported and non-vectored writes when not supported, so that users don't have to reimplement this. ## Solution This PR adds a `poll_write_buf` function to `tokio_util::io`, analogous to the existing `poll_read_buf` function. This function writes from a `Buf` to an `AsyncWrite`, advancing the `Buf`'s internal cursor. In addition, when the `AsyncWrite` supports vectored writes (i.e. its `is_write_vectored` method returns `true`), it will use vectored IO. I copied the documentation for this functions from the docs from Tokio 0.2's `AsyncWrite::poll_write_buf` , with some minor modifications as appropriate. Finally, I fixed a minor issue in the existing docs for `poll_read_buf` and `read_buf`, and updated `tokio_util::codec` to use `poll_write_buf`. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-24codec: add read_buffer_mut to FramedRead (#3166)漂流
2020-11-01util: add back public poll_read_buf() function (#3079)Dirkjan Ochtman
This was accidentally removed in #3064.
2020-10-27Revert "util: upgrade tokio-util to bytes 0.6 (#3052)" (#3060)Carl Lerche
This reverts commit fe2b997. We are avoiding adding poll_read_buf to tokio itself for now. The patch is reverted now in order to not block the v0.3.2 release (#3059).
2020-10-27util: upgrade tokio-util to bytes 0.6 (#3052)Dirkjan Ochtman
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-09-24io: remove poll_{read,write}_buf from traits (#2882)Carl Lerche
These functions have object safety issues. It also has been decided to avoid vectored operations on the I/O traits. A later PR will bring back vectored operations on specific types that support them. Refs: #2879, #2716
2020-07-20chore: fix new manual_non_exhaustive clippy lint (#2669)Alice Ryhl
Our minimum supported Rust version does not allow switching to `#[non_exhaustive]`.
2020-05-31docs: use intra-links in the docs (#2575)xliiv
2020-05-20codec: add Framed::read_buffer_mut (#2546)Ondřej Hruška
Adds a method to retrieve a mutable reference to the Framed stream's read buffer. This makes it possible to e.g. externally clear the buffer to prevent the codec from parsing stale data.
2020-05-14docs: improve discoverability of codec module (#2523)Geoff Shannon
2020-05-12codec: rewrite of codec::Framed (#2368)Plecra
Framed was designed to encapsulate both AsyncRead and AsyncWrite so that it could wrap two-way connections. It used Fuse to manage the pinned io object between the FramedWrite and FramedRead structs. I replaced the Fuse struct by isolating the state used in reading and writing, and making the code generic over that instead. This means the FramedImpl struct now has a parameter for the state, and contains the logic for both directions. The Framed* structs are now simply wrappers around this type Hopefully removing the `Pin` handling made things easier to understand, too.
2020-04-21Remove relative link when possible and fix invalid links (#2423)damienrg
The link to tokio::main was relative to tokio_macros crate in the source directory. This is why it worked in local build of documentation and not in doc.rs. Refs: #1473
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-02util: documentation example for LengthDelimitedCodec (#2339)Benjamin Halsted
There is a gap in examples for Builder::num_skip() that shows how to move past unused bytes between the length and payload.
2020-03-04codec: change Encoder to take &Item (#1746)Lucio Franco
Co-authored-by: Markus Westerlind <marwes91@gmail.com>
2020-03-02codec: Add `Framed::with_capacity` (#2215)Jean-Christophe BEGUE
2020-02-01util: add links to tokio-util + example to BytesCodec (#2207)Alice Ryhl
2020-01-30codec: use advance over split_to when data is not needed (#2198)Markus Westerlind
2019-12-21chore: fix formatting, remove old rustfmt.toml (#2007)Artem Vorotnikov
`cargo fmt` has a bug where it does not format modules scoped with feature flags.
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-11-27doc: misc API documentation fixes (#1834)Oleg Nosov
2019-11-20chore: update `bytes` dependency to git master (#1796)Carl Lerche
Tokio will track changes to bytes until 0.5 is released.
2019-11-16chore: migrate from pin-project to pin-project-lite (#1778)Taiki Endo
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-15codec: Remove Unpin requirement from Framed[Read,Write,] (#1758)Markus Westerlind
cc #1252
2019-11-07chore: update futures to 0.3.0 (#1741)Taiki Endo
2019-10-31Allow non-destructive access to the read buffer. (#1600)Jonathan Bastien-Filiatrault
I need this to implement SMTP pipelining checks. I mostly need to flush my send buffer when the read buffer is empty before waiting for the next command.
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-22codec: move into tokio-util (#1675)Carl Lerche
Related to #1318, Tokio APIs that are "less stable" are moved into a new `tokio-util` crate. This crate will mirror `tokio` and provide additional APIs that may require a greater rate of breaking changes. As examples require `tokio-util`, they are moved into a separate crate (`examples`). This has the added advantage of being able to avoid example only dependencies in the `tokio` crate.