Struct ciruela::VPath
[−]
[src]
pub struct VPath(_);
Virtual path for uploading images
Basically it's an Arc<PathBuf>
so it clones cheaply, but also has
convenience methods for extracting features specific to our
virtual paths.
The anatomy of the virtual path:
/[key]/[suffix]
Type asserts on the presence of the key
and that the path is absolute.
Suffix might be of arbitrary length including zero.
Methods
impl VPath
[src]
pub fn key(&self) -> &str
[src]
Returns a key
, i.e. the first component
pub fn key_vpath(&self) -> VPath
[src]
Returns a key
, i.e. the first component
pub fn level(&self) -> usize
[src]
Returns a level of a directory
Level is number of path components not counting a key
pub fn parent_rel(&self) -> &Path
[src]
Return parent path relative to a key
Panics
Panics if the directory contains only a key (has single component)
pub fn parent(&self) -> VPath
[src]
Return virtual path of the directory
Panics
Panics if the directory contains only a key (has single component)
pub fn suffix(&self) -> &Path
[src]
The path relative to the key
pub fn final_name(&self) -> &str
[src]
pub fn join<P: AsRef<Path>>(&self, path: P) -> VPath
[src]
Join path to the virtual path
Panics
Panics if suffix is invalid: empty, root or has parent ..
components
pub fn from<T: Into<PathBuf>>(t: T) -> VPath
[src]
Create a virtual path from path
Panics
Panics if path is not absolute or doesn't contain directory components
pub fn try_from<T: Into<PathBuf>>(t: T) -> Result<VPath, PathError>
[src]
Create a virtual path from path
pub fn matches_basedir(&self, base_dir: &VPath) -> bool
[src]
Check this directory belongs to the specified basedir
Technically the same, but faster version of:
self.parent() == base_dir
Trait Implementations
impl PartialEq for VPath
[src]
fn eq(&self, __arg_0: &VPath) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &VPath) -> bool
[src]
This method tests for !=
.
impl Eq for VPath
[src]
impl Hash for VPath
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd for VPath
[src]
fn partial_cmp(&self, __arg_0: &VPath) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &VPath) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &VPath) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &VPath) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &VPath) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for VPath
[src]
fn cmp(&self, __arg_0: &VPath) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Clone for VPath
[src]
fn clone(&self) -> VPath
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Borrow<Path> for VPath
[src]
impl AsRef<Path> for VPath
[src]
impl<'de> Deserialize<'de> for VPath
[src]
fn deserialize<D>(deserializer: D) -> Result<VPath, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Display for VPath
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more