Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 35 fields pub database_url: String, pub listen_database_url: Option<String>, pub site_schema: String, pub schema: String, pub pool_size: usize, pub public_url: String, pub site_url: String, pub esports_login: bool, pub esports_secret: Option<String>, pub signup: bool, pub site_name: String, pub host_name: Option<String>, pub admin_emails: Vec<String>, pub staff_passkey_hours: i32, pub bind: String, pub metrics_bind: String, pub lag_comp_ms: i64, pub challenge_ttl_secs: u64, pub first_move_secs: u64, pub gone_after_secs: u64, pub claim_win_secs: u64, pub public_delay_plies: usize, pub fairplay: bool, pub block_marked: bool, pub sweep_ms: u64, pub vision_endpoint: String, pub vision_model: String, pub vision_api_key: Option<String>, pub vision_local_model: String, pub vision_min_confidence: f32, pub vision_review: bool, pub vision_review_max: i64, pub tablebase_url: String, pub app_dir: Option<String>, pub app_theme: Option<String>,
}

Fields§

§database_url: String

Postgres URL: this server’s database (its own; it may share a host site’s database in its own schema). A pooled (-pooler) host is fine; notifications use the direct host automatically.

§listen_database_url: Option<String>

A separate URL for LISTEN, if the direct host can’t be derived.

§site_schema: String

A host site’s schema in the same database whose chess players (and their chess tokens) are imported once, with their ids, the first time this version starts. Nothing is read from it afterwards; a schema that isn’t there is skipped.

§schema: String

This server’s own schema (games, challenges, ratings, fair play).

§pool_size: usize§public_url: String

Where clients reach this server, including any path prefix (https://chess.example.com). Used in game URLs and to mount the API under the prefix.

§site_url: String

The host site (esports-lab) players can sign in with.

§esports_login: bool

“Sign in with the host site” (esports-lab): its players sign in here through it, and its server gets tokens for them. Needs ESPORTS_SECRET. Off by default (the site is private); the server’s own accounts work either way.

§esports_secret: Option<String>

The secret shared with the host site: it signs sign-ins and asks for its players’ tokens with it (at least 32 characters).

§signup: bool

Anyone may make an account here (a name and a password). Off: only accounts that exist (and the host site’s players, with ESPORTS_LOGIN) sign in.

§site_name: String

What players know the site as: on the OAuth page, in PGN event names and in GET / (which the training app shows).

§host_name: Option<String>

What players know the host site as (esports-lab), when they can sign in with it: “Sign in with …”, “linked to your … account”. The site name when unset.

§admin_emails: Vec<String>

People made admins here, by email (comma-separated): an account gets the admin role when it signs in with one of these, once the email is confirmed (a host site’s sign-in vouches for it) and it has a passkey. Accounts made here have unconfirmed emails: make them admins with open-chess admin grant.

§staff_passkey_hours: i32

Hours an admin’s or manager’s passkey check lasts.

§bind: String§metrics_bind: String

/metrics, /healthz and /readyz.

§lag_comp_ms: i64

Milliseconds given back per move for the network round trip.

§challenge_ttl_secs: u64

A real-time challenge lapses after this many seconds unless the challenger keeps a keepAliveStream open.

§first_move_secs: u64

Each side’s first move must come within this many seconds or the game is aborted.

§gone_after_secs: u64

A player with no open game stream for this long is “gone”.

§claim_win_secs: u64

Then the opponent may claim the win after this many more seconds.

§public_delay_plies: usize

The public move stream runs this many plies behind a live game, so it can’t feed an engine helping a player.

§fairplay: bool

Queue human players’ finished games for fair-play analysis.

§block_marked: bool

Accounts marked for engine use can’t start new games.

§sweep_ms: u64

How often the clock sweeper looks for flags and lapsed challenges.

§vision_endpoint: String

Reading boards from photos: base URL of a vision model behind an OpenAI-style /chat/completions (Claude via https://api.anthropic.com/v1, Qwen-VL via Ollama’s http://localhost:11434/v1, or a gateway). Empty: photo reading is off.

§vision_model: String

The vision model’s name as that server knows it.

§vision_api_key: Option<String>

Bearer token for the vision server, if it needs one.

§vision_local_model: String

Our own board reader (chess-vision): a .safetensors weights file from chess-vision-train. It reads photos first, on this server’s CPU; the vision model at CHESS_VISION_ENDPOINT (if set) is only asked about photos it isn’t sure of. Empty: not used.

§vision_min_confidence: f32

The board reader’s answer is used without review when every square is above its unsure threshold and the chance that all 64 are right is at least this.

§vision_review: bool

Keep photos that couldn’t be read for sure for the Review page, where a person confirms the position; confirmed photos become training data (open-chess photos export). Players are told.

§vision_review_max: i64

At most this many photos wait for review; beyond it, new ones aren’t kept.

§tablebase_url: String

Where exact endgame results (up to seven pieces) come from: a Lichess-compatible tablebase server. Answers are kept in the database, so each position is fetched once. Empty: off.

§app_dir: Option<String>

The built training app (web/chess plus its wasm engine), served at /app/. The chess image puts it at /usr/share/open-chess/app.

§app_theme: Option<String>

The app’s look for this deployment: a theme the app bundles, by name (esports-lab: web/chess/themes), CSS, or the path of a .css file; served as /app/theme.css, after the app’s own styles, so it can set the app’s colour and font variables (docs/api.md, “The Chess lab’s look”).

Implementations§

Source§

impl Config

Source

pub fn base_path(&self) -> Result<String>

The path the API lives under (/chess, or empty).

Source

pub fn public_url(&self) -> &str

Source

pub fn host_name(&self) -> &str

What players know the host site as.

Source

pub fn admin_emails(&self) -> Vec<String>

CHESS_ADMIN_EMAILS, lower-cased.

Source

pub fn esports(&self) -> Option<&str>

The secret shared with the host site, when signing in with it is on.

Source

pub fn challenge_ttl(&self) -> Duration

Source

pub fn validate(&self) -> Result<()>

Trait Implementations§

Source§

impl Args for Config

Source§

fn group_id() -> Option<Id>

Report the ArgGroup::id for this set of arguments
Source§

fn augment_args<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate Self via FromArgMatches::from_arg_matches_mut Read more
Source§

fn augment_args_for_update<'b>(__clap_app: Command) -> Command

Append to Command so it can instantiate self via FromArgMatches::update_from_arg_matches_mut Read more
Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromArgMatches for Config

Source§

fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn from_arg_matches_mut( __clap_arg_matches: &mut ArgMatches, ) -> Result<Self, Error>

Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Source§

fn update_from_arg_matches( &mut self, __clap_arg_matches: &ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.
Source§

fn update_from_arg_matches_mut( &mut self, __clap_arg_matches: &mut ArgMatches, ) -> Result<(), Error>

Assign values from ArgMatches to self.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more