Move generated functions under their corresponding items.

- fn serve -> Service::serve
- fn new_stub -> Client::new

This allows the generated function names to remain consistent across
service definitions while preventing collisions.
This commit is contained in:
Tim Kuehn
2019-07-30 20:13:32 -07:00
parent 2f24842b2d
commit 1b58914d59
12 changed files with 155 additions and 144 deletions

View File

@@ -44,9 +44,9 @@ async fn main() -> io::Result<()> {
let transport = json_transport::connect(&server_addr).await?;
// world_stub is generated by the service attribute. Like Server, it takes a config and any
// Transport as input, and returns a Client, also generated by the attribute.
let mut client = service::world_stub(client::Config::default(), transport).await?;
// WorldClient is generated by the service attribute. It has a constructor `new` that takes a
// config and any Transport as input.
let mut client = service::WorldClient::new(client::Config::default(), transport).await?;
// The client has an RPC method for each RPC defined in the annotated trait. It takes the same
// args as defined, with the addition of a Context, which is always the first arg. The Context