Giter Club home page Giter Club logo

actix-protobuf's Introduction

Actix-web ProtoBuf Build Status codecov crates.io Join the chat at https://gitter.im/actix/actix

Protobuf support for actix-web framework.

NOTICE: This repository has been archived. Please visit https://github.com/actix/actix-extras instead.

Example

use actix_protobuf::*;
use actix_web::*;

#[derive(Clone, PartialEq, Message)]
pub struct MyObj {
    #[prost(int32, tag = "1")]
    pub number: i32,
    #[prost(string, tag = "2")]
    pub name: String,
}

async fn index(msg: ProtoBuf<MyObj>) -> Result<HttpResponse> {
    println!("model: {:?}", msg);
    HttpResponse::Ok().protobuf(msg.0) // <- send response
}

See here for the complete example.

License

This project is licensed under either of

at your option.

actix-protobuf's People

Contributors

cdituri avatar elliotekj avatar fafhrd91 avatar hstefan avatar johntitor avatar parkmycar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actix-protobuf's Issues

prost 0.5.0 - the trait bound `MyObj: prost::message::Message` is not satisfied

the trait bound `MyObj: prost::message::Message` is not satisfied

the trait `prost::message::Message` is not implemented for `MyObj`

note: required by `actix_protobuf::ProtoBuf`rustc(E0277)
main.rs(47, 1): the trait `prost::message::Message` is not implemented for `MyObj`

Changing to prost 0.4.0 and prost-derive 0.4.0 works.

Upgrade to actix-web 2.0 now that it's generally available

I tried to upgrade a project of mine to using actix-web 2.0 and actix-protobuf turned out to be the primary blocker for that migration. I suspect many others will find themselves in that position soon as well.

Are there plans in the works?

no method named `map_err` found for type `ProtoBufMessage<actix_web::HttpRequest<S>, _>` in the current scope

Hi,

I'm trying to get this example working for actix_web 0.7 but am running into a puzzling error:

error[E0599]: no method named `map_err` found for type `ProtoBufMessage<actix_web::HttpRequest<S>, _>` in the current scope
   --> actix-protobuf/src/lib.rs:103:14
    |
103 |               .map_err()
    |                ^^^^^^^
...
111 | / pub struct ProtoBufMessage<T, U>
112 | | where U: Message + Default,
113 | | {
114 | |     limit: usize,
...   |
117 | |     fut: Option<Box<Future<Item=U, Error=ProtoBufPayloadError>>>,
118 | | }
    | |_- method `map_err` not found for this
    |
    = note: the method `map_err` exists but the following trait bounds were not satisfied:
            `ProtoBufMessage<actix_web::HttpRequest<S>, _> : futures::Future`
            `&mut ProtoBufMessage<actix_web::HttpRequest<S>, _> : futures::Future`
            `&mut ProtoBufMessage<actix_web::HttpRequest<S>, _> : futures::Stream`
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following traits define an item `map_err`, perhaps you need to implement one of them:
            candidate #1: `actix::ActorFuture`
            candidate #2: `actix::ActorStream`
            candidate #3: `futures::Future`
            candidate #4: `futures::Stream`
            candidate #5: `actix_net::service::ServiceExt`
            candidate #6: `actix_net::service::NewServiceExt`

What's confusing is that there is already an implementation for futures::Future so I'm not so why this error persists:

actix-protobuf/src/lib.rs

Lines 186 to 187 in 99e4e1c

impl<T, U: Message + Default + 'static> Future for ProtoBufMessage<T, U>
where T: HttpMessage + Stream<Item=Bytes, Error=PayloadError> + 'static

Any ideas on what may be the cause?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.