hyperlane/route/
enum.rs

1use crate::*;
2
3/// Represents the different types of segments that can make up a route path.
4///
5/// A route path is parsed into a sequence of these segments. For example, the path
6/// `/users/:id/posts` would be broken down into `Static("users")`, `Dynamic("id")`,
7/// and `Static("posts")`.
8#[derive(Clone, CustomDebug, DisplayDebug)]
9pub enum RouteSegment {
10    /// A static, literal segment of a path.
11    /// This must be an exact match. For example, in `/users/active`, "users" and "active"
12    /// are both static segments.
13    Static(String),
14    /// A dynamic segment that captures a value from the path.
15    /// It is denoted by a colon prefix. The captured value
16    /// is stored as a parameter in the request context.
17    Dynamic(String),
18    /// A segment that is matched against a regular expression.
19    /// This allows for more complex and flexible routing logic. The first element is the parameter
20    /// name, and the second is the compiled `Regex` object.
21    Regex(String, Regex),
22}