| Crates.io | codeuchain |
| lib.rs | codeuchain |
| version | 1.0.1 |
| created_at | 2025-09-06 13:23:55.35291+00 |
| updated_at | 2025-09-12 00:07:05.862658+00 |
| description | CodeUChain Rust: High-performance implementation with memory safety and async support |
| homepage | |
| repository | https://github.com/codeuchain/codeuchain |
| max_upload_size | |
| id | 1827059 |
| size | 70,768 |
CodeUChain provides a memory-safe framework for chaining processing links with middleware support and ownership guarantees.
This package supports the llm.txt standard for easy AI/LLM integration. See llm-full.txt for comprehensive documentation.
Add this to your Cargo.toml:
[dependencies]
codeuchain = "0.1.0"
tokio = { version = "1.0", features = ["full"] }
use codeuchain::{Context, Chain, MathLink, LoggingMiddleware};
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut chain = Chain::new();
chain.add_link("math".to_string(), Box::new(MathLink::new("sum".to_string())));
chain.use_middleware(Box::new(LoggingMiddleware::new()));
let mut data = HashMap::new();
data.insert("numbers".to_string(), serde_json::json!([1, 2, 3]));
let ctx = Context::new(data);
let result = chain.run(ctx).await?;
println!("Result: {:?}", result.get("result")); // 6.0
Ok(())
}
src/core/)Context: Immutable data container with serde integrationLink: Async trait for processing unitsChain: Orchestrator for link executionMiddleware: Trait for cross-cutting concernssrc/utils/)examples/)use codeuchain::{Context, Chain};
use codeuchain::examples::components::{MathLink, LoggingMiddleware};
use std::collections::HashMap;
let mut chain = Chain::new();
chain.add_link("math".to_string(), Box::new(MathLink::new("sum".to_string())));
chain.use_middleware(Box::new(LoggingMiddleware::new()));
use async_trait::async_trait;
use codeuchain::core::{Context, Link};
use serde_json::Value;
struct MyCustomLink;
#[async_trait]
impl Link for MyCustomLink {
async fn call(&self, ctx: Context) -> Result<Context, Box<dyn std::error::Error + Send + Sync>> {
// Your custom logic
Ok(ctx.insert("result".to_string(), Value::String("custom_value".to_string())))
}
}
use codeuchain::examples::components::BasicChain;
let mut chain = BasicChain::new();
chain.add_link("custom".to_string(), Box::new(MyCustomLink));
chain.use_middleware(Box::new(MyCustomMiddleware::new()));
Optimized for Rust's safety and performance—memory-safe, async-native, with zero-cost abstractions. Start fresh, build reliable processing pipelines.
# Run the simple math example
cargo run --example simple_math
# Run tests
cargo test
# Build
cargo build
# Run all tests
cargo test
# Run specific test
cargo test test_context_operations
# Check code
cargo check
# Format code
cargo fmt
# Lint code
cargo clippy