From 5861457f3bd39134199e11f1e0273e2bda5f9533 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sat, 30 May 2020 19:10:21 +0200 Subject: [PATCH] Remove diesel integration --- CHANGELOG.md | 5 ++++ Cargo.toml | 1 - src/diesel_integration.rs | 42 --------------------------------- src/event_id.rs | 5 ---- src/lib.rs | 7 ------ src/room_alias_id.rs | 5 ---- src/room_id.rs | 5 ---- src/room_id_or_room_alias_id.rs | 5 ---- src/room_version_id.rs | 4 ---- src/user_id.rs | 5 ---- 10 files changed, 5 insertions(+), 79 deletions(-) delete mode 100644 src/diesel_integration.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index be2aed48..6eb3c139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # [unreleased] +Breaking changes + +* Removed diesel integration. If you were using it, please comment on the corresponding issue: + https://github.com/ruma/ruma-identifiers/issues/22 + # 0.16.1 Bug fixes: diff --git a/Cargo.toml b/Cargo.toml index d19f2d69..9e40aac5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ rustdoc-args = ["--cfg", "docsrs"] default = ["serde"] [dependencies] -diesel = { version = "1.4.4", optional = true } either = { version = "1.5.3", optional = true } rand = { version = "0.7.3", optional = true } serde = { version = "1.0.106", optional = true } diff --git a/src/diesel_integration.rs b/src/diesel_integration.rs deleted file mode 100644 index 92194179..00000000 --- a/src/diesel_integration.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! Implements traits from Diesel, allowing identifiers to be used as database fields. - -use std::{convert::TryFrom, error::Error as StdError, io::Write}; - -use diesel::{ - backend::Backend, - deserialize::{FromSql, Result as DeserializeResult}, - serialize::{Output, Result as SerializeResult, ToSql}, - sql_types::Text, -}; - -macro_rules! diesel_impl { - ($name:ident) => { - impl ToSql for $crate::$name - where - DB: Backend, - { - fn to_sql(&self, out: &mut Output<'_, W, DB>) -> SerializeResult { - ToSql::::to_sql(self.as_ref(), out) - } - } - - impl FromSql for $crate::$name - where - String: FromSql, - DB: Backend, - { - fn from_sql(value: Option<&::RawValue>) -> DeserializeResult { - let string = >::from_sql(value)?; - Self::try_from(string.as_str()) - .map_err(|error| Box::new(error) as Box) - } - } - }; -} - -diesel_impl!(EventId); -diesel_impl!(RoomAliasId); -diesel_impl!(RoomId); -diesel_impl!(RoomIdOrAliasId); -diesel_impl!(RoomVersionId); -diesel_impl!(UserId); diff --git a/src/event_id.rs b/src/event_id.rs index d4b9811e..9cbfb259 100644 --- a/src/event_id.rs +++ b/src/event_id.rs @@ -2,9 +2,6 @@ use std::{borrow::Cow, convert::TryFrom, num::NonZeroU8}; -#[cfg(feature = "diesel")] -use diesel::sql_types::Text; - use crate::{error::Error, parse_id, validate_id}; /// A Matrix event ID. @@ -41,8 +38,6 @@ use crate::{error::Error, parse_id, validate_id}; /// ); /// ``` #[derive(Clone, Debug)] -#[cfg_attr(feature = "diesel", derive(FromSqlRow, QueryId, AsExpression, SqlType))] -#[cfg_attr(feature = "diesel", sql_type = "Text")] pub struct EventId { full_id: Box, colon_idx: Option, diff --git a/src/lib.rs b/src/lib.rs index 1f044b51..16b6dea6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,10 +11,6 @@ #![allow(clippy::use_self)] #![cfg_attr(docsrs, feature(doc_cfg))] -#[cfg(feature = "diesel")] -#[cfg_attr(feature = "diesel", macro_use)] -extern crate diesel; - use std::num::NonZeroU8; #[cfg(feature = "serde")] @@ -31,9 +27,6 @@ pub use crate::{ mod macros; pub mod device_id; -#[cfg(feature = "diesel")] -#[cfg_attr(docsrs, doc(cfg(feature = "diesel")))] -mod diesel_integration; mod error; mod event_id; mod room_alias_id; diff --git a/src/room_alias_id.rs b/src/room_alias_id.rs index dacce28e..a6e873eb 100644 --- a/src/room_alias_id.rs +++ b/src/room_alias_id.rs @@ -2,9 +2,6 @@ use std::{borrow::Cow, convert::TryFrom, num::NonZeroU8}; -#[cfg(feature = "diesel")] -use diesel::sql_types::Text; - use crate::{error::Error, parse_id}; /// A Matrix room alias ID. @@ -21,8 +18,6 @@ use crate::{error::Error, parse_id}; /// ); /// ``` #[derive(Clone, Debug)] -#[cfg_attr(feature = "diesel", derive(FromSqlRow, QueryId, AsExpression, SqlType))] -#[cfg_attr(feature = "diesel", sql_type = "Text")] pub struct RoomAliasId { pub(crate) full_id: Box, pub(crate) colon_idx: NonZeroU8, diff --git a/src/room_id.rs b/src/room_id.rs index c349ee84..ed120543 100644 --- a/src/room_id.rs +++ b/src/room_id.rs @@ -2,9 +2,6 @@ use std::{borrow::Cow, convert::TryFrom, num::NonZeroU8}; -#[cfg(feature = "diesel")] -use diesel::sql_types::Text; - use crate::{error::Error, parse_id}; /// A Matrix room ID. @@ -21,8 +18,6 @@ use crate::{error::Error, parse_id}; /// ); /// ``` #[derive(Clone, Debug)] -#[cfg_attr(feature = "diesel", derive(FromSqlRow, QueryId, AsExpression, SqlType))] -#[cfg_attr(feature = "diesel", sql_type = "Text")] pub struct RoomId { pub(crate) full_id: Box, pub(crate) colon_idx: NonZeroU8, diff --git a/src/room_id_or_room_alias_id.rs b/src/room_id_or_room_alias_id.rs index 7b356d4a..82787e6b 100644 --- a/src/room_id_or_room_alias_id.rs +++ b/src/room_id_or_room_alias_id.rs @@ -2,9 +2,6 @@ use std::{borrow::Cow, convert::TryFrom, hint::unreachable_unchecked, num::NonZeroU8}; -#[cfg(feature = "diesel")] -use diesel::sql_types::Text; - use crate::{error::Error, parse_id, RoomAliasId, RoomId}; /// A Matrix room ID or a Matrix room alias ID. @@ -27,8 +24,6 @@ use crate::{error::Error, parse_id, RoomAliasId, RoomId}; /// ); /// ``` #[derive(Clone, Debug)] -#[cfg_attr(feature = "diesel", derive(FromSqlRow, QueryId, AsExpression, SqlType))] -#[cfg_attr(feature = "diesel", sql_type = "Text")] pub struct RoomIdOrAliasId { full_id: Box, colon_idx: NonZeroU8, diff --git a/src/room_version_id.rs b/src/room_version_id.rs index 216b59f0..2c4337d3 100644 --- a/src/room_version_id.rs +++ b/src/room_version_id.rs @@ -6,8 +6,6 @@ use std::{ fmt::{self, Display, Formatter}, }; -#[cfg(feature = "diesel")] -use diesel::sql_types::Text; #[cfg(feature = "serde")] use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -27,8 +25,6 @@ const MAX_CODE_POINTS: usize = 32; /// assert_eq!(RoomVersionId::try_from("1").unwrap().as_ref(), "1"); /// ``` #[derive(Clone, Debug, Eq, Hash, PartialEq)] -#[cfg_attr(feature = "diesel", derive(FromSqlRow, QueryId, AsExpression, SqlType))] -#[cfg_attr(feature = "diesel", sql_type = "Text")] pub struct RoomVersionId(InnerRoomVersionId); /// Possibile values for room version, distinguishing between official Matrix versions and custom diff --git a/src/user_id.rs b/src/user_id.rs index 43e499bd..e34e6627 100644 --- a/src/user_id.rs +++ b/src/user_id.rs @@ -2,9 +2,6 @@ use std::{borrow::Cow, convert::TryFrom, num::NonZeroU8}; -#[cfg(feature = "diesel")] -use diesel::sql_types::Text; - use crate::{error::Error, is_valid_server_name, parse_id}; /// A Matrix user ID. @@ -21,8 +18,6 @@ use crate::{error::Error, is_valid_server_name, parse_id}; /// ); /// ``` #[derive(Clone, Debug)] -#[cfg_attr(feature = "diesel", derive(FromSqlRow, QueryId, AsExpression, SqlType))] -#[cfg_attr(feature = "diesel", sql_type = "Text")] pub struct UserId { full_id: Box, colon_idx: NonZeroU8,