Skip to content

Commit

Permalink
1.82 MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
c410-f3r committed Sep 28, 2024
1 parent 926fcfc commit a303991
Show file tree
Hide file tree
Showing 32 changed files with 472 additions and 313 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Test and Build Book
run: |
rustup default nightly-2024-09-07
rustup default nightly-2024-09-01
cargo clean --target-dir mdbook-target
cargo build --all-features --target-dir mdbook-target
mdbook test -L mdbook-target/debug/deps wtx-docs && mdbook build wtx-docs
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: Swatinem/rust-cache@v2
- run: .scripts/autobahn-fuzzingclient.sh ci

Expand All @@ -25,7 +25,7 @@ jobs:
with:
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: Swatinem/rust-cache@v2
- run: .scripts/autobahn-fuzzingserver.sh ci

Expand All @@ -37,7 +37,7 @@ jobs:
with:
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: actions-rs/[email protected]
with:
crate: cargo-fuzz
Expand All @@ -52,7 +52,7 @@ jobs:
with:
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: Swatinem/rust-cache@v2
- run: .scripts/h2spec.sh ci

Expand All @@ -64,7 +64,7 @@ jobs:
with:
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: Swatinem/rust-cache@v2
- run: sudo apt install docker-compose -y
- run: docker-compose -f .test-utils/docker-compose.yml up -d
Expand All @@ -85,7 +85,7 @@ jobs:
components: clippy, rustfmt
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: Swatinem/rust-cache@v2
- run: .scripts/internal-tests-0.sh

Expand All @@ -102,6 +102,6 @@ jobs:
components: clippy, rustfmt
override: true
profile: minimal
toolchain: nightly-2024-09-07
toolchain: nightly-2024-09-01
- uses: Swatinem/rust-cache@v2
- run: .scripts/internal-tests-1.sh
2 changes: 1 addition & 1 deletion .scripts/internal-tests-0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. "$(dirname "$0")/common.sh" --source-only

$rt rustfmt
$rt clippy -Aclippy::panic_in_result_fn
$rt clippy -Aclippy::little-endian-bytes,-Aclippy::needless-return,-Aclippy::panic-in-result-fn

cargo miri test -p wtx

Expand Down
2 changes: 1 addition & 1 deletion .scripts/internal-tests-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cargo check --all-features --all-targets

# WTX Docs

rustup default nightly-2024-09-07
rustup default nightly-2024-09-01
cargo clean --target-dir mdbook-target
cargo build --all-features --target-dir mdbook-target
mdbook test -L mdbook-target/debug/deps wtx-docs
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![crates.io](https://img.shields.io/crates/v/wtx.svg)](https://crates.io/crates/wtx)
[![Documentation](https://docs.rs/wtx/badge.svg)](https://docs.rs/wtx)
[![License](https://img.shields.io/badge/license-APACHE2-blue.svg)](https://github.com/c410-f3r/wtx/blob/main/LICENSE)
[![Rustc](https://img.shields.io/badge/rustc-nightly-blue")](https://blog.rust-lang.org/2023/12/28/Rust-1.80.0.html)
[![Rustc](https://img.shields.io/badge/rustc-1.82-lightgray")](https://blog.rust-lang.org/2023/12/28/Rust-1.80.0.html)

A collection of different transport implementations and related tools focused primarily on web technologies. Contains the implementations of 5 IETF RFCs ([RFC6265](https://datatracker.ietf.org/doc/html/rfc6265), [RFC6455](https://datatracker.ietf.org/doc/html/rfc6455), [RFC7541](https://datatracker.ietf.org/doc/html/rfc7541), [RFC7692](https://datatracker.ietf.org/doc/html/rfc7692), [RFC9113](https://datatracker.ietf.org/doc/html/rfc9113)), 2 formal specifications ([gRPC](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md), [PostgreSQL](https://www.postgresql.org/docs/16/protocol.html)) and several other invented ideas.

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-09-07"
channel = "nightly-2024-09-01"
components = ["clippy", "miri", "rustfmt", "rust-src"]
profile = "minimal"
2 changes: 1 addition & 1 deletion wtx-instances/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pb-rs = { default-features = false, version = "0.10" }
argon2 = { default-features = false, version = "0.5" }
quick-protobuf = { default-features = false, version = "0.8" }
rand_chacha = { default-features = false, version = "0.3" }
rand_core = { default-features = false, feature = ["getrandom"], version = "0.6" }
rand_core = { default-features = false, features = ["getrandom"], version = "0.6" }
serde = { default-features = false, version = "1.0" }
serde_json = { default-features = false, features = ["alloc"], version = "1.0" }
tokio = { default-features = false, features = ["macros", "rt-multi-thread"], version = "1.0" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use wtx::{
server_framework::{get, post, Router, ServerFrameworkBuilder, State, StateClean},
ReqResBuffer, ReqResData, SessionDecoder, SessionEnforcer, SessionTokio, StatusCode,
},
misc::Rng,
pool::{PostgresRM, SimplePoolTokio},
};

Expand Down Expand Up @@ -62,9 +61,7 @@ async fn main() -> wtx::Result<()> {
)?;
let pool = Pool::new(4, PostgresRM::tokio("postgres://USER:PASSWORD@localhost/DB_NAME".into()));
let mut rng = ChaCha20Rng::from_entropy();
let mut key = [0; 16];
rng.fill_slice(&mut key);
let (expired_sessions, session) = Session::builder(key, pool).build();
let (expired_sessions, session) = Session::builder(pool).build_generating_key(&mut rng);
tokio::spawn(async move {
if let Err(err) = expired_sessions.await {
eprintln!("{err}");
Expand Down
2 changes: 2 additions & 0 deletions wtx-macros/tests/ui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Ui
#[test]
fn ui() {
let t = trybuild::TestCases::new();
Expand Down
3 changes: 2 additions & 1 deletion wtx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sha1 = { default-features = false, optional = true, version = "0.10" }
sha2 = { default-features = false, optional = true, version = "0.10" }
simdutf8 = { default-features = false, features = ["aarch64_neon"], optional = true, version = "0.1" }
test-strategy = { default-features = false, optional = true, version = "0.4" }
tokio = { default-features = false, features = ["io-util", "net", "rt", "sync", "time"], optional = true, version = "1.0" }
tokio = { default-features = false, features = ["io-util", "net", "sync", "time"], optional = true, version = "1.0" }
tokio-rustls = { default-features = false, features = ["ring"], optional = true, version = "0.26" }
tracing = { default-features = false, features = ["attributes"], optional = true, version = "0.1" }
tracing-subscriber = { default-features = false, features = ["env-filter", "fmt"], optional = true, version = "0.3" }
Expand Down Expand Up @@ -113,6 +113,7 @@ license = "Apache-2.0"
name = "wtx"
readme = "README.md"
repository = "https://github.com/c410-f3r/wtx"
rust-version = "1.82"
version = "0.20.0"

[package.metadata.docs.rs]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// `GraphQL` request or operation, can be a query or a mutation.
/// `GraphQL` request/operation, can be a query or a mutation.
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Debug)]
pub struct GraphQlRequest<ON, Q, V> {
Expand All @@ -18,12 +18,13 @@ mod serde_json {
data_transformation::{dnsn::SerdeJson, format::GraphQlRequest},
misc::Vector,
};
use serde::Serialize;

impl<ON, Q, V> crate::data_transformation::dnsn::Serialize<SerdeJson> for GraphQlRequest<ON, Q, V>
where
ON: serde::Serialize,
Q: serde::Serialize,
V: serde::Serialize,
ON: Serialize,
Q: Serialize,
V: Serialize,
{
#[inline]
fn to_bytes(&mut self, bytes: &mut Vector<u8>, _: &mut SerdeJson) -> crate::Result<()> {
Expand Down
6 changes: 3 additions & 3 deletions wtx/src/database/client/postgres/tys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ mod pg_numeric {
curr_slice = local_rest;
}
_PgNumeric::Number {
digits: ArrayVector::from_parts(array, digits.into()),
digits: ArrayVector::from_parts(array, Some(digits.into())),
scale,
sign: Sign::try_from(sign)?,
weight,
Expand Down Expand Up @@ -659,8 +659,8 @@ mod rust_decimal {
}
digits.reverse();

let after_decimal = usize::from(scale.wrapping_add(3) / 4);
let weight = digits.len().wrapping_sub(after_decimal).wrapping_sub(1) as i16;
let after_decimal = scale.wrapping_add(3) / 4;
let weight = digits.len().wrapping_sub(after_decimal.into()).wrapping_sub(1) as i16;

while let Some(&0) = digits.last() {
let _ = digits.pop();
Expand Down
9 changes: 5 additions & 4 deletions wtx/src/http/server_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub use res_finalizer::ResFinalizer;
pub use route_wrappers::{get, json, post, Get, Json, Post};
pub use router::Router;
pub use server_framework_builder::ServerFrameworkBuilder;
pub use state::{State, StateClean};
pub use state::{State, StateClean, StateGeneric};

/// Server
#[derive(Debug)]
Expand All @@ -53,14 +53,15 @@ where
CA: Clone + ConnAux + Send + 'static,
CAC: Clone + Fn() -> CA::Init + Send + 'static,
E: From<crate::Error> + Send + 'static,
P: Send + 'static,
P: PathManagement<CA, E, RA, ReqResBuffer, manage_path(..): Send> + Send + 'static,
RA: ReqAux + Send + 'static,
RAC: Clone + Fn() -> RA::Init + Send + 'static,
REQM: ReqMiddleware<CA, E, RA, ReqResBuffer, apply_req_middleware(..): Send> + Send + 'static,
RESM: ResMiddleware<CA, E, RA, ReqResBuffer, apply_res_middleware(..): Send> + Send + 'static,
Arc<Router<CA, E, P, RA, REQM, RESM, ReqResBuffer>>: Send,
Router<CA, E, P, RA, REQM, RESM, ReqResBuffer>:
PathManagement<CA, E, RA, ReqResBuffer, manage_path(..): Send>,
Router<CA, E, P, RA, REQM, RESM, ReqResBuffer>: Send,
for<'any> &'any Arc<Router<CA, E, P, RA, REQM, RESM, ReqResBuffer>>: Send,
for<'any> &'any Router<CA, E, P, RA, REQM, RESM, ReqResBuffer>: Send,
{
/// Starts listening to incoming requests based on the given `host`.
#[inline]
Expand Down
35 changes: 5 additions & 30 deletions wtx/src/http/server_framework/param_wrappers/path_owned.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
http::{
server_framework::{param_wrappers::manage_path, Endpoint, ResFinalizer, State, StateClean},
server_framework::{param_wrappers::manage_path, Endpoint, ResFinalizer, StateGeneric},
ReqResDataMut, Request, StatusCode,
},
misc::{FnFut, FnFutWrapper},
Expand Down Expand Up @@ -39,13 +39,13 @@ where
}
}

impl<CA, E, F, P, RA, RES, RRD> Endpoint<CA, E, RA, RRD>
for FnFutWrapper<(State<'_, CA, RA, RRD>, PathOwned<P>), F>
impl<CA, E, F, P, RA, RES, RRD, const CLEAN: bool> Endpoint<CA, E, RA, RRD>
for FnFutWrapper<(StateGeneric<'_, CA, RA, RRD, CLEAN>, PathOwned<P>), F>
where
E: From<crate::Error>,
P: FromStr,
P::Err: Into<crate::Error>,
F: for<'any> FnFut<(State<'any, CA, RA, RRD>, PathOwned<P>), Result = RES>,
F: for<'any> FnFut<(StateGeneric<'any, CA, RA, RRD, CLEAN>, PathOwned<P>), Result = RES>,
RES: ResFinalizer<E, RRD>,
RRD: ReqResDataMut,
{
Expand All @@ -60,31 +60,6 @@ where
let uri = req.rrd.uri();
let path = manage_path(path_defs, &uri).map_err(From::from)?;
let path_owned = PathOwned(P::from_str(path).map_err(Into::into)?);
self.0.call((State::new(ca, ra, req), path_owned)).await.finalize_response(req)
}
}

impl<CA, E, F, P, RA, RES, RRD> Endpoint<CA, E, RA, RRD>
for FnFutWrapper<(StateClean<'_, CA, RA, RRD>, PathOwned<P>), F>
where
E: From<crate::Error>,
P: FromStr,
P::Err: Into<crate::Error>,
F: for<'any> FnFut<(StateClean<'any, CA, RA, RRD>, PathOwned<P>), Result = RES>,
RES: ResFinalizer<E, RRD>,
RRD: ReqResDataMut,
{
#[inline]
async fn call(
&self,
ca: &mut CA,
path_defs: (u8, &[(&'static str, u8)]),
ra: &mut RA,
req: &mut Request<RRD>,
) -> Result<StatusCode, E> {
let uri = req.rrd.uri();
let path = manage_path(path_defs, &uri).map_err(From::from)?;
let path_owned = PathOwned(P::from_str(path).map_err(Into::into)?);
self.0.call((StateClean::new(ca, ra, req), path_owned)).await.finalize_response(req)
self.0.call((StateGeneric::new(ca, ra, req), path_owned)).await.finalize_response(req)
}
}
17 changes: 12 additions & 5 deletions wtx/src/http/server_framework/param_wrappers/path_str.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
http::{
server_framework::{param_wrappers::manage_path, Endpoint, ResFinalizer, StateClean},
server_framework::{param_wrappers::manage_path, Endpoint, ResFinalizer, StateGeneric},
Headers, ReqResDataMut, Request, StatusCode,
},
misc::{FnFut, FnFutWrapper},
Expand Down Expand Up @@ -35,12 +35,15 @@ where
}
}

impl<CA, E, F, RA, RES, RRD> Endpoint<CA, E, RA, RRD>
for FnFutWrapper<(StateClean<'_, CA, RA, (&mut RRD::Body, &mut Headers)>, PathStr<'_>), F>
impl<CA, E, F, RA, RES, RRD, const CLEAN: bool> Endpoint<CA, E, RA, RRD>
for FnFutWrapper<
(StateGeneric<'_, CA, RA, (&mut RRD::Body, &mut Headers), CLEAN>, PathStr<'_>),
F,
>
where
E: From<crate::Error>,
F: for<'any> FnFut<
(StateClean<'any, CA, RA, (&'any mut RRD::Body, &'any mut Headers)>, PathStr<'any>),
(StateGeneric<'any, CA, RA, (&'any mut RRD::Body, &'any mut Headers), CLEAN>, PathStr<'any>),
Result = RES,
>,
RES: ResFinalizer<E, RRD>,
Expand All @@ -57,6 +60,10 @@ where
let (body, headers, uri) = req.rrd.parts_mut();
let mut new_req = Request::_new(req.method, (body, headers), req.version);
let path = manage_path(path_defs, &uri).map_err(From::from)?;
self.0.call((StateClean::new(ca, ra, &mut new_req), PathStr(path))).await.finalize_response(req)
self
.0
.call((StateGeneric::new(ca, ra, &mut new_req), PathStr(path)))
.await
.finalize_response(req)
}
}
Loading

0 comments on commit a303991

Please sign in to comment.