Skip to content

erhant/rustconnect-libp2p

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibP2P Chat with FFI

A demonstration of using libp2p in Rust with C FFI bindings, showcasing peer-to-peer communication capabilities in a cross-language environment, for Rust Connect #1 in Istanbul, Turkey 04/05/2025.

Usage

You will need Rust to use this project. Clone the repository to get started:

git clone https://github.com/yourusername/rustconnect-libp2p
cd rustconnect-libp2p

Then, build the library:

cargo build --release

You can run with:

cargo run

You can type a text to the terminal, and when you press ENTER it will be published to the network. To exit the application, you must write exit and enter.

FFI

You need a C compiler (gcc / clang) for the FFI example. After building the Rust library, go to ffi directory and build the C binary:

cd ffi
make

# or `make again` if you have changes & want to force re-build

Now you can run the binary with:

./build/main

# can enable logs as well:
RUST_LOG=info ./build/main

This will listen to messages on the network; to terminate the application simply do CTRL+C. How to publish messages is left as an exercise!

Note

The FFI functions are exported via external feature, which is enabled by default.

Documentation

You can view the crate documentation with:

cargo doc --open --no-deps --document-private-items

License

Licensed under the MIT License.

About

Libp2p & FFI for Rust Connect #1

Topics

Resources

License

Stars

Watchers

Forks