Skip to content

Commit

Permalink
Merge pull request #83 from chainbound/chore/maintenance
Browse files Browse the repository at this point in the history
feat: bump MSRV + minor refactoring
  • Loading branch information
mempirate authored Oct 14, 2024
2 parents 0db1efc + ed01279 commit 26492f3
Show file tree
Hide file tree
Showing 30 changed files with 297 additions and 171 deletions.
32 changes: 12 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ jobs:
timeout-minutes: 20
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: cargo test
Expand All @@ -28,15 +26,13 @@ jobs:
timeout-minutes: 20
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
profile: minimal
components: rustfmt, clippy
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: cargo fmt
Expand All @@ -50,14 +46,12 @@ jobs:
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: build
Expand All @@ -71,14 +65,12 @@ jobs:
continue-on-error: true
steps:
- name: Checkout sources
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
profile: minimal
override: true
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: doclint
Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 87 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ members = [
resolver = "2"

[workspace.package]
version = "0.1.2"
version = "0.1.3"
edition = "2021"
rust-version = "1.70"
rust-version = "1.75"
license = "MIT"
description = "A flexible and lightweight messaging library for distributed systems"
authors = ["Jonas Bostoen", "Nicolas Racchi"]
Expand Down Expand Up @@ -72,3 +72,88 @@ opt-level = 3
[profile.debug-maxperf]
inherits = "maxperf"
debug = true

[workspace.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace.lints.rustdoc]
all = "warn"

[workspace.lints.rust]
missing_debug_implementations = "warn"
missing_docs = "warn"
rust-2018-idioms = { level = "deny", priority = -1 }
unreachable-pub = "warn"
unused-must-use = "deny"

[workspace.lints.clippy]
# These are some of clippy's nursery (i.e., experimental) lints that we like.
# By default, nursery lints are allowed. Some of the lints below have made good
# suggestions which we fixed. The others didn't have any findings, so we can
# assume they don't have that many false positives. Let's enable them to
# prevent future problems.
branches_sharing_code = "warn"
clear_with_drain = "warn"
derive_partial_eq_without_eq = "warn"
doc_markdown = "warn"
empty_line_after_doc_comments = "warn"
empty_line_after_outer_attr = "warn"
enum_glob_use = "warn"
equatable_if_let = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
flat_map_option = "warn"
imprecise_flops = "warn"
iter_on_empty_collections = "warn"
iter_on_single_items = "warn"
iter_with_drain = "warn"
iter_without_into_iter = "warn"
large_stack_frames = "warn"
manual_assert = "warn"
manual_clamp = "warn"
manual_string_new = "warn"
match_same_arms = "warn"
missing_const_for_fn = "warn"
mutex_integer = "warn"
naive_bytecount = "warn"
needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_pass_by_ref_mut = "warn"
nonstandard_macro_braces = "warn"
or_fun_call = "warn"
path_buf_push_overwrite = "warn"
read_zero_byte_vec = "warn"
redundant_clone = "warn"
single_char_pattern = "warn"
string_lit_as_bytes = "warn"
suboptimal_flops = "warn"
suspicious_operation_groupings = "warn"
trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
transmute_undefined_repr = "warn"
trivial_regex = "warn"
tuple_array_conversions = "warn"
type_repetition_in_bounds = "warn"
uninhabited_references = "warn"
unnecessary_struct_initialization = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
use_self = "warn"
useless_let_if_seq = "warn"
zero_sized_map_values = "warn"

# These are nursery lints which have findings. Allow them for now. Some are not
# quite mature enough for use in our codebase and some we don't really want.
# Explicitly listing should make it easier to fix in the future.
as_ptr_cast_mut = "allow"
cognitive_complexity = "allow"
collection_is_never_read = "allow"
debug_assert_with_mut_call = "allow"
fallible_impl_from = "allow"
future_not_send = "allow"
needless_collect = "allow"
non_send_fields_in_send_ty = "allow"
redundant_pub_crate = "allow"
significant_drop_in_scrutinee = "allow"
significant_drop_tightening = "allow"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The 📖 [MSG-RS Book][book] contains detailed information on how to use the lib

## MSRV

The minimum supported Rust version is 1.70.
The minimum supported Rust version is 1.75.

## Contributions & Bug Reports

Expand Down
2 changes: 1 addition & 1 deletion book/src/usage/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ Until then, we recommend using the git dependency as shown in the [Getting start

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

MSG-RS currently supports Rust 1.70 or later.
MSG-RS currently supports Rust 1.75 or later.
16 changes: 16 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
default: check doc fmt clippy

check:
cargo check --workspace --all-features --all-targets

doc:
cargo doc --workspace --all-features --no-deps --document-private-items

clippy:
cargo +nightly clippy --all --all-features -- -D warnings

fmt:
cargo +nightly fmt --all -- --check

test:
cargo nextest run --workspace --retries 3
18 changes: 9 additions & 9 deletions msg-common/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ impl<S: Send + 'static, R> Channel<S, R> {
self.tx.send(msg).await
}

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

/// Receives the next value for this receiver.
/// Receives the next value for this channel.
///
/// This method returns `None` if the channel has been closed and there are
/// no remaining messages in the channel's buffer. This indicates that no
/// further values can ever be received from this `Receiver`. The channel is
/// closed when all senders have been dropped, or when [`close`] is called.
/// closed when all senders have been dropped, or when `close` is called.
///
/// If there are no messages in the channel's buffer, but the channel has
/// not yet been closed, this method will sleep until a message is sent or
/// the channel is closed. Note that if [`close`] is called, but there are
/// still outstanding [`Permits`] from before it was closed, the channel is
/// the channel is closed. Note that if `close` is called, but there are
/// still outstanding `Permits` from before it was closed, the channel is
/// not considered closed by `recv` until the permits are released.
pub async fn recv(&mut self) -> Option<R> {
self.rx.recv().await
Expand All @@ -89,10 +89,10 @@ impl<S: Send + 'static, R> Channel<S, R> {
/// Tries to receive the next value for this receiver.
///
/// This method returns the [`Empty`](TryRecvError::Empty) error if the channel is currently
/// empty, but there are still outstanding [senders] or [permits].
/// empty, but there are still outstanding senders or permits.
///
/// This method returns the [`Disconnected`](TryRecvError::Disconnected) error if the channel is
/// currently empty, and there are no outstanding [senders] or [permits].
/// currently empty, and there are no outstanding senders or permits.
///
/// Unlike the [`poll_recv`](Self::poll_recv) method, this method will never return an
/// [`Empty`](TryRecvError::Empty) error spuriously.
Expand Down
4 changes: 2 additions & 2 deletions msg-sim/src/dummynet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,13 @@ fn get_loopback_name() -> String {
}

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

Ok(())
Expand Down
21 changes: 15 additions & 6 deletions msg-socket/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,31 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use msg_transport::Address;
use bytes::Bytes;
use tokio::io::{AsyncRead, AsyncWrite};

use msg_transport::Address;

#[path = "pub/mod.rs"]
mod pubs;
pub use pubs::{PubError, PubOptions, PubSocket};

mod rep;
pub use rep::*;

mod req;
pub use req::*;

mod sub;
pub use sub::*;

mod connection;
pub use connection::*;

use bytes::Bytes;
pub use pubs::{PubError, PubOptions, PubSocket};
pub use rep::*;
pub use req::*;
pub use sub::*;
/// The default buffer size for a socket.
const DEFAULT_BUFFER_SIZE: usize = 1024;

/// A request Identifier.
pub struct RequestId(u32);

impl RequestId {
Expand All @@ -36,10 +43,12 @@ impl RequestId {
}
}

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

/// The result of an authentication attempt.
pub(crate) struct AuthResult<S: AsyncRead + AsyncWrite, A: Address> {
id: Bytes,
addr: A,
Expand Down
3 changes: 2 additions & 1 deletion msg-socket/src/pub/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use crate::{AuthResult, Authenticator};
use msg_transport::{Address, PeerAddress, Transport};
use msg_wire::{auth, pubsub};

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

0 comments on commit 26492f3

Please sign in to comment.