22
33#![ unstable( feature = "unix_socket_ancillary_data" , issue = "76915" ) ]
44
5+ use crate :: ffi:: CStr ;
56use crate :: io;
67use crate :: os:: unix:: net;
78use crate :: sealed:: Sealed ;
@@ -40,6 +41,15 @@ pub trait UnixSocketExt: Sealed {
4041 /// ```
4142 #[ unstable( feature = "unix_socket_ancillary_data" , issue = "76915" ) ]
4243 fn set_local_creds_persistent ( & self , local_creds_persistent : bool ) -> io:: Result < ( ) > ;
44+
45+ /// Get a filter name if one had been set previously on the socket.
46+ #[ unstable( feature = "acceptfilter" , issue = "121891" ) ]
47+ fn acceptfilter ( & self ) -> io:: Result < & CStr > ;
48+
49+ /// Set or disable a filter on the socket to filter incoming connections
50+ /// to defer it before accept(2)
51+ #[ unstable( feature = "acceptfilter" , issue = "121891" ) ]
52+ fn set_acceptfilter ( & self , name : & CStr ) -> io:: Result < ( ) > ;
4353}
4454
4555#[ unstable( feature = "unix_socket_ancillary_data" , issue = "76915" ) ]
@@ -51,6 +61,14 @@ impl UnixSocketExt for net::UnixDatagram {
5161 fn set_local_creds_persistent ( & self , local_creds_persistent : bool ) -> io:: Result < ( ) > {
5262 self . as_inner ( ) . set_local_creds_persistent ( local_creds_persistent)
5363 }
64+
65+ fn acceptfilter ( & self ) -> io:: Result < & CStr > {
66+ self . as_inner ( ) . acceptfilter ( )
67+ }
68+
69+ fn set_acceptfilter ( & self , name : & CStr ) -> io:: Result < ( ) > {
70+ self . as_inner ( ) . set_acceptfilter ( name)
71+ }
5472}
5573
5674#[ unstable( feature = "unix_socket_ancillary_data" , issue = "76915" ) ]
@@ -62,4 +80,12 @@ impl UnixSocketExt for net::UnixStream {
6280 fn set_local_creds_persistent ( & self , local_creds_persistent : bool ) -> io:: Result < ( ) > {
6381 self . as_inner ( ) . set_local_creds_persistent ( local_creds_persistent)
6482 }
83+
84+ fn acceptfilter ( & self ) -> io:: Result < & CStr > {
85+ self . as_inner ( ) . acceptfilter ( )
86+ }
87+
88+ fn set_acceptfilter ( & self , name : & CStr ) -> io:: Result < ( ) > {
89+ self . as_inner ( ) . set_acceptfilter ( name)
90+ }
6591}
0 commit comments