Crates.io | libp2p-rs |
lib.rs | libp2p-rs |
version | 0.3.0 |
source | src |
created_at | 2020-10-26 09:50:00.048063 |
updated_at | 2021-04-23 08:25:11.426165 |
description | Minimal implementation for a multiplexed p2p network framework |
homepage | |
repository | https://github.com/netwarps/libp2p-rs |
max_upload_size | |
id | 305572 |
size | 277,513 |
This repository is an alternative implementation in Rust
of the libp2p spec. Not like rust-libp2p
, libp2p-rs
is written with async/await syntax, and driven by async runtime. Even though, many codes are borrowed from rust-libp2p
and some from go-libp2p
. We are trying to keep compatible with the two implementations, but it is unfortunately not guaranteed.
How to use the library?
As mentioned above, the API is completely different from rust-libp2p
. There is no such thing as 'NetworkBehaviour' in libp2p-rs
at all. Instead, you should build the Swarm with the transports you like to use, then you have to create a Swarm::Control from it. The Swarm::Control is exposing all Swarm APIs which can be used to manipulate the Swarm - open/read/write/close streams and even more. This is quite similar as the BasicHost in go-libp2p
. As for Kad-DHT, similarly you should get the Kad::Control for the same reason. Furthermore, you can combine the Swarm with Kad, after that you have the RoutedHost, which has a routing functionality over the BasicHost.
It is strongly recommended to check the docs and sample code in details:
docs
Code examples:
examples
NOTE: The master branch is now an active development branch (starting with v0.1.0), which means breaking changes could be made at any time.