From 49a3a1b93d7a0b24193570023c372d5f5a3fd00c Mon Sep 17 00:00:00 2001 From: Rodrigo Santiago Date: Sat, 1 Jul 2023 18:28:54 -0400 Subject: [PATCH] Upgrade bitflags to v2.3 Include bitflags v2.3 in axum/Cargo.toml. Derive required macros for EventFlags and MethodFilter structs. Run cargo check / build / test to validate. Refs: #2066 --- axum/Cargo.toml | 2 +- axum/src/response/sse.rs | 5 +++-- axum/src/routing/method_filter.rs | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/axum/Cargo.toml b/axum/Cargo.toml index 7fa7af7ef5..905f50be6e 100644 --- a/axum/Cargo.toml +++ b/axum/Cargo.toml @@ -33,7 +33,7 @@ __private_docs = ["tower/full", "dep:tower-http"] [dependencies] async-trait = "0.1.67" axum-core = { path = "../axum-core", version = "0.3.4" } -bitflags = "1.0" +bitflags = "2.3" bytes = "1.0" futures-util = { version = "0.3", default-features = false, features = ["alloc"] } http = "0.2.9" diff --git a/axum/src/response/sse.rs b/axum/src/response/sse.rs index 3f849b9278..11739cc0fe 100644 --- a/axum/src/response/sse.rs +++ b/axum/src/response/sse.rs @@ -35,6 +35,7 @@ use axum_core::{ body::Body, response::{IntoResponse, Response}, }; +use bitflags::bitflags; use bytes::{BufMut, BytesMut}; use futures_util::{ ready, @@ -372,8 +373,8 @@ impl Event { } } -bitflags::bitflags! { - #[derive(Default)] +bitflags! { + #[derive(Default, Debug, Clone)] struct EventFlags: u8 { const HAS_DATA = 0b0001; const HAS_EVENT = 0b0010; diff --git a/axum/src/routing/method_filter.rs b/axum/src/routing/method_filter.rs index ca9b0c06e3..bdfc0d1843 100644 --- a/axum/src/routing/method_filter.rs +++ b/axum/src/routing/method_filter.rs @@ -7,6 +7,7 @@ use std::{ bitflags! { /// A filter that matches one or more HTTP methods. + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct MethodFilter: u16 { /// Match `DELETE` requests. const DELETE = 0b000000010; @@ -18,7 +19,7 @@ bitflags! { const OPTIONS = 0b000010000; /// Match `PATCH` requests. const PATCH = 0b000100000; - /// Match `POST` requests. + /// Match `POST` requests const POST = 0b001000000; /// Match `PUT` requests. const PUT = 0b010000000;