@@ -555,6 +555,32 @@ impl Connection {
555555 . boxed ( )
556556 }
557557
558+ fn raw_close ( self , type_ : u8 , name : & str ) -> BoxFuture < Connection , Error > {
559+ let mut close = vec ! [ ] ;
560+ let mut sync = vec ! [ ] ;
561+ frontend:: close ( type_, name, & mut close)
562+ . map ( |( ) | frontend:: sync ( & mut sync) )
563+ . into_future ( )
564+ . and_then ( move |( ) | {
565+ let it = Some ( close) . into_iter ( ) . chain ( Some ( sync) ) . map ( Ok :: < _ , io:: Error > ) ;
566+ self . 0 . send_all ( futures:: stream:: iter ( it) )
567+ } )
568+ . and_then ( |s| s. 0 . read ( ) )
569+ . map_err ( Error :: Io )
570+ . and_then ( |( m, s) | {
571+ match m {
572+ backend:: Message :: CloseComplete => Either :: A ( Ok ( Connection ( s) ) . into_future ( ) ) ,
573+ backend:: Message :: ErrorResponse ( body) => {
574+ Either :: B ( Connection ( s) . ready_err ( body) )
575+ }
576+ _ => Either :: A ( Err ( bad_message ( ) ) . into_future ( ) ) ,
577+ }
578+ } )
579+ . and_then ( |s| s. ready ( ( ) ) )
580+ . map ( |( ( ) , s) | s)
581+ . boxed ( )
582+ }
583+
558584 pub fn cancel_data ( & self ) -> CancelData {
559585 self . 0 . cancel_data
560586 }
@@ -581,6 +607,10 @@ impl Statement {
581607 . map ( |( n, conn) | ( n, self , conn) )
582608 . boxed ( )
583609 }
610+
611+ pub fn close ( self , conn : Connection ) -> BoxFuture < Connection , Error > {
612+ conn. raw_close ( b'S' , & self . name )
613+ }
584614}
585615
586616fn connect_err ( fields : & mut ErrorFields ) -> ConnectError {
0 commit comments