Expand description
Contains the data definition for feed schedule entry Defines the application-level representation of a single feed schedule entry.
This module provides the FeedScheduleEntry struct, which is a clean, type-safe
representation of a scheduled feeding event. Its primary role is to act as a
“hydrated” data model, converting raw data retrieved from the database into a
format that the application’s business logic can safely and easily work with.
§Key Components
-
FeedScheduleEntryStruct: The core data structure holding aNaiveDateTime, the associated feed profile ID and name, and a booleanrepeat_dailyflag. -
new()Constructor: A fallible constructor that takes a rawSqlFeedScheduleEntry(as defined insql_interface_feed) and performs the critical conversion of the string-based timestamp into achrono::NaiveDateTime. It also converts the numericrepeat_dailyflag into a proper boolean. -
fmt::DisplayImplementation: Provides a simple, human-readable string format for the struct, which is useful for logging and debugging purposes.
§Design and Architecture
This module serves as a crucial boundary between the database layer and the application’s core logic.
-
Data Hydration and Type Safety: The main purpose of this struct is to “hydrate” data from the database. By parsing the timestamp string into a
NaiveDateTimeat the earliest opportunity, the rest of the application is protected from handling raw strings and can leverage the powerful, type-safe operations provided by thechronocrate. This prevents a whole class of potential bugs related to malformed date strings. -
Robust Error Handling: The
new()constructor returns aResult, explicitly handling the possibility that the timestamp data in the database might be corrupt or in an unexpected format. This forces the calling code to deal with potential data integrity issues gracefully. -
Testability: The inclusion of a
#[cfg(test)]constructor,new_for_test, allows unit tests to create instances ofFeedScheduleEntryeasily without needing to construct a rawSqlFeedScheduleEntryfirst.
Structs§
- Feed
Schedule Entry - Holds the data of a feed schedule entry derived from data read from the database.