diff options
Diffstat (limited to 'src/swarm/members.rs')
| -rw-r--r-- | src/swarm/members.rs | 12 |
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, |
