Skip to content

Commit b8a59b1

Browse files
committed
Fix cargo clippy
Signed-off-by: Gris Ge <[email protected]>
1 parent 55e4835 commit b8a59b1

24 files changed

+53
-71
lines changed

src/address/attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Nla for AddressAttribute {
6060
IPV4_ADDR_LEN
6161
}
6262
}
63-
Self::Label(ref string) => string.as_bytes().len() + 1,
63+
Self::Label(ref string) => string.len() + 1,
6464

6565
Self::Flags(_) => size_of::<u32>(),
6666

src/lib.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
// SPDX-License-Identifier: MIT
22

3+
//! The `netlink-packet-route` crate is designed to abstract Netlink route
4+
//! protocol(`rtnetlink`) packet into Rust data types. The goal of this crate is
5+
//! saving netlink user from reading Kernel Netlink codes.
6+
//!
7+
//! This crate grouped Netlink route protocol into these modules:
8+
//! * `link`: NIC interface, similar to to `ip link` command.
9+
//! * `address`: IP address, similar to `ip address` command.
10+
//! * `route`: Route, similar to `ip route` command.
11+
//! * `rule`: Route rule, similar to `ip rule` command.
12+
//! * `tc`: Traffic control, similar to `tc` command.
13+
//! * `neighbour`: Neighbour, similar to `ip neighbour` command.
14+
//! * `neighbour_table`: Neighbour table, similar to `ip ntable` command.
15+
//! * `nsid`: Namespace, similar to `ip netns` command.
16+
//!
17+
//! At the top level of this crate, we also provide:
18+
//! * [AddressFamily]
19+
//!
20+
//! Normally, you should use [`rtnetlink`][rtnetlink_url] instead of using this
21+
//! crate directly.
22+
//!
23+
//! [rtnetlink_url]: https://docs.rs/rtnetlink
24+
325
pub mod address;
426
pub mod link;
527
pub mod neighbour;
@@ -42,28 +64,6 @@ pub use self::address_family_fallback::AddressFamily;
4264
pub use self::ip::IpProtocol;
4365
pub use self::message::{RouteNetlinkMessage, RouteNetlinkMessageBuffer};
4466

45-
/// The `netlink-packet-route` crate is designed to abstract Netlink route
46-
/// protocol(`rtnetlink`) packet into Rust data types. The goal of this crate is
47-
/// saving netlink user from reading Kernel Netlink codes.
48-
///
49-
/// This crate grouped Netlink route protocol into these modules:
50-
/// * `link`: NIC interface, similar to to `ip link` command.
51-
/// * `address`: IP address, similar to `ip address` command.
52-
/// * `route`: Route, similar to `ip route` command.
53-
/// * `rule`: Route rule, similar to `ip rule` command.
54-
/// * `tc`: Traffic control, similar to `tc` command.
55-
/// * `neighbour`: Neighbour, similar to `ip neighbour` command.
56-
/// * `neighbour_table`: Neighbour table, similar to `ip ntable` command.
57-
/// * `nsid`: Namespace, similar to `ip netns` command.
58-
///
59-
/// At the top level of this crate, we also provide:
60-
/// * [AddressFamily]
61-
///
62-
/// Normally, you should use [`rtnetlink`][rtnetlink_url] instead of using this
63-
/// crate directly.
64-
///
65-
/// [rtnetlink_url]: https://docs.rs/rtnetlink
66-
6767
#[macro_use]
6868
extern crate netlink_packet_utils;
6969

src/link/attribute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Nla for LinkAttribute {
188188
Self::IfName(string)
189189
| Self::Qdisc(string)
190190
| Self::IfAlias(string)
191-
| Self::PhysPortName(string) => string.as_bytes().len() + 1,
191+
| Self::PhysPortName(string) => string.len() + 1,
192192

193193
Self::Mode(_) | Self::Carrier(_) | Self::ProtoDown(_) => 1,
194194

src/link/prop_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Nla for Prop {
2222
fn value_len(&self) -> usize {
2323
use self::Prop::*;
2424
match self {
25-
AltIfName(ref string) => string.as_bytes().len() + 1,
25+
AltIfName(ref string) => string.len() + 1,
2626
Other(nla) => nla.value_len()
2727
}
2828
}

src/link/sriov/broadcast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ buffer!(VfInfoBroadcastBuffer(VF_INFO_BROADCAST_LEN) {
2626
addr: (slice, 0..VF_INFO_BROADCAST_LEN),
2727
});
2828

29-
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<VfInfoBroadcastBuffer<&'a T>>
29+
impl<T: AsRef<[u8]> + ?Sized> Parseable<VfInfoBroadcastBuffer<&T>>
3030
for VfInfoBroadcast
3131
{
3232
fn parse(buf: &VfInfoBroadcastBuffer<&T>) -> Result<Self, DecodeError> {

src/link/sriov/guid.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ buffer!(VfInfoGuidBuffer(VF_INFO_GUID_LEN) {
2222
guid: (u64, 4..12),
2323
});
2424

25-
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<VfInfoGuidBuffer<&'a T>>
26-
for VfInfoGuid
27-
{
25+
impl<T: AsRef<[u8]> + ?Sized> Parseable<VfInfoGuidBuffer<&T>> for VfInfoGuid {
2826
fn parse(buf: &VfInfoGuidBuffer<&T>) -> Result<Self, DecodeError> {
2927
Ok(Self::new(buf.vf_id(), buf.guid()))
3028
}

src/link/sriov/link_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buffer!(VfInfoLinkStateBuffer(VF_INFO_LINK_STATE_LEN) {
2222
state: (u32, 4..8),
2323
});
2424

25-
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<VfInfoLinkStateBuffer<&'a T>>
25+
impl<T: AsRef<[u8]> + ?Sized> Parseable<VfInfoLinkStateBuffer<&T>>
2626
for VfInfoLinkState
2727
{
2828
fn parse(buf: &VfInfoLinkStateBuffer<&T>) -> Result<Self, DecodeError> {

src/link/sriov/mac.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ buffer!(VfInfoMacBuffer(VF_INFO_MAC_LEN) {
3333
mac: (slice, 4..VF_INFO_MAC_LEN),
3434
});
3535

36-
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<VfInfoMacBuffer<&'a T>>
37-
for VfInfoMac
38-
{
36+
impl<T: AsRef<[u8]> + ?Sized> Parseable<VfInfoMacBuffer<&T>> for VfInfoMac {
3937
fn parse(buf: &VfInfoMacBuffer<&T>) -> Result<Self, DecodeError> {
4038
Ok(Self::new(buf.vf_id(), buf.mac()))
4139
}

src/link/sriov/rate.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ buffer!(VfInfoRateBuffer(VF_INFO_RATE_LEN) {
2828
max_tx_rate: (u32, 8..12)
2929
});
3030

31-
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<VfInfoRateBuffer<&'a T>>
32-
for VfInfoRate
33-
{
31+
impl<T: AsRef<[u8]> + ?Sized> Parseable<VfInfoRateBuffer<&T>> for VfInfoRate {
3432
fn parse(buf: &VfInfoRateBuffer<&T>) -> Result<Self, DecodeError> {
3533
Ok(Self {
3634
vf_id: buf.vf_id(),

src/link/sriov/rss_query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buffer!(VfInfoRssQueryEnBuffer(VF_INFO_RSS_QUERY_EN_LEN) {
2222
setting: (u32, 4..8),
2323
});
2424

25-
impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<VfInfoRssQueryEnBuffer<&'a T>>
25+
impl<T: AsRef<[u8]> + ?Sized> Parseable<VfInfoRssQueryEnBuffer<&T>>
2626
for VfInfoRssQueryEn
2727
{
2828
fn parse(buf: &VfInfoRssQueryEnBuffer<&T>) -> Result<Self, DecodeError> {

0 commit comments

Comments
 (0)