@@ -6,12 +6,12 @@ use std::sync::Arc;
66
77use parking_lot:: RwLock ;
88
9- mod error;
109mod bytes;
10+ mod error;
1111
12- use self :: error:: Result ;
1312pub use self :: bytes:: Bytes ;
1413pub use self :: error:: NegentropyError ;
14+ use self :: error:: Result ;
1515
1616pub struct ReconcileWithIds {
1717 pub have_ids : Vec < Arc < Bytes > > ,
@@ -26,7 +26,10 @@ pub struct Negentropy {
2626impl Negentropy {
2727 pub fn new ( id_size : u8 , frame_size_limit : Option < u64 > ) -> Result < Self > {
2828 Ok ( Self {
29- inner : RwLock :: new ( negentropy:: Negentropy :: new ( id_size as usize , frame_size_limit) ?)
29+ inner : RwLock :: new ( negentropy:: Negentropy :: new (
30+ id_size as usize ,
31+ frame_size_limit,
32+ ) ?) ,
3033 } )
3134 }
3235
@@ -67,25 +70,24 @@ impl Negentropy {
6770
6871 pub fn reconcile ( & self , query : Arc < Bytes > ) -> Result < Arc < Bytes > > {
6972 let mut negentropy = self . inner . write ( ) ;
70- Ok ( Arc :: new ( negentropy. reconcile ( query. as_ref ( ) . deref ( ) ) ?. into ( ) ) )
73+ Ok ( Arc :: new (
74+ negentropy. reconcile ( query. as_ref ( ) . deref ( ) ) ?. into ( ) ,
75+ ) )
7176 }
7277
73- pub fn reconcile_with_ids (
74- & self ,
75- query : Arc < Bytes > ,
76- ) -> Result < ReconcileWithIds > {
78+ pub fn reconcile_with_ids ( & self , query : Arc < Bytes > ) -> Result < ReconcileWithIds > {
7779 let mut negentropy = self . inner . write ( ) ;
7880 let mut have_ids: Vec < negentropy:: Bytes > = Vec :: new ( ) ;
7981 let mut need_ids: Vec < negentropy:: Bytes > = Vec :: new ( ) ;
80- let output: Option < negentropy:: Bytes > = negentropy. reconcile_with_ids ( query. as_ref ( ) . deref ( ) , & mut have_ids, & mut need_ids) ?;
81- Ok ( ReconcileWithIds {
82- have_ids : have_ids. into_iter ( ) . map ( |id| Arc :: new ( id. into ( ) ) ) . collect ( ) ,
83- need_ids : need_ids. into_iter ( ) . map ( |id| Arc :: new ( id. into ( ) ) ) . collect ( ) ,
84- output : output. map ( |o| Arc :: new ( o. into ( ) ) )
82+ let output: Option < negentropy:: Bytes > =
83+ negentropy. reconcile_with_ids ( query. as_ref ( ) . deref ( ) , & mut have_ids, & mut need_ids) ?;
84+ Ok ( ReconcileWithIds {
85+ have_ids : have_ids. into_iter ( ) . map ( |id| Arc :: new ( id. into ( ) ) ) . collect ( ) ,
86+ need_ids : need_ids. into_iter ( ) . map ( |id| Arc :: new ( id. into ( ) ) ) . collect ( ) ,
87+ output : output. map ( |o| Arc :: new ( o. into ( ) ) ) ,
8588 } )
8689 }
8790}
8891
89-
9092// UDL
9193uniffi:: include_scaffolding!( "negentropy" ) ;
0 commit comments