Be more consistent about whitespace

This commit is contained in:
Jonas Platte 2020-10-24 00:44:01 +02:00
parent 8ceb57ed1d
commit e1975c2035
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
25 changed files with 87 additions and 0 deletions

View File

@ -30,10 +30,13 @@ pub fn strip_serde_attrs(field: &Field) -> Field {
pub struct Api { pub struct Api {
/// The `metadata` section of the macro. /// The `metadata` section of the macro.
metadata: Metadata, metadata: Metadata,
/// The `request` section of the macro. /// The `request` section of the macro.
request: Request, request: Request,
/// The `response` section of the macro. /// The `response` section of the macro.
response: Response, response: Response,
/// The `error` section of the macro. /// The `error` section of the macro.
error: TokenStream, error: TokenStream,
} }
@ -402,10 +405,13 @@ mod kw {
pub struct RawApi { pub struct RawApi {
/// The `metadata` section of the macro. /// The `metadata` section of the macro.
pub metadata: RawMetadata, pub metadata: RawMetadata,
/// The `request` section of the macro. /// The `request` section of the macro.
pub request: RawRequest, pub request: RawRequest,
/// The `response` section of the macro. /// The `response` section of the macro.
pub response: RawResponse, pub response: RawResponse,
/// The `error` section of the macro. /// The `error` section of the macro.
pub error: Option<RawErrorType>, pub error: Option<RawErrorType>,
} }

View File

@ -10,6 +10,7 @@ use syn::{
pub struct MetaNameValue { pub struct MetaNameValue {
/// The part left of the equals sign /// The part left of the equals sign
pub name: Ident, pub name: Ident,
/// The part right of the equals sign /// The part right of the equals sign
pub value: Ident, pub value: Ident,
} }
@ -18,6 +19,7 @@ pub struct MetaNameValue {
pub enum Meta { pub enum Meta {
/// A single word, like `query` in `#[ruma_api(query)]` /// A single word, like `query` in `#[ruma_api(query)]`
Word(Ident), Word(Ident),
/// A name-value pair, like `header = CONTENT_TYPE` in `#[ruma_api(header = CONTENT_TYPE)]` /// A name-value pair, like `header = CONTENT_TYPE` in `#[ruma_api(header = CONTENT_TYPE)]`
NameValue(MetaNameValue), NameValue(MetaNameValue),
} }

View File

@ -10,14 +10,19 @@ use crate::{api::RawMetadata, util};
pub struct Metadata { pub struct Metadata {
/// The description field. /// The description field.
pub description: LitStr, pub description: LitStr,
/// The method field. /// The method field.
pub method: Ident, pub method: Ident,
/// The name field. /// The name field.
pub name: LitStr, pub name: LitStr,
/// The path field. /// The path field.
pub path: LitStr, pub path: LitStr,
/// The rate_limited field. /// The rate_limited field.
pub rate_limited: LitBool, pub rate_limited: LitBool,
/// The authentication field. /// The authentication field.
pub authentication: Ident, pub authentication: Ident,
} }

View File

@ -540,16 +540,22 @@ impl ToTokens for Request {
pub enum RequestField { pub enum RequestField {
/// JSON data in the body of the request. /// JSON data in the body of the request.
Body(Field), Body(Field),
/// Data in an HTTP header. /// Data in an HTTP header.
Header(Field, Ident), Header(Field, Ident),
/// A specific data type in the body of the request. /// A specific data type in the body of the request.
NewtypeBody(Field), NewtypeBody(Field),
/// Arbitrary bytes in the body of the request. /// Arbitrary bytes in the body of the request.
NewtypeRawBody(Field), NewtypeRawBody(Field),
/// Data that appears in the URL path. /// Data that appears in the URL path.
Path(Field), Path(Field),
/// Data that appears in the query string. /// Data that appears in the query string.
Query(Field), Query(Field),
/// Data that appears in the query string as dynamic key-value pairs. /// Data that appears in the query string as dynamic key-value pairs.
QueryMap(Field), QueryMap(Field),
} }
@ -661,16 +667,22 @@ impl RequestField {
enum RequestFieldKind { enum RequestFieldKind {
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
Body, Body,
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
Header, Header,
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
NewtypeBody, NewtypeBody,
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
NewtypeRawBody, NewtypeRawBody,
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
Path, Path,
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
Query, Query,
/// See the similarly named variant of `RequestField`. /// See the similarly named variant of `RequestField`.
QueryMap, QueryMap,
} }

View File

@ -335,10 +335,13 @@ impl ToTokens for Response {
pub enum ResponseField { pub enum ResponseField {
/// JSON data in the body of the response. /// JSON data in the body of the response.
Body(Field), Body(Field),
/// Data in an HTTP header. /// Data in an HTTP header.
Header(Field, Ident), Header(Field, Ident),
/// A specific data type in the body of the response. /// A specific data type in the body of the response.
NewtypeBody(Field), NewtypeBody(Field),
/// Arbitrary bytes in the body of the response. /// Arbitrary bytes in the body of the response.
NewtypeRawBody(Field), NewtypeRawBody(Field),
} }
@ -398,10 +401,13 @@ impl ResponseField {
enum ResponseFieldKind { enum ResponseFieldKind {
/// See the similarly named variant of `ResponseField`. /// See the similarly named variant of `ResponseField`.
Body, Body,
/// See the similarly named variant of `ResponseField`. /// See the similarly named variant of `ResponseField`.
Header, Header,
/// See the similarly named variant of `ResponseField`. /// See the similarly named variant of `ResponseField`.
NewtypeBody, NewtypeBody,
/// See the similarly named variant of `ResponseField`. /// See the similarly named variant of `ResponseField`.
NewtypeRawBody, NewtypeRawBody,
} }

View File

@ -95,6 +95,7 @@ impl RequestDeserializationError {
pub enum FromHttpResponseError<E> { pub enum FromHttpResponseError<E> {
/// Deserialization failed /// Deserialization failed
Deserialization(ResponseDeserializationError), Deserialization(ResponseDeserializationError),
/// The server returned a non-success status /// The server returned a non-success status
Http(ServerError<E>), Http(ServerError<E>),
} }
@ -163,6 +164,7 @@ pub enum ServerError<E> {
/// An error that is expected to happen under certain circumstances and /// An error that is expected to happen under certain circumstances and
/// that has a well-defined structure /// that has a well-defined structure
Known(E), Known(E),
/// An error of unexpected type of structure /// An error of unexpected type of structure
Unknown(ResponseDeserializationError), Unknown(ResponseDeserializationError),
} }

View File

@ -285,11 +285,14 @@ pub trait IncomingNonAuthRequest: IncomingRequest {}
pub enum AuthScheme { pub enum AuthScheme {
/// No authentication is performed. /// No authentication is performed.
None, None,
/// Authentication is performed by including an access token in the request headers. /// Authentication is performed by including an access token in the request headers.
AccessToken, AccessToken,
/// Authentication is performed by including X-Matrix signatures in the request headers, /// Authentication is performed by including X-Matrix signatures in the request headers,
/// as defined in the federation API. /// as defined in the federation API.
ServerSignatures, ServerSignatures,
/// Authentication is performed by including an access token in the query parameters. /// Authentication is performed by including an access token in the query parameters.
QueryOnlyAccessToken, QueryOnlyAccessToken,
} }

View File

@ -59,8 +59,10 @@ pub struct CrossSigningKey {
pub enum KeyUsage { pub enum KeyUsage {
/// Master key. /// Master key.
Master, Master,
/// Self-signing key. /// Self-signing key.
SelfSigning, SelfSigning,
/// User-signing key. /// User-signing key.
UserSigning, UserSigning,
} }

View File

@ -56,6 +56,7 @@ impl Response {
pub enum Typing { pub enum Typing {
/// Not typing. /// Not typing.
No, No,
/// Typing during the specified length of time. /// Typing during the specified length of time.
Yes(Duration), Yes(Duration),
} }

View File

@ -10,12 +10,16 @@ use ruma_api::error::{FromHttpResponseError, IntoHttpError};
pub enum Error<E> { pub enum Error<E> {
/// Queried endpoint requires authentication but was called on an anonymous client. /// Queried endpoint requires authentication but was called on an anonymous client.
AuthenticationRequired, AuthenticationRequired,
/// Construction of the HTTP request failed (this should never happen). /// Construction of the HTTP request failed (this should never happen).
IntoHttp(IntoHttpError), IntoHttp(IntoHttpError),
/// The request's URL is invalid (this should never happen). /// The request's URL is invalid (this should never happen).
Url(UrlError), Url(UrlError),
/// Couldn't obtain an HTTP response (e.g. due to network or DNS issues). /// Couldn't obtain an HTTP response (e.g. due to network or DNS issues).
Response(ResponseError), Response(ResponseError),
/// Converting the HTTP response to one of ruma's types failed. /// Converting the HTTP response to one of ruma's types failed.
FromHttpResponse(FromHttpResponseError<E>), FromHttpResponse(FromHttpResponseError<E>),
} }

View File

@ -142,8 +142,10 @@ pub struct Client(Arc<ClientData>);
struct ClientData { struct ClientData {
/// The URL of the homeserver to connect to. /// The URL of the homeserver to connect to.
homeserver_url: Uri, homeserver_url: Uri,
/// The underlying HTTP client. /// The underlying HTTP client.
hyper: HyperClient<Connector>, hyper: HyperClient<Connector>,
/// User session data. /// User session data.
session: Mutex<Option<Session>>, session: Mutex<Option<Session>>,
} }

View File

@ -7,6 +7,7 @@ use ruma_identifiers::{DeviceId, DeviceIdBox, UserId};
pub struct Session { pub struct Session {
/// The access token used for this session. /// The access token used for this session.
pub access_token: String, pub access_token: String,
/// Identification information for a user /// Identification information for a user
pub identification: Option<Identification>, pub identification: Option<Identification>,
} }
@ -17,6 +18,7 @@ pub struct Session {
pub struct Identification { pub struct Identification {
/// The user the access token was issued for. /// The user the access token was issued for.
pub user_id: UserId, pub user_id: UserId,
/// The ID of the client device /// The ID of the client device
pub device_id: DeviceIdBox, pub device_id: DeviceIdBox,
} }

View File

@ -14,12 +14,16 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
pub enum ComparisonOperator { pub enum ComparisonOperator {
/// Equals /// Equals
Eq, Eq,
/// Less than /// Less than
Lt, Lt,
/// Greater than /// Greater than
Gt, Gt,
/// Greater or equal /// Greater or equal
Ge, Ge,
/// Less or equal /// Less or equal
Le, Le,
} }
@ -60,6 +64,7 @@ impl Default for ComparisonOperator {
pub struct RoomMemberCountIs { pub struct RoomMemberCountIs {
/// One of `==`, `<`, `>`, `>=`, `<=`, or no prefix. /// One of `==`, `<`, `>`, `>=`, `<=`, or no prefix.
pub prefix: ComparisonOperator, pub prefix: ComparisonOperator,
/// The number of people in the room. /// The number of people in the room.
pub count: UInt, pub count: UInt,
} }

View File

@ -24,6 +24,7 @@ pub struct Protocol {
/// A content URI representing an icon for the third party protocol. /// A content URI representing an icon for the third party protocol.
#[cfg(not(feature = "unstable-synapse-quirks"))] #[cfg(not(feature = "unstable-synapse-quirks"))]
pub icon: String, pub icon: String,
/// A content URI representing an icon for the third party protocol. /// A content URI representing an icon for the third party protocol.
#[cfg(feature = "unstable-synapse-quirks")] #[cfg(feature = "unstable-synapse-quirks")]
pub icon: Option<String>, pub icon: Option<String>,
@ -50,6 +51,7 @@ pub struct ProtocolInit {
/// A content URI representing an icon for the third party protocol. /// A content URI representing an icon for the third party protocol.
#[cfg(not(feature = "unstable-synapse-quirks"))] #[cfg(not(feature = "unstable-synapse-quirks"))]
pub icon: String, pub icon: String,
/// A content URI representing an icon for the third party protocol. /// A content URI representing an icon for the third party protocol.
#[cfg(feature = "unstable-synapse-quirks")] #[cfg(feature = "unstable-synapse-quirks")]
pub icon: Option<String>, pub icon: Option<String>,

View File

@ -503,6 +503,7 @@ fn expand_redacted_enum(
pub enum #ident { pub enum #ident {
/// An un-redacted event. /// An un-redacted event.
Regular(#regular_enum_ident), Regular(#regular_enum_ident),
/// A redacted event. /// A redacted event.
Redacted(#redacted_enum_ident), Redacted(#redacted_enum_ident),
} }

View File

@ -94,14 +94,19 @@ event_enum! {
pub enum AnyEvent { pub enum AnyEvent {
/// Any basic event. /// Any basic event.
Basic(AnyBasicEvent), Basic(AnyBasicEvent),
/// Any ephemeral room event. /// Any ephemeral room event.
Ephemeral(AnyEphemeralRoomEvent), Ephemeral(AnyEphemeralRoomEvent),
/// Any message event. /// Any message event.
Message(AnyMessageEvent), Message(AnyMessageEvent),
/// Any state event. /// Any state event.
State(AnyStateEvent), State(AnyStateEvent),
/// Any message event that has been redacted. /// Any message event that has been redacted.
RedactedMessage(AnyRedactedMessageEvent), RedactedMessage(AnyRedactedMessageEvent),
/// Any state event that has been redacted. /// Any state event that has been redacted.
RedactedState(AnyRedactedStateEvent), RedactedState(AnyRedactedStateEvent),
} }
@ -112,10 +117,13 @@ pub enum AnyEvent {
pub enum AnyRoomEvent { pub enum AnyRoomEvent {
/// Any message event. /// Any message event.
Message(AnyMessageEvent), Message(AnyMessageEvent),
/// Any state event. /// Any state event.
State(AnyStateEvent), State(AnyStateEvent),
/// Any message event that has been redacted. /// Any message event that has been redacted.
RedactedMessage(AnyRedactedMessageEvent), RedactedMessage(AnyRedactedMessageEvent),
/// Any state event that has been redacted. /// Any state event that has been redacted.
RedactedState(AnyRedactedStateEvent), RedactedState(AnyRedactedStateEvent),
} }
@ -126,10 +134,13 @@ pub enum AnyRoomEvent {
pub enum AnySyncRoomEvent { pub enum AnySyncRoomEvent {
/// Any sync message event /// Any sync message event
Message(AnySyncMessageEvent), Message(AnySyncMessageEvent),
/// Any sync state event /// Any sync state event
State(AnySyncStateEvent), State(AnySyncStateEvent),
/// Any sync message event that has been redacted. /// Any sync message event that has been redacted.
RedactedMessage(AnyRedactedSyncMessageEvent), RedactedMessage(AnyRedactedSyncMessageEvent),
/// Any sync state event that has been redacted. /// Any sync state event that has been redacted.
RedactedState(AnyRedactedSyncStateEvent), RedactedState(AnyRedactedSyncStateEvent),
} }

View File

@ -30,6 +30,7 @@ pub enum HashAlgorithm {
pub enum KeyAgreementProtocol { pub enum KeyAgreementProtocol {
/// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol. /// The [Curve25519](https://cr.yp.to/ecdh.html) key agreement protocol.
Curve25519, Curve25519,
/// The Curve25519 key agreement protocol with check for public keys. /// The Curve25519 key agreement protocol with check for public keys.
Curve25519HkdfSha256, Curve25519HkdfSha256,
} }
@ -42,6 +43,7 @@ pub enum KeyAgreementProtocol {
pub enum MessageAuthenticationCode { pub enum MessageAuthenticationCode {
/// The HKDF-HMAC-SHA256 MAC. /// The HKDF-HMAC-SHA256 MAC.
HkdfHmacSha256, HkdfHmacSha256,
/// The HMAC-SHA256 MAC. /// The HMAC-SHA256 MAC.
HmacSha256, HmacSha256,
} }

View File

@ -403,8 +403,10 @@ pub trait RedactedStateEventContent: RedactedEventContent {}
pub enum HasDeserializeFields { pub enum HasDeserializeFields {
/// Deserialize the event's content, failing if invalid. /// Deserialize the event's content, failing if invalid.
True, True,
/// Return the redacted version of this event's content. /// Return the redacted version of this event's content.
False, False,
/// `Optional` is used for `RedactedAliasesEventContent` since it has /// `Optional` is used for `RedactedAliasesEventContent` since it has
/// an empty version and one with content left after redaction that /// an empty version and one with content left after redaction that
/// must be supported together. /// must be supported together.

View File

@ -22,6 +22,7 @@ use serde_json::Value as JsonValue;
pub enum Pdu { pub enum Pdu {
/// PDU for room versions 1 and 2. /// PDU for room versions 1 and 2.
RoomV1Pdu(RoomV1Pdu), RoomV1Pdu(RoomV1Pdu),
/// PDU for room versions 3 and above. /// PDU for room versions 3 and above.
RoomV3Pdu(RoomV3Pdu), RoomV3Pdu(RoomV3Pdu),
} }

View File

@ -155,6 +155,7 @@ pub enum MembershipChange {
ProfileChanged { ProfileChanged {
/// Whether the `displayname` changed. /// Whether the `displayname` changed.
displayname_changed: bool, displayname_changed: bool,
/// Whether the `avatar_url` changed. /// Whether the `avatar_url` changed.
avatar_url_changed: bool, avatar_url_changed: bool,
}, },

View File

@ -7,24 +7,33 @@ use std::fmt::{self, Display, Formatter};
pub enum Error { pub enum Error {
/// The room version ID is empty. /// The room version ID is empty.
EmptyRoomVersionId, EmptyRoomVersionId,
/// The ID's localpart contains invalid characters. /// The ID's localpart contains invalid characters.
/// ///
/// Only relevant for user IDs. /// Only relevant for user IDs.
InvalidCharacters, InvalidCharacters,
/// The key version contains outside of [a-zA-Z0-9_]. /// The key version contains outside of [a-zA-Z0-9_].
InvalidKeyVersion, InvalidKeyVersion,
/// The server name part of the the ID string is not a valid server name. /// The server name part of the the ID string is not a valid server name.
InvalidServerName, InvalidServerName,
/// The ID exceeds 255 bytes (or 32 codepoints for a room version ID). /// The ID exceeds 255 bytes (or 32 codepoints for a room version ID).
MaximumLengthExceeded, MaximumLengthExceeded,
/// The ID is missing the colon delimiter between localpart and server name. /// The ID is missing the colon delimiter between localpart and server name.
MissingDelimiter, MissingDelimiter,
/// The ID is missing the colon delimiter between key algorithm and device ID. /// The ID is missing the colon delimiter between key algorithm and device ID.
MissingDeviceKeyDelimiter, MissingDeviceKeyDelimiter,
/// The ID is missing the colon delimiter between key algorithm and version. /// The ID is missing the colon delimiter between key algorithm and version.
MissingServerKeyDelimiter, MissingServerKeyDelimiter,
/// The ID is missing the correct leading sigil. /// The ID is missing the correct leading sigil.
MissingSigil, MissingSigil,
/// The key algorithm is not recognized. /// The key algorithm is not recognized.
UnknownKeyAlgorithm, UnknownKeyAlgorithm,
} }

View File

@ -21,6 +21,7 @@ use crate::{Error, ServerName};
pub struct UserId { pub struct UserId {
full_id: Box<str>, full_id: Box<str>,
colon_idx: NonZeroU8, colon_idx: NonZeroU8,
/// Whether this user id is a historical one. /// 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 /// A historical user id is one that is not legal per the regular user id rules, but was

View File

@ -144,6 +144,7 @@ impl<'a> Notification<'a> {
pub enum NotificationPriority { pub enum NotificationPriority {
/// A high priority notification /// A high priority notification
High, High,
/// A low priority notification /// A low priority notification
Low, Low,
} }

View File

@ -25,8 +25,10 @@ pub fn to_string<T: Serialize>(val: &T) -> Result<String, Error> {
pub enum Error { pub enum Error {
/// The numeric value failed conversion to js_int::Int. /// The numeric value failed conversion to js_int::Int.
IntConvert, IntConvert,
/// The `CanonicalJsonValue` being serialized was larger than 65,535 bytes. /// The `CanonicalJsonValue` being serialized was larger than 65,535 bytes.
JsonSize, JsonSize,
/// An error occurred while serializing/deserializing. /// An error occurred while serializing/deserializing.
SerDe(JsonError), SerDe(JsonError),
} }

View File

@ -134,8 +134,10 @@ impl Display for Algorithm {
enum SplitError<'a> { enum SplitError<'a> {
/// The signature's ID does not have exactly two components separated by a colon. /// The signature's ID does not have exactly two components separated by a colon.
InvalidLength(usize), InvalidLength(usize),
/// The signature's ID contains invalid characters in its version. /// The signature's ID contains invalid characters in its version.
InvalidVersion(&'a str), InvalidVersion(&'a str),
/// The signature uses an unknown algorithm. /// The signature uses an unknown algorithm.
UnknownAlgorithm(&'a str), UnknownAlgorithm(&'a str),
} }