pub struct S3Path<'i>(/* private fields */);
Expand description
A borrowed, unsized S3 storage path.
Implementations§
Source§impl<'i> S3Path<'i>
impl<'i> S3Path<'i>
Sourcepub fn new(
components: &'i [Cow<'i, str>],
) -> Result<&'i S3Path<'i>, InvalidS3PathComponent>
pub fn new( components: &'i [Cow<'i, str>], ) -> Result<&'i S3Path<'i>, InvalidS3PathComponent>
Create a new S3Path
from a slice of static components
.
§Errors
Returns Err
when any given component
- is empty
- contains characters other than: ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’
- is equal to
.
or..
Sourcepub fn join<C: Into<Cow<'static, str>>>(
&self,
component: C,
) -> Result<S3PathBuf, InvalidS3PathComponent>
pub fn join<C: Into<Cow<'static, str>>>( &self, component: C, ) -> Result<S3PathBuf, InvalidS3PathComponent>
Converts to an owned S3PathBuf
and appends component
to it after validating it.
§Errors
Returns Err
when the given component
- is empty
- contains characters other than: ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’
- is equal to
.
or..
Sourcepub fn components(&'i self) -> impl Iterator<Item = &'i str>
pub fn components(&'i self) -> impl Iterator<Item = &'i str>
Returns an iterator over the components of this path.
Sourcepub fn get(&'i self, index: usize) -> Option<&'i str>
pub fn get(&'i self, index: usize) -> Option<&'i str>
Returns the component at the given index, or None if the index is out of bounds.
Sourcepub fn last(&'i self) -> Option<&'i str>
pub fn last(&'i self) -> Option<&'i str>
Returns the last component of this path, or None if the path is empty.
Sourcepub fn parent(&'i self) -> Option<&'i S3Path<'i>>
pub fn parent(&'i self) -> Option<&'i S3Path<'i>>
Returns all but the last component of this path, or None if the path is empty.
Sourcepub fn to_std_path_buf(&self) -> PathBuf
pub fn to_std_path_buf(&self) -> PathBuf
Convert this S3 path to a std::path::PathBuf
, allowing you to use this S3 path as a
system file path.
Our strong guarantee that path components only consist of ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’ and that no path traversal components (‘.’ and ‘..’) are allowed, makes this a safe operation.
Trait Implementations§
Source§impl<'i> PartialEq<&&S3Path<'i>> for S3PathBuf
Allow comparisons between S3Path
and S3PathBuf
.
impl<'i> PartialEq<&&S3Path<'i>> for S3PathBuf
Allow comparisons between S3Path
and S3PathBuf
.