Skip to content

Commit 341d4f1

Browse files
committed
wip: fix some server-side compile errors
1 parent 3b7fe7d commit 341d4f1

File tree

14 files changed

+407
-223
lines changed

14 files changed

+407
-223
lines changed

Cargo.lock

Lines changed: 163 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ native_db = { git = "https://github.com/vincent-herlemont/native_db", features =
5252
] }
5353
native_model = "0.6.1"
5454
os_info = "3.8.2"
55+
passwords = { version = "3.1.16" }
5556
pem = "3.0.4"
5657
rand = "0.9.0"
5758
regex = "1.11.1"

sandpolis-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ serde = { workspace = true }
1212
tokio = { workspace = true }
1313
tokio-stream = { workspace = true }
1414
clap = { workspace = true }
15-
passwords = { version = "3.1.16", optional = true, features = [
15+
passwords = { workspace = true, optional = true, features = [
1616
"common-password",
1717
] }
1818
sandpolis-instance = { path = "../sandpolis-instance", version = "0.0.1" }

sandpolis-core/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use colored::Color;
33
use native_db::ToKey;
44
use regex::Regex;
55
use serde::{Deserialize, Serialize};
6-
use std::fmt::Display;
6+
use std::fmt::{Display, Write};
77
use std::ops::Deref;
88
use std::str::FromStr;
99
use strum::{EnumIter, IntoEnumIterator};
@@ -334,3 +334,19 @@ impl Default for UserName {
334334
UserName("admin".to_string())
335335
}
336336
}
337+
338+
impl Display for UserName {
339+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
340+
f.write_str(&self.0)
341+
}
342+
}
343+
344+
impl ToKey for UserName {
345+
fn to_key(&self) -> native_db::Key {
346+
native_db::Key::new(self.0.as_bytes().to_vec())
347+
}
348+
349+
fn key_names() -> Vec<String> {
350+
vec!["UserName".to_string()]
351+
}
352+
}

sandpolis-database/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ version = "0.0.1"
99
anyhow = { workspace = true }
1010
chrono = { workspace = true }
1111
clap = { workspace = true }
12+
futures = { workspace = true }
1213
native_db = { workspace = true }
1314
native_model = { workspace = true }
1415
rand = { workspace = true }

sandpolis-database/src/lib.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,12 @@ impl Default for DataRevision {
395395

396396
impl ToKey for DataRevision {
397397
fn to_key(&self) -> native_db::Key {
398-
native_db::Key::new(
399-
match self {
400-
DataRevision::Latest(v) => *v,
401-
// Previous values are stored as negative so we can tell the difference
402-
DataRevision::Previous(v) => -v,
403-
}
404-
.to_be_bytes()
405-
.to_vec(),
406-
)
398+
match self {
399+
DataRevision::Latest(v) => *v,
400+
// Previous values are stored as negative so we can tell the difference
401+
DataRevision::Previous(v) => -v,
402+
}
403+
.to_key()
407404
}
408405

409406
fn key_names() -> Vec<String> {
@@ -428,7 +425,7 @@ impl Default for DataExpiration {
428425

429426
impl ToKey for DataExpiration {
430427
fn to_key(&self) -> native_db::Key {
431-
native_db::Key::new(self.0.timestamp_millis().to_be_bytes().to_vec())
428+
self.0.timestamp_millis().to_key()
432429
}
433430

434431
fn key_names() -> Vec<String> {
@@ -457,7 +454,7 @@ impl Default for DataCreation {
457454

458455
impl ToKey for DataCreation {
459456
fn to_key(&self) -> native_db::Key {
460-
native_db::Key::new(self.0.timestamp_millis().to_be_bytes().to_vec())
457+
self.0.timestamp_millis().to_key()
461458
}
462459

463460
fn key_names() -> Vec<String> {
@@ -650,7 +647,7 @@ mod test_resident {
650647
#[tokio::test]
651648
#[test_log::test]
652649
async fn test_temporal_data() -> Result<()> {
653-
let database = test_db!(TestData);
650+
let database = test_db!(TestHistoryData);
654651

655652
let db = database.realm(RealmName::default()).await?;
656653
let res: Resident<TestHistoryData> = db.resident(())?;
@@ -673,8 +670,6 @@ mod test_resident {
673670

674671
// Check history
675672
{
676-
trace!("{:?}", DataCreation::all().start_bound());
677-
trace!("{:?}", DataCreation::all().end_bound());
678673
assert_eq!(res.history(DataCreation::all()).await?.len(), 10);
679674
}
680675

@@ -790,6 +785,10 @@ impl<T: Data> ResidentVec<T> {
790785
pub async fn iter(&self) -> IntoValues<DataIdentifier, Resident<T>> {
791786
self.inner.read().await.clone().into_values()
792787
}
788+
789+
pub async fn stream(&self) -> futures::stream::Iter<IntoValues<DataIdentifier, Resident<T>>> {
790+
futures::stream::iter(self.inner.read().await.clone().into_values())
791+
}
793792
}
794793

795794
#[derive(Clone)]

sandpolis-mobile/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ pub fn main() {
2222
config.clone(),
2323
DatabaseLayer::new(config.database.clone(), &*sandpolis::MODELS).unwrap(),
2424
)
25-
.await?;
25+
.await
26+
.unwrap();
2627

2728
sandpolis::client::gui::main(config, state).await.unwrap();
2829
});

sandpolis-network/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ axum = { workspace = true }
1212
chrono = { workspace = true }
1313
clap = { workspace = true }
1414
futures = { workspace = true }
15+
futures-util = { workspace = true }
1516
native_db = { workspace = true }
1617
native_model = { workspace = true }
1718
reqwest-websocket = { workspace = true }
@@ -27,6 +28,7 @@ serde_with = { workspace = true }
2728
serde = { workspace = true }
2829
tokio = { workspace = true }
2930
tracing = { workspace = true }
31+
validator = { workspace = true }
3032

3133
[features]
3234
agent = []

sandpolis-network/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::anyhow;
33
use anyhow::bail;
44
use chrono::{DateTime, Utc};
55
use config::NetworkLayerConfig;
6-
use futures::StreamExt;
6+
use futures_util::StreamExt;
77
use messages::PingRequest;
88
use messages::PingResponse;
99
use native_db::ToKey;
@@ -19,7 +19,6 @@ use sandpolis_realm::RealmLayer;
1919
use serde::{Deserialize, Serialize};
2020
use serde_with::chrono::serde::{ts_seconds, ts_seconds_option};
2121
use std::fmt::Display;
22-
use std::fmt::Write;
2322
use std::net::ToSocketAddrs;
2423
use std::str::FromStr;
2524
use std::{cmp::min, net::SocketAddr, sync::Arc, time::Duration};

sandpolis-user/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ version = "0.0.1"
99
anyhow = { workspace = true }
1010
serde = { workspace = true }
1111
base64 = { workspace = true }
12+
futures = { workspace = true }
1213
rand = { workspace = true }
1314
native_db = { workspace = true }
1415
native_model = { workspace = true }
16+
passwords = { workspace = true, optional = true, features = [
17+
"common-password",
18+
] }
1519
ring = { workspace = true }
1620
axum = { workspace = true }
1721
axum-macros = { workspace = true }
@@ -39,5 +43,6 @@ server = [
3943
"dep:argon2",
4044
"dep:jsonwebtoken",
4145
"dep:sandpolis-server",
46+
"dep:passwords",
4247
]
4348
client = ["dep:totp-rs", "totp-rs?/qr", "dep:argon2"]

0 commit comments

Comments
 (0)