Skip to content

Commit 9144710

Browse files
committed
add broadcaster is_local and is_remote
1 parent 4dbd3a2 commit 9144710

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/shared/message/broadcast_message.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,15 @@ pub enum Broadcaster {
404404
/// Received over the network from a remote client.
405405
Remote(ClientId),
406406
}
407+
408+
impl Broadcaster {
409+
/// Returns `true` if the message was written locally.
410+
pub fn is_local(self) -> bool {
411+
matches!(self, Self::Local)
412+
}
413+
414+
/// Returns `true` if the message was received from a remote client.
415+
pub fn is_remote(self) -> bool {
416+
matches!(self, Self::Remote(_))
417+
}
418+
}

tests/broadcast_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn without_plugins() {
143143
.drain()
144144
.collect();
145145
assert_eq!(broadcasts.len(), 1);
146-
assert!(matches!(broadcasts[0].broadcaster, Broadcaster::Remote(_)));
146+
assert!(broadcasts[0].broadcaster.is_remote());
147147
}
148148

149149
#[test]

0 commit comments

Comments
 (0)