Rewrap docstrings and comments to 80 chars.
parent
ea149ebd8e
commit
62943f055d
|
@ -71,20 +71,20 @@ fn redaction_event_from_redaction_stub(
|
||||||
pub struct RoomName {
|
pub struct RoomName {
|
||||||
/// The displayed name of the room.
|
/// The displayed name of the room.
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
/// The canonical alias of the room ex. `#room-name:example.com` and port number.
|
/// The canonical alias of the room ex. `#room-name:example.com` and port
|
||||||
|
/// number.
|
||||||
canonical_alias: Option<RoomAliasId>,
|
canonical_alias: Option<RoomAliasId>,
|
||||||
/// List of `RoomAliasId`s the room has been given.
|
/// List of `RoomAliasId`s the room has been given.
|
||||||
aliases: Vec<RoomAliasId>,
|
aliases: Vec<RoomAliasId>,
|
||||||
/// Users which can be used to generate a room name if the room does not have
|
/// Users which can be used to generate a room name if the room does not
|
||||||
/// one. Required if room name or canonical aliases are not set or empty.
|
/// have one. Required if room name or canonical aliases are not set or
|
||||||
|
/// empty.
|
||||||
pub heroes: Vec<String>,
|
pub heroes: Vec<String>,
|
||||||
/// Number of users whose membership status is `join`.
|
/// Number of users whose membership status is `join`. Required if field
|
||||||
/// Required if field has changed since last sync; otherwise, it may be
|
/// has changed since last sync; otherwise, it may be omitted.
|
||||||
/// omitted.
|
|
||||||
pub joined_member_count: Option<UInt>,
|
pub joined_member_count: Option<UInt>,
|
||||||
/// Number of users whose membership status is `invite`.
|
/// Number of users whose membership status is `invite`. Required if field
|
||||||
/// Required if field has changed since last sync; otherwise, it may be
|
/// has changed since last sync; otherwise, it may be omitted.
|
||||||
/// omitted.
|
|
||||||
pub invited_member_count: Option<UInt>,
|
pub invited_member_count: Option<UInt>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ pub struct Room {
|
||||||
pub joined_members: HashMap<UserId, RoomMember>,
|
pub joined_members: HashMap<UserId, RoomMember>,
|
||||||
/// A queue of messages, holds no more than 10 of the most recent messages.
|
/// A queue of messages, holds no more than 10 of the most recent messages.
|
||||||
///
|
///
|
||||||
/// This is helpful when using a `StateStore` to avoid multiple requests
|
/// This is helpful when using a `StateStore` to avoid multiple requests to
|
||||||
/// to the server for messages.
|
/// the server for messages.
|
||||||
#[cfg(feature = "messages")]
|
#[cfg(feature = "messages")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))]
|
||||||
#[serde(with = "super::message::ser_deser")]
|
#[serde(with = "super::message::ser_deser")]
|
||||||
|
@ -221,8 +221,8 @@ impl RoomName {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculate the canonical display name of a room, taking into account its name, aliases and
|
/// Calculate the canonical display name of the room, taking into account
|
||||||
/// members.
|
/// its name, aliases and members.
|
||||||
///
|
///
|
||||||
/// The display name is calculated according to [this algorithm][spec].
|
/// The display name is calculated according to [this algorithm][spec].
|
||||||
///
|
///
|
||||||
|
@ -276,7 +276,8 @@ impl RoomName {
|
||||||
.collect::<Vec<String>>();
|
.collect::<Vec<String>>();
|
||||||
names.sort();
|
names.sort();
|
||||||
|
|
||||||
// TODO: What length does the spec want us to use here and in the `else`?
|
// TODO: What length does the spec want us to use here and in
|
||||||
|
// the `else`?
|
||||||
format!("{}, and {} others", names.join(", "), (joined + invited))
|
format!("{}, and {} others", names.join(", "), (joined + invited))
|
||||||
} else {
|
} else {
|
||||||
"Empty room".to_string()
|
"Empty room".to_string()
|
||||||
|
@ -335,14 +336,14 @@ impl Room {
|
||||||
|
|
||||||
/// Process the join or invite event for a new room member.
|
/// Process the join or invite event for a new room member.
|
||||||
///
|
///
|
||||||
/// This method should only be called on events which add new members, not those related to
|
/// This method should only be called on events which add new members, not
|
||||||
/// existing ones.
|
/// those related to existing ones.
|
||||||
///
|
///
|
||||||
/// Returns a tuple of:
|
/// Returns a tuple of:
|
||||||
///
|
///
|
||||||
/// 1. True if the event made changes to the room's state, false otherwise.
|
/// 1. True if the event made changes to the room's state, false otherwise.
|
||||||
/// 2. Returns a map of display name disambiguations which tells us which members need to have
|
/// 2. Returns a map of display name disambiguations which tells us which
|
||||||
/// their display names disambiguated and to what.
|
/// members need to have their display names disambiguated and to what.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
@ -395,8 +396,8 @@ impl Room {
|
||||||
/// Returns a tuple of:
|
/// Returns a tuple of:
|
||||||
///
|
///
|
||||||
/// 1. True if the event made changes to the room's state, false otherwise.
|
/// 1. True if the event made changes to the room's state, false otherwise.
|
||||||
/// 2. Returns a map of display name disambiguations which tells us which members need to have
|
/// 2. Returns a map of display name disambiguations which tells us which
|
||||||
/// their display names disambiguated and to what.
|
/// members need to have their display names disambiguated and to what.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
@ -432,7 +433,8 @@ impl Room {
|
||||||
(true, disambiguations)
|
(true, disambiguations)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether the user with the MXID `user_id` is joined or invited to the room.
|
/// Check whether the user with the MXID `user_id` is joined or invited to
|
||||||
|
/// the room.
|
||||||
///
|
///
|
||||||
/// Returns true if so, false otherwise.
|
/// Returns true if so, false otherwise.
|
||||||
pub fn member_is_tracked(&self, user_id: &UserId) -> bool {
|
pub fn member_is_tracked(&self, user_id: &UserId) -> bool {
|
||||||
|
@ -605,8 +607,8 @@ impl Room {
|
||||||
/// Returns a tuple of:
|
/// Returns a tuple of:
|
||||||
///
|
///
|
||||||
/// 1. True if the joined member list changed, false otherwise.
|
/// 1. True if the joined member list changed, false otherwise.
|
||||||
/// 2. A map of display name disambiguations which tells us which members need to have their
|
/// 2. A map of display name disambiguations which tells us which members
|
||||||
/// display names disambiguated and to what.
|
/// need to have their display names disambiguated and to what.
|
||||||
pub fn handle_membership(
|
pub fn handle_membership(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: &StateEventStub<MemberEventContent>,
|
event: &StateEventStub<MemberEventContent>,
|
||||||
|
@ -681,8 +683,9 @@ impl Room {
|
||||||
/// Handle a room.redaction event and update the `MessageQueue`.
|
/// Handle a room.redaction event and update the `MessageQueue`.
|
||||||
///
|
///
|
||||||
/// Returns true if `MessageQueue` was updated. The effected message event
|
/// Returns true if `MessageQueue` was updated. The effected message event
|
||||||
/// has it's contents replaced with the `RedactionEventContents` and the whole
|
/// has it's contents replaced with the `RedactionEventContents` and the
|
||||||
/// redaction event is added to the `Unsigned` `redacted_because` field.
|
/// whole redaction event is added to the `Unsigned` `redacted_because`
|
||||||
|
/// field.
|
||||||
#[cfg(feature = "messages")]
|
#[cfg(feature = "messages")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "messages")))]
|
||||||
pub fn handle_redaction(&mut self, event: &RedactionEventStub) -> bool {
|
pub fn handle_redaction(&mut self, event: &RedactionEventStub) -> bool {
|
||||||
|
@ -713,7 +716,8 @@ impl Room {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle a room.canonical_alias event, updating the room state if necessary.
|
/// Handle a room.canonical_alias event, updating the room state if
|
||||||
|
/// necessary.
|
||||||
///
|
///
|
||||||
/// Returns true if the room name changed, false otherwise.
|
/// Returns true if the room name changed, false otherwise.
|
||||||
pub fn handle_canonical(&mut self, event: &StateEventStub<CanonicalAliasEventContent>) -> bool {
|
pub fn handle_canonical(&mut self, event: &StateEventStub<CanonicalAliasEventContent>) -> bool {
|
||||||
|
@ -845,8 +849,8 @@ impl Room {
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `event` - The `AnyStrippedStateEvent` sent by the server for invited but not
|
/// * `event` - The `AnyStrippedStateEvent` sent by the server for invited
|
||||||
/// joined rooms.
|
/// but not joined rooms.
|
||||||
pub fn receive_stripped_state_event(&mut self, event: &AnyStrippedStateEventStub) -> bool {
|
pub fn receive_stripped_state_event(&mut self, event: &AnyStrippedStateEventStub) -> bool {
|
||||||
match event {
|
match event {
|
||||||
AnyStrippedStateEventStub::RoomName(event) => self.handle_stripped_room_name(event),
|
AnyStrippedStateEventStub::RoomName(event) => self.handle_stripped_room_name(event),
|
||||||
|
@ -856,7 +860,8 @@ impl Room {
|
||||||
|
|
||||||
/// Receive a presence event for a member of the current room.
|
/// Receive a presence event for a member of the current room.
|
||||||
///
|
///
|
||||||
/// Returns true if the event causes a change to the member's presence, false otherwise.
|
/// Returns true if the event causes a change to the member's presence,
|
||||||
|
/// false otherwise.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
@ -910,8 +915,8 @@ impl Room {
|
||||||
/// Returns a tuple of:
|
/// Returns a tuple of:
|
||||||
///
|
///
|
||||||
/// 1. True if the event made changes to the room's state, false otherwise.
|
/// 1. True if the event made changes to the room's state, false otherwise.
|
||||||
/// 2. A map of display name disambiguations which tells us which members need to have their
|
/// 2. A map of display name disambiguations which tells us which members
|
||||||
/// display names disambiguated and to what.
|
/// need to have their display names disambiguated and to what.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
|
|
@ -32,7 +32,8 @@ pub struct RoomMember {
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
/// The human readable name of the user.
|
/// The human readable name of the user.
|
||||||
pub display_name: Option<String>,
|
pub display_name: Option<String>,
|
||||||
/// Whether the member's display name is ambiguous due to being shared with other members.
|
/// Whether the member's display name is ambiguous due to being shared with
|
||||||
|
/// other members.
|
||||||
pub display_name_ambiguous: bool,
|
pub display_name_ambiguous: bool,
|
||||||
/// The matrix url of the users avatar.
|
/// The matrix url of the users avatar.
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
|
@ -102,8 +103,8 @@ impl RoomMember {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the most ergonomic (but potentially ambiguous/non-unique) name available for the
|
/// Returns the most ergonomic (but potentially ambiguous/non-unique) name
|
||||||
/// member.
|
/// available for the member.
|
||||||
///
|
///
|
||||||
/// This is the member's display name if it is set, otherwise their MXID.
|
/// This is the member's display name if it is set, otherwise their MXID.
|
||||||
pub fn name(&self) -> String {
|
pub fn name(&self) -> String {
|
||||||
|
@ -112,11 +113,11 @@ impl RoomMember {
|
||||||
.unwrap_or_else(|| format!("{}", self.user_id))
|
.unwrap_or_else(|| format!("{}", self.user_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a name for the member which is guaranteed to be unique, but not necessarily the
|
/// Returns a name for the member which is guaranteed to be unique, but not
|
||||||
/// most ergonomic.
|
/// necessarily the most ergonomic.
|
||||||
///
|
///
|
||||||
/// This is either a name in the format "DISPLAY_NAME (MXID)" if the member's display name is
|
/// This is either a name in the format "DISPLAY_NAME (MXID)" if the
|
||||||
/// set, or simply "MXID" if not.
|
/// member's display name is set, or simply "MXID" if not.
|
||||||
pub fn unique_name(&self) -> String {
|
pub fn unique_name(&self) -> String {
|
||||||
self.display_name
|
self.display_name
|
||||||
.clone()
|
.clone()
|
||||||
|
@ -124,19 +125,21 @@ impl RoomMember {
|
||||||
.unwrap_or_else(|| format!("{}", self.user_id))
|
.unwrap_or_else(|| format!("{}", self.user_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the disambiguated display name for the member which is as ergonomic as possible while
|
/// Get the disambiguated display name for the member which is as ergonomic
|
||||||
/// still guaranteeing it is unique.
|
/// as possible while still guaranteeing it is unique.
|
||||||
///
|
///
|
||||||
/// If the member's display name is currently ambiguous (i.e. shared by other room members),
|
/// If the member's display name is currently ambiguous (i.e. shared by
|
||||||
/// this method will return the same result as `RoomMember::unique_name`. Otherwise, this
|
/// other room members), this method will return the same result as
|
||||||
/// method will return the same result as `RoomMember::name`.
|
/// `RoomMember::unique_name`. Otherwise, this method will return the same
|
||||||
|
/// result as `RoomMember::name`.
|
||||||
///
|
///
|
||||||
/// This is usually the name you want when showing room messages from the member or when
|
/// This is usually the name you want when showing room messages from the
|
||||||
/// showing the member in the member list.
|
/// member or when showing the member in the member list.
|
||||||
///
|
///
|
||||||
/// **Warning**: When displaying a room member's display name, clients *must* use
|
/// **Warning**: When displaying a room member's display name, clients
|
||||||
/// a disambiguated name, so they *must not* use `RoomMember::display_name` directly. Clients
|
/// *must* use a disambiguated name, so they *must not* use
|
||||||
/// *should* use this method to obtain the name, but an acceptable alternative is to use
|
/// `RoomMember::display_name` directly. Clients *should* use this method to
|
||||||
|
/// obtain the name, but an acceptable alternative is to use
|
||||||
/// `RoomMember::unique_name` in certain situations.
|
/// `RoomMember::unique_name` in certain situations.
|
||||||
pub fn disambiguated_name(&self) -> String {
|
pub fn disambiguated_name(&self) -> String {
|
||||||
if self.display_name_ambiguous {
|
if self.display_name_ambiguous {
|
||||||
|
|
Loading…
Reference in New Issue