#async #rpc #go #async-std #tokio


An async RPC that mimics golang net/rpc’s usage and supports both async-std and tokio

35 releases (7 breaking)

new 0.8.0-beta.0 Jul 28, 2021
0.7.6 Jul 13, 2021
0.6.0-alpha Mar 30, 2021
0.4.5 Dec 22, 2020
0.3.1 Nov 27, 2020

#497 in Network programming

Download history 37/week @ 2021-04-06 65/week @ 2021-04-13 84/week @ 2021-04-20 2/week @ 2021-04-27 26/week @ 2021-05-04 29/week @ 2021-05-18 17/week @ 2021-05-25 30/week @ 2021-06-01 41/week @ 2021-06-08 82/week @ 2021-06-15 37/week @ 2021-06-22 1/week @ 2021-06-29 1/week @ 2021-07-06 64/week @ 2021-07-13 72/week @ 2021-07-20

133 downloads per month




An async RPC crate that mimics the golang's net/rpc package and supports both async-std and tokio.

toy-rpc aims to be an easy-to-use async RPC tool that is inspired by golang's net/rpc's API. It supports both async_std and tokio runtimes over either TCP or TLS. Integration with common HTTP server frameworks such as actix_web, warp and tide are provided.

The overall usage and API should feel similar to that of the golang's net/rpc package. Some of the names are changed to make them sound more "rusty". Because rust does not come with runtime reflection, attribute macros #[export_impl] and #[export_trait] / #[export_trait_impl], and attribute #[export_method] are used to mark functions "exported" in golang's net/rpc perspective.

More detailed usage can be found in the book and documentation.

This crate uses #![forbid(unsafe_code)] to ensure no usage of unsafe in the crate.

Feature flags

The feature flags can be put into three categories.

Choice of runtime and HTTP framework integration

  • async_std_runtime: supports usage with async-std
  • tokio_runtime: supports usage with tokio
  • http_tide: enables tide integration on the server side. This also enables async_std_runtime
  • http_actix_web: enables actix-web integration on the server side. This also enables tokio_runtime
  • http_warp: enables integration with warp on the server side. This also enables tokio_runtime

Choice of RPC server or client (both can be enabled at the same time)

  • server: enables RPC server
  • client: enables RPC client

Choice of serialization/deserialzation (only one should be enabled at a time)

  • serde_bincode: (default) the default codec will use bincode for serialization/deserialization
  • serde_json: the default codec will use serde_json for json serialization/deserialization
  • serde_cbor: the default codec will use serde_cbor for serialization/deserialization
  • serde_rmp: the default codec will use rmp-serde for serialization/deserialization

TLS support

  • tls: enables TLS support

Other trivial feature flags are listed below, and they are likely of no actual usage for you.

  • docs
  • std: serde/std. There is no actual usage right now.

By default, only serde_bincode feature is enabled. You must enable at least one runtime feature flag and the server and/or client to have something usable.

Default features

default = ["serde_bincode"]


HTTP integration is provided for actix-web, tide, and warp. More details can be found in the Book/Integrations and in examples.

Quickstart Example

A quickstart example with tokio runtime is provided in the Book/Quickstart.

License: MIT/Apache-2.0


~295K SLoC