Skip to content

Add rust async functions#483

Open
manuels wants to merge 1 commit into
savoirfairelinux:masterfrom
manuels:master
Open

Add rust async functions#483
manuels wants to merge 1 commit into
savoirfairelinux:masterfrom
manuels:master

Conversation

@manuels

@manuels manuels commented Feb 9, 2020

Copy link
Copy Markdown

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.

Comment thread c/opendht.cpp

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@manuels

manuels commented Feb 14, 2020

Copy link
Copy Markdown
Author

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

@AmarOk1412

Copy link
Copy Markdown
Contributor

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

@aberaud
aberaud force-pushed the master branch 9 times, most recently from f05b60d to dfd0a09 Compare March 23, 2022 22:32
@aberaud
aberaud force-pushed the master branch 11 times, most recently from 87f1050 to c290bf0 Compare April 3, 2022 14:48
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