From 87ac069eaba0dbb3f7128b14515b87119d979db1 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sun, 27 Dec 2020 13:42:42 -0700 Subject: [PATCH] Rename Publication::send to publish --- src/lib.rs | 14 +++++++------- src/publication.rs | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a11ece2..880625e 100644 --- a/src/lib.rs +++ b/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::().unwrap(); let mut publ = orsb.advertise_blocking::().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::().await.unwrap(); let mut publ = orsb.advertise::().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))); diff --git a/src/publication.rs b/src/publication.rs index 50c5ca5..edd8322 100644 --- a/src/publication.rs +++ b/src/publication.rs @@ -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 { @@ -16,7 +16,7 @@ impl Publication { Publication { sender } } - pub fn send(&mut self, message: T) -> Result { + pub fn publish(&mut self, message: T) -> Result { match self.sender.send(message) { Ok(subscribers) => Ok(subscribers), Err(_) => Ok(0),