Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  Bump version to 0.2.1
  Add todo entries
  fixup trailing await_macro's
  Implement Default for Pharos
  • Loading branch information
najamelan committed Aug 2, 2019
2 parents ba9c79b + 56c45c4 commit e3e1d72
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 20 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
@@ -1,5 +1,11 @@
# Pharos Changelog

## 0.2.1 - 2019-08-02

- remove `await_macro` feature use and convert to new await syntax.
- implement `Default` for `Pharos`.


## 0.2.0 - 2019-07-18

BREAKING CHANGE: Update dependencies. The Futures library has some changes, which introduce a breaking change. Bounded channels are no longer queue_size + 1. They now are queue_size. This means that `Observable::observe( queue_size: usize )` will now yield a `futures::channel::Receiver` of the exact `queue_size`.
- **BREAKING CHANGE**: Update dependencies. The Futures library has some changes, which introduce a breaking change. Bounded channels are no longer queue_size + 1. They now are queue_size. This means that `Observable::observe( queue_size: usize )` will now yield a `futures::channel::Receiver` of the exact `queue_size`.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -20,4 +20,4 @@ license = "Unlicense"
name = "pharos"
readme = "README.md"
repository = "https://github.com/najamelan/pharos"
version = "0.2.0"
version = "0.2.1"
2 changes: 1 addition & 1 deletion Cargo.yml
@@ -1,7 +1,7 @@
package:

name : pharos
version : 0.2.0
version : 0.2.1
authors : [ Naja Melan <najamelan@autistici.org> ]
edition : '2018'
readme : README.md
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -15,6 +15,7 @@ I created it to leverage interoperability we can create by using async Streams a

- [Security](#security)
- [Install](#install)
- [Upgrade](#upgrade)
- [Dependencies](#dependencies)
- [Usage](#usage)
- [API](#api)
Expand Down Expand Up @@ -50,6 +51,11 @@ With raw Cargo.toml
pharos = "^0.1"
```

### Upgrade

Please check out the [changelog](https://github.com/najamelan/pharos/blob/master/CHANGELOG.md) when upgrading.


### Dependencies

This crate only has one dependiency. Cargo will automatically handle it's dependencies for you.
Expand Down
9 changes: 9 additions & 0 deletions TODO.md
@@ -0,0 +1,9 @@
# TODO

- Create a filter possibility. Let users provide a closure with a predicate to filter which events they want to receive.
The reasons for doing this in pharos are:

- It's unwieldy to do this in the client because of the unwieldy type that you need to annotate if you need to store
the stream (FilterMap will include a closure in it's type)
- performance. If filtering happens on the client side, we will clone and send out events they are not interested in.
By doing it in pharos, we can avoid that.
8 changes: 4 additions & 4 deletions examples/basic.rs
@@ -1,4 +1,4 @@
#![ feature( async_await, await_macro )]
#![ feature( async_await )]

use
{
Expand Down Expand Up @@ -30,7 +30,7 @@ impl Godess
//
pub async fn sail( &mut self )
{
await!( self.pharos.notify( &GodessEvent::Sailing ) );
self.pharos.notify( &GodessEvent::Sailing ).await;
}
}

Expand Down Expand Up @@ -77,11 +77,11 @@ fn main()

// trigger an event
//
await!( isis.sail() );
isis.sail().await;

// read from stream
//
let from_stream = await!( events.next() ).unwrap();
let from_stream = events.next().await.unwrap();

dbg!( from_stream );
assert_eq!( GodessEvent::Sailing, from_stream );
Expand Down
18 changes: 12 additions & 6 deletions src/lib.rs
Expand Up @@ -15,6 +15,7 @@
//!
//! - [Security](#security)
//! - [Install](#install)
//! - [Upgrade](#upgrade)
//! - [Dependencies](#dependencies)
//! - [Usage](#usage)
//! - [API](#api)
Expand Down Expand Up @@ -50,6 +51,11 @@
//! pharos = "^0.1"
//! ```
//!
//! ### Upgrade
//!
//! Please check out the [changelog](https://github.com/najamelan/pharos/blob/master/CHANGELOG.md) when upgrading.
//!
//!
//! ### Dependencies
//!
//! This crate only has one dependiency. Cargo will automatically handle it's dependencies for you.
Expand All @@ -72,7 +78,7 @@
//! Examples can be found in the [examples](https://github.com/najamelan/pharos/tree/master/examples) directory. Here is a summary of the most basic one:
//!
//! ```rust
//! #![ feature( async_await, await_macro )]
//! #![ feature( async_await )]
//!
//! use
//! {
Expand Down Expand Up @@ -104,7 +110,7 @@
//! //
//! pub async fn sail( &mut self )
//! {
//! await!( self.pharos.notify( &GodessEvent::Sailing ) );
//! self.pharos.notify( &GodessEvent::Sailing ).await;
//! }
//! }
//!
Expand Down Expand Up @@ -151,11 +157,11 @@
//!
//! // trigger an event
//! //
//! await!( isis.sail() );
//! isis.sail().await;
//!
//! // read from stream
//! //
//! let from_stream = await!( events.next() ).unwrap();
//! let from_stream = events.next().await.unwrap();
//!
//! dbg!( from_stream );
//! assert_eq!( GodessEvent::Sailing, from_stream );
Expand Down Expand Up @@ -190,8 +196,8 @@



#![ feature( async_await, await_macro ) ]
#![ forbid ( unsafe_code ) ]
#![ feature( async_await ) ]
#![ forbid ( unsafe_code ) ]


mod observable;
Expand Down
22 changes: 17 additions & 5 deletions src/pharos.rs
Expand Up @@ -6,6 +6,8 @@ use crate :: { import::* };
///
/// You can of course create several `Pharos` (I know, historical sacrilege) for (different) types
/// of events.
///
// TODO: why do we require Send?
//
#[ derive( Clone, Debug ) ]
//
Expand All @@ -22,11 +24,7 @@ impl<Event: Clone + 'static + Send> Pharos<Event>
//
pub fn new() -> Self
{
Self
{
observers: Vec::new(),
unbounded: Vec::new(),
}
Self::default()
}


Expand Down Expand Up @@ -122,3 +120,17 @@ impl<Event: Clone + 'static + Send> Pharos<Event>
*observers = fut.await;
}
}



impl<Event: Clone + 'static + Send> Default for Pharos<Event>
{
fn default() -> Self
{
Self
{
observers: Vec::new(),
unbounded: Vec::new(),
}
}
}
2 changes: 1 addition & 1 deletion tests/bounded.rs
@@ -1,4 +1,4 @@
#![ feature( async_await, await_macro )]
#![ feature( async_await )]

// Tested:
//
Expand Down
2 changes: 1 addition & 1 deletion tests/unbounded.rs
@@ -1,4 +1,4 @@
#![ feature( async_await, await_macro )]
#![ feature( async_await )]

// Tested:
//
Expand Down

0 comments on commit e3e1d72

Please sign in to comment.