diff --git a/CHANGELOG.md b/CHANGELOG.md index bc359f5..1f904c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,14 @@ # Pharos Changelog +## 0.3.2 - 2019-09-23 + +- check spelling + ## 0.3.1 - 2019-09-23 -**BREAKING CHANGE**: Last minute change of heart. I removed two API methods whose only "merit" was +- **BREAKING CHANGE**: Last minute change of heart. I removed two API methods whose only "merit" was to hide a Box::new from the user. +- fix docs.rs showing readme ## 0.3.0 - 2019-09-23 - yanked diff --git a/Cargo.toml b/Cargo.toml index 71b6977..09b3697 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ license = "Unlicense" name = "pharos" readme = "README.md" repository = "https://github.com/najamelan/pharos" -version = "0.3.1" +version = "0.3.2" [package.metadata] [package.metadata.docs] diff --git a/Cargo.yml b/Cargo.yml index 3f3289d..8e1169c 100644 --- a/Cargo.yml +++ b/Cargo.yml @@ -10,7 +10,7 @@ package: # - merge dev branch into master # - create git tag # - version : 0.3.1 + version : 0.3.2 name : pharos authors : [ Naja Melan ] edition : '2018' diff --git a/README.md b/README.md index 730fa93..c3de095 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Minimal rustc version: 1.39. ## Security -The main issue with this crate right now is the posibility for the observable to outpace the observer. When using bounded channels, there is back pressure, which might allow DDOS attacks if using the pattern on arriving network packets. When using the unbounded channels, it might lead to excessive memory consumption if observers are outpaced. +The main issue with this crate right now is the possibility for the observable to outpace the observer. When using bounded channels, there is back pressure, which might allow DDOS attacks if using the pattern on arriving network packets. When using the unbounded channels, it might lead to excessive memory consumption if observers are outpaced. TODO: To mitigate these problems effectively, I will add a ring channel where the channel will only buffer a certain amount events and will overwrite the oldest event instead of blocking the sender when the buffer is full. @@ -40,8 +40,8 @@ This crate has: `#![ forbid( unsafe_code ) ]` ### Limitations -- only bounded and unbounded channel as backend (for now) -- [`Events`] is not clonable right now (would require support from the channels we use as backends, eg. broadcast type channel) +- only bounded and unbounded channel as back-end (for now) +- [`Events`] is not clonable right now (would require support from the channels we use as back-ends, eg. broadcast type channel) - performance tweaking still needs to be done - pharos requires mut access for most operations. This is not intended to change anytime soon. Both on [notify](Pharos::notify) and [observe](Observable::observe), the two main interfaces, manipulate internal @@ -79,7 +79,7 @@ Please check out the [changelog](https://github.com/najamelan/pharos/blob/master ### Dependencies -This crate only has two dependiencies. Cargo will automatically handle it's dependencies for you. +This crate only has two dependencies. Cargo will automatically handle it's dependencies for you. ```yaml dependencies: @@ -109,21 +109,21 @@ use // here we put a pharos object on our struct // -struct Godess { pharos: Pharos } +struct Goddess { pharos: Pharos } -impl Godess +impl Goddess { fn new() -> Self { Self { pharos: Pharos::default() } } - // Send Godess sailing so she can tweet about it! + // Send Goddess sailing so she can tweet about it! // pub async fn sail( &mut self ) { - self.pharos.notify( &GodessEvent::Sailing ).await; + self.pharos.notify( &GoddessEvent::Sailing ).await; } } @@ -134,7 +134,7 @@ impl Godess // #[ derive( Clone, Debug, PartialEq, Copy ) ] // -enum GodessEvent +enum GoddessEvent { Sailing } @@ -145,9 +145,9 @@ enum GodessEvent // and when you want to be observable over several types of events, you might want to keep // pharos in a hashmap over type_id, and a derive would quickly become a mess. // -impl Observable for Godess +impl Observable for Goddess { - fn observe( &mut self, options: ObserveConfig) -> Events + fn observe( &mut self, options: ObserveConfig) -> Events { self.pharos.observe( options ) } @@ -158,7 +158,7 @@ fn main() { let program = async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); // subscribe, the observe method takes options to let you choose: // - channel type (bounded/unbounded) @@ -178,7 +178,7 @@ fn main() // drop( isis ); - assert_eq!( GodessEvent::Sailing, evt ); + assert_eq!( GoddessEvent::Sailing, evt ); assert_eq!( None, events.next().await ); }; @@ -242,14 +242,14 @@ fn main() ## API -Api documentation can be found on [docs.rs](https://docs.rs/pharos). +API documentation can be found on [docs.rs](https://docs.rs/pharos). ## Contributing -This repository accepts contributions. Ideas, questions, feature requests and bug reports can be filed through github issues. +This repository accepts contributions. Ideas, questions, feature requests and bug reports can be filed through Github issues. -Pull Requests are welcome on github. By commiting pull requests, you accept that your code might be modified and reformatted to fit the project coding style or to improve the implementation. Please discuss what you want to see modified before filing a pull request if you don't want to be doing work that might be rejected. +Pull Requests are welcome on Github. By committing pull requests, you accept that your code might be modified and reformatted to fit the project coding style or to improve the implementation. Please discuss what you want to see modified before filing a pull request if you don't want to be doing work that might be rejected. ### Code of conduct diff --git a/examples/basic.rs b/examples/basic.rs index e3b8977..519e296 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -7,21 +7,21 @@ use // here we put a pharos object on our struct // -struct Godess { pharos: Pharos } +struct Goddess { pharos: Pharos } -impl Godess +impl Goddess { fn new() -> Self { Self { pharos: Pharos::default() } } - // Send Godess sailing so she can tweet about it! + // Send Goddess sailing so she can tweet about it! // pub async fn sail( &mut self ) { - self.pharos.notify( &GodessEvent::Sailing ).await; + self.pharos.notify( &GoddessEvent::Sailing ).await; } } @@ -32,7 +32,7 @@ impl Godess // #[ derive( Clone, Debug, PartialEq, Copy ) ] // -enum GodessEvent +enum GoddessEvent { Sailing } @@ -43,9 +43,9 @@ enum GodessEvent // and when you want to be observable over several types of events, you might want to keep // pharos in a hashmap over type_id, and a derive would quickly become a mess. // -impl Observable for Godess +impl Observable for Goddess { - fn observe( &mut self, options: ObserveConfig) -> Events + fn observe( &mut self, options: ObserveConfig) -> Events { self.pharos.observe( options ) } @@ -56,7 +56,7 @@ fn main() { let program = async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); // subscribe, the observe method takes options to let you choose: // - channel type (bounded/unbounded) @@ -76,7 +76,7 @@ fn main() // drop( isis ); - assert_eq!( GodessEvent::Sailing, evt ); + assert_eq!( GoddessEvent::Sailing, evt ); assert_eq!( None, events.next().await ); }; diff --git a/src/events.rs b/src/events.rs index cff5d27..830edfc 100644 --- a/src/events.rs +++ b/src/events.rs @@ -2,7 +2,7 @@ use crate :: { import::*, Filter, ObserveConfig, observable::Channel, Error }; /// A stream of events. This is returned from [Observable::observe](crate::Observable::observe). /// -/// For pharos 0.3.0 on x64 linux: `std::mem::size_of::>() == 16` +/// For pharos 0.3.0 on x64 Linux: `std::mem::size_of::>() == 16` // #[ derive( Debug ) ] // @@ -66,7 +66,7 @@ impl Stream for Events where Event: Clone + 'static + Send /// The sender of the channel. -/// For pharos 0.3.0 on x64 linux: `std::mem::size_of::>() == 56` +/// For pharos 0.3.0 on x64 Linux: `std::mem::size_of::>() == 56` // #[ pin_project ] // diff --git a/src/observable.rs b/src/observable.rs index 638cf75..5a97a08 100644 --- a/src/observable.rs +++ b/src/observable.rs @@ -90,7 +90,7 @@ pub enum Channel // Bounded(usize), - /// A channel with unbounded capacity. Note that this may lead to unbouded memory consumption if producers + /// A channel with unbounded capacity. Note that this may lead to unbounded memory consumption if producers /// outpace consumers. // Unbounded, diff --git a/src/pharos.rs b/src/pharos.rs index e6f0117..919363b 100644 --- a/src/pharos.rs +++ b/src/pharos.rs @@ -27,7 +27,7 @@ use crate :: { import::*, Observable, Events, ObserveConfig, events::Sender }; /// they did not generate an error. /// /// `join_all` will allocate a new vector on every notify from what our concurrent futures return. Ideally -/// we would use a datastructure which allows &mut access to individual elements, so we can work on them +/// we would use a data structure which allows &mut access to individual elements, so we can work on them /// concurrently in place without reallocating. I am looking into the partitions crate, but that's for /// the next release ;). // @@ -50,12 +50,12 @@ impl fmt::Debug for Pharos where Event: 'static + Clone + Send impl Pharos where Event: 'static + Clone + Send { - /// Create a new Pharos. May it's light guide you to safe harbour. + /// Create a new Pharos. May it's light guide you to safe harbor. /// /// You can set the initial capacity of the vector of senders, if you know you will a lot of observers /// it will save allocations by setting this to a higher number. /// - /// For pharos 0.3.0 on x64 linux: `std::mem::size_of::>>() == 56 bytes`. + /// For pharos 0.3.0 on x64 Linux: `std::mem::size_of::>>() == 56 bytes`. // pub fn new( capacity: usize ) -> Self { diff --git a/tests/bounded.rs b/tests/bounded.rs index 24e6ec3..4f5c1ff 100644 --- a/tests/bounded.rs +++ b/tests/bounded.rs @@ -21,7 +21,7 @@ fn basic() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut events = isis.observe( Channel::Bounded( 5 ).into() ); isis.sail().await; @@ -44,7 +44,7 @@ fn close_receiver() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut events = isis.observe( Channel::Bounded( 5 ).into() ); isis.sail().await; @@ -65,7 +65,7 @@ fn one_receiver_drops() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut egypt_evts = isis.observe( Channel::Bounded( 1 ).into() ); let mut shine_evts = isis.observe( Channel::Bounded( 2 ).into() ); @@ -94,7 +94,7 @@ fn types() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); // Note that because of the asserts below type inference works here and we don't have to // put type annotation, but I do find it quite obscure and better to be explicit. @@ -123,7 +123,7 @@ fn threads() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut egypt_evts = isis.observe( Channel::Bounded( 5 ).into() ); let mut shine_evts = isis.observe( Channel::Bounded( 5 ).into() ); @@ -165,7 +165,7 @@ fn block_sender() let mut pool = LocalPool::new(); let mut exec = pool.spawner(); - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut events: Receiver = isis.observe( 0 ); let sender = async move @@ -202,7 +202,7 @@ fn filter() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let filter = |evt: &IsisEvent| { @@ -242,7 +242,7 @@ fn filter_true() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let filter = |_: &IsisEvent| true; @@ -278,7 +278,7 @@ fn filter_false() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let filter = |_: &IsisEvent| false; @@ -309,7 +309,7 @@ fn filter_move() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let v: Vec = Vec::new(); let filter = move |evt: &IsisEvent| diff --git a/tests/combined.rs b/tests/combined.rs index 221d4ae..75553b9 100644 --- a/tests/combined.rs +++ b/tests/combined.rs @@ -13,7 +13,7 @@ fn both() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut events: Events = isis.observe( Channel::Bounded( 5 ).into() ); let mut nuevts: Events = isis.observe( Channel::Bounded( 5 ).into() ); diff --git a/tests/common/mod.rs b/tests/common/mod.rs index cd6492c..ff76870 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -23,14 +23,14 @@ pub mod import use import::*; -pub struct Godess +pub struct Goddess { isis: Pharos, nut : Pharos, } -impl Godess +impl Goddess { pub fn new() -> Self { @@ -79,7 +79,7 @@ pub struct NutEvent } -impl Observable for Godess +impl Observable for Goddess { fn observe( &mut self, options: ObserveConfig ) -> Events { @@ -88,7 +88,7 @@ impl Observable for Godess } -impl Observable for Godess +impl Observable for Goddess { fn observe( &mut self, options: ObserveConfig ) -> Events { diff --git a/tests/unbounded.rs b/tests/unbounded.rs index f72dabf..d103f86 100644 --- a/tests/unbounded.rs +++ b/tests/unbounded.rs @@ -21,7 +21,7 @@ fn basic() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut events = isis.observe( ObserveConfig::default() ); @@ -44,7 +44,7 @@ fn close_receiver() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut events = isis.observe( ObserveConfig::default() ); @@ -66,7 +66,7 @@ fn one_receiver_drops() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut egypt_evts = isis.observe( ObserveConfig::default() ); let mut shine_evts = isis.observe( ObserveConfig::default() ); @@ -98,7 +98,7 @@ fn types() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut egypt_evts: Events = isis.observe( ObserveConfig::default() ); let mut shine_evts: Events = isis.observe( ObserveConfig::default() ); @@ -123,7 +123,7 @@ fn threads() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let mut egypt_evts = isis.observe( ObserveConfig::default() ); let mut shine_evts = isis.observe( ObserveConfig::default() ); @@ -157,7 +157,7 @@ fn alot_of_events() { block_on( async move { - let mut w = Godess::new(); + let mut w = Goddess::new(); let mut events = w.observe( ObserveConfig::default() ); @@ -189,7 +189,7 @@ fn filter() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let filter = |evt: &IsisEvent| { @@ -226,7 +226,7 @@ fn filter_true() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let filter = |_: &IsisEvent| true; @@ -259,7 +259,7 @@ fn filter_false() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let filter = |_: &IsisEvent| false; @@ -287,7 +287,7 @@ fn filter_move() { block_on( async move { - let mut isis = Godess::new(); + let mut isis = Goddess::new(); let v: Vec = Vec::new(); let filter = move |evt: &IsisEvent|