mozilla/rust — pull request #2134 by olsonjeffery (2012-04-05 18:42:14+00:00)
Title: practical impl of low-level libuv bindings, beginning work on higher-level bindings

Contained in this pull request are a few things:

1. Low level bindings for the ipv4 tcp request and server workflow. These map all of their data structs, so pretty much all of the data lives on the Rust stack (there is a c++ malloc for allocating uv buffers, but this is an exception and not the rule).
2. The beginnings of a high-level API (contained in `uv_hl.rs`). This work is contingent on getting some API for interacting with a global channel/task (where a process-wife libuv loop will live) from @brson.

Right now, the tcp server/request test (`test_uv_tcp_server_and_request`) is disabled on 32bit linux because of too many minefields that we're encountering because of, it seems, #2064. I will open another ticket to get this test passing.

The `uv` rust API has also been split up into multiple files, somewhat:

1. `std::uv` will continue to be the "top-level" module. It will import and re-export, as needed, all of the other uv submodules, like:
2. `std::uv::ll` aka `uv_ll.rs` -- contains the rust records corresponding to libuv C structs, as well as direct, low-level bindings to various bits of libuv API. Also some helper functions. This needs more docs.
3. `std::uv::hl` aka `uv_hl.rs` -- some initial thoughts, from me, for how the "high-level" API (to be used by libstd developers who want to write rust-idiomatic bindings to libuv facilities) should be structured. It's very WIP and useless, at the moment, pending some contributions from @brson.
4. The remaining contents of `std::uv` still run and work, as advertised by their tests, but I will deprecate their implementations soon and either remove them entirely or re-implement them using `uv::hl`, once the rest of that lands. The top-level `std::uv` document notes this fact.

Anyways: with this pull request landed, we'll be moving (quickly!) to implement a process-wide libuv loop that will be encapsulated in the `uv::hl` API. Once that work lands, we'll be able to paralellize adding the rest of the libuv API, as needed, to create high-level modules to meet the various IO needs for libstd.