Improve consistency in docs

This commit is contained in:
Jonas Platte 2021-05-16 23:38:19 +02:00
parent d03a7363e6
commit 4dd9baa238
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
17 changed files with 27 additions and 27 deletions

View File

@ -56,7 +56,7 @@ pub struct PublicRoomsChunk {
} }
impl PublicRoomsChunk { impl PublicRoomsChunk {
/// Creates a `PublicRoomsChunk` with the given room ID. /// Creates a new `PublicRoomsChunk` with the given room ID.
/// ///
/// All other fields will be propagated with default values (an empty list of aliases, `None` /// All other fields will be propagated with default values (an empty list of aliases, `None`
/// for all `Option`al fields and `false` for all boolean fields), which should be overriden; /// for all `Option`al fields and `false` for all boolean fields), which should be overriden;

View File

@ -107,7 +107,7 @@ impl<'a> RoomEventFilter<'a> {
Self::default() Self::default()
} }
/// Creates a `RoomEventFilter` that can be used to ignore all room events. /// Creates a new `RoomEventFilter` that can be used to ignore all room events.
pub fn ignore_all() -> Self { pub fn ignore_all() -> Self {
Self { types: Some(&[]), ..Default::default() } Self { types: Some(&[]), ..Default::default() }
} }
@ -193,7 +193,7 @@ impl<'a> RoomFilter<'a> {
Self::default() Self::default()
} }
/// Creates a `RoomFilter` that can be used to ignore all room events (of any type). /// Creates a new `RoomFilter` that can be used to ignore all room events (of any type).
pub fn ignore_all() -> Self { pub fn ignore_all() -> Self {
Self { rooms: Some(&[]), ..Default::default() } Self { rooms: Some(&[]), ..Default::default() }
} }
@ -269,7 +269,7 @@ impl<'a> Filter<'a> {
Self::default() Self::default()
} }
/// Creates a `Filter` that can be used to ignore all events. /// Creates a new `Filter` that can be used to ignore all events.
pub fn ignore_all() -> Self { pub fn ignore_all() -> Self {
Self { types: Some(&[]), ..Default::default() } Self { types: Some(&[]), ..Default::default() }
} }
@ -337,7 +337,7 @@ impl<'a> FilterDefinition<'a> {
Self::default() Self::default()
} }
/// Creates a `FilterDefinition` that can be used to ignore all events. /// Creates a new `FilterDefinition` that can be used to ignore all events.
pub fn ignore_all() -> Self { pub fn ignore_all() -> Self {
Self { Self {
account_data: Filter::ignore_all(), account_data: Filter::ignore_all(),

View File

@ -96,14 +96,14 @@ ruma_api! {
} }
impl Request<'_> { impl Request<'_> {
/// Creates a `Request` will all-default parameters. /// Creates a new `Request` will all-default parameters.
pub fn new() -> Self { pub fn new() -> Self {
Default::default() Default::default()
} }
} }
impl Response { impl Response {
/// Creates a `Response` with the given room id. /// Creates a new `Response` with the given room id.
pub fn new(room_id: RoomId) -> Self { pub fn new(room_id: RoomId) -> Self {
Self { room_id } Self { room_id }
} }

View File

@ -67,7 +67,7 @@ pub enum LoginType {
} }
impl LoginType { impl LoginType {
/// Creates a `LoginType` with the given `login_type` string and data. /// Creates a new `LoginType` with the given `login_type` string and data.
/// ///
/// Prefer to use the public variants of `LoginType` where possible; this constructor is meant /// Prefer to use the public variants of `LoginType` where possible; this constructor is meant
/// be used for unsupported login types only and does not allow setting arbitrary data for /// be used for unsupported login types only and does not allow setting arbitrary data for

View File

@ -111,7 +111,7 @@ impl Request<'_> {
} }
impl Response { impl Response {
/// Creates a `Response` with the given batch token. /// Creates a new `Response` with the given batch token.
pub fn new(next_batch: String) -> Self { pub fn new(next_batch: String) -> Self {
Self { Self {
next_batch, next_batch,

View File

@ -37,7 +37,7 @@ impl Request {
} }
impl Response { impl Response {
/// Creates a `Response` with the given `HomeserverInfo`. /// Creates a new `Response` with the given `HomeserverInfo`.
pub fn new(homeserver: HomeserverInfo) -> Self { pub fn new(homeserver: HomeserverInfo) -> Self {
Self { homeserver, identity_server: None } Self { homeserver, identity_server: None }
} }
@ -52,7 +52,7 @@ pub struct HomeserverInfo {
} }
impl HomeserverInfo { impl HomeserverInfo {
/// Creates a `HomeserverInfo` with the given `base_url`. /// Creates a new `HomeserverInfo` with the given `base_url`.
pub fn new(base_url: String) -> Self { pub fn new(base_url: String) -> Self {
Self { base_url } Self { base_url }
} }

View File

@ -37,7 +37,7 @@ impl Request {
} }
impl Response { impl Response {
/// Creates a `Response` with the given `versions`. /// Creates a new `Response` with the given `versions`.
pub fn new(versions: Vec<String>) -> Self { pub fn new(versions: Vec<String>) -> Self {
Self { versions, unstable_features: BTreeMap::new() } Self { versions, unstable_features: BTreeMap::new() }
} }

View File

@ -11,8 +11,8 @@ use std::{
pub struct MilliSecondsSinceUnixEpoch(pub UInt); pub struct MilliSecondsSinceUnixEpoch(pub UInt);
impl MilliSecondsSinceUnixEpoch { impl MilliSecondsSinceUnixEpoch {
/// Creates a `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before the /// Creates a new `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before
/// unix epoch, or too large to be represented. /// the unix epoch, or too large to be represented.
pub fn from_system_time(time: SystemTime) -> Option<Self> { pub fn from_system_time(time: SystemTime) -> Option<Self> {
let duration = time.duration_since(UNIX_EPOCH).ok()?; let duration = time.duration_since(UNIX_EPOCH).ok()?;
let millis = duration.as_millis().try_into().ok()?; let millis = duration.as_millis().try_into().ok()?;
@ -24,7 +24,7 @@ impl MilliSecondsSinceUnixEpoch {
Self::from_system_time(SystemTime::now()).unwrap() Self::from_system_time(SystemTime::now()).unwrap()
} }
/// Creates a `SystemTime` from `self`, if it can be represented. /// Creates a new `SystemTime` from `self`, if it can be represented.
pub fn to_system_time(self) -> Option<SystemTime> { pub fn to_system_time(self) -> Option<SystemTime> {
UNIX_EPOCH.checked_add(Duration::from_millis(self.0.into())) UNIX_EPOCH.checked_add(Duration::from_millis(self.0.into()))
} }
@ -36,15 +36,15 @@ impl MilliSecondsSinceUnixEpoch {
pub struct SecondsSinceUnixEpoch(pub UInt); pub struct SecondsSinceUnixEpoch(pub UInt);
impl SecondsSinceUnixEpoch { impl SecondsSinceUnixEpoch {
/// Creates a `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before the /// Creates a new `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before
/// unix epoch, or too large to be represented. /// the unix epoch, or too large to be represented.
pub fn from_system_time(time: SystemTime) -> Option<Self> { pub fn from_system_time(time: SystemTime) -> Option<Self> {
let duration = time.duration_since(UNIX_EPOCH).ok()?; let duration = time.duration_since(UNIX_EPOCH).ok()?;
let millis = duration.as_secs().try_into().ok()?; let millis = duration.as_secs().try_into().ok()?;
Some(Self(millis)) Some(Self(millis))
} }
/// Creates a `SystemTime` from `self`, if it can be represented. /// Creates a new `SystemTime` from `self`, if it can be represented.
pub fn to_system_time(self) -> Option<SystemTime> { pub fn to_system_time(self) -> Option<SystemTime> {
UNIX_EPOCH.checked_add(Duration::from_secs(self.0.into())) UNIX_EPOCH.checked_add(Duration::from_secs(self.0.into()))
} }

View File

@ -535,7 +535,7 @@ mod tests {
#[test] #[test]
fn deserialization_failure() { fn deserialization_failure() {
// Ensure that invalid JSON creates a `serde_json::Error` and not `InvalidEvent` // Ensure that invalid JSON Creates a new `serde_json::Error` and not `InvalidEvent`
assert!(serde_json::from_str::<Raw<StartToDeviceEventContent>>("{").is_err()); assert!(serde_json::from_str::<Raw<StartToDeviceEventContent>>("{").is_err());
} }

View File

@ -197,7 +197,7 @@ pub enum MessageType {
} }
impl MessageType { impl MessageType {
/// Creates a `MessageType` with the given `msgtype` string and data. /// Creates a new `MessageType` with the given `msgtype` string and data.
/// ///
/// Prefer to use the public variants of `MessageType` where possible; this constructor is meant /// Prefer to use the public variants of `MessageType` where possible; this constructor is meant
/// be used for unsupported message types only and does not allow setting arbitrary data for /// be used for unsupported message types only and does not allow setting arbitrary data for

View File

@ -118,7 +118,7 @@ pub struct PowerLevelsEventContent {
} }
impl PowerLevelsEventContent { impl PowerLevelsEventContent {
/// Creates a `PowerLevelsEventContent` with all-default values. /// Creates a new `PowerLevelsEventContent` with all-default values.
pub fn new() -> Self { pub fn new() -> Self {
// events_default and users_default having a default of 0 while the others have a default // events_default and users_default having a default of 0 while the others have a default
// of 50 is not an oversight, these defaults are from the Matrix specification. // of 50 is not an oversight, these defaults are from the Matrix specification.

View File

@ -70,7 +70,7 @@ impl RedactionEventContent {
Self::default() Self::default()
} }
/// Creates a `RedactionEventContent` with the given reason. /// Creates a new `RedactionEventContent` with the given reason.
pub fn with_reason(reason: String) -> Self { pub fn with_reason(reason: String) -> Self {
Self { reason: Some(reason) } Self { reason: Some(reason) }
} }

View File

@ -42,7 +42,7 @@ ruma_api! {
} }
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a `Request` from the given room ID, event ID and `Pdu`. /// Creates a new `Request` from the given room ID, event ID and `Pdu`.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self { pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self {
Self { room_id, event_id, pdu } Self { room_id, event_id, pdu }
} }

View File

@ -41,7 +41,7 @@ ruma_api! {
} }
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a `Request` from the given room ID, event ID and `Pdu`. /// Creates a new `Request` from the given room ID, event ID and `Pdu`.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self { pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self {
Self { room_id, event_id, pdu } Self { room_id, event_id, pdu }
} }

View File

@ -36,7 +36,7 @@ ruma_api! {
} }
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a `Request` from the given room ID, event ID and `Pdu`. /// Creates a new `Request` from the given room ID, event ID and `Pdu`.
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self { pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu: Raw<Pdu>) -> Self {
Self { room_id, event_id, pdu } Self { room_id, event_id, pdu }
} }

View File

@ -18,7 +18,7 @@ pub struct KeyId<A, K: ?Sized> {
} }
impl<A, K: ?Sized> KeyId<A, K> { impl<A, K: ?Sized> KeyId<A, K> {
/// Creates a `KeyId` from an algorithm and key name. /// Creates a new `KeyId` from an algorithm and key name.
pub fn from_parts(algorithm: A, key_name: &K) -> Self pub fn from_parts(algorithm: A, key_name: &K) -> Self
where where
A: AsRef<str>, A: AsRef<str>,

View File

@ -40,7 +40,7 @@ ruma_api! {
} }
impl<'a> Request<'a> { impl<'a> Request<'a> {
/// Creates a `Request` with the given parameters. /// Creates a new `Request` with the given parameters.
pub fn new( pub fn new(
access_token: &'a str, access_token: &'a str,
token_type: TokenType, token_type: TokenType,