param.rs
Rust test marker or harnessimports http::StatusCode
SHA-256ba92bbeea27e57000906bcace0efe1f5be3d446295fa487e5539ee2a2a6d68df
MaleculeMd₂(InPa)
Evidence
1use std;
2use std::ops::Index;
3use std::path::PathBuf;
4use std::rc::Rc;
5use std::str::FromStr;
6
7use http::StatusCode;
8use smallvec::SmallVec;
9
10use error::{InternalError, ResponseError, UriSegmentError};
11use uri::Url;
12
13/// A trait to abstract the idea of creating a new instance of a type from a
14/// path parameter.
15pub trait FromParam: Siz …
19:2… /// Parses a string `s` to return a value of this type.
20 fn from_param(s: &str) -> Result<Self, Self::Err>;
21}
22
23#[derive(Debug, Clone)]
24pu …
88:13… et(&self, key: &str) -> Option<&str> {
89 for item in self.segments.iter() {
90 if key == item.0.as_str() {
91 return …
193:45… ition met:
194///
195/// * Decoded segment starts with any of: `.` (except `..`), `*`
196/// * Decoded segment ends with any of: `:`, `>`, `<`
197/// …
264:11… std::net::SocketAddrV4);
265FROM_STR!(std::net::SocketAddrV6);
266
267#[cfg(test)]
268mod tests {
269 use super::*;
270 use std::iter::FromIterator;
271
272 #[test]
273 fn test_path_buf() {
274 assert_eq!(
275 PathBuf::from_param("/test/.tt"),
276 Err(UriSegmentError::BadStart('.') …