Skip to content

Commit

Permalink
Merge pull request #6 from Freyskeyd/master
Browse files Browse the repository at this point in the history
Upgrade to actix 0.12
  • Loading branch information
Diggsey committed Aug 18, 2021
2 parents a9a3bf5 + 244c4c3 commit 42d75fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "actix-interop"
version = "0.2.0"
version = "0.3.0"
authors = ["Diggory Blake <diggsey@googlemail.com>"]
edition = "2018"
license = "MIT/Apache-2.0"
Expand All @@ -13,7 +13,7 @@ keywords = ["actix", "async", "await", "context", "atomic"]
categories = ["asynchronous"]

[dependencies]
actix = "0.10.0"
actix = "0.12.0"
scoped-tls-hkt = "0.1.2"
pin-project = "0.4.21"
pin-project = "1.0.8"
futures = "0.3.4"
33 changes: 12 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ impl<A: Actor, F: Future> FutureInteropWrap<A, F> {
}
}

impl<A: Actor, F: Future> ActorFuture for FutureInteropWrap<A, F> {
type Actor = A;
impl<A: Actor, F: Future> ActorFuture<A> for FutureInteropWrap<A, F> {
type Output = F::Output;

fn poll(
Expand Down Expand Up @@ -279,8 +278,7 @@ impl<A: Actor, S: Stream> StreamInteropWrap<A, S> {
}
}

impl<A: Actor, S: Stream> ActorStream for StreamInteropWrap<A, S> {
type Actor = A;
impl<A: Actor, S: Stream> ActorStream<A> for StreamInteropWrap<A, S> {
type Item = S::Item;

fn poll_next(
Expand All @@ -301,7 +299,7 @@ pub trait StreamInterop<A: Actor>: Stream + Sized {
fn interop_actor(self, actor: &A) -> StreamInteropWrap<A, Self>;
/// Convert a stream using the `with_ctx` or `critical_section` methods into a boxed
/// ActorStream.
fn interop_actor_boxed(self, actor: &A) -> Box<dyn ActorStream<Item = Self::Item, Actor = A>>
fn interop_actor_boxed(self, actor: &A) -> Box<dyn ActorStream<A, Item = Self::Item>>
where
Self: 'static,
{
Expand All @@ -317,6 +315,7 @@ impl<A: Actor, S: Stream> StreamInterop<A> for S {

#[cfg(test)]
mod tests {

use super::{critical_section, with_ctx, FutureInterop};
use actix::prelude::*;

Expand Down Expand Up @@ -363,31 +362,23 @@ mod tests {
}
}

#[test]
fn can_run_future() {
let mut system = System::new("test");

let res = system
.block_on(async {
let addr = Summator { field: 0 }.start();
#[actix::test]
async fn can_run_future() -> Result<(), Box<dyn std::error::Error>> {
let addr = Summator { field: 0 }.start();

addr.send(Sum(3)).await.unwrap().unwrap();
addr.send(Sum(4)).await
})
.unwrap();
addr.send(Sum(3)).await.unwrap().unwrap();
let res = addr.send(Sum(4)).await?;

assert_eq!(res, Ok(7));
Ok(())
}

#[test]
fn can_run_stream() {
let system = System::new("test");

#[actix::test]
async fn can_run_stream() {
Summator::create(|ctx| {
ctx.add_stream(futures::stream::iter(1..5));
Summator { field: 0 }
});
system.run().unwrap();
}

mod pipeline {}
Expand Down

0 comments on commit 42d75fe

Please sign in to comment.