pub struct CompiledCors { /* private fields */ }Expand description
Precompiled zero-allocation CORS policy stored inside CorsPlugin.
Implementations§
Source§impl CompiledCors
Inherent implementation of CompiledCors.
impl CompiledCors
Inherent implementation of CompiledCors.
Sourcepub fn compile(config: CorsConfig) -> Self
pub fn compile(config: CorsConfig) -> Self
Precompiles a CorsConfig into zero-allocation header values.
§Arguments
CorsConfig- Source CORS configuration.
§Returns
Self- Precompiled policy ready for hot-path request evaluation.
Sourcepub fn get_config(&self) -> &CorsConfig
pub fn get_config(&self) -> &CorsConfig
Sourcepub fn resolve_origin<'a>(&self, origin: &'a str) -> Option<&'a str>
pub fn resolve_origin<'a>(&self, origin: &'a str) -> Option<&'a str>
Resolves the Access-Control-Allow-Origin header value for an incoming Origin.
Never returns "*" when allow_credentials is true, satisfying the Fetch specification.
§Arguments
&'a str- IncomingOriginheader value.
§Returns
Option<&'a str>- Header value to emit, orNonewhen the origin is rejected.
Sourcepub fn apply_request(&self, ctx: &mut Context) -> bool
pub fn apply_request(&self, ctx: &mut Context) -> bool
Sourcepub fn ensure_response_headers(&self, ctx: &mut Context)
pub fn ensure_response_headers(&self, ctx: &mut Context)
Re-applies CORS headers on the response path if a route cleared response headers.
§Arguments
&mut Context- Active request/response context.
Trait Implementations§
Source§impl Clone for CompiledCors
impl Clone for CompiledCors
Auto Trait Implementations§
impl !RefUnwindSafe for CompiledCors
impl !UnwindSafe for CompiledCors
impl Forget for CompiledCors
impl Freeze for CompiledCorswhere
PhantomData<fn() -> XxHash3_64>: Freeze,
*const u8 is !null: Freeze,
PhantomData<(String, ())>: Freeze,
PhantomData<String>: Freeze,
*const ArcInner<dyn Fn(&str) -> bool + Sync + Send> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&str) -> bool + Sync + Send>>: Freeze,
*const [String] is !null: Freeze,
PhantomData<[String]>: Freeze,
PhantomData<u8>: Freeze,
*const [u8] is !null: Freeze,
PhantomData<[u8]>: Freeze,
impl Move for CompiledCors
impl Send for CompiledCors
impl Sync for CompiledCors
impl Unpin for CompiledCors
impl UnsafeUnpin for CompiledCorswhere
PhantomData<fn() -> XxHash3_64>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, ())>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
*const ArcInner<dyn Fn(&str) -> bool + Sync + Send> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&str) -> bool + Sync + Send>>: UnsafeUnpin,
*const [String] is !null: UnsafeUnpin,
PhantomData<[String]>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const [u8] is !null: UnsafeUnpin,
PhantomData<[u8]>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more