@@ -151,13 +151,11 @@ impl Request {
151151 ///
152152 /// # Safety
153153 /// Caller must ensure that type `T` matches the configuration type for the specified module.
154- pub fn get_module_main_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
154+ pub unsafe fn get_module_main_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
155155 // SAFETY: main conf is either NULL or allocated with ngx_p(c)alloc and
156156 // explicitly initialized by the module
157- unsafe {
158- let scf = * self . 0 . main_conf . add ( module. ctx_index ) ;
159- scf. cast :: < T > ( ) . as_ref ( )
160- }
157+ let scf = * self . 0 . main_conf . add ( module. ctx_index ) ;
158+ scf. cast :: < T > ( ) . as_ref ( )
161159 }
162160
163161 /// Server-specific configuration for a module.
@@ -166,13 +164,11 @@ impl Request {
166164 ///
167165 /// # Safety
168166 /// Caller must ensure that type `T` matches the configuration type for the specified module.
169- pub fn get_module_srv_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
167+ pub unsafe fn get_module_srv_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
170168 // SAFETY: server conf is either NULL or allocated with ngx_p(c)alloc and
171169 // explicitly initialized by the module
172- unsafe {
173- let scf = * self . 0 . srv_conf . add ( module. ctx_index ) ;
174- scf. cast :: < T > ( ) . as_ref ( )
175- }
170+ let scf = * self . 0 . srv_conf . add ( module. ctx_index ) ;
171+ scf. cast :: < T > ( ) . as_ref ( )
176172 }
177173
178174 /// Location-specific configuration for a module.
@@ -181,26 +177,26 @@ impl Request {
181177 ///
182178 /// # Safety
183179 /// Caller must ensure that type `T` matches the configuration type for the specified module.
184- pub fn get_module_loc_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
180+ pub unsafe fn get_module_loc_conf < T > ( & self , module : & ngx_module_t ) -> Option < & ' static T > {
185181 // SAFETY: location conf is either NULL or allocated with ngx_p(c)alloc and
186182 // explicitly initialized by the module
187- unsafe {
188- let lcf = * self . 0 . loc_conf . add ( module. ctx_index ) ;
189- lcf. cast :: < T > ( ) . as_ref ( )
190- }
183+ let lcf = * self . 0 . loc_conf . add ( module. ctx_index ) ;
184+ lcf. cast :: < T > ( ) . as_ref ( )
191185 }
192186
193187 /// Get Module context pointer
194- fn get_module_ctx_ptr ( & self , module : & ngx_module_t ) -> * mut c_void {
195- unsafe { * self . 0 . ctx . add ( module. ctx_index ) }
188+ unsafe fn get_module_ctx_ptr ( & self , module : & ngx_module_t ) -> * mut c_void {
189+ * self . 0 . ctx . add ( module. ctx_index )
196190 }
197191
198192 /// Get Module context
199- pub fn get_module_ctx < T > ( & self , module : & ngx_module_t ) -> Option < & T > {
200- let ctx = self . get_module_ctx_ptr ( module) . cast :: < T > ( ) ;
193+ ///
194+ /// # Safety
195+ /// Caller must ensure that type `T` matches the context type for the specified module.
196+ pub unsafe fn get_module_ctx < T > ( & self , module : & ngx_module_t ) -> Option < & T > {
201197 // SAFETY: ctx is either NULL or allocated with ngx_p(c)alloc and
202198 // explicitly initialized by the module
203- unsafe { ctx . as_ref ( ) }
199+ self . get_module_ctx_ptr ( module ) . cast :: < T > ( ) . as_ref ( )
204200 }
205201
206202 /// Sets the value as the module's context.
0 commit comments