Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

style: apply rustfmt formatting to device and document store code

Steven Enamakel4300be3166de
diff --git a/crates/openhuman-core/src/security/devices/mod.rs b/crates/openhuman-core/src/security/devices/mod.rs
index 4f4f3b977e..e9127e206a 100644
--- a/crates/openhuman-core/src/security/devices/mod.rs
+++ b/crates/openhuman-core/src/security/devices/mod.rs
@@ -8,6 +8,7 @@ pub mod crypto;
pub mod rpc;
pub mod schemas;
pub mod store;
+mod store_documents;
pub mod tunnel_client;
pub mod types;
diff --git a/crates/openhuman-core/src/security/devices/store_documents.rs b/crates/openhuman-core/src/security/devices/store_documents.rs
index 05cee945b0..eae07023a7 100644
--- a/crates/openhuman-core/src/security/devices/store_documents.rs
+++ b/crates/openhuman-core/src/security/devices/store_documents.rs
@@ -71,7 +71,9 @@ impl Docs {
"revoked": false,
});
self.0.run(|docs| async move {
- let version = docs.put(DEVICES, &id, doc.clone(), Precondition::None).await?;
+ let version = docs
+ .put(DEVICES, &id, doc.clone(), Precondition::None)
+ .await?;
Ok(to_device(&Versioned { id, version, doc }))
})
}
@@ -110,9 +112,8 @@ impl Docs {
pub(super) fn get_device(&self, channel_id: &str) -> Result<Option<PairedDevice>> {
let id = channel_id.to_string();
- self.0.run(|docs| async move {
- Ok(docs.get(DEVICES, &id).await?.as_ref().map(to_device))
- })
+ self.0
+ .run(|docs| async move { Ok(docs.get(DEVICES, &id).await?.as_ref().map(to_device)) })
}
pub(super) fn list_devices(&self) -> Result<Vec<PairedDevice>> {
diff --git a/crates/openhuman-core/src/security/devices/store_documents_tests.rs b/crates/openhuman-core/src/security/devices/store_documents_tests.rs
index 33843f4603..db486efcb8 100644
--- a/crates/openhuman-core/src/security/devices/store_documents_tests.rs
+++ b/crates/openhuman-core/src/security/devices/store_documents_tests.rs
@@ -42,8 +42,18 @@ fn touch_marks_live_devices_only() {
store.touch_device("live").unwrap();
store.touch_device("gone").unwrap();
store.touch_device("missing").unwrap();
- assert!(store.get_device("live").unwrap().unwrap().last_seen_at.is_some());
- assert!(store.get_device("gone").unwrap().unwrap().last_seen_at.is_none());
+ assert!(store
+ .get_device("live")
+ .unwrap()
+ .unwrap()
+ .last_seen_at
+ .is_some());
+ assert!(store
+ .get_device("gone")
+ .unwrap()
+ .unwrap()
+ .last_seen_at
+ .is_none());
}
#[test]
diff --git a/crates/openhuman-core/src/storage/documents_tests.rs b/crates/openhuman-core/src/storage/documents_tests.rs
index 7f19872486..25e8c2b401 100644
--- a/crates/openhuman-core/src/storage/documents_tests.rs
+++ b/crates/openhuman-core/src/storage/documents_tests.rs
@@ -20,9 +20,14 @@ fn run_declares_the_collections_and_returns_the_result() {
let storage = MemoryStorage::new();
let repo = repo(&storage, "local");
repo.run(|docs| async move {
- docs.put(THINGS, "a", json!({ "state": "open" }), Precondition::Absent)
- .await
- .map(|_| ())
+ docs.put(
+ THINGS,
+ "a",
+ json!({ "state": "open" }),
+ Precondition::Absent,
+ )
+ .await
+ .map(|_| ())
})
.unwrap();
let state = repo
@@ -47,8 +52,13 @@ fn compare_and_swap_applies_declines_and_skips_missing() {
let repo = repo(&storage, "local");
let (closed, declined, missing) = repo
.run(|docs| async move {
- docs.put(THINGS, "a", json!({ "state": "open" }), Precondition::Absent)
- .await?;
+ docs.put(
+ THINGS,
+ "a",
+ json!({ "state": "open" }),
+ Precondition::Absent,
+ )
+ .await?;
let close = |doc: &Value| {
(text(doc, "state") == Some("open")).then(|| json!({ "state": "closed" }))
};
@@ -58,7 +68,10 @@ fn compare_and_swap_applies_declines_and_skips_missing() {
Ok((closed, declined, missing))
})
.unwrap();
- assert_eq!(closed.map(|stored| stored.doc), Some(json!({ "state": "closed" })));
+ assert_eq!(
+ closed.map(|stored| stored.doc),
+ Some(json!({ "state": "closed" }))
+ );
assert!(declined.is_none(), "already closed");
assert!(missing.is_none());
}
@@ -68,9 +81,14 @@ fn concurrent_swaps_apply_once() {
let storage = MemoryStorage::new();
let repo = repo(&storage, "local");
repo.run(|docs| async move {
- docs.put(THINGS, "a", json!({ "state": "open" }), Precondition::Absent)
- .await
- .map(|_| ())
+ docs.put(
+ THINGS,
+ "a",
+ json!({ "state": "open" }),
+ Precondition::Absent,
+ )
+ .await
+ .map(|_| ())
})
.unwrap();
let winners: usize = (0..8)
@@ -79,8 +97,7 @@ fn concurrent_swaps_apply_once() {
std::thread::spawn(move || {
repo.run(|docs| async move {
compare_and_swap(&docs, THINGS, "a", |doc| {
- (text(doc, "state") == Some("open"))
- .then(|| json!({ "state": "closed" }))
+ (text(doc, "state") == Some("open")).then(|| json!({ "state": "closed" }))
})
.await
})