Skip to main content

Location

Struct Location 

Source
pub struct Location { /* private fields */ }
Available on crate feature s3 only.
Expand description

The place of a bucket repository: its address, the region of the signature, the endpoint, and the addressing style.

Location::new applies these rules:

  • With no endpoint, the endpoint is AWS: https://s3.REGION.amazonaws.com.
  • An endpoint is an http:// or an https:// URL with no path, no query, no fragment, and no userinfo. One trailing / is allowed.
  • Path style puts the bucket in the path: ENDPOINT/BUCKET/PREFIX/.... Virtual-host style puts the bucket in the host: https://BUCKET.HOST/PREFIX/....
  • The default style is virtual-host for AWS, and path for an endpoint of the caller. A bucket name that holds a . gets path style by default. A style that the caller sets wins.
  • Virtual-host style is refused for a bucket name that holds a . over https, because the certificate of the endpoint does not match such a host. It is also refused for an endpoint whose host is an IP address.

An http:// endpoint needs allow_cleartext_credentials in the options of the bucket client, because the signature is a credential.

Implementations§

Source§

impl Location

Source

pub fn new( address: Address, region: &str, endpoint: Option<&str>, addressing: Option<Addressing>, ) -> Result<Location>

Returns the location of address with the region region, the endpoint endpoint, and the addressing style addressing.

None for endpoint is AWS, and None for addressing is the default style. Location states the rules.

§Errors

Error::InvalidInput in these cases:

  • region is refused by SigV4::new
  • check_base_url refuses endpoint, or endpoint has a path. The message holds no userinfo.
  • virtual-host style with a bucket name that holds a . over https
  • virtual-host style with an endpoint whose host is an IP address.
Source

pub fn from_resolved(address: Address, resolved: &Resolved) -> Result<Location>

Returns the location of address with the region, the endpoint, and the addressing style of resolved.

§Errors

The errors of Location::new. A refused endpoint names the source of the endpoint.

Source

pub fn address(&self) -> &Address

Returns the address of the bucket repository.

Source

pub fn region(&self) -> &str

Returns the region of the signature.

Source

pub fn addressing(&self) -> Addressing

Returns the addressing style in use.

Source

pub fn endpoint(&self) -> &str

Returns the endpoint in use, with no trailing /: the endpoint of the caller, or https://s3.REGION.amazonaws.com.

Source

pub fn bucket_url(&self) -> String

Returns the URL of the bucket: ENDPOINT/BUCKET for path style, and SCHEME://BUCKET.HOST[:PORT] for virtual-host style.

The bucket client sends each request under this URL.

Source

pub fn repository_url(&self) -> String

Returns the base URL of the repository: the URL of the bucket, then / and the prefix if the address has one.

Trait Implementations§

Source§

impl Clone for Location

Source§

fn clone(&self) -> Self

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 Location

Source§

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

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

impl Eq for Location

Source§

impl PartialEq for Location

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Location

Auto Trait Implementations§

§

impl Forget for Location

§

impl Freeze for Location
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for Location

§

impl RefUnwindSafe for Location

§

impl Send for Location
where RawVecInner: Send,

§

impl Sync for Location
where RawVecInner: Sync,

§

impl Unpin for Location
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Location

§

impl UnwindSafe for Location
where RawVecInner: UnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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