Compare commits

..

4 Commits

Author SHA1 Message Date
Michael Pfaff 20ca75a376
Bump version 2022-05-30 13:38:24 -04:00
Michael Pfaff f14bd9d4c2
Update nrid dependency 2022-05-30 13:38:03 -04:00
Michael Pfaff 86d3cefb00
Fix tide 0.17 version restriction 2022-05-03 12:03:34 -04:00
Michael Pfaff 4846d22dec
Support tide 0.17 2022-05-03 11:58:15 -04:00
2 changed files with 25 additions and 30 deletions

View File

@ -1,13 +1,13 @@
[package] [package]
name = "tide_tracing" name = "tide_tracing"
version = "0.7.0" version = "0.6.4"
authors = ["Michael Pfaff <michael@pfaff.dev>"] authors = ["Michael Pfaff <michael@pfaff.dev>"]
edition = "2021" edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
nrid = { git = "https://git.pfaff.dev/michael/nrid.rs.git", tag = "v0.2.0", default-features = false } nrid = { git = "https://git.pfaff.dev/michael/nrid.rs.git", tag = "v0.3.0", default-features = false }
tide = { version = "0.16", default-features = false } tide = { version = ">=0.16, <=0.17.0-beta.1", default-features = false }
tracing = "0.1" tracing = "0.1"
async-trait = "0.1" async-trait = "0.1"
num_enum = "0.7" num_enum = "0.5"

View File

@ -1,3 +1,5 @@
#![feature(const_trait_impl)]
#[macro_use] #[macro_use]
extern crate tracing; extern crate tracing;
@ -27,47 +29,38 @@ pub struct ReqComps(u8);
impl ReqComps { impl ReqComps {
#[inline] #[inline]
pub const fn contains(self, mask: ReqComp) -> bool { pub const fn contains(self, mask: ReqComp) -> bool {
self.bitand_one(mask).0 == mask as u8 (self & mask).0 == mask as u8
} }
#[inline] #[inline]
pub const fn contains_all(self, mask: Self) -> bool { pub const fn contains_all(self, mask: ReqComps) -> bool {
self.bitand_self(mask).0 == mask.0 self & mask == mask
}
#[inline]
const fn bitand_self(self, rhs: Self) -> Self {
Self((self.0 as u8) & (rhs.0 as u8))
}
#[inline]
const fn bitand_one(self, rhs: ReqComp) -> Self {
Self((self.0 as u8) & (rhs as u8))
} }
} }
impl Default for ReqComps { impl const Default for ReqComps {
#[inline] #[inline]
fn default() -> Self { fn default() -> Self {
Self(0) Self(0)
} }
} }
impl From<ReqComp> for ReqComps { // unfortunately, the automatic Into impl will not be const.
impl const From<ReqComp> for ReqComps {
#[inline] #[inline]
fn from(comp: ReqComp) -> Self { fn from(comp: ReqComp) -> Self {
Self(comp as u8) Self(comp as u8)
} }
} }
impl core::cmp::PartialEq for ReqComps { impl const core::cmp::PartialEq for ReqComps {
#[inline] #[inline]
fn eq(&self, comp: &Self) -> bool { fn eq(&self, comp: &Self) -> bool {
self.0 == comp.0 self.0 == comp.0
} }
} }
impl core::ops::BitOr for ReqComp { impl const core::ops::BitOr for ReqComp {
type Output = ReqComps; type Output = ReqComps;
#[inline] #[inline]
@ -76,16 +69,16 @@ impl core::ops::BitOr for ReqComp {
} }
} }
impl core::ops::BitOr for ReqComps { impl const core::ops::BitOr for ReqComps {
type Output = ReqComps; type Output = ReqComps;
#[inline] #[inline]
fn bitor(self, rhs: Self) -> Self::Output { fn bitor(self, rhs: Self) -> Self::Output {
ReqComps(self.0 | rhs.0) ReqComps((self.0 as u8) | (rhs.0 as u8))
} }
} }
impl core::ops::BitOr<ReqComp> for ReqComps { impl const core::ops::BitOr<ReqComp> for ReqComps {
type Output = ReqComps; type Output = ReqComps;
#[inline] #[inline]
@ -94,6 +87,7 @@ impl core::ops::BitOr<ReqComp> for ReqComps {
} }
} }
// TODO make `const` when is "stable" #57349 <https://github.com/rust-lang/rust/issues/57349>
impl core::ops::BitOrAssign for ReqComps { impl core::ops::BitOrAssign for ReqComps {
#[inline] #[inline]
fn bitor_assign(&mut self, rhs: ReqComps) { fn bitor_assign(&mut self, rhs: ReqComps) {
@ -101,6 +95,7 @@ impl core::ops::BitOrAssign for ReqComps {
} }
} }
// TODO make `const` when is "stable" #57349 <https://github.com/rust-lang/rust/issues/57349>
impl core::ops::BitOrAssign<ReqComp> for ReqComps { impl core::ops::BitOrAssign<ReqComp> for ReqComps {
#[inline] #[inline]
fn bitor_assign(&mut self, rhs: ReqComp) { fn bitor_assign(&mut self, rhs: ReqComp) {
@ -108,7 +103,7 @@ impl core::ops::BitOrAssign<ReqComp> for ReqComps {
} }
} }
impl core::ops::BitAnd for ReqComp { impl const core::ops::BitAnd for ReqComp {
type Output = ReqComps; type Output = ReqComps;
#[inline] #[inline]
@ -117,21 +112,21 @@ impl core::ops::BitAnd for ReqComp {
} }
} }
impl core::ops::BitAnd for ReqComps { impl const core::ops::BitAnd for ReqComps {
type Output = ReqComps; type Output = ReqComps;
#[inline] #[inline]
fn bitand(self, rhs: Self) -> Self::Output { fn bitand(self, rhs: Self) -> Self::Output {
self.bitand_self(rhs) ReqComps((self.0 as u8) & (rhs.0 as u8))
} }
} }
impl core::ops::BitAnd<ReqComp> for ReqComps { impl const core::ops::BitAnd<ReqComp> for ReqComps {
type Output = ReqComps; type Output = ReqComps;
#[inline] #[inline]
fn bitand(self, rhs: ReqComp) -> Self::Output { fn bitand(self, rhs: ReqComp) -> Self::Output {
self.bitand_one(rhs) ReqComps((self.0 as u8) & (rhs as u8))
} }
} }
@ -156,7 +151,7 @@ pub struct LogMiddleware {
pub components: ReqComps, pub components: ReqComps,
} }
impl Default for LogMiddleware { impl const Default for LogMiddleware {
#[inline] #[inline]
fn default() -> Self { fn default() -> Self {
Self { Self {