Struct SqlInterfaceMidnightCalculator

Source
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: PooledConn

Connection to the database

Implementations§

Source§

impl SqlInterfaceMidnightCalculator

Source

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

Source§

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T