criterium 3.1.3

Lightweigt dynamic database queries for rusqlite.
Documentation
// SPDX-FileCopyrightText: 2025 Slatian
//
// SPDX-License-Identifier: LGPL-3.0-only

use std::fmt::Debug;

use crate::sql::Prefix;

/// Trait for datatructures representing Tables.
///
/// Criterium recommends that you represent your tables using enums, so that relevant metadata is available everywhere the table is used and to make it possible for the compiler to check for mistakes.
pub trait Table: Debug + Clone + PartialEq + Eq {
	/// Returns an sql safe name that can be used without quoting.
	///
	/// Stick to `A`-`Z`, `a`-`z`, `0`-`9` and `_` here.
	fn sql_safe_table_name(&self) -> &str;

	/// Constructs the prefixed table alias that criterium uses to generate unique names when possibly dealing with joining the same table multiple times for different purposes.
	fn sql_safe_prefixed_table_name(&self, prefix: &Prefix) -> String {
		format!("{}{}", prefix, self.sql_safe_table_name())
	}
}