Skip to content

Commit d935e21

Browse files
Merge pull request #2 from stadiamaps/sqlx-0-5
Upgrade to sqlx 0.5
2 parents 1eb723b + 9755125 commit d935e21

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tile_sorcerer"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
authors = ["Ian Wagner <ian@stadiamaps.com>", "Luke Seelenbinder <luke@stadiamaps.com>"]
55
license = "BSD-3-Clause"
66
repository = "https://github.com/stadiamaps/tile_sorcerer"
@@ -22,9 +22,9 @@ version = "~1.0"
2222
features = ["derive"]
2323

2424
[dependencies.sqlx]
25-
version = "~0.3"
25+
version = "~0.5"
2626
default-features = false
27-
features = ["runtime-tokio", "postgres", "chrono", "uuid"]
27+
features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid", "tls"]
2828

2929
[dev-dependencies]
3030
assert_approx_eq = "~1.1"

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Tools for modeling and querying vector tile sources.
66

77
## Current status
88

9-
This code should be regarded as stable beta. While there are a number of
9+
This crate should be regarded as stable in terms of code correctness, but not
10+
yet stable in terms of trait and method signatures and feature set. While there are a number of
1011
known limitations, this code is being deployed at scale already. We are
1112
releasing this code in Rust tradition as 0.x until we feel the interface
1213
and feature set have stabilized, but welcome usage and contributions from

src/lib.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
//! # Tile Sorcerer
22
//!
3-
//! This crate provides tools for modeling and querying vector tile sources.
3+
//! Tools for modeling and querying vector tile sources.
4+
//!
5+
//! ## Current status
6+
//!
7+
//! This crate should be regarded as stable in terms of code reliability/correctness, but not
8+
//! yet stable in terms of trait and method signatures. While there are a number of
9+
//! known limitations, this code is being deployed at scale already. We are
10+
//! releasing this code in Rust tradition as 0.x until we feel the interface
11+
//! and feature set have stabilized, but welcome usage and contributions from
12+
//! the Rust GIS community.
13+
//!
14+
//! ## Current features
15+
//!
16+
//! Given a PostGIS database and a TileMill source (such as OpenMapTiles data),
17+
//! this crate will help you leverage PostGIS to render Mapbox Vector Tiles.
18+
//!
19+
//! ## Known Limitations
20+
//!
21+
//! The current focus is on high-performance rendering from a single PostGIS database.
22+
//! Other formats are not presently supported, but can be added in the future.
23+
//! As such, the database connection info present in layers is presently ignored, and
24+
//! it is up to the calling application to set up a connection pool pointed at the right
25+
//! database. Projection info is also currently ignored, and your database is assumed to be
26+
//! in EPSG:3857 web mercator already.
27+
//!
28+
//! The trait-based design allows for further extensibility, so additional operations,
29+
//! tile source formats, etc. will likely be added in the future.
430
531
#![deny(warnings)]
632

src/tm2.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
/// TileMill Layer Source YAML Format
2-
///
3-
/// Further reading: https://tilemill-project.github.io/tilemill/docs/manual/adding-layers/
1+
//! Data models and trait implementations for TileMill 2 yaml sources.
2+
//!
3+
//! Further reading: https://tilemill-project.github.io/tilemill/docs/manual/adding-layers/
4+
45
use crate::{get_epsg_3857_tile_bounds, TileSource};
56

67
use std::collections::HashMap;
@@ -10,9 +11,9 @@ use serde::Deserialize;
1011
// TODO: remove once async fn in traits become stable
1112
use async_trait::async_trait;
1213

13-
use sqlx::{cursor::Cursor, query, PgPool, Row};
14+
use sqlx::{query, PgPool, Row};
1415

15-
/// A TileMill (.tm2source) data structure.
16+
/// The TileMill (.tm2source) data source model.
1617
///
1718
/// Note: The current data structure is not entirely complete. See the
1819
/// crate README for limitations.
@@ -31,6 +32,7 @@ pub struct TM2Source {
3132
pub bounds: [f64; 4],
3233
}
3334

35+
/// A single layer of a TM2Source
3436
#[derive(Clone, Deserialize, Debug)]
3537
pub struct DataLayer {
3638
pub id: String,
@@ -40,12 +42,14 @@ pub struct DataLayer {
4042
// TODO: srs
4143
}
4244

45+
/// A `DataLayer`'s source details
4346
#[derive(Clone, Deserialize, Debug)]
4447
pub struct LayerSource {
4548
pub table: String,
4649
// TODO: Database connection parameters
4750
}
4851

52+
/// Additional properties of a `DataLayer`
4953
#[derive(Clone, Deserialize, Debug)]
5054
pub struct DataLayerProperties {
5155
#[serde(rename = "buffer-size")]
@@ -150,8 +154,8 @@ impl TileSource for TM2Source {
150154
});
151155

152156
let mut raw_tile: Vec<u8> = Vec::new();
153-
let mut stream = query.fetch(&mut conn);
154-
while let Some(row) = stream.next().await? {
157+
let results = query.fetch_all(&mut conn).await?;
158+
for row in results {
155159
let layer: Vec<u8> = row.get(0);
156160
raw_tile.extend_from_slice(&layer);
157161
}

0 commit comments

Comments
 (0)