@@ -17,6 +17,7 @@ use rt::uv::{Loop, Watcher, Request, UvError, Buf, NativeHandle, NullCallback,
17
17
status_to_maybe_uv_error} ;
18
18
use rt:: io:: net:: ip:: { IpAddr , Ipv4 , Ipv6 } ;
19
19
use rt:: uv:: last_uv_error;
20
+ use vec;
20
21
21
22
fn ip4_as_uv_ip4 < T > ( addr : IpAddr , f : & fn ( * sockaddr_in ) -> T ) -> T {
22
23
match addr {
@@ -161,7 +162,7 @@ pub struct TcpWatcher(*uvll::uv_tcp_t);
161
162
impl Watcher for TcpWatcher { }
162
163
163
164
impl TcpWatcher {
164
- pub fn new ( loop_ : & mut Loop ) -> TcpWatcher {
165
+ pub fn new ( loop_ : & Loop ) -> TcpWatcher {
165
166
unsafe {
166
167
let handle = malloc_handle ( UV_TCP ) ;
167
168
assert ! ( handle. is_not_null( ) ) ;
@@ -264,8 +265,8 @@ impl NativeHandle<*uvll::uv_tcp_t> for TcpWatcher {
264
265
pub struct UdpWatcher ( * uvll:: uv_udp_t ) ;
265
266
impl Watcher for UdpWatcher { }
266
267
267
- pub impl UdpWatcher {
268
- fn new ( loop_ : & mut Loop ) -> UdpWatcher {
268
+ impl UdpWatcher {
269
+ pub fn new ( loop_ : & mut Loop ) -> UdpWatcher {
269
270
unsafe {
270
271
let handle = malloc_handle ( UV_UDP ) ;
271
272
assert ! ( handle. is_not_null( ) ) ;
@@ -276,7 +277,7 @@ pub impl UdpWatcher {
276
277
}
277
278
}
278
279
279
- fn bind ( & mut self , address : IpAddr ) -> Result < ( ) , UvError > {
280
+ pub fn bind ( & mut self , address : IpAddr ) -> Result < ( ) , UvError > {
280
281
match address {
281
282
Ipv4 ( * ) => {
282
283
do ip4_as_uv_ip4 ( address) |addr| {
@@ -294,7 +295,7 @@ pub impl UdpWatcher {
294
295
}
295
296
}
296
297
297
- fn recv_start ( & mut self , alloc : AllocCallback , cb : UdpReceiveCallback ) {
298
+ pub fn recv_start ( & mut self , alloc : AllocCallback , cb : UdpReceiveCallback ) {
298
299
{
299
300
let data = self . get_watcher_data ( ) ;
300
301
data. alloc_cb = Some ( alloc) ;
@@ -325,12 +326,12 @@ pub impl UdpWatcher {
325
326
}
326
327
}
327
328
328
- fn recv_stop ( & mut self ) {
329
+ pub fn recv_stop ( & mut self ) {
329
330
let handle = self . native_handle ( ) ;
330
331
unsafe { uvll:: udp_recv_stop ( handle) ; }
331
332
}
332
333
333
- fn send ( & mut self , buf : Buf , address : IpAddr , cb : UdpSendCallback ) {
334
+ pub fn send ( & mut self , buf : Buf , address : IpAddr , cb : UdpSendCallback ) {
334
335
{
335
336
let data = self . get_watcher_data ( ) ;
336
337
assert ! ( data. udp_send_cb. is_none( ) ) ;
@@ -366,7 +367,7 @@ pub impl UdpWatcher {
366
367
}
367
368
}
368
369
369
- fn close ( self , cb : NullCallback ) {
370
+ pub fn close ( self , cb : NullCallback ) {
370
371
{
371
372
let mut this = self ;
372
373
let data = this. get_watcher_data ( ) ;
@@ -470,11 +471,10 @@ impl NativeHandle<*uvll::uv_write_t> for WriteRequest {
470
471
}
471
472
472
473
pub struct UdpSendRequest ( * uvll:: uv_udp_send_t ) ;
473
-
474
474
impl Request for UdpSendRequest { }
475
475
476
- pub impl UdpSendRequest {
477
- fn new ( ) -> UdpSendRequest {
476
+ impl UdpSendRequest {
477
+ pub fn new ( ) -> UdpSendRequest {
478
478
let send_handle = unsafe {
479
479
malloc_req ( UV_UDP_SEND )
480
480
} ;
@@ -483,14 +483,14 @@ pub impl UdpSendRequest {
483
483
UdpSendRequest ( send_handle)
484
484
}
485
485
486
- fn handle ( & self ) -> UdpWatcher {
486
+ pub fn handle ( & self ) -> UdpWatcher {
487
487
unsafe {
488
488
let udp_handle = uvll:: get_udp_handle_from_send_req ( self . native_handle ( ) ) ;
489
489
NativeHandle :: from_native_handle ( udp_handle)
490
490
}
491
491
}
492
492
493
- fn delete ( self ) {
493
+ pub fn delete ( self ) {
494
494
unsafe { free_req ( self . native_handle ( ) as * c_void ) }
495
495
}
496
496
}
0 commit comments