Skip to content

init: use OnceLock for global libvips init and automatic shutdown - #3

Merged
houseme merged 12 commits into
masterfrom
feature/up
Nov 1, 2025
Merged

houseme merged 12 commits into
masterfrom
feature/up

Conversation

@houseme

@houseme houseme commented Nov 1, 2025

Copy link
Copy Markdown
Owner

init: use OnceLock for global libvips init and automatic shutdown

  • 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.

- 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.
@github-advanced-security

Copy link
Copy Markdown

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.

@houseme
houseme requested a review from Copilot November 1, 2025 07:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_static dependency in favor of std::sync::OnceLock
  • Introduced unified error handling with new Error and Result types
  • 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.

Comment thread src/lib.rs Outdated
Comment thread src/concurrency.rs Outdated
Comment thread README_CN.md Outdated
Comment thread README.md Outdated
Comment thread src/lib.rs Fixed
@houseme
houseme requested a review from Copilot November 1, 2025 09:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/instance.rs Outdated
Comment thread src/init.rs
Comment thread src/image/mod.rs
Comment thread src/cache.rs Outdated
Comment thread README.md
Comment thread README_CN.md
@houseme
houseme merged commit f00b3dd into master Nov 1, 2025
9 checks passed
@houseme
houseme deleted the feature/up branch November 1, 2025 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants