Skip to content

Commit

Permalink
tuning embed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wlqm committed Apr 27, 2024
1 parent d9a2327 commit f522d8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ruc"
version = "5.1.5"
version = "5.1.8"
authors = ["hui.fan@mail.ru"]
edition = "2021"
description = "Rust Util Collections"
Expand All @@ -25,7 +25,7 @@ rand = { version = "0.8", optional = true }
base64 = {version = "0.21.2", optional = true }
hex = {version = "0.4.3", optional = true }

nix = { version = "0.28", optional = true }
nix = { version = "0.28", features = ["socket"], optional = true }
time = { version = "0.3", features = ["formatting"] }
ssh2 = { version = "0.9.4", optional = true }

Expand Down
7 changes: 1 addition & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
//!
//! # RUC
//!
//! Useful util-collections for Rust.
//!

#![doc = include_str!("../README.md")]
#![deny(warnings)]
#![deny(missing_docs)]

Expand Down
18 changes: 9 additions & 9 deletions src/uau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ use nix::{
},
unistd::close,
};
use std::os::unix::io::RawFd;
use std::os::{fd::OwnedFd, unix::io::AsRawFd};

/// Wrap raw data
pub struct UauSock {
fd: RawFd,
fd: OwnedFd,
sa: UnixAddr,
}

impl Drop for UauSock {
fn drop(&mut self) {
info_omit!(close(self.fd));
info_omit!(close(self.fd.as_raw_fd()));
}
}

Expand All @@ -58,19 +58,19 @@ impl UauSock {
)
.c(d!())?;

setsockopt(fd, sockopt::ReuseAddr, &true).c(d!())?;
setsockopt(fd, sockopt::ReusePort, &true).c(d!())?;
setsockopt(&fd, sockopt::ReuseAddr, &true).c(d!())?;
setsockopt(&fd, sockopt::ReusePort, &true).c(d!())?;
if let Some(to) = recv_timeout {
setsockopt(
fd,
&fd,
sockopt::ReceiveTimeout,
&TimeVal::milliseconds(to),
)
.c(d!())?;
}

let sa = UnixAddr::new_abstract(addr).c(d!())?;
bind(fd, &sa).c(d!())?;
bind(fd.as_raw_fd(), &sa).c(d!())?;

Ok(UauSock { fd, sa })
}
Expand All @@ -91,7 +91,7 @@ impl UauSock {
/// Send msg to another peer
#[inline(always)]
pub fn send(&self, msg: &[u8], peeraddr: &UnixAddr) -> Result<()> {
sendto(self.fd, msg, peeraddr, MsgFlags::empty())
sendto(self.fd.as_raw_fd(), msg, peeraddr, MsgFlags::empty())
.c(d!())
.map(|_| ())
}
Expand Down Expand Up @@ -174,7 +174,7 @@ impl UauSock {
/// Receive msg with a given buffer
#[inline(always)]
pub fn recv(&self, buf: &mut [u8]) -> Result<(usize, UnixAddr)> {
match recvfrom::<UnixAddr>(self.fd, buf) {
match recvfrom::<UnixAddr>(self.fd.as_raw_fd(), buf) {
Ok((n, Some(peer))) => Ok((n, peer)),
Err(e) => Err(eg!(e)),
_ => Err(eg!("peer address is unknown")),
Expand Down

0 comments on commit f522d8e

Please sign in to comment.