diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4d531646..9127ca19 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -40,7 +40,7 @@ jobs: - uses: giraffate/clippy-action@v1.0.1 with: - reporter: 'github-pr-check' + reporter: "github-pr-check" github_token: ${{ secrets.GITHUB_TOKEN }} clippy_flags: --workspace --all-features --tests --examples --bins -- -Dclippy::todo -Aunknown_lints @@ -67,3 +67,31 @@ jobs: - name: check external types run: just check-external-types-all +${{ vars.RUST_VERSION_EXTERNAL_TYPES }} + + public-api-diff: + name: Public API Diff + runs-on: ubuntu-latest + steps: + - name: Checkout main branch + uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + + - name: Checkout PR branch + uses: actions/checkout@v4 + + - name: Install Rust (${{ vars.RUST_VERSION_API_DIFF }}) + uses: actions-rust-lang/setup-rust-toolchain@v1.8.0 + with: + toolchain: ${{ vars.RUST_VERSION_API_DIFF }} + + - name: Install cargo-public-api + uses: taiki-e/install-action@v2.34.0 + with: + tool: cargo-public-api + + - name: Generate API diff + run: | + for f in $(find -mindepth 2 -maxdepth 2 -name Cargo.toml); do + cargo public-api --manifest-path "$f" --simplified diff ${{ github.event.pull_request.base.sha }}..${{ github.sha }} + done diff --git a/Cargo.toml b/Cargo.toml index c130eaf9..3ff0b548 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ members = [ [workspace.package] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.70" +rust-version = "1.71.1" [patch.crates-io] actix-codec = { path = "actix-codec" } diff --git a/actix-codec/CHANGES.md b/actix-codec/CHANGES.md index fa2bfddd..5757d55e 100644 --- a/actix-codec/CHANGES.md +++ b/actix-codec/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 0.5.2 diff --git a/actix-macros/CHANGES.md b/actix-macros/CHANGES.md index 99ecfa97..398f6d27 100644 --- a/actix-macros/CHANGES.md +++ b/actix-macros/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 0.2.4 diff --git a/actix-rt/CHANGES.md b/actix-rt/CHANGES.md index 18466fa6..27476ab9 100644 --- a/actix-rt/CHANGES.md +++ b/actix-rt/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.71. + ## 2.10.0 - Relax `F`'s bound (`Fn => FnOnce`) on `{Arbiter, System}::with_tokio_rt()` functions. diff --git a/actix-server/CHANGES.md b/actix-server/CHANGES.md index 50a11ba7..fa743277 100644 --- a/actix-server/CHANGES.md +++ b/actix-server/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.71. + ## 2.5.0 - Update `mio` dependency to `1`. diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index 0ef39dc1..2617de5d 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 2.0.2 diff --git a/actix-tls/CHANGES.md b/actix-tls/CHANGES.md index 5b7ffb04..2654c083 100644 --- a/actix-tls/CHANGES.md +++ b/actix-tls/CHANGES.md @@ -2,6 +2,8 @@ ## Unreleased +- Minimum supported Rust version (MSRV) is now 1.71. + ## 3.4.0 - Add `rustls-0_23`, `rustls-0_23-webpki-roots`, and `rustls-0_23-native-roots` crate features. diff --git a/actix-tracing/CHANGES.md b/actix-tracing/CHANGES.md index 15f1437a..c288deaa 100644 --- a/actix-tracing/CHANGES.md +++ b/actix-tracing/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 0.1.0 diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index de510788..4e7cdddd 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 3.0.1 diff --git a/bytestring/CHANGES.md b/bytestring/CHANGES.md index 8a24680f..a5d69fd5 100644 --- a/bytestring/CHANGES.md +++ b/bytestring/CHANGES.md @@ -2,7 +2,10 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +## 1.4.0 + +- Add `ByteString::split_at()` method. +- Minimum supported Rust version (MSRV) is now 1.71. ## 1.3.1 diff --git a/bytestring/Cargo.toml b/bytestring/Cargo.toml index 63472205..067a7fbe 100644 --- a/bytestring/Cargo.toml +++ b/bytestring/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "bytestring" -version = "1.3.1" +version = "1.4.0" description = "A UTF-8 encoded read-only string using `Bytes` as storage" authors = [ "Nikolay Kim ", "Rob Ede ", ] -keywords = ["string", "bytes", "utf8", "web", "actix"] +keywords = ["string", "bytes", "utf8", "web", "bytestring"] categories = ["no-std", "web-programming"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-net" diff --git a/bytestring/README.md b/bytestring/README.md index 2bfd3083..a525cd75 100644 --- a/bytestring/README.md +++ b/bytestring/README.md @@ -5,11 +5,11 @@ [![crates.io](https://img.shields.io/crates/v/bytestring?label=latest)](https://crates.io/crates/bytestring) -[![Documentation](https://docs.rs/bytestring/badge.svg?version=1.3.1)](https://docs.rs/bytestring/1.3.1) +[![Documentation](https://docs.rs/bytestring/badge.svg?version=1.4.0)](https://docs.rs/bytestring/1.4.0) [![Version](https://img.shields.io/badge/rustc-1.52+-ab6000.svg)](https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html) ![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/bytestring.svg)
-[![Dependency Status](https://deps.rs/crate/bytestring/1.3.1/status.svg)](https://deps.rs/crate/bytestring/1.3.1) +[![Dependency Status](https://deps.rs/crate/bytestring/1.4.0/status.svg)](https://deps.rs/crate/bytestring/1.4.0) ![Download](https://img.shields.io/crates/d/bytestring.svg) [![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x) diff --git a/bytestring/src/lib.rs b/bytestring/src/lib.rs index 6cb164dc..1108c449 100644 --- a/bytestring/src/lib.rs +++ b/bytestring/src/lib.rs @@ -17,7 +17,7 @@ use core::{borrow::Borrow, fmt, hash, ops, str}; use bytes::Bytes; -/// An immutable UTF-8 encoded string with [`Bytes`] as a storage. +/// An immutable UTF-8 encoded string using [`Bytes`] as the storage. #[derive(Clone, Default, Eq, PartialOrd, Ord)] pub struct ByteString(Bytes); @@ -53,7 +53,29 @@ impl ByteString { Self(src) } - /// Returns a new byte string that is equivalent to the given `subset`. + /// Divides one bytestring into two at an index, returning both parts. + /// + /// # Panics + /// + /// Panics if `mid` is not on a UTF-8 code point boundary, or if it is past the end of the last + /// code point of the bytestring. + pub fn split_at(&self, mid: usize) -> (ByteString, ByteString) { + let this: &str = self.as_ref(); + let _valid_midpoint_check = this.split_at(mid); + + let mut bytes = self.0.clone(); + let first = bytes.split_to(mid); + let last = bytes; + + unsafe { + ( + ByteString::from_bytes_unchecked(first), + ByteString::from_bytes_unchecked(last), + ) + } + } + + /// Returns a new `ByteString` 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 original `ByteString`; i.e., a subset of it. This function turns that @@ -465,4 +487,33 @@ mod test { // being a logical subset of the string ByteString::from_static("foo bar").slice_ref("foo"); } + + #[test] + fn split_at() { + let buf = ByteString::from_static("foo bar"); + + let (first, last) = buf.split_at(0); + assert_eq!(ByteString::from_static(""), first); + assert_eq!(ByteString::from_static("foo bar"), last); + + let (first, last) = buf.split_at(4); + assert_eq!(ByteString::from_static("foo "), first); + assert_eq!(ByteString::from_static("bar"), last); + + let (first, last) = buf.split_at(7); + assert_eq!(ByteString::from_static("foo bar"), first); + assert_eq!(ByteString::from_static(""), last); + } + + #[test] + #[should_panic = "byte index 1 is not a char boundary;"] + fn split_at_invalid_code_point() { + ByteString::from_static("ยต").split_at(1); + } + + #[test] + #[should_panic = "byte index 9 is out of bounds"] + fn split_at_outside_string() { + ByteString::from_static("foo").split_at(9); + } } diff --git a/local-channel/CHANGES.md b/local-channel/CHANGES.md index 602d09b3..9b2111f7 100644 --- a/local-channel/CHANGES.md +++ b/local-channel/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 0.1.5 diff --git a/local-waker/CHANGES.md b/local-waker/CHANGES.md index a6adfbba..5731219b 100644 --- a/local-waker/CHANGES.md +++ b/local-waker/CHANGES.md @@ -2,7 +2,7 @@ ## Unreleased -- Minimum supported Rust version (MSRV) is now 1.70. +- Minimum supported Rust version (MSRV) is now 1.71. ## 0.1.4