Struct SqlInterfaceData

Source
pub struct SqlInterfaceData {
    pub conn: PooledConn,
}
Expand description

Contains the configuration and the implementation of the SQL interface for time-based data.

Fields§

§conn: PooledConn

Connection to the database

Implementations§

Source§

impl SqlInterfaceData

Source

pub fn new( conn: PooledConn, max_rows_data: u64, ) -> Result<SqlInterfaceData, SqlInterfaceError>

Creates a new SqlInterfaceData instance.

This constructor initializes the time-based data SQL interface with an established database connection. It performs a pre-flight check to ensure the number of rows in the data table does not exceed the configured limit.

§Arguments
  • conn - An active, pooled database connection.
  • max_rows_data - The maximum allowed number of rows in the data table. If 0, the check is skipped.
§Returns

A Result containing a new SqlInterfaceData instance on success.

§Errors

This function will return an error if:

  • The initial database query to get the table row count fails (DatabaseCheckDataFailure).
  • The retrieved row count is a negative number, indicating a database issue (DatabaseDataTableNegativeValue).
  • The number of rows in the data table exceeds the configured max_rows_data limit (DatabaseDataTableContainsTooManyRows).
Source

pub fn write_data_frame_to_database( &mut self, data: &RecorderDataFrame, ) -> Result<(), SqlInterfaceError>

Writes a complete RecorderDataFrame to the SQL database.

This function processes all data points within the provided RecorderDataFrame. It intelligently handles optional (Option<f32>) and floating-point values (f32) by converting None, NaN (Not-a-Number), or infinite values into NULL for database insertion. Boolean options are similarly converted to NULL if None.

The data is inserted into the database. If a record with the same timestamp already exists, the existing record will be updated (this behavior depends on the underlying SQL query SQL_QUERY_WRITE_DATA using an ON DUPLICATE KEY UPDATE clause).

§Arguments
  • data - A reference to the RecorderDataFrame containing the data to be written.
§Returns

An empty Result (Ok(())) if the data frame was successfully inserted or updated in the database.

§Errors

Returns SqlInterfaceError::InsertDataFrameFailure if the database operation fails. This can be caused by a lost connection, constraint violations (e.g., foreign keys), incorrect data types, or a malformed SQL query. The original mysql::Error is included as the source for detailed debugging.

Trait Implementations§

Source§

impl Debug for SqlInterfaceData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Pingable for SqlInterfaceData

Source§

fn ping(&mut self)

Pings the database to check connection health and prevent timeouts.

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