Skip to content

Latest commit

 

History

History
153 lines (118 loc) · 8.76 KB

File metadata and controls

153 lines (118 loc) · 8.76 KB

Hew Standard Library

The Hew standard library provides core types, data structures, networking, encoding, and utilities.

This file is the canonical index of shipped stdlib modules in this repository. Module links below go to the public .hew surface that Hew programs import.

For the curated language-only playground snippets, start with ../examples/playground/manifest.json and ../examples/README.md. Use this README when you need the canonical index of shipped std::* modules.

Builtins — auto-imported, plain function calls

println, print, sleep_ms, exit, and panic are ordinary function calls auto-imported into every Hew file — no ! suffix, no special syntax.

fn main() {
    print("count: ");
    println(42);
}

All other standard library modules require an explicit import at the top of the file:

import std::fs;
import std::encoding::json;

fn main() {
    let raw = fs.read("data.json");
    println(json.parse(raw));
}

Quick wayfinding

Shipped module index

Every shipped module under std/ should appear here.

Core and formatting

Module Import Use for
builtins (auto-imported) println, print, sleep_ms, exit, and panic
string std::string String conversion and manipulation utilities
fmt std::fmt Number formatting, padding, and repetition helpers
option std::option Helper functions for common Option<T> patterns
result std::result Helper functions for common Result<T, E> patterns
math std::math Integer helpers, float ops, and common constants

Files, OS, and processes

Module Import Use for
io std::io stdin, stdout, and stderr helpers
fs std::fs File system operations
path std::path File path and glob utilities
os std::os Operating system interfaces
process std::process Process execution

Collections, iteration, and concurrency

Module Import Use for
vec std::vec Utility helpers for Vec<T>
deque std::deque Double-ended queue operations
hashset std::collections::hashset Hash set collection
iter std::iter Map/filter/fold-style helpers for Vec<T>
sort std::sort Sorting and reversing vector helpers
stream std::stream Typed Stream<T>/Sink<T> pipes and file streams
channel std::channel::channel Bounded MPSC channels
semaphore std::semaphore Counting semaphore for concurrency control

Encoding and wire formats

Module Import Use for
base64 std::encoding::base64 Base64 encoding and decoding
compress std::encoding::compress Compression and decompression
csv std::encoding::csv CSV parsing
hex std::encoding::hex Hexadecimal encoding and decoding
json std::encoding::json JSON parsing and manipulation
markdown std::encoding::markdown Markdown to HTML conversion
msgpack std::encoding::msgpack MessagePack serialization
protobuf std::encoding::protobuf Protocol Buffers message construction
toml std::encoding::toml TOML parsing and generation
wire std::encoding::wire Hew wire format encoding and decoding
xml std::encoding::xml XML parsing and manipulation
yaml std::encoding::yaml YAML parsing and generation

Crypto

Module Import Use for
crypto std::crypto::crypto Cryptographic hashing and utilities
encrypt std::crypto::encrypt Symmetric encryption and decryption
jwt std::crypto::jwt JSON Web Token encoding and validation
password std::crypto::password Password hashing and verification

Networking

Module Import Use for
net std::net TCP listeners and connections
dns std::net::dns DNS hostname resolution
http std::net::http HTTP server and request/response handling
http_client std::net::http::http_client Outbound HTTP request helpers (request, request_string, get, post)
ipnet std::net::ipnet IP address and CIDR utilities
mime std::net::mime MIME type detection
quic std::net::quic QUIC transport for internode messaging
smtp std::net::smtp SMTP client for sending email
tls std::net::tls TLS client connections
url std::net::url URL parsing
websocket std::net::websocket WebSocket client and server support

Text, time, and utilities

Module Import Use for
regex std::text::regex Regular expression matching
semver std::text::semver Semantic version parsing and comparison
datetime std::time::datetime Date and time operations
cron std::time::cron Cron expression parsing and scheduling
log std::misc::log Structured logging
uuid std::misc::uuid UUID generation and validation

Testing and benchmarking

Module Import Use for
testing std::testing Assertion helpers for Hew tests
bench std::bench Benchmark harness for measuring function performance

Architecture

Each stdlib module includes:

  • .hew surface -- Declares the public API (types, traits, functions) that Hew programs import, including Hew-native wrappers that can lift raw native status codes/messages into Result and enum surfaces like IoError
  • hew.toml -- Package metadata for the module
  • Rust crate (src/lib.rs, when present) -- Either exports native #[no_mangle] pub extern "C" fn symbols or remains as a placeholder static library to keep the workspace and hew-lib build graph intact

Implementation strategy varies by module:

  • Some modules are implemented entirely in Hew, with the Rust crate retained only as a build placeholder
  • Some modules, such as std::math, expose a Hew surface that codegen lowers directly to compiler intrinsics/MLIR ops, again leaving the Rust crate as a placeholder
  • Modules that need native capabilities still use their Rust crates for the final linked implementation

The compiler resolves import std::* paths against the HEW_STD directory and links any corresponding native static libraries required by the build graph at compile time, whether they provide runtime FFI symbols or act only as placeholders.