@@ -2,9 +2,9 @@ use serde::Deserialize;
22use std:: fs;
33use std:: path:: { Path , PathBuf } ;
44use traverse_registry:: {
5- export_peer_state , FederationFailure , FederationPeer , FederationRegistry ,
6- FederationStatusSummary , FederationSyncOutcome , FederationSyncStatus , FederationTrustState ,
7- RegistryScope , TrustRecord ,
5+ FederationFailure , FederationPeer , FederationRegistry , FederationStatusSummary ,
6+ FederationSyncOutcome , FederationSyncStatus , FederationTrustState , RegistryScope , TrustRecord ,
7+ export_peer_state ,
88} ;
99
1010#[ derive( Debug , Clone , Deserialize ) ]
@@ -75,21 +75,32 @@ struct LoadedFederationContext {
7575
7676pub fn render_federation_peers ( manifest_path : & Path ) -> Result < String , String > {
7777 let context = load_context ( manifest_path) ?;
78- Ok ( render_peer_listing ( & context. federation . status_summary ( ) , & context. federation ) )
78+ Ok ( render_peer_listing (
79+ & context. federation . status_summary ( ) ,
80+ & context. federation ,
81+ ) )
7982}
8083
8184pub fn render_federation_sync ( manifest_path : & Path ) -> Result < String , String > {
8285 let mut context = load_context ( manifest_path) ?;
8386 let outcome = sync_context ( & mut context) ?;
84- Ok ( render_sync_report ( & context. federation . status_summary ( ) , & context. federation , & outcome) )
87+ Ok ( render_sync_report (
88+ & context. federation . status_summary ( ) ,
89+ & context. federation ,
90+ & outcome,
91+ ) )
8592}
8693
8794pub fn render_federation_status ( manifest_path : & Path ) -> Result < String , String > {
8895 let mut context = load_context ( manifest_path) ?;
8996 let outcome = sync_context ( & mut context) ?;
9097 Ok ( format ! (
9198 "{}\n {}" ,
92- render_sync_report( & context. federation. status_summary( ) , & context. federation, & outcome) ,
99+ render_sync_report(
100+ & context. federation. status_summary( ) ,
101+ & context. federation,
102+ & outcome
103+ ) ,
93104 render_peer_listing( & context. federation. status_summary( ) , & context. federation)
94105 ) )
95106}
@@ -136,14 +147,20 @@ fn sync_context(context: &mut LoadedFederationContext) -> Result<FederationSyncO
136147 . map_err ( render_federation_failure)
137148}
138149
139- fn render_peer_listing ( summary : & FederationStatusSummary , federation : & FederationRegistry ) -> String {
150+ fn render_peer_listing (
151+ summary : & FederationStatusSummary ,
152+ federation : & FederationRegistry ,
153+ ) -> String {
140154 let mut lines = vec ! [
141155 format!( "peer_count: {}" , summary. peer_count) ,
142156 format!( "trusted_peer_count: {}" , summary. trusted_peer_count) ,
143157 format!( "last_sync_outcome: {:?}" , summary. last_sync_outcome) . to_lowercase( ) ,
144158 format!(
145159 "sync_age: {}" ,
146- summary. sync_age. clone( ) . unwrap_or_else( || "none" . to_string( ) )
160+ summary
161+ . sync_age
162+ . clone( )
163+ . unwrap_or_else( || "none" . to_string( ) )
147164 ) ,
148165 format!( "conflict_count: {}" , summary. conflict_count) ,
149166 format!( "blocked_entries: {}" , summary. blocked_entries) ,
@@ -153,19 +170,15 @@ fn render_peer_listing(summary: &FederationStatusSummary, federation: &Federatio
153170 for peer in federation. list_peers ( ) {
154171 lines. push ( format ! ( "peer_id: {}" , peer. peer_id) ) ;
155172 lines. push ( format ! ( "display_name: {}" , peer. display_name) ) ;
156- lines. push ( format ! (
157- "trust_state: {:?}" ,
158- peer. trust_state
159- ) . to_lowercase ( ) ) ;
173+ lines. push ( format ! ( "trust_state: {:?}" , peer. trust_state) . to_lowercase ( ) ) ;
160174 lines. push ( format ! ( "sync_enabled: {}" , peer. sync_enabled) ) ;
161175 lines. push ( format ! (
162176 "last_sync_at: {}" ,
163- peer. last_sync_at. clone( ) . unwrap_or_else( || "none" . to_string( ) )
177+ peer. last_sync_at
178+ . clone( )
179+ . unwrap_or_else( || "none" . to_string( ) )
164180 ) ) ;
165- lines. push ( format ! (
166- "last_sync_status: {:?}" ,
167- peer. last_sync_status
168- ) . to_lowercase ( ) ) ;
181+ lines. push ( format ! ( "last_sync_status: {:?}" , peer. last_sync_status) . to_lowercase ( ) ) ;
169182 lines. push ( format ! (
170183 "visible_registry_scopes: {}" ,
171184 peer. visible_registry_scopes
@@ -376,11 +389,7 @@ impl TrustRecordManifest {
376389 Ok ( TrustRecord {
377390 peer_id : self . peer_id ,
378391 trust_model : self . trust_model ,
379- allowed_scopes : self
380- . allowed_scopes
381- . into_iter ( )
382- . map ( Into :: into)
383- . collect ( ) ,
392+ allowed_scopes : self . allowed_scopes . into_iter ( ) . map ( Into :: into) . collect ( ) ,
384393 approved_spec_refs : self . approved_spec_refs ,
385394 approved_at : self . approved_at ,
386395 revoked_at : self . revoked_at ,
0 commit comments