@@ -185,10 +185,8 @@ impl WriterConnectionPool {
185
185
}
186
186
}
187
187
188
- pub struct MasWriter < ' c > {
188
+ pub struct MasWriter {
189
189
conn : LockedMasDatabase ,
190
- // Temporary phantom data, so that we don't remove the lifetime parameter yet
191
- phantom : std:: marker:: PhantomData < & ' c ( ) > ,
192
190
writer_pool : WriterConnectionPool ,
193
191
194
192
indices_to_restore : Vec < IndexDescription > ,
@@ -326,7 +324,7 @@ pub async fn is_syn2mas_in_progress(conn: &mut PgConnection) -> Result<bool, Err
326
324
}
327
325
}
328
326
329
- impl MasWriter < ' _ > {
327
+ impl MasWriter {
330
328
/// Creates a new MAS writer.
331
329
///
332
330
/// # Errors
@@ -448,7 +446,7 @@ impl MasWriter<'_> {
448
446
449
447
Ok ( Self {
450
448
conn,
451
- phantom : std :: marker :: PhantomData ,
449
+
452
450
writer_pool : WriterConnectionPool :: new ( writer_connections) ,
453
451
indices_to_restore,
454
452
constraints_to_restore,
@@ -1027,37 +1025,37 @@ const WRITE_BUFFER_BATCH_SIZE: usize = 4096;
1027
1025
1028
1026
/// A function that can accept and flush buffers from a `MasWriteBuffer`.
1029
1027
/// Intended uses are the methods on `MasWriter` such as `write_users`.
1030
- type WriteBufferFlusher < ' conn , T > =
1031
- for <' a > fn ( & ' a mut MasWriter < ' conn > , Vec < T > ) -> BoxFuture < ' a , Result < ( ) , Error > > ;
1028
+ type WriteBufferFlusher < T > =
1029
+ for <' a > fn ( & ' a mut MasWriter , Vec < T > ) -> BoxFuture < ' a , Result < ( ) , Error > > ;
1032
1030
1033
1031
/// A buffer for writing rows to the MAS database.
1034
1032
/// Generic over the type of rows.
1035
1033
///
1036
1034
/// # Panics
1037
1035
///
1038
1036
/// Panics if dropped before `finish()` has been called.
1039
- pub struct MasWriteBuffer < ' conn , T > {
1037
+ pub struct MasWriteBuffer < T > {
1040
1038
rows : Vec < T > ,
1041
- flusher : WriteBufferFlusher < ' conn , T > ,
1039
+ flusher : WriteBufferFlusher < T > ,
1042
1040
finished : bool ,
1043
1041
}
1044
1042
1045
- impl < ' conn , T > MasWriteBuffer < ' conn , T > {
1046
- pub fn new ( flusher : WriteBufferFlusher < ' conn , T > ) -> Self {
1043
+ impl < T > MasWriteBuffer < T > {
1044
+ pub fn new ( flusher : WriteBufferFlusher < T > ) -> Self {
1047
1045
MasWriteBuffer {
1048
1046
rows : Vec :: with_capacity ( WRITE_BUFFER_BATCH_SIZE ) ,
1049
1047
flusher,
1050
1048
finished : false ,
1051
1049
}
1052
1050
}
1053
1051
1054
- pub async fn finish ( mut self , writer : & mut MasWriter < ' conn > ) -> Result < ( ) , Error > {
1052
+ pub async fn finish ( mut self , writer : & mut MasWriter ) -> Result < ( ) , Error > {
1055
1053
self . finished = true ;
1056
1054
self . flush ( writer) . await ?;
1057
1055
Ok ( ( ) )
1058
1056
}
1059
1057
1060
- pub async fn flush ( & mut self , writer : & mut MasWriter < ' conn > ) -> Result < ( ) , Error > {
1058
+ pub async fn flush ( & mut self , writer : & mut MasWriter ) -> Result < ( ) , Error > {
1061
1059
if self . rows . is_empty ( ) {
1062
1060
return Ok ( ( ) ) ;
1063
1061
}
@@ -1067,7 +1065,7 @@ impl<'conn, T> MasWriteBuffer<'conn, T> {
1067
1065
Ok ( ( ) )
1068
1066
}
1069
1067
1070
- pub async fn write ( & mut self , writer : & mut MasWriter < ' conn > , row : T ) -> Result < ( ) , Error > {
1068
+ pub async fn write ( & mut self , writer : & mut MasWriter , row : T ) -> Result < ( ) , Error > {
1071
1069
self . rows . push ( row) ;
1072
1070
if self . rows . len ( ) >= WRITE_BUFFER_BATCH_SIZE {
1073
1071
self . flush ( writer) . await ?;
@@ -1076,7 +1074,7 @@ impl<'conn, T> MasWriteBuffer<'conn, T> {
1076
1074
}
1077
1075
}
1078
1076
1079
- impl < T > Drop for MasWriteBuffer < ' _ , T > {
1077
+ impl < T > Drop for MasWriteBuffer < T > {
1080
1078
fn drop ( & mut self ) {
1081
1079
assert ! ( self . finished, "MasWriteBuffer dropped but not finished!" ) ;
1082
1080
}
@@ -1185,7 +1183,7 @@ mod test {
1185
1183
/// Runs some code with a `MasWriter`.
1186
1184
///
1187
1185
/// The callback is responsible for `finish`ing the `MasWriter`.
1188
- async fn make_mas_writer ( pool : & PgPool ) -> MasWriter < ' static > {
1186
+ async fn make_mas_writer ( pool : & PgPool ) -> MasWriter {
1189
1187
let main_conn = pool. acquire ( ) . await . unwrap ( ) . detach ( ) ;
1190
1188
let mut writer_conns = Vec :: new ( ) ;
1191
1189
for _ in 0 ..2 {
0 commit comments