Skip to main content

ResourcePath

Trait ResourcePath 

Source
pub trait ResourcePath {
    // Required method
    fn path(&self) -> &str;

    // Provided method
    fn unquote(s: &str) -> Cow<'_, str> { ... }
}
Expand description

A path source, e.g. a string or an urly::Url.

Required Methods§

Source

fn path(&self) -> &str

Full path.

Provided Methods§

Source

fn unquote(s: &str) -> Cow<'_, str>

Decodes a path segment before it is matched.

The path is split into segments on / before decoding, so a decoded segment may contain /. The default implementation returns the segment unchanged.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ResourcePath for &str

Source§

fn path(&self) -> &str

Source§

impl ResourcePath for String

Source§

fn path(&self) -> &str

Source§

impl ResourcePath for Url

Path segments are percent-decoded, escapes that would not decode to valid utf-8 are kept percent-encoded.

Segments are decoded after the path is split on /, so parameter values can contain any character, including / and %. For example /files/..%2F..%2Fetc matches /files/{name} with name set to ../../etc. Such values must be validated before they are used, e.g. as a file system path.

Source§

fn path(&self) -> &str

Source§

fn unquote(s: &str) -> Cow<'_, str>

Source§

impl<T> ResourcePath for &T
where T: ResourcePath,

Source§

fn path(&self) -> &str

Implementors§