Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/metadata_routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl FrameMetadata for HeaderSerializer {
struct Ping;

#[derive(bincode::Decode, bincode::Encode)]
#[expect(
#[allow(
dead_code,
reason = "placeholder for demonstration of metadata routing"
)]
Expand Down
5 changes: 4 additions & 1 deletion examples/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ const PING_ID: u32 = 1;
///
/// The middleware chain generates the actual response, so this
/// handler intentionally performs no work.
#[allow(clippy::unused_async)]
#[allow(
clippy::unused_async,
reason = "handler intentionally performs no work"
)]
async fn ping_handler() {}

struct PongMiddleware;
Expand Down
72 changes: 46 additions & 26 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
crate::metrics::dec_connections();
}
}

Check warning on line 40 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs
/// Return the current number of active connections.
#[must_use]
pub fn active_connection_count() -> u64 { ACTIVE_CONNECTIONS.load(Ordering::Relaxed) }
pub fn active_connection_count() -> u64 {
ACTIVE_CONNECTIONS.load(Ordering::Relaxed)
}

use crate::{
fairness::Fairness,
fairness::FairnessTracker,
hooks::{ConnectionContext, ProtocolHooks},
push::{FrameLike, PushHandle, PushQueues},
response::{FrameStream, WireframeError},
Expand Down Expand Up @@ -108,7 +110,7 @@
counter: Option<ActiveConnection>,
hooks: ProtocolHooks<F, E>,
ctx: ConnectionContext,
fairness: Fairness,
fairness: FairnessTracker,
connection_id: Option<ConnectionId>,
peer_addr: Option<SocketAddr>,
}
Expand Down Expand Up @@ -166,7 +168,7 @@
counter: Some(counter),
hooks,
ctx,
fairness: Fairness::new(FairnessConfig::default()),
fairness: FairnessTracker::new(FairnessConfig::default()),
connection_id: None,
peer_addr: None,
};
Expand All @@ -179,17 +181,23 @@
);
actor.hooks.on_connection_setup(handle, &mut actor.ctx);
actor
}

Check warning on line 184 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs

/// Replace the fairness configuration.
pub fn set_fairness(&mut self, fairness: FairnessConfig) { self.fairness.set_config(fairness); }
pub fn set_fairness(&mut self, fairness: FairnessConfig) {
self.fairness.set_config(fairness);
}
Comment on lines +187 to +189
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix multiple single-line function formatting issues.

The pipeline indicates these functions should all be formatted on a single line.

Apply these diffs to fix the formatting:

-    pub fn set_fairness(&mut self, fairness: FairnessConfig) {
-        self.fairness.set_config(fairness);
-    }
+    pub fn set_fairness(&mut self, fairness: FairnessConfig) { self.fairness.set_config(fairness); }

-    pub fn set_response(&mut self, stream: Option<FrameStream<F, E>>) {
-        self.response = stream;
-    }
+    pub fn set_response(&mut self, stream: Option<FrameStream<F, E>>) { self.response = stream; }

-    pub fn shutdown_token(&self) -> CancellationToken {
-        self.shutdown.clone()
-    }
+    pub fn shutdown_token(&self) -> CancellationToken { self.shutdown.clone() }

-    fn after_low(&mut self) {
-        self.fairness.after_low();
-    }
+    fn after_low(&mut self) { self.fairness.after_low(); }

-    async fn wait_shutdown(token: CancellationToken) {
-        token.cancelled_owned().await;
-    }
+    async fn wait_shutdown(token: CancellationToken) { token.cancelled_owned().await; }

-    async fn recv_push(rx: &mut mpsc::Receiver<F>) -> Option<F> {
-        rx.recv().await
-    }
+    async fn recv_push(rx: &mut mpsc::Receiver<F>) -> Option<F> { rx.recv().await }

-    fn is_active(&self) -> bool {
-        matches!(self.run_state, RunState::Active)
-    }
+    fn is_active(&self) -> bool { matches!(self.run_state, RunState::Active) }

-    fn is_shutting_down(&self) -> bool {
-        matches!(self.run_state, RunState::ShuttingDown)
-    }
+    fn is_shutting_down(&self) -> bool { matches!(self.run_state, RunState::ShuttingDown) }

-    fn is_done(&self) -> bool {
-        matches!(self.run_state, RunState::Finished)
-    }
+    fn is_done(&self) -> bool { matches!(self.run_state, RunState::Finished) }

Also applies to: 192-194, 198-200, 423-425, 462-464, 468-470, 553-555, 557-559, 562-564

🧰 Tools
🪛 GitHub Actions: CI

[warning] 188-188: Prettier-like formatting warning: function set_response should be formatted in a single line.

🤖 Prompt for AI Agents
In src/connection.rs at lines 187-189 and also at lines 192-194, 198-200,
423-425, 462-464, 468-470, 553-555, 557-559, and 562-564, multiple single-line
functions are currently formatted as multi-line blocks. Refactor each of these
functions to be single-line functions by placing the entire function definition,
including the signature and body, on one line to comply with the pipeline
formatting requirements.


/// Set or replace the current streaming response.
pub fn set_response(&mut self, stream: Option<FrameStream<F, E>>) { self.response = stream; }
pub fn set_response(&mut self, stream: Option<FrameStream<F, E>>) {
self.response = stream;
}

/// Get a clone of the shutdown token used by the actor.
#[must_use]
pub fn shutdown_token(&self) -> CancellationToken { self.shutdown.clone() }
pub fn shutdown_token(&self) -> CancellationToken {

Check warning on line 198 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs
self.shutdown.clone()
}

/// Drive the actor until all sources are exhausted or shutdown is triggered.
///
Expand Down Expand Up @@ -393,26 +401,28 @@
fn after_high(&mut self, out: &mut Vec<F>, state: &mut ActorState) {
self.fairness.after_high();

if self.fairness.should_yield()
&& let Some(rx) = &mut self.low_rx
{
match rx.try_recv() {
Ok(mut frame) => {
self.hooks.before_send(&mut frame, &mut self.ctx);
out.push(frame);
self.after_low();
}
Err(mpsc::error::TryRecvError::Empty) => {}
Err(mpsc::error::TryRecvError::Disconnected) => {
self.low_rx = None;
state.mark_closed();
if self.fairness.should_yield_to_low_priority() {
if let Some(rx) = &mut self.low_rx {
match rx.try_recv() {
Ok(mut frame) => {
self.hooks.before_send(&mut frame, &mut self.ctx);
out.push(frame);
self.after_low();
}
Err(mpsc::error::TryRecvError::Empty) => {}
Err(mpsc::error::TryRecvError::Disconnected) => {
self.low_rx = None;
state.mark_closed();
}
}
}
}
}

Check warning on line 420 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs

/// Reset counters after processing a low-priority frame.
fn after_low(&mut self) { self.fairness.after_low(); }
fn after_low(&mut self) {
self.fairness.after_low();
}

/// Push a frame from the response stream into `out` or handle completion.
///
Expand Down Expand Up @@ -446,14 +456,18 @@

Ok(())
}

Check warning on line 459 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs
/// Await cancellation on the provided shutdown token.
#[inline]
async fn wait_shutdown(token: CancellationToken) { token.cancelled_owned().await; }
async fn wait_shutdown(token: CancellationToken) {
token.cancelled_owned().await;
}

/// Receive the next frame from a push queue.
#[inline]
async fn recv_push(rx: &mut mpsc::Receiver<F>) -> Option<F> { rx.recv().await }
async fn recv_push(rx: &mut mpsc::Receiver<F>) -> Option<F> {

Check warning on line 468 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs
rx.recv().await
}

/// Poll `f` if `opt` is `Some`, returning `None` otherwise.
#[expect(
Expand Down Expand Up @@ -533,14 +547,20 @@
if matches!(self.run_state, RunState::Active) {
self.run_state = RunState::ShuttingDown;
}
}

Check warning on line 550 in src/connection.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/connection.rs

/// Returns `true` while the actor is actively processing sources.
fn is_active(&self) -> bool { matches!(self.run_state, RunState::Active) }
fn is_active(&self) -> bool {
matches!(self.run_state, RunState::Active)
}

/// Returns `true` once shutdown has begun.
fn is_shutting_down(&self) -> bool { matches!(self.run_state, RunState::ShuttingDown) }
fn is_shutting_down(&self) -> bool {
matches!(self.run_state, RunState::ShuttingDown)
}

/// Returns `true` when all sources have finished.
fn is_done(&self) -> bool { matches!(self.run_state, RunState::Finished) }
fn is_done(&self) -> bool {
matches!(self.run_state, RunState::Finished)
}
}
90 changes: 65 additions & 25 deletions src/fairness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,94 @@
//!
//! This module encapsulates the logic for deciding when high-priority
//! processing should yield to low-priority traffic based on configured
//! thresholds and optional time slices.
//! thresholds and optional time slices. A pluggable clock decouples the
//! implementation from the runtime and allows deterministic tests.

use tokio::time::Instant;
use std::time::Duration;

use crate::connection::FairnessConfig;

/// Abstraction over a time source returning [`Instant`]s.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider removing the Clock trait and related generics to simplify the code while retaining deterministic tests.

Here’s a way to get rid of almost all of the extra indirection and still keep determinism in your tests (they already use tokio::time::pause/advance), by dropping the Clock trait, the generic, and the extra constructor:

use tokio::time::Instant;
use crate::connection::FairnessConfig;

#[derive(Debug)]
pub(crate) struct FairnessTracker {
    config: FairnessConfig,
    high_counter: usize,
    high_start: Option<Instant>,
}

impl FairnessTracker {
    pub(crate) fn new(config: FairnessConfig) -> Self {
        Self {
            config,
            high_counter: 0,
            high_start: None,
        }
    }

    pub(crate) fn set_config(&mut self, config: FairnessConfig) {
        self.config = config;
        self.reset();
    }

    pub(crate) fn after_high(&mut self) {
        self.high_counter += 1;
        if self.high_counter == 1 {
            self.high_start = Some(Instant::now());
        }
    }

    pub(crate) fn should_yield_to_low_priority(&self) -> bool {
        let threshold_hit = self.config.max_high_before_low > 0
            && self.high_counter >= self.config.max_high_before_low;

        let time_hit = self
            .config
            .time_slice
            .zip(self.high_start)
            .map_or(false, |(slice, start)| start.elapsed() >= slice);

        threshold_hit || time_hit
    }

    pub(crate) fn after_low(&mut self) {
        self.reset();
    }

    fn reset(&mut self) {
        self.high_counter = 0;
        self.high_start = None;
    }
}

What this buys you:

  • No more Clock trait + TokioClock type
  • Only one constructor (new) instead of two
  • Direct use of Instant::now() which your tests already control via tokio::time::pause()
  • No change to any existing tests (they still call .should_yield_to_low_priority() under the hood)
  • ~70 lines of boilerplate gone while preserving 100% of the behavior and test determinism.

pub(crate) trait Clock {
type Instant: Copy;
fn now(&self) -> Self::Instant;
fn elapsed(&self, start: Self::Instant) -> Duration;
}

#[derive(Debug, Default)]
pub(crate) struct TokioClock;

Check warning on line 21 in src/fairness.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/fairness.rs
impl Clock for TokioClock {
type Instant = tokio::time::Instant;
fn now(&self) -> Self::Instant {
tokio::time::Instant::now()
}
fn elapsed(&self, start: Self::Instant) -> Duration {
start.elapsed()
}
Comment on lines +24 to +29
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Format Clock trait methods as single lines.

The pipeline indicates these methods should be formatted on single lines.

Apply this diff to fix the formatting:

-    fn now(&self) -> Self::Instant {
-        tokio::time::Instant::now()
-    }
-    fn elapsed(&self, start: Self::Instant) -> Duration {
-        start.elapsed()
-    }
+    fn now(&self) -> Self::Instant { tokio::time::Instant::now() }
+    fn elapsed(&self, start: Self::Instant) -> Duration { start.elapsed() }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn now(&self) -> Self::Instant {
tokio::time::Instant::now()
}
fn elapsed(&self, start: Self::Instant) -> Duration {
start.elapsed()
}
fn now(&self) -> Self::Instant { tokio::time::Instant::now() }
fn elapsed(&self, start: Self::Instant) -> Duration { start.elapsed() }
🤖 Prompt for AI Agents
In src/fairness.rs around lines 24 to 29, the methods of the Clock trait are
currently formatted with braces on separate lines. Reformat the now() and
elapsed() methods to be single-line functions without braces, placing the entire
function definition on one line each to comply with the pipeline formatting
requirements.

}

#[derive(Debug)]
pub(crate) struct Fairness {
pub(crate) struct FairnessTracker<C: Clock = TokioClock> {
config: FairnessConfig,
high_counter: usize,
high_start: Option<Instant>,
high_start: Option<C::Instant>,
clock: C,
}

Check warning on line 38 in src/fairness.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/fairness.rs

impl Fairness {
impl FairnessTracker<TokioClock> {
pub(crate) fn new(config: FairnessConfig) -> Self {
Self::with_clock(config, TokioClock)
}
Comment on lines 41 to +43
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Format new method as a single line.

The pipeline indicates this method should be formatted on a single line.

Apply this diff to fix the formatting:

-    pub(crate) fn new(config: FairnessConfig) -> Self {
-        Self::with_clock(config, TokioClock)
-    }
+    pub(crate) fn new(config: FairnessConfig) -> Self { Self::with_clock(config, TokioClock) }
🤖 Prompt for AI Agents
In src/fairness.rs around lines 41 to 43, the new method should be formatted as
a single line to comply with the pipeline formatting rules. Change the method
definition to a single line by removing the line break and extra indentation, so
it reads: pub(crate) fn new(config: FairnessConfig) -> Self {
Self::with_clock(config, TokioClock) }.

}

impl<C: Clock> FairnessTracker<C> {
pub(crate) fn with_clock(config: FairnessConfig, clock: C) -> Self {
Self {
config,
high_counter: 0,
high_start: None,
clock,
}
}

pub(crate) fn set_config(&mut self, config: FairnessConfig) {
self.config = config;
self.reset();
self.clear();
}

pub(crate) fn after_high(&mut self) {
self.high_counter += 1;
if self.high_counter == 1 {
self.high_start = Some(Instant::now());
self.high_start = Some(self.clock.now());
}
}

pub(crate) fn should_yield(&self) -> bool {
let threshold_hit = self.config.max_high_before_low > 0
&& self.high_counter >= self.config.max_high_before_low;
let time_hit = self
.config
.time_slice
.zip(self.high_start)
.is_some_and(|(slice, start)| start.elapsed() >= slice);
threshold_hit || time_hit
pub(crate) fn should_yield_to_low_priority(&self) -> bool {
if self.config.max_high_before_low > 0
&& self.high_counter >= self.config.max_high_before_low
{
return true;
}

if let (Some(slice), Some(start)) = (self.config.time_slice, self.high_start) {
if self.clock.elapsed(start) >= slice {
return true;
}
}

false

Check warning on line 81 in src/fairness.rs

View workflow job for this annotation

GitHub Actions / build-test

Diff in /home/runner/work/wireframe/wireframe/src/fairness.rs
}

pub(crate) fn after_low(&mut self) { self.reset(); }
pub(crate) fn after_low(&mut self) {
self.clear();
}

pub(crate) fn reset(&mut self) {
self.clear();
}
Comment on lines +84 to +90
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Format after_low and reset methods as single lines.

The pipeline indicates these methods should be formatted on single lines.

Apply this diff to fix the formatting:

-    pub(crate) fn after_low(&mut self) {
-        self.clear();
-    }
+    pub(crate) fn after_low(&mut self) { self.clear(); }

-    pub(crate) fn reset(&mut self) {
-        self.clear();
-    }
+    pub(crate) fn reset(&mut self) { self.clear(); }
🧰 Tools
🪛 GitHub Actions: CI

[warning] 81-90: Prettier-like formatting warning: functions after_low and reset should be formatted in a single line.

🤖 Prompt for AI Agents
In src/fairness.rs around lines 84 to 90, the methods after_low and reset are
currently formatted with braces on separate lines. To fix the formatting,
rewrite both methods as single-line functions by placing the function signature
and the call to self.clear() on the same line, removing the extra line breaks
and braces.


fn clear(&mut self) {
self.high_counter = 0;
self.high_start = None;
}
Expand All @@ -69,11 +109,11 @@
max_high_before_low: 2,
time_slice: None,
};
let mut fairness = Fairness::new(cfg);
let mut fairness = FairnessTracker::new(cfg);
fairness.after_high();
assert!(!fairness.should_yield());
assert!(!fairness.should_yield_to_low_priority());
fairness.after_high();
assert!(fairness.should_yield());
assert!(fairness.should_yield_to_low_priority());
}

#[rstest]
Expand All @@ -83,11 +123,11 @@
max_high_before_low: 1,
time_slice: None,
};
let mut fairness = Fairness::new(cfg);
let mut fairness = FairnessTracker::new(cfg);
fairness.after_high();
assert!(fairness.should_yield());
assert!(fairness.should_yield_to_low_priority());
fairness.after_low();
assert!(!fairness.should_yield());
assert!(!fairness.should_yield_to_low_priority());
}

#[rstest]
Expand All @@ -98,9 +138,9 @@
max_high_before_low: 0,
time_slice: Some(Duration::from_millis(5)),
};
let mut fairness = Fairness::new(cfg);
let mut fairness = FairnessTracker::new(cfg);
fairness.after_high();
time::advance(Duration::from_millis(6)).await;
assert!(fairness.should_yield());
assert!(fairness.should_yield_to_low_priority());
}
}
16 changes: 10 additions & 6 deletions src/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ pub(crate) struct PushHandleInner<F> {
pub struct PushHandle<F>(Arc<PushHandleInner<F>>);

impl<F: FrameLike> PushHandle<F> {
pub(crate) fn from_arc(arc: Arc<PushHandleInner<F>>) -> Self { Self(arc) }
pub(crate) fn from_arc(arc: Arc<PushHandleInner<F>>) -> Self {
Self(arc)
}
Comment on lines +100 to +102
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Format from_arc as a single line.

The pipeline indicates this function should be formatted on a single line.

Apply this diff to fix the formatting:

-    pub(crate) fn from_arc(arc: Arc<PushHandleInner<F>>) -> Self {
-        Self(arc)
-    }
+    pub(crate) fn from_arc(arc: Arc<PushHandleInner<F>>) -> Self { Self(arc) }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub(crate) fn from_arc(arc: Arc<PushHandleInner<F>>) -> Self {
Self(arc)
}
pub(crate) fn from_arc(arc: Arc<PushHandleInner<F>>) -> Self { Self(arc) }
🤖 Prompt for AI Agents
In src/push.rs around lines 100 to 102, the function from_arc should be
formatted as a single line to comply with the pipeline formatting rules. Change
the function definition to a single line by removing the line breaks and placing
the entire function body on the same line as the signature.


/// Internal helper to push a frame with the requested priority.
///
Expand Down Expand Up @@ -253,7 +255,9 @@ impl<F: FrameLike> PushHandle<F> {
}

/// Downgrade to a `Weak` reference for storage in a registry.
pub(crate) fn downgrade(&self) -> Weak<PushHandleInner<F>> { Arc::downgrade(&self.0) }
pub(crate) fn downgrade(&self) -> Weak<PushHandleInner<F>> {
Arc::downgrade(&self.0)
}
Comment on lines +258 to +260
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Format downgrade as a single line.

The pipeline indicates this function should be formatted on a single line.

Apply this diff to fix the formatting:

-    pub(crate) fn downgrade(&self) -> Weak<PushHandleInner<F>> {
-        Arc::downgrade(&self.0)
-    }
+    pub(crate) fn downgrade(&self) -> Weak<PushHandleInner<F>> { Arc::downgrade(&self.0) }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub(crate) fn downgrade(&self) -> Weak<PushHandleInner<F>> {
Arc::downgrade(&self.0)
}
pub(crate) fn downgrade(&self) -> Weak<PushHandleInner<F>> { Arc::downgrade(&self.0) }
🤖 Prompt for AI Agents
In src/push.rs around lines 258 to 260, the downgrade function is currently
formatted across multiple lines but should be condensed into a single line.
Rewrite the entire function definition as a single line by placing the function
signature and its body on the same line without line breaks.

}

/// Receiver ends of the push queues stored by the connection actor.
Expand Down Expand Up @@ -382,10 +386,10 @@ impl<F: FrameLike> PushQueues<F> {
rate: Option<usize>,
dlq: Option<mpsc::Sender<F>>,
) -> Result<(Self, PushHandle<F>), PushConfigError> {
if let Some(r) = rate
&& (r == 0 || r > MAX_PUSH_RATE)
{
return Err(PushConfigError::InvalidRate(r));
if let Some(r) = rate {
if r == 0 || r > MAX_PUSH_RATE {
return Err(PushConfigError::InvalidRate(r));
}
}
let (high_tx, high_rx) = mpsc::channel(high_capacity);
let (low_tx, low_rx) = mpsc::channel(low_capacity);
Expand Down
14 changes: 8 additions & 6 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ where
/// ```
#[inline]
#[must_use]
pub const fn worker_count(&self) -> usize { self.workers }
pub const fn worker_count(&self) -> usize {
self.workers
}
Comment on lines +232 to +234
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Format worker_count as a single line.

The pipeline indicates this method should be formatted on a single line.

Apply this diff to fix the formatting:

-    pub const fn worker_count(&self) -> usize {
-        self.workers
-    }
+    pub const fn worker_count(&self) -> usize { self.workers }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub const fn worker_count(&self) -> usize {
self.workers
}
pub const fn worker_count(&self) -> usize { self.workers }
🤖 Prompt for AI Agents
In src/server.rs around lines 232 to 234, the worker_count method should be
formatted as a single line function. Change the method definition to a single
line by placing the entire function signature and body on one line, like `pub
const fn worker_count(&self) -> usize { self.workers }`.


/// Get the socket address the server is bound to, if available.
#[must_use]
Expand Down Expand Up @@ -507,10 +509,10 @@ async fn process_stream<F, T>(
let peer_addr = stream.peer_addr().ok();
match read_preamble::<_, T>(&mut stream).await {
Ok((preamble, leftover)) => {
if let Some(handler) = on_success.as_ref()
&& let Err(e) = handler(&preamble, &mut stream).await
{
tracing::error!(error = ?e, ?peer_addr, "preamble callback error");
if let Some(handler) = on_success.as_ref() {
if let Err(e) = handler(&preamble, &mut stream).await {
tracing::error!(error = ?e, ?peer_addr, "preamble callback error");
}
}
let stream = RewindStream::new(leftover, stream);
// Hand the connection to the application for processing.
Expand Down Expand Up @@ -558,7 +560,7 @@ mod tests {

/// Test helper preamble carrying no data.
#[derive(Debug, Clone, PartialEq, Encode, Decode)]
#[expect(
#[allow(
dead_code,
reason = "used only in doctest to illustrate an empty preamble"
)]
Expand Down
Loading
Loading