You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A professional-grade, cross-language standard library for high-performance desktop applications. This project enables C# developers to offload compute-heavy, system-level, or security-critical tasks to Rust while maintaining a seamless .NET developer experience.
💎 The "Best of Both Worlds" Architecture
This library isn't just a set of utilities; it's designed to leverage the specific strengths of each ecosystem:
🦀 Rust $\rightarrow$ C# (Power & Safety)
Fearless Concurrency: Uses Rayon for data-parallel processing across all CPU cores without data races.
Linear-Time Regex: Leverages Rust's regex crate to avoid catastrophic backtracking.
Memory-Safe Crypto: Implements SHA256 and Base64 using Rust's strict type system.
Low-Level OS Integration: Direct access to system APIs and efficient file I/O.
🔷 C# $\rightarrow$ Rust (Flexibility & UI)
Event Bridge: Implements a Reverse FFI system where Rust can trigger C# delegates, enabling Rust background tasks to update C# UIs in real-time.
Rapid Prototyping: High-level application flow and UI managed in .NET.
OS and Architecture detection (desktop_get_os, desktop_get_arch).
Logging
Thread-safe system-wide logging (desktop_log).
🛠️ Getting Started
1. Build
cargo build --release
2. C# Integration
Copy libshared_std_rust_csharp.so (or .dll) to your execution folder and use the DllImport signatures provided in the csharp_example project.
⚠️ Memory Safety Rules
Strings: Any IntPtr returned as a string must be freed with free_string(ptr).
Handles: Any IntPtr representing a stateful object (e.g., AppConfig, UserSession) must be destroyed using the corresponding destroy function.
Callbacks: When passing a delegate to Rust, ensure the delegate is pinned or stored in a static variable to prevent the .NET Garbage Collector from moving it.