diff --git a/ruma-api-macros/src/api.rs b/ruma-api-macros/src/api.rs index 88b0ba8c..d23271c3 100644 --- a/ruma-api-macros/src/api.rs +++ b/ruma-api-macros/src/api.rs @@ -30,10 +30,13 @@ pub fn strip_serde_attrs(field: &Field) -> Field { pub struct Api { /// The `metadata` section of the macro. metadata: Metadata, + /// The `request` section of the macro. request: Request, + /// The `response` section of the macro. response: Response, + /// The `error` section of the macro. error: TokenStream, } @@ -402,10 +405,13 @@ mod kw { pub struct RawApi { /// The `metadata` section of the macro. pub metadata: RawMetadata, + /// The `request` section of the macro. pub request: RawRequest, + /// The `response` section of the macro. pub response: RawResponse, + /// The `error` section of the macro. pub error: Option, } diff --git a/ruma-api-macros/src/api/attribute.rs b/ruma-api-macros/src/api/attribute.rs index 1d93eb97..da592a8e 100644 --- a/ruma-api-macros/src/api/attribute.rs +++ b/ruma-api-macros/src/api/attribute.rs @@ -10,6 +10,7 @@ use syn::{ pub struct MetaNameValue { /// The part left of the equals sign pub name: Ident, + /// The part right of the equals sign pub value: Ident, } @@ -18,6 +19,7 @@ pub struct MetaNameValue { pub enum Meta { /// A single word, like `query` in `#[ruma_api(query)]` Word(Ident), + /// A name-value pair, like `header = CONTENT_TYPE` in `#[ruma_api(header = CONTENT_TYPE)]` NameValue(MetaNameValue), } diff --git a/ruma-api-macros/src/api/metadata.rs b/ruma-api-macros/src/api/metadata.rs index 2226bae6..a95e60ed 100644 --- a/ruma-api-macros/src/api/metadata.rs +++ b/ruma-api-macros/src/api/metadata.rs @@ -10,14 +10,19 @@ use crate::{api::RawMetadata, util}; pub struct Metadata { /// The description field. pub description: LitStr, + /// The method field. pub method: Ident, + /// The name field. pub name: LitStr, + /// The path field. pub path: LitStr, + /// The rate_limited field. pub rate_limited: LitBool, + /// The authentication field. pub authentication: Ident, } diff --git a/ruma-api-macros/src/api/request.rs b/ruma-api-macros/src/api/request.rs index ba80a7c1..a7c5f031 100644 --- a/ruma-api-macros/src/api/request.rs +++ b/ruma-api-macros/src/api/request.rs @@ -540,16 +540,22 @@ impl ToTokens for Request { pub enum RequestField { /// JSON data in the body of the request. Body(Field), + /// Data in an HTTP header. Header(Field, Ident), + /// A specific data type in the body of the request. NewtypeBody(Field), + /// Arbitrary bytes in the body of the request. NewtypeRawBody(Field), + /// Data that appears in the URL path. Path(Field), + /// Data that appears in the query string. Query(Field), + /// Data that appears in the query string as dynamic key-value pairs. QueryMap(Field), } @@ -661,16 +667,22 @@ impl RequestField { enum RequestFieldKind { /// See the similarly named variant of `RequestField`. Body, + /// See the similarly named variant of `RequestField`. Header, + /// See the similarly named variant of `RequestField`. NewtypeBody, + /// See the similarly named variant of `RequestField`. NewtypeRawBody, + /// See the similarly named variant of `RequestField`. Path, + /// See the similarly named variant of `RequestField`. Query, + /// See the similarly named variant of `RequestField`. QueryMap, } diff --git a/ruma-api-macros/src/api/response.rs b/ruma-api-macros/src/api/response.rs index 7a3a4ce1..4bab4868 100644 --- a/ruma-api-macros/src/api/response.rs +++ b/ruma-api-macros/src/api/response.rs @@ -335,10 +335,13 @@ impl ToTokens for Response { pub enum ResponseField { /// JSON data in the body of the response. Body(Field), + /// Data in an HTTP header. Header(Field, Ident), + /// A specific data type in the body of the response. NewtypeBody(Field), + /// Arbitrary bytes in the body of the response. NewtypeRawBody(Field), } @@ -398,10 +401,13 @@ impl ResponseField { enum ResponseFieldKind { /// See the similarly named variant of `ResponseField`. Body, + /// See the similarly named variant of `ResponseField`. Header, + /// See the similarly named variant of `ResponseField`. NewtypeBody, + /// See the similarly named variant of `ResponseField`. NewtypeRawBody, } diff --git a/ruma-api/src/error.rs b/ruma-api/src/error.rs index 9a30ddc2..3aaa5cb4 100644 --- a/ruma-api/src/error.rs +++ b/ruma-api/src/error.rs @@ -95,6 +95,7 @@ impl RequestDeserializationError { pub enum FromHttpResponseError { /// Deserialization failed Deserialization(ResponseDeserializationError), + /// The server returned a non-success status Http(ServerError), } @@ -163,6 +164,7 @@ pub enum ServerError { /// An error that is expected to happen under certain circumstances and /// that has a well-defined structure Known(E), + /// An error of unexpected type of structure Unknown(ResponseDeserializationError), } diff --git a/ruma-api/src/lib.rs b/ruma-api/src/lib.rs index 02014d11..9220b8fa 100644 --- a/ruma-api/src/lib.rs +++ b/ruma-api/src/lib.rs @@ -285,11 +285,14 @@ pub trait IncomingNonAuthRequest: IncomingRequest {} pub enum AuthScheme { /// No authentication is performed. None, + /// Authentication is performed by including an access token in the request headers. AccessToken, + /// Authentication is performed by including X-Matrix signatures in the request headers, /// as defined in the federation API. ServerSignatures, + /// Authentication is performed by including an access token in the query parameters. QueryOnlyAccessToken, } diff --git a/ruma-client-api/src/r0/keys.rs b/ruma-client-api/src/r0/keys.rs index 3604ac17..e5136c2b 100644 --- a/ruma-client-api/src/r0/keys.rs +++ b/ruma-client-api/src/r0/keys.rs @@ -59,8 +59,10 @@ pub struct CrossSigningKey { pub enum KeyUsage { /// Master key. Master, + /// Self-signing key. SelfSigning, + /// User-signing key. UserSigning, } diff --git a/ruma-client-api/src/r0/typing/create_typing_event.rs b/ruma-client-api/src/r0/typing/create_typing_event.rs index 2714c29d..3aa39f0d 100644 --- a/ruma-client-api/src/r0/typing/create_typing_event.rs +++ b/ruma-client-api/src/r0/typing/create_typing_event.rs @@ -56,6 +56,7 @@ impl Response { pub enum Typing { /// Not typing. No, + /// Typing during the specified length of time. Yes(Duration), } diff --git a/ruma-client/src/error.rs b/ruma-client/src/error.rs index c8c0955f..046341aa 100644 --- a/ruma-client/src/error.rs +++ b/ruma-client/src/error.rs @@ -10,12 +10,16 @@ use ruma_api::error::{FromHttpResponseError, IntoHttpError}; pub enum Error { /// Queried endpoint requires authentication but was called on an anonymous client. AuthenticationRequired, + /// Construction of the HTTP request failed (this should never happen). IntoHttp(IntoHttpError), + /// The request's URL is invalid (this should never happen). Url(UrlError), + /// Couldn't obtain an HTTP response (e.g. due to network or DNS issues). Response(ResponseError), + /// Converting the HTTP response to one of ruma's types failed. FromHttpResponse(FromHttpResponseError), } diff --git a/ruma-client/src/lib.rs b/ruma-client/src/lib.rs index 5b1e49cc..a6d8ab24 100644 --- a/ruma-client/src/lib.rs +++ b/ruma-client/src/lib.rs @@ -142,8 +142,10 @@ pub struct Client(Arc); struct ClientData { /// The URL of the homeserver to connect to. homeserver_url: Uri, + /// The underlying HTTP client. hyper: HyperClient, + /// User session data. session: Mutex>, } diff --git a/ruma-client/src/session.rs b/ruma-client/src/session.rs index d77b83f8..0ea6be0f 100644 --- a/ruma-client/src/session.rs +++ b/ruma-client/src/session.rs @@ -7,6 +7,7 @@ use ruma_identifiers::{DeviceId, DeviceIdBox, UserId}; pub struct Session { /// The access token used for this session. pub access_token: String, + /// Identification information for a user pub identification: Option, } @@ -17,6 +18,7 @@ pub struct Session { pub struct Identification { /// The user the access token was issued for. pub user_id: UserId, + /// The ID of the client device pub device_id: DeviceIdBox, } diff --git a/ruma-common/src/push/condition/room_member_count_is.rs b/ruma-common/src/push/condition/room_member_count_is.rs index ca158124..a29d87ce 100644 --- a/ruma-common/src/push/condition/room_member_count_is.rs +++ b/ruma-common/src/push/condition/room_member_count_is.rs @@ -14,12 +14,16 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub enum ComparisonOperator { /// Equals Eq, + /// Less than Lt, + /// Greater than Gt, + /// Greater or equal Ge, + /// Less or equal Le, } @@ -60,6 +64,7 @@ impl Default for ComparisonOperator { pub struct RoomMemberCountIs { /// One of `==`, `<`, `>`, `>=`, `<=`, or no prefix. pub prefix: ComparisonOperator, + /// The number of people in the room. pub count: UInt, } diff --git a/ruma-common/src/thirdparty.rs b/ruma-common/src/thirdparty.rs index ab9e01ee..d42e6d4a 100644 --- a/ruma-common/src/thirdparty.rs +++ b/ruma-common/src/thirdparty.rs @@ -24,6 +24,7 @@ pub struct Protocol { /// A content URI representing an icon for the third party protocol. #[cfg(not(feature = "unstable-synapse-quirks"))] pub icon: String, + /// A content URI representing an icon for the third party protocol. #[cfg(feature = "unstable-synapse-quirks")] pub icon: Option, @@ -50,6 +51,7 @@ pub struct ProtocolInit { /// A content URI representing an icon for the third party protocol. #[cfg(not(feature = "unstable-synapse-quirks"))] pub icon: String, + /// A content URI representing an icon for the third party protocol. #[cfg(feature = "unstable-synapse-quirks")] pub icon: Option, diff --git a/ruma-events-macros/src/event_enum.rs b/ruma-events-macros/src/event_enum.rs index 12971c93..dba76d2e 100644 --- a/ruma-events-macros/src/event_enum.rs +++ b/ruma-events-macros/src/event_enum.rs @@ -503,6 +503,7 @@ fn expand_redacted_enum( pub enum #ident { /// An un-redacted event. Regular(#regular_enum_ident), + /// A redacted event. Redacted(#redacted_enum_ident), } diff --git a/ruma-events/src/enums.rs b/ruma-events/src/enums.rs index fb9fd1a6..42a6c991 100644 --- a/ruma-events/src/enums.rs +++ b/ruma-events/src/enums.rs @@ -94,14 +94,19 @@ event_enum! { pub enum AnyEvent { /// Any basic event. Basic(AnyBasicEvent), + /// Any ephemeral room event. Ephemeral(AnyEphemeralRoomEvent), + /// Any message event. Message(AnyMessageEvent), + /// Any state event. State(AnyStateEvent), + /// Any message event that has been redacted. RedactedMessage(AnyRedactedMessageEvent), + /// Any state event that has been redacted. RedactedState(AnyRedactedStateEvent), } @@ -112,10 +117,13 @@ pub enum AnyEvent { pub enum AnyRoomEvent { /// Any message event. Message(AnyMessageEvent), + /// Any state event. State(AnyStateEvent), + /// Any message event that has been redacted. RedactedMessage(AnyRedactedMessageEvent), + /// Any state event that has been redacted. RedactedState(AnyRedactedStateEvent), } @@ -126,10 +134,13 @@ pub enum AnyRoomEvent { pub enum AnySyncRoomEvent { /// Any sync message event Message(AnySyncMessageEvent), + /// Any sync state event State(AnySyncStateEvent), + /// Any sync message event that has been redacted. RedactedMessage(AnyRedactedSyncMessageEvent), + /// Any sync state event that has been redacted. RedactedState(AnyRedactedSyncStateEvent), } diff --git a/ruma-events/src/key/verification.rs b/ruma-events/src/key/verification.rs index f4af3d38..c5d9b38b 100644 --- a/ruma-events/src/key/verification.rs +++ b/ruma-events/src/key/verification.rs @@ -30,6 +30,7 @@ pub enum HashAlgorithm { pub enum KeyAgreementProtocol { /// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol. Curve25519, + /// The Curve25519 key agreement protocol with check for public keys. Curve25519HkdfSha256, } @@ -42,6 +43,7 @@ pub enum KeyAgreementProtocol { pub enum MessageAuthenticationCode { /// The HKDF-HMAC-SHA256 MAC. HkdfHmacSha256, + /// The HMAC-SHA256 MAC. HmacSha256, } diff --git a/ruma-events/src/lib.rs b/ruma-events/src/lib.rs index e9677d29..ac5dddb6 100644 --- a/ruma-events/src/lib.rs +++ b/ruma-events/src/lib.rs @@ -403,8 +403,10 @@ pub trait RedactedStateEventContent: RedactedEventContent {} pub enum HasDeserializeFields { /// Deserialize the event's content, failing if invalid. True, + /// Return the redacted version of this event's content. False, + /// `Optional` is used for `RedactedAliasesEventContent` since it has /// an empty version and one with content left after redaction that /// must be supported together. diff --git a/ruma-events/src/pdu.rs b/ruma-events/src/pdu.rs index 7c4c8889..5d95b66c 100644 --- a/ruma-events/src/pdu.rs +++ b/ruma-events/src/pdu.rs @@ -22,6 +22,7 @@ use serde_json::Value as JsonValue; pub enum Pdu { /// PDU for room versions 1 and 2. RoomV1Pdu(RoomV1Pdu), + /// PDU for room versions 3 and above. RoomV3Pdu(RoomV3Pdu), } diff --git a/ruma-events/src/room/member.rs b/ruma-events/src/room/member.rs index 7d54d67e..9a8bda96 100644 --- a/ruma-events/src/room/member.rs +++ b/ruma-events/src/room/member.rs @@ -155,6 +155,7 @@ pub enum MembershipChange { ProfileChanged { /// Whether the `displayname` changed. displayname_changed: bool, + /// Whether the `avatar_url` changed. avatar_url_changed: bool, }, diff --git a/ruma-identifiers-validation/src/error.rs b/ruma-identifiers-validation/src/error.rs index 1389a4c6..792be507 100644 --- a/ruma-identifiers-validation/src/error.rs +++ b/ruma-identifiers-validation/src/error.rs @@ -7,24 +7,33 @@ use std::fmt::{self, Display, Formatter}; pub enum Error { /// The room version ID is empty. EmptyRoomVersionId, + /// The ID's localpart contains invalid characters. /// /// Only relevant for user IDs. InvalidCharacters, + /// The key version contains outside of [a-zA-Z0-9_]. InvalidKeyVersion, + /// The server name part of the the ID string is not a valid server name. InvalidServerName, + /// The ID exceeds 255 bytes (or 32 codepoints for a room version ID). MaximumLengthExceeded, + /// The ID is missing the colon delimiter between localpart and server name. MissingDelimiter, + /// The ID is missing the colon delimiter between key algorithm and device ID. MissingDeviceKeyDelimiter, + /// The ID is missing the colon delimiter between key algorithm and version. MissingServerKeyDelimiter, + /// The ID is missing the correct leading sigil. MissingSigil, + /// The key algorithm is not recognized. UnknownKeyAlgorithm, } diff --git a/ruma-identifiers/src/user_id.rs b/ruma-identifiers/src/user_id.rs index ea3998d7..fd10739a 100644 --- a/ruma-identifiers/src/user_id.rs +++ b/ruma-identifiers/src/user_id.rs @@ -21,6 +21,7 @@ use crate::{Error, ServerName}; pub struct UserId { full_id: Box, colon_idx: NonZeroU8, + /// Whether this user id is a historical one. /// /// A historical user id is one that is not legal per the regular user id rules, but was diff --git a/ruma-push-gateway-api/src/send_event_notification/v1.rs b/ruma-push-gateway-api/src/send_event_notification/v1.rs index 604eb863..147b501e 100644 --- a/ruma-push-gateway-api/src/send_event_notification/v1.rs +++ b/ruma-push-gateway-api/src/send_event_notification/v1.rs @@ -144,6 +144,7 @@ impl<'a> Notification<'a> { pub enum NotificationPriority { /// A high priority notification High, + /// A low priority notification Low, } diff --git a/ruma-serde/src/canonical_json.rs b/ruma-serde/src/canonical_json.rs index 7aba15f1..6eec850a 100644 --- a/ruma-serde/src/canonical_json.rs +++ b/ruma-serde/src/canonical_json.rs @@ -25,8 +25,10 @@ pub fn to_string(val: &T) -> Result { pub enum Error { /// The numeric value failed conversion to js_int::Int. IntConvert, + /// The `CanonicalJsonValue` being serialized was larger than 65,535 bytes. JsonSize, + /// An error occurred while serializing/deserializing. SerDe(JsonError), } diff --git a/ruma-signatures/src/lib.rs b/ruma-signatures/src/lib.rs index 45d72c20..33ea30e2 100644 --- a/ruma-signatures/src/lib.rs +++ b/ruma-signatures/src/lib.rs @@ -134,8 +134,10 @@ impl Display for Algorithm { enum SplitError<'a> { /// The signature's ID does not have exactly two components separated by a colon. InvalidLength(usize), + /// The signature's ID contains invalid characters in its version. InvalidVersion(&'a str), + /// The signature uses an unknown algorithm. UnknownAlgorithm(&'a str), }