Clean up cargo features

This commit is contained in:
Jonas Platte 2021-02-02 19:12:46 +01:00
parent c692fe5565
commit 891db9083b
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
12 changed files with 44 additions and 67 deletions

View File

@ -22,4 +22,3 @@ serde_json = "1.0.61"
[features]
unstable-exhaustive-types = []
unstable-synapse-quirks = ["ruma-events/unstable-synapse-quirks"]

View File

@ -35,8 +35,4 @@ matches = "0.1.8"
[features]
unstable-exhaustive-types = []
unstable-pre-spec = ["ruma-common/unstable-pre-spec"]
unstable-synapse-quirks = [
"ruma-common/unstable-synapse-quirks",
"ruma-events/unstable-synapse-quirks",
]
unstable-pre-spec = []

View File

@ -54,8 +54,6 @@ tls-rustls-webpki-roots = [
"_tls-rustls",
]
unstable-synapse-quirks = ["ruma-events/unstable-synapse-quirks"]
# Internal, not meant to be used directly
_tls = []
_tls-rustls = ["_tls"]

View File

@ -22,6 +22,6 @@ serde_json = { version = "1.0.60", features = ["raw_value"] }
matches = "0.1.8"
[features]
compat = []
unstable-exhaustive-types = []
unstable-synapse-quirks = []
unstable-pre-spec = []

View File

@ -24,9 +24,9 @@ pub struct Protocol {
/// A content URI representing an icon for the third party protocol.
///
/// If you activate the `unstable-synapse-quirks` feature, this field being absent in JSON will
/// give you an empty string here.
#[cfg_attr(feature = "unstable-synapse-quirks", serde(default))]
/// If you activate the `compat` feature, this field being absent in JSON will give you an
/// empty string here.
#[cfg_attr(feature = "compat", serde(default))]
pub icon: String,
/// The type definitions for the fields defined in `user_fields` and `location_fields`.

View File

@ -29,11 +29,12 @@ ruma-identifiers = { version = "=0.18.0-alpha.1", path = "../ruma-identifiers",
trybuild = "1.0.38"
[features]
unstable-exhaustive-types = []
unstable-pre-spec = ["ruma-common/unstable-pre-spec"]
unstable-synapse-quirks = []
compat = []
markdown = ["pulldown-cmark"]
unstable-exhaustive-types = []
unstable-pre-spec = []
[[bench]]
name = "event_deserialize"
harness = false

View File

@ -17,10 +17,7 @@ pub type PowerLevelsEvent = StateEvent<PowerLevelsEventContent>;
#[ruma_event(type = "m.room.power_levels")]
pub struct PowerLevelsEventContent {
/// The level required to ban a user.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default = "default_power_level", skip_serializing_if = "is_default_power_level")]
#[ruma_event(skip_redaction)]
pub ban: Int,
@ -29,7 +26,7 @@ pub struct PowerLevelsEventContent {
///
/// This is a mapping from event type to power level required.
#[cfg_attr(
feature = "unstable-synapse-quirks",
feature = "compat",
serde(deserialize_with = "ruma_serde::btreemap_int_or_string_to_int_values")
)]
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
@ -37,45 +34,30 @@ pub struct PowerLevelsEventContent {
pub events: BTreeMap<EventType, Int>,
/// The default level required to send message events.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[ruma_event(skip_redaction)]
pub events_default: Int,
/// The level required to invite a user.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default = "default_power_level", skip_serializing_if = "is_default_power_level")]
pub invite: Int,
/// The level required to kick a user.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default = "default_power_level", skip_serializing_if = "is_default_power_level")]
#[ruma_event(skip_redaction)]
pub kick: Int,
/// The level required to redact an event.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default = "default_power_level", skip_serializing_if = "is_default_power_level")]
#[ruma_event(skip_redaction)]
pub redact: Int,
/// The default level required to send state events.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default = "default_power_level", skip_serializing_if = "is_default_power_level")]
#[ruma_event(skip_redaction)]
pub state_default: Int,
@ -84,7 +66,7 @@ pub struct PowerLevelsEventContent {
///
/// This is a mapping from `user_id` to power level for that user.
#[cfg_attr(
feature = "unstable-synapse-quirks",
feature = "compat",
serde(deserialize_with = "ruma_serde::btreemap_int_or_string_to_int_values")
)]
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
@ -92,10 +74,7 @@ pub struct PowerLevelsEventContent {
pub users: BTreeMap<UserId, Int>,
/// The default power level for every user in the room.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
#[ruma_event(skip_redaction)]
pub users_default: Int,
@ -130,10 +109,7 @@ impl Default for PowerLevelsEventContent {
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct NotificationPowerLevels {
/// The level required to trigger an `@room` notification.
#[cfg_attr(
feature = "unstable-synapse-quirks",
serde(deserialize_with = "ruma_serde::int_or_string_to_int")
)]
#[cfg_attr(feature = "compat", serde(deserialize_with = "ruma_serde::int_or_string_to_int"))]
#[serde(default = "default_power_level")]
pub room: Int,
}

View File

@ -17,15 +17,15 @@ pub type ThirdPartyInviteEvent = StateEvent<ThirdPartyInviteEventContent>;
#[ruma_event(type = "m.room.third_party_invite")]
pub struct ThirdPartyInviteEventContent {
/// A user-readable string which represents the user who has been invited.
#[cfg_attr(feature = "unstable-synapse-quirks", serde(default))]
#[cfg_attr(feature = "compat", serde(default))]
pub display_name: String,
/// A URL which can be fetched to validate whether the key has been revoked.
#[cfg_attr(feature = "unstable-synapse-quirks", serde(default))]
#[cfg_attr(feature = "compat", serde(default))]
pub key_validity_url: String,
/// A Base64-encoded Ed25519 key with which the token must be signed.
#[cfg_attr(feature = "unstable-synapse-quirks", serde(default))]
#[cfg_attr(feature = "compat", serde(default))]
pub public_key: String,
/// Keys with which the token may be signed.

View File

@ -15,7 +15,7 @@ pub type TombstoneEvent = StateEvent<TombstoneEventContent>;
#[ruma_event(type = "m.room.tombstone")]
pub struct TombstoneEventContent {
/// A server-defined message.
#[cfg_attr(feature = "unstable-synapse-quirks", serde(default))]
#[cfg_attr(feature = "compat", serde(default))]
pub body: String,
/// The new room the client should be visiting.

View File

@ -29,5 +29,4 @@ matches = "0.1.8"
[features]
unstable-exhaustive-types = []
unstable-pre-spec = ["ruma-common/unstable-pre-spec"]
unstable-synapse-quirks = ["ruma-events/unstable-synapse-quirks"]
unstable-pre-spec = []

View File

@ -22,4 +22,3 @@ serde_json = "1.0.61"
[features]
unstable-exhaustive-types = []
unstable-synapse-quirks = ["ruma-events/unstable-synapse-quirks"]

View File

@ -33,9 +33,6 @@ ruma-push-gateway-api = { version = "0.0.1", path = "../ruma-push-gateway-api",
serde = { version = "1.0.118", features = ["derive"] }
[features]
either = ["ruma-identifiers/either"]
rand = ["ruma-identifiers/rand"]
api = ["ruma-api"]
events = ["ruma-events"]
signatures = ["ruma-signatures"]
@ -46,22 +43,34 @@ federation-api = ["api", "signatures", "ruma-federation-api"]
identity-service-api = ["api", "ruma-identity-service-api"]
push-gateway-api = ["api", "ruma-push-gateway-api"]
# Concenience features
either = ["ruma-identifiers/either"]
rand = ["ruma-identifiers/rand"]
markdown = ["ruma-events/markdown"]
# Increase compatibility with other parts of the Matrix ecosystem, at the
# expense of weird behaviour where things deviate from the specification.
#
# For example, some mandatory string fields are defaulted to an empty string if
# missing with this feature.
compat = ["ruma-common/compat", "ruma-events/compat"]
# unstable: by using any of these, you opt out of all semver guarantees Ruma
# otherwise provides!
unstable-exhaustive-types = [
"ruma-common/unstable-exhaustive-types",
"ruma-events/unstable-exhaustive-types",
"ruma-appservice-api/unstable-exhaustive-types",
"ruma-client-api/unstable-exhaustive-types",
"ruma-federation-api/unstable-exhaustive-types",
"ruma-common/unstable-exhaustive-types",
"ruma-identity-service-api/unstable-exhaustive-types",
"ruma-push-gateway-api/unstable-exhaustive-types",
]
unstable-pre-spec = [
"ruma-common/unstable-pre-spec",
"ruma-client-api/unstable-pre-spec",
"ruma-events/unstable-pre-spec",
"ruma-federation-api/unstable-pre-spec",
"ruma-common/unstable-pre-spec",
#"ruma-identity-service-api/unstable-pre-spec",
#"ruma-push-gateway-api/unstable-pre-spec",
]
unstable-synapse-quirks = [
"ruma-client-api/unstable-synapse-quirks",
"ruma-common/unstable-synapse-quirks",
"ruma-events/unstable-synapse-quirks",
]
markdown = ["ruma-events/markdown"]