use crate::export::Styles;
use crate::linear::proofs::cut;
#[cfg(feature = "interactive")]
use crate::linear::proofs::interactive;
use crate::linear::search::{Jobs, Options, batch};
use crate::{
Limits,
linear::{InputOptions, ViewOptions},
ordinary,
};
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
serde(default, deny_unknown_fields)
)]
pub struct Clock {
#[cfg_attr(feature = "serialize", serde(with = "crate::serialize::exact"))]
pub time_limit_ms: Option<u64>,
#[cfg_attr(feature = "serialize", serde(with = "crate::serialize::exact"))]
pub pool_after_ms: Option<u64>,
#[cfg_attr(feature = "serialize", serde(with = "crate::serialize::exact"))]
pub batch_time_limit_ms: Option<u64>,
}
impl Clock {
pub const DEFAULT_TIME_LIMIT_MS: u64 = 2000;
pub const DEFAULT_POOL_AFTER_MS: u64 = 100;
#[must_use]
pub const fn with_time_limit_ms(self, time_limit_ms: Option<u64>) -> Self {
Self {
time_limit_ms,
..self
}
}
#[must_use]
pub const fn with_pool_after_ms(self, pool_after_ms: Option<u64>) -> Self {
Self {
pool_after_ms,
..self
}
}
#[must_use]
pub const fn with_batch_time_limit_ms(self, batch_time_limit_ms: Option<u64>) -> Self {
Self {
batch_time_limit_ms,
..self
}
}
}
impl Default for Clock {
fn default() -> Self {
Self {
time_limit_ms: Some(Self::DEFAULT_TIME_LIMIT_MS),
pool_after_ms: Some(Self::DEFAULT_POOL_AFTER_MS),
batch_time_limit_ms: None,
}
}
}
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(
feature = "serialize",
derive(serde::Serialize, serde::Deserialize),
serde(default, deny_unknown_fields)
)]
pub struct Settings {
pub clock: Clock,
pub limits: Limits,
pub search: Options,
pub view: ViewOptions,
pub styles: Styles,
pub batch: batch::Options,
pub ordinary: ordinary::Options,
#[cfg(feature = "interactive")]
pub interactive: interactive::Options,
pub input: InputOptions,
pub cut: cut::Options,
pub lambda: crate::lambda::Options,
}
impl Default for Settings {
fn default() -> Self {
Self {
clock: Clock::default(),
limits: Limits::default(),
search: Options::default().with_copies(None).with_jobs(Jobs::Auto),
view: ViewOptions::default(),
styles: Styles::default(),
batch: batch::Options::default(),
ordinary: ordinary::Options::default(),
#[cfg(feature = "interactive")]
interactive: interactive::Options::default(),
input: InputOptions::default(),
cut: cut::Options::default(),
lambda: crate::lambda::Options::default(),
}
}
}
impl Settings {
#[must_use]
pub fn with_clock(self, clock: Clock) -> Self {
Self { clock, ..self }
}
#[must_use]
pub fn with_limits(self, limits: Limits) -> Self {
Self { limits, ..self }
}
#[must_use]
pub fn with_search(self, search: Options) -> Self {
Self { search, ..self }
}
#[must_use]
pub fn with_input(self, input: InputOptions) -> Self {
Self { input, ..self }
}
#[must_use]
pub fn with_view(self, view: ViewOptions) -> Self {
Self { view, ..self }
}
#[must_use]
pub fn with_styles(self, styles: Styles) -> Self {
Self { styles, ..self }
}
#[must_use]
pub fn with_batch(self, batch: batch::Options) -> Self {
Self { batch, ..self }
}
#[must_use]
pub fn with_ordinary(self, ordinary: ordinary::Options) -> Self {
Self { ordinary, ..self }
}
#[must_use]
pub fn with_cut(self, cut: cut::Options) -> Self {
Self { cut, ..self }
}
#[cfg(feature = "interactive")]
#[must_use]
pub fn with_interactive(self, interactive: interactive::Options) -> Self {
Self {
interactive,
..self
}
}
}