Skip to main content

Introduction

Quark is a batteries included utility library for the nanos world server, written in Rust. It adds what the built-in scripting API does not cover: cryptography, networking, data formats, compression, fast native computation and more, all from the global Quark in your server scripts.

local Crypto = Quark.Import("Crypto")

Console.Log(Crypto.SHA256("abc"))

Crypto.Argon2Hash("hunter2", function(hash, error)
Console.Log(hash)
end)

Heavy work runs on native worker threads and the results come back on the game thread, so hashing passwords, generating terrain or answering HTTP requests does not stall the server.

Modules​

ModuleCovers
CryptoHashing, HMAC, key derivation, password hashing, encryption, signatures, JWT, one time passwords, secure randomness
BufferMutable byte arrays with typed number access, accepted wherever binary data is expected
PromisePromises, Quark.Async / Quark.Await, Quark.Delay
JSON, TOML, YAML, MessagePack, CBOREncoding and decoding, optionally off the game thread, JSON Schema validation
XML, INI, CSV, UUID, URLElement trees, configuration files, tables, identifiers and URLs
Compression, Zip, TarLZ4, Zstandard, Gzip, Deflate, Zlib, Brotli and archives in memory
Net, TCP, UDP, WebSocket, HTTPDNS, sockets, WebSocket clients and servers, HTTP servers and clients, TLS
MQTT, NATSMessaging clients with automatic reconnects, queue groups and request/reply
RedisCommands, pipelines, transactions, pub/sub, streams and cluster support
Math, Geometry, BigInt, DecimalEasing, curves, quaternions, statistics, formulas, 2D and 3D shapes, big integers and exact decimals
Pathfinding, SpatialA*, Dijkstra and flow fields, navigation graphs, spatial hashing and KD trees
ProcGenCaves, dungeons and heightmaps
RandomSeeded generators, distributions, weighted picking, loot tables, dice and noise
ImagePNG, JPEG, WebP and BMP images, drawing, resizing, minimaps
WorkerSandboxed Lua states on separate threads for real parallel Lua
Regex, Text, TemplateRegular expressions, Unicode text helpers, fuzzy matching, word filters and Jinja templates
TimeDates with time zones, durations, cron expressions and schedules
LocaleTranslations with Fluent, plural rules and language negotiation
RateLimit, Cache, PriorityQueue, RingBuffer, Bitset, Metrics, LogRate limiting, caches, data structures, Prometheus metrics and structured logging
TestingUnit tests with async support, expectations, spies and mocks

Start with the installation, then read the basics shared by all modules.