A light-as-air client/server networking library for Rust

Related tags

Command-line aeronet
Overview

aeronet

crates.io docs.rs

A light-as-air client/server networking library with first-class support for Bevy, providing a consistent API which can be implemented by different transport mechanisms.

Aeronet's main feature is the transport - an interface for sending data to and receiving data from an endpoint, either the client or the server. You write your code against this interface (or use the Bevy plugin which provides events used by the transport), and you don't have to worry about the underlying mechanism used to transport your data.

Transports

  • aeronet_channel via in-memory MPSC channels, useful for local singleplayer servers
  • aeronet_wt_native via a Rust implementation of WebTransport, useful for a generic client-server architecture with support for WASM clients
  • aeronet_wt_wasm via the browser's implementation of WebTransport, useful for a WASM app which requires a networking client

Getting started

First, you will need two [Message] types to use for sending client-to-server (C2S) and server-to-client messages (S2C). They may be the same type.

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum C2S {
    Move(f32),
    Shoot,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub enum S2C {
    AddPlayer(String),
    UpdateHealth(f32),
}

fn assert_is_message<T: aeronet::Message>() {}

assert_is_message::<C2S>();
assert_is_message::<S2C>();

Then, you will need a transport implementation to use. Select one from the list above that suits your needs. Afterwards, use the [ClientTransport] and [ServerTransport] traits to interact with the transport, to do functions such as sending and receiving data.

let client = MyClientTransport::<C2S, S2C>::new();

client.send(C2S::Shoot);

let rtt: Duration = client.info().rtt();
println!("Latency to server: {rtt}");

With Bevy

Aeronet provides transport-agnostic plugins for the client and server transports, letting you write the same code for all networking without worrying about the underlying transport that's used to deliver your messages.

use bevy::prelude::*;
use aeronet::ClientTransportPlugin;

fn main() {
    App::new()
        .add_plugins((
            ClientTransportPlugin::<C2S, S2C, MyClientTransport<_, _>>::default(),
        ))
        .add_systems(Update, on_recv)
        .run();
}

fn on_recv(
    mut recv: EventReader<FromServer<S2C>>,
) {
    for FromServer(msg) in recv.iter() {
        println!("Got a message from the server: {msg:?}");
    }
}
You might also like...
TinyTodo is a Cedar Agent example, with a server in Rust and client in python
TinyTodo is a Cedar Agent example, with a server in Rust and client in python

TinyTodo - OPAL and Cedar Agent Demo TinyTodo is a simple application for managing task lists. It uses OPAL and Cedar Agent to control who has access

REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀
REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀

Information: REC2 is an old personal project (early 2023) that I didn't continue development on. It's part of a list of projects that helped me to lea

SA-MP client server list fix but written in Rust

Server List Fix This is a samp client server list fix, which reroutes the client's request to list.sa-mp.com to sam.markski.ar. The idea is originally

Bruteforce connecting to a specific Sea of Thieves server. Useful if you want to be in the same server as your friends.

SoT Server Finder Find which Sea of Thieves server you're connected to. Useful if you want to be in the same server as your friends. Setup Download so

Leptos server signals synced through Server-Sent-Events (SSE)

Leptos Server Sent Events Server signals are leptos signals kept in sync with the server through server-sent-events (SSE). The signals are read-only o

Russh - Async (tokio) SSH2 client and server rimplementation

Russh Async (tokio) SSH2 client and server rimplementation. This is a fork of Thrussh by Pierre-Étienne Meunier which adds: More safety guarantees AES

A backend server and client for Norg related applications.

Norgopolis Norgopolis is a lightweight communication, launcher and utility services client for the Neorg rust-native modules ecosystem on Desktop. It

Provides a mock Ambi client that emulates real sensor hardware such as an Edge client

ambi_mock_client Provides a mock Ambi client that emulates real sensor hardware such as an Edge client. Usage You must have Rust installed to build am

A tool to easily work with timezone lookups via a binary, a library, or a server.
A tool to easily work with timezone lookups via a binary, a library, or a server.

rtz A self-contained geo lookup library / binary / server for Rust / JS (via WASM) (free server) using data from the Natural Earth and OpenStreetMap d

Comments
  • Message types

    Message types

    Use <C2S, S2C> instead of <C: *TransportConfig> or <M: MessageTypes> to make it easier for transport impls to put type bounds on C2S and S2C

    opened by aecsocket 0
Owner
A hobbyist programmer from the UK
null
A domain-specific language for writing AIR constraints for Miden VM

AirScript A domain-specific language for expressing AIR constraints for STARKs, especially for STARK-based virtual machines like Miden VM. An in-depth

Polygon Miden 16 Nov 9, 2022
A lightning fast networking solution for roblox.

Zap Zap is a blazingly fast networking solution for Roblox. Features Zap packs data into buffers with no overhead. The same data can be sent using a f

null 18 Dec 31, 2023
A ln scraper to read light novels and watch anime in your terminal (Written in rust)

Readme Table of content Why use kami Dependencies Install Linux/mac Windows Honorable mentions Why use kami Well its a fast and easy way to watch anim

mrfluffy 26 Dec 23, 2022
Benson, the light that warms all

benson Benson, the light that warms all Commands Command Info !benson status Checks benson bot status !benson join_vc id Joins a voice channel by ID

Residence 3 2 Nov 17, 2021
Build light & secure cross-platform applications with a web-based UI

Millennium Icon by XFaon. *Stats are from Tauri and may not be fully accurate. Millennium is a cross-platform webview framework written in Rust. With

pyke 20 Dec 29, 2022
Proof-of-concept on how to solve Bitcoin's light node sync problem with zkSNARKs

BTC Warp Prove and verify the longest Bitcoin PoW chain BTC Warp is a proof-of-concept system that aims to solve the client-syncing problem for Bitcoi

Succinct 45 May 31, 2023
A dark and light Neovim theme written in fennel, inspired by IBM Carbon.

oxocarbon.nvim Note: The old rust version can be found on the rust branch of this repository Oxocarbon is looking for ports! If you're a user of anoth

Nyoom Engineering 690 Jun 29, 2023
Light and fast indexer for Ordinals.

ordi ordi is a fast light indexer for building ordinals data source. Usage export btc_data_dir= export ordi_data_dir= export btc_rpc_host= export btc

null 21 Oct 1, 2023
Light and fast indexer for Ordinals.

ordi ordi is a fast light indexer for building ordinals data source. Usage export btc_data_dir= export ordi_data_dir= export btc_rpc_host= export btc

null 22 Oct 7, 2023
A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

Vagelis Prokopiou 4 Aug 14, 2022