@@ -612,7 +612,7 @@ pub(crate) fn poll_connect(socket: &crate::Socket, timeout: Duration) -> io::Res
612612 }
613613
614614 let timeout = ( timeout - elapsed) . as_millis ( ) ;
615- let timeout = clamp ( timeout , 1 , c_int:: MAX as u128 ) as c_int ;
615+ let timeout = timeout . clamp ( 1 , c_int:: MAX as u128 ) as c_int ;
616616
617617 match syscall ! ( poll( & mut pollfd, 1 , timeout) ) {
618618 Ok ( 0 ) => return Err ( io:: ErrorKind :: TimedOut . into ( ) ) ,
@@ -638,20 +638,6 @@ pub(crate) fn poll_connect(socket: &crate::Socket, timeout: Duration) -> io::Res
638638 }
639639}
640640
641- // TODO: use clamp from std lib, stable since 1.50.
642- fn clamp < T > ( value : T , min : T , max : T ) -> T
643- where
644- T : Ord ,
645- {
646- if value <= min {
647- min
648- } else if value >= max {
649- max
650- } else {
651- value
652- }
653- }
654-
655641pub ( crate ) fn listen ( fd : Socket , backlog : c_int ) -> io:: Result < ( ) > {
656642 syscall ! ( listen( fd, backlog) ) . map ( |_| ( ) )
657643}
@@ -2064,14 +2050,14 @@ impl crate::Socket {
20642050 unsafe { getsockopt ( self . as_raw ( ) , libc:: SOL_DCCP , libc:: DCCP_SOCKOPT_TX_CCID ) }
20652051 }
20662052
2067- /// Get the value of the `DCCP_SOCKOPT_XX_CCID ` option on this socket.
2053+ /// Get the value of the `DCCP_SOCKOPT_RX_CCID ` option on this socket.
20682054 ///
20692055 /// For more information about this option see [`set_dccp_ccid`].
20702056 ///
20712057 /// [`set_dccp_ccid`]: crate::Socket::set_dccp_ccid
20722058 #[ cfg( all( feature = "all" , target_os = "linux" ) ) ]
20732059 #[ cfg_attr( docsrs, doc( cfg( feature = "all" , target_os = "linux" ) ) ) ]
2074- pub fn dccp_tx_ccid ( & self ) -> io:: Result < u32 > {
2060+ pub fn dccp_xx_ccid ( & self ) -> io:: Result < u32 > {
20752061 unsafe { getsockopt ( self . as_raw ( ) , libc:: SOL_DCCP , libc:: DCCP_SOCKOPT_RX_CCID ) }
20762062 }
20772063
@@ -2224,7 +2210,7 @@ impl crate::Socket {
22242210 #[ cfg_attr( docsrs, doc( cfg( feature = "all" , target_os = "linux" ) ) ) ]
22252211 pub fn dccp_available_ccids < const N : usize > ( & self ) -> io:: Result < CcidEndpoints < N > > {
22262212 let mut endpoints = [ 0 ; N ] ;
2227- let mut length = buf . len ( ) as libc:: socklen_t ;
2213+ let mut length = endpoints . len ( ) as libc:: socklen_t ;
22282214 syscall ! ( getsockopt(
22292215 self . as_raw( ) ,
22302216 libc:: SOL_DCCP ,
@@ -2255,6 +2241,7 @@ impl crate::Socket {
22552241/// See [`Socket::dccp_available_ccids`].
22562242#[ cfg( all( feature = "all" , target_os = "linux" ) ) ]
22572243#[ cfg_attr( docsrs, doc( cfg( feature = "all" , target_os = "linux" ) ) ) ]
2244+ #[ derive( Debug ) ]
22582245pub struct CcidEndpoints < const N : usize > {
22592246 endpoints : [ u8 ; N ] ,
22602247 length : u32 ,
0 commit comments