Skip to content

Commit

Permalink
chore: bump to 0.6.1 (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
driftluo committed Jun 13, 2024
1 parent 86e442a commit cabee62
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## tentacle 0.6.1

### Features
- impl `AsFd` `AsSocket` for `TcpSocket`

## secio 0.6.2 tentacle 0.6.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion tentacle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tentacle"
version = "0.6.0"
version = "0.6.1"
license = "MIT"
description = "Minimal implementation for a multiplexed p2p network framework."
authors = ["piaoliu <[email protected]>", "Nervos Core Dev <[email protected]>"]
Expand Down
25 changes: 22 additions & 3 deletions tentacle/src/service/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ use crate::{
yamux::config::Config as YamuxConfig,
ProtocolId, SessionId,
};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
use std::os::windows::io::{
AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, RawSocket,
};
#[cfg(unix)]
use std::os::{
fd::AsFd,
unix::io::{AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd},
};
use std::{sync::Arc, time::Duration};
#[cfg(feature = "tls")]
use tokio_rustls::rustls::{ClientConfig, ServerConfig};
Expand Down Expand Up @@ -144,6 +149,13 @@ impl IntoRawFd for TcpSocket {
}
}

#[cfg(unix)]
impl AsFd for TcpSocket {
fn as_fd(&self) -> BorrowedFd<'_> {
self.inner.as_fd()
}
}

#[cfg(windows)]
impl IntoRawSocket for TcpSocket {
fn into_raw_socket(self) -> RawSocket {
Expand All @@ -167,6 +179,13 @@ impl FromRawSocket for TcpSocket {
}
}

#[cfg(windows)]
impl AsSocket for TcpSocket {
fn as_socket(&self) -> BorrowedSocket<'_> {
unsafe { BorrowedSocket::borrow_raw(self.as_raw_socket()) }
}
}

/// tls config wrap for server setup
#[derive(Clone, Default)]
#[cfg(feature = "tls")]
Expand Down

0 comments on commit cabee62

Please sign in to comment.