Rename Publication::send to publish

This commit is contained in:
Alex Mikhalev 2020-12-27 13:42:42 -07:00
parent 158c044328
commit 87ac069eab
2 changed files with 9 additions and 9 deletions

View File

@ -8,7 +8,7 @@ use broker_task::{
SubscribeRequestSender,
};
pub use message::Message;
pub use publication::{Publication, SendError};
pub use publication::{Publication, PublishError};
pub use subscription::{RecvError, Subscription};
use futures::executor::block_on;
@ -98,9 +98,9 @@ mod test {
let mut sub = orsb.subscribe_blocking::<TestMsg>().unwrap();
let mut publ = orsb.advertise_blocking::<TestMsg>().unwrap();
publ.send(TestMsg(10)).unwrap();
publ.send(TestMsg(20)).unwrap();
publ.send(TestMsg(30)).unwrap();
publ.publish(TestMsg(10)).unwrap();
publ.publish(TestMsg(20)).unwrap();
publ.publish(TestMsg(30)).unwrap();
assert_eq!(sub.recv_blocking(), Ok(TestMsg(10)));
assert_eq!(sub.recv_blocking(), Ok(TestMsg(20)));
@ -120,9 +120,9 @@ mod test {
let mut sub = orsb.subscribe::<TestMsg>().await.unwrap();
let mut publ = orsb.advertise::<TestMsg>().await.unwrap();
publ.send(TestMsg(10)).unwrap();
publ.send(TestMsg(20)).unwrap();
publ.send(TestMsg(30)).unwrap();
publ.publish(TestMsg(10)).unwrap();
publ.publish(TestMsg(20)).unwrap();
publ.publish(TestMsg(30)).unwrap();
assert_eq!(sub.recv().await, Ok(TestMsg(10)));
assert_eq!(sub.recv().await, Ok(TestMsg(20)));

View File

@ -4,7 +4,7 @@ use crate::message::Message;
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum SendError {}
pub enum PublishError {}
#[derive(Debug)]
pub struct Publication<T> {
@ -16,7 +16,7 @@ impl<T: Message> Publication<T> {
Publication { sender }
}
pub fn send(&mut self, message: T) -> Result<usize, SendError> {
pub fn publish(&mut self, message: T) -> Result<usize, PublishError> {
match self.sender.send(message) {
Ok(subscribers) => Ok(subscribers),
Err(_) => Ok(0),