Skip to content

Commit 0a6b05b

Browse files
committed
docs: fix rustdoc warnings and some incorrect references
1 parent 7058d0d commit 0a6b05b

File tree

5 files changed

+73
-69
lines changed

5 files changed

+73
-69
lines changed

src/core/buffer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::ffi::*;
33
use std::slice;
44

55
/// The `Buffer` trait provides methods for working with an nginx buffer (`ngx_buf_t`).
6+
///
7+
/// See <https://nginx.org/en/docs/dev/development_guide.html#buffer>
68
pub trait Buffer {
79
/// Returns a raw pointer to the underlying `ngx_buf_t` of the buffer.
810
fn as_ngx_buf(&self) -> *const ngx_buf_t;

src/core/pool.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use crate::ffi::*;
44
use std::os::raw::c_void;
55
use std::{mem, ptr};
66

7-
/// Wrapper struct for an `ngx_pool_t` pointer, providing methods for working with memory pools.
7+
/// Wrapper struct for an [`ngx_pool_t`] pointer, providing methods for working with memory pools.
8+
///
9+
/// See <https://nginx.org/en/docs/dev/development_guide.html#pool>
810
pub struct Pool(*mut ngx_pool_t);
911

1012
impl Pool {

src/http/module.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Merge for () {
4545
/// These functions allocate structures, initialize them, and merge through the configuration
4646
/// layers.
4747
///
48-
/// See https://nginx.org/en/docs/dev/development_guide.html#adding_new_modules for details.
48+
/// See <https://nginx.org/en/docs/dev/development_guide.html#adding_new_modules> for details.
4949
pub trait HTTPModule {
5050
/// Configuration in the `http` block.
5151
type MainConf: Merge + Default;

src/http/request.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ macro_rules! http_variable_get {
7575
};
7676
}
7777

78-
/// Wrapper struct for an `ngx_http_request_t` pointer, , providing methods for working with HTTP requests.
78+
/// Wrapper struct for an [`ngx_http_request_t`] pointer, providing methods for working with HTTP requests.
79+
///
80+
/// See <https://nginx.org/en/docs/dev/development_guide.html#http_request>
7981
#[repr(transparent)]
8082
pub struct Request(ngx_http_request_t);
8183

@@ -94,8 +96,6 @@ impl<'a> From<&'a mut Request> for *mut ngx_http_request_t {
9496
impl Request {
9597
/// Create a [`Request`] from an [`ngx_http_request_t`].
9698
///
97-
/// [`ngx_http_request_t`]: https://nginx.org/en/docs/dev/development_guide.html#http_request
98-
///
9999
/// # Safety
100100
///
101101
/// The caller has provided a valid non-null pointer to a valid `ngx_http_request_t`
@@ -121,9 +121,8 @@ impl Request {
121121
/// The option wraps an ngx_http_upstream_t instance, it will be none when the underlying NGINX request
122122
/// does not have a pointer to a [`ngx_http_upstream_t`] upstream structure.
123123
///
124-
/// [`ngx_http_upstream_t`]: is best described in
125-
/// https://nginx.org/en/docs/dev/development_guide.html#http_request
126-
/// https://nginx.org/en/docs/dev/development_guide.html#http_load_balancing
124+
/// [`ngx_http_upstream_t`] is best described in
125+
/// <https://nginx.org/en/docs/dev/development_guide.html#http_load_balancing>
127126
pub fn upstream(&self) -> Option<*mut ngx_http_upstream_t> {
128127
if self.0.upstream.is_null() {
129128
return None;
@@ -178,7 +177,7 @@ impl Request {
178177

179178
/// Sets the value as the module's context.
180179
///
181-
/// See https://nginx.org/en/docs/dev/development_guide.html#http_request
180+
/// See <https://nginx.org/en/docs/dev/development_guide.html#http_request>
182181
pub fn set_module_ctx(&self, value: *mut c_void, module: &ngx_module_t) {
183182
unsafe {
184183
*self.0.ctx.add(module.ctx_index) = value;
@@ -227,15 +226,15 @@ impl Request {
227226

228227
/// Add header to the `headers_in` object.
229228
///
230-
/// See https://nginx.org/en/docs/dev/development_guide.html#http_request
229+
/// See <https://nginx.org/en/docs/dev/development_guide.html#http_request>
231230
pub fn add_header_in(&mut self, key: &str, value: &str) -> Option<()> {
232231
let table: *mut ngx_table_elt_t = unsafe { ngx_list_push(&mut self.0.headers_in.headers) as _ };
233232
unsafe { add_to_ngx_table(table, self.0.pool, key, value) }
234233
}
235234

236235
/// Add header to the `headers_out` object.
237236
///
238-
/// See https://nginx.org/en/docs/dev/development_guide.html#http_request
237+
/// See <https://nginx.org/en/docs/dev/development_guide.html#http_request>
239238
pub fn add_header_out(&mut self, key: &str, value: &str) -> Option<()> {
240239
let table: *mut ngx_table_elt_t = unsafe { ngx_list_push(&mut self.0.headers_out.headers) as _ };
241240
unsafe { add_to_ngx_table(table, self.0.pool, key, value) }
@@ -385,7 +384,7 @@ impl fmt::Debug for Request {
385384
}
386385
}
387386

388-
/// Iterator for `ngx_list_t` types.
387+
/// Iterator for [`ngx_list_t`] types.
389388
///
390389
/// Implementes the std::iter::Iterator trait.
391390
pub struct NgxListIterator {
@@ -395,10 +394,11 @@ pub struct NgxListIterator {
395394
i: ngx_uint_t,
396395
}
397396

398-
// create new http request iterator
397+
/// Creates new HTTP header iterator
398+
///
399399
/// # Safety
400400
///
401-
/// The caller has provided a valid `ngx_str_t` which can be dereferenced validly.
401+
/// The caller has provided a valid [`ngx_str_t`] which can be dereferenced validly.
402402
pub unsafe fn list_iterator(list: *const ngx_list_t) -> NgxListIterator {
403403
let part: *const ngx_list_part_t = &(*list).part;
404404

src/log.rs

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -38,64 +38,13 @@ macro_rules! ngx_log_debug_http {
3838
}
3939
}
4040

41-
/// Debug masks for use with ngx_log_debug_mask, these represent the only accepted values for the
42-
/// mask.
43-
#[derive(Debug)]
44-
pub enum DebugMask {
45-
/// Aligns to the NGX_LOG_DEBUG_CORE mask.
46-
Core,
47-
/// Aligns to the NGX_LOG_DEBUG_ALLOC mask.
48-
Alloc,
49-
/// Aligns to the NGX_LOG_DEBUG_MUTEX mask.
50-
Mutex,
51-
/// Aligns to the NGX_LOG_DEBUG_EVENT mask.
52-
Event,
53-
/// Aligns to the NGX_LOG_DEBUG_HTTP mask.
54-
Http,
55-
/// Aligns to the NGX_LOG_DEBUG_MAIL mask.
56-
Mail,
57-
/// Aligns to the NGX_LOG_DEBUG_STREAM mask.
58-
Stream,
59-
}
60-
61-
impl TryFrom<u32> for DebugMask {
62-
type Error = u32;
63-
64-
fn try_from(value: u32) -> Result<Self, Self::Error> {
65-
match value {
66-
crate::ffi::NGX_LOG_DEBUG_CORE => Ok(DebugMask::Core),
67-
crate::ffi::NGX_LOG_DEBUG_ALLOC => Ok(DebugMask::Alloc),
68-
crate::ffi::NGX_LOG_DEBUG_MUTEX => Ok(DebugMask::Mutex),
69-
crate::ffi::NGX_LOG_DEBUG_EVENT => Ok(DebugMask::Event),
70-
crate::ffi::NGX_LOG_DEBUG_HTTP => Ok(DebugMask::Http),
71-
crate::ffi::NGX_LOG_DEBUG_MAIL => Ok(DebugMask::Mail),
72-
crate::ffi::NGX_LOG_DEBUG_STREAM => Ok(DebugMask::Stream),
73-
_ => Err(0),
74-
}
75-
}
76-
}
77-
78-
impl From<DebugMask> for u32 {
79-
fn from(value: DebugMask) -> Self {
80-
match value {
81-
DebugMask::Core => crate::ffi::NGX_LOG_DEBUG_CORE,
82-
DebugMask::Alloc => crate::ffi::NGX_LOG_DEBUG_ALLOC,
83-
DebugMask::Mutex => crate::ffi::NGX_LOG_DEBUG_MUTEX,
84-
DebugMask::Event => crate::ffi::NGX_LOG_DEBUG_EVENT,
85-
DebugMask::Http => crate::ffi::NGX_LOG_DEBUG_HTTP,
86-
DebugMask::Mail => crate::ffi::NGX_LOG_DEBUG_MAIL,
87-
DebugMask::Stream => crate::ffi::NGX_LOG_DEBUG_STREAM,
88-
}
89-
}
90-
}
91-
9241
/// Log with requested debug mask.
9342
///
94-
/// **NOTE:** This macro supports `DebugMask::Http` (`NGX_LOG_DEBUG_HTTP`), however, if you have
95-
/// access to a Request object via an http handler it can be more convenient and readable to use the
96-
/// `ngx_log_debug_http` macro instead.
43+
/// **NOTE:** This macro supports [`DebugMask::Http`] (`NGX_LOG_DEBUG_HTTP`), however, if you have
44+
/// access to a Request object via an http handler it can be more convenient and readable to use
45+
/// the [`ngx_log_debug_http`] macro instead.
9746
///
98-
/// See https://nginx.org/en/docs/dev/development_guide.html#logging for details and available
47+
/// See <https://nginx.org/en/docs/dev/development_guide.html#logging> for details and available
9948
/// masks.
10049
#[macro_export]
10150
macro_rules! ngx_log_debug_mask {
@@ -178,6 +127,57 @@ macro_rules! ngx_log_debug_mask {
178127
});
179128
}
180129

130+
/// Debug masks for use with [`ngx_log_debug_mask`], these represent the only accepted values for
131+
/// the mask.
132+
#[derive(Debug)]
133+
pub enum DebugMask {
134+
/// Aligns to the NGX_LOG_DEBUG_CORE mask.
135+
Core,
136+
/// Aligns to the NGX_LOG_DEBUG_ALLOC mask.
137+
Alloc,
138+
/// Aligns to the NGX_LOG_DEBUG_MUTEX mask.
139+
Mutex,
140+
/// Aligns to the NGX_LOG_DEBUG_EVENT mask.
141+
Event,
142+
/// Aligns to the NGX_LOG_DEBUG_HTTP mask.
143+
Http,
144+
/// Aligns to the NGX_LOG_DEBUG_MAIL mask.
145+
Mail,
146+
/// Aligns to the NGX_LOG_DEBUG_STREAM mask.
147+
Stream,
148+
}
149+
150+
impl TryFrom<u32> for DebugMask {
151+
type Error = u32;
152+
153+
fn try_from(value: u32) -> Result<Self, Self::Error> {
154+
match value {
155+
crate::ffi::NGX_LOG_DEBUG_CORE => Ok(DebugMask::Core),
156+
crate::ffi::NGX_LOG_DEBUG_ALLOC => Ok(DebugMask::Alloc),
157+
crate::ffi::NGX_LOG_DEBUG_MUTEX => Ok(DebugMask::Mutex),
158+
crate::ffi::NGX_LOG_DEBUG_EVENT => Ok(DebugMask::Event),
159+
crate::ffi::NGX_LOG_DEBUG_HTTP => Ok(DebugMask::Http),
160+
crate::ffi::NGX_LOG_DEBUG_MAIL => Ok(DebugMask::Mail),
161+
crate::ffi::NGX_LOG_DEBUG_STREAM => Ok(DebugMask::Stream),
162+
_ => Err(0),
163+
}
164+
}
165+
}
166+
167+
impl From<DebugMask> for u32 {
168+
fn from(value: DebugMask) -> Self {
169+
match value {
170+
DebugMask::Core => crate::ffi::NGX_LOG_DEBUG_CORE,
171+
DebugMask::Alloc => crate::ffi::NGX_LOG_DEBUG_ALLOC,
172+
DebugMask::Mutex => crate::ffi::NGX_LOG_DEBUG_MUTEX,
173+
DebugMask::Event => crate::ffi::NGX_LOG_DEBUG_EVENT,
174+
DebugMask::Http => crate::ffi::NGX_LOG_DEBUG_HTTP,
175+
DebugMask::Mail => crate::ffi::NGX_LOG_DEBUG_MAIL,
176+
DebugMask::Stream => crate::ffi::NGX_LOG_DEBUG_STREAM,
177+
}
178+
}
179+
}
180+
181181
#[cfg(test)]
182182
mod tests {
183183

0 commit comments

Comments
 (0)