Rewrap comments

This commit is contained in:
Jonas Platte 2020-11-27 18:22:18 +01:00
parent 6c4bd7c72c
commit e7f55ea2c6
No known key found for this signature in database
GPG key ID: CC154DE0E30B7C67
24 changed files with 130 additions and 129 deletions

View file

@ -1,4 +1,6 @@
comment_width = 100
edition = "2018"
merge_imports = true
newline_style = "Unix"
use_small_heuristics = "Max"
wrap_comments = true

View file

@ -53,48 +53,44 @@ use http::Method;
///
/// This will generate a `ruma_api::Metadata` value to be used for the `ruma_api::Endpoint`'s
/// associated constant, single `Request` and `Response` structs, and the necessary trait
/// implementations to convert the request into a `http::Request` and to create a response from a
/// `http::Response` and vice versa.
/// implementations to convert the request into a `http::Request` and to create a response from
/// a `http::Response` and vice versa.
///
/// The details of each of the three sections of the macros are documented below.
///
/// ## Metadata
///
/// * `description`: A short description of what the endpoint does.
/// * `method`: The HTTP method used for requests to the endpoint.
/// It's not necessary to import `http::Method`'s associated constants. Just write
/// the value as if it was imported, e.g. `GET`.
/// * `name`: A unique name for the endpoint.
/// Generally this will be the same as the containing module.
/// * `path`: The path component of the URL for the endpoint, e.g. "/foo/bar".
/// Components of the path that are parameterized can indicate a varible by using a Rust
/// identifier prefixed with a colon, e.g. `/foo/:some_parameter`.
/// A corresponding query string parameter will be expected in the request struct (see below
/// for details).
/// * `rate_limited`: Whether or not the endpoint enforces rate limiting on requests.
/// * `authentication`: What authentication scheme the endpoint uses.
/// * `description`: A short description of what the endpoint does.
/// * `method`: The HTTP method used for requests to the endpoint. It's not necessary to import
/// `http::Method`'s associated constants. Just write the value as if it was imported, e.g.
/// `GET`.
/// * `name`: A unique name for the endpoint. Generally this will be the same as the containing
/// module.
/// * `path`: The path component of the URL for the endpoint, e.g. "/foo/bar". Components of
/// the path that are parameterized can indicate a varible by using a Rust identifier
/// prefixed with a colon, e.g. `/foo/:some_parameter`. A corresponding query string
/// parameter will be expected in the request struct (see below for details).
/// * `rate_limited`: Whether or not the endpoint enforces rate limiting on requests.
/// * `authentication`: What authentication scheme the endpoint uses.
///
/// ## Request
///
/// The request block contains normal struct field definitions.
/// Doc comments and attributes are allowed as normal.
/// There are also a few special attributes available to control how the struct is converted into a
/// `http::Request`:
/// There are also a few special attributes available to control how the struct is converted
/// into a `http::Request`:
///
/// * `#[ruma_api(header = HEADER_NAME)]`: Fields with this attribute will be treated as HTTP
/// headers on the request.
/// The value must implement `AsRef<str>`.
/// Generally this is a `String`.
/// The attribute value shown above as `HEADER_NAME` must be a header name constant from
/// `http::header`, e.g. `CONTENT_TYPE`.
/// * `#[ruma_api(path)]`: Fields with this attribute will be inserted into the matching path
/// component of the request URL.
/// * `#[ruma_api(query)]`: Fields with this attribute will be inserting into the URL's query
/// string.
/// * `#[ruma_api(query_map)]`: Instead of individual query fields, one query_map field, of any
/// type that implements `IntoIterator<Item = (String, String)>` (e.g.
/// `HashMap<String, String>`, can be used for cases where an endpoint supports arbitrary query
/// parameters.
/// * `#[ruma_api(header = HEADER_NAME)]`: Fields with this attribute will be treated as HTTP
/// headers on the request. The value must implement `AsRef<str>`. Generally this is a
/// `String`. The attribute value shown above as `HEADER_NAME` must be a header name constant
/// from `http::header`, e.g. `CONTENT_TYPE`.
/// * `#[ruma_api(path)]`: Fields with this attribute will be inserted into the matching path
/// component of the request URL.
/// * `#[ruma_api(query)]`: Fields with this attribute will be inserting into the URL's query
/// string.
/// * `#[ruma_api(query_map)]`: Instead of individual query fields, one query_map field, of any
/// type that implements `IntoIterator<Item = (String, String)>` (e.g. `HashMap<String,
/// String>`, can be used for cases where an endpoint supports arbitrary query parameters.
///
/// Any field that does not include one of these attributes will be part of the request's JSON
/// body.
@ -106,12 +102,10 @@ use http::Method;
/// There is also a special attribute available to control how the struct is created from a
/// `http::Request`:
///
/// * `#[ruma_api(header = HEADER_NAME)]`: Fields with this attribute will be treated as HTTP
/// headers on the response.
/// The value must implement `AsRef<str>`.
/// Generally this is a `String`.
/// The attribute value shown above as `HEADER_NAME` must be a header name constant from
/// `http::header`, e.g. `CONTENT_TYPE`.
/// * `#[ruma_api(header = HEADER_NAME)]`: Fields with this attribute will be treated as HTTP
/// headers on the response. The value must implement `AsRef<str>`. Generally this is a
/// `String`. The attribute value shown above as `HEADER_NAME` must be a header name constant
/// from `http::header`, e.g. `CONTENT_TYPE`.
///
/// Any field that does not include the above attribute will be expected in the response's JSON
/// body.
@ -119,15 +113,15 @@ use http::Method;
/// ## Newtype bodies
///
/// Both the request and response block also support "newtype bodies" by using the
/// `#[ruma_api(body)]` attribute on a field. If present on a field, the entire request or response
/// body will be treated as the value of the field. This allows you to treat the entire request or
/// response body as a specific type, rather than a JSON object with named fields. Only one field in
/// each struct can be marked with this attribute. It is an error to have a newtype body field and
/// normal body fields within the same struct.
/// `#[ruma_api(body)]` attribute on a field. If present on a field, the entire request or
/// response body will be treated as the value of the field. This allows you to treat the
/// entire request or response body as a specific type, rather than a JSON object with named
/// fields. Only one field in each struct can be marked with this attribute. It is an error to
/// have a newtype body field and normal body fields within the same struct.
///
/// There is another kind of newtype body that is enabled with `#[ruma_api(raw_body)]`. It is used
/// for endpoints in which the request or response body can be arbitrary bytes instead of a JSON
/// objects. A field with `#[ruma_api(raw_body)]` needs to have the type `Vec<u8>`.
/// There is another kind of newtype body that is enabled with `#[ruma_api(raw_body)]`. It is
/// used for endpoints in which the request or response body can be arbitrary bytes instead of
/// a JSON objects. A field with `#[ruma_api(raw_body)]` needs to have the type `Vec<u8>`.
///
/// # Examples
///
@ -201,10 +195,11 @@ use http::Method;
///
/// ## Fallible deserialization
///
/// All request and response types also derive [`Outgoing`][Outgoing]. As such, to allow fallible
/// deserialization, you can use the `#[wrap_incoming]` attribute. For details, see the
/// documentation for [the derive macro](derive.Outgoing.html).
// TODO: Explain the concept of fallible deserialization before jumping to `ruma_common::Outgoing`
/// All request and response types also derive [`Outgoing`][Outgoing]. As such, to allow
/// fallible deserialization, you can use the `#[wrap_incoming]` attribute. For details, see
/// the documentation for [the derive macro](derive.Outgoing.html).
// TODO: Explain the concept of fallible deserialization before jumping to
// `ruma_common::Outgoing`
pub use ruma_api_macros::ruma_api;
pub mod error;

View file

@ -1,3 +1,4 @@
//! Endpoint to retrieve a list of Matrix portal rooms that lead to the matched third party location.
//! Endpoint to retrieve a list of Matrix portal rooms that lead to the matched third party
//! location.
pub mod v1;

View file

@ -1,3 +1,4 @@
//! Endpoint to present clients with specific information about the various third party networks that an application service supports.
//! Endpoint to present clients with specific information about the various third party networks
//! that an application service supports.
pub mod v1;

View file

@ -1,3 +1,4 @@
//! Endpoint to retrieve a Matrix User ID linked to a user on the third party network, given a set of user parameters.
//! Endpoint to retrieve a Matrix User ID linked to a user on the third party network, given a set
//! of user parameters.
pub mod v1;

View file

@ -23,8 +23,8 @@ pub enum ErrorKind {
/// M_UNKNOWN_TOKEN
UnknownToken {
/// If this is `true`, the client can acquire a new access token by specifying the device ID
/// it is already using to the login API. For more information, see [the spec].
/// If this is `true`, the client can acquire a new access token by specifying the device
/// ID it is already using to the login API. For more information, see [the spec].
///
/// [the spec]: https://matrix.org/docs/spec/client_server/r0.6.1#soft-logout
soft_logout: bool,

View file

@ -66,8 +66,8 @@ pub struct RoomEventFilter<'a> {
/// A list of sender IDs to exclude.
///
/// If this list is absent then no senders are excluded. A matching sender will be excluded even
/// if it is listed in the 'senders' filter.
/// If this list is absent then no senders are excluded. A matching sender will be excluded
/// even if it is listed in the 'senders' filter.
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
pub not_senders: &'a [UserId],
@ -79,8 +79,8 @@ pub struct RoomEventFilter<'a> {
/// A list of event types to include.
///
/// If this list is absent then all event types are included. A '*' can be used as a wildcard to
/// match any sequence of characters.
/// If this list is absent then all event types are included. A '*' can be used as a wildcard
/// to match any sequence of characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub types: Option<&'a [String]>,
@ -248,15 +248,15 @@ pub struct Filter<'a> {
/// A list of event types to include.
///
/// If this list is absent then all event types are included. A '*' can be used as a wildcard to
/// match any sequence of characters.
/// If this list is absent then all event types are included. A '*' can be used as a wildcard
/// to match any sequence of characters.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub types: Option<&'a [String]>,
/// A list of sender IDs to exclude.
///
/// If this list is absent then no senders are excluded. A matching sender will be excluded even
/// if it is listed in the 'senders' filter.
/// If this list is absent then no senders are excluded. A matching sender will be excluded
/// even if it is listed in the 'senders' filter.
#[serde(default, skip_serializing_if = "<[_]>::is_empty")]
pub not_senders: &'a [UserId],
}

View file

@ -125,8 +125,8 @@ impl Response {
pub enum Filter<'a> {
// The filter definition needs to be (de)serialized twice because it is a URL-encoded JSON
// string. Since #[ruma_api(query)] only does the latter and this is a very uncommon
// setup, we implement it through custom serde logic for this specific enum variant rather than
// adding another ruma_api attribute.
// setup, we implement it through custom serde logic for this specific enum variant rather
// than adding another ruma_api attribute.
//
// On the deserialization side, because this is an enum with #[serde(untagged)], serde will
// try the variants in order (https://serde.rs/enum-representations.html). That means because

View file

@ -23,8 +23,8 @@
//! ```
//!
//! You can also pass an existing session to the `Client` constructor to restore a previous session
//! rather than calling `log_in`. This can also be used to create a session for an application service
//! that does not need to log in, but uses the access_token directly:
//! rather than calling `log_in`. This can also be used to create a session for an application
//! service that does not need to log in, but uses the access_token directly:
//!
//! ```no_run
//! use ruma_client::{Client, Session};

View file

@ -12,8 +12,8 @@ pub struct Session {
pub identification: Option<Identification>,
}
/// The identification information about the associated user account if the session is associated with
/// a single user account.
/// The identification information about the associated user account if the session is associated
/// with a single user account.
#[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)]
pub struct Identification {
/// The user the access token was issued for.

View file

@ -31,8 +31,8 @@ pub enum Action {
pub enum Tweak {
/// A string representing the sound to be played when this notification arrives.
///
/// A value of "default" means to play a default sound. A device may choose to alert the user by
/// some other means if appropriate, eg. vibration.
/// A value of "default" means to play a default sound. A device may choose to alert the user
/// by some other means if appropriate, eg. vibration.
Sound(String),
/// A boolean representing whether or not this message should be highlighted in the UI.
@ -40,8 +40,8 @@ pub enum Tweak {
/// This will normally take the form of presenting the message in a different color and/or
/// style. The UI might also be adjusted to draw particular attention to the room in which the
/// event occurred. If a `highlight` tweak is given with no value, its value is defined to be
/// `true`. If no highlight tweak is given at all then the value of `highlight` is defined to be
/// `false`.
/// `true`. If no highlight tweak is given at all then the value of `highlight` is defined to
/// be `false`.
Highlight(#[serde(default = "ruma_serde::default_true")] bool),
/// A custom tweak

View file

@ -16,8 +16,8 @@ pub enum PushCondition {
/// The glob-style pattern to match against.
///
/// Patterns with no special glob characters should be treated as having asterisks prepended
/// and appended when testing the condition.
/// Patterns with no special glob characters should be treated as having asterisks
/// prepended and appended when testing the condition.
pattern: String,
},

View file

@ -43,8 +43,8 @@ impl Ruleset {
/// Default override push rules
impl ConditionalPushRule {
/// Matches all events, this can be enabled to turn off all push
/// notifications other than those generated by override rules set by the user.
/// Matches all events, this can be enabled to turn off all push notifications other than those
/// generated by override rules set by the user.
pub fn master() -> Self {
Self {
actions: vec![DontNotify],
@ -99,8 +99,8 @@ impl ConditionalPushRule {
}
}
/// Matches any message whose content is unencrypted and contains the user's
/// current display name in the room in which it was sent.
/// Matches any message whose content is unencrypted and contains the user's current display
/// name in the room in which it was sent.
pub fn contains_display_name() -> Self {
Self {
actions: vec![
@ -131,8 +131,8 @@ impl ConditionalPushRule {
}
}
/// Matches any message whose content is unencrypted and contains the
/// text `@room`, signifying the whole room should be notified of the event.
/// Matches any message whose content is unencrypted and contains the text `@room`, signifying
/// the whole room should be notified of the event.
pub fn roomnotif() -> Self {
Self {
actions: vec![Notify, SetTweak(Tweak::Highlight(true))],
@ -149,8 +149,8 @@ impl ConditionalPushRule {
/// Default content push rules
impl PatternedPushRule {
/// Matches any message whose content is unencrypted and contains
/// the local part of the user's Matrix ID, separated by word boundaries.
/// Matches any message whose content is unencrypted and contains the local part of the user's
/// Matrix ID, separated by word boundaries.
pub fn contains_user_name(user_id: &UserId) -> Self {
Self {
rule_id: ".m.rules.contains_user_name".into(),
@ -183,12 +183,10 @@ impl ConditionalPushRule {
}
}
/// Matches any encrypted event sent in a room with exactly
/// two members. Unlike other push rules, this rule cannot be
/// matched against the content of the event by nature of it
/// being encrypted. This causes the rule to be an "all or
/// nothing" match where it either matches all events that are
/// encrypted (in 1:1 rooms) or none.
/// Matches any encrypted event sent in a room with exactly two members. Unlike other push
/// rules, this rule cannot be matched against the content of the event by nature of it being
/// encrypted. This causes the rule to be an "all or nothing" match where it either matches all
/// events that are encrypted (in 1:1 rooms) or none.
pub fn encrypted_room_one_to_one() -> Self {
Self {
rule_id: ".m.rules.encrypted_room_one_to_one".into(),
@ -235,11 +233,10 @@ impl ConditionalPushRule {
}
}
/// Matches all encrypted events. Unlike other push rules,
/// this rule cannot be matched against the content of the
/// event by nature of it being encrypted. This causes the
/// rule to be an "all or nothing" match where it either matches
/// all events that are encrypted (in group rooms) or none.
/// Matches all encrypted events. Unlike other push rules, this rule cannot be matched against
/// the content of the event by nature of it being encrypted. This causes the rule to be an
/// "all or nothing" match where it either matches all events that are encrypted (in group
/// rooms) or none.
pub fn encrypted() -> Self {
Self {
rule_id: ".m.rules.encrypted".into(),

View file

@ -192,8 +192,8 @@ pub struct EventEnumInput {
///
/// This will generate the variants of the event type "name". There needs to be a corresponding
/// variant in `ruma_events::EventType` for this event (converted to a valid Rust-style type
/// name by stripping `m.`, replacing the remaining dots by underscores and then converting from
/// snake_case to CamelCase).
/// name by stripping `m.`, replacing the remaining dots by underscores and then converting
/// from snake_case to CamelCase).
pub events: Vec<EventEnumEntry>,
}

View file

@ -26,7 +26,7 @@ pub struct MacEventContent {
/// The MAC is encoded as unpadded Base64.
pub mac: BTreeMap<String, String>,
/// The MAC of the comma-separated, sorted, list of key IDs given in the `mac` property, encoded
/// as unpadded Base64.
/// The MAC of the comma-separated, sorted, list of key IDs given in the `mac` property,
/// encoded as unpadded Base64.
pub keys: String,
}

View file

@ -27,26 +27,25 @@
//! Matrix defines three "kinds" of events:
//!
//! 1. **Events**, which are arbitrary JSON structures that have two required keys:
//! * `type`, which specifies the event's type
//! * `content`, which is a JSON object containing the "payload" of the event
//! * `type`, which specifies the event's type
//! * `content`, which is a JSON object containing the "payload" of the event
//! 2. **Room events**, which are a superset of events and represent actions that occurred within
//! the context of a Matrix room.
//! They have at least the following additional keys:
//! * `event_id`, which is a unique identifier for the event
//! * `room_id`, which is a unique identifier for the room in which the event occurred
//! * `sender`, which is the unique identifier of the Matrix user who created the event
//! * Optionally, `unsigned`, which is a JSON object containing arbitrary additional metadata
//! * `event_id`, which is a unique identifier for the event
//! * `room_id`, which is a unique identifier for the room in which the event occurred
//! * `sender`, which is the unique identifier of the Matrix user who created the event
//! * Optionally, `unsigned`, which is a JSON object containing arbitrary additional metadata
//! that is not digitally signed by Matrix homeservers.
//! 3. **State events**, which are a superset of room events and represent persistent state
//! specific to a room, such as the room's member list or topic.
//! Within a single room, state events of the same type and with the same "state key" will
//! effectively "replace" the previous one, updating the room's state.
//! They have at least the following additional keys:
//! * `state_key`, a string which serves as a sort of "sub-type."
//! The state key allows a room to persist multiple state events of the same type.
//! You can think of a room's state events as being a `BTreeMap` where the keys are the
//! tuple `(event_type, state_key)`.
//! * Optionally, `prev_content`, a JSON object containing the `content` object from the
//! * `state_key`, a string which serves as a sort of "sub-type." The state key allows a room to
//! persist multiple state events of the same type. You can think of a room's state events as
//! being a `BTreeMap` where the keys are the tuple `(event_type, state_key)`.
//! * Optionally, `prev_content`, a JSON object containing the `content` object from the
//! previous event of the given `(event_type, state_key)` tuple in the given room.
//!
//! ruma-events represents these three event kinds as traits, allowing any Rust type to serve as a

View file

@ -11,7 +11,8 @@ pub mod user;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct PolicyRuleEventContent {
/// The entity affected by this rule. Glob characters * and ? can be used to match zero or more and one or more characters respectively.
/// The entity affected by this rule. Glob characters * and ? can be used to match zero or more
/// and one or more characters respectively.
pub entity: String,
/// The suggested action to take.

View file

@ -246,8 +246,9 @@ pub struct FileInfo {
/// The payload for an image message.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ImageMessageEventContent {
/// A textual representation of the image. This could be the alt text of the image, the filename
/// of the image, or some kind of content description for accessibility e.g. "image attachment."
/// A textual representation of the image. This could be the alt text of the image, the
/// filename of the image, or some kind of content description for accessibility e.g.
/// "image attachment."
pub body: String,
/// Metadata about the image referred to in `url`.
@ -267,8 +268,8 @@ pub struct ImageMessageEventContent {
/// The payload for a location message.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct LocationMessageEventContent {
/// A description of the location e.g. "Big Ben, London, UK,"or some kind of content description
/// for accessibility, e.g. "location attachment."
/// A description of the location e.g. "Big Ben, London, UK,"or some kind of content
/// description for accessibility, e.g. "location attachment."
pub body: String,
/// A geo URI representing the location.
@ -291,8 +292,8 @@ pub struct LocationInfo {
#[serde(skip_serializing_if = "Option::is_none")]
pub thumbnail_url: Option<String>,
/// Information on an encrypted thumbnail of the location being represented. Only present if the
/// thumbnail is encrypted.
/// Information on an encrypted thumbnail of the location being represented. Only present if
/// the thumbnail is encrypted.
#[serde(skip_serializing_if = "Option::is_none")]
pub thumbnail_file: Option<Box<EncryptedFile>>,
}

View file

@ -1,4 +1,5 @@
//! Endpoint to submits a signed leave event to the receiving server for it to accept it into the room's graph.
//! Endpoint to submits a signed leave event to the receiving server for it to accept it into the
//! room's graph.
pub mod v1;
pub mod v2;

View file

@ -1,3 +1,4 @@
//! Endpoint to asks the receiving server to return information that the sending server will need to prepare a leave event to get out of the room.
//! Endpoint to asks the receiving server to return information that the sending server will need
//! to prepare a leave event to get out of the room.
pub mod v1;

View file

@ -273,7 +273,8 @@ mod tweak_serde {
};
}
// If no highlight tweak is given at all then the value of highlight is defined to be false.
// If no highlight tweak is given at all then the value of highlight is defined to be
// false.
if !tweaks.iter().any(|tw| matches!(tw, Tweak::Highlight(_))) {
tweaks.push(Tweak::Highlight(false));
}

View file

@ -79,13 +79,13 @@ where
/// A deserializer for the `application/x-www-form-urlencoded` format.
///
/// * Supported top-level outputs are structs, maps and sequences of pairs,
/// with or without a given length.
/// * Supported top-level outputs are structs, maps and sequences of pairs, with or without a given
/// length.
///
/// * Main `deserialize` methods defers to `deserialize_map`.
///
/// * Everything else but `deserialize_seq` and `deserialize_seq_fixed_size`
/// defers to `deserialize`.
/// * Everything else but `deserialize_seq` and `deserialize_seq_fixed_size` defers to
/// `deserialize`.
pub struct Deserializer<'de> {
inner: MapDeserializer<'de, EntryIterator<'de>, Error>,
}

View file

@ -32,11 +32,11 @@ pub fn to_string<T: ser::Serialize>(input: T) -> Result<String, Error> {
/// A serializer for the `application/x-www-form-urlencoded` format.
///
/// * Supported top-level inputs are structs, maps and sequences of pairs,
/// with or without a given length.
/// * Supported top-level inputs are structs, maps and sequences of pairs, with or without a given
/// length.
///
/// * Supported keys and values are integers, bytes (if convertible to strings),
/// unit structs and unit variants.
/// * Supported keys and values are integers, bytes (if convertible to strings), unit structs and
/// unit variants.
///
/// * Newtype structs defer to their inner values.
pub struct Serializer<'input, 'output, Target: 'output + UrlEncodedTarget> {

View file

@ -34,9 +34,9 @@ impl Ed25519KeyPair {
/// # Parameters
///
/// * document: PKCS8-formatted bytes containing the private & public keys.
/// * version: The "version" of the key used for this signature.
/// Versions are used as an identifier to distinguish signatures generated from different keys
/// but using the same algorithm on the same homeserver.
/// * version: The "version" of the key used for this signature. Versions are used as an
/// identifier to distinguish signatures generated from different keys but using the same
/// algorithm on the same homeserver.
///
/// # Errors
///