Skip to content

Commit 9affb83

Browse files
committed
Docs changes: these functions are not unsafe.
* ngx_str_t::to_str * Pool::allocate * Buf and MutableBuf methods
1 parent 9d0cee9 commit 9affb83

File tree

3 files changed

+0
-19
lines changed

3 files changed

+0
-19
lines changed

nginx-sys/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ impl ngx_str_t {
111111

112112
/// Convert the nginx string to a string slice (`&str`).
113113
///
114-
/// # Safety
115-
/// This function is marked as unsafe because it involves raw pointer manipulation.
116-
/// It assumes that the underlying `data` pointer is valid and points to a valid UTF-8 encoded string.
117-
///
118114
/// # Panics
119115
/// This function panics if the `ngx_str_t` is not valid UTF-8.
120116
///

src/core/buffer.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ pub trait Buffer {
1313
fn as_ngx_buf_mut(&mut self) -> *mut ngx_buf_t;
1414

1515
/// Returns the buffer contents as a byte slice.
16-
///
17-
/// # Safety
18-
/// This function is marked as unsafe because it involves raw pointer manipulation.
1916
fn as_bytes(&self) -> &[u8] {
2017
let buf = self.as_ngx_buf();
2118
unsafe { slice::from_raw_parts((*buf).pos, self.len()) }
2219
}
2320

2421
/// Returns the length of the buffer contents.
25-
///
26-
/// # Safety
27-
/// This function is marked as unsafe because it involves raw pointer manipulation.
2822
fn len(&self) -> usize {
2923
let buf = self.as_ngx_buf();
3024
unsafe {
@@ -68,9 +62,6 @@ pub trait Buffer {
6862
/// The `MutableBuffer` trait extends the `Buffer` trait and provides methods for working with a mutable buffer.
6963
pub trait MutableBuffer: Buffer {
7064
/// Returns a mutable reference to the buffer contents as a byte slice.
71-
///
72-
/// # Safety
73-
/// This function is marked as unsafe because it involves raw pointer manipulation.
7465
fn as_bytes_mut(&mut self) -> &mut [u8] {
7566
let buf = self.as_ngx_buf_mut();
7667
unsafe { slice::from_raw_parts_mut((*buf).pos, self.len()) }
@@ -105,9 +96,6 @@ impl Buffer for TemporaryBuffer {
10596

10697
impl MutableBuffer for TemporaryBuffer {
10798
/// Returns a mutable reference to the buffer contents as a byte slice.
108-
///
109-
/// # Safety
110-
/// This function is marked as unsafe because it involves raw pointer manipulation.
11199
fn as_bytes_mut(&mut self) -> &mut [u8] {
112100
unsafe { slice::from_raw_parts_mut((*self.0).pos, self.len()) }
113101
}

src/core/pool.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@ impl Pool {
135135
/// Allocates memory for a value of a specified type and adds a cleanup handler to the memory pool.
136136
///
137137
/// Returns a typed pointer to the allocated memory if successful, or a null pointer if allocation or cleanup handler addition fails.
138-
///
139-
/// # Safety
140-
/// This function is marked as unsafe because it involves raw pointer manipulation.
141138
pub fn allocate<T>(&mut self, value: T) -> *mut T {
142139
unsafe {
143140
let p = self.alloc(mem::size_of::<T>()) as *mut T;

0 commit comments

Comments
 (0)