• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2023 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 //     http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 //! Event-driven non-blocking Tcp/Udp
15 
16 macro_rules! syscall {
17     ($fn: ident ( $($arg: expr),* $(,)* ) ) => {{
18         let res = unsafe { libc::$fn($($arg, )*) };
19         if res == -1 {
20             Err(std::io::Error::last_os_error())
21         } else {
22             Ok(res)
23         }
24     }};
25 }
26 
27 cfg_tcp! {
28     mod tcp;
29     pub use self::tcp::{TcpListener, TcpStream};
30 }
31 
32 cfg_udp! {
33     mod udp;
34     pub use self::udp::{UdpSocket, ConnectedUdpSocket};
35 }
36 
37 mod uds;
38 pub use uds::{SocketAddr, UnixDatagram, UnixListener, UnixStream};
39 
40 mod epoll;
41 pub use epoll::Selector;
42 
43 mod socket_addr;
44 
45 mod events;
46 pub use events::{Event, Events};
47 
48 mod waker;
49 pub(crate) use waker::WakerInner;
50