freechat/json-api/db/src/lib.rs
shockrah 988aa9f155 Removal of chrono and async_trait as dependancy in db-lib
Removig chrono from api code as well

Removing chrono as dep in api code
+ Using Content-Type for /message/send content type

Updating cargo lists for removal of fluff deps

Removal of more fluff

Addking makefile to avoid compiling debug builds by accident while developing
2021-03-20 14:59:06 -07:00

85 lines
1.7 KiB
Rust

use serde::Serialize;
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;
#[derive(Debug)]
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)
}
#[allow(dead_code)]
#[derive(Serialize)]
pub struct Message {
pub id: UBigInt,
pub time: BigInt,
pub content: VarChar,
pub content_type: VarChar,
pub author_id: UBigInt,
pub channel_id: UBigInt
}
#[derive(Debug, Serialize)]
pub struct UserMessage {
pub id: UBigInt,
pub time: BigInt,
pub content: VarChar,
pub content_type: VarChar,
pub author_id: UBigInt,
pub channel_id: UBigInt,
pub name: VarChar
}
#[derive(Serialize)]
pub struct Channel {
pub id: UBigInt,
pub name: VarChar,
pub description: Option<VarChar>,
pub kind: Integer
}
#[derive(Serialize, Debug)]
pub struct Invite {
pub id: BigInt,
pub uses: Option<BigInt>,
pub expires: bool
}
#[derive(Debug, Serialize)]
pub struct Member {
pub id: UBigInt,
pub secret: VarChar,
pub name: VarChar,
pub status: Integer,
pub permissions: UBigInt,
}