pub struct TimeHandler;Expand description
Time validation handler
Validates and canonicalizes time values. Supports multiple input formats:
- Single or double-digit hours: 0, 1, 01, 23 (converted to HH00 format)
- HH:MM format: Standard time with colon separator (e.g., “14:30”)
- HHMM format: Compact time without separator (e.g., “1430”)
All valid inputs are canonicalized to HHMM format (4-digit string) for consistent representation in topics and storage systems.
Implementations§
Source§impl TimeHandler
impl TimeHandler
Sourcepub fn validate_and_canonicalize(
value: &str,
field_name: &str,
) -> Result<String>
pub fn validate_and_canonicalize( value: &str, field_name: &str, ) -> Result<String>
Validate and canonicalize a time value to HHMM format
This method handles multiple time input formats and converts them to the standard HHMM format used throughout the system:
§Supported Input Formats
- Single or double-digit hours: “0”, “1”, “01”, “23” → “0000”, “0100”, “0100”, “2300”
- HH:MM format: “14:30” → “1430”, “9:15” → “0915”
- HHMM format: “1430” → “1430” (validated and normalized)
§Arguments
value- The time string to validate (in any supported format)field_name- Name of the field being validated (for error messages)
§Returns
Ok(String)- The time in canonical HHMM formatErr(anyhow::Error)- Invalid time format or impossible time
§Time Validation Rules
- Hours must be 0-23 (24-hour format)
- Minutes must be 0-59
- Leading zeros are added as needed for consistent 4-digit format
Auto Trait Implementations§
impl Freeze for TimeHandler
impl RefUnwindSafe for TimeHandler
impl Send for TimeHandler
impl Sync for TimeHandler
impl Unpin for TimeHandler
impl UnsafeUnpin for TimeHandler
impl UnwindSafe for TimeHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more