Crate jstream_ext[][src]

Introduction

Extensions to the Stream and TryStream traits which implement behavior that I've implemented at least a few times while working with them.

To use these extensions, simply use the JStreamExt or JTryStreamExt items exported by this crate.

Summary

Here's a list of the various extensions provided by this crate:

Stream Extensions

The extensions to Stream are provided by the JStreamExt trait.

  • dedup - remove duplicate items from a stream
  • fold_mut - Similar to fold, but asks for a (&mut T, Self::Item) -> Future<Output=()> instead of a (T, Self::Item) -> Future<Output=T> folding function.
  • first - turns a stream into a future which emits only the first item emitted by the source.
  • nth - turns a stream into a future which emits an item after skipping a specified number of preceding items.

TryStream Extensions

The extensions to TryStream are provided by the JTryStreamExt trait.

  • try_first - turns the stream into a future which emits only the first result emitted by the source.
  • try_nth - turns the stream into a future which emits an item after skipping a specified number of preceding items, or emits an error immediately when encountered.
  • try_filter_map_ok - similar to filter_map, except it allows you to filter-map on the Ok part of the TryStream, and it emits any errors immediately when they are encountered.
  • try_dedup - remove duplicate items from a stream, but also emit any errors immediately when they are seen.
  • fuse_on_fail - if an error is seen, "fuse" the stream such that it panics if try_poll_next is called after an Err(Self::Error) item is emitted. This also makes a TryStream implement FusedStream regardless if the source implements that trait.
  • try_fold_mut - Similar to try_fold, but asks for a (&mut T, Self::Ok) -> Future<Output=Result<(), Self::Error>> instead of a (T, Self::Ok) -> Future<Output=Result<T, Self::Error>> folding function.

Modules

ops

The various structs which wrap various Stream and TryStream upstreams to implement various behavior live in this module.

Traits

JStreamExt

Extensions to the Stream type which aren't already covered in StreamExt.

JTryStreamExt

Extensions to the TryStream type which aren't already covered by the included TryStreamExt.