Skip to main content

ResourcePath

Trait ResourcePath 

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

    // Provided methods
    fn unquote(s: &str) -> Cow<'_, str> { ... }
    fn needs_unquote(path: &str) -> bool { ... }
}
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.

Source

fn needs_unquote(path: &str) -> bool

Returns false if unquote returns every segment of path unchanged, so the router can skip decoding them.

The default implementation returns true.

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§

impl ResourcePath for String

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§

fn needs_unquote(path: &str) -> bool

Source§

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

Source§

fn path(&self) -> &str

Source§

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

Source§

fn needs_unquote(path: &str) -> bool

Implementors§