1
1
# Rust-Postgres
2
2
A native PostgreSQL driver for Rust.
3
3
4
- [ Documentation] ( https://sfackler.github.io/rust-postgres/doc/v0.11.11 /postgres )
4
+ [ Documentation] ( https://sfackler.github.io/rust-postgres/doc/v0.12.0 /postgres )
5
5
6
6
[ ![ Build Status] ( https://travis-ci.org/sfackler/rust-postgres.png?branch=master )] ( https://travis-ci.org/sfackler/rust-postgres ) [ ![ Latest Version] ( https://img.shields.io/crates/v/postgres.svg )] ( https://crates.io/crates/postgres )
7
7
8
8
You can integrate Rust-Postgres into your project through the [ releases on crates.io] ( https://crates.io/crates/postgres ) :
9
9
``` toml
10
- # Cargo.toml
11
10
[dependencies ]
12
- postgres = " 0.11 "
11
+ postgres = " 0.12 "
13
12
```
14
13
15
14
## Overview
16
15
Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database.
17
16
``` rust
18
17
extern crate postgres;
19
18
20
- use postgres :: {Connection , SslMode };
19
+ use postgres :: {Connection , TlsMode };
21
20
22
21
struct Person {
23
22
id : i32 ,
@@ -26,7 +25,7 @@ struct Person {
26
25
}
27
26
28
27
fn main () {
29
- let conn = Connection :: connect (" postgres://postgres@localhost" , SslMode :: None ). unwrap ();
28
+ let conn = Connection :: connect (" postgres://postgres@localhost" , TlsMode :: None ). unwrap ();
30
29
conn . execute (" CREATE TABLE person (
31
30
id SERIAL PRIMARY KEY,
32
31
name VARCHAR NOT NULL,
@@ -51,7 +50,7 @@ fn main() {
51
50
```
52
51
53
52
## Requirements
54
- * ** Rust** - Rust-Postgres is developed against the 1.9 release of Rust
53
+ * ** Rust** - Rust-Postgres is developed against the 1.10 release of Rust
55
54
available on http://www.rust-lang.org . It should also compile against more
56
55
recent releases.
57
56
@@ -65,19 +64,18 @@ fn main() {
65
64
Connect to a Postgres server using the standard URI format:
66
65
``` rust
67
66
let conn = try ! (Connection :: connect (" postgres://user:pass@host:port/database?arg1=val1&arg2=val2" ,
68
- SslMode :: None ));
67
+ TlsMode :: None ));
69
68
```
70
69
` pass ` may be omitted if not needed. ` port ` defaults to ` 5432 ` and ` database `
71
70
defaults to the value of ` user ` if not specified. The driver supports ` trust ` ,
72
71
` password ` , and ` md5 ` authentication.
73
72
74
- Unix domain sockets can be used as well by activating the ` unix_socket ` or
75
- ` nightly ` features. The ` host ` portion of the URI should be set to the absolute
76
- path to the directory containing the socket file. Since ` / ` is a reserved
77
- character in URLs, the path should be URL encoded. If Postgres stored its socket
78
- files in ` /run/postgres ` , the connection would then look like:
73
+ Unix domain sockets can be used as well. The ` host ` portion of the URI should
74
+ be set to the absolute path to the directory containing the socket file. Since
75
+ ` / ` is a reserved character in URLs, the path should be URL encoded. If Postgres
76
+ stored its socket files in ` /run/postgres ` , the connection would then look like:
79
77
``` rust
80
- let conn = try ! (Connection :: connect (" postgres://postgres@%2Frun%2Fpostgres" , SslMode :: None ));
78
+ let conn = try ! (Connection :: connect (" postgres://postgres@%2Frun%2Fpostgres" , TlsMode :: None ));
81
79
```
82
80
Paths which contain non-UTF8 characters can be handled in a different manner;
83
81
see the documentation for details.
@@ -182,7 +180,7 @@ types. The driver currently supports the following conversions:
182
180
</tr>
183
181
<tr>
184
182
<td>str/String</td>
185
- <td>VARCHAR, CHAR(n), TEXT, CITEXT</td>
183
+ <td>VARCHAR, CHAR(n), TEXT, CITEXT, NAME </td>
186
184
</tr>
187
185
<tr>
188
186
<td>[u8]/Vec<u8></td>
@@ -285,42 +283,36 @@ crate.
285
283
286
284
## Optional features
287
285
288
- ### Unix socket connections
289
-
290
- Support for connections through Unix domain sockets is provided optionally by
291
- either the ` unix_socket ` or ` nightly ` features. It is only available on "unixy"
292
- platforms such as OSX, BSD and Linux.
293
-
294
286
### UUID type
295
287
296
288
[ UUID] ( http://www.postgresql.org/docs/9.4/static/datatype-uuid.html ) support is
297
- provided optionally by the ` uuid ` feature, which adds ` ToSql ` and ` FromSql `
289
+ provided optionally by the ` with- uuid` feature, which adds ` ToSql ` and ` FromSql `
298
290
implementations for ` uuid ` 's ` Uuid ` type.
299
291
300
292
### JSON/JSONB types
301
293
302
294
[ JSON and JSONB] ( http://www.postgresql.org/docs/9.4/static/datatype-json.html )
303
- support is provided optionally by the ` rustc-serialize ` feature, which adds
295
+ support is provided optionally by the ` with- rustc-serialize` feature, which adds
304
296
` ToSql ` and ` FromSql ` implementations for ` rustc-serialize ` 's ` Json ` type, and
305
- the ` serde_json ` feature, which adds implementations for ` serde_json ` 's ` Value `
306
- type.
297
+ the ` with- serde_json` feature, which adds implementations for ` serde_json ` 's
298
+ ` Value ` type.
307
299
308
300
### TIMESTAMP/TIMESTAMPTZ/DATE/TIME types
309
301
310
302
[ Date and Time] ( http://www.postgresql.org/docs/9.1/static/datatype-datetime.html )
311
- support is provided optionally by the ` time ` feature, which adds ` ToSql ` and
312
- ` FromSql ` implementations for ` time ` 's ` Timespec ` type, or the ` chrono `
303
+ support is provided optionally by the ` with- time` feature, which adds ` ToSql `
304
+ and ` FromSql ` implementations for ` time ` 's ` Timespec ` type, or the ` with- chrono`
313
305
feature, which adds ` ToSql ` and ` FromSql ` implementations for ` chrono ` 's
314
306
` DateTime ` , ` NaiveDateTime ` , ` NaiveDate ` and ` NaiveTime ` types.
315
307
316
308
### BIT/VARBIT types
317
309
318
310
[ BIT and VARBIT] ( http://www.postgresql.org/docs/9.4/static/datatype-bit.html )
319
- support is provided optionally by the ` bit-vec ` feature, which adds ` ToSql ` and
320
- ` FromSql ` implementations for ` bit-vec ` 's ` BitVec ` type.
311
+ support is provided optionally by the ` with- bit-vec` feature, which adds ` ToSql `
312
+ and ` FromSql ` implementations for ` bit-vec ` 's ` BitVec ` type.
321
313
322
314
### MACADDR type
323
315
324
316
[ MACADDR] ( http://www.postgresql.org/docs/9.4/static/datatype-net-types.html#DATATYPE-MACADDR )
325
- support is provided optionally by the ` eui48 ` feature, which adds ` ToSql ` and
326
- ` FromSql ` implementations for ` eui48 ` 's ` MacAddress ` type.
317
+ support is provided optionally by the ` with- eui48` feature, which adds ` ToSql `
318
+ and ` FromSql ` implementations for ` eui48 ` 's ` MacAddress ` type.
0 commit comments