1///|
2extern type Handle
3
4///|
5extern "c" fn uv_close(handle : type Handle
Handle, cb : (type Handle
Handle) -> Unit
Unit) = "moonbit_uv_close"
6
7///|
8pub fn type Handle
Handle::(self : Handle, cb : (Handle) -> Unit) -> Unit
close(Handle
self : type Handle
Handle, (Handle) -> Unit
cb : (type Handle
Handle) -> Unit
Unit) -> Unit
Unit {
9 (handle : Handle, cb : (Handle) -> Unit) -> Unit
uv_close(Handle
self, (Handle) -> Unit
cb)
10}
11
12///|
13pub fn[Handle : trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle] (handle : Handle, cb : (Handle) -> Unit) -> Unit
close(Handle
handle : type parameter Handle
Handle, (Handle) -> Unit
cb : (type parameter Handle
Handle) -> Unit
Unit) -> Unit
Unit {
14 Handle
handle.(Handle, (Handle) -> Unit) -> Unit
close((Handle) -> Unit
cb)
15}
16
17///|
18extern "c" fn uv_is_closing(handle : type Handle
Handle) -> Bool
Bool = "moonbit_uv_is_closing"
19
20///|
21pub fn type Handle
Handle::(self : Handle) -> Bool
is_closing(Handle
self : type Handle
Handle) -> Bool
Bool {
22 (handle : Handle) -> Bool
uv_is_closing(Handle
self)
23}
24
25///|
26pub fn[Handle : trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle] (handle : Handle) -> Bool
is_closing(Handle
handle : type parameter Handle
Handle) -> Bool
Bool {
27 Handle
handle.(Handle) -> Bool
is_closing()
28}
29
30///|
31pub trait trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle {
32 (Self) -> Handle
to_handle(type parameter Self
Self) -> type Handle
Handle
33 (Handle) -> Self
of_handle(type Handle
Handle) -> type parameter Self
Self
34 (Self, (Self) -> Unit) -> Unit
close(type parameter Self
Self, (type parameter Self
Self) -> Unit
Unit) -> Unit
Unit = _
35 (Self) -> Bool
is_closing(type parameter Self
Self) -> Bool
Bool = _
36}
37
38///|
39impl trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle with (self : Self, cb : (Self) -> Unit) -> Unit
close(Self
self, (Self) -> Unit
cb) {
40 fn (Handle) -> Unit
uv_cb(Handle
handle : type Handle
Handle) {
41 (Self) -> Unit
cb(trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle(_ : Handle) -> Self
::of_handle(Handle
handle))
42 }
43
44 Self
self.(Self) -> Handle
to_handle().(self : Handle, cb : (Handle) -> Unit) -> Unit
close((Handle) -> Unit
uv_cb)
45}
46
47///|
48impl trait ToHandle {
to_handle(Self) -> Handle
of_handle(Handle) -> Self
close(Self, (Self) -> Unit) -> Unit
is_closing(Self) -> Bool
}
ToHandle with (self : Self) -> Bool
is_closing(Self
self) {
49 return Self
self.(Self) -> Handle
to_handle().(self : Handle) -> Bool
is_closing()
50}
51