solverforge_core/
lib.rs

1//! SolverForge Core - Language-agnostic constraint solver library
2//!
3//! This crate provides the core functionality for SolverForge, a Rust-based
4//! constraint solver library that uses WASM modules and HTTP communication
5//! to solve constraint satisfaction and optimization problems by acting as a
6//! bridge towards the Timefold JVM.
7//!
8//! # Architecture
9//!
10//! SolverForge is designed with a layered architecture:
11//!
12//! 1. **Core Types** (this crate) - Language-agnostic types and abstractions
13//! 2. **Language Bindings** - Language-specific implementations (Python, JS, etc.)
14//! 3. **Solver Service** - HTTP service that executes the solving
15//!
16//! # Key Components
17//!
18//! - [`Value`] - Language-agnostic value representation
19//! - [`ObjectHandle`] / [`FunctionHandle`] - Opaque handles to host language objects
20//! - [`SolverForgeError`] / [`SolverForgeResult`] - Error handling types
21//!
22//! # Example
23//!
24//! ```
25//! use solverforge_core::{Value, ObjectHandle, FunctionHandle};
26//!
27//! // Create values
28//! let int_val = Value::from(42i64);
29//! let str_val = Value::from("hello");
30//!
31//! // Create handles
32//! let obj_handle = ObjectHandle::new(1);
33//! let func_handle = FunctionHandle::new(2);
34//!
35//! // Use in a map
36//! use std::collections::HashMap;
37//! let mut map = HashMap::new();
38//! map.insert(obj_handle, "object 1");
39//! ```
40
41pub mod analysis;
42mod bridge;
43pub mod constraints;
44pub mod domain;
45pub mod entity_context;
46mod error;
47mod handles;
48pub mod score;
49pub mod solver;
50mod traits;
51mod value;
52pub mod wasm;
53
54pub use analysis::{ConstraintMatch, Indictment, ScoreExplanation, SolutionManager};
55pub use bridge::{ClassInfo, FieldInfo, LanguageBridge};
56pub use constraints::{
57    Collector, Constraint, ConstraintSet, IntoNamedExpression, Joiner, NamedExpression,
58    StreamComponent, WasmFunction,
59};
60pub use domain::{
61    ConstraintConfiguration, ConstraintWeight, DeepPlanningClone, DefaultVariableListenerContext,
62    ListVariableListener, ListenerCallbackDto, PlanningAnnotation, ShadowAnnotation,
63    SourceVariableRef, VariableListener, VariableListenerContext, VariableListenerRegistration,
64};
65pub use error::{SolverForgeError, SolverForgeResult};
66pub use handles::{FunctionHandle, ObjectHandle};
67pub use score::{
68    BendableDecimalScore, BendableScore, HardMediumSoftDecimalScore, HardMediumSoftScore,
69    HardSoftDecimalScore, HardSoftScore, Score, SimpleDecimalScore, SimpleScore,
70};
71pub use solver::{
72    AsyncSolveResponse, ChangeConsumer, ClassAnnotation, DefaultProblemChangeDirector,
73    DiminishedReturnsConfig, DomainAccessor, DomainObjectDto, DomainObjectMapper, EnvironmentMode,
74    FieldDescriptor, HttpSolverService, ListAccessorDto, MoveThreadCount, ProblemChange,
75    ProblemChangeDirector, ProblemChangeDto, ProblemChangeError, ScoreDto, SolveHandle,
76    SolveRequest, SolveResponse, SolveState, SolveStatus, Solver, SolverBuilder, SolverConfig,
77    SolverFactory, SolverManager, SolverService, SolverStats, TerminationConfig, TypedSolver,
78    DEFAULT_SERVICE_URL,
79};
80pub use traits::{DomainStruct, PlanningEntity, PlanningSolution};
81pub use value::Value;
82pub use wasm::{
83    Expr, Expression, FieldAccessExt, FieldLayout, LayoutCalculator, MemoryLayout,
84    PredicateDefinition, WasmMemoryType, WasmModuleBuilder,
85};