Skip to content

Commit 2626fee

Browse files
committed
feat: bump MSRV + minor refactoring
1 parent 0db1efc commit 2626fee

29 files changed

+282
-150
lines changed

Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+87-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ members = [
1010
resolver = "2"
1111

1212
[workspace.package]
13-
version = "0.1.2"
13+
version = "0.1.3"
1414
edition = "2021"
15-
rust-version = "1.70"
15+
rust-version = "1.75"
1616
license = "MIT"
1717
description = "A flexible and lightweight messaging library for distributed systems"
1818
authors = ["Jonas Bostoen", "Nicolas Racchi"]
@@ -72,3 +72,88 @@ opt-level = 3
7272
[profile.debug-maxperf]
7373
inherits = "maxperf"
7474
debug = true
75+
76+
[workspace.metadata.docs.rs]
77+
all-features = true
78+
rustdoc-args = ["--cfg", "docsrs"]
79+
80+
[workspace.lints.rustdoc]
81+
all = "warn"
82+
83+
[workspace.lints.rust]
84+
missing_debug_implementations = "warn"
85+
missing_docs = "warn"
86+
rust-2018-idioms = { level = "deny", priority = -1 }
87+
unreachable-pub = "warn"
88+
unused-must-use = "deny"
89+
90+
[workspace.lints.clippy]
91+
# These are some of clippy's nursery (i.e., experimental) lints that we like.
92+
# By default, nursery lints are allowed. Some of the lints below have made good
93+
# suggestions which we fixed. The others didn't have any findings, so we can
94+
# assume they don't have that many false positives. Let's enable them to
95+
# prevent future problems.
96+
branches_sharing_code = "warn"
97+
clear_with_drain = "warn"
98+
derive_partial_eq_without_eq = "warn"
99+
doc_markdown = "warn"
100+
empty_line_after_doc_comments = "warn"
101+
empty_line_after_outer_attr = "warn"
102+
enum_glob_use = "warn"
103+
equatable_if_let = "warn"
104+
explicit_into_iter_loop = "warn"
105+
explicit_iter_loop = "warn"
106+
flat_map_option = "warn"
107+
imprecise_flops = "warn"
108+
iter_on_empty_collections = "warn"
109+
iter_on_single_items = "warn"
110+
iter_with_drain = "warn"
111+
iter_without_into_iter = "warn"
112+
large_stack_frames = "warn"
113+
manual_assert = "warn"
114+
manual_clamp = "warn"
115+
manual_string_new = "warn"
116+
match_same_arms = "warn"
117+
missing_const_for_fn = "warn"
118+
mutex_integer = "warn"
119+
naive_bytecount = "warn"
120+
needless_bitwise_bool = "warn"
121+
needless_continue = "warn"
122+
needless_pass_by_ref_mut = "warn"
123+
nonstandard_macro_braces = "warn"
124+
or_fun_call = "warn"
125+
path_buf_push_overwrite = "warn"
126+
read_zero_byte_vec = "warn"
127+
redundant_clone = "warn"
128+
single_char_pattern = "warn"
129+
string_lit_as_bytes = "warn"
130+
suboptimal_flops = "warn"
131+
suspicious_operation_groupings = "warn"
132+
trailing_empty_array = "warn"
133+
trait_duplication_in_bounds = "warn"
134+
transmute_undefined_repr = "warn"
135+
trivial_regex = "warn"
136+
tuple_array_conversions = "warn"
137+
type_repetition_in_bounds = "warn"
138+
uninhabited_references = "warn"
139+
unnecessary_struct_initialization = "warn"
140+
unused_peekable = "warn"
141+
unused_rounding = "warn"
142+
use_self = "warn"
143+
useless_let_if_seq = "warn"
144+
zero_sized_map_values = "warn"
145+
146+
# These are nursery lints which have findings. Allow them for now. Some are not
147+
# quite mature enough for use in our codebase and some we don't really want.
148+
# Explicitly listing should make it easier to fix in the future.
149+
as_ptr_cast_mut = "allow"
150+
cognitive_complexity = "allow"
151+
collection_is_never_read = "allow"
152+
debug_assert_with_mut_call = "allow"
153+
fallible_impl_from = "allow"
154+
future_not_send = "allow"
155+
needless_collect = "allow"
156+
non_send_fields_in_send_ty = "allow"
157+
redundant_pub_crate = "allow"
158+
significant_drop_in_scrutinee = "allow"
159+
significant_drop_tightening = "allow"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The 📖 [MSG-RS Book][book] contains detailed information on how to use the lib
5252

5353
## MSRV
5454

55-
The minimum supported Rust version is 1.70.
55+
The minimum supported Rust version is 1.75.
5656

5757
## Contributions & Bug Reports
5858

book/src/usage/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ Until then, we recommend using the git dependency as shown in the [Getting start
1515

1616
## What is the minimum supported Rust version (MSRV)?
1717

18-
MSG-RS currently supports Rust 1.70 or later.
18+
MSG-RS currently supports Rust 1.75 or later.

justfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default: check doc fmt
2+
3+
check:
4+
cargo check --workspace --all-features --all-targets
5+
6+
doc:
7+
cargo doc --workspace --all-features --no-deps --document-private-items
8+
9+
10+
fmt:
11+
cargo +nightly fmt --all -- --check
12+
13+
test:
14+
cargo nextest run --workspace --retries 3

msg-common/src/channel.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ impl<S: Send + 'static, R> Channel<S, R> {
5656
self.tx.send(msg).await
5757
}
5858

59-
/// Attempts to immediately send a message on this [`Sender`]
59+
/// Attempts to immediately send a message on this channel.
6060
///
61-
/// This method differs from [`send`] by returning immediately if the channel's
61+
/// This method differs from `send` by returning immediately if the channel's
6262
/// buffer is full or no receiver is waiting to acquire some data. Compared
63-
/// with [`send`], this function has two failure cases instead of one (one for
63+
/// with `send`, this function has two failure cases instead of one (one for
6464
/// disconnection, one for a full buffer).
6565
pub fn try_send(&mut self, msg: S) -> Result<(), TrySendError<S>> {
6666
if let Some(tx) = self.tx.get_ref() {
@@ -70,17 +70,17 @@ impl<S: Send + 'static, R> Channel<S, R> {
7070
}
7171
}
7272

73-
/// Receives the next value for this receiver.
73+
/// Receives the next value for this channel.
7474
///
7575
/// This method returns `None` if the channel has been closed and there are
7676
/// no remaining messages in the channel's buffer. This indicates that no
7777
/// further values can ever be received from this `Receiver`. The channel is
78-
/// closed when all senders have been dropped, or when [`close`] is called.
78+
/// closed when all senders have been dropped, or when `close` is called.
7979
///
8080
/// If there are no messages in the channel's buffer, but the channel has
8181
/// not yet been closed, this method will sleep until a message is sent or
82-
/// the channel is closed. Note that if [`close`] is called, but there are
83-
/// still outstanding [`Permits`] from before it was closed, the channel is
82+
/// the channel is closed. Note that if `close` is called, but there are
83+
/// still outstanding `Permits` from before it was closed, the channel is
8484
/// not considered closed by `recv` until the permits are released.
8585
pub async fn recv(&mut self) -> Option<R> {
8686
self.rx.recv().await
@@ -89,10 +89,10 @@ impl<S: Send + 'static, R> Channel<S, R> {
8989
/// Tries to receive the next value for this receiver.
9090
///
9191
/// This method returns the [`Empty`](TryRecvError::Empty) error if the channel is currently
92-
/// empty, but there are still outstanding [senders] or [permits].
92+
/// empty, but there are still outstanding senders or permits.
9393
///
9494
/// This method returns the [`Disconnected`](TryRecvError::Disconnected) error if the channel is
95-
/// currently empty, and there are no outstanding [senders] or [permits].
95+
/// currently empty, and there are no outstanding senders or permits.
9696
///
9797
/// Unlike the [`poll_recv`](Self::poll_recv) method, this method will never return an
9898
/// [`Empty`](TryRecvError::Empty) error spuriously.

msg-sim/src/dummynet.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ fn get_loopback_name() -> String {
271271
}
272272

273273
/// Assert that the given status is successful, otherwise return an error with the given message.
274-
/// The type of the error will be `io::ErrorKind::Other`.
274+
/// The type of the error will be [`io::ErrorKind::Other`].
275275
fn assert_status<E>(status: ExitStatus, error: E) -> io::Result<()>
276276
where
277277
E: Into<Box<dyn std::error::Error + Send + Sync>>,
278278
{
279279
if !status.success() {
280-
return Err(io::Error::new(io::ErrorKind::Other, error));
280+
return Err(io::Error::other(error));
281281
}
282282

283283
Ok(())

msg-socket/src/lib.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
33
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
44

5-
use msg_transport::Address;
5+
use bytes::Bytes;
66
use tokio::io::{AsyncRead, AsyncWrite};
77

8+
use msg_transport::Address;
9+
810
#[path = "pub/mod.rs"]
911
mod pubs;
12+
pub use pubs::{PubError, PubOptions, PubSocket};
13+
1014
mod rep;
15+
pub use rep::*;
16+
1117
mod req;
18+
pub use req::*;
19+
1220
mod sub;
21+
pub use sub::*;
1322

1423
mod connection;
1524
pub use connection::*;
1625

17-
use bytes::Bytes;
18-
pub use pubs::{PubError, PubOptions, PubSocket};
19-
pub use rep::*;
20-
pub use req::*;
21-
pub use sub::*;
26+
/// The default buffer size for a socket.
27+
const DEFAULT_BUFFER_SIZE: usize = 1024;
2228

29+
/// A request Identifier.
2330
pub struct RequestId(u32);
2431

2532
impl RequestId {
@@ -36,10 +43,12 @@ impl RequestId {
3643
}
3744
}
3845

46+
/// An interface for authenticating clients, given their ID.
3947
pub trait Authenticator: Send + Sync + Unpin + 'static {
4048
fn authenticate(&self, id: &Bytes) -> bool;
4149
}
4250

51+
/// The result of an authentication attempt.
4352
pub(crate) struct AuthResult<S: AsyncRead + AsyncWrite, A: Address> {
4453
id: Bytes,
4554
addr: A,

msg-socket/src/pub/driver.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ use crate::{AuthResult, Authenticator};
1717
use msg_transport::{Address, PeerAddress, Transport};
1818
use msg_wire::{auth, pubsub};
1919

20-
#[allow(clippy::type_complexity)]
20+
/// The driver for the publisher socket. This is responsible for accepting incoming connections,
21+
/// authenticating them, and spawning new [`SubscriberSession`]s for each connection.
2122
pub(crate) struct PubDriver<T: Transport<A>, A: Address> {
2223
/// Session ID counter.
2324
pub(super) id_counter: u32,

msg-socket/src/pub/mod.rs

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1-
use bytes::Bytes;
21
use std::io;
2+
3+
use bytes::Bytes;
34
use thiserror::Error;
45

56
mod driver;
6-
use msg_wire::{
7-
compression::{CompressionType, Compressor},
8-
pubsub,
9-
};
7+
108
mod session;
9+
1110
mod socket;
12-
mod stats;
13-
mod trie;
1411
pub use socket::*;
12+
13+
mod stats;
1514
use stats::SocketStats;
1615

16+
mod trie;
17+
18+
use msg_wire::{
19+
compression::{CompressionType, Compressor},
20+
pubsub,
21+
};
22+
23+
/// The default buffer size for the socket.
24+
const DEFAULT_BUFFER_SIZE: usize = 1024;
25+
1726
#[derive(Debug, Error)]
1827
pub enum PubError {
1928
#[error("IO error: {0:?}")]
@@ -28,10 +37,8 @@ pub enum PubError {
2837
TopicExists,
2938
#[error("Unknown topic: {0}")]
3039
UnknownTopic(String),
31-
#[error("Topic closed")]
32-
TopicClosed,
33-
#[error("Transport error: {0:?}")]
34-
Transport(#[from] Box<dyn std::error::Error + Send + Sync>),
40+
#[error("Could not connect to any valid endpoints")]
41+
NoValidEndpoints,
3542
}
3643

3744
#[derive(Debug)]
@@ -55,7 +62,7 @@ impl Default for PubOptions {
5562
fn default() -> Self {
5663
Self {
5764
max_clients: None,
58-
session_buffer_size: 1024,
65+
session_buffer_size: DEFAULT_BUFFER_SIZE,
5966
flush_interval: Some(std::time::Duration::from_micros(50)),
6067
backpressure_boundary: 8192,
6168
min_compress_size: 8192,

0 commit comments

Comments
 (0)