I'm working on a program that uses the futures 0.3 alpha/stdlib integration and getting an error I can't figure out. The error and the code are in the linked gist.
The ActionStream
type that the function returns is defined as:
pub type ActionStream = Box<dyn Stream<Item = Result<Action, Error>> + Unpin>;
Where Action
and Error
are enums defined in the same crate.
The general flow of the function is that it checks for the presence of some data in a data store, which is a regular old Future
, and then returns either a stream containing a single item (if the data was present) or an empty stream. So the value returned by the function needs to be a stream, but the result of a future is needed to determine what the returned stream should contain.
I'm confused by the error I'm getting, which implies that ActionStream
does not implement Future
, but streams do implement Future
, so there is some subtlety here that I'm not able to parse out of the long, confusing trait bounds shown in the compiler output. Any help would be appreciated!
https://gist.github.com/jimmycuadra/6d4eb4e42ec16b5bbcee80a4f03a2e86