Closed Noir-e closed 5 months ago
That's an interesting idea. Indeed removing all the examples from the template would be a nice place to start. I will keep this issue open until there's a PR or I have time to implement that feature :)
How do you think that separate to two command args like : rinf sample
used for understand how it work and rinf template
used for start to develop.
Yeah, that would be a good idea :)
In my opinion, rinf template
can provide only the base template, while rinf template --sample
provides the full sample code, when we copy those template files.
I already have an idea on how it could work. We could possibly add comments on line or lines that should be excluded in the template, unless --sample
option is included.
// native/hub/src/lib.rs
use bridge::respond_to_dart;
use tokio_with_wasm::tokio;
use with_request::handle_request;
mod bridge;
mod messages;
mod sample_functions; # SAMPLE
mod with_request;
/// This `hub` crate is the entry point for the Rust logic.
/// Always use non-blocking async functions such as `tokio::fs::File::open`.
async fn main() {
// This is `tokio::sync::mpsc::Reciver` that receives the requests from Dart.
let mut request_receiver = bridge::get_request_receiver();
// Repeat `tokio::spawn` anywhere in your code
// if more concurrent tasks are needed.
tokio::spawn(sample_functions::stream_mandelbrot()); # SAMPLE
tokio::spawn(sample_functions::run_debug_tests()); # SAMPLE
while let Some(request_unique) = request_receiver.recv().await {
tokio::spawn(async {
let response_unique = handle_request(request_unique).await;
respond_to_dart(response_unique);
});
}
}
And I would implement this idea once I have time, though I think it would take a few days, or weeks for me to be free. This implementation doesn't look too hard. Meanwhile, PR for this is welcome :)
Report
Discussion about
rinf template
Steps to Reproduce
Could you in the chapter "Applying Rust Template", if you can, please mention about
rinf template -b
orrinf template --bridge
for clarityOr maybe even add by default just rinf things without anything else, and add mandelbrot and etc by some argument like --example
It's just that these tutorial files make Rust part confusing, unless you deliberately go and check how to disable them
System Information
Please provide the output from the command below, using markdown codeblock syntax.