Skip to main content

twine_observers/
lib.rs

1//! Reusable observers for the Twine framework.
2//!
3//! This crate provides [`Observer`] implementations and capability traits that
4//! work across different solvers in the Twine ecosystem.
5//!
6//! # Crate position in the dependency graph
7//!
8//! `twine-observers` sits at the top of the stack:
9//!
10//! ```text
11//! twine-core  ←  twine-solvers  ←  twine-observers
12//! ```
13//!
14//! This is intentional. Observers know about solvers — they implement capability
15//! traits (see [`traits`]) for the concrete event and action types that solvers
16//! expose. Solvers know nothing about observers. Removing this crate leaves
17//! `twine-solvers` entirely unaffected.
18//!
19//! # Modules
20//!
21//! - [`traits`] — Capability traits for cross-solver observers
22//!   ([`HasResidual`], [`HasObjective`], [`CanStopEarly`], [`CanAssumeWorse`])
23//!
24//! # Features
25//!
26#![cfg_attr(
27    feature = "plot",
28    doc = "- `plot` — Enables [`PlotObserver`] and [`ShowConfig`] for visualizing solver \
29           behavior via egui. This feature adds dependencies on `eframe` and `egui_plot`."
30)]
31#![cfg_attr(
32    not(feature = "plot"),
33    doc = "- `plot` — Enables `PlotObserver` and `ShowConfig` for visualizing solver \
34           behavior via egui. This feature adds dependencies on `eframe` and `egui_plot`."
35)]
36//!
37//! [`Observer`]: twine_core::Observer
38//! [`HasResidual`]: traits::HasResidual
39//! [`HasObjective`]: traits::HasObjective
40//! [`CanStopEarly`]: traits::CanStopEarly
41//! [`CanAssumeWorse`]: traits::CanAssumeWorse
42
43pub mod traits;
44
45#[cfg(feature = "plot")]
46mod plot;
47
48#[cfg(feature = "plot")]
49pub use plot::{PlotObserver, ShowConfig};