Rust Examples

Page 8 of 8

Browse Rust examples

rustSnippet

Hex Encode And Decode

Convert bytes to lowercase hex and back, accepting an optional prefix and embedded whitespace while rejecting invalid digits.

rustSnippet

INI File Parser

Parse INI sections and key-value pairs into a sorted map, trimming quotes and rejecting malformed headers or empty keys.

rustSnippet

Generic RAII Object Pool

Reuse expensive objects through a mutex-backed pool whose guard returns the item automatically on drop, with a factory fallback.

rustSnippet

JoinSet Task Supervisor

Spawn a batch of async tasks, collect results as they finish, and abort everything still running when a deadline expires.

rustSnippet

Rust JWT Authentication

Implement JWT authentication in Rust using the jsonwebtoken crate with HMAC-SHA256 signing, claims validation, expiry checking, and Axum extractor for.

rustSnippet

Rust CLI Tool with Clap

Build a command-line tool in Rust using Clap with derive macros for subcommands, typed arguments, environment variable fallback, colored output, and shell.

rustSnippet

Rust File Upload with Axum

Handle multipart file uploads in Rust using Axum with size limits, content type validation, streaming to disk, and async file operations using tokio for.

rustSnippet

Rust HTTP Client with Reqwest

Make HTTP requests in Rust using reqwest with async/await, retry logic, JSON deserialization with serde, timeout handling, and connection pooling for.

rustSnippet

Rust HTTP Server with Axum

Build a type-safe HTTP server in Rust using Axum with extractors, JSON responses, error handling, and state sharing. Includes route definitions, middleware.