@@ -38,76 +38,104 @@ pub trait HttpModuleConfExt {
3838 }
3939}
4040
41+ impl HttpModuleConfExt for crate :: ffi:: ngx_http_conf_ctx_t {
42+ #[ inline]
43+ unsafe fn http_main_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
44+ NonNull :: new ( unsafe { * self . main_conf . add ( module. ctx_index ) } . cast ( ) )
45+ }
46+
47+ #[ inline]
48+ unsafe fn http_server_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
49+ NonNull :: new ( unsafe { * self . srv_conf . add ( module. ctx_index ) } . cast ( ) )
50+ }
51+
52+ #[ inline]
53+ unsafe fn http_location_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
54+ NonNull :: new ( unsafe { * self . loc_conf . add ( module. ctx_index ) } . cast ( ) )
55+ }
56+ }
57+
4158impl HttpModuleConfExt for crate :: ffi:: ngx_cycle_t {
4259 #[ inline]
4360 unsafe fn http_main_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
44- let http_conf = self
45- . conf_ctx
46- . add ( nginx_sys:: ngx_http_module. index )
47- . as_ref ( ) ?;
61+ let http_conf = unsafe {
62+ self . conf_ctx
63+ . add ( nginx_sys:: ngx_http_module. index )
64+ . as_ref ( ) ?
65+ } ;
4866 let conf_ctx = ( * http_conf) . cast :: < ngx_http_conf_ctx_t > ( ) ;
49- let conf_ctx = conf_ctx. as_ref ( ) ?;
50- NonNull :: new ( ( * conf_ctx. main_conf . add ( module. ctx_index ) ) . cast ( ) )
67+ unsafe { conf_ctx. as_ref ( ) ?. http_main_conf_unchecked ( module) }
5168 }
5269}
5370
5471impl HttpModuleConfExt for crate :: ffi:: ngx_conf_t {
5572 #[ inline]
5673 unsafe fn http_main_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
5774 let conf_ctx = self . ctx . cast :: < ngx_http_conf_ctx_t > ( ) ;
58- let conf_ctx = conf_ctx. as_ref ( ) ?;
59- NonNull :: new ( ( * conf_ctx. main_conf . add ( module. ctx_index ) ) . cast ( ) )
75+ unsafe { conf_ctx. as_ref ( ) ?. http_main_conf_unchecked ( module) }
6076 }
6177
6278 #[ inline]
6379 unsafe fn http_server_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
6480 let conf_ctx = self . ctx . cast :: < ngx_http_conf_ctx_t > ( ) ;
65- let conf_ctx = conf_ctx. as_ref ( ) ?;
66- NonNull :: new ( ( * conf_ctx. srv_conf . add ( module. ctx_index ) ) . cast ( ) )
81+ unsafe { conf_ctx. as_ref ( ) ?. http_server_conf_unchecked ( module) }
6782 }
6883
6984 #[ inline]
7085 unsafe fn http_location_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
7186 let conf_ctx = self . ctx . cast :: < ngx_http_conf_ctx_t > ( ) ;
72- let conf_ctx = conf_ctx. as_ref ( ) ?;
73- NonNull :: new ( ( * conf_ctx. loc_conf . add ( module. ctx_index ) ) . cast ( ) )
87+ unsafe { conf_ctx. as_ref ( ) ?. http_location_conf_unchecked ( module) }
88+ }
89+ }
90+
91+ impl HttpModuleConfExt for crate :: ffi:: ngx_http_connection_t {
92+ #[ inline]
93+ unsafe fn http_main_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
94+ unsafe { self . conf_ctx . as_ref ( ) ?. http_main_conf_unchecked ( module) }
95+ }
96+
97+ #[ inline]
98+ unsafe fn http_server_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
99+ unsafe { self . conf_ctx . as_ref ( ) ?. http_server_conf_unchecked ( module) }
100+ }
101+
102+ #[ inline]
103+ unsafe fn http_location_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
104+ unsafe { self . conf_ctx . as_ref ( ) ?. http_location_conf_unchecked ( module) }
74105 }
75106}
76107
77108impl HttpModuleConfExt for ngx_http_core_srv_conf_t {
78109 #[ inline]
79110 unsafe fn http_main_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
80- let conf_ctx = self . ctx . as_ref ( ) ?;
81- NonNull :: new ( ( * conf_ctx. main_conf . add ( module. ctx_index ) ) . cast ( ) )
111+ unsafe { self . ctx . as_ref ( ) ?. http_main_conf_unchecked ( module) }
82112 }
83113
84114 #[ inline]
85115 unsafe fn http_server_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
86- let conf_ctx = self . ctx . as_ref ( ) ?;
87- NonNull :: new ( ( * conf_ctx. srv_conf . add ( module. ctx_index ) ) . cast ( ) )
116+ unsafe { self . ctx . as_ref ( ) ?. http_server_conf_unchecked ( module) }
88117 }
89118
90119 #[ inline]
91120 unsafe fn http_location_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
92- let conf_ctx = self . ctx . as_ref ( ) ?;
93- NonNull :: new ( ( * conf_ctx. loc_conf . add ( module. ctx_index ) ) . cast ( ) )
121+ unsafe { self . ctx . as_ref ( ) ?. http_location_conf_unchecked ( module) }
94122 }
95123}
96124
97125impl HttpModuleConfExt for ngx_http_request_t {
98126 #[ inline]
99127 unsafe fn http_main_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
100- NonNull :: new ( ( * self . main_conf . add ( module. ctx_index ) ) . cast ( ) )
128+ NonNull :: new ( unsafe { * self . main_conf . add ( module. ctx_index ) } . cast ( ) )
101129 }
102130
103131 #[ inline]
104132 unsafe fn http_server_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
105- NonNull :: new ( ( * self . srv_conf . add ( module. ctx_index ) ) . cast ( ) )
133+ NonNull :: new ( unsafe { * self . srv_conf . add ( module. ctx_index ) } . cast ( ) )
106134 }
107135
108136 #[ inline]
109137 unsafe fn http_location_conf_unchecked < T > ( & self , module : & ngx_module_t ) -> Option < NonNull < T > > {
110- NonNull :: new ( ( * self . loc_conf . add ( module. ctx_index ) ) . cast ( ) )
138+ NonNull :: new ( unsafe { * self . loc_conf . add ( module. ctx_index ) } . cast ( ) )
111139 }
112140}
113141
@@ -118,7 +146,7 @@ impl HttpModuleConfExt for ngx_http_upstream_srv_conf_t {
118146 if conf. is_null ( ) {
119147 return None ;
120148 }
121- NonNull :: new ( ( * conf. add ( module. ctx_index ) ) . cast ( ) )
149+ NonNull :: new ( unsafe { * conf. add ( module. ctx_index ) } . cast ( ) )
122150 }
123151}
124152
0 commit comments