[go: up one dir, main page]

rocket 0.5.1

Web framework with a focus on usability, security, extensibility, and speed.
Documentation
use crate::http::RawStr;

#[derive(Debug, Clone)]
pub struct Segment {
    pub value: String,
    pub dynamic: bool,
    pub trailing: bool,
}

impl Segment {
    pub fn from(segment: &RawStr) -> Self {
        let mut value = segment;
        let mut dynamic = false;
        let mut trailing = false;

        if segment.starts_with('<') && segment.ends_with('>') {
            dynamic = true;
            value = &segment[1..(segment.len() - 1)];

            if value.ends_with("..") {
                trailing = true;
                value = &value[..(value.len() - 2)];
            }
        }

        Segment { value: value.to_string(), dynamic, trailing }
    }
}