Skip to main content

ts_netstack_smoltcp_socket/
lib.rs

1#![doc = include_str!("../README.md")]
2// Requires std all the same: `ts_netstack_smoltcp_core` links `flume`, which has no std-less mode.
3#![no_std]
4#![deny(unsafe_code)]
5
6extern crate alloc;
7
8#[cfg(feature = "std")]
9extern crate std;
10
11pub extern crate ts_netstack_smoltcp_core as netcore;
12
13#[doc(inline)]
14pub use netcore::smoltcp::wire::IpProtocol;
15
16/// Provide internal `request` and `request_async` helper methods for sockets, wrapping
17/// [`netcore::request_blocking`] and [`netcore::request`]. Automatically passes
18/// the internal socket `handle` and wraps/unwraps request and response types.
19macro_rules! socket_requestor_impl {
20    () => {
21        fn request_blocking(
22            &self,
23            command: impl Into<$crate::netcore::Command>,
24        ) -> Result<$crate::netcore::Response, $crate::netcore::ChannelClosedError> {
25            ::netcore::HasChannel::request_blocking(&self.sender, Some(self.handle), command)
26        }
27
28        async fn request(
29            &self,
30            command: impl Into<$crate::netcore::Command>,
31        ) -> Result<$crate::netcore::Response, $crate::netcore::Error> {
32            ::netcore::HasChannel::request(&self.sender, Some(self.handle), command).await
33        }
34    };
35}
36
37mod create_socket;
38pub use create_socket::CreateSocket;
39
40pub mod ping;
41mod raw;
42mod tcp;
43mod udp;
44
45pub use ping::PingError;
46#[cfg(feature = "tokio")]
47pub use ping::ping;
48pub use raw::RawSocket;
49pub use tcp::{TcpListener, TcpStream};
50pub use udp::UdpSocket;