diff --git a/src/payload.rs b/src/payload.rs index e43124bbb..f7a737ef5 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -247,17 +247,19 @@ pub extern "C" fn zc_payload_len(payload: zc_payload_t) -> usize { z_buffer_len(payload) } - - pub use crate::zc_payload_reader; impl_guarded_transmute!(ZBufReader<'static>, zc_payload_reader); impl_guarded_transmute!(noderefs zc_payload_reader, ZBufReader<'static>); -/// Creates a reader for the specified `payload`. +/// Creates a reader for the specified `payload`. /// /// Returns 0 in case of success, -1 if `payload` is not valid. #[no_mangle] -pub unsafe extern "C" fn zc_payload_reader_init(payload: zc_payload_t, reader: *mut zc_payload_reader) -> i8 { +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn zc_payload_reader_init( + payload: zc_payload_t, + reader: *mut zc_payload_reader, +) -> i8 { if payload._inner.is_none() { return -1; } @@ -265,22 +267,30 @@ pub unsafe extern "C" fn zc_payload_reader_init(payload: zc_payload_t, reader: * 0 } - /// Reads data into specified destination. -/// -/// Will read at most `len` bytes. +/// +/// Will read at most `len` bytes. /// Returns number of bytes read. If return value is smaller than `len`, it means that end of the payload was reached. #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn zc_payload_reader_read(reader: *mut zc_payload_reader, dest: *mut u8, len: usize) -> usize { - let buf = unsafe { from_raw_parts_mut(dest, len) } ; - reader.as_mut().unwrap().read(buf).map(|n| n.get()).unwrap_or(0) +pub unsafe extern "C" fn zc_payload_reader_read( + reader: *mut zc_payload_reader, + dest: *mut u8, + len: usize, +) -> usize { + let buf = unsafe { from_raw_parts_mut(dest, len) }; + reader + .as_mut() + .unwrap() + .read(buf) + .map(|n| n.get()) + .unwrap_or(0) } /// Returns number of the remaining bytes in the payload -/// +/// #[no_mangle] #[allow(clippy::missing_safety_doc)] pub unsafe extern "C" fn zc_payload_reader_remaining(reader: *const zc_payload_reader) -> usize { reader.as_ref().unwrap().remaining() -} \ No newline at end of file +}