Skip to content
Open
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
1 change: 1 addition & 0 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ pub trait FrameProcessor: Send + Sync {
}

/// Simple length-prefixed framing using a configurable length prefix.
#[derive(Clone, Copy, Debug)]
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (review_instructions): Attributes should be placed after the doc comment, not before.

The #[derive(Clone, Copy, Debug)] attribute should be placed after the doc comment for LengthPrefixedProcessor to comply with the style guide.

Review instructions:

Path patterns: **/*.rs

Instructions:
Ensure that function attributes are placed AFTER the function doc comment

pub struct LengthPrefixedProcessor {
format: LengthFormat,
}
Expand Down
8 changes: 4 additions & 4 deletions tests/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use bytes::BytesMut;
use wireframe::{
Serializer,
app::WireframeApp,
frame::{FrameProcessor, LengthPrefixedProcessor},
frame::FrameProcessor,
message::Message,
serializer::BincodeSerializer,
};

mod util;
use util::run_app_with_frame;
use util::{default_processor, run_app_with_frame};

#[derive(bincode::Encode, bincode::BorrowDecode, PartialEq, Debug)]
struct TestEnvelope {
Expand All @@ -28,9 +28,10 @@ struct Echo(u8);
async fn handler_receives_message_and_echoes_response() {
let called = Arc::new(AtomicUsize::new(0));
let called_clone = called.clone();
let processor = default_processor();
let app = WireframeApp::new()
.unwrap()
.frame_processor(LengthPrefixedProcessor::default())
.frame_processor(processor)
.route(
1,
Box::new(move |_| {
Expand All @@ -49,7 +50,6 @@ async fn handler_receives_message_and_echoes_response() {
};
let env_bytes = BincodeSerializer.serialize(&env).unwrap();
let mut framed = BytesMut::new();
let processor = LengthPrefixedProcessor::default();
processor.encode(&env_bytes, &mut framed).unwrap();

let out = run_app_with_frame(app, framed.to_vec()).await.unwrap();
Expand Down
6 changes: 6 additions & 0 deletions tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ pub async fn run_app_with_frame_with_capacity(
server_task.await.unwrap();
Ok(buf)
}

/// Convenience for constructing a default length-prefixed processor.
#[must_use]
pub fn default_processor() -> wireframe::frame::LengthPrefixedProcessor {
wireframe::frame::LengthPrefixedProcessor::default()
}
Loading