Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rust async functions #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

manuels
Copy link

@manuels manuels commented Feb 9, 2020

Hey, here is a first sketch of who async could be implemented.
I'm not quite sure about the Errors that could be raised, i.e. in what cases does get()'s done callback return ok=false? If the peer is not connected to the network, yet? Maybe we should raise a special Error (right now I am misusing std::io::Error).

Let me know what you think about it?

EDIT: oh, damn, I overwrote the dhtnode example - I will move that to a new file - done.


size_t i = 0;
while(addrs != nullptr && addrs[i] != nullptr) {
sa.push_back(dht::SockAddr(addrs[i], addrs_len[i]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emplace_back


println!("Current node id: {}", dht.node_id());

let mut stream = dht.get_async(&InfoHash::get("bob"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho, we can do like reqwest crate. Async by default and a sync Dht builder if someone needs to do some sync operations. So we can have DhtRunner::new(); and DhtRunner::blocking::new(), then .get() for both versions (https://docs.rs/reqwest/0.10.1/reqwest/blocking/index.html vs https://docs.rs/reqwest/0.10.1/reqwest/)

If you want I can take some time to modify this :). I think adding _async everywhere is not the best way

@AmarOk1412
Copy link
Contributor

For the get, "ok" in the callback will be false if the Dht is not running, this can occurs during a connectivity change too.

@AmarOk1412
Copy link
Contributor

Maybe a std::io::NotConnected makes more sense.

@manuels
Copy link
Author

manuels commented Feb 14, 2020

Hey @AmarOk1412,
I'm a bit busy these days, but I hope I can fix it this weekend.

@AmarOk1412
Copy link
Contributor

Np I'm not available till Feb 26 so it will take time :)

@aberaud aberaud force-pushed the master branch 3 times, most recently from 966e620 to fe6676f Compare April 4, 2022 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants