Skip to main content

wire/preference/
core.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! Performance configuration grammar (`crates/wire/spec/Preference.lean` D30).
7
8use serde::{Deserialize, Serialize};
9use std::num::NonZeroU64;
10
11/// The placement arm; platform policy belongs to serving::placement.
12#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
13#[serde(rename_all = "snake_case")]
14#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
15pub enum CorePlacement {
16    #[serde(rename = "none")]
17    Off,
18    #[default]
19    Soft,
20    SoftShares,
21    Pinned,
22}
23
24/// Whether the core's hot threads stand above normal.
25#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
26#[serde(rename_all = "snake_case")]
27#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
28pub enum CorePriority {
29    #[default]
30    Raised,
31    Normal,
32}
33
34/// The person's `[core]` section, read at serving startup.
35#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
36#[serde(default, deny_unknown_fields)]
37#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
38pub struct CorePreferences {
39    pub placement: CorePlacement,
40    pub priority: CorePriority,
41    /// Absent means no memory ceiling. Only soft_shares requests it.
42    pub memory_bytes: Option<NonZeroU64>,
43}