From 4ddcdbb3279fe78ed96c5bf56f785566fd7a5e28 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sat, 13 Jul 2024 13:20:30 +0200 Subject: [PATCH] Rename crate --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 2 +- README.md | 12 +++++++----- src/lib.rs | 14 +++++++------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27dc815..5f1a88b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,6 +106,14 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pubserve" +version = "1.0.0" +dependencies = [ + "async-trait", + "tokio", +] + [[package]] name = "quote" version = "1.0.36" @@ -121,14 +129,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "spectra" -version = "1.0.0" -dependencies = [ - "async-trait", - "tokio", -] - [[package]] name = "syn" version = "2.0.71" diff --git a/Cargo.toml b/Cargo.toml index fd2a6d0..da4eddc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "spectra" +name = "pubserve" license = "MPL-2.0" version = "1.0.0" edition = "2021" diff --git a/README.md b/README.md index a31f93f..ef63324 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ -# spectra +# pubserve + +> Publish and observe. Simple, generic observer pattern implementation for Rust. ## Usage -spectra is really simple to use. Start by creating a `Publisher` for your data type: +pubserve is really simple to use. Start by creating a `Publisher` for your data type: ```rust -use spectra::Publisher; +use pubserve::Publisher; let publisher = Publisher::::new(); ``` @@ -15,7 +17,7 @@ let publisher = Publisher::::new(); Then, create a subscriber that will listen to the publisher: ```rust -use spectra::Subscriber; +use pubserve::Subscriber; struct MySubscriber; @@ -30,7 +32,7 @@ impl Subscriber for MySubscriber { Finally, subscribe the observer to the publisher: ```rust -use spectra::ReferenceCounted; +use pubserve::ReferenceCounted; let observer = MySubscriber; let reference = ReferenceCounted::new(&observer); diff --git a/src/lib.rs b/src/lib.rs index eb69e85..abd6e31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ pub trait Subscriber { /// /// # Example /// ``` -/// use spectra::Publisher; +/// use pubserve::Publisher; /// let mut publisher = Publisher::::new(); /// publisher.publish("Hello, World!".to_string()); // .await, if async feature is enabled /// ``` @@ -89,7 +89,7 @@ impl Publisher { /// identical. /// /// ``` - /// use spectra::{Publisher, Subscriber}; + /// use pubserve::{Publisher, Subscriber}; /// /// struct MySubscriber; /// @@ -102,7 +102,7 @@ impl Publisher { /// /// let mut publisher = Publisher::::new(); /// let subscriber = MySubscriber; - /// let rc_subscriber = spectra::ReferenceCounted::new(subscriber); + /// let rc_subscriber = pubserve::ReferenceCounted::new(subscriber); /// publisher.subscribe(rc_subscriber.clone()); /// // This will print "Received this message: Hello, World!" /// publisher.publish("Hello, World!".to_string()); @@ -113,7 +113,7 @@ impl Publisher { /// // The following subscribing/unsubscribing will NOT work. If you do not understand why, /// // please read up on how reference counting works in Rust. /// publisher.subscribe(rc_subscriber.clone()); - /// publisher.unsubscribe(spectra::ReferenceCounted::new(MySubscriber)); + /// publisher.unsubscribe(pubserve::ReferenceCounted::new(MySubscriber)); /// ``` pub fn subscribe(&mut self, subscriber: ReferenceCounted>) { self.subscribers.push(subscriber); @@ -135,7 +135,7 @@ impl Publisher { /// identical. /// /// ``` - /// use spectra::{Publisher, Subscriber}; + /// use pubserve::{Publisher, Subscriber}; /// /// struct MySubscriber; /// @@ -148,7 +148,7 @@ impl Publisher { /// /// let mut publisher = Publisher::::new(); /// let subscriber = MySubscriber; - /// let rc_subscriber = spectra::ReferenceCounted::new(subscriber); + /// let rc_subscriber = pubserve::ReferenceCounted::new(subscriber); /// publisher.subscribe(rc_subscriber.clone()); /// // This will print "Received this message: Hello, World!" /// publisher.publish("Hello, World!".to_string()); @@ -159,7 +159,7 @@ impl Publisher { /// // The following subscribing/unsubscribing will NOT work. If you do not understand why, /// // please read up on how reference counting works in Rust. /// publisher.subscribe(rc_subscriber.clone()); - /// publisher.unsubscribe(spectra::ReferenceCounted::new(MySubscriber)); + /// publisher.unsubscribe(pubserve::ReferenceCounted::new(MySubscriber)); /// ``` pub fn unsubscribe(&mut self, subscriber: ReferenceCounted>) { self.subscribers