Built-in Native Libraries
A source-linked reference to modules bundled with the Solan executable: JSON, HTTP, WebSocket, SQLite, regex, compression, crypto, time, and FFI.
Loading and use
What are native modules?
These modules are built into the Solan executable rather than downloaded as external packages. Programs import them with استورد "name". README identifies نظام, جيسون, شبكة, سوكت, and حلقة as always available without an explicit import; import the other modules before use.
| Modules | Area |
|---|---|
رياضيات, ضخم, عشوائي, زمن | Math, arbitrary-size integers, randomness, and time. |
نظام, ملفات, جيسون, نمط | Environment/processes, files, JSON, and regular expressions. |
تشفير, ضغط | Hashes, HMAC, Base64/hex, gzip/zlib. |
شبكة, سوكت, ويبسوكت, حلقة | HTTP/TLS, TCP/UDP, WebSocket, event-loop handles and timers. |
قاعدة, ffi | SQLite and calling C libraries or loading native modules. |
Networking
HTTP and web servers
| Function | Source-described behavior |
|---|---|
شبكة.جلب(url, options?) | Blocking HTTP/HTTPS request returning a map with status, body, headers, success, and final URL. Options include method, headers, body, timeout, redirects, TLS verification, and form encodings. |
شبكة.جلب_متدفق(url, callback, options?) | Calls back with transport chunks before completion, then returns the usual response map. The call itself is synchronous/blocking. |
شبكة.خادم(port, handler, options?) | Blocking HTTP server; handler receives a request map. Returning text produces HTML; a map can specify status, headers, and body. |
شبكة.خادم_حلقة(...) | Event-loop HTTP server; supports an asynchronous handler. |
شبكة.ترميز_رابط(text) / فك_رابط(text) | URL component encoding and decoding. |
شبكة.اقرا_طلب(...) / اكتب_رد(...) | Lower-level HTTP handling over sockets. |
With جلب_متدفق, an SSE event or UTF-8 character may span chunks. Buffer and reassemble before parsing events or decoding text. A failure after partial data raises rather than returning a partial response as complete.
HTTPS and WSS require runtime OpenSSL in the configuration described by README; without TLS, ordinary HTTP/TCP still works. Do not disable certificate verification without a specific reason.
Networking
TCP, UDP, WebSocket, and the event loop
سوكتprovides listen, accept, connect, send, bounded/exact/line reads, timeouts, nonblocking mode, readiness waits, DNS, UDP operations, and handle closure.ويبسوكتconnects tows://orwss://, upgrades inbound HTTP, sends/receives messages and ping, and closes channels.حلقةis a single-threaded event loop with one-shot/repeating timers, handle watchers, step/run/stop operations.
خل مقبض = سوكت.اتصل("localhost", 9000)
سوكت.ارسل(مقبض, "مرحبا")
خل م = حلقة.كل(1, دالة() { اطبع("tick") })
حلقة.الغ(م)Data and cryptography
JSON, regex, SQLite, compression, and cryptography
| Module | Documented API and behavior |
|---|---|
جيسون | ترميز(value, spacing?) encodes a value; فك(text) parses JSON and maps null to عدم. |
نمط | ابحث, هل, مطابق_كامل, كل, قسم, ابدل; supports named groups and case-insensitive, normalization, multiline, and dotall options. |
قاعدة | افتح, نفذ, استعلم, اغلق; SELECT returns a list of maps. Pass values separately in a list of ? parameters rather than concatenating SQL text. |
ضغط | gzip, gunzip, zlib, فك; core compression is bundled and documented output limit is 512 MiB for decompression protection. |
تشفير | sha256, sha1, hmac_sha256, base64/فك_base64, hex/فك_hex, عشوائي_بايتات. |
استورد "قاعدة"
خل ق = قاعدة.افتح("t.db")
قاعدة.نفذ(ق, "INSERT INTO ت VALUES (?, ?)", [1, "س"])
خل صفوف = قاعدة.استعلم(ق, "SELECT * FROM ت WHERE ا = ?", [1])
قاعدة.اغلق(ق)Data and cryptography
Big integers, time, and FFI
ضخمaccepts integer values as strings and returns strings to avoid precision loss; documented operations include add, subtract, multiply, integer divide, remainder, power, factorial, compare, and normalization.زمنprovides Unix time, a monotonic duration clock, sleep, date conversion, strftime formatting, and parsing.نومblocks; README recommendsنمin asynchronous code.ffiopens a library, binds functions using signatures such asd(d), and manages memory/pointers. It requires theاصليpermission and is inherently unsafe.- Documented FFI limits: x86-64 and AArch64 only; up to 6 integer and 8 floating-point arguments; no float ABI, varargs, or callbacks.
Native loading and FFI execute external code within the process. Do not use them with untrusted libraries; understand the اصلي permission and platform limits first.
Loading and use
Module sources and verification
The signatures above are concise and do not replace the README or source files. Examples on this page were not executed; follow the install page, then use solan --check when testing new syntax.
Source files
Direct links pinned to the source snapshot used by this reference; the main branch may change later.