@@ -55,7 +55,6 @@ extern crate net2;
5555
5656use bufstream:: BufStream ;
5757use md5:: Md5 ;
58- use std:: ascii:: AsciiExt ;
5958use std:: cell:: { Cell , RefCell } ;
6059use std:: collections:: { VecDeque , HashMap } ;
6160use std:: error:: Error as StdError ;
@@ -70,7 +69,7 @@ use std::time::Duration;
7069use std:: path:: PathBuf ;
7170
7271// FIXME remove in 0.12
73- pub use transaction:: Transaction ;
72+ pub use transaction:: { Transaction , IsolationLevel } ;
7473
7574use error:: { Error , ConnectError , SqlState , DbError } ;
7675use io:: { StreamWrapper , NegotiateSsl } ;
@@ -303,52 +302,6 @@ fn desynchronized() -> std_io::Error {
303302 error")
304303}
305304
306- /// An enumeration of transaction isolation levels.
307- ///
308- /// See the [Postgres documentation](http://www.postgresql.org/docs/9.4/static/transaction-iso.html)
309- /// for full details on the semantics of each level.
310- #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
311- pub enum IsolationLevel {
312- /// The "read uncommitted" level.
313- ///
314- /// In current versions of Postgres, this behaves identically to
315- /// `ReadCommitted`.
316- ReadUncommitted ,
317- /// The "read committed" level.
318- ///
319- /// This is the default isolation level in Postgres.
320- ReadCommitted ,
321- /// The "repeatable read" level.
322- RepeatableRead ,
323- /// The "serializable" level.
324- Serializable ,
325- }
326-
327- impl IsolationLevel {
328- fn to_sql ( & self ) -> & ' static str {
329- match * self {
330- IsolationLevel :: ReadUncommitted => "READ UNCOMMITTED" ,
331- IsolationLevel :: ReadCommitted => "READ COMMITTED" ,
332- IsolationLevel :: RepeatableRead => "REPEATABLE READ" ,
333- IsolationLevel :: Serializable => "SERIALIZABLE" ,
334- }
335- }
336-
337- fn parse ( raw : & str ) -> Result < IsolationLevel > {
338- if raw. eq_ignore_ascii_case ( "READ UNCOMMITTED" ) {
339- Ok ( IsolationLevel :: ReadUncommitted )
340- } else if raw. eq_ignore_ascii_case ( "READ COMMITTED" ) {
341- Ok ( IsolationLevel :: ReadCommitted )
342- } else if raw. eq_ignore_ascii_case ( "REPEATABLE READ" ) {
343- Ok ( IsolationLevel :: RepeatableRead )
344- } else if raw. eq_ignore_ascii_case ( "SERIALIZABLE" ) {
345- Ok ( IsolationLevel :: Serializable )
346- } else {
347- Err ( Error :: Io ( bad_response ( ) ) )
348- }
349- }
350- }
351-
352305/// Specifies the SSL support requested for a new connection.
353306#[ derive( Debug ) ]
354307pub enum SslMode < ' a > {
@@ -1239,7 +1192,7 @@ impl Connection {
12391192 let mut conn = self . conn . borrow_mut ( ) ;
12401193 check_desync ! ( conn) ;
12411194 let result = try!( conn. quick_query ( "SHOW TRANSACTION ISOLATION LEVEL" ) ) ;
1242- IsolationLevel :: parse ( result[ 0 ] [ 0 ] . as_ref ( ) . unwrap ( ) )
1195+ IsolationLevel :: new ( result[ 0 ] [ 0 ] . as_ref ( ) . unwrap ( ) )
12431196 }
12441197
12451198 /// # Deprecated
@@ -1502,3 +1455,7 @@ trait TransactionInternals<'conn> {
15021455trait ConfigInternals {
15031456 fn build_command ( & self , s : & mut String ) ;
15041457}
1458+
1459+ trait IsolationLevelNew {
1460+ fn new ( level : & str ) -> Result < IsolationLevel > ;
1461+ }
0 commit comments