Skip to content

Commit

Permalink
Optimize io layout (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 authored Jul 30, 2024
1 parent d81e089 commit f5bad7b
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 166 deletions.
4 changes: 4 additions & 0 deletions ntex-io/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [2.1.0] - 2024-07-30

* Optimize `Io` layout

## [2.0.0] - 2024-05-28

* Use async fn for Service::ready() and Service::shutdown()
Expand Down
4 changes: 2 additions & 2 deletions ntex-io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-io"
version = "2.0.0"
version = "2.1.0"
authors = ["ntex contributors <[email protected]>"]
description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"]
Expand All @@ -18,7 +18,7 @@ path = "src/lib.rs"
[dependencies]
ntex-codec = "0.6.2"
ntex-bytes = "0.1.24"
ntex-util = "2.0"
ntex-util = "2.2"
ntex-service = "3.0"

bitflags = "2"
Expand Down
12 changes: 12 additions & 0 deletions ntex-io/src/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,12 @@ pub struct ReadBuf<'a> {
}

impl<'a> ReadBuf<'a> {
#[inline]
/// Get io tag
pub fn tag(&self) -> &'static str {
self.io.tag()
}

#[inline]
/// Get number of newly added bytes
pub fn nbytes(&self) -> usize {
Expand Down Expand Up @@ -433,6 +439,12 @@ pub struct WriteBuf<'a> {
}

impl<'a> WriteBuf<'a> {
#[inline]
/// Get io tag
pub fn tag(&self) -> &'static str {
self.io.tag()
}

#[inline]
/// Initiate graceful io stream shutdown
pub fn want_shutdown(&self) {
Expand Down
1 change: 0 additions & 1 deletion ntex-io/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ mod tests {

#[ntex::test]
async fn test_basic() {
let _ = env_logger::try_init();
let (client, server) = IoTest::create();
client.remote_buffer_cap(1024);
client.write("GET /test HTTP/1\r\n\r\n");
Expand Down
2 changes: 1 addition & 1 deletion ntex-io/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) struct NullFilter;
const NULL: NullFilter = NullFilter;

impl NullFilter {
pub(super) fn get() -> &'static dyn Filter {
pub(super) const fn get() -> &'static dyn Filter {
&NULL
}
}
Expand Down
Loading

0 comments on commit f5bad7b

Please sign in to comment.