These are chat archives for rust-lang/rust

20th
May 2018
Nikolay Kim
@fafhrd91
May 20 2018 00:57 UTC
@mberndt123 try actix-web
Kelly Thomas Kline
@kellytk
May 20 2018 01:09 UTC
@fafhrd91 What's the difference between Actix and Actix web?
Nikolay Kim
@fafhrd91
May 20 2018 01:10 UTC
actix is actor framework, actix-web is a web framework
Kelly Thomas Kline
@kellytk
May 20 2018 01:11 UTC
Does Actix web use Actix?
Nikolay Kim
@fafhrd91
May 20 2018 01:12 UTC
yes, you can start special http actor as part of response
also websockets proto is implemented as an actor
Kevin Cheung
@dataopt
May 20 2018 01:12 UTC
Are there any free online courses for learning Rust?
Kelly Thomas Kline
@kellytk
May 20 2018 01:14 UTC
Thanks @fafhrd91
Matthias Berndt
@mberndt123
May 20 2018 04:47 UTC
@fafhrd91, any reason in particular why you're recommending actix in particular and not one of the many other frameworks out there?
Nikolay Kim
@fafhrd91
May 20 2018 04:48 UTC
It is fast, so it should consume very few energy and cpu. On other hand what other framework you can recommend?
Matthias Berndt
@mberndt123
May 20 2018 04:58 UTC
I don't know anything about rust web frameworks, so I can't recommend anything. That's why I ask
I do most of my programming in Scala and I like it, but a GC language is not ideal for that kind of environment
Nikolay Kim
@fafhrd91
May 20 2018 05:00 UTC
You don’t have much choice with async rust.
Matthias Berndt
@mberndt123
May 20 2018 05:02 UTC
The thing is, I don't worry so much about speed but memory use. Realistically only one user will use it at a time.
Nikolay Kim
@fafhrd91
May 20 2018 05:02 UTC
I think you have only two choice rocket and actix-web. Rocket is nightly and kind of slow and actix is fast but is not that ergonomic as rocket
Matthias Berndt
@mberndt123
May 20 2018 05:02 UTC
ok... who said
anything about async?
Nikolay Kim
@fafhrd91
May 20 2018 05:03 UTC
Memory usage is good in general for rust apps
Rocket is Sync, actix is async
Matthias Berndt
@mberndt123
May 20 2018 05:04 UTC
I see
what about pencil
Nikolay Kim
@fafhrd91
May 20 2018 05:05 UTC
I would stick with rocket or actix
Everything else is pretty weak
Matthias Berndt
@mberndt123
May 20 2018 05:06 UTC
hm, ok. I see
thanks
What would you recommend for editing Rust code?
Nikolay Kim
@fafhrd91
May 20 2018 05:11 UTC
That is hard question:)
I use tmux + emacs
There are options, visual studio code, IntelliJ + rust plugin
Matthias Berndt
@mberndt123
May 20 2018 05:13 UTC
oh, I mostly use IntelliJ for my Scala coding, good to know that Rust is supported
Marvin Perez
@marvsperez_twitter
May 20 2018 11:23 UTC
@mberndt123 I think you will enjoy visual studio code. It has a very good rust plugin.
Hi, I'm very new to rust and especially to hyper but I like it. I'm building a simple web api and I want it to be full rest api. How can I parse the last part of the route so that I can use it as parameter.
My code is something like this, but I like the last part of the route to be a parameter.
            (&Method::Get, "/api/transactions/{id}") => {
                let response = match svc::transactionsvc::get_single_transaction(2) {
                    Some(result) => {
                        let j = serde_json::to_string(&result);
                        match j {
                            Ok(data) => make_response(data),
                            Err(_error) => make_error_response("No records found"),
                        }
                    }
                    None => make_error_response("No records found"),
                };

                Box::new(response)
            }
Denis Lisov
@tanriol
May 20 2018 11:33 UTC
@marvsperez_twitter Are you building directly on hyper without any higher-level frameworks?
Judson Lester
@nyarly
May 20 2018 20:08 UTC
I'm converting some older code to impl Trait (and doing goofy muppet dances all the while.)
Is it pretty common to have make_future().share().clone().map(|err| *err) with some "space" between those calls?
IOW to map the SharedError to *itself?
It might be because I'm using failure?
Judson Lester
@nyarly
May 20 2018 21:33 UTC
the trait 'std::convert::From<failure::Error>' is not implemented for 'std::result::Result<_, failure::Error>' <- surprising
Denis Lisov
@tanriol
May 20 2018 21:36 UTC
@nyarly Do you need many of your futures to be shared?
Judson Lester
@nyarly
May 20 2018 21:37 UTC
I'm looking at that now.
I might be able to remove some shared() calls
But not all.
Judson Lester
@nyarly
May 20 2018 21:45 UTC
(my problem with the convert::From was that I was bail!ing instead of Error::from)
Still figuring out the relationship between * and &
Judson Lester
@nyarly
May 20 2018 21:54 UTC
No, still a problem. @tanriol Is there simple idiom here?
I've got a shared future whose Error is failure::Error
Stephen Judkins
@stephenjudkins
May 20 2018 23:34 UTC
i'm implementing an old VM that has 256 registers. its bytecode refers to these registers by byte. the problem with doing this with a Vec is that I have to do either do unwrap or use unsafe to access the darn thing
is there are data structure that's either 256 or 65536 elements long that I can access "safely" using u8 or u16?