Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Quat3rnion committed Oct 27, 2024
1 parent d17e1ce commit 3b232ba
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

static DEFAULT_API_BIND: &str = "0.0.0.0:3001";

use poem::middleware::Cors;
use poem::{
listener::TcpListener,
middleware::{NormalizePath, TrailingSlash},
middleware::{Cors, NormalizePath, TrailingSlash},
web::Json,
EndpointExt, IntoResponse, Route, Server,
};
Expand Down
6 changes: 4 additions & 2 deletions src/api/routes/auth/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ use poem::{
};
use serde_json::json;

use crate::database::entities::{Config, Role, User};
use crate::gateway::ConnectedUsers;
use crate::{
database::entities::{Config, Role, User},
gateway::ConnectedUsers,
};

#[handler]
pub async fn register(
Expand Down
13 changes: 7 additions & 6 deletions src/api/routes/ping.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
use std::env;

use crate::database::entities::Config;
use chorus::types::{PingInstance, PingReturn};
use poem::{handler, web::Json, IntoResponse, Route};
use poem::web::Data;
use poem::{
handler,
web::{Data, Json},
IntoResponse, Route,
};
use serde::Serialize;
use crate::database::entities::Config;

pub fn setup_routes() -> Route {
Route::new().at("/ping", ping)
}

#[handler]
pub async fn ping(
Data(config): Data<&Config>
) -> poem::Result<impl IntoResponse> {
pub async fn ping(Data(config): Data<&Config>) -> poem::Result<impl IntoResponse> {
let ping_response = PingReturn {
ping: "pong!".to_string(),
instance: PingInstance {
Expand Down
3 changes: 1 addition & 2 deletions src/database/entities/relationship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use chorus::types::{PublicUser, Snowflake};
use serde::{Deserialize, Serialize};
use sqlx::PgPool;

use crate::errors::Error;
use crate::QUERY_UPPER_LIMIT;
use crate::{errors::Error, QUERY_UPPER_LIMIT};

use super::*;

Expand Down
3 changes: 1 addition & 2 deletions src/database/entities/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ use serde::{Deserialize, Serialize};
use sqlx::{PgPool, Row};
use sqlx_pg_uint::PgU64;

use crate::QUERY_UPPER_LIMIT;
use crate::{eq_shared_event_publisher, errors::Error, SharedEventPublisherMap};
use crate::{eq_shared_event_publisher, errors::Error, SharedEventPublisherMap, QUERY_UPPER_LIMIT};

#[derive(Debug, Clone, Serialize, Deserialize, sqlx::FromRow)]
pub struct Role {
Expand Down
7 changes: 4 additions & 3 deletions src/gateway/establish_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ use tokio_tungstenite::{
},
};

use crate::gateway::ready::create_ready;
use crate::gateway::Event;
use crate::{
database::entities::Config,
errors::{Error, GatewayError},
gateway::{gateway_task, heartbeat::HeartbeatHandler, GatewayPayload, GatewayUser},
gateway::{
gateway_task, heartbeat::HeartbeatHandler, ready::create_ready, Event, GatewayPayload,
GatewayUser,
},
util::token::check_token,
};

Expand Down
15 changes: 9 additions & 6 deletions src/gateway/gateway_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ use std::{sync::Arc, time::Duration};
use chorus::types::{GatewayHeartbeat, GatewaySendPayload, Opcode, Snowflake};
use futures::StreamExt;
use log::debug;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::{from_str, json};
use tokio::{sync::Mutex, time::sleep};
use tokio_tungstenite::tungstenite::protocol::frame::coding::CloseCode;
use tokio_tungstenite::tungstenite::{protocol::CloseFrame, Message};
use tokio_tungstenite::tungstenite::{
protocol::{frame::coding::CloseCode, CloseFrame},
Message,
};

use crate::errors::{Error, GatewayError};
use crate::gateway::{DispatchEvent, DispatchEventType};
use crate::{
errors::{Error, GatewayError},
gateway::{DispatchEvent, DispatchEventType},
};

use super::{ConnectedUsers, Event, GatewayClient, GatewayPayload};

Expand Down
6 changes: 4 additions & 2 deletions src/gateway/ready.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use chorus::types::{ClientInfo, GatewayReady, ReadState, Session, Snowflake, Use
use serde_json::json;
use sqlx::PgPool;

use crate::database::entities::{Channel, Guild, Note, Relationship};
use crate::{database::entities::User, errors::Error};
use crate::{
database::entities::{Channel, Guild, Note, Relationship, User},
errors::Error,
};

pub async fn create_ready(user_id: Snowflake, db: &PgPool) -> Result<GatewayReady, Error> {
let user = match User::get_by_id(db, user_id).await? {
Expand Down
8 changes: 5 additions & 3 deletions src/gateway/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub mod event;
pub use dispatchevent::*;
pub use event::*;

use std::fmt::Display;
use std::{
collections::{HashMap, HashSet},
fmt::Display,
ops::{Deref, DerefMut},
sync::{Arc, Weak},
};
Expand Down Expand Up @@ -48,8 +48,10 @@ use tokio_tungstenite::{
WebSocketStream,
};

use crate::errors::{Error, GatewayError};
use crate::{WebSocketReceive, WebSocketSend};
use crate::{
errors::{Error, GatewayError},
WebSocketReceive, WebSocketSend,
};

use super::ResumableClientsStore;

Expand Down

0 comments on commit 3b232ba

Please sign in to comment.