S3PathBuf

Struct S3PathBuf 

Source
pub struct S3PathBuf { /* private fields */ }
Expand description

An owned S3 storage path.

Implementations§

Source§

impl S3PathBuf

Source

pub fn new() -> Self

Creates an empty S3 path. Call join or push to extend it with additional path segments.

Source

pub fn try_from<C: Into<Cow<'static, str>>, I: IntoIterator<Item = C>>( components: I, ) -> Result<Self, InvalidS3PathComponent>

Validates and adds all components to the returned S3PathBuf.

NO component is parsed for slashes (‘/’) to be split up further!

§Errors

Returns Err when any given component

  • is empty
  • contains characters other than: ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’
  • is equal to . or ..
Source

pub fn try_from_str( string: impl AsRef<str>, ) -> Result<Self, InvalidS3PathComponent>

Splits string at each occurrence of a /, then validates and add all components to the returned S3PathBuf.

Multiple consecutive slashes, as in “foo//bar”, are treated as one.

§Errors

Returns Err when any component read

  • contains characters other than: ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’
  • is equal to . or ..
Source

pub fn extend( &mut self, addition: impl Into<Cow<'static, str>>, ) -> Result<&mut Self, InvalidS3PathComponent>

Extend the last component of the path, if there is one, with [addition].

If this path is empty, pushes [addition] the initial path component instead.

use s3_path::S3PathBuf;
let mut file = S3PathBuf::try_from_str("my/file").unwrap();
file.extend(".txt").unwrap();
§Errors

Returns Err when the given component

  • is empty
  • contains characters other than: ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’
  • is equal to . or ..
Source

pub fn push( &mut self, component: impl Into<Cow<'static, str>>, ) -> Result<&mut Self, InvalidS3PathComponent>

Adds component to the path after validating it.

§Errors

Returns Err when the given component

  • is empty
  • contains characters other than: ascii alphanumeric characters, ‘-’, ‘_’ and ‘.’
  • is equal to . or ..
Source

pub fn join( &self, component: impl Into<Cow<'static, str>>, ) -> Result<Self, InvalidS3PathComponent>

Clones this path and pushes [component] onto it.

Leaves this path untouched. Great for quickly creating multiple paths having the same root.

Source

pub fn as_path(&self) -> &S3Path<'_>

Source

pub fn pop(&mut self) -> Option<Cow<'static, str>>

Pop the last component from this path, returning true if a component was removed

Methods from Deref<Target = S3Path<'static>>§

Source

pub fn to_owned(&'i self) -> S3PathBuf

Converts to an owned S3PathBuf.

Source

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 ..
Source

pub fn is_empty(&'i self) -> bool

Returns true if this path has no components.

Source

pub fn len(&'i self) -> usize

Returns the number of components in this path.

Source

pub fn components(&'i self) -> impl Iterator<Item = &'i str>

Returns an iterator over the components of this path.

Source

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.

Source

pub fn last(&'i self) -> Option<&'i str>

Returns the last component of this path, or None if the path is empty.

Source

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.

Source

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> AsRef<S3Path<'i>> for S3PathBuf

Source§

fn as_ref(&self) -> &S3Path<'i>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<S3PathBuf> for S3PathBuf

Source§

fn as_ref(&self) -> &S3PathBuf

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for S3PathBuf

Source§

fn clone(&self) -> S3PathBuf

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for S3PathBuf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for S3PathBuf

Source§

fn default() -> S3PathBuf

Returns the “default value” for a type. Read more
Source§

impl Deref for S3PathBuf

Source§

type Target = S3Path<'static>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for S3PathBuf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'i> PartialEq<&&S3Path<'i>> for S3PathBuf

Allow comparisons between S3Path and S3PathBuf.

Source§

fn eq(&self, other: &&&S3Path<'i>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'i> PartialEq<&S3Path<'i>> for S3PathBuf

Allow comparisons between S3Path and S3PathBuf.

Source§

fn eq(&self, other: &&S3Path<'i>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<S3Path<'_>> for S3PathBuf

Allow comparisons between S3Path and S3PathBuf.

Source§

fn eq(&self, other: &S3Path<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<S3PathBuf> for &&S3Path<'_>

Allow comparisons between S3Path and S3PathBuf.

Source§

fn eq(&self, other: &S3PathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<S3PathBuf> for &S3Path<'_>

Allow comparisons between S3Path and S3PathBuf.

Source§

fn eq(&self, other: &S3PathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<S3PathBuf> for S3Path<'_>

Allow comparisons between S3Path and S3PathBuf.

Source§

fn eq(&self, other: &S3PathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for S3PathBuf

Source§

fn eq(&self, other: &S3PathBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for S3PathBuf

Source§

impl StructuralPartialEq for S3PathBuf

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.