lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit cb0aa5a5a261cca9da236f0332b8a1ecc754986a
parent e9b80ddbd0bd9fd51035466370002cc176cec007
Author: triesap <tyson@radroots.org>
Date:   Wed,  4 Mar 2026 17:53:32 +0000

replica-sync: run cargo fmt

Diffstat:
Mcrates/replica-sync/src/canonical.rs | 4+++-
Mcrates/replica-sync/src/emit.rs | 10++++++----
Mcrates/replica-sync/src/ingest.rs | 6+++---
Mcrates/replica-sync/src/sync_state.rs | 5+++--
Mcrates/replica-sync/src/tests.rs | 4++--
Mcrates/replica-sync/tests/ingest_roundtrip.rs | 14+++++++++-----
6 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/crates/replica-sync/src/canonical.rs b/crates/replica-sync/src/canonical.rs @@ -9,7 +9,9 @@ use serde_json::{Map, Value}; use crate::error::RadrootsReplicaEventsError; -pub fn canonical_json_string<T: Serialize>(value: &T) -> Result<String, RadrootsReplicaEventsError> { +pub fn canonical_json_string<T: Serialize>( + value: &T, +) -> Result<String, RadrootsReplicaEventsError> { let value = serde_json::to_value(value).map_err(|_| { RadrootsReplicaEventsError::InvalidData("canonical json serialization failed".to_string()) })?; diff --git a/crates/replica-sync/src/emit.rs b/crates/replica-sync/src/emit.rs @@ -24,7 +24,6 @@ use radroots_events_codec::farm::list_sets as farm_list_sets; use radroots_events_codec::list_set::encode as list_set_encode; use radroots_events_codec::plot::encode as plot_encode; use radroots_events_codec::wire::WireEventParts; -use radroots_sql_core::SqlExecutor; use radroots_replica_db::{ farm, farm_gcs_location, farm_member, farm_member_claim, farm_tag, gcs_location, nostr_profile, plot, plot_gcs_location, plot_tag, @@ -53,6 +52,7 @@ use radroots_replica_db_schema::plot_gcs_location::{ IPlotGcsLocationFieldsFilter, IPlotGcsLocationFindMany, PlotGcsLocation, }; use radroots_replica_db_schema::plot_tag::{IPlotTagFieldsFilter, IPlotTagFindMany}; +use radroots_sql_core::SqlExecutor; use serde_json::Value; use crate::canonical::canonical_json_string; @@ -659,8 +659,10 @@ fn parse_polygon(value: &str, lat: f64, lng: f64) -> RadrootsGeoJsonPolygon { fn load_profile<E: SqlExecutor>( exec: &E, pubkey: &str, -) -> Result<Option<radroots_replica_db_schema::nostr_profile::NostrProfile>, RadrootsReplicaEventsError> -{ +) -> Result< + Option<radroots_replica_db_schema::nostr_profile::NostrProfile>, + RadrootsReplicaEventsError, +> { let result_query = nostr_profile::find_one( exec, &INostrProfileFindOne::On(INostrProfileFindOneArgs { @@ -823,7 +825,6 @@ fn parts_to_draft(author: &str, parts: WireEventParts) -> RadrootsReplicaEventDr #[cfg(test)] mod tests { use super::*; - use radroots_sql_core::SqliteExecutor; use radroots_replica_db::{ farm, farm_gcs_location, farm_member, farm_member_claim, farm_tag, gcs_location, migrations, nostr_profile, plot, plot_gcs_location, plot_tag, @@ -842,6 +843,7 @@ mod tests { IPlotGcsLocationFields, IPlotGcsLocationFindMany, }; use radroots_replica_db_schema::plot_tag::IPlotTagFields; + use radroots_sql_core::SqliteExecutor; fn seed(exec: &SqliteExecutor) -> (Farm, Plot, Plot) { migrations::run_all_up(exec).expect("migrations"); diff --git a/crates/replica-sync/src/ingest.rs b/crates/replica-sync/src/ingest.rs @@ -17,8 +17,6 @@ use radroots_events_codec::farm::decode as farm_decode; use radroots_events_codec::list_set::decode as list_set_decode; use radroots_events_codec::plot::decode as plot_decode; use radroots_events_codec::profile::decode as profile_decode; -use radroots_sql_core::SqlExecutor; -use radroots_sql_core::error::SqlError; use radroots_replica_db::{ farm, farm_gcs_location, farm_member, farm_member_claim, farm_tag, gcs_location, nostr_event_state, nostr_profile, plot, plot_gcs_location, plot_tag, @@ -64,6 +62,8 @@ use radroots_replica_db_schema::plot_tag::{ IPlotTagDelete, IPlotTagFields, IPlotTagFieldsFilter, IPlotTagFindMany, IPlotTagFindOneArgs, PlotTagQueryBindValues, }; +use radroots_sql_core::SqlExecutor; +use radroots_sql_core::error::SqlError; use serde_json::Value; use crate::error::RadrootsReplicaEventsError; @@ -1048,7 +1048,6 @@ mod tests { use radroots_events_codec::farm::list_sets as farm_list_sets; use radroots_events_codec::list_set::encode as list_set_encode; use radroots_events_codec::plot::encode as plot_encode; - use radroots_sql_core::{ExecOutcome, SqlExecutor, SqliteExecutor}; use radroots_replica_db::{ farm, farm_gcs_location, farm_member, farm_member_claim, farm_tag, gcs_location, migrations, plot, plot_gcs_location, plot_tag, @@ -1062,6 +1061,7 @@ mod tests { use radroots_replica_db_schema::plot::IPlotFields; use radroots_replica_db_schema::plot_gcs_location::IPlotGcsLocationFields; use radroots_replica_db_schema::plot_tag::IPlotTagFields; + use radroots_sql_core::{ExecOutcome, SqlExecutor, SqliteExecutor}; struct FixedFactory; diff --git a/crates/replica-sync/src/sync_state.rs b/crates/replica-sync/src/sync_state.rs @@ -6,9 +6,9 @@ use alloc::{ #[cfg(feature = "std")] use std::collections::BTreeMap; -use radroots_sql_core::SqlExecutor; use radroots_replica_db_schema::farm::IFarmFindMany; use radroots_replica_db_schema::nostr_event_state::INostrEventStateFindMany; +use radroots_sql_core::SqlExecutor; use crate::error::RadrootsReplicaEventsError; use crate::event_state::{event_content_hash, event_state_key, tag_value}; @@ -23,7 +23,8 @@ pub struct RadrootsReplicaSyncStatus { pub fn radroots_replica_sync_status<E: SqlExecutor>( exec: &E, ) -> Result<RadrootsReplicaSyncStatus, RadrootsReplicaEventsError> { - let farms = radroots_replica_db::farm::find_many(exec, &IFarmFindMany { filter: None })?.results; + let farms = + radroots_replica_db::farm::find_many(exec, &IFarmFindMany { filter: None })?.results; let mut expected: BTreeMap<String, String> = BTreeMap::new(); for farm in farms { diff --git a/crates/replica-sync/src/tests.rs b/crates/replica-sync/src/tests.rs @@ -4,8 +4,6 @@ use crate::{ }; use radroots_events::farm::{RadrootsGeoJsonPoint, RadrootsGeoJsonPolygon}; use radroots_events::kinds::{KIND_FARM, KIND_LIST_SET_GENERIC, KIND_PLOT, KIND_PROFILE}; -use radroots_sql_core::SqliteExecutor; -use radroots_sql_core::error::SqlError; use radroots_replica_db::{ farm, farm_gcs_location, farm_member, farm_member_claim, farm_tag, gcs_location, migrations, nostr_profile, plot, plot_gcs_location, plot_tag, @@ -20,6 +18,8 @@ use radroots_replica_db_schema::nostr_profile::INostrProfileFields; use radroots_replica_db_schema::plot::IPlotFields; use radroots_replica_db_schema::plot_gcs_location::IPlotGcsLocationFields; use radroots_replica_db_schema::plot_tag::IPlotTagFields; +use radroots_sql_core::SqliteExecutor; +use radroots_sql_core::error::SqlError; use radroots_types::types::IError; fn unwrap_sql<T>(result: Result<T, IError<SqlError>>, label: &str) -> T { diff --git a/crates/replica-sync/tests/ingest_roundtrip.rs b/crates/replica-sync/tests/ingest_roundtrip.rs @@ -18,9 +18,6 @@ use radroots_events_codec::farm::encode as farm_encode; use radroots_events_codec::farm::list_sets as farm_list_sets; use radroots_events_codec::list_set::encode as list_set_encode; use radroots_events_codec::plot::encode as plot_encode; -use radroots_sql_core::SqlExecutor; -use radroots_sql_core::SqliteExecutor; -use radroots_sql_core::error::SqlError; use radroots_replica_db::{ farm, farm_gcs_location, farm_member, farm_member_claim, farm_tag, gcs_location, migrations, nostr_profile, plot, plot_gcs_location, plot_tag, @@ -33,18 +30,25 @@ use radroots_replica_db_schema::farm_member::{ use radroots_replica_db_schema::farm_member_claim::{ IFarmMemberClaimFields, IFarmMemberClaimFieldsFilter, IFarmMemberClaimFindMany, }; -use radroots_replica_db_schema::farm_tag::{IFarmTagFields, IFarmTagFieldsFilter, IFarmTagFindMany}; +use radroots_replica_db_schema::farm_tag::{ + IFarmTagFields, IFarmTagFieldsFilter, IFarmTagFindMany, +}; use radroots_replica_db_schema::gcs_location::IGcsLocationFields; use radroots_replica_db_schema::nostr_profile::INostrProfileFields; use radroots_replica_db_schema::plot::IPlotFields; use radroots_replica_db_schema::plot_gcs_location::IPlotGcsLocationFields; -use radroots_replica_db_schema::plot_tag::{IPlotTagFields, IPlotTagFieldsFilter, IPlotTagFindMany}; +use radroots_replica_db_schema::plot_tag::{ + IPlotTagFields, IPlotTagFieldsFilter, IPlotTagFindMany, +}; use radroots_replica_sync::{ RADROOTS_REPLICA_TRANSFER_VERSION, RadrootsReplicaEventDraft, RadrootsReplicaEventsError, RadrootsReplicaFarmSelector, RadrootsReplicaIngestOutcome, RadrootsReplicaSyncOptions, RadrootsReplicaSyncRequest, radroots_replica_ingest_event, radroots_replica_sync_all, radroots_replica_sync_status, }; +use radroots_sql_core::SqlExecutor; +use radroots_sql_core::SqliteExecutor; +use radroots_sql_core::error::SqlError; use radroots_types::types::IError; fn unwrap_sql<T>(result: Result<T, IError<SqlError>>, label: &str) -> T {