sqlx/sqlx-core/src/column.rs
Ryan Leckey 8d188c5f1a feat: expose column information on Row
- add database-specific Column types: MySqlColumn, PgColumn, etc.
 - add Row::columns() -> &[DB::Column]
 - add Row::column(I) and Row::try_column(I)
2020-07-05 03:48:36 -07:00

27 lines
825 B
Rust

use crate::database::Database;
use std::fmt::Debug;
pub trait Column: private_column::Sealed + 'static + Send + Sync + Debug {
type Database: Database;
/// Gets the column ordinal.
///
/// This can be used to unambiguously refer to this column within a row in case more than
/// one column have the same name
fn ordinal(&self) -> usize;
/// Gets the column name or alias.
///
/// The column name is unreliable (and can change between database minor versions) if this
/// column is an expression that has not been aliased.
fn name(&self) -> &str;
/// Gets the type information for the column.
fn type_info(&self) -> &<Self::Database as Database>::TypeInfo;
}
// Prevent users from implementing the `Row` trait.
pub(crate) mod private_column {
pub trait Sealed {}
}