@@ -105,7 +105,7 @@ const TYPENAME_QUERY: &'static str = "t";
105105pub type Result < T > = result:: Result < T , Error > ;
106106
107107/// Specifies the target server to connect to.
108- #[ derive( Clone ) ]
108+ #[ derive( Clone , Show ) ]
109109pub enum ConnectTarget {
110110 /// Connect via TCP to the specified host.
111111 Tcp ( String ) ,
@@ -114,7 +114,7 @@ pub enum ConnectTarget {
114114}
115115
116116/// Authentication information
117- #[ derive( Clone ) ]
117+ #[ derive( Clone , Show ) ]
118118pub struct UserInfo {
119119 /// The username
120120 pub user : String ,
@@ -123,7 +123,7 @@ pub struct UserInfo {
123123}
124124
125125/// Information necessary to open a new connection to a Postgres server.
126- #[ derive( Clone ) ]
126+ #[ derive( Clone , Show ) ]
127127pub struct ConnectParams {
128128 /// The target server
129129 pub target : ConnectTarget ,
@@ -205,7 +205,7 @@ pub trait NoticeHandler: Send {
205205/// A notice handler which logs at the `info` level.
206206///
207207/// This is the default handler used by a `Connection`.
208- #[ derive( Copy ) ]
208+ #[ derive( Copy , Show ) ]
209209pub struct DefaultNoticeHandler ;
210210
211211impl NoticeHandler for DefaultNoticeHandler {
@@ -215,6 +215,7 @@ impl NoticeHandler for DefaultNoticeHandler {
215215}
216216
217217/// An asynchronous notification
218+ #[ derive( Clone , Show ) ]
218219pub struct Notification {
219220 /// The process ID of the notifying backend process
220221 pub pid : u32 ,
@@ -229,6 +230,12 @@ pub struct Notifications<'conn> {
229230 conn : & ' conn Connection
230231}
231232
233+ impl < ' a > fmt:: Show for Notifications < ' a > {
234+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
235+ write ! ( fmt, "Notifications" )
236+ }
237+ }
238+
232239impl < ' conn > Iterator for Notifications < ' conn > {
233240 type Item = Notification ;
234241
@@ -326,7 +333,7 @@ impl<'conn> Notifications<'conn> {
326333}
327334
328335/// Contains information necessary to cancel queries for a session
329- #[ derive( Copy ) ]
336+ #[ derive( Copy , Clone , Show ) ]
330337pub struct CancelData {
331338 /// The process ID of the session
332339 pub process_id : u32 ,
@@ -783,6 +790,16 @@ pub struct Connection {
783790 conn : RefCell < InnerConnection >
784791}
785792
793+ impl fmt:: Show for Connection {
794+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
795+ let conn = self . conn . borrow ( ) ;
796+ write ! ( fmt,
797+ "Connection {{ cancel_data: {:?}, notifications: {:?}, transaction_depth: {:?}, \
798+ desynchronized: {:?} }}", conn. cancel_data, conn. notifications. len( ) ,
799+ conn. trans_depth, conn. desynchronized)
800+ }
801+ }
802+
786803impl Connection {
787804 /// Creates a new connection to a Postgres database.
788805 ///
@@ -1056,6 +1073,8 @@ impl Connection {
10561073}
10571074
10581075/// Specifies the SSL support requested for a new connection
1076+ // FIXME
1077+ // #[derive(Show)]
10591078pub enum SslMode {
10601079 /// The connection will not use SSL
10611080 None ,
@@ -1075,6 +1094,13 @@ pub struct Transaction<'conn> {
10751094 finished : bool ,
10761095}
10771096
1097+ impl < ' a > fmt:: Show for Transaction < ' a > {
1098+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1099+ write ! ( fmt, "Transaction {{ connection: {:?}, commit: {:?}, depth: {:?} }}" ,
1100+ self . conn, self . commit. get( ) , self . depth)
1101+ }
1102+ }
1103+
10781104#[ unsafe_destructor]
10791105impl < ' conn > Drop for Transaction < ' conn > {
10801106 fn drop ( & mut self ) {
@@ -1205,6 +1231,18 @@ pub struct Statement<'conn> {
12051231 finished : bool ,
12061232}
12071233
1234+ impl < ' a > fmt:: Show for Statement < ' a > {
1235+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1236+ write ! ( fmt,
1237+ "Statement {{ connection: {:?}, name: {:?}, parameter_types: {:?},
1238+ result_descriptions: {:?} }}" ,
1239+ self . conn,
1240+ self . name,
1241+ self . param_types,
1242+ self . result_desc)
1243+ }
1244+ }
1245+
12081246#[ unsafe_destructor]
12091247impl < ' conn > Drop for Statement < ' conn > {
12101248 fn drop ( & mut self ) {
@@ -1382,7 +1420,7 @@ impl<'conn> Statement<'conn> {
13821420}
13831421
13841422/// Information about a column of the result of a query.
1385- #[ derive( PartialEq , Eq ) ]
1423+ #[ derive( PartialEq , Eq , Clone , Show ) ]
13861424pub struct ResultDescription {
13871425 /// The name of the column
13881426 pub name : String ,
@@ -1400,6 +1438,13 @@ pub struct Rows<'stmt> {
14001438 finished : bool ,
14011439}
14021440
1441+ impl < ' a > fmt:: Show for Rows < ' a > {
1442+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1443+ write ! ( fmt, "Rows {{ statement: {:?}, name: {:?}, remaining_rows: {:?} }}" ,
1444+ self . stmt, self . name, self . data. len( ) )
1445+ }
1446+ }
1447+
14031448#[ unsafe_destructor]
14041449impl < ' stmt > Drop for Rows < ' stmt > {
14051450 fn drop ( & mut self ) {
@@ -1511,6 +1556,12 @@ pub struct Row<'stmt> {
15111556 data : Vec < Option < Vec < u8 > > >
15121557}
15131558
1559+ impl < ' a > fmt:: Show for Row < ' a > {
1560+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1561+ write ! ( fmt, "Row {{ statement: {:?} }}" , self . stmt)
1562+ }
1563+ }
1564+
15141565impl < ' stmt > Row < ' stmt > {
15151566 /// Returns the number of values in the row
15161567 pub fn len ( & self ) -> usize {
@@ -1594,6 +1645,19 @@ pub struct LazyRows<'trans, 'stmt> {
15941645 _trans : & ' trans Transaction < ' trans > ,
15951646}
15961647
1648+ impl < ' a , ' b > fmt:: Show for LazyRows < ' a , ' b > {
1649+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1650+ write ! ( fmt,
1651+ "LazyRows {{ statement: {:?}, name: {:?}, row_limit: {:?}, remaining_rows: {:?}, \
1652+ more_rows: {:?} }}",
1653+ self . result. stmt,
1654+ self . result. name,
1655+ self . result. row_limit,
1656+ self . result. data. len( ) ,
1657+ self . result. more_rows)
1658+ }
1659+ }
1660+
15971661impl < ' trans , ' stmt > LazyRows < ' trans , ' stmt > {
15981662 /// Like `Rows::finish`.
15991663 pub fn finish ( self ) -> Result < ( ) > {
@@ -1621,6 +1685,13 @@ pub struct CopyInStatement<'a> {
16211685 finished : bool ,
16221686}
16231687
1688+ impl < ' a > fmt:: Show for CopyInStatement < ' a > {
1689+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
1690+ write ! ( fmt, "CopyInStatement {{ connection: {:?}, name: {:?}, column_types: {:?} }}" ,
1691+ self . conn, self . name, self . column_types)
1692+ }
1693+ }
1694+
16241695#[ unsafe_destructor]
16251696impl < ' a > Drop for CopyInStatement < ' a > {
16261697 fn drop ( & mut self ) {
@@ -1710,7 +1781,7 @@ impl<'a> CopyInStatement<'a> {
17101781 // FIXME this is not the right way to handle this
17111782 try_desync ! ( conn, conn. stream. write_message(
17121783 & CopyFail {
1713- message: & * format!( "{:? }" , err) ,
1784+ message: & * format!( "{}" , err) ,
17141785 } ) ) ;
17151786 break ' l;
17161787 }
0 commit comments