Run rust fmt.

This commit is contained in:
Paul Makles
2020-04-06 13:07:05 +01:00
parent 8e908ce105
commit ec1e91aee1
16 changed files with 1094 additions and 1025 deletions

View File

@@ -1,18 +1,18 @@
use serde::{ Deserialize, Serialize };
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Channel {
#[serde(rename = "_id")]
pub id: String,
#[serde(rename = "type")]
pub channel_type: u8,
pub channel_type: u8,
pub last_message: Option<String>,
// for Direct Messages
pub recipients: Option<Vec<String>>,
pub last_message: Option<String>,
// for Direct Messages
pub recipients: Option<Vec<String>>,
pub active: Option<bool>,
// for Guilds
pub name: Option<String>,

View File

@@ -1,4 +1,4 @@
use serde::{ Deserialize, Serialize };
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Member {
@@ -16,7 +16,7 @@ pub struct Invite {
pub struct Guild {
#[serde(rename = "_id")]
pub id: String,
// pub nonce: String, used internally
// pub nonce: String, used internally
pub name: String,
pub description: String,
pub owner: String,

View File

@@ -1,5 +1,5 @@
use serde::{ Deserialize, Serialize };
use bson::{ UtcDateTime };
use bson::UtcDateTime;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct PreviousEntry {
@@ -10,13 +10,13 @@ pub struct PreviousEntry {
#[derive(Serialize, Deserialize, Debug)]
pub struct Message {
#[serde(rename = "_id")]
pub id: String,
// pub nonce: String, used internally
pub channel: String,
pub author: String,
pub id: String,
// pub nonce: String, used internally
pub channel: String,
pub author: String,
pub content: String,
pub content: String,
pub edited: Option<UtcDateTime>,
pub previous_content: Option<Vec<PreviousEntry>>
pub previous_content: Option<Vec<PreviousEntry>>,
}

View File

@@ -1,30 +1,30 @@
use mongodb::{ Client, Collection, Database };
use mongodb::{Client, Collection, Database};
use std::env;
use once_cell::sync::OnceCell;
static DBCONN: OnceCell<Client> = OnceCell::new();
pub fn connect() {
let client = Client::with_uri_str(
&env::var("DB_URI").expect("DB_URI not in environment variables!"))
.expect("Failed to init db connection.");
let client =
Client::with_uri_str(&env::var("DB_URI").expect("DB_URI not in environment variables!"))
.expect("Failed to init db connection.");
DBCONN.set(client).unwrap();
DBCONN.set(client).unwrap();
}
pub fn get_connection() -> &'static Client {
DBCONN.get().unwrap()
DBCONN.get().unwrap()
}
pub fn get_db() -> Database {
get_connection().database("revolt")
get_connection().database("revolt")
}
pub fn get_collection(collection: &str) -> Collection {
get_db().collection(collection)
get_db().collection(collection)
}
pub mod user;
pub mod channel;
pub mod message;
pub mod guild;
pub mod message;
pub mod user;

View File

@@ -1,19 +1,19 @@
use serde::{ Deserialize, Serialize };
use bson::UtcDateTime;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct UserEmailVerification {
pub verified: bool,
pub target: Option<String>,
pub expiry: Option<UtcDateTime>,
pub rate_limit: Option<UtcDateTime>,
pub code: Option<String>,
pub verified: bool,
pub target: Option<String>,
pub expiry: Option<UtcDateTime>,
pub rate_limit: Option<UtcDateTime>,
pub code: Option<String>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct UserRelationship {
pub id: String,
pub status: u8,
pub id: String,
pub status: u8,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -21,9 +21,9 @@ pub struct User {
#[serde(rename = "_id")]
pub id: String,
pub email: String,
pub username: String,
pub password: String,
pub access_token: Option<String>,
pub email_verification: UserEmailVerification,
pub relations: Option<Vec<UserRelationship>>,
pub username: String,
pub password: String,
pub access_token: Option<String>,
pub email_verification: UserEmailVerification,
pub relations: Option<Vec<UserRelationship>>,
}