PlanningEntity

Trait PlanningEntity 

Source
pub trait PlanningEntity:
    Send
    + Sync
    + Clone {
    // Required methods
    fn domain_class() -> DomainClass;
    fn planning_id(&self) -> Value;
    fn to_value(&self) -> Value;
    fn from_value(value: &Value) -> SolverForgeResult<Self>
       where Self: Sized;
}
Expand description

Marker trait for types that can be used as planning entities.

A planning entity is an object that can be changed during solving. It contains one or more planning variables that the solver assigns values to from their respective value ranges.

§Requirements

  • Must have a unique planning ID field
  • Must have at least one planning variable
  • Must be serializable to/from Value

§Derive Macro

This trait is typically implemented via #[derive(PlanningEntity)]:

#[derive(PlanningEntity)]
struct Lesson {
    #[planning_id]
    id: String,
    subject: String,
    #[planning_variable(value_range_provider = "timeslots")]
    timeslot: Option<Timeslot>,
}

Required Methods§

Source

fn domain_class() -> DomainClass

Returns the domain class descriptor for this entity type.

The domain class contains metadata about the entity’s fields, annotations, and planning variables.

Source

fn planning_id(&self) -> Value

Returns the planning ID for this instance.

The planning ID uniquely identifies this entity instance and is used for tracking during solving and for entity matching.

Source

fn to_value(&self) -> Value

Serializes this entity to a language-agnostic Value.

The resulting Value::Object contains all fields of the entity.

Source

fn from_value(value: &Value) -> SolverForgeResult<Self>
where Self: Sized,

Deserializes an entity from a Value.

Returns an error if the value cannot be converted to this entity type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§