-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add proper library API for external Rust projects #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduce high-level AllSmi client struct with ergonomic API for querying GPU/NPU, CPU, memory, and chassis information. Add unified Error type using thiserror, prelude module for convenient imports, and comprehensive examples and tests for library usage. Closes #106
Security & Performance Review - PR #109Analysis Summary
Prioritized Issue ListHIGH (1 issue)1. Unsafe
MEDIUM (3 issues)2. Multiple AllSmi instances may cause race conditions with platform managers
3. Missing
4. Documentation warnings from
LOW (1 issue)5.
Positive Findings
Test ResultsRecommendations Summary
ConclusionThis PR introduces a well-designed library API for Recommendation: APPROVE with minor documentation improvements suggested. |
Summary
AllSmiclient struct with high-level, ergonomic API for hardware monitoringErrortype using thiserror for comprehensive error handlingpreludemodule for convenient imports of all common typesSend + Syncbounds onAllSmiChanges
New Files
src/client.rs- MainAllSmistruct withget_gpu_info(),get_cpu_info(),get_memory_info(),get_process_info(),get_chassis_info()src/error.rs- UnifiedErrorenum withPlatformInit,NoDevicesFound,DeviceAccess,PermissionDenied,NotSupported,Iovariantssrc/prelude.rs- Re-exports forAllSmi,Error,Result, core types, traits, and factory functionsexamples/library_usage.rs- Comprehensive example demonstrating library API usagetests/library_api_test.rs- Integration tests for the library APIModified Files
src/lib.rs- Updated to export new public API with comprehensive documentationREADME.md- Added "Library API" section with usage examplesTest Plan
cargo test- all 17 library API tests passcargo clippy- no warningscargo run --example library_usage- example executes successfullyAllSmiisSend + SyncCloses #106