From f1cdeda3375a415f7c3fc76b1f9606c8a8a1f1a4 Mon Sep 17 00:00:00 2001
From: Denis Biryukov <denis.biryukov@zettascale.tech>
Date: Mon, 8 Apr 2024 14:33:47 +0200
Subject: [PATCH] fmt and clippy

---
 src/payload.rs | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

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
+}