@@ -6,6 +6,7 @@ use crate::io::{IoSlice, IoSliceMut};
66use crate :: net:: Shutdown ;
77use crate :: os:: unix:: io:: { AsFd , AsRawFd , BorrowedFd , FromRawFd , IntoRawFd , OwnedFd , RawFd } ;
88use crate :: path:: Path ;
9+ use crate :: sealed:: Sealed ;
910use crate :: sys:: cvt;
1011use crate :: sys:: net:: Socket ;
1112use crate :: sys_common:: { AsInner , FromInner , IntoInner } ;
@@ -54,6 +55,10 @@ const MSG_NOSIGNAL: libc::c_int = 0x0;
5455#[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
5556pub struct UnixDatagram ( Socket ) ;
5657
58+ /// Allows extension traits within `std`.
59+ #[ unstable( feature = "sealed" , issue = "none" ) ]
60+ impl Sealed for UnixDatagram { }
61+
5762#[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
5863impl fmt:: Debug for UnixDatagram {
5964 fn fmt ( & self , fmt : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -802,69 +807,6 @@ impl UnixDatagram {
802807 self . 0 . set_nonblocking ( nonblocking)
803808 }
804809
805- /// Moves the socket to pass unix credentials as control message in [`SocketAncillary`].
806- ///
807- /// Set the socket option `SO_PASSCRED`.
808- ///
809- /// # Examples
810- ///
811- #[ cfg_attr(
812- any(
813- target_os = "android" ,
814- target_os = "linux" ,
815- target_os = "netbsd" ,
816- target_os = "freebsd" ,
817- ) ,
818- doc = "```no_run"
819- ) ]
820- #[ cfg_attr(
821- not( any(
822- target_os = "android" ,
823- target_os = "linux" ,
824- target_os = "netbsd" ,
825- target_os = "freebsd"
826- ) ) ,
827- doc = "```ignore"
828- ) ]
829- /// #![feature(unix_socket_ancillary_data)]
830- /// use std::os::unix::net::UnixDatagram;
831- ///
832- /// fn main() -> std::io::Result<()> {
833- /// let sock = UnixDatagram::unbound()?;
834- /// sock.set_passcred(true).expect("set_passcred function failed");
835- /// Ok(())
836- /// }
837- /// ```
838- #[ cfg( any(
839- doc,
840- target_os = "android" ,
841- target_os = "linux" ,
842- target_os = "netbsd" ,
843- target_os = "freebsd"
844- ) ) ]
845- #[ unstable( feature = "unix_socket_ancillary_data" , issue = "76915" ) ]
846- pub fn set_passcred ( & self , passcred : bool ) -> io:: Result < ( ) > {
847- self . 0 . set_passcred ( passcred)
848- }
849-
850- /// Get the current value of the socket for passing unix credentials in [`SocketAncillary`].
851- /// This value can be change by [`set_passcred`].
852- ///
853- /// Get the socket option `SO_PASSCRED`.
854- ///
855- /// [`set_passcred`]: UnixDatagram::set_passcred
856- #[ cfg( any(
857- doc,
858- target_os = "android" ,
859- target_os = "linux" ,
860- target_os = "netbsd" ,
861- target_os = "freebsd"
862- ) ) ]
863- #[ unstable( feature = "unix_socket_ancillary_data" , issue = "76915" ) ]
864- pub fn passcred ( & self ) -> io:: Result < bool > {
865- self . 0 . passcred ( )
866- }
867-
868810 /// Set the id of the socket for network filtering purpose
869811 ///
870812 #[ cfg_attr(
@@ -1038,3 +980,10 @@ impl From<OwnedFd> for UnixDatagram {
1038980 unsafe { Self :: from_raw_fd ( owned. into_raw_fd ( ) ) }
1039981 }
1040982}
983+
984+ impl AsInner < Socket > for UnixDatagram {
985+ #[ inline]
986+ fn as_inner ( & self ) -> & Socket {
987+ & self . 0
988+ }
989+ }
0 commit comments