1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-License-Identifier: MIT

use std::fmt::Debug;

use netlink_packet_core::NetlinkMessage;

use crate::sys::SocketAddr;

#[derive(Debug)]
pub(crate) struct Request<T, M> {
    pub metadata: M,
    pub message: NetlinkMessage<T>,
    pub destination: SocketAddr,
}

impl<T, M> From<(NetlinkMessage<T>, SocketAddr, M)> for Request<T, M>
where
    T: Debug,
    M: Debug,
{
    fn from(parts: (NetlinkMessage<T>, SocketAddr, M)) -> Self {
        Request {
            message: parts.0,
            destination: parts.1,
            metadata: parts.2,
        }
    }
}

impl<T, M> From<Request<T, M>> for (NetlinkMessage<T>, SocketAddr, M)
where
    T: Debug,
    M: Debug,
{
    fn from(req: Request<T, M>) -> (NetlinkMessage<T>, SocketAddr, M) {
        (req.message, req.destination, req.metadata)
    }
}