From 97551257a3a506ec23dfbc0f6e725b3b6720ef1a Mon Sep 17 00:00:00 2001 From: Ian Wagner Date: Thu, 18 Feb 2021 19:25:07 +0900 Subject: [PATCH] Upgrade to sqlx 0.5 --- Cargo.toml | 6 +++--- README.md | 3 ++- src/lib.rs | 28 +++++++++++++++++++++++++++- src/tm2.rs | 18 +++++++++++------- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 96d9716..767bd6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tile_sorcerer" -version = "0.2.0" +version = "0.3.0" authors = ["Ian Wagner ", "Luke Seelenbinder "] license = "BSD-3-Clause" repository = "https://github.com/stadiamaps/tile_sorcerer" @@ -22,9 +22,9 @@ version = "~1.0" features = ["derive"] [dependencies.sqlx] -version = "~0.3" +version = "~0.5" default-features = false -features = ["runtime-tokio", "postgres", "chrono", "uuid"] +features = ["runtime-tokio-rustls", "postgres", "chrono", "uuid", "tls"] [dev-dependencies] assert_approx_eq = "~1.1" diff --git a/README.md b/README.md index f669fdc..3d75f26 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Tools for modeling and querying vector tile sources. ## Current status -This code should be regarded as stable beta. While there are a number of +This crate should be regarded as stable in terms of code correctness, but not +yet stable in terms of trait and method signatures and feature set. While there are a number of known limitations, this code is being deployed at scale already. We are releasing this code in Rust tradition as 0.x until we feel the interface and feature set have stabilized, but welcome usage and contributions from diff --git a/src/lib.rs b/src/lib.rs index 0bce049..f0f4b05 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,32 @@ //! # Tile Sorcerer //! -//! This crate provides tools for modeling and querying vector tile sources. +//! Tools for modeling and querying vector tile sources. +//! +//! ## Current status +//! +//! This crate should be regarded as stable in terms of code reliability/correctness, but not +//! yet stable in terms of trait and method signatures. While there are a number of +//! known limitations, this code is being deployed at scale already. We are +//! releasing this code in Rust tradition as 0.x until we feel the interface +//! and feature set have stabilized, but welcome usage and contributions from +//! the Rust GIS community. +//! +//! ## Current features +//! +//! Given a PostGIS database and a TileMill source (such as OpenMapTiles data), +//! this crate will help you leverage PostGIS to render Mapbox Vector Tiles. +//! +//! ## Known Limitations +//! +//! The current focus is on high-performance rendering from a single PostGIS database. +//! Other formats are not presently supported, but can be added in the future. +//! As such, the database connection info present in layers is presently ignored, and +//! it is up to the calling application to set up a connection pool pointed at the right +//! database. Projection info is also currently ignored, and your database is assumed to be +//! in EPSG:3857 web mercator already. +//! +//! The trait-based design allows for further extensibility, so additional operations, +//! tile source formats, etc. will likely be added in the future. #![deny(warnings)] diff --git a/src/tm2.rs b/src/tm2.rs index 61af0c9..d9c9343 100644 --- a/src/tm2.rs +++ b/src/tm2.rs @@ -1,6 +1,7 @@ -/// TileMill Layer Source YAML Format -/// -/// Further reading: https://tilemill-project.github.io/tilemill/docs/manual/adding-layers/ +//! Data models and trait implementations for TileMill 2 yaml sources. +//! +//! Further reading: https://tilemill-project.github.io/tilemill/docs/manual/adding-layers/ + use crate::{get_epsg_3857_tile_bounds, TileSource}; use std::collections::HashMap; @@ -10,9 +11,9 @@ use serde::Deserialize; // TODO: remove once async fn in traits become stable use async_trait::async_trait; -use sqlx::{cursor::Cursor, query, PgPool, Row}; +use sqlx::{query, PgPool, Row}; -/// A TileMill (.tm2source) data structure. +/// The TileMill (.tm2source) data source model. /// /// Note: The current data structure is not entirely complete. See the /// crate README for limitations. @@ -31,6 +32,7 @@ pub struct TM2Source { pub bounds: [f64; 4], } +/// A single layer of a TM2Source #[derive(Clone, Deserialize, Debug)] pub struct DataLayer { pub id: String, @@ -40,12 +42,14 @@ pub struct DataLayer { // TODO: srs } +/// A `DataLayer`'s source details #[derive(Clone, Deserialize, Debug)] pub struct LayerSource { pub table: String, // TODO: Database connection parameters } +/// Additional properties of a `DataLayer` #[derive(Clone, Deserialize, Debug)] pub struct DataLayerProperties { #[serde(rename = "buffer-size")] @@ -150,8 +154,8 @@ impl TileSource for TM2Source { }); let mut raw_tile: Vec = Vec::new(); - let mut stream = query.fetch(&mut conn); - while let Some(row) = stream.next().await? { + let results = query.fetch_all(&mut conn).await?; + for row in results { let layer: Vec = row.get(0); raw_tile.extend_from_slice(&layer); }