Skip to content
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

chore: reduce boilerplate code for ngx_module_t declarations #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xeioex
Copy link

@xeioex xeioex commented Jan 9, 2025

This partially addresses #107.

Copy link
Member

@bavshin-f5 bavshin-f5 left a comment

Choose a reason for hiding this comment

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

Still not convinced the commands initialization change is right. It assumes constness where we shouldn't, and could be less readable with a larger set of commands.

src/http/prelude.rs Outdated Show resolved Hide resolved
src/core/prelude.rs Outdated Show resolved Hide resolved
src/core/prelude.rs Outdated Show resolved Hide resolved
examples/async.rs Outdated Show resolved Hide resolved
Copy link
Member

@bavshin-f5 bavshin-f5 left a comment

Choose a reason for hiding this comment

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

ngx_module_t::default and CONF_OFFSET changes look good. I'm ready to cherry-pick these to master if you split the CONF_OFFSET patch and reorder both before the prelude one,

I have reservations about the prelude patch though. Maybe we need more high-level wrappers before introducing this.

Note: refactor!: prefix to the commit summaries seems more fitting. See https://www.conventionalcommits.org/en/v1.0.0/#summary and https://github.com/angular/angular/blob/22b96b9/CONTRIBUTING.md#-commit-message-guidelines

Comment on lines +25 to +28
/// The offset of the `main_conf` field in the `ngx_http_conf_ctx_t` struct.
///
/// This is used to access the main configuration context for an HTTP module.
pub const NGX_HTTP_MAIN_CONF_OFFSET: usize = offset_of!(ngx_http_conf_ctx_t, main_conf);
Copy link
Member

Choose a reason for hiding this comment

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

Can you please split this change into a separate commit?

spare0: 0,
spare1: 0,
version: nginx_version as ngx_uint_t,
signature: NGX_RS_MODULE_SIGNATURE.as_ptr() as *const core::ffi::c_char,
Copy link
Member

Choose a reason for hiding this comment

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

NGX_RS_MODULE_SIGNATURE.as_ptr() already returns *const c_char, the cast seems redundant.

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.

2 participants