Skip to content

Commit 03fe59a

Browse files
author
Eric Reed
committed
added bindings to extract udp handle from udp send requests
1 parent 74e7255 commit 03fe59a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/libstd/rt/uv/uvll.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ pub type uv_fs_t = c_void;
6666
pub type uv_udp_send_t = c_void;
6767

6868
pub type uv_idle_cb = *u8;
69+
pub type uv_alloc_cb = *u8;
70+
pub type uv_udp_send_cb = *u8;
71+
pub type uv_udp_recv_cb = *u8;
6972

7073
pub type sockaddr_in = c_void;
7174
pub type sockaddr_in6 = c_void;
@@ -198,27 +201,31 @@ pub unsafe fn udp_bind6(server: *uv_udp_t, addr: *sockaddr_in6, flags: c_uint) -
198201
}
199202

200203
pub unsafe fn udp_send<T>(req: *uv_udp_send_t, handle: *T, buf_in: &[uv_buf_t],
201-
addr: *sockaddr_in, cb: *u8) -> c_int {
204+
addr: *sockaddr_in, cb: uv_udp_send_cb) -> c_int {
202205
let buf_ptr = vec::raw::to_ptr(buf_in);
203206
let buf_cnt = buf_in.len() as i32;
204207
return rust_uv_udp_send(req, handle as *c_void, buf_ptr, buf_cnt, addr, cb);
205208
}
206209

207210
pub unsafe fn udp_send6<T>(req: *uv_udp_send_t, handle: *T, buf_in: &[uv_buf_t],
208-
addr: *sockaddr_in6, cb: *u8) -> c_int {
211+
addr: *sockaddr_in6, cb: uv_udp_send_cb) -> c_int {
209212
let buf_ptr = vec::raw::to_ptr(buf_in);
210213
let buf_cnt = buf_in.len() as i32;
211214
return rust_uv_udp_send(req, handle as *c_void, buf_ptr, buf_cnt, addr, cb);
212215
}
213216

214-
pub unsafe fn udp_recv_start(server: *uv_udp_t, on_alloc: *u8, on_recv: *u8) -> c_int {
217+
pub unsafe fn udp_recv_start(server: *uv_udp_t, on_alloc: uv_alloc_cb, on_recv: uv_udp_recv_cb) -> c_int {
215218
return rust_uv_udp_recv_start(server, on_alloc, on_recv);
216219
}
217220

218221
pub unsafe fn udp_recv_stop(server: *uv_udp_t) -> c_int {
219222
return rust_uv_udp_recv_stop(server);
220223
}
221224

225+
pub unsafe fn get_udp_handle_from_send_req(send_req: *uv_udp_send_t) -> *uv_udp_t {
226+
return rust_uv_get_udp_handle_from_send_req(send_req);
227+
}
228+
222229
pub unsafe fn tcp_init(loop_handle: *c_void, handle: *uv_tcp_t) -> c_int {
223230
return rust_uv_tcp_init(loop_handle, handle);
224231
}
@@ -269,7 +276,7 @@ pub unsafe fn write<T>(req: *uv_write_t, stream: *T, buf_in: &[uv_buf_t], cb: *u
269276
let buf_cnt = buf_in.len() as i32;
270277
return rust_uv_write(req as *c_void, stream as *c_void, buf_ptr, buf_cnt, cb);
271278
}
272-
pub unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, on_read: *u8) -> c_int {
279+
pub unsafe fn read_start(stream: *uv_stream_t, on_alloc: uv_alloc_cb, on_read: *u8) -> c_int {
273280
return rust_uv_read_start(stream as *c_void, on_alloc, on_read);
274281
}
275282

@@ -463,6 +470,7 @@ extern {
463470
buf_cnt: c_int, addr: *sockaddr_in6, cb: *u8) -> c_int;
464471
fn rust_uv_udp_recv_start(server: *uv_udp_t, on_alloc: *u8, on_recv: *u8) -> c_int;
465472
fn rust_uv_udp_recv_stop(server: *uv_udp_t) -> c_int;
473+
fn rust_uv_get_udp_handle_from_send_req(req: *uv_udp_send_t) -> *uv_udp_t;
466474

467475
fn rust_uv_listen(stream: *c_void, backlog: c_int, cb: *u8) -> c_int;
468476
fn rust_uv_accept(server: *c_void, client: *c_void) -> c_int;

0 commit comments

Comments
 (0)