From 6d2be50597e741d9eb3e5dc4a8573dc4c76cc89e Mon Sep 17 00:00:00 2001 From: Gris Ge Date: Tue, 21 Jan 2025 09:33:38 +0800 Subject: [PATCH] Run cargo fmt Signed-off-by: Gris Ge --- src/framed.rs | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/framed.rs b/src/framed.rs index a8d1446..7fe235a 100644 --- a/src/framed.rs +++ b/src/framed.rs @@ -2,7 +2,12 @@ use bytes::BytesMut; use std::{ - fmt::Debug, io, marker::PhantomData, mem::size_of, pin::Pin, task::{Context, Poll} + fmt::Debug, + io, + marker::PhantomData, + mem::size_of, + pin::Pin, + task::{Context, Poll}, }; use futures::{Sink, Stream}; @@ -13,8 +18,8 @@ use crate::{ sys::{AsyncSocket, SocketAddr}, }; use netlink_packet_core::{ - NetlinkDeserializable, NetlinkMessage, NetlinkSerializable, NetlinkHeader, - NLMSG_OVERRUN, NetlinkPayload, + NetlinkDeserializable, NetlinkHeader, NetlinkMessage, NetlinkPayload, + NetlinkSerializable, NLMSG_OVERRUN, }; /// Buffer overrun condition @@ -68,24 +73,28 @@ where *in_addr = match ready!(socket.poll_recv_from(cx, reader)) { Ok(addr) => addr, - // When receiving messages in multicast mode (i.e. we subscribed to - // notifications), the kernel will not wait for us to read datagrams before - // sending more. The receive buffer has a finite size, so once it is full (no - // more message can fit in), new messages will be dropped and recv calls will - // return `ENOBUFS`. - // This needs to be handled for applications to resynchronize with the contents - // of the kernel if necessary. + // When receiving messages in multicast mode (i.e. we subscribed + // to notifications), the kernel will not wait + // for us to read datagrams before sending more. + // The receive buffer has a finite size, so once it is full (no + // more message can fit in), new messages will be dropped and + // recv calls will return `ENOBUFS`. + // This needs to be handled for applications to resynchronize + // with the contents of the kernel if necessary. // We don't need to do anything special: - // - contents of the reader is still valid because we won't have partial messages - // in there anyways (large enough buffer) - // - contents of the socket's internal buffer is still valid because the kernel - // won't put partial data in it + // - contents of the reader is still valid because we won't have + // partial messages in there anyways (large enough buffer) + // - contents of the socket's internal buffer is still valid + // because the kernel won't put partial data in it Err(e) if e.raw_os_error() == Some(ENOBUFS) => { warn!("netlink socket buffer full"); let mut hdr = NetlinkHeader::default(); hdr.length = size_of::() as u32; hdr.message_type = NLMSG_OVERRUN; - let msg = NetlinkMessage::new(hdr, NetlinkPayload::Overrun(Vec::new())); + let msg = NetlinkMessage::new( + hdr, + NetlinkPayload::Overrun(Vec::new()), + ); return Poll::Ready(Some((msg, SocketAddr::new(0, 0)))); } Err(e) => {