init: use OnceLock for global libvips init and automatic shutdown - #3
Conversation
- Use `OnceLock<InitGuard>` to guarantee one-time initialization. - Add `InitGuard` with `Drop` to call `vips_shutdown()` on process exit. - Improve error handling for invalid app name and `vips_init` failures. - Remove `lazy_static` in favor of standard library primitives. - Add documentation/comments and extend crate features with further libvips API integration.
…mon precautions and status instructions. Add Chinese documents and change logs.
|
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the vips-rs library by removing external dependencies, improving error handling, and enhancing code quality. The changes focus on replacing lazy_static with standard library primitives, improving lifetime annotations, and modernizing string literal syntax.
- Removed
lazy_staticdependency in favor ofstd::sync::OnceLock - Introduced unified error handling with new
ErrorandResulttypes - Added new modules for initialization, versioning, caching, and concurrency control
Reviewed Changes
Copilot reviewed 30 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib.rs | Replaced lazy_static with standard library imports, reorganized module structure |
| src/init.rs | New module implementing OnceLock-based initialization |
| src/error.rs | New unified error type and vips error buffer handling |
| src/version.rs | New module exposing libvips version information |
| src/cache.rs | New module for cache configuration with tests |
| src/concurrency.rs | New module for concurrency control |
| src/instance.rs | Replaced lazy_static with AtomicBool, improved compare-and-swap logic |
| src/interpolate.rs | Removed unused lifetime parameter, replaced as_ptr() with as_mut_ptr() |
| src/image/mod.rs | Added C string literals, improved formatting, fixed memory management in to_vec() |
| src/region.rs | Added Drop implementation, updated imports |
| src/buffer.rs | Added error checking for thumbnail operation |
| src/common.rs | Simplified error retrieval |
| tests/*.rs | Removed extern crate, alphabetized imports, improved formatting |
| examples/resize.rs | Simplified scoping to avoid lifetime issues |
| Cargo.toml | Updated version, dependencies, and metadata |
| README.md | Complete documentation overhaul |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 31 out of 33 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
init: use OnceLock for global libvips init and automatic shutdown
OnceLock<InitGuard>to guarantee one-time initialization.InitGuardwithDropto callvips_shutdown()on process exit.vips_initfailures.lazy_staticin favor of standard library primitives.