Skip to content

Commit 0ca3042

Browse files
committed
refactor!: replace ngx_null_command! with ngx_command_t::empty()
1 parent 5b0430e commit 0ca3042

File tree

6 files changed

+27
-30
lines changed

6 files changed

+27
-30
lines changed

examples/async.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use ngx::ffi::{
1212
NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE,
1313
};
1414
use ngx::http::{self, HTTPModule, MergeConfigError};
15-
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
15+
use ngx::{http_request_handler, ngx_log_debug_http, ngx_string};
1616
use tokio::runtime::Runtime;
1717

1818
struct Module;
@@ -63,7 +63,7 @@ static mut NGX_HTTP_ASYNC_COMMANDS: [ngx_command_t; 2] = [
6363
offset: 0,
6464
post: std::ptr::null_mut(),
6565
},
66-
ngx_null_command!(),
66+
ngx_command_t::empty(),
6767
];
6868

6969
static NGX_HTTP_ASYNC_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {

examples/awssig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ngx::ffi::{
99
NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE, NGX_HTTP_SRV_CONF,
1010
};
1111
use ngx::http::*;
12-
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
12+
use ngx::{http_request_handler, ngx_log_debug_http, ngx_string};
1313

1414
struct Module;
1515

@@ -82,7 +82,7 @@ static mut NGX_HTTP_AWSSIGV4_COMMANDS: [ngx_command_t; 6] = [
8282
offset: 0,
8383
post: std::ptr::null_mut(),
8484
},
85-
ngx_null_command!(),
85+
ngx_command_t::empty(),
8686
];
8787

8888
static NGX_HTTP_AWSSIGV4_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {

examples/curl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ngx::ffi::{
88
NGX_HTTP_LOC_CONF, NGX_HTTP_LOC_CONF_OFFSET, NGX_HTTP_MODULE,
99
};
1010
use ngx::http::{self, HTTPModule, MergeConfigError};
11-
use ngx::{http_request_handler, ngx_log_debug_http, ngx_null_command, ngx_string};
11+
use ngx::{http_request_handler, ngx_log_debug_http, ngx_string};
1212

1313
struct Module;
1414

@@ -45,7 +45,7 @@ static mut NGX_HTTP_CURL_COMMANDS: [ngx_command_t; 2] = [
4545
offset: 0,
4646
post: std::ptr::null_mut(),
4747
},
48-
ngx_null_command!(),
48+
ngx_command_t::empty(),
4949
];
5050

5151
static NGX_HTTP_CURL_MODULE_CTX: ngx_http_module_t = ngx_http_module_t {

examples/upstream.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ use ngx::http::{
2323
ngx_http_conf_get_module_srv_conf, ngx_http_conf_upstream_srv_conf_immutable,
2424
ngx_http_conf_upstream_srv_conf_mutable, HTTPModule, Merge, MergeConfigError, Request,
2525
};
26-
use ngx::{
27-
http_upstream_init_peer_pt, ngx_conf_log_error, ngx_log_debug_http, ngx_log_debug_mask, ngx_null_command,
28-
ngx_string,
29-
};
26+
use ngx::{http_upstream_init_peer_pt, ngx_conf_log_error, ngx_log_debug_http, ngx_log_debug_mask, ngx_string};
3027

3128
#[derive(Clone, Copy, Debug)]
3229
#[repr(C)]
@@ -97,7 +94,7 @@ static mut NGX_HTTP_UPSTREAM_CUSTOM_COMMANDS: [ngx_command_t; 2] = [
9794
offset: 0,
9895
post: std::ptr::null_mut(),
9996
},
100-
ngx_null_command!(),
97+
ngx_command_t::empty(),
10198
];
10299

103100
// Generate the `ngx_modules` table with exported modules.

nginx-sys/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,25 @@ impl TryFrom<ngx_str_t> for &str {
212212
}
213213
}
214214

215+
impl ngx_command_t {
216+
/// Creates a new empty [`ngx_command_t`] instance.
217+
///
218+
/// This method replaces the `ngx_null_command` C macro. This is typically used to terminate an
219+
/// array of configuration directives.
220+
///
221+
/// [`ngx_command_t`]: https://nginx.org/en/docs/dev/development_guide.html#config_directives
222+
pub const fn empty() -> Self {
223+
Self {
224+
name: ngx_str_t::empty(),
225+
type_: 0,
226+
set: None,
227+
conf: 0,
228+
offset: 0,
229+
post: ptr::null_mut(),
230+
}
231+
}
232+
}
233+
215234
impl ngx_module_t {
216235
/// Create a new `ngx_module_t` instance with default values.
217236
pub const fn default() -> Self {

src/core/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,3 @@ pub use buffer::*;
77
pub use pool::*;
88
pub use status::*;
99
pub use string::*;
10-
11-
/// Static empty configuration directive initializer for [`ngx_command_t`].
12-
///
13-
/// This is typically used to terminate an array of configuration directives.
14-
///
15-
/// [`ngx_command_t`]: https://nginx.org/en/docs/dev/development_guide.html#config_directives
16-
#[macro_export]
17-
macro_rules! ngx_null_command {
18-
() => {
19-
$crate::ffi::ngx_command_t {
20-
name: $crate::ffi::ngx_str_t::empty(),
21-
type_: 0,
22-
set: None,
23-
conf: 0,
24-
offset: 0,
25-
post: ::core::ptr::null_mut(),
26-
}
27-
};
28-
}

0 commit comments

Comments
 (0)