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 maybe_async::async_impl as keep;
24use maybe_async::sync_impl as skip;
25
26#[cfg_attr(docsrs, doc(cfg(any(feature = "std", not(feature = "async")))))]
27#[cfg(any(feature = "std", not(feature = "async")))]
28#[path = ""]
29pub mod std {
30    use crate::keep as only_sync;
31    use crate::keep as not_tokio;
32    use crate::skip as only_async;
33    use crate::skip as only_tokio;
34
35    use maybe_async::must_be_sync as strip_async;
36
37    use std::{
38        io::{Read, Write},
39        net::TcpStream as Socket,
40    };
41
42    pub(crate) mod chained;
43    pub(crate) mod multicast;
44    pub(crate) mod sock;
45
46    pub use {
47        chained::NetlinkReplyChained,
48        multicast::{MulticastRecv, MulticastSocketRaw},
49        sock::{NetlinkReply, NetlinkSocket},
50    };
51}
52
53#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
54#[cfg(feature = "tokio")]
55#[path = ""]
56pub mod tokio {
57    use crate::keep as only_async;
58    use crate::keep as only_tokio;
59    use crate::skip as only_sync;
60    use crate::skip as not_tokio;
61
62    use maybe_async::must_be_async as strip_async;
63
64    use tokio::{
65        io::{AsyncReadExt as Read, AsyncWriteExt as Write},
66        net::TcpStream as Socket,
67    };
68
69    pub(crate) mod chained;
70    pub(crate) mod multicast;
71    pub(crate) mod sock;
72
73    pub use {
74        chained::NetlinkReplyChained,
75        multicast::{MulticastRecv, MulticastSocketRaw},
76        sock::{NetlinkReply, NetlinkSocket},
77    };
78}
79
80#[cfg_attr(docsrs, doc(cfg(feature = "smol")))]
81#[cfg(feature = "smol")]
82#[path = ""]
83pub mod smol {
84    use crate::keep as only_async;
85    use crate::keep as not_tokio;
86    use crate::skip as only_tokio;
87    use crate::skip as only_sync;
88
89    use maybe_async::must_be_async as strip_async;
90
91    use smol::io::{AsyncReadExt as Read, AsyncWriteExt as Write};
92    type Socket = smol::Async<std::net::TcpStream>;
93
94    pub(crate) mod chained;
95    pub(crate) mod multicast;
96    pub(crate) mod sock;
97
98    pub use {
99        chained::NetlinkReplyChained,
100        multicast::{MulticastRecv, MulticastSocketRaw},
101        sock::{NetlinkReply, NetlinkSocket},
102    };
103}