aboutsummaryrefslogtreecommitdiffstats
path: root/src/swarm/members.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-31 19:51:52 +0100
committertv <tv@krebsco.de>2026-10-31 19:51:52 +0100
commitf4b0a7c5159d418e22682d2bd7d413fb3587ca7f (patch)
tree14a8a240970c43cc06e0042a376c80bd9f7b3418 /src/swarm/members.rs
parentc83604d8f82b6c67a64e3cee6f5c012ee4a10fc1 (diff)
store function accept any document
Diffstat (limited to 'src/swarm/members.rs')
-rw-r--r--src/swarm/members.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/swarm/members.rs b/src/swarm/members.rs
index 8d7f909..9885750 100644
--- a/src/swarm/members.rs
+++ b/src/swarm/members.rs
@@ -21,9 +21,9 @@ use std::time::Duration;
use serde_json::{Value as JsonValue, json};
use tracing::{debug, info, warn};
-use crate::document::Document;
use crate::document::meta;
use crate::document::store::{self, StoreError};
+use crate::document::{Document, Transactable};
use crate::state::AppState;
pub(crate) fn members_dir() -> Vec<String> {
@@ -74,7 +74,11 @@ pub(crate) fn tier(doc: &Document, pk: &str) -> Tier {
}
}
-pub(crate) fn set_tier(doc: &mut Document, pk: &str, tier: Tier) -> Result<(), StoreError> {
+pub(crate) fn set_tier(
+ doc: &mut impl Transactable,
+ pk: &str,
+ tier: Tier,
+) -> Result<(), StoreError> {
store::write_path(doc, &tier_path(pk), &json!(tier.as_str()))
}
@@ -100,7 +104,7 @@ pub(crate) fn aliases(doc: &Document) -> HashMap<String, String> {
.collect()
}
-fn set_alias(doc: &mut Document, pk: &str, alias: Option<&str>) -> Result<(), StoreError> {
+fn set_alias(doc: &mut impl Transactable, pk: &str, alias: Option<&str>) -> Result<(), StoreError> {
match alias {
Some(alias) => store::write_path(doc, &alias_path(pk), &json!(alias)),
None => match store::delete_path(doc, &alias_path(pk), false) {
@@ -314,7 +318,7 @@ pub(crate) async fn ensure_registered(state: &AppState) {
}
/// Removes `pk`'s entry (an operator forgot it). Absent is fine.
-pub(crate) fn unregister(doc: &mut Document, pk: &str) -> Result<(), StoreError> {
+pub(crate) fn unregister(doc: &mut impl Transactable, pk: &str) -> Result<(), StoreError> {
match store::delete_path(doc, &member_path(pk), false) {
Err(StoreError::NotFound) => Ok(()),
result => result,