This repository was archived by the owner on Oct 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +2
-61
lines changed Expand file tree Collapse file tree 1 file changed +2
-61
lines changed Original file line number Diff line number Diff line change 5
5
Syntax extensions to automatically derive ` FromSql ` and ` ToSql ` implementations for Postgres enum,
6
6
domain, and composite types.
7
7
8
- The generated code requires rust-postgres 0.12.0 or higher and Rust 1.10 .0 or higher.
8
+ The generated code requires rust-postgres 0.12.0 or higher and Rust 1.15 .0 or higher.
9
9
10
10
# Usage
11
11
12
- postgres-derive can be used both as a syntax extension with a nightly build of the compiler, or
13
- as a code generator with stable builds.
14
-
15
- ## Nightlies
16
-
17
- Simply depend on the ` postgres-derive-macros ` crate and register it as a plugin:
12
+ Simply depend on the ` postgres-derive ` crate and register it as a plugin:
18
13
19
14
20
15
Cargo.toml
@@ -42,60 +37,6 @@ pub enum Mood {
42
37
43
38
// ...
44
39
```
45
-
46
- ## Stable
47
-
48
- Use ` postgres-derive-codegen ` in a build script:
49
-
50
- Cargo.toml
51
- ``` toml
52
- [package ]
53
- # ...
54
- build = " build.rs"
55
-
56
- [build-dependencies ]
57
- postgres-derive-codegen = " 0.2"
58
-
59
- [dependencies ]
60
- postgres = " 0.13"
61
- ```
62
-
63
- build.rs
64
- ``` rust
65
- extern crate postgres_derive_codegen;
66
-
67
- use std :: env;
68
- use std :: path :: Path ;
69
-
70
- pub fn main () {
71
- let out_dir = env :: var_os (" OUT_DIR" ). unwrap ();
72
- let src = Path :: new (" src/types.rs.in" );
73
- let dst = Path :: new (& out_dir ). join (" types.rs" );
74
-
75
- postgres_derive_codegen :: expand (src , dst ). unwrap ();
76
- }
77
- ```
78
-
79
- types.rs.in
80
- ``` rust
81
- #[derive(Debug , ToSql , FromSql )]
82
- pub enum Mood {
83
- Sad ,
84
- Ok ,
85
- Happy ,
86
- }
87
- ```
88
-
89
- lib.rs
90
- ``` rust
91
- #[macro_use]
92
- extern crate postgres;
93
-
94
- include! (concat! (env! (" OUT_DIR" ), " /types.rs" ));
95
-
96
- // ...
97
- ```
98
-
99
40
# Types
100
41
101
42
## Enums
You can’t perform that action at this time.
0 commit comments