@@ -22,7 +22,7 @@ use sqlx_core::error::BoxDynError;
2222// that has a patch, we then apply the patch which should write to &mut Vec<u8>,
2323// backtrack and update the prefixed-len, then write until the next patch offset
2424
25- #[ derive( Default ) ]
25+ #[ derive( Default , Debug , Clone ) ]
2626pub struct PgArgumentBuffer {
2727 buffer : Vec < u8 > ,
2828
@@ -46,20 +46,32 @@ pub struct PgArgumentBuffer {
4646 type_holes : Vec < ( usize , HoleKind ) > , // Vec<{ offset, type_name }>
4747}
4848
49+ #[ derive( Debug , Clone ) ]
4950enum HoleKind {
5051 Type { name : UStr } ,
5152 Array ( Arc < PgArrayOf > ) ,
5253}
5354
55+ #[ derive( Clone ) ]
5456struct Patch {
5557 buf_offset : usize ,
5658 arg_index : usize ,
5759 #[ allow( clippy:: type_complexity) ]
58- callback : Box < dyn Fn ( & mut [ u8 ] , & PgTypeInfo ) + ' static + Send + Sync > ,
60+ callback : Arc < dyn Fn ( & mut [ u8 ] , & PgTypeInfo ) + ' static + Send + Sync > ,
61+ }
62+
63+ impl fmt:: Debug for Patch {
64+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
65+ f. debug_struct ( "Patch" )
66+ . field ( "buf_offset" , & self . buf_offset )
67+ . field ( "arg_index" , & self . arg_index )
68+ . field ( "callback" , & "<callback>" )
69+ . finish ( )
70+ }
5971}
6072
6173/// Implementation of [`Arguments`] for PostgreSQL.
62- #[ derive( Default ) ]
74+ #[ derive( Default , Debug , Clone ) ]
6375pub struct PgArguments {
6476 // Types of each bind parameter
6577 pub ( crate ) types : Vec < PgTypeInfo > ,
@@ -194,7 +206,7 @@ impl PgArgumentBuffer {
194206 self . patches . push ( Patch {
195207 buf_offset : offset,
196208 arg_index,
197- callback : Box :: new ( callback) ,
209+ callback : Arc :: new ( callback) ,
198210 } ) ;
199211 }
200212
0 commit comments