pub struct SqlInterfaceMidnightCalculator {
pub conn: PooledConn,
}Expand description
Struct holds connection data to the SQL database and provides implementation for calculating the time in seconds until midnight.
Fields§
§conn: PooledConnConnection to the database
Implementations§
Source§impl SqlInterfaceMidnightCalculator
impl SqlInterfaceMidnightCalculator
Sourcepub fn new(conn: PooledConn) -> SqlInterfaceMidnightCalculator
pub fn new(conn: PooledConn) -> SqlInterfaceMidnightCalculator
Creates a new SqlInterfaceMidnightCalculator instance.
This constructor initializes the calculator with an established database connection, which it uses to perform time-related queries, such as determining time until midnight.
§Arguments
conn- An active database connection pool object.
§Returns
A new SqlInterfaceMidnightCalculator struct.
Trait Implementations§
Source§impl SqlInterfaceMidnightCalculatorTrait for SqlInterfaceMidnightCalculator
impl SqlInterfaceMidnightCalculatorTrait for SqlInterfaceMidnightCalculator
Source§fn get_duration_until_midnight(&mut self) -> Result<i64, SqlInterfaceError>
fn get_duration_until_midnight(&mut self) -> Result<i64, SqlInterfaceError>
Queries the database to determine the number of seconds remaining until the next midnight.
This function executes a standard SQL query to retrieve a precise count of seconds from the current database time until 00:00:00 of the upcoming day.
§Returns
A Result containing the number of seconds (as an i64) remaining until midnight on success.
§Errors
This function will return an Err variant of SqlInterfaceError if the underlying
call to get_single_integer_from_database fails. This can happen if:
- The database connection is lost or invalid.
- The SQL query fails to execute for other reasons (e.g., syntax error, permissions).
- The query does not return exactly one row and one column containing an integer.