1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-27 10:39:03 +02:00

use released versions of actix-net

This commit is contained in:
Nikolay Kim
2019-12-02 23:33:39 +06:00
parent 068f047dd5
commit 14075ebf7f
19 changed files with 128 additions and 126 deletions

View File

@ -667,7 +667,7 @@ mod tests {
async fn async_with_block() -> Result<HttpResponse, Error> {
let res = web::block(move || Some(4usize).ok_or("wrong")).await;
match res? {
match res {
Ok(value) => Ok(HttpResponse::Ok()
.content_type("text/plain")
.body(format!("Async with block value: {}", value))),

View File

@ -6,6 +6,7 @@ pub use actix_http::Response as HttpResponse;
pub use bytes::{Bytes, BytesMut};
pub use futures::channel::oneshot::Canceled;
use crate::error::BlockingError;
use crate::extract::FromRequest;
use crate::handler::Factory;
use crate::resource::Resource;
@ -274,10 +275,11 @@ pub fn service(path: &str) -> WebService {
/// Execute blocking function on a thread pool, returns future that resolves
/// to result of the function execution.
pub fn block<F, R>(f: F) -> impl Future<Output = Result<R, Canceled>>
pub async fn block<F, I, E>(f: F) -> Result<I, BlockingError<E>>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
F: FnOnce() -> Result<I, E> + Send + 'static,
I: Send + 'static,
E: Send + std::fmt::Debug + 'static,
{
actix_threadpool::run(f)
actix_threadpool::run(f).await
}