Funny timing that you release this now, I'm starting a project at work to incorporate Rust into my workplace's C++ codebase, and the task I'm doing to prove its worth is replacing (one of) our json format parsers with serde (and binding with cxx). So far, with very little work Serde does the same work (or better) than rapidjson in 2/3 the time, and that's with buffered input, if I read the whole file to a string first (no networking stuff, all local) it's 10x as fast. In either case it's looking to be a strong win for Rust.
@@sledgex9 Sadly I don't have any other comparisons, but I believe rapidjson is generally known to be one of the fastest, if not the fastest C++ json library. You can probably find benchmarks comparing various C++ parsing libraries easily though.
@@alextrotta796 I was asking because Boost.JSON is relatively new, and according to their benchmarks they are faster than rapidjson. I was just wondering if any other type of comparison was done for this project at your work.
@@sledgex9 Interesting, I actually hadn't heard of it until now, the big players are rapidjson (speed) and nlohmann (modern). We use boost already, so it would be a viable alternative, though we have to do validation via a schema, it doesn't look like boost json supports that, would have to do that manually. Most of the validation is simple stuff like "this is a length 3 array of floats" and "this field is required", stuff that is handled by serde trivially by just specifying a type. Static reflection in C++ can't come fast enough - it won't be able to truly compete with Rust in these types of workloads (without lots of hand tuning) until we have it.
It isn't really tokio that lets you use the async await syntax. But it is the most commonly used wrapper around the machinery that rust expects when encountering them.
Assuming one electron stores one bit of information uncompressed it is worth 1,99563 USD/g * 9,05*10^-28 g/e * 1e/bit * 24bit/px * 1920*1080 px/f * (7*60 + 16 ) s * 30 f/s = 4,898*10^-17 USD so basically 0 in any currency. Seems a bit low in my estimation :D
How to get the response status code, headers ...? If we try to json-deserialize a non-json string to a struct, will the library give us a Result or the app will panic? I guess that the issue with a lot of Rust crates are lack of documentation.
How do you have the inline linter telling you the object names and the syntax errors and stuff? like, at one point after .json() you can see impl Future What's the extension?
That's a good question. I've done some digging. The crate source: docs.rs/reqwest/latest/src/reqwest/async_impl/request.rs.html#436-452 docs.rs/crate/reqwest/latest/source/Cargo.toml Serde is imported under a "feature" caluse: #[cfg(feature = "json")] use serde_json; The function is enabled under feature "json" config too: #[cfg(feature = "json")] #[cfg_attr(docsrs, doc(cfg(feature = "json")))] pub fn json(mut self, json: &T) -> RequestBuilder { And the config has the feature and dependency defined as: [dependencies.serde_json] optional = true version = "1.0" [features] ... json = ["serde_json"]
@@sohn7767 So it sounds like either they're serialized as UTF-8, which is correct behaviour for JSON, or (for double-quotes specifically, and some other chars) they have their escaped representation with \u and four hex digits. Seems like expected behavior. I don't see the problem.
I tried this code but I am facing error "error: could not compile `futures-util` Caused by: process didn't exit successfully: `rustc --crate-name futures_util --edition=2018 " pls guys i am beginner help me to solve this issue
It would be awesome if you make a series building a real world project that people can get creative adding features to it and extending it, cause unfortunately currently the videos are categorized as "Tutorial Hell".
📝Get your *FREE Rust cheat sheet* :
www.letsgetrusty.com/cheatsheet
Funny timing that you release this now, I'm starting a project at work to incorporate Rust into my workplace's C++ codebase, and the task I'm doing to prove its worth is replacing (one of) our json format parsers with serde (and binding with cxx).
So far, with very little work Serde does the same work (or better) than rapidjson in 2/3 the time, and that's with buffered input, if I read the whole file to a string first (no networking stuff, all local) it's 10x as fast. In either case it's looking to be a strong win for Rust.
Any comparison to Boost.Json?
@@sledgex9 Sadly I don't have any other comparisons, but I believe rapidjson is generally known to be one of the fastest, if not the fastest C++ json library. You can probably find benchmarks comparing various C++ parsing libraries easily though.
@@alextrotta796 I was asking because Boost.JSON is relatively new, and according to their benchmarks they are faster than rapidjson. I was just wondering if any other type of comparison was done for this project at your work.
@@sledgex9 Interesting, I actually hadn't heard of it until now, the big players are rapidjson (speed) and nlohmann (modern). We use boost already, so it would be a viable alternative, though we have to do validation via a schema, it doesn't look like boost json supports that, would have to do that manually. Most of the validation is simple stuff like "this is a length 3 array of floats" and "this field is required", stuff that is handled by serde trivially by just specifying a type.
Static reflection in C++ can't come fast enough - it won't be able to truly compete with Rust in these types of workloads (without lots of hand tuning) until we have it.
It isn't really tokio that lets you use the async await syntax. But it is the most commonly used wrapper around the machinery that rust expects when encountering them.
tokio is required for running future, so its fine i guess.
@@cosmic2236 any async runtime can run future
@@CuriousSpy yes, you are correct.
Thank you! I’ve been struggling with this problem for far too long because the examples in the reqwest docs are incomplete fragments 😫
I mean you can figure this out yourself by reading the examples and documentation of the functions, but it’s definitely not easy
This is a good video for anybody trying to create a JSON over HTTP (REST) client.
One of the things that's tripped me up using Rust is the concept of unwrapping. Would love to see a video explaining it all
thats the fundamental of error handling in rust. you should read the rust book.
unwrap just gets you whatever is inside Result and Option enums
Otherwise you need a match block.
Error handling. Simply unwrapping is usually not recommended
This video is worth it's weight in gold.
Assuming one electron stores one bit of information uncompressed it is worth 1,99563 USD/g * 9,05*10^-28 g/e * 1e/bit * 24bit/px * 1920*1080 px/f * (7*60 + 16 ) s * 30 f/s = 4,898*10^-17 USD so basically 0 in any currency. Seems a bit low in my estimation :D
@@svhuwagv2965 what a chad
I think code reviews similar to what the Cherno does for c++ could be a pretty interesting addition to your current content
Awesome video!
Is there any video linking Rust to a sql database?
I’m watching the language book series and haven’t finished it yet rs
Aewsome video! I was looking for something like this. thank you
Been looking for a video JUST like this. Thank you, very helpful 👍
If it would cover some error handling like running another function if the request fails it would be perfect.
Did you mean circuit breaker?
Great Man! Perfect Video!
How to get the response status code, headers ...?
If we try to json-deserialize a non-json string to a struct, will the library give us a Result or the app will panic?
I guess that the issue with a lot of Rust crates are lack of documentation.
u have an amazing teaching skill buddy !! u made rust so simple !!
Excellent content and very easy to follow. Thanks for the tutorial!!!
Excellent demo!
What if the struct of the get response is variable?
so good! another great tutorial! thank you!!!
What VScode extensions do you have? I like the generated text next to some of the code statements showing the result value type.
Probably rust analyzer
Super helpful. Thanks!
You made this easy peasy for begineers
Awesome! Can you do a websocket client?
What if i have error response and success response, how would i go about that?
Such a excellent video!
Thanks so much for this video!
You can teach us how to make a CRUD with an API and database?
Hi, instead making it async. Why not try reqwest blocking. I think it will make the code easier
how to access key values from arbitrary json ?
How do you have the inline linter telling you the object names and the syntax errors and stuff? like, at one point after .json() you can see impl Future
What's the extension?
He did a video about tools to help dev in their code journey (rust).
Check: rust-analyzer (it did many things like prints variables types,...)
explain about ntix please, it's seems interesting
ntex*
How support to call "json()" is added to reqwest? Just by importing serde?
That's a good question. I've done some digging.
The crate source:
docs.rs/reqwest/latest/src/reqwest/async_impl/request.rs.html#436-452
docs.rs/crate/reqwest/latest/source/Cargo.toml
Serde is imported under a "feature" caluse:
#[cfg(feature = "json")]
use serde_json;
The function is enabled under feature "json" config too:
#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
pub fn json(mut self, json: &T) -> RequestBuilder {
And the config has the feature and dependency defined as:
[dependencies.serde_json]
optional = true
version = "1.0"
[features]
...
json = ["serde_json"]
awsome video
Thanks bro..,
good one!
Thank you
Keep in mind that special characters like “ will not be serialized properly
Why not? Usually things like that just get escaped in the serialized output. Doesn't that happen here?
@@peter9477 nope, they turn into their utf representation \u0203 or smth
@@sohn7767 So it sounds like either they're serialized as UTF-8, which is correct behaviour for JSON, or (for double-quotes specifically, and some other chars) they have their escaped representation with \u and four hex digits. Seems like expected behavior. I don't see the problem.
Thank you 😊
I tried this code but I am facing error "error: could not compile `futures-util`
Caused by:
process didn't exit successfully: `rustc --crate-name futures_util --edition=2018 " pls guys i am beginner help me to solve this issue
Yoo!! Do you have a discord server?? :D I would Love to join it!
Funny that your spell checker is angry with `reqwest` but fine with `tokio`
Excellente
thanks!
Json wife is Ruby
Hello Bogden, i made this crate to get nested properties from a json with an easy syntax. What do you think? crates io crates json_extract
B-but... I just wanted to parse my json, not to make http requests :c
Use the serde_json crate functions
great tutorial, but 3 days too late, lol.
It would be awesome if you make a series building a real world project that people can get creative adding features to it and extending it, cause unfortunately currently the videos are categorized as "Tutorial Hell".
First, pin comment :^)
2nd :)
Not a big fan of adding tokio. we should be able to learn the subject without that unrelated complexity.
use blocking then
Please fix haircut
please link your photo ;)
I have request each return a different response (different variables) how can I make structs for this kind of response ?