tokenless-core
Shared core types and utilities for the tokenless workspace.
Part of the tokenless toolkit.
Why tokenless-core?
Every tokenless crate needs validated configuration, path traversal protection, and a unified error type. Rather than duplicating these across 6 crates, tokenless-core provides them once — with compile-time safety guarantees:
Configvalidates at construction, not at use-siteSafePathrejects..,/, and NUL bytes — you can't accidentally construct a dangerous pathCoreErrorgives the whole workspace a singleResult<T>alias
Quick Start
[]
= "0.4"
use ;
// Validated configuration
let config = new?
.with_description;
// Path traversal-safe relative paths (rejects "..", "/", and NUL at construction)
let safe = new?;
let display_path = safe.as_path.display;
// Unified error handling
Types
Config
Validated runtime configuration.
| Method | Description |
|---|---|
Config::new(name) |
Create with app name (fails on empty) |
with_description(desc) |
Optional description |
name() |
Return app name |
description() |
Return optional description |
SafePath
Path traversal-resistant relative path. Rejects .., absolute paths, and NUL bytes at construction time — no runtime checks needed.
| Method | Description |
|---|---|
SafePath::new(path) |
Create; returns Err for traversal attempts |
as_path() |
Borrow as &Path |
impl Display |
Human-readable display |
impl AsRef<Path> |
Interop with std::path APIs |
CoreError
Unified error type (#[non_exhaustive]). Variants: Io, Serialization, App, Path.
Result<T>
Type alias for std::result::Result<T, CoreError>.
Minimum Rust Version
Rust 2024 edition, MSRV 1.89.
License: Apache-2.0