2626//!
2727//! # Usage
2828//!
29- //! The `UdsConfig ` transport supports multiaddresses of the form `/unix//tmp/foo`.
29+ //! The `Config ` transport supports multiaddresses of the form `/unix//tmp/foo`.
3030//!
31- //! The `UdsConfig ` structs implements the `Transport` trait of the `core` library. See the
31+ //! The `Config ` structs implements the `Transport` trait of the `core` library. See the
3232//! documentation of `core` and of libp2p in general to learn how to use the `Transport` trait.
3333
3434#![ cfg( all( unix, not( target_os = "emscripten" ) , feature = "tokio" ) ) ]
@@ -62,28 +62,28 @@ pub type Listener<T> = BoxStream<
6262> ;
6363
6464macro_rules! codegen {
65- ( $feature_name: expr, $uds_config : ident, $build_listener: expr, $unix_stream: ty, $( $mut_or_not: tt) * ) => {
65+ ( $feature_name: expr, $config : ident, $build_listener: expr, $unix_stream: ty, $( $mut_or_not: tt) * ) => {
6666 /// Represents the configuration for a Unix domain sockets transport capability for libp2p.
67- pub struct $uds_config {
67+ pub struct $config {
6868 listeners: VecDeque <( ListenerId , Listener <Self >) >,
6969 }
7070
71- impl $uds_config {
71+ impl $config {
7272 /// Creates a new configuration object for Unix domain sockets.
73- pub fn new( ) -> $uds_config {
74- $uds_config {
73+ pub fn new( ) -> $config {
74+ $config {
7575 listeners: VecDeque :: new( ) ,
7676 }
7777 }
7878 }
7979
80- impl Default for $uds_config {
80+ impl Default for $config {
8181 fn default ( ) -> Self {
8282 Self :: new( )
8383 }
8484 }
8585
86- impl Transport for $uds_config {
86+ impl Transport for $config {
8787 type Output = $unix_stream;
8888 type Error = io:: Error ;
8989 type ListenerUpgrade = Ready <Result <Self :: Output , Self :: Error >>;
@@ -204,11 +204,16 @@ macro_rules! codegen {
204204#[ cfg( feature = "tokio" ) ]
205205codegen ! (
206206 "tokio" ,
207- TokioUdsConfig ,
207+ Config ,
208208 |addr| async move { tokio:: net:: UnixListener :: bind( & addr) } ,
209209 tokio:: net:: UnixStream ,
210210) ;
211211
212+ // Deprecated type alias for backward compatibility
213+ #[ cfg( feature = "tokio" ) ]
214+ #[ deprecated( since = "0.43.1" , note = "Use `libp2p::uds::Config` instead" ) ]
215+ pub type TokioUdsConfig = Config ;
216+
212217/// Turns a `Multiaddr` containing a single `Unix` component into a path.
213218///
214219/// Also returns an error if the path is not absolute, as we don't want to dial/listen on relative
@@ -243,7 +248,8 @@ mod tests {
243248 } ;
244249 use tokio:: io:: { AsyncReadExt , AsyncWriteExt } ;
245250
246- use super :: { multiaddr_to_path, TokioUdsConfig } ;
251+ use super :: multiaddr_to_path;
252+ use crate :: Config ;
247253
248254 #[ test]
249255 fn multiaddr_to_path_conversion ( ) {
@@ -272,7 +278,7 @@ mod tests {
272278 let ( tx, rx) = oneshot:: channel ( ) ;
273279
274280 let listener = async move {
275- let mut transport = TokioUdsConfig :: new ( ) . boxed ( ) ;
281+ let mut transport = Config :: new ( ) . boxed ( ) ;
276282 transport. listen_on ( ListenerId :: next ( ) , addr) . unwrap ( ) ;
277283
278284 let listen_addr = transport
@@ -296,7 +302,7 @@ mod tests {
296302 } ;
297303
298304 let dialer = async move {
299- let mut uds = TokioUdsConfig :: new ( ) ;
305+ let mut uds = Config :: new ( ) ;
300306 let addr = rx. await . unwrap ( ) ;
301307 let mut socket = uds
302308 . dial (
@@ -318,7 +324,7 @@ mod tests {
318324 #[ test]
319325 #[ ignore] // TODO: for the moment unix addresses fail to parse
320326 fn larger_addr_denied ( ) {
321- let mut uds = TokioUdsConfig :: new ( ) ;
327+ let mut uds = Config :: new ( ) ;
322328
323329 let addr = "/unix//foo/bar" . parse :: < Multiaddr > ( ) . unwrap ( ) ;
324330 assert ! ( uds. listen_on( ListenerId :: next( ) , addr) . is_err( ) ) ;
0 commit comments