[][src]Struct rocket::http::uri::Segments

pub struct Segments<'a>(pub &'a str);

Iterator over the segments of an absolute URI path. Skips empty segments.

Examples

use rocket::http::uri::Origin;

let uri = Origin::parse("/a/////b/c////////d").unwrap();
let segments = uri.segments();
for (i, segment) in segments.enumerate() {
    match i {
        0 => assert_eq!(segment, "a"),
        1 => assert_eq!(segment, "b"),
        2 => assert_eq!(segment, "c"),
        3 => assert_eq!(segment, "d"),
        _ => panic!("only four segments")
    }
}

Implementations

impl<'a> Segments<'a>[src]

pub fn into_path_buf(
    self,
    allow_dotfiles: bool
) -> Result<PathBuf, SegmentError>
[src]

Creates a PathBuf from a Segments iterator. The returned PathBuf is percent-decoded. If a segment is equal to "..", the previous segment (if any) is skipped.

For security purposes, if a segment meets any of the following conditions, an Err is returned indicating the condition met:

  • Decoded segment starts with any of: '*'
  • Decoded segment ends with any of: :, >, <
  • Decoded segment contains any of: /
  • On Windows, decoded segment contains any of: \
  • Percent-encoding results in invalid UTF8.

Additionally, if allow_dotfiles is false, an Err is returned if the following condition is met:

  • Decoded segment starts with any of: . (except ..)

As a result of these conditions, a PathBuf derived via FromSegments is safe to interpolate within, or use as a suffix of, a path without additional checks.

Trait Implementations

impl<'a> Clone for Segments<'a>[src]

impl<'a> Debug for Segments<'a>[src]

impl<'a> FromSegments<'a> for Segments<'a>[src]

type Error = !

The associated error to be returned when parsing fails.

impl<'a> Iterator for Segments<'a>[src]

type Item = &'a str

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Segments<'a>

impl<'a> Send for Segments<'a>

impl<'a> Sync for Segments<'a>

impl<'a> Unpin for Segments<'a>

impl<'a> UnwindSafe for Segments<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, I> AsResult<T, I> for T where
    I: Input
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoCollection<T> for T[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<I> IteratorRandom for I where
    I: Iterator
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,