Sign in

    uv

    MoonBit binding to libuv

    Download zip
    Version
    0.12.12
    License
    Apache-2.0
    Last updated
    8 months ago
    Downloads
    1K

    #tonyfettes/uv

    This is a MoonBit binding to the libuv library.

    #Quickstart

    1. Add this module as a dependency to your MoonBit project.

      moon update moon add tonyfettes/uv

    2. Import tonyfettes/uv package where you need it.

      { "import": [ "tonyfettes/uv" ] }

    3. Use the tonyfettes/uv package in your MoonBit project.

      fn main {
      try {
      let uv = @uv.Loop::new()
      let options = @uv.ProcessOptions::new(
      "moon",
      ["moon", "version"],
      fn(process, exit_status, term_signal) {
      println(
      "Process exited with status \{exit_status} and signal \{term_signal}",
      )
      process.close(() => ())
      },
      )
      let process = uv.spawn(options)
      println("Launched process with ID \{(process).pid()}")
      uv.run(Default)
      uv.stop()
      uv.close()
      } catch {
      error => println("Error: \{error}")
      }
      }

    #Roadmap

    The following libuv APIs are not yet implemented in this library:

    #Handle Functions

    • uv_ref() - Reference counting for handles
    • uv_unref() - Unreference handles
    • uv_has_ref() - Check handle reference status

    #Process Functions

    • uv_get_osfhandle() - Get OS handle from file descriptor
    • uv_open_osfhandle() - Open file descriptor from OS handle

    Cancelable

    pub trait Cancelable : ToReq {
    cancel(Self) -> Unit raise Errno
    }

    Share

    pub trait Share {
    share(Self) -> Self
    }

    Shares an object safely between threads.

    In MoonBit, the default reference counting (RC) for objects is not atomic, so it is not safe to share most objects directly between threads.

    To enable safe sharing, we use a separate atomic reference counter (ARC) stored alongside the actual object data. The MoonBit object itself is managed by non-atomic RC, but the shared payload is managed by ARC.

    When you want to share an object:
    • The MoonBit object holds a pointer to a heap-allocated block containing both the ARC and the payload (e.g., a mutex or thread handle).
    • Copying the MoonBit object only copies the pointer; the ARC is incremented atomically (guarded by a mutex if needed).
    • When a copy is dropped, the ARC is decremented atomically. When ARC reaches zero, the payload is freed.

    Example: uv_thread_t stores an arc field and a uv_mutex_t object in a heap-allocated block. All increments/decrements of arc are protected by the mutex to ensure thread safety.

    Diagram:

    (thread 0) (thread 1) +--------+ +--------+ | rc (M) | | rc (M) | +--------+ +--------+ \ / \---> +---------+ <---/ | arc (F) | +---------+ | mutex | +---------+ | payload | +---------+

    The Share trait provides a share method to allow implementor of this trait to create a new MoonBit object pointing to the same shared payload, incrementing the ARC safely.

    ToHandle

    pub trait ToHandle {
    to_handle(Self) -> Handle
    of_handle(Handle) -> Self
    close(Self, () -> Unit) -> Unit
    is_closing(Self) -> Bool
    loop_(Self) -> Loop
    fileno(Self) -> OsFd raise Errno
    os_sock(Self) -> OsSock raise Errno
    get_send_buffer_size(Self) -> Int raise Errno
    set_send_buffer_size(Self, Int) -> Unit raise Errno
    get_recv_buffer_size(Self) -> Int raise Errno
    set_recv_buffer_size(Self, Int) -> Unit raise Errno
    }

    ToReq

    pub trait ToReq {
    to_req(Self) -> Req
    type_(self : Self) -> ReqType
    }

    ToSockaddr

    pub trait ToSockaddr : ToJson {
    to_sockaddr(self : Self) -> Sockaddr
    of_sockaddr(self : Sockaddr) -> Self?
    ip_name(self : Self) -> Bytes raise Errno
    }

    ToStream

    pub trait ToStream : ToHandle {
    to_stream(Self) -> Stream
    of_stream(Stream) -> Self
    read_start(Self, (Self, Int) -> BytesView, (Self, Int, BytesView) -> Unit, (Self, Errno) -> Unit) -> Unit raise Errno
    read_stop(Self) -> Unit raise Errno
    write(Self, Array[BytesView], () -> Unit, (Errno) -> Unit) -> Write raise Errno
    try_write(Self, Array[BytesView], () -> Unit, (Errno) -> Unit) -> Write raise Errno
    listen(Self, Int, (Self) -> Unit, (Self, Errno) -> Unit) -> Unit raise Errno
    is_readable(Self) -> Bool
    is_writable(Self) -> Bool
    shutdown(Self, () -> Unit, (Errno) -> Unit) -> Shutdown raise Errno
    set_blocking(Self, Bool) -> Unit raise Errno
    write_queue_size(Self) -> UInt64
    }

    DlError

    type DlError

    Errno

    pub(all) suberror Errno {
    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
    }

    impl Eq for Errno
    impl Hash for Errno
    impl Show for Errno

    Errno::to_bytes

    fn Errno::to_bytes(self : Errno) -> Bytes

    AccessFlags

    type AccessFlags

    AccessFlags::new

    fn AccessFlags::new(read? : Bool, write? : Bool, execute? : Bool) -> AccessFlags

    AccessHint

    pub(all) enum AccessHint {
    Random
    Sequential
    }

    AddrInfo

    type AddrInfo

    AddrInfo::addr

    fn AddrInfo::addr(self : AddrInfo) -> Sockaddr

    AddrInfo::canonname

    fn AddrInfo::canonname(self : AddrInfo) -> Bytes?

    AddrInfo::family

    fn AddrInfo::family(self : AddrInfo) -> AddressFamily raise Errno

    AddrInfo::protocol

    fn AddrInfo::protocol(self : AddrInfo) -> Protocol raise Errno

    AddrInfo::socktype

    fn AddrInfo::socktype(self : AddrInfo) -> SockType raise Errno

    AddrInfoFlags

    type AddrInfoFlags

    AddrInfoFlags::new

    fn AddrInfoFlags::new(passive? : Bool, canonname? : Bool, numeric_host? : Bool, numeric_serv? : Bool, all? : Bool, addrconfig? : Bool, v4mapped? : Bool) -> AddrInfoFlags

    AddrInfoHints

    type AddrInfoHints

    AddrInfoHints::new

    fn AddrInfoHints::new(flags? : AddrInfoFlags, family? : AddressFamily, socktype? : SockType, protocol? : Protocol) -> AddrInfoHints

    AddressFamily

    pub(all) enum AddressFamily {
    Inet
    Inet6
    }

    Represents the address family for network communication, specifying the format of network addresses.

    Constructors:

    • Inet : IPv4 address family
    • Inet6 : IPv6 address family

    Example:

    let ipv4 = AddressFamily::inet()
    let ipv6 = AddressFamily::inet6()
    @assert.t(ipv4 is Inet)
    @assert.t(ipv6 is Inet6)

    AddressFamily::inet

    AddressFamily::inet6

    Async

    type Async

    Wake up the event loop and call the async handle’s callback.

    RETURNS: 0 on success, or an error code < 0 on failure.

    Note: It’s safe to call this function from any thread. The callback will be called on the loop thread.

    Note: uv_async_send() is async-signal-safe. It’s safe to call this function from a signal handler.

    Warning: libuv will coalesce calls to uv_async_send(), that is, not every call to it will yield an execution of the callback. For example: if uv_async_send() is called 5 times in a row before the callback is called, the callback will only be called once. If uv_async_send() is called again after the callback was called, it will be called again.
    impl ToHandle for Async

    Async::new

    fn Async::new(self : Loop, cb : (Async) -> Unit) -> Async raise Errno

    Create a new async handle.

    @param cb The callback to execute when the async handle is triggered @return A new Async handle @raise Errno if the async handle could not be created

    Async::send

    fn Async::send(self : Async) -> Unit raise Errno

    Wake up the event loop and call the async handle's callback.

    This function is async-signal-safe and can be called from any thread. Multiple calls to send() may result in only one callback execution due to coalescing. The callback is guaranteed to be called at least once after send() is called.

    @return Unit @raise Errno if the send operation failed

    Barrier

    type Barrier

    Barrier::new

    fn Barrier::new(count : UInt) -> Barrier raise Errno

    Barrier::wait

    fn Barrier::wait(self : Barrier) -> Bool raise Errno

    Check

    type Check

    Handle for check watchers in the libuv event loop.

    Check watchers run their callbacks once per event loop iteration, right after the event loop has blocked for I/O. They are essentially the counterpart of prepare handles.

    Example:

    let uv = @uv.Loop::new()
    let check = @uv.Check::new(uv)
    let errors = []
    check.start(fn(_) {
    println("Check callback running")
    check.stop() catch {
    error => errors.push(error)
    }
    check.close(() => ())
    })
    uv.fs_open(
    "test/fixtures/example.txt",
    @uv.OpenFlags::read_only(),
    0o644,
    _ => (),
    error => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }
    impl ToHandle for Check

    Check::new

    fn Check::new(self : Loop) -> Check raise Errno

    Check::start

    fn Check::start(self : Check, cb : (Check) -> Unit) -> Unit raise Errno

    Check::stop

    fn Check::stop(self : Check) -> Unit raise Errno

    ClockId

    pub(all) enum ClockId {
    Monotonic
    Realtime
    }

    Cond

    type Cond

    Condition variable for thread synchronization.

    Condition variables are used in combination with mutexes to allow threads to wait for certain conditions to be met. A thread can wait on a condition variable while holding a mutex, and other threads can signal or broadcast to wake up waiting threads.

    Condition variables must always be used with mutexes. The typical pattern is:
    1. Lock the mutex
    2. Check the condition in a loop
    3. If condition not met, wait on the condition variable
    4. When signaled, the loop continues and rechecks the condition
    5. Unlock the mutex when done
    impl Share for Cond

    Cond::broadcast

    fn Cond::broadcast(self : Cond) -> Unit

    Broadcast to all waiting threads.

    Wake up all threads that are waiting on this condition variable. If no threads are waiting, this call has no effect.

    Cond::new

    fn Cond::new() -> Cond raise Errno

    Cond::signal

    fn Cond::signal(self : Cond) -> Unit

    Signal one waiting thread.

    Wake up one thread that is waiting on this condition variable. If no threads are waiting, this call has no effect.

    Cond::timedwait

    fn Cond::timedwait(self : Cond, mutex : Mutex, timeout_ns : UInt64) -> Unit raise Errno

    Wait on the condition variable with a timeout.

    Similar to wait(), but will return after the specified timeout (in nanoseconds) even if no signal was received.

    Returns:
    • Ok(()) if signaled before timeout
    • Err(ETIMEDOUT) if timeout occurred
    • Err(_) for other errors

    Note

    This function can experience spurious wakeups. Always use this in a loop that checks the actual condition.

    Cond::wait

    fn Cond::wait(self : Cond, mutex : Mutex) -> Unit

    Wait on the condition variable.

    The calling thread will block until another thread calls signal() or broadcast() on this condition variable. The mutex must be locked by the calling thread prior to calling this function. The mutex will be automatically unlocked while waiting and re-locked before returning.

    Note

    This function can experience spurious wakeups. Always use this in a loop that checks the actual condition.

    Connect

    type Connect

    impl ToReq for Connect

    CopyFileFlags

    type CopyFileFlags

    CopyFileFlags::new

    fn CopyFileFlags::new(allow_exists? : Bool, copy_on_write? : CopyOnWrite) -> CopyFileFlags

    CopyOnWrite

    pub(all) enum CopyOnWrite {
    False
    True
    Force
    }

    CpuInfo

    type CpuInfo

    CpuInfo::cpu_times

    fn CpuInfo::cpu_times(self : CpuInfo) -> CpuTimes

    CpuInfo::model

    fn CpuInfo::model(self : CpuInfo) -> Bytes

    CpuInfo::speed

    fn CpuInfo::speed(self : CpuInfo) -> Int

    CpuSet

    type CpuSet

    impl BitAnd for CpuSet
    impl BitOr for CpuSet
    impl BitXOr for CpuSet
    impl Eq for CpuSet

    CpuSet::clear

    fn CpuSet::clear(self : CpuSet, cpu : Int) -> Unit

    CpuSet::count

    fn CpuSet::count(self : CpuSet) -> Int

    CpuSet::intersect

    fn CpuSet::intersect(self : CpuSet, other : CpuSet) -> CpuSet

    CpuSet::is_set

    fn CpuSet::is_set(self : CpuSet, cpu : Int) -> Bool

    CpuSet::new

    fn CpuSet::new() -> CpuSet raise Errno

    CpuSet::set

    fn CpuSet::set(self : CpuSet, cpu : Int) -> Unit

    CpuSet::union

    fn CpuSet::union(self : CpuSet, other : CpuSet) -> CpuSet

    CpuSet::xor

    fn CpuSet::xor(self : CpuSet, other : CpuSet) -> CpuSet

    CpuSet::zero

    fn CpuSet::zero(self : CpuSet) -> Unit

    CpuTimes

    type CpuTimes

    CpuTimes::idle

    fn CpuTimes::idle(self : CpuTimes) -> UInt64

    CpuTimes::irq

    fn CpuTimes::irq(self : CpuTimes) -> UInt64

    CpuTimes::nice

    fn CpuTimes::nice(self : CpuTimes) -> UInt64

    CpuTimes::sys

    fn CpuTimes::sys(self : CpuTimes) -> UInt64

    CpuTimes::user

    fn CpuTimes::user(self : CpuTimes) -> UInt64

    Dir

    type Dir

    Dirent

    type Dirent

    Dirent::name

    fn Dirent::name(self : Dirent) -> Bytes

    Dirent::type_

    fn Dirent::type_(self : Dirent) -> DirentType

    DirentType

    pub enum DirentType {
    Unknown
    File
    Dir
    Link
    Fifo
    Socket
    Char
    Block
    }

    Type of directory entry, indicating the file system object kind.

    Environ

    type Environ

    Environ::iter2

    fn Environ::iter2(self : Environ) -> Iter2[Bytes, Bytes]

    File

    type File

    File::of_int

    fn File::of_int(fd : Int) -> File

    File::to_int

    fn File::to_int(self : File) -> Int

    type Fs

    impl Cancelable for Fs
    impl ToReq for Fs

    FsEvent

    type FsEvent

    impl ToHandle for FsEvent

    FsEvent::get_path

    fn FsEvent::get_path(self : FsEvent) -> Bytes raise Errno

    FsEvent::new

    fn FsEvent::new(self : Loop) -> FsEvent raise Errno

    FsEvent::start

    fn FsEvent::start(self : FsEvent, path : Bytes, flags : FsEventFlags, event_cb : (FsEvent, Bytes?, Array[FsEventType]) -> Unit, error_cb : (FsEvent, Bytes?, Errno) -> Unit) -> Unit raise Errno

    FsEvent::stop

    fn FsEvent::stop(self : FsEvent) -> Unit raise Errno

    FsEventFlags

    type FsEventFlags

    FsEventFlags::new

    fn FsEventFlags::new(recursive? : Bool) -> FsEventFlags

    FsEventType

    pub enum FsEventType {
    Rename
    Change
    }

    FsPoll

    type FsPoll

    impl ToHandle for FsPoll

    FsPoll::get_path

    fn FsPoll::get_path(self : FsPoll) -> Bytes raise Errno

    FsPoll::new

    fn FsPoll::new(self : Loop) -> FsPoll raise Errno

    FsPoll::start

    fn FsPoll::start(self : FsPoll, path : Bytes, interval : UInt, poll_cb : (FsPoll, Stat, Stat) -> Unit, error_cb : (FsPoll, Errno) -> Unit) -> Unit raise Errno

    FsPoll::stop

    fn FsPoll::stop(self : FsPoll) -> Unit raise Errno

    GetAddrInfo

    type GetAddrInfo

    GetNameInfo

    type GetNameInfo

    Gid

    pub(all) type Gid UInt64

    Gid::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn Gid::inner(self : Gid) -> UInt64
    Convert newtype to its underlying type, automatically derived.

    Group

    type Group

    Group::gid

    fn Group::gid(group : Group) -> Gid

    Group::members

    fn Group::members(group : Group) -> FixedArray[Bytes]

    Group::name

    fn Group::name(group : Group) -> Bytes

    Handle

    type Handle

    Handle::close

    fn Handle::close(self : Handle, cb : () -> Unit) -> Unit

    Handle::is_closing

    fn Handle::is_closing(self : Handle) -> Bool

    HandleType

    pub enum HandleType {
    Unknown
    Async
    Check
    FsEvent
    FsPoll
    Handle
    Idle
    Pipe
    Poll
    Prepare
    Process
    Stream
    Tcp
    Timer
    Tty
    Udp
    Signal
    File
    }

    Idle

    type Idle

    Handle for idle watchers in the libuv event loop.

    Idle watchers run their callbacks once per event loop iteration, right before the event loop blocks for I/O. They are useful for performing background tasks when the event loop is idle.

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let idle = @uv.Idle::new(uv)
    idle.start(fn(_) {
    println("Idle callback running")
    idle.stop() catch {
    error => errors.push(error)
    }
    idle.close(() => ())
    })
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }
    impl ToHandle for Idle

    Idle::new

    fn Idle::new(self : Loop) -> Idle raise Errno

    Idle::start

    fn Idle::start(self : Idle, cb : (Idle) -> Unit) -> Unit raise Errno

    Idle::stop

    fn Idle::stop(self : Idle) -> Unit raise Errno

    IfIndex

    type IfIndex

    impl Show for IfIndex
    impl ToJson for IfIndex

    IfIndex::to_iid

    fn IfIndex::to_iid(self : IfIndex) -> Bytes raise

    IfIndex::to_name

    fn IfIndex::to_name(self : IfIndex) -> Bytes raise

    In6Addr

    type In6Addr

    impl ToJson for In6Addr

    In6Addr::new

    fn In6Addr::new(h0 : UInt16, h1 : UInt16, h2 : UInt16, h3 : UInt16, h4 : UInt16, h5 : UInt16, h6 : UInt16, h7 : UInt16) -> In6Addr

    In6Addr::ntop

    fn In6Addr::ntop(self : In6Addr) -> Bytes raise Errno

    In6Addr::pton

    fn In6Addr::pton(src : Bytes) -> In6Addr raise Errno

    In6Addr::to_bytes

    fn In6Addr::to_bytes(self : In6Addr) -> Bytes

    InAddr

    type InAddr

    impl ToJson for InAddr

    InAddr::new

    fn InAddr::new(b0 : Byte, b1 : Byte, b2 : Byte, b3 : Byte) -> InAddr

    InAddr::ntop

    fn InAddr::ntop(self : InAddr) -> Bytes raise Errno

    InAddr::pton

    fn InAddr::pton(src : Bytes) -> InAddr raise Errno

    InAddr::to_bytes

    fn InAddr::to_bytes(self : InAddr) -> Bytes

    InterfaceAddress

    pub struct InterfaceAddress {
    name : Bytes
    phys_addr : PhysAddr
    is_internal : Bool
    address : Sockaddr
    netmask : Sockaddr
    }

    Key

    type Key

    Key::get

    fn[T] Key::get(self : Key) -> T?

    Key::new

    fn Key::new() -> Key raise Errno

    Key::set

    fn[T] Key::set(self : Key, value : T) -> Unit

    Lib

    type Lib

    Lib::open

    fn Lib::open(filename : Bytes) -> Lib raise DlError

    Lib::symbol

    fn[T] Lib::symbol(lib : Lib, name : Bytes) -> T?

    Loop

    type Loop

    Loop::alive

    fn Loop::alive(uv : Loop) -> Bool

    Loop::backend_fd

    fn Loop::backend_fd(uv : Loop) -> Int raise Errno

    Loop::backend_timeout

    fn Loop::backend_timeout(uv : Loop) -> Int raise Errno

    Loop::close

    fn Loop::close(self : Loop) -> Unit raise Errno

    Closes the event loop and releases its associated resources.

    Parameters:

    • self : The event loop to close.

    Throws an error of type Errno if the loop cannot be closed properly, such as when there are still active handles or requests associated with the loop.

    Example:

    let uv = @uv.Loop::new()
    uv.close()

    Loop::configure

    fn Loop::configure(self : Loop, option : LoopOption) -> Unit raise Errno

    Loop::fork

    fn Loop::fork(uv : Loop) -> Unit raise Errno

    Loop::fs_access

    #as_free_fn
    fn Loop::fs_access(self : Loop, path : Bytes, mode : AccessFlags, access_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_access_sync

    #as_free_fn
    fn Loop::fs_access_sync(self : Loop, path : Bytes, mode : AccessFlags) -> Unit raise Errno

    Loop::fs_chmod

    #as_free_fn
    fn Loop::fs_chmod(self : Loop, path : Bytes, mode : Int, chmod_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously changes the permissions of a file.

    This function initiates a file permission change operation that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The file path whose permissions to change as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • mode : The new file permissions (octal notation, e.g., 0o644 for read/write for owner, read-only for group and others).
    • chmod_cb : Success callback function that receives the filesystem request handle when the permission change succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Note: On Windows, this function can only modify the write permission bit. All other permission bits are ignored.

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/example-chmod.txt"
    uv.fs_chmod(
    path,
    0o644, // rw-r--r--
    () => (),
    error => errors.push(error)
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_chmod_sync

    #as_free_fn
    fn Loop::fs_chmod_sync(self : Loop, path : Bytes, mode : Int) -> Unit raise Errno

    Synchronously changes the permissions of a file.

    This function blocks the current thread until the file permission change operation completes. Unlike the asynchronous fs_chmod function, this operation does not require callbacks and returns immediately upon completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The file path whose permissions to change as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • mode : The new file permissions (octal notation, e.g., 0o644 for read/write for owner, read-only for group and others).

    Throws an error of type Errno if the permissions cannot be changed (e.g., file does not exist, insufficient permissions, or system resource exhaustion).

    Note: On Windows, this function can only modify the write permission bit. All other permission bits are ignored.

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/example-chmod-sync.txt"
    uv.fs_chmod_sync(path, 0o644) // rw-r--r--
    uv.close()

    Loop::fs_chown

    #as_free_fn
    fn Loop::fs_chown(self : Loop, path : Bytes, uid : Uid, gid : Gid, chown_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously changes the owner and group of a file.

    This function initiates a file ownership change operation that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The file path whose ownership to change as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • uid : The new user ID (UID) for the file. Use -1 (or UInt::max_value) to leave the current owner unchanged.
    • gid : The new group ID (GID) for the file. Use -1 (or UInt::max_value) to leave the current group unchanged.
    • chown_cb : Success callback function that receives the filesystem request handle when the ownership change succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Note: On Windows, this function is a no-op and always succeeds since Windows doesn't use the same ownership model as Unix-like systems.

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/example.txt"
    let passwd = @uv.os_get_passwd()
    uv.fs_chown(
    path,
    passwd.uid(),
    passwd.gid(),
    () => println("Ownership changed successfully"),
    error => errors.push(error)
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_chown_sync

    #as_free_fn
    fn Loop::fs_chown_sync(self : Loop, path : Bytes, uid : Uid, gid : Gid) -> Unit raise Errno

    Synchronously changes the owner and group of a file.

    This function blocks the current thread until the file ownership change operation completes. Unlike the asynchronous fs_chown function, this operation does not require callbacks and returns immediately upon completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The file path whose ownership to change as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • uid : The new user ID (UID) for the file. Use -1 (or UInt::max_value) to leave the current owner unchanged.
    • gid : The new group ID (GID) for the file. Use -1 (or UInt::max_value) to leave the current group unchanged.

    Throws an error of type Errno if the ownership cannot be changed (e.g., file does not exist, insufficient permissions, or system resource exhaustion).

    Note: On Windows, this function is a no-op and always succeeds since Windows doesn't use the same ownership model as Unix-like systems.

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/example.txt"
    let passwd = @uv.os_get_passwd()
    uv.fs_chown_sync(path, passwd.uid(), passwd.gid())
    uv.close()

    Loop::fs_close

    #as_free_fn
    fn Loop::fs_close(self : Loop, file : File, close_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously closes a file descriptor.

    This function initiates a file close operation that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor to close, typically obtained from fs_open or fs_open_sync.
    • close_cb : Success callback function that receives the filesystem request handle when the file is closed successfully.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Example:

    let uv = Loop::new()
    let errors = []
    let file = uv.fs_open_sync("README.md", OpenFlags::read_only(), 0o644)
    uv.fs_close(
    file,
    () => println("File closed successfully"),
    (error) => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_close_sync

    #as_free_fn
    fn Loop::fs_close_sync(self : Loop, file : File) -> Unit raise Errno

    Loop::fs_closedir

    #as_free_fn
    fn Loop::fs_closedir(self : Loop, dir : Dir, closedir_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_copyfile

    #as_free_fn
    fn Loop::fs_copyfile(self : Loop, path : Bytes, new_path : Bytes, flags : CopyFileFlags, copy_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_copyfile_sync

    #as_free_fn
    fn Loop::fs_copyfile_sync(self : Loop, path : Bytes, new_path : Bytes, flags : CopyFileFlags) -> Unit raise Errno

    Loop::fs_fchmod

    #as_free_fn
    fn Loop::fs_fchmod(self : Loop, file : File, mode : Int, fchmod_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously changes the permissions of a file by file descriptor.

    This function initiates a file permission change operation using a file descriptor that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor whose permissions to change, typically obtained from fs_open or fs_open_sync.
    • mode : The new file permissions (octal notation, e.g., 0o644 for read/write for owner, read-only for group and others).
    • fchmod_cb : Success callback function that receives the filesystem request handle when the permission change succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Note: On Windows, this function can only modify the write permission bit. All other permission bits are ignored.

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/example-fchmod.txt"
    let file = uv.fs_open_sync(path, @uv.OpenFlags::read_write(), 0o644)
    uv.fs_fchmod(
    file,
    0o600, // rw-------
    () => {
    try uv.fs_close_sync(file) catch { e => errors.push(e) }
    },
    error => {
    errors.push(error)
    try uv.fs_close_sync(file) catch { e => errors.push(e) }
    }
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_fchmod_sync

    #as_free_fn
    fn Loop::fs_fchmod_sync(self : Loop, file : File, mode : Int) -> Unit raise Errno

    Synchronously changes the permissions of a file by file descriptor.

    This function blocks the current thread until the file permission change operation completes. Unlike the asynchronous fs_fchmod function, this operation does not require callbacks and returns immediately upon completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • file : The file descriptor whose permissions to change, typically obtained from fs_open or fs_open_sync.
    • mode : The new file permissions (octal notation, e.g., 0o644 for read/write for owner, read-only for group and others).

    Throws an error of type Errno if the permissions cannot be changed (e.g., invalid file descriptor, insufficient permissions, or system resource exhaustion).

    Note: On Windows, this function can only modify the write permission bit. All other permission bits are ignored.

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/example-fchmod-sync.txt"
    let file = uv.fs_open_sync(path, @uv.OpenFlags::read_write(), 0o644)
    uv.fs_fchmod_sync(file, 0o600) // rw-------
    uv.fs_close_sync(file)
    uv.close()

    Loop::fs_fchown

    #as_free_fn
    fn Loop::fs_fchown(self : Loop, file : File, uid : Uid, gid : Gid, fchown_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously changes the owner and group of a file by file descriptor.

    This function initiates a file ownership change operation using a file descriptor that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor whose ownership to change, typically obtained from fs_open or fs_open_sync.
    • uid : The new user ID (UID) for the file. Use -1 (or UInt::max_value) to leave the current owner unchanged.
    • gid : The new group ID (GID) for the file. Use -1 (or UInt::max_value) to leave the current group unchanged.
    • fchown_cb : Success callback function that receives the filesystem request handle when the ownership change succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Note: On Windows, this function is a no-op and always succeeds since Windows doesn't use the same ownership model as Unix-like systems.

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/example.txt"
    let passwd = @uv.os_get_passwd()
    let file = uv.fs_open_sync(path, @uv.OpenFlags::read_write(), 0o644)
    uv.fs_fchown(
    file,
    passwd.uid(),
    passwd.gid(),
    () => {
    try uv.fs_close_sync(file) catch { e => errors.push(e) }
    },
    error => {
    errors.push(error)
    try uv.fs_close_sync(file) catch { e => errors.push(e) }
    }
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_fchown_sync

    #as_free_fn
    fn Loop::fs_fchown_sync(self : Loop, file : File, uid : Uid, gid : Gid) -> Unit raise Errno

    Synchronously changes the owner and group of a file by file descriptor.

    This function blocks the current thread until the file ownership change operation completes. Unlike the asynchronous fs_fchown function, this operation does not require callbacks and returns immediately upon completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • file : The file descriptor whose ownership to change, typically obtained from fs_open or fs_open_sync.
    • uid : The new user ID (UID) for the file. Use -1 (or UInt::max_value) to leave the current owner unchanged.
    • gid : The new group ID (GID) for the file. Use -1 (or UInt::max_value) to leave the current group unchanged.

    Throws an error of type Errno if the ownership cannot be changed (e.g., invalid file descriptor, insufficient permissions, or system resource exhaustion).

    Note: On Windows, this function is a no-op and always succeeds since Windows doesn't use the same ownership model as Unix-like systems.

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/example.txt"
    let file = uv.fs_open_sync(path, @uv.OpenFlags::read_write(), 0o644)
    let passwd = @uv.os_get_passwd()
    // Change to user ID 1000 and group ID 1000
    uv.fs_fchown_sync(file, passwd.uid(), passwd.gid())
    uv.fs_close_sync(file)
    uv.close()

    Loop::fs_fdatasync

    #as_free_fn
    fn Loop::fs_fdatasync(self : Loop, file : File, sync_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously synchronizes a file's data with storage.

    This function initiates a file data sync operation that will be handled asynchronously by the event loop. The sync operation ensures that all in-memory data changes for the file are written to the underlying storage device, but does not necessarily synchronize metadata. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    This is equivalent to the fdatasync() system call, which synchronizes only the file's data but not necessarily the metadata (such as timestamps). This can be faster than fs_fsync since it doesn't need to wait for metadata writes.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor to synchronize, typically obtained from fs_open or fs_open_sync.
    • sync_cb : Success callback function that receives the filesystem request handle when the data sync operation completes successfully.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/datasync-test.txt"
    let file = uv.fs_open_sync(
    path,
    @uv.OpenFlags::write_only(create=true),
    0o644
    )
    let data : Bytes = "Hello, World!"
    uv.fs_write_sync(file, [data])
    uv.fs_fdatasync(
    file,
    () => println("File data synced successfully"),
    error => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_fdatasync_sync

    #as_free_fn
    fn Loop::fs_fdatasync_sync(self : Loop, file : File) -> Unit raise Errno

    Synchronously synchronizes a file's data with storage.

    This function blocks the current thread until the file data sync operation completes. Unlike the asynchronous fs_fdatasync function, this operation does not require callbacks and returns immediately upon successful completion or failure.

    This is equivalent to the fdatasync() system call, which synchronizes only the file's data but not necessarily the metadata (such as timestamps). This can be faster than fs_fsync_sync since it doesn't need to wait for metadata writes.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • file : The file descriptor to synchronize, typically obtained from fs_open or fs_open_sync.

    Throws an error of type Errno if the file data cannot be synchronized (e.g., invalid file descriptor, I/O error, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/datasync-test-sync.txt"
    let file = uv.fs_open_sync(
    path,
    @uv.OpenFlags::write_only(create=true),
    0o644
    )
    let data : Bytes = "Hello, World!"
    uv.fs_write_sync(file, [data])
    uv.fs_fdatasync_sync(file)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()

    Loop::fs_fstat

    #as_free_fn
    fn Loop::fs_fstat(self : Loop, file : File, fstat_cb : (Stat) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_fsync

    #as_free_fn
    fn Loop::fs_fsync(self : Loop, file : File, sync_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously synchronizes a file's data and metadata with storage.

    This function initiates a file sync operation that will be handled asynchronously by the event loop. The sync operation ensures that all in-memory data and metadata changes for the file are written to the underlying storage device. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    This is equivalent to the fsync() system call, which synchronizes both the file's data and metadata (such as timestamps and file size).

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor to synchronize, typically obtained from fs_open or fs_open_sync.
    • sync_cb : Success callback function that receives the filesystem request handle when the sync operation completes successfully.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/sync-test.txt"
    let file = uv.fs_open_sync(
    path,
    @uv.OpenFlags::write_only(create=true),
    0o644
    )
    let data : Bytes = "Hello, World!"
    uv.fs_write_sync(file, [data])
    uv.fs_fsync(
    file,
    () => println("File synced successfully"),
    error => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_fsync_sync

    #as_free_fn
    fn Loop::fs_fsync_sync(self : Loop, file : File) -> Unit raise Errno

    Synchronously synchronizes a file's data and metadata with storage.

    This function blocks the current thread until the file sync operation completes. Unlike the asynchronous fs_fsync function, this operation does not require callbacks and returns immediately upon successful completion or failure.

    This is equivalent to the fsync() system call, which synchronizes both the file's data and metadata (such as timestamps and file size).

    Parameters:

    • self : The event loop instance to perform the operation on.
    • file : The file descriptor to synchronize, typically obtained from fs_open or fs_open_sync.

    Throws an error of type Errno if the file cannot be synchronized (e.g., invalid file descriptor, I/O error, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/sync-test-sync.txt"
    let file = uv.fs_open_sync(
    path,
    @uv.OpenFlags::write_only(create=true),
    0o644
    )
    let data : Bytes = "Hello, World!"
    uv.fs_write_sync(file, [data])
    uv.fs_fsync_sync(file)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()

    Loop::fs_ftruncate

    #as_free_fn
    fn Loop::fs_ftruncate(self : Loop, file : File, length : Int64, k : () -> Unit, e : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_futime

    #as_free_fn
    fn Loop::fs_futime(self : Loop, file : Int, atime : Double, mtime : Double, success_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_futime_sync

    #as_free_fn
    fn Loop::fs_futime_sync(self : Loop, file : Int, atime : Double, mtime : Double) -> Unit raise Errno

    Loop::fs_lchown

    #as_free_fn
    fn Loop::fs_lchown(self : Loop, path : Bytes, uid : Uid, gid : Gid, lchown_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously changes the owner and group of a symbolic link.

    This function initiates a symbolic link ownership change operation that will be handled asynchronously by the event loop. Unlike fs_chown, this function changes the ownership of the symbolic link itself rather than the file it points to. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The symbolic link path whose ownership to change as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • uid : The new user ID (UID) for the symbolic link. Use -1 (or UInt::max_value) to leave the current owner unchanged.
    • gid : The new group ID (GID) for the symbolic link. Use -1 (or UInt::max_value) to leave the current group unchanged.
    • lchown_cb : Success callback function that receives the filesystem request handle when the ownership change succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Note: On Windows, this function is a no-op and always succeeds since Windows doesn't use the same ownership model as Unix-like systems.

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-lchown.txt"
    let passwd = @uv.os_get_passwd()
    // First create a symlink
    uv.fs_symlink_sync(target_file, symlink_file, @uv.SymlinkFlags::new())
    uv.fs_lchown(
    symlink_file,
    passwd.uid(),
    passwd.gid(),
    () => {
    try uv.fs_unlink_sync(symlink_file) catch { e => errors.push(e) }
    },
    error => {
    errors.push(error)
    try uv.fs_unlink_sync(symlink_file) catch { e => errors.push(e) }
    }
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_lchown_sync

    #as_free_fn
    fn Loop::fs_lchown_sync(self : Loop, path : Bytes, uid : Uid, gid : Gid) -> Unit raise Errno

    Synchronously changes the owner and group of a symbolic link.

    This function blocks the current thread until the symbolic link ownership change operation completes. Unlike the asynchronous fs_lchown function, this operation does not require callbacks and returns immediately upon completion or failure. Unlike fs_chown_sync, this function changes the ownership of the symbolic link itself rather than the file it points to.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The symbolic link path whose ownership to change as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • uid : The new user ID (UID) for the symbolic link. Use -1 (or UInt::max_value) to leave the current owner unchanged.
    • gid : The new group ID (GID) for the symbolic link. Use -1 (or UInt::max_value) to leave the current group unchanged.

    Throws an error of type Errno if the ownership cannot be changed (e.g., symbolic link does not exist, insufficient permissions, or system resource exhaustion).

    Note: On Windows, this function is a no-op and always succeeds since Windows doesn't use the same ownership model as Unix-like systems.

    Example:

    let uv = @uv.Loop::new()
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-lchown-sync.txt"
    let passwd = @uv.os_get_passwd()
    uv.fs_symlink_sync(target_file, symlink_file, @uv.SymlinkFlags::new())
    uv.fs_lchown_sync(symlink_file, passwd.uid(), passwd.gid())
    uv.fs_unlink_sync(symlink_file)
    uv.close()
    #as_free_fn
    fn Loop::fs_link(self : Loop, path : Bytes, new_path : Bytes, link_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously creates a hard link from new_path to path.

    This function initiates a hard link creation operation that will be handled asynchronously by the event loop. A hard link creates an additional directory entry that points to the same file data as the original path. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Hard links can only be created for files (not directories) and both paths must be on the same filesystem. Unlike symbolic links, hard links point directly to the file data and remain valid even if the original path is removed.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The existing file path to link to as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • new_path : The new path for the hard link as a Bytes object.
    • link_cb : Success callback function that receives the filesystem request handle when the hard link is created successfully.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let original_file : Bytes = "test/fixtures/example.txt"
    let link_file : Bytes = "test/fixtures/example-link.txt"
    uv.fs_link(
    original_file,
    link_file,
    () => {
    println("Hard link created successfully")
    try uv.fs_unlink_sync(link_file) catch { e => errors.push(e) }
    },
    error => errors.push(error)
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }
    #as_free_fn
    fn Loop::fs_link_sync(self : Loop, path : Bytes, new_path : Bytes) -> Unit raise Errno

    Synchronously creates a hard link from new_path to path.

    This function blocks the current thread until the hard link creation operation completes. Unlike the asynchronous fs_link function, this operation does not require callbacks and returns immediately upon completion or failure.

    Hard links can only be created for files (not directories) and both paths must be on the same filesystem. Unlike symbolic links, hard links point directly to the file data and remain valid even if the original path is removed.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The existing file path to link to as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • new_path : The new path for the hard link as a Bytes object.

    Throws an error of type Errno if the hard link cannot be created (e.g., file does not exist, paths on different filesystems, insufficient permissions, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let original_file : Bytes = "test/fixtures/example.txt"
    let link_file : Bytes = "test/fixtures/example-link-sync.txt"
    uv.fs_link_sync(original_file, link_file)
    // Verify the link exists
    let stat = uv.fs_stat_sync(link_file)
    @assert.t(stat.is_file())
    // Clean up
    uv.fs_unlink_sync(link_file)
    uv.close()

    Loop::fs_lstat

    #as_free_fn
    fn Loop::fs_lstat(self : Loop, path : Bytes, lstat_cb : (Stat) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_lstat_sync

    #as_free_fn
    fn Loop::fs_lstat_sync(self : Loop, path : Bytes) -> Stat raise Errno

    Synchronously gets file status information for a symbolic link.

    This function blocks the current thread until the lstat operation completes. Unlike fs_stat_sync, this function does not follow symbolic links and returns information about the link itself rather than the target.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The file or symbolic link path to examine as a Bytes object.

    Returns a Stat structure containing file information.

    Throws an error of type Errno if the file information cannot be obtained (e.g., file does not exist, insufficient permissions, or I/O error).

    Example:

    let uv = @uv.Loop::new()
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-lstat.txt"
    uv.fs_symlink_sync(target_file, symlink_file, @uv.SymlinkFlags::new())
    let stat = uv.fs_lstat_sync(symlink_file)
    @assert.t(stat.is_symlink())
    uv.fs_unlink_sync(symlink_file)
    uv.close()

    Loop::fs_lutime

    #as_free_fn
    fn Loop::fs_lutime(self : Loop, path : Bytes, atime : Double, mtime : Double, success_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_lutime_sync

    #as_free_fn
    fn Loop::fs_lutime_sync(self : Loop, path : Bytes, atime : Double, mtime : Double) -> Unit raise Errno

    Loop::fs_mkdir

    #as_free_fn
    fn Loop::fs_mkdir(self : Loop, path : Bytes, mode : Int, mkdir_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously creates a directory at the specified path with the given permissions.

    This function initiates a directory creation operation that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The directory path to create as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • mode : The directory permissions to use when creating the directory (octal notation, e.g., 0o755).
    • mkdir_cb : Success callback function that receives the filesystem request handle when the directory is created successfully.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let es = []
    let dir : Bytes = "test/fixtures/doc-test-dir"
    uv.fs_mkdir(
    dir,
    0o755,
    () => println("Directory created successfully"),
    (e) => es.push(e)
    )
    |> ignore()
    uv.run(Default)
    uv.fs_rmdir_sync(dir)
    uv.close()
    for e in es {
    raise e
    }

    Loop::fs_mkdir_sync

    #as_free_fn
    fn Loop::fs_mkdir_sync(self : Loop, path : Bytes, mode : Int) -> Unit raise Errno

    Synchronously creates a directory at the specified path with the given permissions.

    This function blocks the current thread until the directory creation operation completes. Unlike the asynchronous fs_mkdir function, this operation does not require callbacks and returns immediately upon completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The directory path to create as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • mode : The directory permissions to use when creating the directory (octal notation, e.g., 0o755).

    Throws an error of type Errno if the directory cannot be created (e.g., path already exists, insufficient permissions, or invalid path).

    Example:

    let uv = @uv.Loop::new()
    try {
    uv.fs_mkdir_sync("test/fixtures", 0o755)
    fail("Directory should not exist")
    } catch {
    Errno::EEXIST => ()
    error => raise error
    }
    uv.close()

    Loop::fs_mkdtemp

    #as_free_fn
    fn Loop::fs_mkdtemp(self : Loop, template : Bytes, mkdtemp_cb : (Bytes) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_mkdtemp_sync

    #as_free_fn
    fn Loop::fs_mkdtemp_sync(self : Loop, template : Bytes) -> Bytes raise Errno

    Loop::fs_mkstemp

    #as_free_fn
    fn Loop::fs_mkstemp(self : Loop, template : Bytes, mkstemp_cb : (Bytes) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_mkstemp_sync

    #as_free_fn
    fn Loop::fs_mkstemp_sync(self : Loop, template : Bytes) -> Bytes raise Errno

    Loop::fs_open

    #as_free_fn
    fn Loop::fs_open(self : Loop, path : Bytes, flags : OpenFlags, mode : Int, open_cb : (File) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously opens a file at the specified path with the given flags and mode.

    This function initiates a file open operation that will be handled asynchronously by the event loop. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The file path to open as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • flags : The file access mode and behavior flags. Use OpenFlags::read_only(), OpenFlags::write_only(), or OpenFlags::read_write() with optional parameters for additional behaviors like append, create, truncate, or exclusive access.
    • mode : The file permissions to use when creating a new file (octal notation, e.g., 0o644). This parameter is ignored if the file already exists.
    • open_cb : Success callback function that receives the filesystem request handle and the opened file descriptor when the operation succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Example:

    let uv = Loop::new()
    let errors = []
    uv.fs_open(
    "README.md",
    OpenFlags::read_only(),
    0o644,
    file => uv.fs_close_sync(file) catch { _ => () },
    (error) => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_open_sync

    #as_free_fn
    fn Loop::fs_open_sync(self : Loop, path : Bytes, flags : OpenFlags, mode : Int) -> File raise Errno

    Synchronously opens a file at the specified path with the given flags and mode.

    This function blocks the current thread until the file open operation completes. Unlike the asynchronous fs_open function, this operation does not require callbacks and returns the file descriptor immediately upon successful completion.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The file path to open as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • flags : The file access mode and behavior flags. Use OpenFlags::read_only(), OpenFlags::write_only(), or OpenFlags::read_write() with optional parameters for additional behaviors like append, create, truncate, or exclusive access.
    • mode : The file permissions to use when creating a new file (octal notation, e.g., 0o644). This parameter is ignored if the file already exists.

    Returns a File handle that can be used for subsequent file operations like reading, writing, or closing.

    Throws an error of type Errno if the file cannot be opened (e.g., file does not exist, insufficient permissions, invalid path, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let file = uv.fs_open_sync("README.md", @uv.OpenFlags::read_only(), 0o644)
    uv.fs_close_sync(file)
    uv.close()

    Loop::fs_opendir

    #as_free_fn
    fn Loop::fs_opendir(self : Loop, path : Bytes, opendir_cb : (Dir) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_read

    #as_free_fn
    fn Loop::fs_read(self : Loop, file : File, bufs : Array[BytesView], offset? : Int64, read_cb : (Int) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously reads data from a file into multiple buffers.

    This function initiates a read operation that will be handled asynchronously by the event loop. The data is read from the file into the provided array of byte views, which can be used for scatter-gather I/O operations. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor to read from, typically obtained from fs_open or fs_open_sync.
    • bufs : An array of byte views that will receive the data read from the file. The views define both the memory locations and the amount of data to read into each buffer.
    • offset : The file position to start reading from. If -1 (default), reads from the current file position. Otherwise, reads from the specified absolute position in the file.
    • read_cb : Success callback function that receives the filesystem request handle and the number of bytes actually read when the operation succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    uv.fs_read(
    @uv.stdin(),
    [Bytes::make(100, 0)],
    count => println("Read \{count} bytes"),
    error => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_read_sync

    #as_free_fn
    fn Loop::fs_read_sync(self : Loop, file : File, bufs : Array[BytesView], offset? : Int64) -> Int raise Errno

    Loop::fs_readdir

    #as_free_fn
    fn Loop::fs_readdir(self : Loop, dir : Dir, n : Int, readdir_cb : (Array[Dirent]) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    #as_free_fn
    fn Loop::fs_readlink(self : Loop, path : Bytes, readlink_cb : (Bytes) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously reads the target of a symbolic link.

    This function initiates a symbolic link read operation that will be handled asynchronously by the event loop. The operation reads the target path that a symbolic link points to. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The symbolic link path to read as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • readlink_cb : Success callback function that receives the filesystem request handle and the target path when the operation succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-symlink.txt"
    // First create a symlink
    uv.fs_symlink_sync(target_file, symlink_file, @uv.SymlinkFlags::new())
    // Then read its target
    uv.fs_readlink(
    symlink_file,
    target => {
    println("Symlink points to: \{target}")
    try {
    @assert.eq(target, target_file)
    uv.fs_unlink_sync(symlink_file)
    } catch { e => errors.push(e) }
    },
    error => errors.push(error)
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }
    #as_free_fn
    fn Loop::fs_readlink_sync(self : Loop, path : Bytes) -> Bytes raise Errno

    Synchronously reads the target of a symbolic link.

    This function blocks the current thread until the symbolic link read operation completes. Unlike the asynchronous fs_readlink function, this operation does not require callbacks and returns the target path immediately upon successful completion.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The symbolic link path to read as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).

    Returns the target path that the symbolic link points to as a Bytes object.

    Throws an error of type Errno if the symbolic link cannot be read (e.g., path does not exist, path is not a symbolic link, insufficient permissions, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-symlink-sync.txt"
    // First create a symlink
    uv.fs_symlink_sync(target_file, symlink_file, @uv.SymlinkFlags::new())
    // Then read its target
    let target = uv.fs_readlink_sync(symlink_file)
    @assert.eq(target, target_file)
    // Clean up
    uv.fs_unlink_sync(symlink_file)
    uv.close()

    Loop::fs_realpath

    #as_free_fn
    fn Loop::fs_realpath(self : Loop, path : Bytes, path_cb : (Bytes) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously resolves a file path to its absolute canonical form.

    This function initiates a path resolution operation that will be handled asynchronously by the event loop. The resolved path eliminates symbolic links, relative path components (like . and ..), and redundant separators to produce an absolute canonical path. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The file path to resolve as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • path_cb : Success callback function that receives the filesystem request handle and the resolved absolute path when the operation succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    uv.fs_realpath(
    "test/fixtures/example.txt",
    realpath => println("Resolved: \{realpath}"),
    error => errors.push(error)
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_realpath_sync

    #as_free_fn
    fn Loop::fs_realpath_sync(self : Loop, path : Bytes) -> Bytes raise Errno

    Loop::fs_rename

    #as_free_fn
    fn Loop::fs_rename(self : Loop, path : Bytes, new_path : Bytes, rename_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_rename_sync

    #as_free_fn
    fn Loop::fs_rename_sync(self : Loop, path : Bytes, new_path : Bytes) -> Unit raise Errno

    Synchronously renames a file or directory.

    This function blocks the current thread until the rename operation completes. Unlike the asynchronous fs_rename function, this operation does not require callbacks and returns immediately upon successful completion or failure.

    Parameters

    • path: The current path of the file or directory to rename
    • new_path: The new path for the file or directory

    Errors

    Raises an Errno error if the rename operation fails, such as:
    • Source path does not exist
    • Destination path already exists (for files)
    • Insufficient permissions
    • Cross-device rename not supported

    Example

    let uv = @uv.Loop::new()
    try {
    uv.fs_rename_sync("old_file.txt", "new_file.txt")
    println("File renamed successfully")
    } catch {
    error => println("Rename failed: " + error.to_string())
    }
    uv.close()

    Loop::fs_rmdir

    #as_free_fn
    fn Loop::fs_rmdir(self : Loop, path : Bytes, rmdir_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_rmdir_sync

    #as_free_fn
    fn Loop::fs_rmdir_sync(self : Loop, path : Bytes) -> Unit raise Errno

    Loop::fs_scandir

    #as_free_fn
    fn Loop::fs_scandir(self : Loop, path : Bytes, flags : Int, scandir_cb : (Scandir) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_scandir_sync

    #as_free_fn
    fn Loop::fs_scandir_sync(self : Loop, path : Bytes, flags : Int) -> Scandir raise Errno

    Loop::fs_sendfile

    #as_free_fn
    fn Loop::fs_sendfile(self : Loop, out_fd : File, in_fd : File, in_offset : Int64, length : UInt64, sendfile_cb : (Int64) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously transfers data between file descriptors.

    This function initiates a sendfile operation that will be handled asynchronously by the event loop. The sendfile operation is an efficient way to transfer data from one file descriptor to another without copying data through userspace. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    On platforms that support it, this function uses the native sendfile() system call for optimal performance. On platforms that don't support it, it falls back to a read/write loop.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • out_fd : The destination file descriptor to write to.
    • in_fd : The source file descriptor to read from.
    • in_offset : The offset in the input file to start reading from.
    • length : The maximum number of bytes to transfer.
    • sendfile_cb : Success callback function that receives the filesystem request handle and the number of bytes transferred when the operation succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptors or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let dst_path : Bytes = "test/fixtures/example-sent.txt"
    let src_file = uv.fs_open_sync("test/fixtures/example.txt", @uv.OpenFlags::read_only(), 0o644)
    let dst_file = uv.fs_open_sync(dst_path, @uv.OpenFlags::write_only(create=true), 0o644)
    uv.fs_sendfile(
    dst_file,
    src_file,
    0L,
    1024UL,
    _ => {
    try {
    uv.fs_close_sync(src_file)
    uv.fs_close_sync(dst_file)
    uv.fs_unlink_sync(dst_path)
    } catch { e => errors.push(e) }
    },
    error => {
    errors.push(error)
    try {
    uv.fs_close_sync(src_file)
    uv.fs_close_sync(dst_file)
    uv.fs_unlink_sync(dst_path)
    } catch { e => errors.push(e) }
    }
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_sendfile_sync

    #as_free_fn
    fn Loop::fs_sendfile_sync(self : Loop, out_fd : File, in_fd : File, in_offset : Int64, length : UInt64) -> Int64 raise Errno

    Synchronously transfers data between file descriptors.

    This function blocks the current thread until the sendfile operation completes. Unlike the asynchronous fs_sendfile function, this operation does not require callbacks and returns the number of bytes transferred immediately upon successful completion.

    On platforms that support it, this function uses the native sendfile() system call for optimal performance. On platforms that don't support it, it falls back to a read/write loop.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • out_fd : The destination file descriptor to write to.
    • in_fd : The source file descriptor to read from.
    • in_offset : The offset in the input file to start reading from.
    • length : The maximum number of bytes to transfer.

    Returns the number of bytes actually transferred.

    Throws an error of type Errno if the transfer cannot be completed (e.g., invalid file descriptors, I/O error, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let dst_path : Bytes = "test/fixtures/example-sent.txt"
    let src_file = uv.fs_open_sync("test/fixtures/example.txt", @uv.OpenFlags::read_only(), 0o644)
    let dst_file = uv.fs_open_sync(dst_path, @uv.OpenFlags::write_only(create=true), 0o644)
    let _ = uv.fs_sendfile_sync(dst_file, src_file, 0L, 1024UL)
    uv.fs_close_sync(src_file)
    uv.fs_close_sync(dst_file)
    uv.fs_unlink_sync(dst_path)
    uv.close()

    Loop::fs_stat

    #as_free_fn
    fn Loop::fs_stat(self : Loop, path : Bytes, stat_cb : (Stat) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_stat_sync

    #as_free_fn
    fn Loop::fs_stat_sync(self : Loop, path : Bytes) -> Stat raise Errno

    Loop::fs_statfs

    #as_free_fn
    fn Loop::fs_statfs(self : Loop, path : Bytes, statfs_cb : (StatFs) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_statfs_sync

    #as_free_fn
    fn Loop::fs_statfs_sync(self : Loop, path : Bytes) -> StatFs raise Errno

    #as_free_fn
    fn Loop::fs_symlink(self : Loop, path : Bytes, new_path : Bytes, flags : SymlinkFlags, symlink_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously creates a symbolic link from new_path to path.

    This function initiates a symbolic link creation operation that will be handled asynchronously by the event loop. A symbolic link creates a file that points to another file or directory by name. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Unlike hard links, symbolic links can point to files or directories on different filesystems and can point to non-existent targets. If the target file is moved or deleted, the symlink becomes broken.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • path : The target path that the symlink will point to as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • new_path : The path where the symbolic link will be created as a Bytes object.
    • flags : Symbolic link creation flags. Use SymlinkFlags::new() with optional parameters to specify symlink behavior on Windows.
    • symlink_cb : Success callback function that receives the filesystem request handle when the symbolic link is created successfully.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid parameters or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-symlink.txt"
    uv.fs_symlink(
    target_file,
    symlink_file,
    @uv.SymlinkFlags::new(),
    () => {
    println("Symbolic link created successfully")
    try uv.fs_unlink_sync(symlink_file) catch { e => errors.push(e) }
    },
    error => errors.push(error)
    )
    |> ignore()
    uv.run(Default)
    uv.close()
    for error in errors {
    raise error
    }
    #as_free_fn
    fn Loop::fs_symlink_sync(self : Loop, path : Bytes, new_path : Bytes, flags : SymlinkFlags) -> Unit raise Errno

    Synchronously creates a symbolic link from new_path to path.

    This function blocks the current thread until the symbolic link creation operation completes. Unlike the asynchronous fs_symlink function, this operation does not require callbacks and returns immediately upon completion or failure.

    Unlike hard links, symbolic links can point to files or directories on different filesystems and can point to non-existent targets. If the target file is moved or deleted, the symlink becomes broken.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • path : The target path that the symlink will point to as a Bytes object. If you have a String, StringView, or BytesView, convert it to Bytes first using @encoding.encode(encoding=UTF8, string_value).
    • new_path : The path where the symbolic link will be created as a Bytes object.
    • flags : Symbolic link creation flags. Use SymlinkFlags::new() with optional parameters to specify symlink behavior on Windows.

    Throws an error of type Errno if the symbolic link cannot be created (e.g., insufficient permissions, invalid path, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let target_file : Bytes = "test/fixtures/example.txt"
    let symlink_file : Bytes = "test/fixtures/example-symlink-sync.txt"
    uv.fs_symlink_sync(target_file, symlink_file, @uv.SymlinkFlags::new())
    // Verify the symlink exists
    let stat = uv.fs_lstat_sync(symlink_file)
    @assert.t(stat.is_symlink())
    // Clean up
    uv.fs_unlink_sync(symlink_file)
    uv.close()
    #as_free_fn
    fn Loop::fs_unlink(self : Loop, path : Bytes, k : () -> Unit, e : (Errno) -> Unit) -> Fs raise Errno

    #as_free_fn
    fn Loop::fs_unlink_sync(self : Loop, path : Bytes) -> Unit raise Errno

    Loop::fs_utime

    #as_free_fn
    fn Loop::fs_utime(self : Loop, path : Bytes, atime : Double, mtime : Double, success_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Loop::fs_utime_sync

    #as_free_fn
    fn Loop::fs_utime_sync(self : Loop, path : Bytes, atime : Double, mtime : Double) -> Unit raise Errno

    Loop::fs_write

    #as_free_fn
    fn Loop::fs_write(self : Loop, file : File, bufs : Array[BytesView], offset? : Int64, write_cb : (Int) -> Unit, error_cb : (Errno) -> Unit) -> Fs raise Errno

    Asynchronously writes data from multiple buffers to a file.

    This function initiates a write operation that will be handled asynchronously by the event loop. The data is written from the provided array of byte views to the file, which can be used for gather I/O operations. When the operation completes, either the success callback or error callback will be invoked depending on the result.

    Parameters:

    • self : The event loop instance to schedule the operation on.
    • file : The file descriptor to write to, typically obtained from fs_open or fs_open_sync.
    • bufs : An array of byte views containing the data to write to the file. The views define both the memory locations and the amount of data to write from each buffer.
    • offset : The file position to start writing to. If -1 (default), writes to the current file position. Otherwise, writes to the specified absolute position in the file.
    • write_cb : Success callback function that receives the filesystem request handle and the number of bytes actually written when the operation succeeds.
    • error_cb : Error callback function that receives the filesystem request handle and the error code when the operation fails.

    Throws an error of type Errno if the operation cannot be initiated (e.g., invalid file descriptor or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let errors = []
    let path : Bytes = "test/fixtures/doc-test.txt"
    let file = uv.fs_open_sync(
    path,
    @uv.OpenFlags::write_only(create=true),
    0o644
    )
    let data : Bytes = "Hello, World!"
    uv.fs_write(
    file,
    [data],
    written => println("Wrote \{written} bytes"),
    error => errors.push(error),
    )
    |> ignore()
    uv.run(Default)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()
    for error in errors {
    raise error
    }

    Loop::fs_write_sync

    #as_free_fn
    fn Loop::fs_write_sync(self : Loop, file : File, bufs : Array[BytesView], offset? : Int64) -> Unit raise Errno

    Synchronously writes data from multiple buffers to a file.

    This function blocks the current thread until the write operation completes. Unlike the asynchronous fs_write function, this operation does not require callbacks and returns immediately upon successful completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • file : The file descriptor to write to, typically obtained from fs_open or fs_open_sync.
    • bufs : An array of byte views containing the data to write to the file. The views define both the memory locations and the amount of data to write from each buffer.
    • offset : The file position to start writing to. If -1 (default), writes to the current file position. Otherwise, writes to the specified absolute position in the file.

    Throws an error of type Errno if the file cannot be written to (e.g., invalid file descriptor, insufficient permissions, disk full, or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let path : Bytes = "test/fixtures/doc-test-sync.txt"
    let file = uv.fs_open_sync(
    path,
    @uv.OpenFlags::write_only(create=true),
    0o644
    )
    let data : Bytes = "Hello, World!"
    uv.fs_write_sync(file, [data])
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()

    Loop::getaddrinfo

    #as_free_fn
    fn Loop::getaddrinfo(self : Loop, getaddrinfo_cb : (Iter[AddrInfo]) -> Unit, error_cb : (Errno) -> Unit, node : Bytes, service : Bytes, hints? : AddrInfoHints) -> GetAddrInfo raise Errno

    Loop::getnameinfo

    #as_free_fn
    fn Loop::getnameinfo(self : Loop, getnameinfo_cb : (Bytes?, Bytes?) -> Unit, error_cb : (Errno) -> Unit, addr : Sockaddr, flags? : Int) -> GetNameInfo raise Errno

    Loop::metrics_idle_time

    #as_free_fn
    fn Loop::metrics_idle_time(self : Loop) -> UInt64

    Loop::metrics_info

    #as_free_fn
    fn Loop::metrics_info(self : Loop) -> Metrics raise Errno

    Loop::new

    fn Loop::new() -> Loop raise Errno

    Creates a new event loop instance.

    Returns a new event loop that can be used for asynchronous I/O operations.

    Throws an error of type Errno if the loop initialization fails due to system resource constraints or other platform-specific issues.

    Example:

    let uv = @uv.Loop::new()
    uv.close()

    Loop::now

    fn Loop::now(self : Loop) -> UInt64

    Return the current timestamp in milliseconds. The timestamp is cached at the start of the event loop tick, see uv_update_time() for details and rationale.

    The timestamp increases monotonically from some arbitrary point in time. Don't make assumptions about the starting point, you will only get disappointed.

    Note: Use @uv.hrtime() if you need sub-millisecond granularity.

    Loop::print_all_handles

    fn Loop::print_all_handles(self : Loop, file : File) -> Unit

    Loop::queue_work

    fn Loop::queue_work(self : Loop, work_cb : () -> Unit, after_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Work raise Errno

    Loop::random

    #as_free_fn
    fn Loop::random(self : Loop, buffer : BytesView, flags : Int, random_cb : (BytesView) -> Unit, error_cb : (Errno) -> Unit) -> Random raise Errno

    Loop::random_sync

    #as_free_fn
    fn Loop::random_sync(self : Loop, buffer : BytesView, flags : Int) -> Unit raise Errno

    Synchronously generates random data.

    The synchronous version may block indefinitely when not enough entropy is available. This function blocks the current thread until the random data generation completes. Unlike the asynchronous random function, this operation does not require callbacks and returns immediately upon successful completion or failure.

    Parameters:

    • self : The event loop instance to perform the operation on.
    • buffer : A view of the buffer to fill with random data.
    • flags : Flags to control the random data generation (typically 0).

    Throws an error of type Errno if random data cannot be generated (e.g., insufficient entropy or system resource exhaustion).

    Example:

    let uv = @uv.Loop::new()
    let buffer = Bytes::make(16, 0)
    uv.random_sync(buffer[:], 0)
    // buffer now contains random data
    uv.close()

    Loop::run

    fn Loop::run(self : Loop, mode : RunMode) -> Unit raise Errno

    Runs the event loop with the specified mode.

    Parameters:

    • self : The event loop to run.
    • mode : The run mode that determines how the loop executes. Can be Default (runs until no more active handles), Once (runs once and returns), or NoWait (polls for I/O once but doesn't block).

    Throws an error of type Errno if the loop fails to run properly.

    Example:

    let uv = @uv.Loop::new()
    uv.run(Default)
    uv.close()

    Loop::spawn

    #as_free_fn
    fn Loop::spawn(self : Loop, options : ProcessOptions) -> Process raise Errno

    Loop::stop

    fn Loop::stop(self : Loop) -> Unit

    Loop::update_time

    fn Loop::update_time(self : Loop) -> Unit

    Update the event loop's concept of "now". Libuv caches the current time at the start of the event loop tick in order to reduce the number of time-related system calls.

    You won't normally need to call this function unless you have callbacks that block the event loop for longer periods of time, where "longer" is somewhat subjective but probably on the order of a millisecond or more.

    Loop::walk

    fn Loop::walk(self : Loop, walk_cb : (Handle) -> Unit) -> Unit

    LoopOption

    pub(all) enum LoopOption {
    BlockSignal(Signum)
    MeasureIdleTime
    UseIoUringSqPoll
    }

    Membership

    pub(all) enum Membership {
    LeaveGroup
    JoinGroup
    }

    Membership::to_int

    fn Membership::to_int(self : Membership) -> Int

    Metrics

    type Metrics

    Metrics::events

    fn Metrics::events(self : Metrics) -> UInt64

    Metrics::events_waiting

    fn Metrics::events_waiting(self : Metrics) -> UInt64

    Metrics::loop_count

    fn Metrics::loop_count(self : Metrics) -> UInt64

    Mutex

    type Mutex

    impl Share for Mutex

    Mutex::lock

    fn Mutex::lock(self : Mutex) -> Unit

    Mutex::new

    fn Mutex::new() -> Mutex raise Errno

    Mutex::trylock

    fn Mutex::trylock(self : Mutex) -> Unit raise Errno

    Mutex::unlock

    fn Mutex::unlock(self : Mutex) -> Unit

    Once

    type Once

    Once::call

    fn Once::call(once : Once, cb : FuncRef[() -> Unit]) -> Unit

    Once::new

    fn Once::new() -> Once

    OpenFlags

    type OpenFlags

    OpenFlags::read_only

    fn OpenFlags::read_only(access_hint? : AccessHint, direct? : Bool, directory? : Bool, exclusive_lock? : Bool, filemap? : Bool, noatime? : Bool, nofollow? : Bool, nonblock? : Bool, symlink? : Bool) -> OpenFlags

    Creates file open flags for read-only access.

    Returns an OpenFlags instance configured for read-only file access. Files opened with these flags can only be read from, not written to or modified.

    Example:

    let uv = @uv.Loop::new()
    let flags = @uv.OpenFlags::read_only()
    let file = uv.fs_open_sync("README.md", flags, 0o644)
    uv.fs_close_sync(file)
    uv.close()

    OpenFlags::read_write

    fn OpenFlags::read_write(access_hint? : AccessHint, append? : Bool, create? : Bool, direct? : Bool, exclusive? : Bool, exclusive_lock? : Bool, filemap? : Bool, noatime? : Bool, noctty? : Bool, nofollow? : Bool, nonblock? : Bool, symlink? : Bool, sync? : Sync, temporary? : Bool, truncate? : Bool) -> OpenFlags

    Creates file open flags for read-write access with configurable behaviors.

    Parameters:

    • append : Whether to append to the file instead of overwriting. When true, writes will be positioned at the end of the file. Defaults to false.
    • create : Whether to create the file if it doesn't exist. When true, a new file will be created if the specified path doesn't exist. Defaults to false.
    • truncate : Whether to truncate the file to zero length when opening. When true, any existing content will be discarded. Defaults to false.
    • exclusive : Whether to fail if the file already exists when creating. When true and create is also true, the operation will fail if the file already exists. Defaults to false.

    Returns an OpenFlags instance configured for read-write access with the specified behaviors.

    Example:

    let uv = @uv.Loop::new()
    // Create a new file for reading and writing, fail if it exists
    let flags = @uv.OpenFlags::read_write(create=true, exclusive=true)
    let path : Bytes = "new_file.txt"
    let file = uv.fs_open_sync(path, flags, 0o644)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()

    OpenFlags::write_only

    fn OpenFlags::write_only(append? : Bool, create? : Bool, direct? : Bool, exclusive? : Bool, exclusive_lock? : Bool, filemap? : Bool, nofollow? : Bool, nonblock? : Bool, sync? : Sync, temporary? : Bool, truncate? : Bool) -> OpenFlags

    Creates file open flags for write-only access with configurable behaviors.

    Parameters:

    • append : Whether to append to the file instead of overwriting. When true, writes will be positioned at the end of the file. Defaults to false.
    • create : Whether to create the file if it doesn't exist. When true, a new file will be created if the specified path doesn't exist. Defaults to false.
    • truncate : Whether to truncate the file to zero length when opening. When true, any existing content will be discarded. Defaults to false.
    • exclusive : Whether to fail if the file already exists when creating. When true and create is also true, the operation will fail if the file already exists. Defaults to false.

    Returns an OpenFlags instance configured for write-only access with the specified behaviors.

    Example:

    let uv = @uv.Loop::new()
    // Create a new file for writing, truncate if it exists
    let flags = @uv.OpenFlags::write_only(create=true, truncate=true)
    let path : Bytes = "output.txt"
    let file = uv.fs_open_sync(path, flags, 0o644)
    uv.fs_close_sync(file)
    uv.fs_unlink_sync(path)
    uv.close()

    OsFd

    type OsFd

    OsFd::to_int

    fn OsFd::to_int(self : OsFd) -> Int raise Errno

    OsSock

    type OsSock

    OsSock::to_int

    fn OsSock::to_int(self : OsSock) -> Int

    Passwd

    type Passwd

    Passwd::gid

    fn Passwd::gid(passwd : Passwd) -> Gid

    Passwd::shell

    fn Passwd::shell(passwd : Passwd) -> Bytes

    Passwd::uid

    fn Passwd::uid(passwd : Passwd) -> Uid

    Passwd::username

    fn Passwd::username(passwd : Passwd) -> Bytes

    PhysAddr

    type PhysAddr

    impl Show for PhysAddr
    impl ToJson for PhysAddr

    Pid

    type Pid

    impl Compare for Pid
    impl Eq for Pid
    impl Hash for Pid
    impl Show for Pid

    Pid::of_int

    fn Pid::of_int(pid : Int) -> Pid

    Pid::to_int

    fn Pid::to_int(self : Pid) -> Int

    Pipe

    type Pipe

    impl ToHandle for Pipe
    impl ToStream for Pipe

    Pipe::bind

    fn Pipe::bind(self : Pipe, name : Bytes, flags : PipeBindFlags) -> Unit raise Errno

    Pipe::chmod

    fn Pipe::chmod(self : Pipe, mode : PipeMode) -> Unit raise Errno

    Alters pipe permissions, allowing it to be accessed from processes run by different users. Makes the pipe writable or readable by all users.

    Pipe::connect

    fn Pipe::connect(self : Pipe, name : Bytes, connect_cb : () -> Unit, error_cb : (Errno) -> Unit, no_truncate? : Bool) -> Connect raise Errno

    Pipe::new

    fn Pipe::new(self : Loop, ipc? : Bool) -> Pipe raise Errno

    Pipe::open

    fn Pipe::open(self : Pipe, file : File) -> Unit raise Errno

    Pipe::pending_count

    fn Pipe::pending_count(self : Pipe) -> UInt

    Pipe::pending_instances

    fn Pipe::pending_instances(self : Pipe, count : Int) -> Unit

    Set the number of pending pipe instance handles when the pipe server is waiting for connections.

    NOTE: This setting applies to Windows only.

    Pipe::pending_type

    fn Pipe::pending_type(self : Pipe) -> HandleType

    Pipe::to_handle

    fn Pipe::to_handle(self : Pipe) -> Handle

    Pipe::to_stream

    fn Pipe::to_stream(self : Pipe) -> Stream

    Pipe::try_write2

    fn[Stream : ToStream + ToHandle] Pipe::try_write2(self : Pipe, bufs : Array[BytesView], send_handle : Stream, write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    Pipe::write2

    fn[Stream : ToStream + ToHandle] Pipe::write2(self : Pipe, bufs : Array[BytesView], send_handle : Stream, write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    PipeBindFlags

    type PipeBindFlags

    PipeBindFlags::new

    fn PipeBindFlags::new(truncate? : Bool) -> PipeBindFlags

    PipeFlags

    type PipeFlags

    PipeFlags::new

    fn PipeFlags::new(non_block? : Bool) -> PipeFlags

    PipeMode

    pub(all) enum PipeMode {
    Readable
    Writable
    ReadWrite
    }

    Poll

    type Poll

    impl ToHandle for Poll

    Poll::file

    fn Poll::file(self : Loop, fd : File) -> Poll raise Errno

    Poll::socket

    fn Poll::socket(self : Loop, socket : OsSock) -> Poll raise Errno

    Poll::start

    fn Poll::start(self : Poll, events : PollEvent, poll_cb : (Poll, PollEvent) -> Unit, error_cb : (Poll, Errno) -> Unit) -> Unit raise Errno

    Poll::stop

    fn Poll::stop(self : Poll) -> Unit raise Errno

    PollEvent

    type PollEvent

    impl BitAnd for PollEvent
    impl BitOr for PollEvent

    PollEvent::disconnect

    fn PollEvent::disconnect() -> PollEvent

    PollEvent::is_disconnect

    fn PollEvent::is_disconnect(self : PollEvent) -> Bool

    PollEvent::is_prioritized

    fn PollEvent::is_prioritized(self : PollEvent) -> Bool

    PollEvent::is_readable

    fn PollEvent::is_readable(self : PollEvent) -> Bool

    PollEvent::is_writable

    fn PollEvent::is_writable(self : PollEvent) -> Bool

    PollEvent::prioritized

    fn PollEvent::prioritized() -> PollEvent

    PollEvent::readable

    fn PollEvent::readable() -> PollEvent

    PollEvent::writable

    fn PollEvent::writable() -> PollEvent

    Prepare

    type Prepare

    impl ToHandle for Prepare

    Prepare::new

    fn Prepare::new(self : Loop) -> Prepare raise Errno

    Prepare::start

    fn Prepare::start(self : Prepare, cb : (Prepare) -> Unit) -> Unit raise Errno

    Prepare::stop

    fn Prepare::stop(self : Prepare) -> Unit raise Errno

    Process

    type Process

    impl ToHandle for Process

    Process::kill

    fn Process::kill(self : Process, signum : Signum) -> Unit raise Errno

    Process::pid

    fn Process::pid(self : Process) -> Pid

    ProcessOptions

    type ProcessOptions

    ProcessOptions::new

    fn ProcessOptions::new(file : Bytes, args : Array[Bytes], env? : Array[Bytes], cwd? : Bytes, stdio? : Array[StdioContainer], uid? : Uid, gid? : Gid, exit_cb : (Process, Int64, Int) -> Unit) -> ProcessOptions

    Protocol

    pub(all) enum Protocol {
    Tcp
    Udp
    }

    Protocol::tcp

    fn Protocol::tcp() -> Protocol

    Protocol::udp

    fn Protocol::udp() -> Protocol

    Random

    type Random

    impl ToReq for Random

    Req

    type Req

    Req::type_

    fn Req::type_(self : Req) -> ReqType

    ReqType

    pub enum ReqType {
    Unknown
    Req
    Connect
    Write
    Shutdown
    UdpSend
    Fs
    Work
    Getaddrinfo
    Getnameinfo
    Random
    }

    ReqType::name

    fn ReqType::name(self : ReqType) -> Bytes

    RunMode

    pub(all) enum RunMode {
    Default
    Once
    NoWait
    }

    Rusage

    type Rusage

    Rusage::idrss

    fn Rusage::idrss(rusage : Rusage) -> Int

    Rusage::inblock

    fn Rusage::inblock(rusage : Rusage) -> Int

    Rusage::isrss

    fn Rusage::isrss(rusage : Rusage) -> Int

    Rusage::ixrss

    fn Rusage::ixrss(rusage : Rusage) -> Int

    Rusage::majflt

    fn Rusage::majflt(rusage : Rusage) -> Int

    Rusage::maxrss

    fn Rusage::maxrss(rusage : Rusage) -> Int

    Rusage::minflt

    fn Rusage::minflt(rusage : Rusage) -> Int

    Rusage::msgrcv

    fn Rusage::msgrcv(rusage : Rusage) -> Int

    Rusage::msgsnd

    fn Rusage::msgsnd(rusage : Rusage) -> Int

    Rusage::nivcsw

    fn Rusage::nivcsw(rusage : Rusage) -> Int

    Rusage::nsignals

    fn Rusage::nsignals(rusage : Rusage) -> Int

    Rusage::nswap

    fn Rusage::nswap(rusage : Rusage) -> Int

    Rusage::nvcsw

    fn Rusage::nvcsw(rusage : Rusage) -> Int

    Rusage::oublock

    fn Rusage::oublock(rusage : Rusage) -> Int

    Rusage::stime

    fn Rusage::stime(rusage : Rusage) -> Timeval

    Rusage::utime

    fn Rusage::utime(rusage : Rusage) -> Timeval

    RwLock

    #alias(RWLock, deprecated="`RWLock` is deprecated, use `RwLock` instead")
    type RwLock

    impl Share for RwLock

    RwLock::new

    fn RwLock::new() -> RwLock raise Errno

    RwLock::rdlock

    fn RwLock::rdlock(self : RwLock) -> Unit

    RwLock::rdunlock

    fn RwLock::rdunlock(self : RwLock) -> Unit

    RwLock::tryrdlock

    fn RwLock::tryrdlock(self : RwLock) -> Unit raise Errno

    RwLock::trywrlock

    fn RwLock::trywrlock(self : RwLock) -> Unit raise Errno

    RwLock::wrlock

    fn RwLock::wrlock(self : RwLock) -> Unit

    RwLock::wrunlock

    fn RwLock::wrunlock(self : RwLock) -> Unit

    Scandir

    type Scandir

    Scandir::next

    fn Scandir::next(self : Scandir) -> Dirent raise Errno

    Sem

    type Sem

    impl Share for Sem

    Sem::new

    fn Sem::new(value : UInt) -> Sem raise Errno

    Sem::post

    fn Sem::post(self : Sem) -> Unit

    Sem::trywait

    fn Sem::trywait(self : Sem) -> Unit raise Errno

    Sem::wait

    fn Sem::wait(self : Sem) -> Unit

    Shutdown

    type Shutdown

    impl ToReq for Shutdown

    Signal

    type Signal

    Signal::new

    fn Signal::new(self : Loop) -> Signal raise Errno

    Signal::start

    fn Signal::start(self : Signal, cb : (Signal, Signum) -> Unit, signum : Signum, oneshot? : Bool) -> Unit raise Errno

    Signal::stop

    fn Signal::stop(self : Signal) -> Unit raise Errno

    Signum

    type Signum

    Signum::sigabrt

    fn Signum::sigabrt() -> Signum

    Signum::sighup

    fn Signum::sighup() -> Signum

    Signum::sigint

    fn Signum::sigint() -> Signum

    Signum::sigpipe

    fn Signum::sigpipe() -> Signum raise Errno

    Signum::sigprof

    fn Signum::sigprof() -> Signum raise Errno

    Signum::sigquit

    fn Signum::sigquit() -> Signum

    Signum::sigterm

    fn Signum::sigterm() -> Signum

    Signum::sigtstp

    fn Signum::sigtstp() -> Signum raise Errno

    Signum::sigwinch

    fn Signum::sigwinch() -> Signum

    SockType

    type SockType

    SockType::datagram

    fn SockType::datagram() -> SockType

    SockType::dgram

    #deprecated("Use SockType::datagram() instead")
    fn SockType::dgram() -> SockType

    SockType::raw

    fn SockType::raw() -> SockType

    SockType::stream

    fn SockType::stream() -> SockType

    Sockaddr

    type Sockaddr

    impl ToJson for Sockaddr

    SockaddrIn

    type SockaddrIn

    SockaddrIn::addr

    fn SockaddrIn::addr(self : SockaddrIn) -> InAddr

    SockaddrIn::port

    fn SockaddrIn::port(self : SockaddrIn) -> UInt16

    SockaddrIn6

    type SockaddrIn6

    SockaddrIn6::addr

    fn SockaddrIn6::addr(self : SockaddrIn6) -> In6Addr

    SockaddrIn6::port

    fn SockaddrIn6::port(self : SockaddrIn6) -> UInt16

    SockaddrIn6::scope_id

    fn SockaddrIn6::scope_id(self : SockaddrIn6) -> IfIndex

    Stat

    type Stat

    Stat::atim_nsec

    fn Stat::atim_nsec(self : Stat) -> Int64

    Stat::atim_sec

    fn Stat::atim_sec(self : Stat) -> Int64

    Stat::birthtim_nsec

    fn Stat::birthtim_nsec(self : Stat) -> Int64

    Stat::birthtim_sec

    fn Stat::birthtim_sec(self : Stat) -> Int64

    Stat::blksize

    fn Stat::blksize(self : Stat) -> UInt64

    Stat::blocks

    fn Stat::blocks(self : Stat) -> UInt64

    Stat::ctim_nsec

    fn Stat::ctim_nsec(self : Stat) -> Int64

    Stat::ctim_sec

    fn Stat::ctim_sec(self : Stat) -> Int64

    Stat::dev

    fn Stat::dev(self : Stat) -> UInt64

    Stat::flags

    fn Stat::flags(self : Stat) -> UInt64

    Stat::gen

    fn Stat::gen(self : Stat) -> UInt64

    Stat::gid

    fn Stat::gid(self : Stat) -> UInt64

    Stat::ino

    fn Stat::ino(self : Stat) -> UInt64

    Stat::is_block_device

    fn Stat::is_block_device(self : Stat) -> Bool raise Errno

    Stat::is_character_device

    fn Stat::is_character_device(self : Stat) -> Bool

    Stat::is_directory

    fn Stat::is_directory(self : Stat) -> Bool

    Stat::is_fifo

    fn Stat::is_fifo(self : Stat) -> Bool

    Stat::is_file

    fn Stat::is_file(self : Stat) -> Bool

    Stat::is_pipe

    #deprecated("Use Stat::is_fifo instead")
    fn Stat::is_pipe(self : Stat) -> Bool

    Stat::is_regular

    fn Stat::is_regular(self : Stat) -> Bool

    Stat::is_socket

    fn Stat::is_socket(self : Stat) -> Bool raise Errno

    fn Stat::is_symlink(self : Stat) -> Bool

    Stat::mode

    fn Stat::mode(self : Stat) -> UInt64

    Stat::mtim_nsec

    fn Stat::mtim_nsec(self : Stat) -> Int64

    Stat::mtim_sec

    fn Stat::mtim_sec(self : Stat) -> Int64

    fn Stat::nlink(self : Stat) -> UInt64

    Stat::rdev

    fn Stat::rdev(self : Stat) -> UInt64

    Stat::size

    fn Stat::size(self : Stat) -> UInt64

    Stat::type_

    fn Stat::type_(self : Stat) -> DirentType

    Stat::uid

    fn Stat::uid(self : Stat) -> UInt64

    StatFs

    type StatFs

    StatFs::get_bavail

    fn StatFs::get_bavail(self : StatFs) -> UInt64

    StatFs::get_bfree

    fn StatFs::get_bfree(self : StatFs) -> UInt64

    StatFs::get_blocks

    fn StatFs::get_blocks(self : StatFs) -> UInt64

    StatFs::get_bsize

    fn StatFs::get_bsize(self : StatFs) -> UInt64

    StatFs::get_ffree

    fn StatFs::get_ffree(self : StatFs) -> UInt64

    StatFs::get_files

    fn StatFs::get_files(self : StatFs) -> UInt64

    StatFs::get_type

    fn StatFs::get_type(self : StatFs) -> UInt64

    StdioContainer

    type StdioContainer

    StdioContainer::create_pipe

    fn[Stream : ToStream + ToHandle] StdioContainer::create_pipe(stream : Stream, readable? : Bool, writable? : Bool, non_block? : Bool) -> StdioContainer

    StdioContainer::ignore

    StdioContainer::inherit_file

    fn StdioContainer::inherit_file(file : File) -> StdioContainer

    StdioContainer::inherit_stream

    fn StdioContainer::inherit_stream(stream : Stream) -> StdioContainer

    Stream

    type Stream

    impl ToHandle for Stream
    impl ToStream for Stream

    Stream::is_readable

    fn Stream::is_readable(self : Stream) -> Bool

    Stream::is_writable

    fn Stream::is_writable(self : Stream) -> Bool

    Stream::read_start

    fn Stream::read_start(self : Stream, alloc_cb : (Handle, Int) -> BytesView, read_cb : (Stream, Int, BytesView) -> Unit, error_cb : (Stream, Errno) -> Unit) -> Unit raise Errno

    Stream::read_stop

    fn Stream::read_stop(self : Stream) -> Unit raise Errno

    Stream::shutdown

    fn Stream::shutdown(self : Stream, shutdown_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Shutdown raise Errno

    Stream::to_handle

    fn Stream::to_handle(self : Stream) -> Handle

    Stream::try_write

    fn Stream::try_write(self : Stream, bufs : Array[BytesView], write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    Stream::try_write2

    fn Stream::try_write2(self : Stream, bufs : Array[BytesView], send_handle : Stream, write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    Stream::write

    fn Stream::write(self : Stream, bufs : Array[BytesView], write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    Stream::write2

    fn Stream::write2(self : Stream, bufs : Array[BytesView], send_handle : Stream, write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    SymlinkFlags

    type SymlinkFlags

    SymlinkFlags::new

    fn SymlinkFlags::new(dir? : Bool, junction? : Bool) -> SymlinkFlags

    Creates symbolic link flags for different types of symbolic links.

    Parameters:

    • dir : Whether the symlink points to a directory (Windows only). When true, creates a directory symlink on Windows. This flag is ignored on Unix-like systems where symlink type is determined automatically. Defaults to false.
    • junction : Whether to create a junction point (Windows only). When true, creates a junction point instead of a regular symlink on Windows. Junction points have different permissions and behavior than regular symlinks. This flag is ignored on Unix-like systems. Defaults to false.

    Returns a SymlinkFlags instance configured with the specified behaviors.

    Example:

    // Regular file symlink (works on all platforms)
    ignore(@uv.SymlinkFlags::new())

    // Directory symlink (needed on Windows for directories)
    ignore(@uv.SymlinkFlags::new(dir=true))

    // Junction point (Windows-specific)
    ignore(@uv.SymlinkFlags::new(junction=true))

    Sync

    pub(all) enum Sync {
    Data
    Full
    }

    Tcp

    type Tcp

    impl ToHandle for Tcp
    impl ToStream for Tcp

    Tcp::bind

    fn[Sockaddr : ToSockaddr + ToJson] Tcp::bind(self : Tcp, addr : Sockaddr, flags : TcpBindFlags) -> Unit raise Errno

    Bind the handle to an address and port.

    When the port is already taken, you can expect to see an UV_EADDRINUSE error from uv_listen() or uv_tcp_connect() unless you specify UV_TCP_REUSEPORT in flags for all the binding sockets. That is, a successful call to this function does not guarantee that the call to uv_listen() or uv_tcp_connect() will succeed as well.

    PARAMETERS:

    • handle – TCP handle. It should have been initialized with uv_tcp_init().
    • addr – Address to bind to. It should point to an initialized SockaddrIn or SockaddrIn6.
    • flags – Flags that control the behavior of binding the socket. UV_TCP_IPV6ONLY can be contained in flags to disable dual-stack support and only use IPv6. UV_TCP_REUSEPORT can be contained in flags to enable the socket option SO_REUSEPORT with the capability of load balancing that distribute incoming connections across all listening sockets in multiple processes or threads.

    RETURNS:

    0 on success, or an error code < 0 on failure.

    Changed in version 1.49.0: added the UV_TCP_REUSEPORT flag.

    Tcp::close_reset

    fn Tcp::close_reset(self : Tcp, close_cb : () -> Unit) -> Unit raise Errno

    Resets a TCP connection by sending a RST packet. This is accomplished by setting the SO_LINGER socket option with a linger interval of zero and then calling uv_close(). Due to some platform inconsistencies, mixing of uv_shutdown() and uv_tcp_close_reset() calls is not allowed.

    New in version 1.32.0.

    Tcp::connect

    fn[Sockaddr : ToSockaddr + ToJson] Tcp::connect(self : Tcp, addr : Sockaddr, connect_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Connect raise Errno

    Tcp::getpeername

    fn Tcp::getpeername(self : Tcp) -> Sockaddr raise Errno

    Get the address of the peer connected to the handle. struct sockaddr_storage is used for IPv4 and IPv6 support.

    Tcp::getsockname

    fn Tcp::getsockname(self : Tcp) -> Sockaddr raise Errno

    Get the current address to which the handle is bound. struct sockaddr_storage is used for IPv4 and IPv6 support.

    Tcp::keepalive

    fn Tcp::keepalive(self : Tcp, enable : Bool, delay? : UInt) -> Unit raise Errno

    Enable / disable TCP keep-alive. delay is the initial delay in seconds, ignored when enable is zero.

    After delay has been reached, 10 successive probes, each spaced 1 second from the previous one, will still happen. If the connection is still lost at the end of this procedure, then the handle is destroyed with a UV_ETIMEDOUT error passed to the corresponding callback.

    If delay is less than 1 then UV_EINVAL is returned.

    Changed in version 1.49.0: If delay is less than 1 then UV_EINVAL is returned.

    Tcp::keepalive_ex

    fn Tcp::keepalive_ex(self : Tcp, on : Bool, idle~ : UInt, interval~ : UInt, count~ : UInt) -> Unit raise Errno

    Enable / disable TCP keep-alive with all socket options: TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT. idle is the value for TCP_KEEPIDLE, intvl is the value for TCP_KEEPINTVL, cnt is the value for TCP_KEEPCNT, ignored when on is zero.

    With TCP keep-alive enabled, idle is the time (in seconds) the connection needs to remain idle before TCP starts sending keep-alive probes. intvl is the time (in seconds) between individual keep-alive probes. TCP will drop the connection after sending cnt probes without getting any replies from the peer, then the handle is destroyed with a UV_ETIMEDOUT error passed to the corresponding callback.

    If one of idle, intvl, or cnt is less than 1, UV_EINVAL is returned.

    Tcp::new

    fn Tcp::new(uv : Loop) -> Tcp raise Errno

    Tcp::new_ex

    fn Tcp::new_ex(uv : Loop, domain : AddressFamily) -> Tcp raise Errno

    Tcp::nodelay

    fn Tcp::nodelay(self : Tcp, enable : Bool) -> Unit raise Errno

    Enable TCP_NODELAY, which disables Nagle’s algorithm.

    Tcp::open

    fn Tcp::open(self : Tcp, os_sock : OsSock) -> Unit raise Errno

    Tcp::simultaneous_accepts

    fn Tcp::simultaneous_accepts(self : Tcp, enable : Bool) -> Unit raise Errno

    Enable / disable simultaneous asynchronous accept requests that are queued by the operating system when listening for new TCP connections.

    This setting is used to tune a TCP server for the desired performance. Having simultaneous accepts can significantly improve the rate of accepting connections (which is why it is enabled by default) but may lead to uneven load distribution in multi-process setups.

    Tcp::try_write2

    fn[Stream : ToStream + ToHandle] Tcp::try_write2(self : Tcp, bufs : Array[BytesView], send_handle : Stream, write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    Tcp::write2

    fn[Stream : ToStream + ToHandle] Tcp::write2(self : Tcp, bufs : Array[BytesView], send_handle : Stream, write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    TcpBindFlags

    type TcpBindFlags

    TcpBindFlags::new

    fn TcpBindFlags::new(ipv6_only? : Bool, reuse_port? : Bool) -> TcpBindFlags

    Thread

    type Thread

    impl Eq for Thread
    impl Share for Thread

    Thread::detach

    fn Thread::detach(self : Thread) -> Unit raise Errno

    Thread::equal

    fn Thread::equal(self : Thread, other : Thread) -> Bool

    Thread::get_affinity

    fn Thread::get_affinity(self : Thread) -> CpuSet raise Errno

    Thread::get_name

    fn Thread::get_name(self : Thread) -> Bytes raise Errno

    Thread::get_priority

    fn Thread::get_priority(self : Thread) -> ThreadPriority raise Errno

    Thread::join

    fn Thread::join(self : Thread) -> Unit raise Errno

    Thread::new

    fn Thread::new(cb : () -> Unit, stack_size? : UInt64) -> Thread raise Errno

    Thread::self

    fn Thread::self() -> Thread raise Errno

    Thread::set_affinity

    fn Thread::set_affinity(self : Thread, cpu_set : CpuSet) -> Unit raise Errno

    Thread::set_name

    fn Thread::set_name(name : Bytes) -> Unit raise Errno

    Thread::set_priority

    fn Thread::set_priority(self : Thread, priority : ThreadPriority) -> Unit raise Errno

    ThreadPriority

    pub enum ThreadPriority {
    Highest
    AboveNormal
    Normal
    BelowNormal
    Lowest
    }

    Timer

    type Timer

    impl ToHandle for Timer

    Timer::get_due_in

    fn Timer::get_due_in(self : Timer) -> UInt64

    Timer::get_repeat

    fn Timer::get_repeat(self : Timer) -> UInt64

    Timer::new

    fn Timer::new(self : Loop) -> Timer raise Errno

    Timer::set_repeat

    fn Timer::set_repeat(self : Timer, repeat : UInt64) -> Unit

    Timer::start

    fn Timer::start(self : Timer, timeout~ : UInt64, repeat~ : UInt64, cb : (Timer) -> Unit) -> Unit raise Errno

    Timer::stop

    fn Timer::stop(self : Timer) -> Unit raise Errno

    Timespec64

    pub type Timespec64 FixedArray[Int64]

    Timespec64::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn Timespec64::inner(self : Timespec64) -> FixedArray[Int64]
    Convert newtype to its underlying type, automatically derived.

    Timespec64::nsec

    fn Timespec64::nsec(self : Timespec64) -> Int

    Timespec64::sec

    fn Timespec64::sec(self : Timespec64) -> Int64

    Timeval

    pub struct Timeval {
    sec : Int64
    usec : Int64
    }

    Timeval64

    pub type Timeval64 FixedArray[Int64]

    Timeval64::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn Timeval64::inner(self : Timeval64) -> FixedArray[Int64]
    Convert newtype to its underlying type, automatically derived.

    Timeval64::sec

    fn Timeval64::sec(self : Timeval64) -> Int64

    Timeval64::usec

    fn Timeval64::usec(self : Timeval64) -> Int

    Tty

    type Tty

    impl ToHandle for Tty
    impl ToStream for Tty

    Tty::get_vterm_state

    fn Tty::get_vterm_state() -> Unit raise Errno

    Tty::get_winsize

    fn Tty::get_winsize(self : Tty) -> (Int, Int) raise Errno

    Tty::new

    fn Tty::new(self : Loop, file : File) -> Tty raise Errno

    Tty::reset_mode

    fn Tty::reset_mode() -> Unit raise Errno

    Tty::set_mode

    fn Tty::set_mode(self : Tty, mode : TtyMode) -> Unit raise Errno

    Tty::set_vterm_state

    fn Tty::set_vterm_state(state : TtyVtermState) -> Unit

    TtyMode

    type TtyMode

    TtyMode::io

    fn TtyMode::io() -> TtyMode

    TtyMode::normal

    fn TtyMode::normal() -> TtyMode

    TtyMode::raw

    fn TtyMode::raw() -> TtyMode

    TtyMode::raw_vt

    fn TtyMode::raw_vt() -> TtyMode

    TtyVtermState

    pub enum TtyVtermState {
    Supported
    Unsupported
    }

    TtyVtermState::supported

    fn TtyVtermState::supported() -> TtyVtermState

    TtyVtermState::unsupported

    fn TtyVtermState::unsupported() -> TtyVtermState

    Udp

    type Udp

    impl ToHandle for Udp

    Udp::bind

    fn[Sockaddr : ToSockaddr + ToJson] Udp::bind(self : Udp, addr : Sockaddr, flags : UdpFlags) -> Unit raise Errno

    Udp::connect

    fn[Sockaddr : ToSockaddr + ToJson] Udp::connect(self : Udp, addr : Sockaddr) -> Unit raise Errno

    Udp::get_send_queue_count

    fn Udp::get_send_queue_count(self : Udp) -> UInt64

    Get the count of items in the send queue

    Udp::get_send_queue_size

    fn Udp::get_send_queue_size(self : Udp) -> UInt64

    Get the size of the send queue

    Udp::getpeername

    fn Udp::getpeername(self : Udp) -> Sockaddr raise Errno

    Get the address of the peer connected to the UDP handle

    Udp::getsockname

    fn Udp::getsockname(self : Udp) -> Sockaddr raise Errno

    Get the current address to which the UDP handle is bound

    Udp::new

    fn Udp::new(uv : Loop) -> Udp raise Errno

    Udp::new_ex

    fn Udp::new_ex(uv : Loop, domain : AddressFamily, flags : UdpFlags) -> Udp raise Errno

    Extended UDP initialization with flags

    Udp::open

    fn Udp::open(self : Udp, os_sock : OsSock) -> Unit raise Errno

    Open UDP handle from existing socket

    Udp::recv_start

    fn Udp::recv_start(self : Udp, alloc_cb : (Handle, Int) -> BytesView, read_cb : (Udp, Int, BytesView, Sockaddr, UdpFlags) -> Unit, error_cb : (Udp, Errno) -> Unit) -> Unit raise Errno

    Udp::recv_stop

    fn Udp::recv_stop(self : Udp) -> Unit raise Errno

    Udp::send

    fn[Sockaddr : ToSockaddr + ToJson] Udp::send(self : Udp, data : Array[BytesView], send_cb : () -> Unit, error_cb : (Errno) -> Unit, addr? : Sockaddr) -> UdpSend raise Errno

    Udp::set_broadcast

    fn Udp::set_broadcast(self : Udp, on : Bool) -> Unit raise Errno

    Enable or disable broadcast mode

    Udp::set_membership

    fn Udp::set_membership(self : Udp, multicast_addr : Bytes, interface_addr : Bytes, membership : Membership) -> Unit raise Errno

    Set UDP multicast group membership

    Udp::set_multicast_interface

    fn Udp::set_multicast_interface(self : Udp, interface_addr : Bytes) -> Unit raise Errno

    Set the multicast interface to use

    Udp::set_multicast_loop

    fn Udp::set_multicast_loop(self : Udp, on : Bool) -> Unit raise Errno

    Enable or disable multicast loopback

    Udp::set_multicast_ttl

    fn Udp::set_multicast_ttl(self : Udp, ttl : Int) -> Unit raise Errno

    Set the multicast Time To Live (TTL)

    Udp::set_source_membership

    fn Udp::set_source_membership(self : Udp, multicast_addr : Bytes, interface_addr : Bytes, source_addr : Bytes, membership : Membership) -> Unit raise Errno

    Set UDP source-specific multicast group membership

    Udp::set_ttl

    fn Udp::set_ttl(self : Udp, ttl : Int) -> Unit raise Errno

    Set the Time To Live (TTL) for UDP packets

    Udp::try_send

    fn[Sockaddr : ToSockaddr + ToJson] Udp::try_send(self : Udp, data : Array[BytesView], addr? : Sockaddr) -> Int raise Errno

    Try to send data synchronously (non-blocking) Returns the number of bytes written or a negative error code

    Udp::try_send2

    fn[T : ToSockaddr + ToJson] Udp::try_send2(self : Udp, data : Array[(Array[BytesView], T?)], flags : UdpFlags) -> Int raise Errno

    Udp::using_recvmmsg

    fn Udp::using_recvmmsg(self : Udp) -> Bool

    Check if the UDP handle is using recvmmsg for receiving data

    UdpFlags

    type UdpFlags

    UdpFlags::new

    fn UdpFlags::new(ipv6_only? : Bool, partial? : Bool, reuse_addr? : Bool, mmsg_chunk? : Bool, mmsg_free? : Bool, linux_recv_err? : Bool, reuse_port? : Bool, recvmmsg? : Bool) -> UdpFlags

    UdpSend

    type UdpSend

    impl ToReq for UdpSend

    Uid

    pub(all) type Uid UInt64

    Uid::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn Uid::inner(self : Uid) -> UInt64
    Convert newtype to its underlying type, automatically derived.

    Utsname

    type Utsname

    Utsname::machine

    fn Utsname::machine(self : Utsname) -> BytesView

    Utsname::release

    fn Utsname::release(self : Utsname) -> BytesView

    Utsname::sysname

    fn Utsname::sysname(self : Utsname) -> BytesView

    Utsname::version

    fn Utsname::version(self : Utsname) -> BytesView

    Version

    type Version

    Version::major

    fn Version::major(self : Version) -> Int

    Version::minor

    fn Version::minor(self : Version) -> Int

    Version::patch

    fn Version::patch(self : Version) -> Int

    Version::suffix

    fn Version::suffix(self : Version) -> Bytes

    Version::to_bytes

    fn Version::to_bytes(_ : Version) -> Bytes

    Work

    type Work

    impl Cancelable for Work
    impl ToReq for Work

    Write

    type Write

    impl ToReq for Write

    PriorityAboveNormal

    let PriorityAboveNormal : Int

    PriorityBelowNormal

    let PriorityBelowNormal : Int

    PriorityHigh

    let PriorityHigh : Int

    PriorityHighest

    let PriorityHighest : Int

    PriorityLow

    let PriorityLow : Int

    PriorityNormal

    let PriorityNormal : Int

    accept

    fn[Server : ToStream + ToHandle, Client : ToStream + ToHandle] accept(server : Server, client : Client) -> Unit raise Errno

    args

    fn args() -> FixedArray[Bytes]

    Returns a copy of command-line arguments passed to the program.

    The arguments are copied to prevent accidental/intentional modification to the original command-line arguments.

    Example:

    println(@uv.args())

    available_parallelism

    fn available_parallelism() -> Int

    chdir

    fn chdir(path : Bytes) -> Unit raise Errno

    clock_gettime

    fn clock_gettime(clock_id : ClockId) -> Timespec64 raise Errno

    close

    #deprecated("Use Handle::close() instead")
    fn[Handle : ToHandle] close(handle : Handle, cb : () -> Unit) -> Unit

    cpu_info

    fn cpu_info() -> Array[CpuInfo] raise Errno

    Returns current CPU information.

    Example:

    let cpu_infos = @uv.cpu_info()
    for cpu_info in cpu_infos {
    println(cpu_info.model())
    }

    cwd

    fn cwd() -> Bytes raise Errno

    disable_stdio_inheritance

    fn disable_stdio_inheritance() -> Unit

    exepath

    fn exepath() -> Bytes raise Errno

    get_available_memory

    fn get_available_memory() -> UInt64

    get_constrained_memory

    fn get_constrained_memory() -> UInt64

    get_free_memory

    fn get_free_memory() -> UInt64

    get_process_title

    fn get_process_title() -> Bytes raise

    get_total_memory

    fn get_total_memory() -> UInt64

    getcpu

    fn getcpu() -> Int raise Errno

    getrusage

    fn getrusage() -> Rusage raise Errno

    getrusage_thread

    fn getrusage_thread() -> Rusage raise Errno

    gettimeofday

    fn gettimeofday() -> Timeval64 raise Errno

    guess_handle

    fn guess_handle(file : File) -> HandleType

    hrtime

    fn hrtime() -> UInt64

    Returns the current high-resolution timestamp. This is expressed in nanoseconds. It is relative to an arbitrary time in the past. It is not related to the time of day and therefore not subject to clock drift. The primary use is for measuring performance between intervals.

    Note: Not every platform can support nanosecond resolution; however, this value will always be in nanoseconds.

    interface_addresses

    fn interface_addresses() -> FixedArray[InterfaceAddress] raise

    ip4_addr

    fn ip4_addr(ip : Bytes, port : Int) -> SockaddrIn raise Errno

    Creates an IPv4 socket address structure from an IP address and port number.

    Parameters:

    • ip : The IPv4 address as a null-terminated byte string (e.g., "127.0.0.1").
    • port : The port number for the socket address.

    Returns a SockaddrIn structure representing the IPv4 socket address that can be used with TCP operations like binding or connecting.

    Example:

    let addr = @uv.ip4_addr("127.0.0.1", 8080)
    println(addr.ip_name())

    ip6_addr

    fn ip6_addr(ip : Bytes, port : Int) -> SockaddrIn6 raise Errno

    is_closing

    #deprecated("Use Handle::is_closing() instead")
    fn[Handle : ToHandle] is_closing(handle : Handle) -> Bool

    is_readable

    #deprecated("Use Stream::is_readable() instead")
    fn[Stream : ToStream + ToHandle] is_readable(stream : Stream) -> Bool

    is_writable

    #deprecated("Use Stream::is_writable() instead")
    fn[Stream : ToStream + ToHandle] is_writable(stream : Stream) -> Bool

    kill

    fn kill(pid : Pid, signum : Signum) -> Unit raise Errno

    library_shutdown

    fn library_shutdown() -> Unit

    listen

    fn[Stream : ToStream + ToHandle] listen(stream : Stream, backlog : Int, connection_cb : (Stream) -> Unit, error_cb : (Stream, Errno) -> Unit) -> Unit raise Errno

    loadavg

    fn loadavg() -> (Double, Double, Double)

    os_environ

    fn os_environ() -> Environ raise Errno

    os_get_group

    fn os_get_group(gid : Gid) -> Group raise Errno

    os_get_passwd

    fn os_get_passwd() -> Passwd raise Errno

    let passwd = @uv.os_get_passwd() println(passwd.username()) println(passwd.uid().0) println(passwd.gid().0) println(passwd.shell())

    os_get_passwd2

    fn os_get_passwd2(uid : Uid) -> Passwd raise Errno

    os_getenv

    fn os_getenv(name : Bytes) -> Bytes? raise Errno

    os_gethostname

    fn os_gethostname() -> Bytes raise Errno

    os_getpid

    fn os_getpid() -> Pid

    os_getppid

    fn os_getppid() -> Pid

    os_getpriority

    fn os_getpriority(pid : Pid) -> Int raise Errno

    Retrieves the scheduling priority of the process specified by pid. The returned value of priority is between -20 (high priority) and 19 (low priority).

    Note: On Windows, the returned priority will equal one of the Priority constants.

    os_homedir

    fn os_homedir() -> Bytes raise Errno

    os_setenv

    fn os_setenv(name : Bytes, value : Bytes) -> Unit raise Errno

    os_setpriority

    fn os_setpriority(pid : Pid, priority : Int) -> Unit raise Errno

    Sets the scheduling priority of the process specified by pid. The priority value range is between -20 (high priority) and 19 (low priority).

    Note: On Windows, this function utilizes SetPriorityClass(). The priority argument is mapped to a Windows priority class. When retrieving the process priority, the result will equal one of the @uv.Priorityconstants, and not necessarily the exact value of priority`.

    Note: On Windows, setting @uv.PriorityHighest will only work for elevated user, for others it will be silently reduced to @uv.PriorityHigh.

    os_tmpdir

    fn os_tmpdir() -> Bytes raise Errno

    Retrieves the path to the system's temporary directory.

    Returns a String containing the path to the temporary directory where temporary files can be created.

    Throws an error of type Errno if the underlying system call fails or if there are insufficient resources to complete the operation.

    Example:

    println(@uv.os_tmpdir())

    os_uname

    fn os_uname() -> Utsname raise Errno

    Retrieves system information including the system name, release, version, and machine architecture.

    Returns a Utsname structure containing system identification information.

    Throws an error of type Errno if the underlying system call fails.

    Example:

    let info = @uv.os_uname()
    println(info.sysname())
    println(info.release())
    println(info.machine())

    os_unsetenv

    fn os_unsetenv(name : Bytes) -> Unit raise Errno

    pipe

    fn pipe(read_flags? : PipeFlags, write_flags? : PipeFlags) -> (File, File) raise Errno

    read_start

    #deprecated("Use Stream::read_start() instead")
    fn[Stream : ToStream + ToHandle] read_start(stream : Stream, alloc_cb : (Stream, Int) -> BytesView, read_cb : (Stream, Int, BytesView) -> Unit, error_cb : (Stream, Errno) -> Unit) -> Unit raise Errno

    Starts reading from a stream with custom allocation and data handling callbacks.

    Parameters:

    • stream : The stream to read from.
    • alloc_cb : Callback function to allocate buffer space for incoming data. Takes the stream and suggested buffer size, returns a bytes view.
    • read_cb : Callback function to handle successfully read data. Takes the stream, number of bytes read, and the data as a bytes view.
    • error_cb : Callback function to handle read errors. Takes the stream and the error code.

    Throws an error of type Errno if the operation fails to start.

    read_stop

    #deprecated("Use Stream::read_stop() instead")
    fn[Stream : ToStream + ToHandle] read_stop(stream : Stream) -> Unit raise Errno

    resident_set_memory

    fn resident_set_memory() -> UInt64 raise Errno

    set_process_title

    fn set_process_title(title : Bytes) -> Unit raise Errno

    shutdown

    #deprecated("Use Stream::shutdown() instead")
    fn[Stream : ToStream + ToHandle] shutdown(stream : Stream, shutdown_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Shutdown raise Errno

    sleep

    fn sleep(milliseconds : UInt) -> Unit

    socketpair

    fn socketpair(type_ : SockType, protocol? : Protocol, flags : (PipeFlags, PipeFlags)) -> (OsSock, OsSock) raise Errno

    stderr

    fn stderr() -> File

    stdin

    fn stdin() -> File

    stdout

    fn stdout() -> File

    string_to_wtf8

    fn string_to_wtf8(utf16 : String) -> Bytes

    uptime

    fn uptime() -> Double raise Errno

    version

    fn version() -> Version

    write

    #deprecated("Use Stream::write() instead")
    fn[Stream : ToStream + ToHandle] write(stream : Stream, bufs : Array[BytesView], write_cb : () -> Unit, error_cb : (Errno) -> Unit) -> Write raise Errno

    wtf8_to_string

    fn wtf8_to_string(wtf8 : Bytes) -> String