From b895773b0828e815dbd2caf715e60ce13a8261e7 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Thu, 11 Jul 2024 08:34:10 +0200 Subject: [PATCH 1/2] fix deprecated and warnings --- examples/throughput/main.rs | 4 ++-- src/adapters/framed_tcp.rs | 9 ++++----- src/adapters/tcp.rs | 13 ++++++------- src/adapters/ws.rs | 8 +++++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/throughput/main.rs b/examples/throughput/main.rs index 9d19022c..abc9d805 100644 --- a/examples/throughput/main.rs +++ b/examples/throughput/main.rs @@ -234,7 +234,7 @@ fn throughput_native_ws(packet_size: usize) { let (mut sender, _) = ws_connect(Url::parse(&url_addr).unwrap()).unwrap(); let start_time = Instant::now(); while total_sent < EXPECTED_BYTES { - sender.write_message(Message::Binary(message.clone())).unwrap(); + sender.send(Message::Binary(message.clone())).unwrap(); total_sent += message.len(); } start_time @@ -245,7 +245,7 @@ fn throughput_native_ws(packet_size: usize) { let mut receiver = ws_accept(listener.accept().unwrap().0).unwrap(); let mut total_received = 0; while total_received < EXPECTED_BYTES { - total_received += receiver.read_message().unwrap().len(); + total_received += receiver.read().unwrap().len(); } let end_time = Instant::now(); diff --git a/src/adapters/framed_tcp.rs b/src/adapters/framed_tcp.rs index b0637103..55f0aa3c 100644 --- a/src/adapters/framed_tcp.rs +++ b/src/adapters/framed_tcp.rs @@ -14,7 +14,6 @@ use socket2::{Socket}; use std::net::{SocketAddr}; use std::io::{self, ErrorKind, Read, Write}; -use std::ops::{Deref}; use std::cell::{RefCell}; use std::mem::{forget, MaybeUninit}; #[cfg(target_os = "windows")] @@ -103,8 +102,8 @@ impl Remote for RemoteResource { let mut input_buffer = unsafe { buffer.assume_init() }; // Avoid to initialize the array loop { - let stream = &self.stream; - match stream.deref().read(&mut input_buffer) { + let mut stream = &self.stream; + match stream.read(&mut input_buffer) { Ok(0) => break ReadStatus::Disconnected, Ok(size) => { let data = &input_buffer[..size]; @@ -140,8 +139,8 @@ impl Remote for RemoteResource { false => &data[total_bytes_sent - encoded_size.len()..], }; - let stream = &self.stream; - match stream.deref().write(data_to_send) { + let mut stream = &self.stream; + match stream.write(data_to_send) { Ok(bytes_sent) => { total_bytes_sent += bytes_sent; if total_bytes_sent == total_bytes { diff --git a/src/adapters/tcp.rs b/src/adapters/tcp.rs index d2693627..58029b0c 100644 --- a/src/adapters/tcp.rs +++ b/src/adapters/tcp.rs @@ -17,7 +17,6 @@ use std::ffi::{CString}; use std::io::{self, ErrorKind, Read, Write}; #[cfg(target_os = "macos")] use std::num::NonZeroU32; -use std::ops::{Deref}; use std::mem::{forget, MaybeUninit}; use std::os::raw::c_int; #[cfg(target_os = "windows")] @@ -133,7 +132,7 @@ impl Remote for RemoteResource { #[cfg(target_os = "macos")] match NonZeroU32::new(unsafe { libc::if_nametoindex(device.as_ptr()) }) { - Some(index) => socket.bind_device_by_index(Some(index))?, + Some(index) => socket.bind_device_by_index_v4(Some(index))?, None => { return Err(io::Error::new( ErrorKind::NotFound, @@ -165,8 +164,8 @@ impl Remote for RemoteResource { let mut input_buffer = unsafe { buffer.assume_init() }; // Avoid to initialize the array loop { - let stream = &self.stream; - match stream.deref().read(&mut input_buffer) { + let mut stream = &self.stream; + match stream.read(&mut input_buffer) { Ok(0) => break ReadStatus::Disconnected, Ok(size) => process_data(&input_buffer[..size]), Err(ref err) if err.kind() == ErrorKind::Interrupted => continue, @@ -191,8 +190,8 @@ impl Remote for RemoteResource { // this only occurs in the case when the receiver is full because reads slower that it sends. let mut total_bytes_sent = 0; loop { - let stream = &self.stream; - match stream.deref().write(&data[total_bytes_sent..]) { + let mut stream = &self.stream; + match stream.write(&data[total_bytes_sent..]) { Ok(bytes_sent) => { total_bytes_sent += bytes_sent; if total_bytes_sent == data.len() { @@ -289,7 +288,7 @@ impl Local for LocalResource { #[cfg(target_os = "macos")] match NonZeroU32::new(unsafe { libc::if_nametoindex(device.as_ptr()) }) { - Some(index) => socket.bind_device_by_index(Some(index))?, + Some(index) => socket.bind_device_by_index_v4(Some(index))?, None => { return Err(io::Error::new( ErrorKind::NotFound, diff --git a/src/adapters/ws.rs b/src/adapters/ws.rs index a6b3a316..80f5fa09 100644 --- a/src/adapters/ws.rs +++ b/src/adapters/ws.rs @@ -118,8 +118,9 @@ impl Remote for RemoteResource { // "emulates" full duplex for the websocket case locking here and not outside the loop. let mut state = self.state.lock().expect(OTHER_THREAD_ERR); let deref_state = state.deref_mut(); + match deref_state { - RemoteState::WebSocket(web_socket) => match web_socket.read_message() { + RemoteState::WebSocket(web_socket) => match web_socket.read() { Ok(message) => match message { Message::Binary(data) => { // As an optimization. @@ -162,12 +163,13 @@ impl Remote for RemoteResource { match deref_state { RemoteState::WebSocket(web_socket) => { let message = Message::Binary(data.to_vec()); - let mut result = web_socket.write_message(message); + + let mut result = web_socket.send(message); loop { match result { Ok(_) => break SendStatus::Sent, Err(Error::Io(ref err)) if err.kind() == ErrorKind::WouldBlock => { - result = web_socket.write_pending(); + result = web_socket.flush(); } Err(Error::Capacity(_)) => break SendStatus::MaxPacketSizeExceeded, Err(err) => { From 45abd422acd47f56dd2eb54de862a0850f644ed2 Mon Sep 17 00:00:00 2001 From: lemunozm Date: Thu, 11 Jul 2024 08:34:24 +0200 Subject: [PATCH 2/2] prepare release version --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e890487..6898ecae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Release 0.18.2 +- Fix tugstenite dependency adding url feature + ## Release 0.18.1 - Update tugstenite version. - Update minor versions of internal dependencies diff --git a/Cargo.lock b/Cargo.lock index 8378e21d..170c9d4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -502,7 +502,7 @@ dependencies = [ [[package]] name = "message-io" -version = "0.18.1" +version = "0.18.2" dependencies = [ "bincode", "chrono", diff --git a/Cargo.toml b/Cargo.toml index cec884d8..3051eb60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "message-io" -version = "0.18.1" +version = "0.18.2" authors = ["lemunozm "] edition = "2018" readme = "README.md"