libtransport-tcp in Rust.
This crate provides a TCP-based implementation of the libtransport crate. Other data structures such as the Peer, PeerId, PeerList and Data must be defined by the developer for their individual use case.
A simple example of a method which can use this trait is the common_test method in libtransport:
// Create data type to be sent over TCP stream
struct data (pub u8);
// Create a set of peers with associated addresses and sockets
let a: Vec<String> = vec![
String::from("127.0.0.1:9000"),
String::from("127.0.0.1:9001"),
String::from("127.0.0.1:9002"),
];
// Call the method, using the transport type, with the peers inputted.
common_test::<TCPtransport<data>>(a);
When implementing this yourself, you would obviously need to implement more features and traits. This is just a general idea of how it could work. For a more specific example, refer to the common_test method in libtransport/generic_tests.
https://github.com/Fantom-foundation/fantom-rfcs
Install the latest version of Rust. We tend to use nightly versions. CLI tool for installing Rust.
We use rust-clippy linters to improve code quality.
There are plenty of IDEs and other Rust development tools to consider.
# Install Rust (nightly)
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly
# Install cargo-make (cross-platform feature-rich reimplementation of Make)
$ cargo install --force cargo-make
# Install rustfmt (Rust formatter)
$ rustup component add rustfmt
# Install clippy (Rust linter)
$ rustup component add clippy
# Clone this repo
$ git clone https://github.com/Fantom-foundation/libtransport-tcp && cd libtransport-tcp
# Run tests
$ cargo test
# Format, build and test
$ cargo make