Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBloom committed Oct 15, 2023
1 parent 52a27ff commit 04ca9fb
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion squire_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{env, process::Command};

fn main() -> Result<(), i32> {
if env::var("CARGO_FEATURE_IGNORE_FRONTEND").is_ok() {
return Ok(())
return Ok(());
}

let wd = env::var("CARGO_MANIFEST_DIR").unwrap();
Expand Down
5 changes: 4 additions & 1 deletion squire_core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ pub fn create_router(state: AppState) -> Router {
.add_route::<0, POST, Reauth, _, _>(reauth)
.add_route::<0, DELETE, Terminate, _, _>(terminate)
.into_router()
.route("/api/v1/tournaments/subscribe/other/:t_id", get(tournaments::join_gathering))
.route(
"/api/v1/tournaments/subscribe/other/:t_id",
get(tournaments::join_gathering),
)
.route("/", get(assets::landing))
.route("/squire_web_bg.wasm", get(assets::get_wasm))
.route("/squire_web.js", get(assets::get_js))
Expand Down
7 changes: 5 additions & 2 deletions squire_core/src/state/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ impl Trackable<AnyUser, SessionToken> for SessionCommand {
}

impl Trackable<SessionToken, Option<watch::Receiver<SquireSession>>> for SessionCommand {
fn track(msg: SessionToken, send: OneshotSender<Option<watch::Receiver<SquireSession>>>) -> Self {
fn track(
msg: SessionToken,
send: OneshotSender<Option<watch::Receiver<SquireSession>>>,
) -> Self {
Self::Subscribe(msg, send)
}
}
Expand All @@ -48,7 +51,7 @@ impl Trackable<AnyUser, bool> for SessionCommand {

impl Debug for SessionCommand {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self{
match self {
Self::Create(value, _) => write!(f, "Create({value:?})"),
Self::Guest(_) => write!(f, "Guest()"),
Self::Get(value, _) => write!(f, "Get({value:?})"),
Expand Down
9 changes: 5 additions & 4 deletions squire_core/src/state/tournaments.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::{sync::Arc, ops::Range};
use std::{ops::Range, sync::Arc};

use futures::StreamExt;
use mongodb::{
bson::{doc, spec::BinarySubtype, Binary, Document},
Collection, Database, options::{UpdateModifications, UpdateOptions, Hint, FindOptions},
options::{FindOptions, Hint, UpdateModifications, UpdateOptions},
Collection, Database,
};
use squire_sdk::{
actor::*, model::tournament::TournamentId, server::gathering::PersistMessage,
sync::TournamentManager, api::TournamentSummary,
actor::*, api::TournamentSummary, model::tournament::TournamentId,
server::gathering::PersistMessage, sync::TournamentManager,
};
use tracing::Level;

Expand Down
30 changes: 25 additions & 5 deletions squire_sdk/src/client/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ impl<UP: OnUpdate> ClientBuilder<UP, String, ()> {
let user = state.subscribe();
let client = ActorBuilder::new(state).launch();
let tourns = TournsClient::new(client.clone(), on_update);
Ok(SquireClient { client, tourns, user })
Ok(SquireClient {
client,
tourns,
user,
})
}

/// Creates a client but does not check if the URL is valid.
Expand All @@ -99,7 +103,11 @@ impl<UP: OnUpdate> ClientBuilder<UP, String, ()> {
let user = state.subscribe();
let client = ActorBuilder::new(state).launch();
let tourns = TournsClient::new(client.clone(), on_update);
SquireClient { client, tourns, user }
SquireClient {
client,
tourns,
user,
}
}
}

Expand All @@ -112,7 +120,11 @@ impl<UP: OnUpdate> ClientBuilder<UP, String, Credentials> {
let user = state.subscribe();
let client = ActorBuilder::new(state).launch();
let tourns = TournsClient::new(client.clone(), on_update);
Ok(SquireClient { client, tourns, user })
Ok(SquireClient {
client,
tourns,
user,
})
}
}

Expand All @@ -129,7 +141,11 @@ impl<UP: OnUpdate> ClientBuilder<UP, String, SquireAccount> {
let user = state.subscribe();
let client = ActorBuilder::new(state).launch();
let tourns = TournsClient::new(client.clone(), on_update);
Ok(SquireClient { client, tourns, user })
Ok(SquireClient {
client,
tourns,
user,
})
}

/// Creates a client but does not check if the URL is valid.
Expand All @@ -143,6 +159,10 @@ impl<UP: OnUpdate> ClientBuilder<UP, String, SquireAccount> {
let user = state.subscribe();
let client = ActorBuilder::new(state).launch();
let tourns = TournsClient::new(client.clone(), on_update);
SquireClient { client, tourns, user }
SquireClient {
client,
tourns,
user,
}
}
}
6 changes: 5 additions & 1 deletion squire_sdk/src/compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
//!
//! By no means is this an exhuastive or future-proof module. Rather, the module just implements
//! wrappers for functionalities that are presently needed.
use std::{pin::Pin, fmt::Debug, task::{Context, Poll}};
use std::{
fmt::Debug,
pin::Pin,
task::{Context, Poll},
};

use futures::{Future, FutureExt};

Expand Down
4 changes: 2 additions & 2 deletions squire_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ pub mod client;
/// The default client used by non-squire_core services to communicate with squire_core
pub mod server;

/// Contains the definition of the actor model used by both the client and server
pub mod actor;
/// Contains all of the API definitions
pub mod api;
/// The primary generic response type
pub mod response;
/// Contains all of the components needed for client-server synchronization
pub mod sync;
/// Contains the definition of the actor model used by both the client and server
pub mod actor;

/// A compatability layer to enable use in both native and WASM platforms
pub mod compat;
2 changes: 1 addition & 1 deletion squire_sdk/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use axum::{
body::{Body, HttpBody},
extract::State,
handler::Handler,
Router
Router,
};

use self::state::ServerState;
Expand Down
4 changes: 2 additions & 2 deletions squire_sdk/src/server/state.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::ops::Range;

use async_trait::async_trait;
use axum::extract::ws::WebSocket;
use squire_lib::identifiers::SquireAccountId;

use axum::extract::ws::WebSocket;
use super::session::{AnyUser, SquireSession, SessionWatcher};
use super::session::{AnyUser, SessionWatcher, SquireSession};
use crate::{
api::{SessionToken, TournamentSummary, Version},
model::tournament::TournamentId,
Expand Down
3 changes: 2 additions & 1 deletion squire_web/src/tournament/overview/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::time::Duration;

use squire_sdk::{
compat::sleep,
model::{
identifiers::TournamentId, players::PlayerStatus, rounds::RoundStatus,
tournament::TournamentStatus,
},
sync::TournamentManager, compat::sleep,
sync::TournamentManager,
};
use yew::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion squire_web/src/tournament/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ impl SettingsView {
.get()
.unwrap()
.query_tourn(id, |tourn| tourn.settings())

.await
.unwrap_or_else(TournamentSettingsTree::new);
SettingsMessage::QueryReady(Box::new(settings))
Expand Down

0 comments on commit 04ca9fb

Please sign in to comment.