IntoResourcePath

Trait IntoResourcePath 

Source
pub trait IntoResourcePath {
    // Required method
    fn into_abs_path(self) -> Result<ResourcePath, Error>;
}
Expand description

Convert common input types into a normalized ResourcePath (absolute).

This trait is intentionally implemented for the “obvious” path-like things:

  • ResourcePath / &ResourcePath (pass-through / clone)
  • &str, String, and &String

It is used by session-scoped storage methods (SessionStorage) that act as the current user and therefore do not need a PublicKey.

§Examples

fn takes_abs<P: IntoResourcePath>(p: P) -> pubky::Result<ResourcePath> {
    p.into_abs_path()
}

let a = takes_abs("/pub/my-cool-app/file")?;
let b = takes_abs("pub/my-cool-app/file")?;
assert_eq!(a, b);

Required Methods§

Source

fn into_abs_path(self) -> Result<ResourcePath, Error>

Convert into a validated, normalized absolute ResourcePath.

§Errors
  • Returns Error::Request if the input cannot be normalized into a valid absolute path.

Implementations on Foreign Types§

Source§

impl IntoResourcePath for &str

Source§

impl IntoResourcePath for &String

Source§

impl IntoResourcePath for String

Implementors§