Update depedencies:

* contrib: 'rmp-serde', 'tera', 'memcache', 'mysql', 'postgres', 'redis'.
* examples: 'parking-lot', 'rand'
This commit is contained in:
Razican 2020-01-14 17:20:06 +01:00 committed by Jeb Rosen
parent ff2000293c
commit f4bb8bb511
7 changed files with 46 additions and 26 deletions

View File

@ -49,33 +49,33 @@ log = "0.4"
# Serialization and templating dependencies.
serde = { version = "1.0", optional = true }
serde_json = { version = "1.0.26", optional = true }
rmp-serde = { version = "^0.13", optional = true }
rmp-serde = { version = "0.14.0", optional = true }
# Templating dependencies.
handlebars = { version = "2.0", optional = true }
glob = { version = "0.3", optional = true }
tera = { version = "0.11", optional = true }
tera = { version = "1.0.2", optional = true }
# UUID dependencies.
uuid = { version = ">=0.7.0, <0.9.0", optional = true }
# Database dependencies
diesel = { version = "1.0", default-features = false, optional = true }
postgres = { version = "0.15", optional = true }
postgres = { version = "0.17", optional = true }
r2d2 = { version = "0.8", optional = true }
r2d2_postgres = { version = "0.14", optional = true }
mysql = { version = "16.0", optional = true }
r2d2_mysql = { version = "16.0", optional = true }
r2d2_postgres = { version = "0.16", optional = true }
mysql = { version = "17.0", optional = true }
r2d2_mysql = { version = "17.0", optional = true }
rusqlite = { version = "0.16.0", optional = true }
r2d2_sqlite = { version = "0.8", optional = true }
rusted_cypher = { version = "1", optional = true }
r2d2_cypher = { version = "0.4", optional = true }
redis = { version = "0.10", optional = true }
r2d2_redis = { version = "0.9", optional = true }
redis = { version = "0.13", optional = true }
r2d2_redis = { version = "0.12", optional = true }
mongodb = { version = "0.3.12", optional = true }
r2d2-mongodb = { version = "0.2.0", optional = true }
memcache = { version = "0.11", optional = true }
r2d2-memcache = { version = "0.3", optional = true }
memcache = { version = "0.14", optional = true }
r2d2-memcache = { version = "0.5", optional = true }
# SpaceHelmet dependencies
time = { version = "0.1.40", optional = true }

View File

@ -221,7 +221,7 @@
//! use rocket_contrib::databases::postgres;
//!
//! #[database("my_pg_db")]
//! struct MyPgDatabase(postgres::Connection);
//! struct MyPgDatabase(postgres::Client);
//! # }
//! ```
//!
@ -756,13 +756,15 @@ impl Poolable for diesel::MysqlConnection {
// TODO: Come up with a way to handle TLS
#[cfg(feature = "postgres_pool")]
impl Poolable for postgres::Connection {
type Manager = r2d2_postgres::PostgresConnectionManager;
impl Poolable for postgres::Client {
type Manager = r2d2_postgres::PostgresConnectionManager<postgres::tls::NoTls>;
type Error = DbError<postgres::Error>;
fn pool(config: DatabaseConfig<'_>) -> Result<r2d2::Pool<Self::Manager>, Self::Error> {
let manager = r2d2_postgres::PostgresConnectionManager::new(config.url, r2d2_postgres::TlsMode::None)
.map_err(DbError::Custom)?;
let manager = r2d2_postgres::PostgresConnectionManager::new(
config.url.parse().map_err(DbError::Custom)?,
postgres::tls::NoTls,
);
r2d2::Pool::builder().max_size(config.pool_size).build(manager)
.map_err(DbError::PoolError)

View File

@ -30,7 +30,7 @@ pub(crate) trait Engine: Send + Sync + 'static {
/// use rocket_contrib::templates::{Template, Engines};
/// use rocket_contrib::templates::tera::{self, Value};
///
/// fn my_filter(value: Value, _: HashMap<String, Value>) -> tera::Result<Value> {
/// fn my_filter(value: &Value, _: &HashMap<String, Value>) -> tera::Result<Value> {
/// # /*
/// ...
/// # */ unimplemented!();

View File

@ -1,8 +1,9 @@
use serde::Serialize;
use std::error::Error;
use crate::templates::{Engine, TemplateInfo};
pub use crate::templates::tera::Tera;
pub use crate::templates::tera::{Context, Tera};
impl Engine for Tera {
const EXT: &'static str = "tera";
@ -21,8 +22,11 @@ impl Engine for Tera {
// Finally try to tell Tera about all of the templates.
if let Err(e) = tera.add_template_files(tera_templates) {
error!("Failed to initialize Tera templating.");
for error in e.iter() {
info_!("{}", error);
let mut error = Some(&e as &dyn Error);
while let Some(err) = error {
info_!("{}", err);
error = err.source();
}
None
@ -37,12 +41,26 @@ impl Engine for Tera {
return None;
};
match Tera::render(self, name, &context) {
let tera_ctx = match Context::from_serialize(context) {
Ok(ctx) => ctx,
Err(_) => {
error_!(
"Error generating context when rendering Tera template '{}'.",
name
);
return None;
}
};
match Tera::render(self, name, &tera_ctx) {
Ok(string) => Some(string),
Err(e) => {
error_!("Error rendering Tera template '{}'.", name);
for error in e.iter() {
error_!("{}", error);
let mut error = Some(&e as &dyn Error);
while let Some(err) = error {
error_!("{}", err);
error = err.source();
}
None

View File

@ -7,4 +7,4 @@ publish = false
[dependencies]
rocket = { path = "../../core/lib" }
rand = "0.6"
rand = "0.7"

View File

@ -15,8 +15,8 @@ diesel_migrations = "1.3"
log = "0.4"
[dev-dependencies]
parking_lot = { version = "0.8", features = ["nightly"] }
rand = "0.6"
parking_lot = { version = "0.10", features = ["nightly"] }
rand = "0.7"
[dependencies.rocket_contrib]
path = "../../contrib/lib"

View File

@ -83,7 +83,7 @@ fn test_toggle() {
fn test_many_insertions() {
const ITER: usize = 100;
let mut rng = thread_rng();
let rng = thread_rng();
run_test!(|client, conn| {
// Get the number of tasks initially.
let init_num = Task::all(&conn).len();