Rename Publication::send to publish
This commit is contained in:
parent
158c044328
commit
87ac069eab
14
src/lib.rs
14
src/lib.rs
@ -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)));
|
||||
|
@ -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),
|
||||
|
Loading…
x
Reference in New Issue
Block a user