46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
extern crate serde;
|
|
pub mod member;
|
|
pub mod common;
|
|
pub mod invites;
|
|
pub mod channels;
|
|
pub mod messages;
|
|
pub mod auth;
|
|
|
|
use std::vec::Vec;
|
|
|
|
pub type BigInt = i64;
|
|
pub type UBigInt = u64;
|
|
|
|
pub type Integer = i32;
|
|
pub type UInteger = u32;
|
|
|
|
pub type VarChar = String;
|
|
|
|
pub enum Response<T> {
|
|
// A set of rows collected
|
|
Set(Vec<T>),
|
|
// Single row collected
|
|
Row(T),
|
|
// Nothing was found -> for select/update/delete's
|
|
Empty,
|
|
// Generic success for things like update/delete's
|
|
Success,
|
|
// Mask 500's with probable user generated errors like duplicate keys being added
|
|
// or data that doesn't fit in column or something
|
|
RestrictedInput(String),
|
|
// Not sure what this will be used for but maybe its useful at some point
|
|
Other(String)
|
|
}
|
|
|
|
|
|
#[macro_export]
|
|
macro_rules! fetch_row {
|
|
($table:literal, $col:literal, $key:expr, $rtype:ty,$conn:expr) => {
|
|
let lib_str = format!("SELECT * FROM {} WHERE {} = :{}", $table, $col, $col);
|
|
let (_, $rtype) = $conn.first_exec!(lib_str, sql_params{
|
|
$col => $key,
|
|
});
|
|
}
|
|
}
|
|
|