Skip to main content

PathMapping

Struct PathMapping 

Source
pub struct PathMapping {
    pub bucket_segments: usize,
    pub bucket_separator: String,
    pub display_bucket_segments: usize,
}
Expand description

Defines how URL path segments map to internal bucket names.

Fields§

§bucket_segments: usize

Number of path segments that form the “bucket” portion. E.g., 2 for /{account}/{product}/...

§bucket_separator: String

Separator to join segments into an internal bucket name. E.g., “:” produces account:product.

§display_bucket_segments: usize

How many leading segments form the “display bucket” name for XML responses. E.g., 1 means <Name> shows just account.

Implementations§

Source§

impl PathMapping

Source

pub fn parse(&self, path: &str) -> Option<MappedPath>

Parse a URL path into a MappedPath.

The path is expected to start with /. Segments are split on /, and the first bucket_segments segments form the internal bucket name. Any remaining content becomes the key.

Returns None if there are fewer than bucket_segments non-empty segments.

Source

pub fn parse_bucket_name(&self, bucket_name: &str) -> Option<MappedPath>

Parse a bucket name (e.g., “account:product”) back into a MappedPath.

Used by MappedRegistry when it receives an already-mapped bucket name. Returns None if the bucket name does not split into exactly bucket_segments parts.

Source

pub fn rewrite_request(&self, path: &str, query: Option<&str>) -> RewriteResult

Rewrite an incoming request path and query string for the gateway.

Translates hierarchical paths into internal single-segment bucket paths:

  1. Path-based: if the path has enough segments, they are joined into a single bucket name. /{a}/{b}/{key}/{a:b}/{key}

  2. Prefix-based: if the path has fewer segments than required but the query string contains a list-type= param with a non-empty prefix=, the first component of the prefix is folded into the bucket name. /{a}?list-type=2&prefix=b/sub//{a:b}?list-type=2&prefix=sub/

  3. Pass-through: all other paths are returned unchanged. Route handlers or the gateway itself will handle them.

Source

pub fn rewrite_copy_source(&self, copy_source: &str) -> Option<String>

Rewrite an x-amz-copy-source header value into the gateway’s bucket namespace.

CopyObject names its source in a header rather than the URL, so rewrite_request never sees it and the gateway would otherwise resolve a client-facing name (alukach) that the registry has never heard of. Feed the result to RequestInfo::with_copy_source alongside the untouched header, which stays as sent for SigV4 verification.

/{a}/{b}/{key}[?versionId=id]/{a:b}/{key}[?versionId=id]. The key keeps its percent-encoding (only leading segments are rewritten), and the versionId suffix rides through. Returns None when the value has too few segments to map, leaving the caller to pass the header through unchanged.

Trait Implementations§

Source§

impl Clone for PathMapping

Source§

fn clone(&self) -> PathMapping

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PathMapping

Source§

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

Formats the value using the given formatter. Read more

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more