@@ -222,7 +222,7 @@ impl AddressFamily {
222
222
}
223
223
}
224
224
225
- #[ derive( Clone , Copy ) ]
225
+ #[ derive( Copy ) ]
226
226
pub enum InetAddr {
227
227
V4 ( libc:: sockaddr_in ) ,
228
228
V6 ( libc:: sockaddr_in6 ) ,
@@ -348,6 +348,12 @@ impl hash::Hash for InetAddr {
348
348
}
349
349
}
350
350
351
+ impl Clone for InetAddr {
352
+ fn clone ( & self ) -> InetAddr {
353
+ * self
354
+ }
355
+ }
356
+
351
357
impl fmt:: Display for InetAddr {
352
358
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
353
359
match * self {
@@ -357,6 +363,12 @@ impl fmt::Display for InetAddr {
357
363
}
358
364
}
359
365
366
+ impl fmt:: Debug for InetAddr {
367
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
368
+ fmt:: Display :: fmt ( self , f)
369
+ }
370
+ }
371
+
360
372
/*
361
373
*
362
374
* ===== IpAddr =====
@@ -390,7 +402,6 @@ impl IpAddr {
390
402
net::IpAddr::V6(ref std) => IpAddr::V6(Ipv6Addr::from_std(std)),
391
403
}
392
404
}
393
-
394
405
pub fn to_std(&self) -> net::IpAddr {
395
406
match *self {
396
407
IpAddr::V4(ref ip) => net::IpAddr::V4(ip.to_std()),
@@ -409,13 +420,19 @@ impl fmt::Display for IpAddr {
409
420
}
410
421
}
411
422
423
+ impl fmt:: Debug for IpAddr {
424
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
425
+ fmt:: Display :: fmt ( self , f)
426
+ }
427
+ }
428
+
412
429
/*
413
430
*
414
431
* ===== Ipv4Addr =====
415
432
*
416
433
*/
417
434
418
- #[ derive( Clone , Copy ) ]
435
+ #[ derive( Copy ) ]
419
436
pub struct Ipv4Addr ( pub libc:: in_addr ) ;
420
437
421
438
impl Ipv4Addr {
@@ -463,13 +480,25 @@ impl hash::Hash for Ipv4Addr {
463
480
}
464
481
}
465
482
483
+ impl Clone for Ipv4Addr {
484
+ fn clone ( & self ) -> Ipv4Addr {
485
+ * self
486
+ }
487
+ }
488
+
466
489
impl fmt:: Display for Ipv4Addr {
467
490
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
468
491
let octets = self . octets ( ) ;
469
492
write ! ( fmt, "{}.{}.{}.{}" , octets[ 0 ] , octets[ 1 ] , octets[ 2 ] , octets[ 3 ] )
470
493
}
471
494
}
472
495
496
+ impl fmt:: Debug for Ipv4Addr {
497
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
498
+ fmt:: Display :: fmt ( self , f)
499
+ }
500
+ }
501
+
473
502
/*
474
503
*
475
504
* ===== Ipv6Addr =====
@@ -524,6 +553,12 @@ impl fmt::Display for Ipv6Addr {
524
553
}
525
554
}
526
555
556
+ impl fmt:: Debug for Ipv6Addr {
557
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
558
+ fmt:: Display :: fmt ( self , f)
559
+ }
560
+ }
561
+
527
562
/*
528
563
*
529
564
* ===== UnixAddr =====
@@ -538,7 +573,7 @@ impl fmt::Display for Ipv6Addr {
538
573
/// does not require that `sun_len` include the terminating null even for normal
539
574
/// sockets. Note that the actual sockaddr length is greater by
540
575
/// `offset_of!(libc::sockaddr_un, sun_path)`
541
- #[ derive( Clone , Copy ) ]
576
+ #[ derive( Copy ) ]
542
577
pub struct UnixAddr ( pub libc:: sockaddr_un , pub usize ) ;
543
578
544
579
impl UnixAddr {
@@ -645,6 +680,12 @@ impl hash::Hash for UnixAddr {
645
680
}
646
681
}
647
682
683
+ impl Clone for UnixAddr {
684
+ fn clone ( & self ) -> UnixAddr {
685
+ * self
686
+ }
687
+ }
688
+
648
689
impl fmt:: Display for UnixAddr {
649
690
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
650
691
if self . 1 == 0 {
@@ -658,14 +699,20 @@ impl fmt::Display for UnixAddr {
658
699
}
659
700
}
660
701
702
+ impl fmt:: Debug for UnixAddr {
703
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
704
+ fmt:: Display :: fmt ( self , f)
705
+ }
706
+ }
707
+
661
708
/*
662
709
*
663
710
* ===== Sock addr =====
664
711
*
665
712
*/
666
713
667
714
/// Represents a socket address
668
- #[ derive( Clone , Copy ) ]
715
+ #[ derive( Copy , Debug ) ]
669
716
pub enum SockAddr {
670
717
Inet ( InetAddr ) ,
671
718
Unix ( UnixAddr ) ,
@@ -732,7 +779,8 @@ impl SockAddr {
732
779
SysControlAddr ( * ( addr as * const sys_control:: sockaddr_ctl ) ) ) ) ,
733
780
// Other address families are currently not supported and simply yield a None
734
781
// entry instead of a proper conversion to a `SockAddr`.
735
- Some ( _) | None => None ,
782
+ Some ( _) => None ,
783
+ None => None ,
736
784
}
737
785
}
738
786
}
@@ -784,6 +832,12 @@ impl hash::Hash for SockAddr {
784
832
}
785
833
}
786
834
835
+ impl Clone for SockAddr {
836
+ fn clone ( & self ) -> SockAddr {
837
+ * self
838
+ }
839
+ }
840
+
787
841
impl fmt:: Display for SockAddr {
788
842
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
789
843
match * self {
@@ -850,6 +904,12 @@ pub mod netlink {
850
904
write ! ( f, "pid: {} groups: {}" , self . pid( ) , self . groups( ) )
851
905
}
852
906
}
907
+
908
+ impl fmt:: Debug for NetlinkAddr {
909
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
910
+ fmt:: Display :: fmt ( self , f)
911
+ }
912
+ }
853
913
}
854
914
855
915
#[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
@@ -948,4 +1008,10 @@ pub mod sys_control {
948
1008
write ! ( f, "id: {} unit: {}" , self . id( ) , self . unit( ) )
949
1009
}
950
1010
}
951
- }
1011
+
1012
+ impl fmt:: Debug for SysControlAddr {
1013
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1014
+ fmt:: Display :: fmt ( self , f)
1015
+ }
1016
+ }
1017
+ }
0 commit comments