[package]
name = "ruma"
categories = ["api-bindings", "web-programming"]
keywords = ["matrix", "chat", "messaging", "ruma"]
description = "Types and traits for working with the Matrix protocol."
homepage = "https://www.ruma.io/"
repository = "https://github.com/ruma/ruma"
readme = "README.md"
license = "MIT"
version = "0.9.0"
edition = "2021"
rust-version = { workspace = true }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
api = ["ruma-common/api"]
canonical-json = ["ruma-common/canonical-json", "ruma-events?/canonical-json"]
client = ["dep:ruma-client"]
events = ["dep:ruma-events"]
server-util = ["dep:ruma-server-util"]
signatures = ["dep:ruma-signatures", "canonical-json"]
state-res = ["dep:ruma-state-res"]

# ruma-client feature flags
client-ext-client-api = ["client", "ruma-client?/client-api"]
client-hyper = ["client", "ruma-client?/hyper"]
client-hyper-native-tls = ["client", "ruma-client?/hyper-native-tls"]
client-isahc = ["client", "ruma-client?/isahc"]
client-reqwest = ["client", "ruma-client?/reqwest"]
client-reqwest-native-tls = ["client", "ruma-client?/reqwest-native-tls"]
client-reqwest-native-tls-vendored = ["client", "ruma-client?/reqwest-native-tls-vendored"]
client-reqwest-rustls-manual-roots = ["client", "ruma-client?/reqwest-rustls-manual-roots"]
client-reqwest-rustls-webpki-roots = ["client", "ruma-client?/reqwest-rustls-webpki-roots"]
client-reqwest-rustls-native-roots = ["client", "ruma-client?/reqwest-rustls-native-roots"]

appservice-api-c = ["api", "events", "dep:ruma-appservice-api", "ruma-appservice-api?/client"]
appservice-api-s = ["api", "events", "dep:ruma-appservice-api", "ruma-appservice-api?/server"]
appservice-api = ["appservice-api-c", "appservice-api-s"]

client-api-c = ["api", "events", "dep:ruma-client-api", "ruma-client-api?/client"]
client-api-s = ["api", "events", "dep:ruma-client-api", "ruma-client-api?/server"]
client-api = ["client-api-c", "client-api-s"]

federation-api-c = ["api", "signatures", "dep:ruma-federation-api", "ruma-federation-api?/client"]
federation-api-s = ["api", "signatures", "dep:ruma-federation-api", "ruma-federation-api?/server"]
federation-api = ["federation-api-c", "federation-api-s"]

identity-service-api-c = [
    "api",
    "dep:ruma-identity-service-api",
    "ruma-identity-service-api?/client",
]
identity-service-api-s = [
    "api",
    "dep:ruma-identity-service-api",
    "ruma-identity-service-api?/server",
]
identity-service-api = ["identity-service-api-c", "identity-service-api-s"]

push-gateway-api-c = ["api", "dep:ruma-push-gateway-api", "ruma-push-gateway-api?/client"]
push-gateway-api-s = ["api", "dep:ruma-push-gateway-api", "ruma-push-gateway-api?/server"]
push-gateway-api = ["push-gateway-api-c", "push-gateway-api-s"]

# Required for randomness, current system time in browser environments
js = ["ruma-common/js"]

# Convenience features
rand = ["ruma-common/rand"]
markdown = ["ruma-events?/markdown"]
html = ["dep:ruma-html", "ruma-events?/html"]

# Everything except compat, js and unstable features
full = [
    "api",
    "client",
    "client-ext-client-api",
    "events",
    "signatures",
    "state-res",
    "appservice-api",
    "client-api",
    "federation-api",
    "identity-service-api",
    "push-gateway-api",
    "rand",
    "markdown",
    "html",
]

# Enable all compatibility hacks. Deprecated.
compat = [
    "compat-key-id",
    "compat-user-id",
    "compat-empty-string-null",
    "compat-null",
    "compat-optional",
    "compat-unset-avatar",
    "compat-get-3pids",
    "compat-signature-id",
    "compat-tag-info",
]

# Allow IDs to exceed 255 bytes.
compat-arbitrary-length-ids = ["ruma-common/compat-arbitrary-length-ids"]

# Don't validate the version part in `KeyId`.
compat-key-id = ["ruma-common/compat-key-id"]

# Allow some user IDs that are invalid even with the specified historical
# user ID scheme.
compat-user-id = ["ruma-common/compat-user-id"]

# Allow some mandatory fields in requests / responses to be missing, defaulting
# them to an empty string in deserialization.
compat-empty-string-null = [
    "ruma-common/compat-empty-string-null",
    "ruma-client-api?/compat-empty-string-null",
    "ruma-events?/compat-empty-string-null",
    "ruma-federation-api?/compat-empty-string-null",
]

# Allow certain fields to be `null` for compatibility, treating that the same as
# the field being absent.
compat-null = ["ruma-common/compat-null"]

# Allow certain fields to be absent even though the spec marks them as
# mandatory. Deserialization will yield a default value like an empty string.
compat-optional = [
    "ruma-common/compat-optional",
    "ruma-events?/compat-optional",
]

# Unset avatars by sending an empty string, same as what Element Web does, c.f.
# https://github.com/matrix-org/matrix-spec/issues/378#issuecomment-1055831264
compat-unset-avatar = ["ruma-client-api?/compat-unset-avatar"]

# Always serialize the threepids response field in `get_3pids::v3::Response`,
# even if its value is an empty list.
compat-get-3pids = ["ruma-client-api?/compat-get-3pids"]

# Accept `message` as an alias for `error` in `upload_signatures::v3::Failure`,
# since that's what Synapse sends.
compat-upload-signatures = ["ruma-client-api?/compat-upload-signatures"]

# Allow extra characters in signature IDs not allowed in the specification.
compat-signature-id = ["ruma-signatures?/compat-signature-id"]

# Allow TagInfo to contain a stringified floating-point value for the `order` field.
compat-tag-info = ["ruma-events?/compat-tag-info"]

# Specific compatibility for past ring public/private key documents.
ring-compat = ["dep:ruma-signatures", "ruma-signatures?/ring-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-appservice-api?/unstable-exhaustive-types",
    "ruma-client-api?/unstable-exhaustive-types",
    "ruma-federation-api?/unstable-exhaustive-types",
    "ruma-identity-service-api?/unstable-exhaustive-types",
    "ruma-push-gateway-api?/unstable-exhaustive-types",
    "ruma-state-res?/unstable-exhaustive-types",
    "ruma-events?/unstable-exhaustive-types"
]
unstable-extensible-events = [
    "unstable-msc3246",
    "unstable-msc3488",
    "unstable-msc3553",
    "unstable-msc3954",
    "unstable-msc3955",
]
unstable-msc1767 = ["ruma-events?/unstable-msc1767"]
unstable-msc2409 = ["ruma-appservice-api?/unstable-msc2409"]
unstable-msc2448 = [
    "ruma-client-api?/unstable-msc2448",
    "ruma-events?/unstable-msc2448",
    "ruma-federation-api?/unstable-msc2448"
]
unstable-msc2654 = ["ruma-client-api?/unstable-msc2654"]
unstable-msc2666 = ["ruma-client-api?/unstable-msc2666"]
unstable-msc2747 = ["ruma-events?/unstable-msc2747"]
unstable-msc2870 = ["ruma-common/unstable-msc2870"]
unstable-msc2965 = ["ruma-client-api?/unstable-msc2965"]
unstable-msc2967 = ["ruma-client-api?/unstable-msc2967"]
unstable-msc3061 = ["ruma-events?/unstable-msc3061"]
unstable-msc3202 = ["ruma-appservice-api?/unstable-msc3202"]
unstable-msc3245 = ["ruma-events?/unstable-msc3245"]
# Support the m.room.message fallback fields from the first version of MSC3245,
# implemented in Element Web and documented at
# https://github.com/matrix-org/matrix-spec-proposals/blob/83f6c5b469c1d78f714e335dcaa25354b255ffa5/proposals/3245-voice-messages.md
unstable-msc3245-v1-compat = ["ruma-events?/unstable-msc3245-v1-compat"]
unstable-msc3246 = ["ruma-events?/unstable-msc3246"]
unstable-msc3381 = ["ruma-events?/unstable-msc3381"]
unstable-msc3488 = ["ruma-client-api?/unstable-msc3488", "ruma-events?/unstable-msc3488"]
unstable-msc3551 = ["ruma-events?/unstable-msc3551"]
unstable-msc3552 = ["ruma-events?/unstable-msc3552"]
unstable-msc3553 = ["ruma-events?/unstable-msc3553"]
unstable-msc3554 = ["ruma-events?/unstable-msc3554"]
unstable-msc3575 = ["ruma-client-api?/unstable-msc3575"]
unstable-msc3618 = ["ruma-federation-api?/unstable-msc3618"]
unstable-msc3723 = ["ruma-federation-api?/unstable-msc3723"]
unstable-msc3814 = ["ruma-client-api?/unstable-msc3814"]
unstable-msc3927 = ["ruma-events?/unstable-msc3927"]
unstable-msc3930 = ["ruma-common/unstable-msc3930"]
unstable-msc3931 = ["ruma-common/unstable-msc3931"]
unstable-msc3932 = ["ruma-common/unstable-msc3932"]
unstable-msc3954 = ["ruma-events?/unstable-msc3954"]
unstable-msc3955 = ["ruma-events?/unstable-msc3955"]
unstable-msc3956 = ["ruma-events?/unstable-msc3956"]
unstable-msc3958 = ["ruma-common/unstable-msc3958"]
unstable-pdu = ["ruma-events?/unstable-pdu"]
unstable-unspecified = [
    "ruma-common/unstable-unspecified",
    "ruma-federation-api?/unstable-unspecified",
    "ruma-push-gateway-api?/unstable-unspecified",
]

# Private feature, only used in test / benchmarking code
__ci = [
    "full",
    "compat-upload-signatures",
    "unstable-unspecified",
    "unstable-msc1767",
    "unstable-msc2409",
    "unstable-msc2448",
    "unstable-msc2654",
    "unstable-msc2666",
    "unstable-msc2747",
    "unstable-msc2870",
    "unstable-msc2965",
    "unstable-msc2967",
    "unstable-msc3061",
    "unstable-msc3202",
    "unstable-msc3245",
    "unstable-msc3245-v1-compat",
    "unstable-msc3246",
    "unstable-msc3381",
    "unstable-msc3488",
    "unstable-msc3551",
    "unstable-msc3552",
    "unstable-msc3553",
    "unstable-msc3554",
    "unstable-msc3575",
    "unstable-msc3618",
    "unstable-msc3723",
    "unstable-msc3814",
    "unstable-msc3927",
    "unstable-msc3930",
    "unstable-msc3932",
    "unstable-msc3954",
    "unstable-msc3955",
    "unstable-msc3956",
    "unstable-msc3958",
]

[dependencies]
assign = { workspace = true }
js_int = { workspace = true }
js_option = "0.1.1"

ruma-common = { workspace = true }

ruma-client = { workspace = true, optional = true }
ruma-events = { workspace = true, optional = true }
ruma-html = { workspace = true, optional = true }
ruma-server-util = { workspace = true, optional = true }
ruma-signatures = { workspace = true, optional = true }
ruma-state-res = { workspace = true, optional = true }

ruma-appservice-api = { workspace = true, optional = true }
ruma-client-api = { workspace = true, optional = true }
ruma-federation-api = { workspace = true, optional = true }
ruma-identity-service-api = { workspace = true, optional = true }
ruma-push-gateway-api = { workspace = true, optional = true }

[dev-dependencies]
serde = { workspace = true }
