NexusClient::create
NexusClient is Clone (an Arc bump) and Debug (credentials redacted).
Config, WifNotConfigured, WifTokenExchangeFailed, DeveloperCredentials, Transport, ResponseTooLarge, Json, and any variant of the status mapping - EnvironmentDisabled included - since the mandatory initial sync (and, with WIF, the token exchange) can be refused like any request.
On success the startup summary is emitted.
Read methods (synchronous)
They read the in-memory snapshot: no network call, and they never block on one. A stale snapshot is served as-is while a single background refresh runs - unless a quarantine, a billing back-off or a switched-off environment is holding the refresh.key_type is derived from the configured api_key prefix. sync_errors lists what the last sync reported it did not deliver - empty when everything arrived; a 304 keeps the previous list:
SyncError is #[non_exhaustive] and never carries a value.
get_secret returns text secrets only.
find_flag returns None for an absent flag, which is a different answer from present-and-false.
File-type secrets
0600 inside a private, unguessable, mode-0700 directory owned by this client, created with create_new + O_NOFOLLOW and renamed into place - so a reader never sees a half-written file and no other local user can read it. The filename is a hash, so neither the key nor the value appears in the path your application logs. Two clients holding the same secret get different paths. A secret removed on the server is removed from disk on the next sync, and everything is deleted on close() or when the last clone of the client is dropped.
get_secret_file_path enforces the same authorisation gates as get_secret. On Windows there is no 0600 equivalent - the file inherits the private directory’s ACL.
Write methods (async, secret key required)
PublicKeyRestricted before any HTTP call. Keys are percent-encoded into the path.
evaluate_ab
AbAddonNotAvailable when the add-on is not active, EnvironmentDisabled when the environment is switched off, RateLimited on 429. A result that is not a boolean is reported as an error rather than silently read as false.
Attribute values are strings. The service compares them with eq, neq and in, so string equality is the whole of what a cohort rule can express. At most 200 keys per call; an empty keys array is rejected by the service. Available identically on the blocking client, without .await.
sync
Live updates and shutdown
run_stream() starts SSE live updates on a tokio task and is idempotent - a second call opens no second connection. See SSE live updates.
close() stops all background work and removes materialised file-type secrets. It is final - nothing restarts them, and an in-flight sync cannot re-arm them - and idempotent. Cache reads keep working afterwards. The same cleanup runs automatically when the last clone of the client is dropped, including while the stream is active.
blocking::NexusClient
With theblocking feature, westyx_nexus::blocking::NexusClient mirrors every method above without .await, plus as_async() to reach the async client underneath. It owns a small runtime on its own threads, so its calls work from anywhere - including inside another runtime.
NexusError
#[non_exhaustive] - match with a _ arm. status() and code() answer for every variant. See Error handling for the full table.