DBType

Enum DBType 

Source
pub enum DBType {
    PostgreSQL,
    MySQL,
    SQLite,
}
Expand description

Database type enumeration supporting major database systems

Variants§

§

PostgreSQL

PostgreSQL database

§

MySQL

MySQL database

§

SQLite

SQLite database

Implementations§

Source§

impl DBType

Source

pub fn new(db_name: &str) -> Result<Self, Error>

Creates a DBType instance from database name

§Arguments
  • db_name - Database identifier (“PostgreSQL”|“MySQL”|“SQLite”)
§Errors

Returns Error::Protocol for unsupported database types

§Example
let db_type = DBType::new("PostgreSQL")?;

Trait Implementations§

Source§

impl DatabaseDialect for DBType

Source§

fn get_encode_placeholder_fn(&self) -> Option<fn(usize, &mut String)>

Gets placeholder generation function for parameter binding

Database-specific placeholder formats:

  • PostgreSQL: $1, $2…
  • MySQL/SQLite: ?
§Returns

Option<fn(usize, &mut String)> placeholder generation function

Source§

fn write_count_sql(&self, sql: &mut String)

Wraps SQL in count query

§Arguments
  • sql - Original SQL to modify
Source§

fn write_page_sql<'c, 'q, DB>( &self, sql: &mut String, page_size: i64, page_no: i64, arg: &mut DB::Arguments<'q>, ) -> Result<(), Error>
where DB: Database, i64: Encode<'q, DB> + Type<DB>,

Generates pagination SQL clause

§Arguments
  • sql - Original SQL statement to modify
  • page_size - Items per page
  • page_no - Page number (auto-corrected to >=1)
  • arg - SQL arguments container
§Note

Automatically handles invalid page numbers

Source§

fn backend_name(&self) -> &str

Returns the name of the database backend in use (e.g. PostgreSQL, MySQL, SQLite, etc.)
Source§

impl Debug for DBType

Source§

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

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

impl PartialEq for DBType

Source§

fn eq(&self, other: &DBType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DBType

Auto Trait Implementations§

§

impl Freeze for DBType

§

impl RefUnwindSafe for DBType

§

impl Send for DBType

§

impl Sync for DBType

§

impl Unpin for DBType

§

impl UnwindSafe for DBType

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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