rustasync / runtime

Empowering everyone to build asynchronous software
https://docs.rs/runtime
Apache License 2.0
862 stars 28 forks source link

Rename Future types #40

Closed yoshuawuyts closed 5 years ago

yoshuawuyts commented 5 years ago

As we're building out the FS layer, we've noticed that our current naming scheme is having some problems. E.g. tcp_stream::connect currently returns Connect. But for say fs::read_dir this doesn't hold up, and it needs to be suffixed by Future instead:

struct ReadDir;
struct ReadDirFuture;

fn read_dir<P: AsRef<Path>>(path: P) -> ReadDirFuture;

For consistency we should probably consider changing all our futures that could be generated by async fn to be suffixed with Future instead.

However, combinator types on futures like AndThen returned by the and_then() method don't need the suffix because and_then() is not an asynchronous function - it's just a function converting one type of future into another.

bryandmc commented 5 years ago

I'm handling this, cause it's insanely easy -- but what about 'accept' and the stream related? Thoughts?

Edit: how about AcceptFuture and then IncomingStream for incoming()...?

yoshuawuyts commented 5 years ago

Edit: how about AcceptFuture and then IncomingStream for incoming()...?

That sounds good to me! I'm not sure if we'll ever get nicer syntax for creating streams (yield perhaps), but until we do there seems little harm in spelling this out (: