mirror of
https://github.com/fafhrd91/actix-net
synced 2025-08-13 00:37:04 +02:00
Compare commits
10 Commits
utils-v3.0
...
bytestring
Author | SHA1 | Date | |
---|---|---|---|
|
8e9401f8e1 | ||
|
9ede174e81 | ||
|
bb36e2a072 | ||
|
6061a44a22 | ||
|
363984ad75 | ||
|
00654aadc5 | ||
|
428914e65e | ||
|
df9a9d1a1e | ||
|
056d2cd573 | ||
|
68228a6cf2 |
@@ -20,4 +20,4 @@ ci-test = "hack --feature-powerset --exclude-features=io-uring test --lib --test
|
||||
ci-test-win = "hack --feature-powerset --depth 2 --exclude-features=io-uring test --lib --tests --no-fail-fast -- --nocapture"
|
||||
|
||||
# test with io-uring feature
|
||||
ci-test-linux = " hack --feature-powerset test --lib --tests --no-fail-fast -- --nocapture"
|
||||
ci-test-linux = "hack --feature-powerset test --lib --tests --no-fail-fast -- --nocapture"
|
||||
|
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -77,6 +77,11 @@ jobs:
|
||||
uses: actions-rs/cargo@v1
|
||||
with: { command: generate-lockfile }
|
||||
|
||||
- name: workaround MSRV issues
|
||||
if: matrix.version != 'stable'
|
||||
run: |
|
||||
cargo update -p=time --precise=0.3.13 # time is only a dev dep so shouldn't affect msrv
|
||||
|
||||
- name: check lib
|
||||
if: >
|
||||
matrix.target.os != 'ubuntu-latest'
|
||||
@@ -118,6 +123,7 @@ jobs:
|
||||
sudo bash -c "ulimit -Sl 512 && ulimit -Hl 512 && PATH=$PATH:/usr/share/rust/.cargo/bin && RUSTUP_TOOLCHAIN=${{ matrix.version }} cargo ci-test && RUSTUP_TOOLCHAIN=${{ matrix.version }} cargo ci-test-linux"
|
||||
|
||||
- name: Clear the cargo caches
|
||||
if: matrix.version == 'stable' # MSRV(1.58) cargo-cache now fails to install on 1.57
|
||||
run: |
|
||||
cargo install cargo-cache --version 0.6.2 --no-default-features --features ci-autoclean
|
||||
cargo-cache
|
||||
|
@@ -28,7 +28,7 @@ tokio-util = { version = "0.7", features = ["codec", "io"] }
|
||||
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
|
||||
|
||||
[dev-dependencies]
|
||||
criterion = { version = "0.3", features = ["html_reports"] }
|
||||
criterion = { version = "0.4", features = ["html_reports"] }
|
||||
tokio-test = "0.4.2"
|
||||
|
||||
[[bench]]
|
||||
|
@@ -1,8 +1,7 @@
|
||||
//! Codec utilities for working with framed protocols.
|
||||
//!
|
||||
//! Contains adapters to go from streams of bytes, [`AsyncRead`] and
|
||||
//! [`AsyncWrite`], to framed streams implementing [`Sink`] and [`Stream`].
|
||||
//! Framed streams are also known as `transports`.
|
||||
//! Contains adapters to go from streams of bytes, [`AsyncRead`] and [`AsyncWrite`], to framed
|
||||
//! streams implementing [`Sink`] and [`Stream`]. Framed streams are also known as `transports`.
|
||||
//!
|
||||
//! [`Sink`]: futures_sink::Sink
|
||||
//! [`Stream`]: futures_core::Stream
|
||||
|
@@ -4,7 +4,6 @@ version = "2.7.0"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
"fakeshadow <24548779@qq.com>",
|
||||
]
|
||||
description = "Tokio-based single-threaded async runtime for the Actix ecosystem"
|
||||
keywords = ["async", "futures", "io", "runtime"]
|
||||
|
@@ -3,7 +3,6 @@ name = "actix-server"
|
||||
version = "2.1.1"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"fakeshadow <24548779@qq.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
"Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>",
|
||||
]
|
||||
@@ -41,8 +40,8 @@ tracing = { version = "0.1.30", default-features = false, features = ["log"] }
|
||||
tokio-uring = { version = "0.3", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-codec = "0.5.0"
|
||||
actix-rt = "2.6.0"
|
||||
actix-codec = "0.5"
|
||||
actix-rt = "2.6"
|
||||
|
||||
bytes = "1"
|
||||
env_logger = "0.9"
|
||||
|
@@ -4,7 +4,6 @@ version = "2.0.2"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
"fakeshadow <24548779@qq.com>",
|
||||
]
|
||||
description = "Service trait and combinators for representing asynchronous request/response operations."
|
||||
keywords = ["network", "framework", "async", "futures", "service"]
|
||||
|
@@ -30,19 +30,18 @@ accept = []
|
||||
connect = []
|
||||
|
||||
# use openssl impls
|
||||
openssl = ["tls-openssl", "tokio-openssl", "actix-codec"]
|
||||
openssl = ["tls-openssl", "tokio-openssl"]
|
||||
|
||||
# use rustls impls
|
||||
rustls = ["tokio-rustls", "webpki-roots", "actix-codec"]
|
||||
rustls = ["tokio-rustls", "webpki-roots"]
|
||||
|
||||
# use native-tls impls
|
||||
native-tls = ["tokio-native-tls", "actix-codec"]
|
||||
native-tls = ["tokio-native-tls"]
|
||||
|
||||
# support http::Uri as connect address
|
||||
uri = ["http"]
|
||||
|
||||
[dependencies]
|
||||
actix-codec = { version = "0.5.0", optional = true }
|
||||
actix-rt = { version = "2.2.0", default-features = false }
|
||||
actix-service = "2"
|
||||
actix-utils = "3"
|
||||
@@ -50,6 +49,7 @@ actix-utils = "3"
|
||||
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
||||
impl-more = "0.1"
|
||||
pin-project-lite = "0.2.7"
|
||||
tokio = "1.13.1"
|
||||
tokio-util = "0.7"
|
||||
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
|
||||
|
||||
@@ -68,17 +68,17 @@ webpki-roots = { version = "0.22", optional = true }
|
||||
tokio-native-tls = { version = "0.3", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-codec = "0.5.0"
|
||||
actix-rt = "2.2.0"
|
||||
actix-codec = "0.5"
|
||||
actix-rt = "2.2"
|
||||
actix-server = "2"
|
||||
bytes = "1"
|
||||
env_logger = "0.9"
|
||||
futures-util = { version = "0.3.7", default-features = false, features = ["sink"] }
|
||||
log = "0.4"
|
||||
rcgen = "0.8"
|
||||
rustls-pemfile = "0.2.1"
|
||||
rcgen = "0.10"
|
||||
rustls-pemfile = "1"
|
||||
tokio-rustls = { version = "0.23", features = ["dangerous_configuration"] }
|
||||
trust-dns-resolver = "0.20"
|
||||
trust-dns-resolver = "0.22"
|
||||
|
||||
[[example]]
|
||||
name = "accept-rustls"
|
||||
|
@@ -10,7 +10,6 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use actix_rt::{
|
||||
net::{ActixStream, Ready},
|
||||
time::timeout,
|
||||
@@ -21,6 +20,7 @@ use actix_utils::{
|
||||
future::{ready, Ready as FutReady},
|
||||
};
|
||||
use futures_core::future::LocalBoxFuture;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use tokio_native_tls::{native_tls::Error, TlsAcceptor};
|
||||
|
||||
use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER};
|
||||
|
@@ -11,7 +11,6 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use actix_rt::{
|
||||
net::{ActixStream, Ready},
|
||||
time::{sleep, Sleep},
|
||||
@@ -23,6 +22,7 @@ use actix_utils::{
|
||||
};
|
||||
use openssl::ssl::{Error, Ssl, SslAcceptor};
|
||||
use pin_project_lite::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
|
||||
use super::{TlsError, DEFAULT_TLS_HANDSHAKE_TIMEOUT, MAX_CONN_COUNTER};
|
||||
|
||||
|
@@ -12,7 +12,6 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use actix_codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use actix_rt::{
|
||||
net::{ActixStream, Ready},
|
||||
time::{sleep, Sleep},
|
||||
@@ -23,6 +22,7 @@ use actix_utils::{
|
||||
future::{ready, Ready as FutReady},
|
||||
};
|
||||
use pin_project_lite::pin_project;
|
||||
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use tokio_rustls::rustls::ServerConfig;
|
||||
use tokio_rustls::{Accept, TlsAcceptor};
|
||||
|
||||
|
@@ -1,8 +1,20 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2022-xx-xx
|
||||
|
||||
|
||||
## 1.2.1 - 2022-11-12
|
||||
- Fix `#[no_std]` compatibility. [#471]
|
||||
|
||||
[#471]: https://github.com/actix/actix-net/pull/471
|
||||
|
||||
|
||||
## 1.2.0 - 2022-11-07
|
||||
- Add `ByteString::slice_ref` which can safely slice a `ByteString` into a new one with zero copy. [#470]
|
||||
- Minimum supported Rust version (MSRV) is now 1.57.
|
||||
|
||||
[#470]: https://github.com/actix/actix-net/pull/470
|
||||
|
||||
|
||||
## 1.1.0 - 2022-06-11
|
||||
- Implement `From<Box<str>>` for `ByteString`. [#458]
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bytestring"
|
||||
version = "1.1.0"
|
||||
version = "1.2.1"
|
||||
authors = [
|
||||
"Nikolay Kim <fafhrd91@gmail.com>",
|
||||
"Rob Ede <robjtede@icloud.com>",
|
||||
@@ -18,11 +18,11 @@ name = "bytestring"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
bytes = "1.2"
|
||||
bytes = { version = "1.2", default-features = false }
|
||||
serde = { version = "1.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
ahash = { version = "0.7.6", default-features = false }
|
||||
ahash = { version = "0.8", default-features = false }
|
||||
serde_json = "1.0"
|
||||
static_assertions = "1.1"
|
||||
rustversion = "1"
|
||||
|
@@ -50,6 +50,33 @@ impl ByteString {
|
||||
pub const unsafe fn from_bytes_unchecked(src: Bytes) -> ByteString {
|
||||
Self(src)
|
||||
}
|
||||
|
||||
/// Returns a byte string that is equivalent to the given `subset`.
|
||||
///
|
||||
/// When processing a `ByteString` buffer with other tools, one often gets a `&str` which is in
|
||||
/// fact a slice of the `ByteString`; i.e., a subset of it. This function turns that `&str` into
|
||||
/// another `ByteString`, as if one had sliced the `ByteString` with the offsets that correspond
|
||||
/// to `subset`.
|
||||
///
|
||||
/// Corresponds to [`Bytes::slice_ref`].
|
||||
///
|
||||
/// This operation is `O(1)`.
|
||||
///
|
||||
/// # Panics
|
||||
/// Requires that the given `subset` str is in fact contained within the `ByteString` buffer;
|
||||
/// otherwise this function will panic.
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// # use bytestring::ByteString;
|
||||
/// let string = ByteString::from_static(" foo ");
|
||||
/// let subset = string.trim();
|
||||
/// let substring = string.slice_ref(subset);
|
||||
/// assert_eq!(substring, "foo");
|
||||
/// ```
|
||||
pub fn slice_ref(&self, subset: &str) -> Self {
|
||||
Self(self.0.slice_ref(subset.as_bytes()))
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<str> for ByteString {
|
||||
@@ -349,4 +376,10 @@ mod test {
|
||||
let s = serde_json::to_string(&ByteString::from_static("nice bytes")).unwrap();
|
||||
assert_eq!(s, r#""nice bytes""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_slice_ref_catches_not_a_subset() {
|
||||
ByteString::from_static("foo bar").slice_ref("foo");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user