Improve consistency in docs
This commit is contained in:
parent
d03a7363e6
commit
4dd9baa238
@ -56,7 +56,7 @@ pub struct 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`
|
||||
/// for all `Option`al fields and `false` for all boolean fields), which should be overriden;
|
||||
|
@ -107,7 +107,7 @@ impl<'a> RoomEventFilter<'a> {
|
||||
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 {
|
||||
Self { types: Some(&[]), ..Default::default() }
|
||||
}
|
||||
@ -193,7 +193,7 @@ impl<'a> RoomFilter<'a> {
|
||||
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 {
|
||||
Self { rooms: Some(&[]), ..Default::default() }
|
||||
}
|
||||
@ -269,7 +269,7 @@ impl<'a> Filter<'a> {
|
||||
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 {
|
||||
Self { types: Some(&[]), ..Default::default() }
|
||||
}
|
||||
@ -337,7 +337,7 @@ impl<'a> FilterDefinition<'a> {
|
||||
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 {
|
||||
Self {
|
||||
account_data: Filter::ignore_all(),
|
||||
|
@ -96,14 +96,14 @@ ruma_api! {
|
||||
}
|
||||
|
||||
impl Request<'_> {
|
||||
/// Creates a `Request` will all-default parameters.
|
||||
/// Creates a new `Request` will all-default parameters.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
Self { room_id }
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ pub enum 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
|
||||
/// be used for unsupported login types only and does not allow setting arbitrary data for
|
||||
|
@ -111,7 +111,7 @@ impl Request<'_> {
|
||||
}
|
||||
|
||||
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 {
|
||||
Self {
|
||||
next_batch,
|
||||
|
@ -37,7 +37,7 @@ impl Request {
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a `Response` with the given `HomeserverInfo`.
|
||||
/// Creates a new `Response` with the given `HomeserverInfo`.
|
||||
pub fn new(homeserver: HomeserverInfo) -> Self {
|
||||
Self { homeserver, identity_server: None }
|
||||
}
|
||||
@ -52,7 +52,7 @@ pub struct 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 {
|
||||
Self { base_url }
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ impl Request {
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a `Response` with the given `versions`.
|
||||
/// Creates a new `Response` with the given `versions`.
|
||||
pub fn new(versions: Vec<String>) -> Self {
|
||||
Self { versions, unstable_features: BTreeMap::new() }
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ use std::{
|
||||
pub struct MilliSecondsSinceUnixEpoch(pub UInt);
|
||||
|
||||
impl MilliSecondsSinceUnixEpoch {
|
||||
/// Creates a `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before the
|
||||
/// unix epoch, or too large to be represented.
|
||||
/// Creates a new `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before
|
||||
/// the unix epoch, or too large to be represented.
|
||||
pub fn from_system_time(time: SystemTime) -> Option<Self> {
|
||||
let duration = time.duration_since(UNIX_EPOCH).ok()?;
|
||||
let millis = duration.as_millis().try_into().ok()?;
|
||||
@ -24,7 +24,7 @@ impl MilliSecondsSinceUnixEpoch {
|
||||
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> {
|
||||
UNIX_EPOCH.checked_add(Duration::from_millis(self.0.into()))
|
||||
}
|
||||
@ -36,15 +36,15 @@ impl MilliSecondsSinceUnixEpoch {
|
||||
pub struct SecondsSinceUnixEpoch(pub UInt);
|
||||
|
||||
impl SecondsSinceUnixEpoch {
|
||||
/// Creates a `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before the
|
||||
/// unix epoch, or too large to be represented.
|
||||
/// Creates a new `MilliSecondsSinceUnixEpoch` from the given `SystemTime`, if it is not before
|
||||
/// the unix epoch, or too large to be represented.
|
||||
pub fn from_system_time(time: SystemTime) -> Option<Self> {
|
||||
let duration = time.duration_since(UNIX_EPOCH).ok()?;
|
||||
let millis = duration.as_secs().try_into().ok()?;
|
||||
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> {
|
||||
UNIX_EPOCH.checked_add(Duration::from_secs(self.0.into()))
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ pub enum 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
|
||||
/// be used for unsupported message types only and does not allow setting arbitrary data for
|
||||
|
@ -118,7 +118,7 @@ pub struct PowerLevelsEventContent {
|
||||
}
|
||||
|
||||
impl PowerLevelsEventContent {
|
||||
/// Creates a `PowerLevelsEventContent` with all-default values.
|
||||
/// Creates a new `PowerLevelsEventContent` with all-default values.
|
||||
pub fn new() -> Self {
|
||||
// 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.
|
||||
|
@ -70,7 +70,7 @@ impl RedactionEventContent {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Creates a `RedactionEventContent` with the given reason.
|
||||
/// Creates a new `RedactionEventContent` with the given reason.
|
||||
pub fn with_reason(reason: String) -> Self {
|
||||
Self { reason: Some(reason) }
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
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 {
|
||||
Self { room_id, event_id, pdu }
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
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 {
|
||||
Self { room_id, event_id, pdu }
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
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 {
|
||||
Self { room_id, event_id, pdu }
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ pub struct KeyId<A, K: ?Sized> {
|
||||
}
|
||||
|
||||
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
|
||||
where
|
||||
A: AsRef<str>,
|
||||
|
@ -40,7 +40,7 @@ ruma_api! {
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a `Request` with the given parameters.
|
||||
/// Creates a new `Request` with the given parameters.
|
||||
pub fn new(
|
||||
access_token: &'a str,
|
||||
token_type: TokenType,
|
||||
|
Loading…
x
Reference in New Issue
Block a user