room/Occupant: Add docstrings

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2022-09-30 18:39:00 +02:00
parent d94d472b9d
commit dc9a56857c
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -320,7 +320,7 @@ impl Room {
Ok(())
}
/// Looks for the occupant associated with the provided nick and ensure the session is part of
/// Fetch the occupant associated with the provided nick and ensure the session is part of
/// it.
pub fn get_occupant(&self, realjid: &Session, nick: &Nick) -> Result<&Occupant, Error> {
if let Some(occupant) = self.occupants.get(nick) {
@ -339,16 +339,18 @@ impl Room {
}
}
/// An occupant in a room. May contain multiple sessions (Multi-Session Nicks)
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Occupant {
/// Public Jid for the Occupant
pub real: BareJid,
pub participant: FullJid,
pub nick: Nick,
pub sessions: Vec<FullJid>,
pub sessions: Vec<Presence>,
}
impl Occupant {
/// New occupant
pub fn new(room: &Room, real: FullJid, nick: Nick) -> Occupant {
Occupant {
real: BareJid::from(real.clone()),
@ -358,6 +360,7 @@ impl Occupant {
}
}
/// Add a new session to the occupant
pub fn add_session(&mut self, real: FullJid) -> Result<(), Error> {
if BareJid::from(real.clone()) != self.real {
return Err(Error::MismatchJids(
@ -376,6 +379,7 @@ impl Occupant {
Ok(())
}
/// Remove a session from the occupant
pub fn remove_session(&mut self, real: FullJid) -> Result<(), Error> {
if BareJid::from(real.clone()) != self.real {
return Err(Error::MismatchJids(
@ -395,6 +399,8 @@ impl Occupant {
}
}
/// Return whether a Jid matches the occupant. If FullJid, compare with each session, otherwise
/// see if the BareJid matches.
pub fn contains<J: Into<Jid>>(&self, _jid: &J) -> bool {
true
}