Expand description
A Rust client for net_backend_server, built on the shared types of net_backend_protocol.
For Rust apps that do not use Bevy (other engines, tools, bots, command-line programs); Bevy
games use bevy_net_backend.
Client(async, tokio): typed calls for every route (Client::callwith anyHttpCall), the session (login, register, Steam, automatic refresh before expiry, one refresh at a time, rotating refresh tokens reported throughTokenUpdates, logout), errors as the server’s codes (Error::Api).blocking::Client: the same client for programs without a runtime, withReply::try_takefor game loops.- Feature
ws: the WebSocket (modulews): typed requests, pushes, heartbeats, reconnects that obey the close codes. - Features
ssh/sftp/ssh-rsa: SSH and SFTP to the server machine’s OpenSSH (modulessh), for admin tools.
use net_backend_client::protocol::auth::{GetAccount, LoginRequest};
use net_backend_client::protocol::storage::{GetObject, PutObject, WriteObject};
use net_backend_client::Client;
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 README is the full manual.
Re-exports§
pub use net_backend_protocol as protocol;
Modules§
- blocking
- The blocking interface: the same client for programs without an async runtime (game loops of other engines, simple tools). Always compiled.
- ssh
ssh - SSH to the server machine’s OpenSSH (feature
ssh), and SFTP on it (featuresftp). For admin tools: deploy scripts, log tails, backups. It never goes throughnet_backend_server. - ws
ws - The WebSocket (feature
ws): one connection per client carrying typed requests and answers (WsCall), server pushes (ServerPush), heartbeats and reconnects that obey the protocol’s close codes.
Structs§
- Client
- The async client (tokio). Cheap to clone: clones share the connection pool and the session.
- Client
Builder - Settings for a
Client(Client::builder). Nothing is checked or opened untilbuild. - Reply
- The answer to one request that is on its way: exactly one
Resultarrives. - Token
Updates - Every change of the session’s tokens, for the app to persist them (
Client::token_updates).
Enums§
- Error
- Why a call, a connection or a command did not succeed.
- Host
KeyProblem - Why an SSH host key was refused (
Error::HostKey).
Constants§
- DEFAULT_
MAX_ RESPONSE_ BYTES - The default limit of one HTTP answer body: 10 MiB (a full storage batch is about 4 MiB).
- DEFAULT_
TIMEOUT - The default deadline of one call: 15 s.
- MAX_
TIMEOUT - The longest deadline accepted: 1 hour.