Skip to main content

netlink_socket2/
lib.rs

1#![allow(clippy::doc_lazy_continuation)]
2#![doc = include_str!("../README.md")]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4
5/// Netlink documentation recommends max(8192, page_size)
6pub const RECV_BUF_SIZE: usize = 8192;
7
8mod error;
9pub use error::ReplyError;
10
11#[cfg(all(feature = "std", feature = "async"))]
12pub use crate::std::*;
13
14#[cfg(not(feature = "async"))]
15pub use crate::std::*;
16
17#[cfg(all(not(feature = "std"), feature = "tokio", not(feature = "smol")))]
18pub use crate::tokio::*;
19
20#[cfg(all(not(feature = "std"), not(feature = "tokio"), feature = "smol"))]
21pub use crate::smol::*;
22
23use strip_async::{keep, skip, strip_async};
24
25#[cfg_attr(docsrs, doc(cfg(any(feature = "std", not(feature = "async")))))]
26#[cfg(any(feature = "std", not(feature = "async")))]
27#[path = ""]
28pub mod std {
29    use crate::keep as only_sync;
30    use crate::keep as not_tokio;
31    use crate::skip as only_async;
32    use crate::skip as only_tokio;
33
34    use crate::strip_async;
35
36    use std::{
37        io::{Read, Write},
38        net::TcpStream as Socket,
39    };
40
41    pub(crate) mod chained;
42    pub(crate) mod multicast;
43    pub(crate) mod sock;
44
45    pub use {
46        chained::NetlinkReplyChained,
47        multicast::{MulticastRecv, MulticastSocketRaw},
48        sock::{NetlinkReply, NetlinkSocket},
49    };
50}
51
52#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
53#[cfg(feature = "tokio")]
54#[path = ""]
55pub mod tokio {
56    use crate::keep as only_async;
57    use crate::keep as only_tokio;
58    use crate::skip as only_sync;
59    use crate::skip as not_tokio;
60
61    use crate::keep as strip_async;
62
63    use tokio::{
64        io::{AsyncReadExt as Read, AsyncWriteExt as Write},
65        net::TcpStream as Socket,
66    };
67
68    pub(crate) mod chained;
69    pub(crate) mod multicast;
70    pub(crate) mod sock;
71
72    pub use {
73        chained::NetlinkReplyChained,
74        multicast::{MulticastRecv, MulticastSocketRaw},
75        sock::{NetlinkReply, NetlinkSocket},
76    };
77}
78
79#[cfg_attr(docsrs, doc(cfg(feature = "smol")))]
80#[cfg(feature = "smol")]
81#[path = ""]
82pub mod smol {
83    use crate::keep as only_async;
84    use crate::keep as not_tokio;
85    use crate::skip as only_tokio;
86    use crate::skip as only_sync;
87
88    use crate::keep as strip_async;
89
90    use smol::io::{AsyncReadExt as Read, AsyncWriteExt as Write};
91    type Socket = smol::Async<std::net::TcpStream>;
92
93    pub(crate) mod chained;
94    pub(crate) mod multicast;
95    pub(crate) mod sock;
96
97    pub use {
98        chained::NetlinkReplyChained,
99        multicast::{MulticastRecv, MulticastSocketRaw},
100        sock::{NetlinkReply, NetlinkSocket},
101    };
102}