~/selfhut

selfhut/src/utils/own_pathbuf.rs -rw-r--r-- 472 B
7dbdfabf — arthurmelton I did alot, I should have commited more 2 years ago
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::path::PathBuf;
use rocket::http::uri::{Segments, error::PathError, fmt::Path};
use rocket::request::FromSegments;

pub struct PathBufWithDotfiles(PathBuf);

impl FromSegments<'_> for PathBufWithDotfiles {
    type Error = PathError;

    fn from_segments(segments: Segments<'_, Path>) -> Result<Self, Self::Error> {
        segments.to_path_buf(true).map(Self)
    }
}

impl PathBufWithDotfiles {
    pub fn get(&self) -> PathBuf {
        self.0.clone()
    }
}