rocket/route/segment.rs
1#[derive(Debug, Clone)]
2pub struct Segment {
3 /// The name of the parameter or just the static string.
4 pub value: String,
5 /// This is a `<a>`.
6 pub dynamic: bool,
7 /// This is a `<a..>`.
8 pub dynamic_trail: bool,
9}
10
11impl Segment {
12 pub fn from(segment: &crate::http::RawStr) -> Self {
13 let mut value = segment;
14 let mut dynamic = false;
15 let mut dynamic_trail = false;
16
17 if segment.starts_with('<') && segment.ends_with('>') {
18 dynamic = true;
19 value = &segment[1..(segment.len() - 1)];
20
21 if value.ends_with("..") {
22 dynamic_trail = true;
23 value = &value[..(value.len() - 2)];
24 }
25 }
26
27 Segment { value: value.to_string(), dynamic, dynamic_trail }
28 }
29}