Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
Remove T generic from NetlinkDeserializable and NetlinkSerializable
Browse files Browse the repository at this point in the history
`T` always was the same as `Self`.
Also do a major bump on depending crates.
  • Loading branch information
stbuehler committed Nov 14, 2021
1 parent 1cd3e0f commit 94c2632
Show file tree
Hide file tree
Showing 27 changed files with 67 additions and 68 deletions.
6 changes: 3 additions & 3 deletions audit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "audit"
version = "0.4.0"
version = "0.5.0" # TODO: drop this comment - already bumped version for trait changes
authors = ["Corentin Henry <corentinhenry@gmail.com>"]
edition = "2018"

Expand All @@ -14,8 +14,8 @@ description = "linux audit via netlink"
[dependencies]
futures = "0.3.11"
thiserror = "1"
netlink-packet-audit = "0.2"
netlink-proto = { default-features = false, version = "0.7" }
netlink-packet-audit = "0.3"
netlink-proto = { default-features = false, version = "0.8" }

[features]
default = ["tokio_socket"]
Expand Down
10 changes: 5 additions & 5 deletions ethtool/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ethtool"
version = "0.1.0"
version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes
authors = ["Gris Ge <fge@redhat.com>"]
license = "MIT"
edition = "2018"
Expand All @@ -24,12 +24,12 @@ anyhow = "1.0.44"
async-std = { version = "1.9.0", optional = true}
byteorder = "1.4.3"
futures = "0.3.17"
genetlink = { default-features = false, version = "0.1.0"}
genetlink = { default-features = false, version = "0.2.0"}
log = "0.4.14"
netlink-packet-core = "0.2.4"
netlink-packet-generic = "0.1.0"
netlink-packet-core = "0.3.0"
netlink-packet-generic = "0.2.0"
netlink-packet-utils = "0.4.1"
netlink-proto = { default-features = false, version = "0.7.0" }
netlink-proto = { default-features = false, version = "0.8.0" }
netlink-sys = "0.7.0"
thiserror = "1.0.29"
tokio = { version = "1.0.1", features = ["rt"], optional = true}
Expand Down
8 changes: 4 additions & 4 deletions genetlink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "genetlink"
version = "0.1.0"
version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes
authors = ["Leo <leo881003@gmail.com>"]
edition = "2018"
homepage = "https://github.com/little-dude/netlink"
Expand All @@ -17,12 +17,12 @@ smol_socket = ["netlink-proto/smol_socket","netlink-proto/workaround-audit-bug",

[dependencies]
futures = "0.3.16"
netlink-packet-generic = "0.1.0"
netlink-proto = { default-features = false, version = "0.7.0" }
netlink-packet-generic = "0.2.0"
netlink-proto = { default-features = false, version = "0.8.0" }
tokio = { version = "1.9.0", features = ["rt"], optional = true }
async-std = { version = "1.9.0", optional = true }
netlink-packet-utils = "0.4.1"
netlink-packet-core = "0.2.4"
netlink-packet-core = "0.3.0"
thiserror = "1.0.26"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions genetlink/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ where
}
}

impl NetlinkSerializable<RawGenlMessage> for RawGenlMessage {
impl NetlinkSerializable for RawGenlMessage {
fn message_type(&self) -> u16 {
self.family_id
}
Expand All @@ -121,7 +121,7 @@ impl NetlinkSerializable<RawGenlMessage> for RawGenlMessage {
}
}

impl NetlinkDeserializable<RawGenlMessage> for RawGenlMessage {
impl NetlinkDeserializable for RawGenlMessage {
type Error = DecodeError;
fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error> {
let buffer = GenlBuffer::new_checked(payload)?;
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-audit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Corentin Henry <corentinhenry@gmail.com>"]
name = "netlink-packet-audit"
version = "0.2.2"
version = "0.3.0" # TODO: drop this comment - already bumped version for trait changes
edition = "2018"

homepage = "https://github.com/little-dude/netlink"
Expand All @@ -14,7 +14,7 @@ description = "netlink packet types"
[dependencies]
anyhow = "1.0.31"
byteorder = "1.3.2"
netlink-packet-core = "0.2"
netlink-packet-core = "0.3"
netlink-packet-utils = ">= 0.3, <0.5"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-audit/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2018"
cargo-fuzz = true

[dependencies]
netlink-packet-audit = "0.2"
netlink-packet-core = "0.2"
netlink-packet-audit = "0.3"
netlink-packet-core = "0.3"
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }

[[bin]]
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-audit/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Emitable for AuditMessage {
}
}

impl NetlinkSerializable<AuditMessage> for AuditMessage {
impl NetlinkSerializable for AuditMessage {
fn message_type(&self) -> u16 {
self.message_type()
}
Expand All @@ -120,7 +120,7 @@ impl NetlinkSerializable<AuditMessage> for AuditMessage {
}
}

impl NetlinkDeserializable<AuditMessage> for AuditMessage {
impl NetlinkDeserializable for AuditMessage {
type Error = DecodeError;
fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error> {
match AuditBuffer::new_checked(payload) {
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Corentin Henry <corentinhenry@gmail.com>"]
name = "netlink-packet-core"
version = "0.2.4"
version = "0.3.0" # TODO: drop this comment - already bumped version for trait changes
edition = "2018"

homepage = "https://github.com/little-dude/netlink"
Expand All @@ -18,4 +18,4 @@ libc = "0.2.66"
netlink-packet-utils = ">=0.3, <0.5"

[dev-dependencies]
netlink-packet-route = "0.8"
netlink-packet-route = "0.9"
4 changes: 2 additions & 2 deletions netlink-packet-core/examples/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl fmt::Display for DeserializeError {
}

// NetlinkDeserializable implementation
impl NetlinkDeserializable<PingPongMessage> for PingPongMessage {
impl NetlinkDeserializable for PingPongMessage {
type Error = DeserializeError;

fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error> {
Expand All @@ -59,7 +59,7 @@ impl NetlinkDeserializable<PingPongMessage> for PingPongMessage {
}

// NetlinkSerializable implementation
impl NetlinkSerializable<PingPongMessage> for PingPongMessage {
impl NetlinkSerializable for PingPongMessage {
fn message_type(&self) -> u16 {
match self {
PingPongMessage::Ping(_) => PING_MESSAGE,
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
//! }
//!
//! // NetlinkDeserializable implementation
//! impl NetlinkDeserializable<PingPongMessage> for PingPongMessage {
//! impl NetlinkDeserializable for PingPongMessage {
//! type Error = DeserializeError;
//!
//! fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error> {
Expand All @@ -171,7 +171,7 @@
//! }
//!
//! // NetlinkSerializable implementation
//! impl NetlinkSerializable<PingPongMessage> for PingPongMessage {
//! impl NetlinkSerializable for PingPongMessage {
//! fn message_type(&self) -> u16 {
//! match self {
//! PingPongMessage::Ping(_) => PING_MESSAGE,
Expand Down
8 changes: 4 additions & 4 deletions netlink-packet-core/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ where

impl<I> NetlinkMessage<I>
where
I: NetlinkDeserializable<I> + Debug + PartialEq + Eq + Clone,
I: NetlinkDeserializable + Debug + PartialEq + Eq + Clone,
{
/// Parse the given buffer as a netlink message
pub fn deserialize(buffer: &[u8]) -> Result<Self, DecodeError> {
Expand All @@ -56,7 +56,7 @@ where

impl<I> NetlinkMessage<I>
where
I: NetlinkSerializable<I> + Debug + PartialEq + Eq + Clone,
I: NetlinkSerializable + Debug + PartialEq + Eq + Clone,
{
/// Return the length of this message in bytes
pub fn buffer_len(&self) -> usize {
Expand Down Expand Up @@ -92,7 +92,7 @@ where
impl<'buffer, B, I> Parseable<NetlinkBuffer<&'buffer B>> for NetlinkMessage<I>
where
B: AsRef<[u8]> + 'buffer,
I: Debug + PartialEq + Eq + Clone + NetlinkDeserializable<I>,
I: Debug + PartialEq + Eq + Clone + NetlinkDeserializable,
{
fn parse(buf: &NetlinkBuffer<&'buffer B>) -> Result<Self, DecodeError> {
use self::NetlinkPayload::*;
Expand Down Expand Up @@ -129,7 +129,7 @@ where

impl<I> Emitable for NetlinkMessage<I>
where
I: NetlinkSerializable<I> + Debug + PartialEq + Eq + Clone,
I: NetlinkSerializable + Debug + PartialEq + Eq + Clone,
{
fn buffer_len(&self) -> usize {
use self::NetlinkPayload::*;
Expand Down
2 changes: 1 addition & 1 deletion netlink-packet-core/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ where

impl<I> NetlinkPayload<I>
where
I: NetlinkSerializable<I> + Debug + PartialEq + Eq + Clone,
I: NetlinkSerializable + Debug + PartialEq + Eq + Clone,
{
pub fn message_type(&self) -> u16 {
match self {
Expand Down
11 changes: 5 additions & 6 deletions netlink-packet-core/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::NetlinkHeader;
use std::error::Error;

/// A `NetlinkDeserializable` type can be used to deserialize a buffer
/// into the target type `T` for which it is implemented.
pub trait NetlinkDeserializable<T> {
/// A `NetlinkDeserializable` type can be deserialized from a buffer
pub trait NetlinkDeserializable: Sized {
type Error: Error + Send + Sync + 'static;

/// Deserialize the given buffer into `T`.
fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<T, Self::Error>;
/// Deserialize the given buffer into `Self`.
fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error>;
}

pub trait NetlinkSerializable<T> {
pub trait NetlinkSerializable {
fn message_type(&self) -> u16;

/// Return the length of the serialized data.
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-generic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "netlink-packet-generic"
version = "0.1.0"
version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes
authors = ["Leo <leo881003@gmail.com>"]
edition = "2018"
homepage = "https://github.com/little-dude/netlink"
Expand All @@ -14,7 +14,7 @@ description = "generic netlink packet types"
anyhow = "1.0.39"
libc = "0.2.86"
byteorder = "1.4.2"
netlink-packet-core = "0.2"
netlink-packet-core = "0.3"
netlink-packet-utils = "0.4"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-generic/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
}
}

impl<F> NetlinkSerializable<GenlMessage<F>> for GenlMessage<F>
impl<F> NetlinkSerializable for GenlMessage<F>
where
F: GenlFamily + Emitable + Clone + Debug + PartialEq + Eq,
{
Expand All @@ -163,7 +163,7 @@ where
}
}

impl<'a, F> NetlinkDeserializable<GenlMessage<F>> for GenlMessage<F>
impl<F> NetlinkDeserializable for GenlMessage<F>
where
F: ParseableParametrized<[u8], GenlHeader> + Clone + Debug + PartialEq + Eq,
{
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-route/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Corentin Henry <corentinhenry@gmail.com>"]
name = "netlink-packet-route"
version = "0.8.0"
version = "0.9.0" # TODO: drop this comment - already bumped version for trait changes
edition = "2018"

homepage = "https://github.com/little-dude/netlink"
Expand All @@ -15,7 +15,7 @@ description = "netlink packet types"
anyhow = "1.0.31"
byteorder = "1.3.2"
libc = "0.2.66"
netlink-packet-core = "0.2"
netlink-packet-core = "0.3"
netlink-packet-utils = "0.4"
bitflags = "1.2.1"

Expand Down
2 changes: 1 addition & 1 deletion netlink-packet-route/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
cargo-fuzz = true

[dependencies]
netlink-packet-route = "0.7"
netlink-packet-route = "0.9"
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }

[[bin]]
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-route/src/rtnl/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl Emitable for RtnlMessage {
}
}

impl NetlinkSerializable<RtnlMessage> for RtnlMessage {
impl NetlinkSerializable for RtnlMessage {
fn message_type(&self) -> u16 {
self.message_type()
}
Expand All @@ -370,7 +370,7 @@ impl NetlinkSerializable<RtnlMessage> for RtnlMessage {
}
}

impl NetlinkDeserializable<RtnlMessage> for RtnlMessage {
impl NetlinkDeserializable for RtnlMessage {
type Error = DecodeError;
fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error> {
let buf = RtnlMessageBuffer::new(payload);
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-sock-diag/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Flier Lu <flier.lu@gmail.com>", "Corentin Henry <corentinhenry@gmail.com>"]
name = "netlink-packet-sock-diag"
version = "0.1.0"
version = "0.2.0" # TODO: drop this comment - already bumped version for trait changes
edition = "2018"

homepage = "https://github.com/little-dude/netlink"
Expand All @@ -14,7 +14,7 @@ description = "netlink packet types for the sock_diag subprotocol"
[dependencies]
anyhow = "1.0.32"
byteorder = "1.3.4"
netlink-packet-core = "0.2"
netlink-packet-core = "0.3"
netlink-packet-utils = ">= 0.3, <0.5"
bitflags = "1.2.1"
libc = "0.2.77"
Expand Down
4 changes: 2 additions & 2 deletions netlink-packet-sock-diag/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Emitable for SockDiagMessage {
}
}

impl NetlinkSerializable<SockDiagMessage> for SockDiagMessage {
impl NetlinkSerializable for SockDiagMessage {
fn message_type(&self) -> u16 {
self.message_type()
}
Expand All @@ -78,7 +78,7 @@ impl NetlinkSerializable<SockDiagMessage> for SockDiagMessage {
}
}

impl NetlinkDeserializable<SockDiagMessage> for SockDiagMessage {
impl NetlinkDeserializable for SockDiagMessage {
type Error = DecodeError;
fn deserialize(header: &NetlinkHeader, payload: &[u8]) -> Result<Self, Self::Error> {
let buffer = SockDiagBuffer::new_checked(&payload)?;
Expand Down
8 changes: 4 additions & 4 deletions netlink-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Corentin Henry <corentinhenry@gmail.com>"]
name = "netlink-proto"
version = "0.7.0"
version = "0.8.0" # TODO: drop this comment - already bumped version for trait changes
edition = "2018"

homepage = "https://github.com/little-dude/netlink"
Expand All @@ -17,7 +17,7 @@ log = "0.4.8"
futures = "0.3"
tokio = { version = "1.0", default-features = false, features = ["io-util"] }
tokio-util = { version = "0.6", default-features = false, features = ["codec"] }
netlink-packet-core = "0.2"
netlink-packet-core = "0.3"
netlink-sys = { default-features = false, version = "0.7" }

[features]
Expand All @@ -29,8 +29,8 @@ workaround-audit-bug = []
[dev-dependencies]
env_logger = "0.8.2"
tokio = { version = "1.0.1", default-features = false, features = ["macros", "rt-multi-thread"] }
netlink-packet-route = "0.8"
netlink-packet-audit = "0.2"
netlink-packet-route = "0.9"
netlink-packet-audit = "0.3"
async-std = {version = "1.9.0", features = ["attributes"]}

[[example]]
Expand Down
Loading

0 comments on commit 94c2632

Please sign in to comment.