vimpunk / cratetorrent

A BitTorrent V1 engine library for Rust (and currently Linux)
468 stars 35 forks source link

Fallback to buffered IO disk operations when not on Linux #95

Open ExceptionallyHandsome opened 3 years ago

ExceptionallyHandsome commented 3 years ago

Closes #88

I had to implement read_exact_at/write_all_at, and guess what? There's no cross platform API for read_at/write_at! For good reason: Unix API does not affect "seek cursor", while other's do. I don't think we care since we always specify the offset explicitly, but perhaps it's undesirable? Need your input, but I think we can live with that.

There are couple of code pieces gated under cfg which is quite ugly, but all attempts at factoring these pieces out resulted in pretentious versions of roughly the same code, so I decided this is good enough. Suggestions are welcome.

Overall, this is roughly the "working" version. "Working" because I haven't had a chance to test it. I'll proceed to it in two-three days (busy days, sorry), so this is just me presenting the design for your judgement.

(and a somewhat unrelated question: is TorrentFile really supposed be public? I just see all its methods are pub and have detailed doc comments, but the struct itself is pub(crate))

vimpunk commented 3 years ago

Just saw this:

is TorrentFile really supposed be public? I just see all its methods are pub and have detailed doc comments, but the struct itself is pub(crate)

It's not! I try to document everything as nicely as possible though, especially more complicated things. As noted above though, no intentions of making the type public.

ExceptionallyHandsome commented 3 years ago

It's not! I try to document everything as nicely as possible though, especially more complicated things. As noted above though, no intentions of making the type public.

Then do you mind if I make the methods pub(crate) instead of pub? It's kinda confusing.

vimpunk commented 3 years ago

@ExceptionallyHandsome I thought it was sufficient to make a type's visibility restricted without having to alter its methods' visibility, but I wasn't sure what is actually good practice in this case as I haven't found much online. Do you perhaps know?

Arguably being explicit is better so I don't actually mind.

vimpunk commented 3 years ago

Hi @ExceptionallyHandsome, how have you been doing?

I've been very busy and haven't had a lot of time to put more thought into this MR. Do you plan to continue it at some point? I plan to recommence developmenet of cratetorrent in the coming weeks, I just have a few more priorities to attend to first.

No rush, and absolutely no problem if you don't want to pick this up. I'm just inquiring, I understand what it's like to be busy after all. :)

nikita-fuchs commented 2 years ago

Hey everybody, I'm new to this project and noticed that it can't be built on Mac due to the use ofpreadv and pwritev , which doesn't exist for darwin. Is this the intent to fix this issue and if so, is there any chance there will be progress on that matter ?