actix_web_location/
lib.rs

1//! Location determination for Actix Web applications.
2
3#![warn(missing_docs)]
4#![forbid(unsafe_code)]
5
6/* This is a mess, but it makes the rest of the crate tidier. Only include this
7 * modules and uses if exactly one of v3 or v4 is specified. */
8
9#[cfg(any(
10    all(feature = "actix-web-v3", not(feature = "actix-web-v4")),
11    all(not(feature = "actix-web-v3"), feature = "actix-web-v4")
12))]
13mod domain;
14#[cfg(any(
15    all(feature = "actix-web-v3", not(feature = "actix-web-v4")),
16    all(not(feature = "actix-web-v3"), feature = "actix-web-v4")
17))]
18mod error;
19#[cfg(any(
20    all(feature = "actix-web-v3", not(feature = "actix-web-v4")),
21    all(not(feature = "actix-web-v3"), feature = "actix-web-v4")
22))]
23mod extractors;
24#[cfg(any(
25    all(feature = "actix-web-v3", not(feature = "actix-web-v4")),
26    all(not(feature = "actix-web-v3"), feature = "actix-web-v4")
27))]
28pub mod providers;
29
30#[cfg(any(
31    all(feature = "actix-web-v3", not(feature = "actix-web-v4")),
32    all(not(feature = "actix-web-v3"), feature = "actix-web-v4")
33))]
34pub use crate::{domain::Location, error::Error, extractors::LocationConfig, providers::Provider};
35
36/* The two stanzas below provide nicer error messages if not exactly one of v3
37 * and v4 are enabled. They aren't hard errors so that this crate's CI still
38 * works, but because nothing will be defined above it will be a hard error for
39 * any downstream crates. This provides a nicer message to debug what's happening.
40 * It uses deprecation notices because this is the only way to generate compiler
41 * warnings.
42 * */
43
44/* If both v3 and v4 are enabled at the same time, generate a compiler warning. */
45#[cfg(all(feature = "actix-web-v3", feature = "actix-web-v4"))]
46mod warning {
47    #![allow(dead_code)]
48
49    #[deprecated(
50        note = "Only one of actix-web-v3 and actix-web-v4 can be used at once. This entire crate will be disabled."
51    )]
52    fn actix_web_location_must_specify_one_version_of_actix_web() {}
53    fn trigger_warning() {
54        actix_web_location_must_specify_one_version_of_actix_web()
55    }
56}
57
58/* If neither v3 or v4 are enabled at the same time, generate a compiler warning. */
59#[cfg(not(any(feature = "actix-web-v3", feature = "actix-web-v4")))]
60mod warning {
61    #![allow(dead_code)]
62
63    #[deprecated(note = "Exactly of actix-web-v3 or actix-web-v4 must be specified")]
64    fn actix_web_location_must_specify_one_version_of_actix_web() {}
65    fn trigger_warning() {
66        actix_web_location_must_specify_one_version_of_actix_web()
67    }
68}