Futures in Rust don’t run on their own - they need an executor to run them. When you create a future inside call(), it doesn’t do anything yet - it’s merely a recipe of what to do once it does run. It only starts running after you’ve returned it to hyper; hyper gives it to tokio, which serves as the executor. This part has nothing to do with you removing future impl from Store.
But here’s the deal - as it stands, you don’t need to make add() perform the addition inside a future - it doesn’t do anything asynchronously. Instead, make add() perform the update via normal code (ie no futures there).
The data should be there - you’re not seeing it because of how you’re inspecting this, as mentioned above.
Ok, delete using futures. Could you explain how to process POST which add item to vector (field of server) and then do something with added item inside another POST? For me it's difficult to understand without simple example.
Have you tried issuing a second POST request after the first one added the item? I think it’s there but you’re just not seeing it because of how you’re inspecting things in the first POST.
No, it's not here. I have a client which send batch of data to store it inside server and then try to find (in other POST) necessary data which should be store inside of server. In second case of searching my client received StatusCode::NotFound, because store is still empty.
let addr = "127.0.0.1:8080".parse().unwrap();
let server = Http::new().bind(&addr, move || Ok(
Server{store: Rc::new(RefCell::new(Store::new()))}
)).unwrap();
Note the code I showed you earlier has the Rc<RefCell<Store> outside the closure:
As it stands, each client connection gets its own Rc<RefCell<Store>>, and that explains what you're seeing.