From 8c6402e77b11d05d05c1b6a9332bcd185f04d1fd Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 27 Oct 2024 15:56:01 +0100 Subject: [PATCH] Simplify using recv_from_full --- examples/listen_uevents.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/listen_uevents.rs b/examples/listen_uevents.rs index fb1d069..1059fa5 100644 --- a/examples/listen_uevents.rs +++ b/examples/listen_uevents.rs @@ -23,12 +23,10 @@ use kobject_uevent::UEvent; fn main() { let mut socket = Socket::new(NETLINK_KOBJECT_UEVENT).unwrap(); let sa = SocketAddr::new(process::id(), 1); - let mut buf = vec![0u8; 1024 * 8]; socket.bind(&sa).unwrap(); - loop { - let n = socket.recv(&mut buf, 0).unwrap(); + while let Ok((buf, _addr)) = socket.recv_from_full() { let s = std::str::from_utf8(&buf).unwrap(); let u = UEvent::from_netlink_packet(&buf).unwrap(); println!(">> {}", s);