pub struct ScheduleEntry {
schedule_type: ScheduleType,
start_time: NaiveTime,
stop_time: NaiveTime,
is_active: bool,
}Expand description
Contains one schedule data set after post-processing
Fields§
§schedule_type: ScheduleTypeSchedule type (either Balling, Refill, Ventilation or Heating)
start_time: NaiveTimeTime of day from which on the control shall be active
stop_time: NaiveTimeTime of day from which on the control shall not be active
is_active: boolFlag describing if the schedule entry is active
Implementations§
Source§impl ScheduleEntry
impl ScheduleEntry
Sourcepub fn new(
sql_schedule_entry: SqlScheduleEntry,
) -> Result<ScheduleEntry, SqlInterfaceError>
pub fn new( sql_schedule_entry: SqlScheduleEntry, ) -> Result<ScheduleEntry, SqlInterfaceError>
Creates a new ScheduleEntry by converting raw data from an SqlScheduleEntry.
This constructor takes a SqlScheduleEntry (typically read from the database)
and performs necessary type conversions, such as transforming string representations
of the schedule type and times into their respective Rust types.
§Arguments
sql_schedule_entry- A struct containing the raw schedule data from the SQL database.
§Returns
A Result containing a new, fully typed ScheduleEntry on success.
§Errors
This function will return an Err variant of SqlInterfaceError if:
- The
schedule_typestring cannot be parsed into a validScheduleTypeenum (ScheduleTypeConversionFailure).
Sourcepub fn check_if_allowed(&self) -> bool
pub fn check_if_allowed(&self) -> bool
Determines if the current local time falls within the allowed time window of this schedule entry.
This function compares the system’s current local time (Local::now().time())
against the start_time and stop_time defined in this ScheduleEntry.
§Returns
true: If the current local time is on or afterstart_timeAND on or beforestop_time.false: Given an active schedule limitation: If the current local time is outside this inclusive window.