MoonBit binding to libuv
moon update
moon add tonyfettes/uv{
"import": [
"tonyfettes/uv"
]
}fn main {
try {
let uv = @uv.Loop::new!()
let options = @uv.ProcessOptions::new(
"mkdir",
["mkdir", "test-dir"],
fn(process, exit_status, term_signal) {
println(
"Process exited with status \{exit_status} and signal \{term_signal}",
)
process.close(fn(_) { })
},
)
let process = uv.spawn!(options)
println("Launched process with ID \{(process).pid()}")
uv.run!(Default)
uv.stop()
uv.close!()
} catch {
error => println("Error: \{error}")
}
}trait ToNtbspub trait ToStream : ToHandle {
to_stream(Self) -> Stream
of_stream(Stream) -> Self
read_start(Self, (Self, Int) -> View, (Self, Int, View) -> Unit, (Self, Errno) -> Unit) -> Unit!Errno
read_stop(Self) -> Unit!Errno
write(Self, Array[View], (Write) -> Unit, (Write, Errno) -> Unit) -> Unit!Errno
listen(Self, Int, (Self) -> Unit, (Self, Errno) -> Unit) -> Unit!Errno
is_readable(Self) -> Bool
is_writable(Self) -> Bool
shutdown(Self, (Shutdown) -> Unit, (Shutdown, Errno) -> Unit) -> Unit!Errno
}type CopyFileFlagsfn CopyFileFlags::new(allow_exists~ : Bool = .., copy_on_write~ : CopyOnWrite = ..) -> CopyFileFlagstype Direntpub enum DirentType {
Unknown
File
Dir
Link
Fifo
Socket
Char
Block
}type FsEventfn FsEvent::start(self : FsEvent, path : String, flags : FsEventFlags, event_cb : (FsEvent, String?, Array[FsEventType]) -> Unit, error_cb : (FsEvent, String?, Errno) -> Unit) -> Unit!Errnopub enum FsEventType {
Rename
Change
}type Handletype Idletype Loopfn Loop::getaddrinfo(self : Loop, req : GetAddrInfo, getaddrinfo_cb : (GetAddrInfo, AddrInfo) -> Unit, error_cb : (GetAddrInfo, Errno) -> Unit, node : Bytes, service : Bytes, hints : FixedArray[AddrInfo]) -> Unit!Errnotype Mutextype OpenFlagstype Pipetype Processtype ProcessOptionsfn ProcessOptions::new[Ntbs : ToNtbs](file : Ntbs, args : Array[StringView], env? : Array[StringView], cwd? : StringView, stdio? : Array[StdioContainer], uid? : Uid, gid? : Gid, exit_cb : (Process, Int64, Int) -> Unit) -> ProcessOptionstype Signalpub enum Signum {
SIGHUP
SIGINT
SIGQUIT
SIGABRT
SIGTERM
SIGWINCH
}pub enum Status {
E2BIG
EACCES
EADDRINUSE
EADDRNOTAVAIL
EAFNOSUPPORT
EAGAIN
EAI_ADDRFAMILY
EAI_AGAIN
EAI_BADFLAGS
EAI_BADHINTS
EAI_CANCELED
EAI_FAIL
EAI_FAMILY
EAI_MEMORY
EAI_NODATA
EAI_NONAME
EAI_OVERFLOW
EAI_PROTOCOL
EAI_SERVICE
EAI_SOCKTYPE
EALREADY
EBADF
EBUSY
ECANCELED
ECHARSET
ECONNABORTED
ECONNREFUSED
ECONNRESET
EDESTADDRREQ
EEXIST
EFAULT
EFBIG
EHOSTUNREACH
EINTR
EINVAL
EIO
EISCONN
EISDIR
ELOOP
EMFILE
EMSGSIZE
ENAMETOOLONG
ENETDOWN
ENETUNREACH
ENFILE
ENOBUFS
ENODEV
ENOENT
ENOMEM
ENONET
ENOPROTOOPT
ENOSPC
ENOSYS
ENOTCONN
ENOTDIR
ENOTEMPTY
ENOTSOCK
ENOTSUP
EOVERFLOW
EPERM
EPIPE
EPROTO
EPROTONOSUPPORT
EPROTOTYPE
ERANGE
EROFS
ESHUTDOWN
ESPIPE
ESRCH
ETIMEDOUT
ETXTBSY
EXDEV
UNKNOWN
EOF
ENXIO
EMLINK
EHOSTDOWN
EREMOTEIO
ENOTTY
EFTYPE
EILSEQ
ESOCKTNOSUPPORT
ENODATA
EUNATCH
ENOEXEC
}type StdioContainerfn StdioContainer::create_pipe[Stream : ToStream + ToHandle](stream : Stream, readable~ : Bool = .., writable~ : Bool = .., non_block~ : Bool = ..) -> StdioContainertype Streamtype Tcptype Timertype Ttytype TtyModetype Utsnamefn getaddrinfo(self : Loop, req : GetAddrInfo, getaddrinfo_cb : (GetAddrInfo, AddrInfo) -> Unit, error_cb : (GetAddrInfo, Errno) -> Unit, node : Bytes, service : Bytes, hints : FixedArray[AddrInfo]) -> Unit!Errno