Skip to content

Commit d08dc13

Browse files
committed
Move types out to postgres-shared
1 parent e675ee7 commit d08dc13

File tree

20 files changed

+48
-41
lines changed

20 files changed

+48
-41
lines changed

codegen/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mod sqlstate;
99
mod type_gen;
1010

1111
fn main() {
12-
let path = Path::new("..");
12+
let path = Path::new("../postgres-shared/src");
1313
sqlstate::build(path);
1414
type_gen::build(path);
1515
}

codegen/src/sqlstate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct Code {
1313
}
1414

1515
pub fn build(path: &Path) {
16-
let mut file = BufWriter::new(File::create(path.join("postgres-shared/src/error/sqlstate.rs")).unwrap());
16+
let mut file = BufWriter::new(File::create(path.join("error/sqlstate.rs")).unwrap());
1717

1818
let codes = parse_codes();
1919

codegen/src/type_gen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct Type {
2020
}
2121

2222
pub fn build(path: &Path) {
23-
let mut file = BufWriter::new(File::create(path.join("postgres/src/types/type_gen.rs")).unwrap());
23+
let mut file = BufWriter::new(File::create(path.join("types/type_gen.rs")).unwrap());
2424

2525
let ranges = parse_ranges();
2626
let types = parse_types(&ranges);

postgres-shared/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,23 @@ name = "postgres-shared"
33
version = "0.1.0"
44
authors = ["Steven Fackler <[email protected]>"]
55

6+
[features]
7+
with-bit-vec = ["bit-vec"]
8+
with-chrono = ["chrono"]
9+
with-eui48 = ["eui48"]
10+
with-serde_json = ["serde_json"]
11+
with-time = ["time"]
12+
with-uuid = ["uuid"]
13+
614
[dependencies]
715
hex = "0.2"
816
fallible-iterator = "0.1.3"
917
phf = "=0.7.20"
1018
postgres-protocol = "0.2"
19+
20+
bit-vec = { version = "0.4", optional = true }
21+
chrono = { version = "0.2.14", optional = true }
22+
eui48 = { version = "0.1", optional = true }
23+
serde_json = { version = ">= 0.6, < 0.9", optional = true }
24+
time = { version = "0.1.14", optional = true }
25+
uuid = { version = ">= 0.1, < 0.4", optional = true }

postgres-shared/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::ops::Range;
1010

1111
pub mod error;
1212
pub mod params;
13+
pub mod types;
1314

1415
pub struct RowData {
1516
buf: Vec<u8>,
File renamed without changes.
File renamed without changes.
File renamed without changes.

postgres/src/types/mod.rs renamed to postgres-shared/src/types/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//! Traits dealing with Postgres data types
2-
31
use fallible_iterator::FallibleIterator;
42
use postgres_protocol;
53
use postgres_protocol::types::{self, ArrayDimension};
@@ -13,7 +11,6 @@ pub use postgres_protocol::Oid;
1311

1412
pub use self::type_gen::Type;
1513
pub use self::special::{Date, Timestamp};
16-
use {SessionInfoNew, OtherNew, WrongTypeNew, FieldNew};
1714

1815
/// Generates a simple implementation of `ToSql::accepts` which accepts the
1916
/// types passed to it.
@@ -88,8 +85,9 @@ pub struct SessionInfo<'a> {
8885
parameters: &'a HashMap<String, String>,
8986
}
9087

91-
impl<'a> SessionInfoNew<'a> for SessionInfo<'a> {
92-
fn new(parameters: &'a HashMap<String, String>) -> SessionInfo<'a> {
88+
impl<'a> SessionInfo<'a> {
89+
#[doc(hidden)]
90+
pub fn new(parameters: &'a HashMap<String, String>) -> SessionInfo<'a> {
9391
SessionInfo { parameters: parameters }
9492
}
9593
}
@@ -142,8 +140,9 @@ impl Field {
142140
}
143141
}
144142

145-
impl FieldNew for Field {
146-
fn new(name: String, type_: Type) -> Field {
143+
impl Field {
144+
#[doc(hidden)]
145+
pub fn new(name: String, type_: Type) -> Field {
147146
Field {
148147
name: name,
149148
type_: type_,
@@ -174,8 +173,9 @@ struct OtherInner {
174173
schema: String,
175174
}
176175

177-
impl OtherNew for Other {
178-
fn new(name: String, oid: Oid, kind: Kind, schema: String) -> Other {
176+
impl Other {
177+
#[doc(hidden)]
178+
pub fn new(name: String, oid: Oid, kind: Kind, schema: String) -> Other {
179179
Other(Arc::new(OtherInner {
180180
name: name,
181181
oid: oid,
@@ -243,8 +243,9 @@ impl Error for WrongType {
243243
}
244244
}
245245

246-
impl WrongTypeNew for WrongType {
247-
fn new(ty: Type) -> WrongType {
246+
impl WrongType {
247+
#[doc(hidden)]
248+
pub fn new(ty: Type) -> WrongType {
248249
WrongType(ty)
249250
}
250251
}

0 commit comments

Comments
 (0)