rustasync / runtime

Empowering everyone to build asynchronous software

Home Page:https://docs.rs/runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rename Future types

yoshuawuyts opened this issue · comments

commented

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.

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()...?

commented

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 (: