Files
LLeMbas-TTY/async_ossl/src/lib.rs
T
Rebecca Turner bf9a2aeeba Fix mismatched_lifetime_syntaxes warnings
Fixes a bunch of warnings like this:

```
warning: hiding a lifetime that's elided elsewhere is confusing
   --> window/src/os/macos/window.rs:670:23
    |
670 |     fn display_handle(&self) -> Result<DisplayHandle, HandleError> {
    |                       ^^^^^            ------------- the same lifetime is hidden here
    |                       |
    |                       the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
670 |     fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError> {
    |                                                     ++++
```

This lint was added in Rust 1.89: https://github.com/rust-lang/rust/issues/141787
2025-09-09 07:05:12 -07:00

66 lines
1.5 KiB
Rust

use openssl::ssl::SslStream;
use std::net::TcpStream;
#[cfg(unix)]
pub trait AsRawDesc: std::os::unix::io::AsRawFd {}
#[cfg(windows)]
pub trait AsRawDesc: std::os::windows::io::AsRawSocket {}
#[derive(Debug)]
pub struct AsyncSslStream {
s: SslStream<TcpStream>,
}
unsafe impl async_io::IoSafe for AsyncSslStream {}
impl AsyncSslStream {
pub fn new(s: SslStream<TcpStream>) -> Self {
Self { s }
}
}
#[cfg(unix)]
impl std::os::fd::AsFd for AsyncSslStream {
fn as_fd(&self) -> std::os::fd::BorrowedFd<'_> {
self.s.get_ref().as_fd()
}
}
#[cfg(unix)]
impl std::os::unix::io::AsRawFd for AsyncSslStream {
fn as_raw_fd(&self) -> std::os::unix::io::RawFd {
self.s.get_ref().as_raw_fd()
}
}
#[cfg(windows)]
impl std::os::windows::io::AsRawSocket for AsyncSslStream {
fn as_raw_socket(&self) -> std::os::windows::io::RawSocket {
self.s.get_ref().as_raw_socket()
}
}
#[cfg(windows)]
impl std::os::windows::io::AsSocket for AsyncSslStream {
fn as_socket(&self) -> std::os::windows::io::BorrowedSocket {
self.s.get_ref().as_socket()
}
}
impl AsRawDesc for AsyncSslStream {}
impl std::io::Read for AsyncSslStream {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
self.s.read(buf)
}
}
impl std::io::Write for AsyncSslStream {
fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
self.s.write(buf)
}
fn flush(&mut self) -> Result<(), std::io::Error> {
self.s.flush()
}
}