Skip to content

Commit

Permalink
update from tracking issue
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Mar 11, 2024
1 parent 44102a8 commit 5a503e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions library/std/src/os/unix/net/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,16 +875,27 @@ impl UnixDatagram {
/// Set a filter name on the socket to filter incoming connections to defer it before accept(2)
///
/// an empty name allows to remove this connection's filter
#[cfg_attr(any(target_os = "freebsd", target_os = "netbsd"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "freebsd", target_os = "netbsd")), doc = "```ignore")]
/// #![feature(unix_set_mark)]
/// use std::os::unix::net::UnixDatagram;
///
/// fn main() -> std::io::Result<()> {
/// let sock = UnixDatagram::unbound()?;
/// sock.set_acceptfilter(&c"data")?;
/// Ok(())
/// }
/// ```
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
#[unstable(feature = "acceptfilter", issue = "none")]
#[unstable(feature = "acceptfilter", issue = "121891")]
pub fn set_acceptfilter(&self, name: &CStr) -> io::Result<()> {
self.0.set_acceptfilter(name)
}

/// Get a filter name if one had been set previously on the socket.
///
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
#[unstable(feature = "acceptfilter", issue = "none")]
#[unstable(feature = "acceptfilter", issue = "121891")]
pub fn acceptfilter(&self) -> io::Result<&CStr> {
self.0.acceptfilter()
}
Expand Down
15 changes: 13 additions & 2 deletions library/std/src/os/unix/net/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,16 +452,27 @@ impl UnixStream {
/// Set a filter name on the socket to filter incoming connections to defer it before accept(2)
///
/// an empty name allows to remove this connection's filter
#[cfg_attr(any(target_os = "freebsd", target_os = "netbsd"), doc = "```no_run")]
#[cfg_attr(not(any(target_os = "freebsd", target_os = "netbsd")), doc = "```ignore")]
/// #![feature(unix_set_mark)]
/// use std::os::unix::net::UnixStream;
///
/// fn main() -> std::io::Result<()> {
/// let sock = UnixStream::connect("/tmp/sock")?;
/// sock.set_acceptfilter(&c"http")?;
/// Ok(())
/// }
/// ```
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
#[unstable(feature = "acceptfilter", issue = "none")]
#[unstable(feature = "acceptfilter", issue = "121891")]
pub fn set_acceptfilter(&self, name: &CStr) -> io::Result<()> {
self.0.set_acceptfilter(name)
}

/// Get a filter name if one had been set previously on the socket.
///
#[cfg(any(doc, target_os = "netbsd", target_os = "freebsd"))]
#[unstable(feature = "acceptfilter", issue = "none")]
#[unstable(feature = "acceptfilter", issue = "121891")]
pub fn acceptfilter(&self) -> io::Result<&CStr> {
self.0.acceptfilter()
}
Expand Down

0 comments on commit 5a503e7

Please sign in to comment.