@@ -55,7 +55,6 @@ extern crate net2;
55
55
56
56
use bufstream:: BufStream ;
57
57
use md5:: Md5 ;
58
- use std:: ascii:: AsciiExt ;
59
58
use std:: cell:: { Cell , RefCell } ;
60
59
use std:: collections:: { VecDeque , HashMap } ;
61
60
use std:: error:: Error as StdError ;
@@ -70,7 +69,7 @@ use std::time::Duration;
70
69
use std:: path:: PathBuf ;
71
70
72
71
// FIXME remove in 0.12
73
- pub use transaction:: Transaction ;
72
+ pub use transaction:: { Transaction , IsolationLevel } ;
74
73
75
74
use error:: { Error , ConnectError , SqlState , DbError } ;
76
75
use io:: { StreamWrapper , NegotiateSsl } ;
@@ -303,52 +302,6 @@ fn desynchronized() -> std_io::Error {
303
302
error")
304
303
}
305
304
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
-
352
305
/// Specifies the SSL support requested for a new connection.
353
306
#[ derive( Debug ) ]
354
307
pub enum SslMode < ' a > {
@@ -1239,7 +1192,7 @@ impl Connection {
1239
1192
let mut conn = self . conn . borrow_mut ( ) ;
1240
1193
check_desync ! ( conn) ;
1241
1194
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 ( ) )
1243
1196
}
1244
1197
1245
1198
/// # Deprecated
@@ -1502,3 +1455,7 @@ trait TransactionInternals<'conn> {
1502
1455
trait ConfigInternals {
1503
1456
fn build_command ( & self , s : & mut String ) ;
1504
1457
}
1458
+
1459
+ trait IsolationLevelNew {
1460
+ fn new ( level : & str ) -> Result < IsolationLevel > ;
1461
+ }
0 commit comments