mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
rustfmt
This commit is contained in:
parent
63ebfc2c55
commit
1c2143193f
@ -285,7 +285,11 @@ impl SocketAddr {
|
||||
));
|
||||
}
|
||||
|
||||
ptr::copy_nonoverlapping(namespace.as_ptr(), addr.sun_path.as_mut_ptr().offset(1) as *mut u8, namespace.len());
|
||||
ptr::copy_nonoverlapping(
|
||||
namespace.as_ptr(),
|
||||
addr.sun_path.as_mut_ptr().offset(1) as *mut u8,
|
||||
namespace.len(),
|
||||
);
|
||||
let len = (sun_path_offset(&addr) + 1 + namespace.len()) as libc::socklen_t;
|
||||
SocketAddr::from_parts(addr, len)
|
||||
}
|
||||
|
@ -136,7 +136,11 @@ impl UnixDatagram {
|
||||
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixDatagram> {
|
||||
unsafe {
|
||||
let socket = UnixDatagram::unbound()?;
|
||||
cvt(libc::bind(*socket.0.as_inner(), &socket_addr.addr as *const _ as *const _, socket_addr.len as _))?;
|
||||
cvt(libc::bind(
|
||||
*socket.0.as_inner(),
|
||||
&socket_addr.addr as *const _ as *const _,
|
||||
socket_addr.len as _,
|
||||
))?;
|
||||
Ok(socket)
|
||||
}
|
||||
}
|
||||
@ -245,7 +249,11 @@ impl UnixDatagram {
|
||||
#[unstable(feature = "unix_socket_abstract", issue = "42048")]
|
||||
pub fn connect_addr(&self, socket_addr: &SocketAddr) -> io::Result<()> {
|
||||
unsafe {
|
||||
cvt(libc::connect(*self.0.as_inner(), &socket_addr.addr as *const _ as *const _, socket_addr.len))?;
|
||||
cvt(libc::connect(
|
||||
*self.0.as_inner(),
|
||||
&socket_addr.addr as *const _ as *const _,
|
||||
socket_addr.len,
|
||||
))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -107,14 +107,17 @@ impl UnixListener {
|
||||
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixListener> {
|
||||
unsafe {
|
||||
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
||||
cvt(libc::bind(*inner.as_inner(), &socket_addr.addr as *const _ as *const _, socket_addr.len as _))?;
|
||||
cvt(libc::bind(
|
||||
*inner.as_inner(),
|
||||
&socket_addr.addr as *const _ as *const _,
|
||||
socket_addr.len as _,
|
||||
))?;
|
||||
cvt(libc::listen(*inner.as_inner(), 128))?;
|
||||
|
||||
Ok(UnixListener(inner))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Accepts a new incoming connection to this listener.
|
||||
///
|
||||
/// This function will block the calling thread until a new Unix connection
|
||||
|
@ -132,7 +132,11 @@ impl UnixStream {
|
||||
pub fn connect_addr(socket_addr: &SocketAddr) -> io::Result<UnixStream> {
|
||||
unsafe {
|
||||
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
||||
cvt(libc::connect(*inner.as_inner(), &socket_addr.addr as *const _ as *const _, socket_addr.len))?;
|
||||
cvt(libc::connect(
|
||||
*inner.as_inner(),
|
||||
&socket_addr.addr as *const _ as *const _,
|
||||
socket_addr.len,
|
||||
))?;
|
||||
Ok(UnixStream(inner))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user