Isolator
A Rust library for running functions in isolation using separate threads, with panic catching and error handling.
Installation • Usage • Examples • API Reference
Features
- ✨ Run synchronous and async functions in separate threads
- 🧵 True isolation through Tokio's thread pools
- 🛡️ Catch panics and convert them to proper errors
- 🔄 Support for async/await
- 🧪 Comprehensive test coverage
- 📦 Minimal dependencies (only tokio and thiserror)
Installation
Add this to your Cargo.toml:
[]
= "0.1.2"
Usage
Basic Example
use ;
Async Example
use ;
async
Error Handling
The library provides the IsolationError enum for handling both panics and regular errors:
Example with error handling:
use ;
Advanced Usage
Custom Error Types
You can use your own error types as long as they implement std::error::Error:
use Error;
use isolate;
Thread Pool Configuration
The library uses Tokio's thread pools for isolation:
isolate()usesspawn_blockingfor CPU-intensive tasksisolate_async()uses Tokio's async runtime for concurrent tasks
use isolate_async;
use tokio;
async
API Reference
For detailed API documentation, visit docs.rs/isolator.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
Made by Voltaged.