Crates · 0.2.0 · MIT OR Apache-2.0
The crates.
The server, the protocol, the Rust client and the installer live in the net_backend repository; the Bevy plugin and the Steam crate have their own. Each crate has its own version, changelog and README. Rust 1.95 or newer.
net_backend_server
0.2.0 · the frameworkA Rust library you build your own game-server binary with (tokio + axum; not a finished server application): accounts and sessions, a WebSocket hub, modules with hooks, MySQL / PostgreSQL / SQLite, migrations, OpenAPI + AsyncAPI documents, a command line (serve, migrate, config check, user:create, healthcheck, …). Every module is a cargo feature, off by default; a server compiles only what it registers.
- Eight new modules: Leaderboards, Notifications, Friends, Groups, OpenID Connect logins (
oauth), Lobbies, Matchmaking, Files, and Permissions in the core. With Accounts, Storage and Chat: eleven modules. - Chat extras: message editing, read markers and unread counts, typing indicators, rooms created by players.
- Storage objects other players read: a visibility
private/public/friends. - A
healthcheckcommand in every server binary (container health checks without a shell orcurl), and--version. - The default database feature is
postgres:cargo add net_backend_serverbuilds PostgreSQL; MySQL / MariaDB is--no-default-features --features mysql; a missingdatabase.urlis an error, never a fallback. - SQLite runs with
synchronous = NORMAL(WAL): a commit no longer waits for the disk; a power loss can lose the last moments of writes and never corrupts the file;database.sqlite_synchronous = "full"waits for the disk on every write. - A per-account session cap (
max_sessions_per_user, 100),database.statement_timeout_secs, upload time limits timed by the data (30 s without data, 1 h overall). - The reference server and the Docker image register every module; one Compose file per database and a one-command Docker trial.
cargo add net_backend_server # PostgreSQL (the default)
cargo add net_backend_server --no-default-features --features sqlite,storage,chat # SQLite with storage + chat
net_backend_protocol
0.2.0 · the shared message typesPlain Rust + serde data types and pure helpers, used by the server and by Rust clients: every request, answer and push, and the exact JSON they become. The JSON on the wire is the contract; this crate is the convenience for Rust.
- The types and typed HTTP calls (
HttpCall) of every new module: leaderboards, notifications, friends with the Steam ID lookup, groups, OpenID Connect, files, storage visibility, lobbies with join codes, matchmaking, the chat extras. - With the feature
bevy_net_backend, the modulebevy: every HTTP route as a typedbevy_net_backendrequest (request,HttpClientCalls::call,api_error), plus the WebSocket requests and pushes. Password,AccessToken,RefreshTokenandSecretoverwrite their memory with zeros when dropped.
cargo add net_backend_protocol
cargo add net_backend_protocol --features bevy_net_backend # typed calls for Bevy
net_backend_client
0.2.0 · the Rust clientA Rust client for apps that do not use Bevy (tools, bots, command-line programs, other engines): HTTP, WebSocket, SSH / SFTP; async (tokio) and blocking (for game loops: nothing blocks a frame). Logs in (email + password, a Steam ticket, an OpenID Connect ID token), refreshes tokens, retries a 401 once after a refresh.
- Every new module's calls and pushes.
- Files: uploads streamed from disk with progress, downloads into memory or to a file, checked by SHA-256.
- "Sign in with Google" or any OpenID Connect provider from a desktop app (system browser, PKCE, a one-time loopback redirect; non-blocking on the blocking client).
- A token file (
ClientBuilder::token_file): stay logged in between runs, written atomically, owner-only on Unix. - Proxies (HTTP CONNECT from
HTTPS_PROXY/HTTP_PROXY/ALL_PROXY/NO_PROXYor the builder); certificates (extra root certificates from PEM text or a file, the operating system's store with the featureos-certificates); HTTP/2 through ALPN (featurehttp2). - Cancel (
Reply::cancel, with an honest "was it sent"); a call's own deadline (call_with_timeout); SSH auto-reconnect (opt-in); pipelined SFTP downloads with progress; secrets overwritten with zeros when dropped and never in a log line.
cargo add net_backend_client --features ws
cargo add tokio --features rt-multi-thread,macros
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"]);
use net_backend_client::blocking::Client;
use net_backend_client::protocol::auth::{GetAccount, LoginRequest};
let client = Client::new("https://api.example.com")?;
client.login(LoginRequest::new("player@example.com", "a long password"))?; // blocks (start-up)
let mut me = client.send(GetAccount::new()); // never blocks
loop {
// ... one frame of the game ...
if let Some(answer) = me.try_take() {
println!("hello {:?}", answer?.display_name);
break;
}
}
net_backend
0.2.0 · the installer (CLInet-backend)cargo install net_backend gives the command net-backend. net-backend new mygame asks a few questions (or takes flags) and writes a game backend that runs at once: the server with the chosen modules on SQLite, PostgreSQL or MySQL, a client for your kind of game, a demo app with buttons, and Docker files matched to the database. It prints the one-line command that gives the same project. In a terminal it shows a "NET BACKEND" banner, a section per question, colored badges and a summary box (--no-color / NO_COLOR: plain text). Generating needs no network.
cargo install net_backend
net-backend new mygame
cd mygame
cargo run # the server on http://127.0.0.1:8080, on SQLite
cargo run -p demo # in a second terminal: the demo window, a panel per module
bevy_net_backend
0.2.0 · the Bevy pluginHTTP, WebSocket and SSH / SFTP for Bevy: 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. Works with any backend (HTTPS + JSON, plain WebSocket); with net_backend it is the Bevy client, typed through net_backend_protocol's bevy_net_backend feature. bevy_net_backend 0.2.0 and bevy_steam_kit 0.2.0 are made for Bevy 0.19.
- WebSocket credentials refresh (opt-in): one
WsCredentialsRefusedmessage, the game refreshes, the connection reconnects once; a handshake refused with 429 / 503 waits for itsRetry-After. - Files streamed from disk in multipart uploads with upload progress, JSON / typed parts; downloads to a file with progress and a SHA-256 / size check (never whole in memory).
- "Sign in with Google" or any OpenID Connect provider (feature
oauth: PKCE, a one-time listener on 127.0.0.1, the sign-in URL handed to the game as a message). - Certificates (
TlsSettings: extra roots, the OS store withos-certificates);SecretFile(one secret in a file between runs, written atomically, owner-only on Unix). - Proxies (
ProxySettings: the environment, one URL, or none; WebSocket throughhttp://proxies; a request that would need a SOCKS proxy is refused, never sent around it). - Request bodies and secrets overwritten with zeros; pipelined SFTP downloads.
cargo add bevy_net_backend --features ws
cargo add net_backend_protocol --features bevy_net_backend
bevy_steam_kit
0.2.0 · Steam for BevySteam for Bevy, as opt-in features: one plugin owns the one Steam callback pump of the process; six features, plus steam, the real backend over steamworks. An in-memory fake Steam makes all of it testable without a Steam client.
| Feature | What |
|---|---|
lobby | lobbies, rich presence so friends see "Join Game", invites, every join request as one Bevy message |
stats | stats and achievements |
leaderboards | Steam leaderboards |
auth | Steam Web API tickets for logging in to a game server |
friends | the friends list with online status, invites with any connect string, avatars |
overlay | open the Steam overlay, know when it opens and closes |
steam | the real backend over steamworks |
cargo add bevy_steam_kit --features lobby,friends,auth,overlay,steam