tokio_sctp/
lib.rs

1//! # tokio-sctp
2//!
3//! `tokio-sctp` provides non-blocking SCTP socket bindings over the tokio runtime. This crate is
4//! currently Linux only and only supports one-to-one style sockets. Building thus requires the
5//! [lksctp-tools](https://github.com/sctp/lksctp-tools) package is installed on the system.
6mod listener;
7pub use listener::SctpListener;
8
9mod socket;
10pub use socket::*;
11
12mod stream;
13pub use stream::*;
14
15mod split_owned;
16pub use split_owned::*;
17
18mod sys;
19
20use std::io;
21
22fn wrap_io_error(desc: &'static str, e: io::Error) -> io::Error {
23    io::Error::new(e.kind(), WrappedIoErr(desc, e))
24}
25
26struct WrappedIoErr(&'static str, io::Error);
27
28impl std::fmt::Display for WrappedIoErr {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        write!(f, "{:?}", self)
31    }
32}
33
34impl std::fmt::Debug for WrappedIoErr {
35    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36        write!(f, "{}: {:?}", self.0, self.1)
37    }
38}
39
40impl std::error::Error for WrappedIoErr {
41    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
42        Some(&self.1)
43    }
44}