Skip to main content

RtFunc

Enum RtFunc 

Source
pub enum RtFunc {
Show 94 variants Println, Print, EPrint, EPrintln, StrConcat, StrConcatN, IntToStr, FloatToStr, FloatFixed, StrToFloat, BoolToStr, CharToStr, StrEq, StrCmp, StrHash, StrLenChars, StrChars, StrFromChars, StrJoin, StrIndexOf, JsonQuote, StrToUpper, StrToLower, Alloc, CheckBounds, Panic, TestSelector, TaskSpawn, TaskBlockOn, TaskIsDone, TaskTakeOutput, TaskRelease, TaskYieldFuture, TaskSleepFutureNanos, TaskJoinFuture, TaskTimeoutFuture, FsReadToString, FsWriteString, FsTakeString, FsLastErrorMessage, FsTempDir, FsExists, FsCreateDir, FsCreateDirAll, FsRemoveFile, FsRemoveDirAll, FsReadDir, FsTakeStringArray, FsKind, FsRead, FsTakeBytes, FsWrite, FileOpen, FileClose, FileRead, FileWrite, FileFlush, IoStdinRead, IoStdoutWrite, IoStderrWrite, IoStdoutFlush, IoStderrFlush, NetConnect, NetClose, NetRead, NetWrite, NetReadTimeout, NetListen, NetLocalPort, NetAccept, BytesLen, BytesFromString, BytesIsUtf8, BytesToStringUnchecked, BytesAt, BytesSlice, BytesConcat, BytesToInts, BytesFromInts, BytesEq, IntHashSeed, HttpParseRequest, CryptoHash, CryptoRandomBytes, CryptoRandomInt, TimeNowNanos, TimeNowEpochNanos, LogConfigLevel, LogConfigToStderr, LogSetConfig, ShutdownRequested, ProcessArgCount, ProcessArg, ProcessExit,
}
Expand description

Runtime support functions provided by nova-runtime.

Variants§

§

Println

(str) -> unit

§

Print

(str) -> unit

§

EPrint

(str) -> unit — write to stderr with no trailing newline.

§

EPrintln

(str) -> unit — write to stderr followed by a newline.

§

StrConcat

(str, str) -> str

§

StrConcatN

([str]) -> str — concatenate every element of a string array; the lowering of an interpolation of three or more parts.

§

IntToStr

(i64) -> str

§

FloatToStr

(f64) -> str

§

FloatFixed

(f64, i64) -> str — a Float at a fixed number of decimal places.

§

StrToFloat

(str) -> f64 — decimal text parsed as a Float.

§

BoolToStr

(i8) -> str

§

CharToStr

(i64 codepoint) -> str

§

StrEq

(str, str) -> i8

§

StrCmp

(str, str) -> i64 — lexicographic compare: -1, 0, or 1.

§

StrHash

(str) -> i64 — seeded, finalized hash of the bytes (may be negative). Seeded FNV-1a then splitmix64’s finalizer; the reasoning is at nova_rt_str_hash.

§

StrLenChars

(str) -> i64 — count of Unicode scalar values.

§

StrChars

(str) -> ptr — a Nova [Char].

§

StrFromChars

(ptr to [Char]) -> str

§

StrJoin

(str, ptr to [String]) -> str — the parts with the separator between each pair.

§

StrIndexOf

(str, str) -> i64 — the character index of the first match, or -1.

§

JsonQuote

(str) -> str — the string as a JSON string literal.

§

StrToUpper

(str) -> str — full Unicode uppercase.

§

StrToLower

(str) -> str — full Unicode lowercase.

§

Alloc

(size_bytes) -> ptr — allocate a heap value (sum or record).

§

CheckBounds

(index, len) -> unit — abort if index is out of 0..len.

§

Panic

(str) -> ! — abort with a message.

§

TestSelector

() -> i64. See Builtin::TestSelector.

§

TaskSpawn

(ptr to { poll_code, state }) -> i64 — queue a task, return its id.

§

TaskBlockOn

(ptr to { poll_code, state }) -> i64 — drive the executor until this future completes; returns its output slot.

§

TaskIsDone

(ptr to { poll_code, state }) -> i8 — whether the task named by that future’s state has completed.

§

TaskTakeOutput

(i64 task_id) -> i64 — a completed task’s output, taken exactly once. Declared for completeness of the executor’s ABI; no MIR statement emits it, because a task’s output reaches Nova through the future’s own state object instead (Builtin::TaskOutput, whose class the runtime’s i64 return cannot carry for a Float).

§

TaskRelease

(ptr to { poll_code, state }) -> unit — end the executor’s claim on the task named by that future’s state, without handing its output back. Idempotent.

§

TaskYieldFuture

() -> ptr to { poll_code, state } — a fresh future that reports pending once and then completes. What std/task’s yield_now awaits.

§

TaskSleepFutureNanos

(i64 nanos) -> ptr to { poll_code, state } — a fresh future that parks for nanos nanoseconds via the executor’s park set, then completes. What std/time’s sleep awaits.

§

TaskJoinFuture

(ptr to { poll_code, state }) -> ptr to { poll_code, state } — a fresh future that parks via the executor’s park set until the task named by the given future’s state completes, then completes itself. What std/task’s join awaits.

§

TaskTimeoutFuture

(i64, ptr) -> ptr to { poll_code, state } — a future that polls its inner future under a deadline

§

FsReadToString

(str) -> i64 — read the path as UTF-8. 0 on success, with the contents waiting in FsTakeString; otherwise an IoErrorKind status code (crates/nova-runtime/src/fs.rs).

§

FsWriteString

(str, str) -> i64 — write the second string to the path named by the first, truncating. Status code, as FsReadToString.

§

FsTakeString

() -> str — take the payload staged by a successful FsReadToString.

§

FsLastErrorMessage

() -> str — take the message staged by a failed filesystem operation.

§

FsTempDir

() -> str — the OS temporary-directory path (std::env::temp_dir()).

§

FsExists

(str) -> i8 — whether the path exists.

§

FsCreateDir

(str) -> i64 — create the directory. Status code, as FsReadToString.

§

FsCreateDirAll

(str) -> i64 — create the directory and any missing parents. Status code, as FsReadToString.

§

FsRemoveFile

(str) -> i64 — remove the file. Status code, as FsReadToString.

§

FsRemoveDirAll

(str) -> i64 — remove the directory and everything under it. Status code, as FsReadToString.

§

FsReadDir

(str) -> i64 — list the directory’s entry names, sorted. Status code, as FsReadToString; on success the names are waiting in FsTakeStringArray.

§

FsTakeStringArray

() -> ptr — take the [String] staged by a successful FsReadDir.

§

FsKind

(str) -> i64 — what the path is: 0 = metadata unavailable (absent, or unreadable), 1 file, 2 directory.

§

FsRead

(str) -> i64 — read the path’s raw bytes. 0 on success, with the contents waiting in FsTakeBytes; otherwise an IoErrorKind status code, as FsReadToString. Unlike FsReadToString this cannot produce INVALID_DATA: there is no encoding to violate.

§

FsTakeBytes

() -> bytes — take the payload staged by a successful FsRead.

§

FsWrite

(str, bytes) -> i64 — write the bytes to the path named by the first argument, truncating. Status code, as FsReadToString.

§

FileOpen

(ptr, i8, i8, i8, i8, i8, i8) -> i64 — open the path through std::fs::OpenOptions, forwarding the six flags (read, write, append, truncate, create, create_new) one for one. 0 on success, with the new fd waiting in FsTakeBytes, encoded as an 8-byte little-endian value; otherwise an IoErrorKind status code, as FsReadToString.

§

FileClose

(i64 fd) -> i64 — close fd, dropping the underlying file and releasing its OS handle. Idempotent: closing an already-closed, stale, or forged fd still reports success.

§

FileRead

(i64 fd, i64 max) -> i64 — read up to max bytes from fd. 0 on success, with the bytes waiting in FsTakeBytes; otherwise an IoErrorKind status code, as FsReadToString — including a closed, stale, or forged fd. An empty payload means end of stream; a short read does not.

§

FileWrite

(i64 fd, bytes) -> i64 — write the bytes to fd with one Write::write call, not a write_all loop. Status code, as FsReadToString — including a closed, stale, or forged fd — with the byte count waiting in FsTakeBytes on success, encoded as an 8-byte little-endian count.

§

FileFlush

(i64 fd) -> i64 — flush fd. Status code, as FsReadToString, including a closed, stale, or forged fd; no payload.

§

IoStdinRead

(i64) -> i64 — read up to max bytes from stdin. 0 on success, with the bytes waiting in FsTakeBytes; otherwise an IoErrorKind status code, as FsReadToString. An empty payload means end of stream; a short read does not.

§

IoStdoutWrite

(bytes) -> i64 — write the bytes to stdout with one Write::write call, not a write_all loop. Status code, as FsReadToString; on success the number of bytes actually written is waiting in FsTakeBytes, encoded as an 8-byte little-endian count.

§

IoStderrWrite

(bytes) -> i64 — write the bytes to stderr. Mirrors IoStdoutWrite against the other stream.

§

IoStdoutFlush

() -> i64 — flush stdout. Status code, as FsReadToString; no payload.

§

IoStderrFlush

() -> i64 — flush stderr. Mirrors IoStdoutFlush against the other stream.

§

NetConnect

(ptr addr) -> ptr to { poll_code, state } — a fresh future that connects to addr (“host:port”), non-blockingly.

A future constructor, like TaskSleepFutureNanos/TaskJoinFuture above — not a status word, unlike every FsWrite/File*/Io* variant above it. .awaiting the returned future produces the i64 status: 0 on success, with the new fd waiting in FsTakeBytes as an 8-byte little-endian payload, as FileOpen’s own fd; otherwise an IoErrorKind status code, as FsReadToString.

§

NetClose

(i64 fd) -> i64 — close fd, dropping the underlying handle (a connection or a listener alike) and releasing its OS handle. Idempotent, as FileClose.

Not a future constructor — it returns its status directly, exactly FileClose’s shape. NetListen and NetLocalPort below do the same. A roster, not a closed world: this read “are the only other members of this group that do”, which is true today and is the shape that has gone stale twice in this group already.

§

NetRead

(i64 fd, i64 max) -> ptr to { poll_code, state } — a fresh future that reads up to max bytes from fd, non-blockingly.

A future constructor, as NetConnect’s doc comment explains — .awaiting it produces 0 on success, with the bytes waiting in FsTakeBytes; otherwise an IoErrorKind status code, as FsReadToString — including a closed, stale, or forged fd. An empty payload means end of stream; a short read does not.

§

NetWrite

(i64 fd, ptr bytes) -> ptr to { poll_code, state } — a fresh future that writes the bytes to fd with one Write::write attempt, not a write_all loop, non-blockingly.

A future constructor, as NetConnect’s doc comment explains — .awaiting it produces 0 on success, with the byte count actually written waiting in FsTakeBytes, encoded as an 8-byte little-endian count, as FileWrite; otherwise an IoErrorKind status code, as FsReadToString — including a closed, stale, or forged fd.

§

NetReadTimeout

(i64 fd, i64 max, i64 ms) -> ptr to { poll_code, state } — a fresh future that reads up to max bytes from fd, non-blockingly, reporting TIMED_OUT if ms milliseconds pass with nothing to read first.

A future constructor, as NetConnect’s doc comment explains — otherwise identical to NetRead, including EOF/short-read semantics and where the bytes land on success.

§

NetListen

(ptr addr) -> i64 — bind and listen on addr (“host:port”), registering a non-blocking listening socket.

Not a future constructor, one of the three members of this group that are not, with NetClose and NetLocalPort: the bind and listen syscalls do not block, so there is no suspension to model. 0 on success, with the new fd waiting in FsTakeBytes as an 8-byte little-endian payload, as NetConnect’s and FileOpen’s own; otherwise an IoErrorKind status code, as FsReadToString. Closed with NetClose, which serves both kinds of handle.

A hostname argument still resolves through a blocking lookup, which no future here parks on — see nova_rt_net_listen’s own doc comment in crates/nova-runtime/src/net.rs for that caveat and for how its resolution differs from NetConnect’s.

§

NetLocalPort

(i64 fd) -> i64 — the port the listening socket behind fd is bound to, which is how a caller learns the kernel’s choice after a NetListen on port 0.

Not a future constructor, with NetClose and NetListen — a roster rather than the ordinal this read before (“the third member of this group that is not”), which ranks within a group that grows: local_addr is a getsockname call over bookkeeping the kernel already holds, so there is no suspension to model. Unlike NetListen it takes no address, so it carries none of that variant’s blocking-resolution caveat either.

0 on success, with the port waiting in FsTakeBytes as an 8-byte little-endian payload rather than in the return value, which is the status word itself; otherwise an IoErrorKind status code, as FsReadToString — including an fd that names a connected stream rather than a listener, which is a wrong-kind miss and not a port.

§

NetAccept

(i64 fd) -> ptr to { poll_code, state } — a fresh future that waits for the next incoming connection on the listening socket behind fd.

A future constructor, as NetConnect’s doc comment explains — unlike NetClose and NetLocalPort, whose syscalls cannot wait on a peer. .awaiting it produces 0 on success, with the accepted connection’s new fd waiting in FsTakeBytes as an 8-byte little-endian payload, as NetListen’s and NetConnect’s own; otherwise an IoErrorKind status code, as FsReadToString — including an fd that names a connected stream rather than a listener, which is the same wrong-kind miss NetLocalPort describes.

The accepted fd is an ordinary stream fd, so NetRead, NetWrite, NetReadTimeout and NetClose all act on it unchanged.

§

BytesLen

(bytes) -> i64 — the byte length. Not a character count: Bytes has no encoding.

§

BytesFromString

(str) -> bytes — a Bytes holding s’s UTF-8 bytes.

§

BytesIsUtf8

(bytes) -> i8 — whether the bytes are valid UTF-8.

§

BytesToStringUnchecked

(bytes) -> str — the bytes as a String, without checking UTF-8 validity. The caller must have checked BytesIsUtf8 first.

§

BytesAt

(bytes, i64) -> i64 — the byte at the given index, as a value in 0..=255. Aborts if the index is out of range.

§

BytesSlice

(bytes, i64, i64) -> bytes — the bytes in start..end, clamped to the buffer and to start <= end.

§

BytesConcat

(bytes, bytes) -> bytes — the first buffer’s bytes followed by the second’s.

§

BytesToInts

(bytes) -> ptr — a Nova [Int], one element per byte.

§

BytesFromInts

(ptr to [Int]) -> bytes — a Bytes holding each array element as one byte. Aborts if any element is outside 0..=255.

§

BytesEq

(bytes, bytes) -> i8 — byte-for-byte equality.

§

IntHashSeed

() -> i64 — the per-process seed for Int, Bool and Char hashing, drawn separately from the string hash’s own seed.

§

HttpParseRequest

(bytes) -> ptr — a Nova [Int] offset table for an HTTP/1.1 request head. Element 0 is a status; a non-zero status yields a length-1 array.

§

CryptoHash

(i64, ptr, ptr, ptr) -> i64 — std/crypto’s hash/HMAC intrinsic. Status word, not the digest: 0 on success for the digest operations, with the digest waiting in FsTakeBytes; 1 for a failed tag check (an answer, not an error); no negative range at all, since none of its operations can fail for any input a Nova program can construct — a bound that is ring’s rather than this tree’s, stated in full on the ERR_* block in crates/nova-runtime/src/crypto.rs.

§

CryptoRandomBytes

(i64) -> i64 — std/crypto’s random-bytes intrinsic. Status word, not the bytes: 0 on success, with the bytes waiting in FsTakeBytes; otherwise negative, naming one of crypto.rs’s ERR_* kinds (crates/nova-runtime/src/crypto.rs).

§

CryptoRandomInt

(i64, i64) -> i64 — std/crypto’s bounded random-integer intrinsic. Status word, not the integer: 0 on success, with the value waiting in FsTakeBytes as an 8-byte little-endian count; otherwise negative, naming one of crypto.rs’s ERR_* kinds (crates/nova-runtime/src/crypto.rs).

§

TimeNowNanos

() -> i64 — nanoseconds since the runtime’s process epoch.

§

TimeNowEpochNanos

() -> i64 — nanoseconds since the Unix epoch. Distinct from TimeNowNanos, which is process-relative.

§

LogConfigLevel

() -> i64 — the logger’s configured threshold, as LogLevel::to_int numbers it.

§

LogConfigToStderr

() -> i64 — 1 for stderr, 0 for stdout.

§

LogSetConfig

(i64 level, i64 to_stderr) -> unit — install a logger configuration, overwriting any previous one.

§

ShutdownRequested

() -> i8 — whether a termination signal has been received; the first call installs the handler (crates/nova-runtime/src/signal.rs).

§

ProcessArgCount

() -> i64 — the program’s argument count (crates/nova-runtime/src/process.rs).

§

ProcessArg

(i64 i) -> ptr — argument i as a String, or the empty string.

§

ProcessExit

(i64 code) -> unit — std::process::exit; never returns.

Implementations§

Source§

impl RtFunc

Source

pub const ALL: [RtFunc; 94]

Every variant, in the declaration order above — the sole authoritative list of “all runtime functions”. Codegen backends iterate this instead of hand-maintaining their own copy (see the rt_funcs! docs above).

Source§

impl RtFunc

Source

pub fn symbol(self) -> &'static str

Symbol name registered with the JIT / linker.

Source

pub fn signature(self) -> (Vec<MirTy>, MirTy)

Parameter and return classes: (params, ret).

Trait Implementations§

Source§

impl Clone for RtFunc

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RtFunc

Source§

impl Debug for RtFunc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RtFunc

Source§

impl Hash for RtFunc

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RtFunc

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RtFunc

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.