Commit Graph
69 Commits
Author SHA1 Message Date
Markus Jais 5567ec904e small typo fixed for io module 2017-05-09 21:02:09 +02:00
Dan Munckton 3111443113 Update links to pages in the tokio.rs going-deeper section
See: tokio-rs/website#72
2017-04-25 19:26:43 +01:00
Alex Crichton 89fcc96dd4 Migrate to using tokio-io
Deprecate the existing `io` module in this crate entirely.

More details coming soon!

Closes #61
2017-03-15 09:46:54 -07:00
Martin Hoffmann 54dcd3a015 Add PartialOrd and Ord to EasyBuf, generalize PartialEq. 2017-02-18 20:30:01 +01:00
Sebastian Thiel fe9a798811 Implement PartialEq for EasyBuf 2017-02-13 07:55:26 +01:00
Sebastian Thiel 65c5c5241b Test semantics of buffer allocation of get_mut()
* if remaining bytes are smaller then 8 * 1024, allocate 8 * 1024
* otherwise allocate as much as needed to hold the remaining bytes
  without re-allocations.
2017-02-12 09:47:03 +01:00
Sebastian Thiel e11dd06ead Assure we don't have to allocate while growing the vector
We now have enough capacity to copy the unconsumed portion
of the previous frame.
2017-02-11 10:23:02 +01:00
Sebastian Thiel 5adde38a65 Allocation in get_mut() always uses 8 * 1024 bytes
The previous implementation would always use the capacity
of the previous buffer, which would effectively prevent it
from ever shrinking.

This also means that protocol with greater variance in
possible frame sizes would likely be heavily over-allocating.
If these implementations use zero-copy, this would imply
that even small frames kept alive by the client would use
large amounts of memory.

The change is motivated by the implementation of the
cassandra-protocol, which allows frames of up to 256MB
in size, which solely depend on the kind of query.
2017-02-11 09:01:07 +01:00
Manuel Woelker b4cd223476 impl Into<Vec<u8>> for EasyBuf (cf. #120) 2017-02-10 23:01:46 +01:00
Manuel Woelker f86addf113 fix allocating EasyBuf::get_mut() leaving vector too large (cf. #162) 2017-02-10 22:58:16 +01:00
Denis Andrejew e31b76c047 Fix typo in non-doc comment in copy.rs 2017-01-27 22:42:04 +00:00
Alex Crichton 05f01d6c9b Merge pull request #157 from seanmonstar/vecio
add read_bufs and write_bufs to Io and TcpStream
2017-01-27 14:34:26 -08:00
Sean McArthur 829563ccfc add read_bufs and write_bufs to Io and TcpStream 2017-01-27 11:32:08 -08:00
Alex Crichton cf74a6b2c9 Merge pull request #159 from jtescher/fix-typos
Fix typos
2017-01-24 21:05:21 -08:00
Julian Tescher baeb35b6d4 Fix typos 2017-01-24 20:52:48 -08:00
Manuel Woelker b9e182a2ce impl fmt::Debug for EasyBuf (cf. #120)
Debug format looks like this for small resp. long buffers

EasyBuf{len=2/6 [5, 6]}
EasyBuf{len=255/255 [0, 1, 2, 3, ..., 251, 252, 253, 254]}
2017-01-22 21:10:48 +01:00
Alex Crichton c47c445be6 Add some docs links and such 2017-01-11 09:47:12 -08:00
sinkuu 5929a59aca Use io::Result 2017-01-04 17:47:20 +09:00
Steven Fackler 24d941d676 Encode/Decode -> Codec in docs 2016-12-19 22:19:39 -08:00
Aaron Turon 46d68f739a Add Clone for EasyBuf 2016-12-17 14:17:52 -08:00
Aaron Turon 9bb1366f33 Add From<Vec<u8>> for EasyBuf 2016-12-17 14:16:47 -08:00
Alex Crichton b89150c464 Fixup Result-returning encode method 2016-11-22 15:22:30 -08:00
Alex Crichton e970e9a79c Merge branch 'master' of https://github.com/colindjk/tokio-core 2016-11-22 13:07:01 -08:00
Alex Crichton 9b62ade962 Touch up codes for UDP
* Move to `std::net` as it's all purely UDP related
* Rename to `UdpCodec` and `UdpFramed` to give a consistent `Udp` prefix
* Add `RecvDgram`, rename `SendDGram` to `SendDgram`
* Touch up some style here and there
2016-11-22 11:48:09 -08:00
Alex Crichton 0d10b0e05a Merge branch 'udp_frame' of https://github.com/rrichardson/tokio-core 2016-11-22 09:44:29 -08:00
Rick Richardson 1a6753df1f added Default Codec for Udp 2016-11-22 08:47:57 -08:00
Rick Richardson 2cb600bd19 changed CodecUdp::decode to return Self::In instead of Option<Self::In> 2016-11-22 08:29:02 -08:00
Rick Richardson b12d32ce1c made send_dgram move self, made FramedUdp::new private, other clean-ups and tweaks 2016-11-21 11:28:25 -08:00
Paul Colomiets e27abd3841 Remove Framed::split because it's now in futures 2016-11-21 19:33:07 +02:00
kibbles dcf994d517 Updated 'encode' return value to Result, removed parameter passing buffer 2016-11-20 21:44:23 -05:00
Rick Richardson 161811de8b moved udp test to examples, optimized buffer handling 2016-11-20 11:40:43 -08:00
Rick Richardson 71d8672aab implemented moste of udp frames test 2016-11-20 09:08:03 -08:00
Rick Richardson 592a99bca4 completed basic implementation of FramedUdp for streams and sink 2016-11-19 09:05:00 -08:00
Dan Burkert 46dd38b7d7 Clean up Sink implementation on Framed
This commit makes a few changes to the Sink implementation on Framed:

* Backpressure is implemented for `start_send`. If the write buffer is
  over 8KiB and can't be flushed, no new items are accepted.
* 0 length writes to the upstream transport are translated into a
  `WriteZero` error, as with `io::Write::write_all`. `write_all` checks
  for and ignores `Interrupted` errors, but I do not think this is
  necessary for non-blocking writes.
* In `poll_complete`, the upstream transport is not flushed until
  *after* writing the entire write buffer.
2016-11-16 18:42:30 -08:00
Alex Crichton 89a9ab6d34 Merge pull request #102 from aturon/decoder-encoder
Reintroduce "decoder" and "encoder" for Decode and Encode, merging them into Codec
2016-11-15 10:42:34 -06:00
Aaron Turon c353de13fc Reintroduce "decoder" and "encoder" for Decode and Encode, and merge the
traits into `Codec`

A previous commit refactored such that `Encode` and `Decode` are
implemented directly on the types being encoded or decoded. This was
thought to be less expressive but more convenient than having a separate
notion of a (stateful) encoder or decoder.

However, there are certain situations where the approach is just too
limiting: you're required to implemented `Decode` and `Encode` for types
you don't "own" and can't newtype.

This commit moves back to a setup where `Self` represents the
encoder/decoder state; it also merges the two traits into a single
`Codec` trait, since they are currently always used together.
2016-11-15 08:28:26 -08:00
Bheesham Persaud 06a4c5e2d5 Remove references to EasyFramed and easy module. 2016-11-15 00:42:46 -05:00
Alex Crichton 6e7410567c Typo 2016-11-11 11:26:07 -08:00
Aaron Turon 17faf329e0 Add note about how to get a Framed 2016-11-10 09:46:23 -08:00
Aaron Turon 91347f44a5 Remove mentions of EasyFramed 2016-11-10 09:45:09 -08:00
Aaron Turon 36e3dbf418 Refactor framing to use Streams and Sinks
- Gets rid of `easy` module, instead providing framing support directly
  in the `io` module.

- In particular, adds a framing adapter directly to the `Io` trait,
  which gives you a Stream + Sink object. That object can then be
  `split` into separate `Stream` and `Sink` objects if needed.

- Deprecates the `FramedIo` trait; that's now just Stream + Sink.

- Updates the line framing test to use the stream/sink combinators.
2016-11-08 15:47:13 -08:00
David Renshaw f96d37ccf3 Fix some typos. 2016-11-05 16:29:54 -04:00
Alex Crichton 614887b8c1 Implement split() with BiLock 2016-11-05 11:14:54 -07:00
Paul Lietar 4719fbdb28 Allow start and end of window to match length of underlying slice. 2016-10-22 15:56:02 +02:00
Alex Crichton b84ef90a98 Move Framed from tokio-proto to core
This commit extracts the concrete implementation of `FrameIo` in tokio-proto to
tokio-core under the name `EasyFramed`. This extraction is accompanied with a
new `EasyBuf` buffer type to work with when parsing types.

The purpose of this movement is to provide a clear and easy entry point at the
`FramedIo` layer for those who need it. Eventually these buffer types will get
replaced or moved to the `bytes` crate, but in the interest of an 0.1 release
and remaining backwards compatible with the tokio-core 0.1 release this is
adding a separate module.
2016-10-21 11:46:32 -07:00
Jack O'Connor 6789527952 rename ReadOnce back to Read, but keep it exposed 2016-10-15 09:46:59 -04:00
Jack O'Connor da37ad0948 rename Read to ReadOnce and expose it
The other read futures (read_exact, read_until, etc.) all expose their
concrete future types so that function signatures can return them, but
until now `read()` didn't. Exposing it with the name "Read" causes
naming conflicts with the std::io::Read trait, so the easiest thing to
do is to just change the name. Importing std::io::Read under a different
name would've been an option too, but that would probably be annoying
for consumers in the same way it's annoying for us.

The original PR (https://github.com/tokio-rs/tokio-core/pull/29) decided
that "read" was a better name than "read_some", so I'm leaving the top
level functions unchanged. I don't have a strong opinion about it one
way or the other, but I *do* think it's worth bikeshedding a little bit.
Python's asyncio library actually ended up with a very similar issue
around naming inconsistency between the sync and async worlds, and we
can hopefully avoid repeating that: https://bugs.python.org/issue22279
2016-10-08 01:28:39 -04:00
Marek Kotewicz a94be1bca9 fixed typo in split.rs 2016-10-05 11:28:46 +02:00
Alex Crichton e32115b1b4 Merge pull request #50 from oberien/read
doc(read): Add number of bytes read to doc
2016-10-04 07:50:44 -07:00
oberien b0033eb463 doc(read): Add number of bytes read to doc 2016-10-04 13:56:31 +02:00