Crates.io | yoshi-std |
lib.rs | yoshi-std |
version | 0.1.5 |
created_at | 2025-06-01 19:11:17.597485+00 |
updated_at | 2025-06-04 07:24:35.855508+00 |
description | Core, std-only error type for the Yoshi framework. |
homepage | |
repository | https://github.com/arcmoonstudios/yoshi |
max_upload_size | |
id | 1697428 |
size | 225,098 |
Core error types for the Yoshi framework. Use this directly if you want minimal dependencies.
The foundation of Yoshi - provides Yoshi
, YoshiKind
, and YoContext
types. Everything else is built on top of this.
[dependencies]
yoshi-std = "0.1"
# For no_std environments
yoshi-std = { version = "0.1", default-features = false }
use yoshi_std::{Yoshi, YoshiKind};
// Create errors
let error = Yoshi::new(YoshiKind::NotFound, "User not found");
// Add context
let error = error
.with_context("user_id", "12345")
.with_context("operation", "lookup");
// Chain errors
let io_error = std::fs::read("missing.txt").unwrap_err();
let yoshi_error = Yoshi::from_error(YoshiKind::Io, io_error)
.with_context("file", "missing.txt");
use yoshi_std::YoshiKind;
match error.kind() {
YoshiKind::Io => println!("File system error"),
YoshiKind::Network => println!("Network error"),
YoshiKind::Validation => println!("Input validation failed"),
YoshiKind::NotFound => println!("Resource not found"),
YoshiKind::Timeout => println!("Operation timed out"),
YoshiKind::Config => println!("Configuration error"),
YoshiKind::Internal => println!("Internal error"),
// ... more variants
}
use yoshi_std::Yoshi;
let mut error = Yoshi::new(YoshiKind::Database, "Connection failed");
// Add structured context
error = error
.with_context("host", "db.example.com")
.with_context("port", 5432)
.with_context("retry_count", 3);
// Access context
if let Some(host) = error.context().get("host") {
println!("Failed host: {}", host);
}
// Iterate context
for (key, value) in error.context().iter() {
println!("{}: {}", key, value);
}
Operation | Time | Memory |
---|---|---|
Yoshi::new() |
42ns | 64 bytes |
with_context() |
38ns | +32 bytes |
context_access() |
12ns | 0 |
std
- Standard library support (default)serde
- Serialization supporttracing
- Tracing integrationproptest
- Property testing utilitiesLicensed under either of Apache License, Version 2.0 or MIT License at your option.