gotham/router/tree/segment.rs
1//! Defines `SegmentType` for `Tree`.
2use std::collections::HashMap;
3
4use crate::helpers::http::PercentDecoded;
5use crate::router::tree::regex::ConstrainedSegmentRegex;
6
7/// Mapping of segment names into the collection of values for that segment.
8pub type SegmentMapping<'r> = HashMap<&'r str, Vec<&'r PercentDecoded>>;
9
10/// Indicates the type of segment which is being represented by this Node.
11#[derive(Clone, Eq, PartialEq, Ord, PartialOrd)]
12pub enum SegmentType {
13 /// Is matched exactly (string equality) to the segment for incoming request paths.
14 ///
15 /// Unlike all other `SegmentTypes`, values determined to be associated with this segment
16 /// within a `Request` path are **not** stored within `State`.
17 Static,
18
19 /// Uses the supplied regex to determine match against incoming request paths.
20 Constrained {
21 /// Regex used to match against a single segment of a request path.
22 regex: Box<ConstrainedSegmentRegex>,
23 },
24
25 /// Matches any corresponding segment for incoming request paths.
26 Dynamic,
27
28 /// Matches multiple path segments until the end of the request path or until a child
29 /// segment of the above defined types is found.
30 Glob,
31}