Dmitry has noted that the amount of imports required for even the smallest module example is overwhelming.
We can approach this from several directions:
- Expose a minimal sufficient set of symbols via
ngx::core::prelude::* and ngx::http::prelude::*
- 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.
- 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.
Dmitry has noted that the amount of imports required for even the smallest module example is overwhelming.
We can approach this from several directions:
ngx::core::prelude::*andngx::http::prelude::*bitflagsas much as possible.E.g. wrapping
NGX_CONF_...withbitflagswould save a few imports and remove noisyas ngx_uint_tcasts.