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

Import optimization #107

Open
bavshin-f5 opened this issue Dec 24, 2024 · 0 comments
Open

Import optimization #107

bavshin-f5 opened this issue Dec 24, 2024 · 0 comments

Comments

@bavshin-f5
Copy link
Member

Dmitry has noted that the amount of imports required for even the smallest module example is overwhelming.

We can approach this from several directions:

  1. Expose a minimal sufficient set of symbols via ngx::core::prelude::* and ngx::http::prelude::*
  2. Use enums and bitflags as much as possible.
    E.g. wrapping NGX_CONF_... with bitflags would save a few imports and remove noisy as ngx_uint_t casts.
  3. Reduce boilerplate code. For example,
    #[no_mangle]
    #[used]
    pub static mut ngx_http_example_module: ngx_module_t = ngx_module_t {
      ctx: std::ptr::addr_of!(NGX_HTTP_EXAMPLE_MODULE_CTX) as _,
      // Safety: nginx does not modify module.commands.
      commands: NGX_HTTP_EXAMPLE_COMMANDS.as_ptr().cast_mut(),
      type_: NGX_HTTP_MODULE as _
    
      .. NGX_RS_MODULE_V1
    }
    would remove a couple of imports that are never necessary in the code and reduce amount of copy-paste needed to get started.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant