Be more consistent about whitespace
This commit is contained in:
parent
8ceb57ed1d
commit
e1975c2035
@ -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<RawErrorType>,
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ impl RequestDeserializationError {
|
||||
pub enum FromHttpResponseError<E> {
|
||||
/// Deserialization failed
|
||||
Deserialization(ResponseDeserializationError),
|
||||
|
||||
/// The server returned a non-success status
|
||||
Http(ServerError<E>),
|
||||
}
|
||||
@ -163,6 +164,7 @@ pub enum ServerError<E> {
|
||||
/// 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),
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -59,8 +59,10 @@ pub struct CrossSigningKey {
|
||||
pub enum KeyUsage {
|
||||
/// Master key.
|
||||
Master,
|
||||
|
||||
/// Self-signing key.
|
||||
SelfSigning,
|
||||
|
||||
/// User-signing key.
|
||||
UserSigning,
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ impl Response {
|
||||
pub enum Typing {
|
||||
/// Not typing.
|
||||
No,
|
||||
|
||||
/// Typing during the specified length of time.
|
||||
Yes(Duration),
|
||||
}
|
||||
|
@ -10,12 +10,16 @@ use ruma_api::error::{FromHttpResponseError, IntoHttpError};
|
||||
pub enum Error<E> {
|
||||
/// 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<E>),
|
||||
}
|
||||
|
@ -142,8 +142,10 @@ pub struct Client(Arc<ClientData>);
|
||||
struct ClientData {
|
||||
/// The URL of the homeserver to connect to.
|
||||
homeserver_url: Uri,
|
||||
|
||||
/// The underlying HTTP client.
|
||||
hyper: HyperClient<Connector>,
|
||||
|
||||
/// User session data.
|
||||
session: Mutex<Option<Session>>,
|
||||
}
|
||||
|
@ -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<Identification>,
|
||||
}
|
||||
@ -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,
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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<String>,
|
||||
@ -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<String>,
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -155,6 +155,7 @@ pub enum MembershipChange {
|
||||
ProfileChanged {
|
||||
/// Whether the `displayname` changed.
|
||||
displayname_changed: bool,
|
||||
|
||||
/// Whether the `avatar_url` changed.
|
||||
avatar_url_changed: bool,
|
||||
},
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ use crate::{Error, ServerName};
|
||||
pub struct UserId {
|
||||
full_id: Box<str>,
|
||||
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
|
||||
|
@ -144,6 +144,7 @@ impl<'a> Notification<'a> {
|
||||
pub enum NotificationPriority {
|
||||
/// A high priority notification
|
||||
High,
|
||||
|
||||
/// A low priority notification
|
||||
Low,
|
||||
}
|
||||
|
@ -25,8 +25,10 @@ pub fn to_string<T: Serialize>(val: &T) -> Result<String, Error> {
|
||||
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),
|
||||
}
|
||||
|
@ -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),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user