~/selfhut

selfhut/src/utils/own_pathbuf.rs -rw-r--r-- 472 B
00c0a257 — Arthur Melton format code 2 years ago

            
00c0a257 Arthur Melton
7dbdfabf arthurmelton
00c0a257 Arthur Melton
7dbdfabf arthurmelton















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use rocket::http::uri::{error::PathError, fmt::Path, Segments};
use rocket::request::FromSegments;
use std::path::PathBuf;

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()
    }
}