net_backend

Crates · one workspace, each crate versioned on its own

The crates.

The server, the protocol and the Rust client live in the net_backend repository; the Bevy plugin has its own. Each crate has its own version, changelog and README.

net_backend_server

0.1.0

The game-backend framework: tokio + axum, modules with hooks, accounts and sessions, a WebSocket hub, storage (saves) and chat, MySQL / PostgreSQL / SQLite, migrations, OpenAPI + AsyncAPI. A library you build your own server binary with.

Cargo.toml
net_backend_server = { version = "0.1.0" }   # features: mysql (default), postgres, sqlite, storage, chat, steam, smtp

net_backend_protocol

0.1.0

The shared message types: plain Rust + serde, no networking, no async runtime, no engine. The server and Rust clients import the same types, so both sides agree on every request, answer and push, and on the exact JSON they become. The JSON on the wire is the real contract; this crate is the convenience for Rust and the single source of truth.

Cargo.toml
net_backend_protocol = { version = "0.1.0" }
# With the optional client integration:
# net_backend_protocol = { version = "0.1.0", features = ["bevy_net_backend"] }

net_backend_client

0.1.0

The Rust client, built on the protocol, for Rust apps that do not use Bevy: other engines, tools, bots, command-line programs and admin tools.

  • Every HTTP route, typed. client.call(&request) takes any request of the protocol, or a game's own route described the same way, and answers its typed response. Errors carry the server's stable error code.
  • The session, handled. Register, log in (email + password or a Steam ticket), log out or log out everywhere. The access token is refreshed before it expires, one refresh at a time for every caller; a call answered 401 is retried once after a refresh; every new token pair is handed to your app so it can store it.
  • Async or blocking. One async core on tokio, plus a blocking interface for game loops and simple programs: send now, pick up the answer later with try_take(), from any thread. Nothing ever blocks a game frame.
  • A WebSocket that reconnects by the rules (feature ws): typed requests and answers, typed server pushes, heartbeats, automatic reconnects with backoff that never retry after a "do not come back" close code.
  • SSH and SFTP to the server machine (features ssh, sftp) for admin tools: commands and file transfer to its OpenSSH, strict host-key checks, Terrapin protection.
  • Small. TLS with rustls + ring, no OpenSSL; HTTP and the WebSocket use the same crates as the server, so an app that also runs the server adds no new crate for them.
FeatureWhat
(always)HTTP(S): log in, keep the session fresh, call the server's routes with the protocol's typed requests; the blocking interface
wsthe WebSocket: typed requests and answers, server pushes, heartbeats, reconnects
sshSSH to the server machine's OpenSSH (admin tools, commands)
sftpfile transfer over SSH (implies ssh)
ssh-rsaalso accept old RSA host keys and RSA key files (opt-in)
Cargo.toml
net_backend_client = { version = "0.1.0" }
# or with the WebSocket:
net_backend_client = { version = "0.1.0", features = ["ws"] }
# an admin tool with SSH and SFTP:
net_backend_client = { version = "0.1.0", features = ["ws", "sftp"] }
async
use net_backend_client::protocol::auth::{GetAccount, LoginRequest};
use net_backend_client::protocol::storage::{GetObject, PutObject, WriteObject};
use net_backend_client::{Client, Error};

let client = Client::new("https://api.example.com")?;
client.login(LoginRequest::new("player@example.com", "a long password")).await?;

let me = client.call(&GetAccount::new()).await?;
client.call(&WriteObject::new("saves", "slot-1", PutObject::new(serde_json::json!({"level": 3})))).await?;
let save = client.call(&GetObject::new("saves", "slot-1")).await?;
println!("{:?} is on level {}", me.display_name, save.value["level"]);

The protocol's types are re-exported as net_backend_client::protocol, so the versions always match. The crate's tests run the real net_backend_server in the same process, plus an in-process mock SSH server. Compatible with net_backend_server 0.1.x (protocol version 1), Rust 1.95+.

bevy_net_backend

0.1.0 · Bevy 0.19

Connects a Bevy game to its own backend, with the same features as Bevy plugins: HTTP (default) with your serde types and file uploads, WebSocket (feature ws) with reconnect and heartbeat built in, and SSH and SFTP (features ssh, sftp) for admin and developer tools. A system fires a request and gets a RequestId back at once; a few frames later exactly one typed answer arrives as a Bevy message.

Source and manual: github.com/warmar94/bevy_net_backend.

net_backend_servernet_backend_protocolaxumsqlxsea-queryutoipaRust
0.1.00.1.00.8 (≥ 0.8.9)0.91.0 (≥ 1.0.2)61.95+