Struct EndPoint

Source
#[non_exhaustive]
pub struct EndPoint { /* private fields */ }
Expand description

§OSS 的可用区

aliyun docs

Implementations§

Source§

impl EndPoint

Source

pub const CN_HANGZHOU: Self

杭州

Source

pub const HANGZHOU: Self = Self::CN_HANGZHOU

杭州

Source

pub const CN_SHANGHAI: Self

上海

Source

pub const SHANGHAI: Self = Self::CN_SHANGHAI

上海

Source

pub const CN_QINGDAO: Self

青岛

Source

pub const QINGDAO: Self = Self::CN_QINGDAO

青岛

Source

pub const CN_BEIJING: Self

北京

Source

pub const BEIJING: Self = Self::CN_BEIJING

北京

Source

pub const CN_ZHANGJIAKOU: Self = Self::ZHANGJIAKOU

张家口

Source

pub const ZHANGJIAKOU: Self

张家口

Source

pub const CN_HONGKONG: Self

香港

Source

pub const HONGKONG: Self = Self::CN_HONGKONG

香港

Source

pub const CN_SHENZHEN: Self

深圳

Source

pub const SHENZHEN: Self = Self::CN_SHENZHEN

深圳

Source

pub const US_WEST_1: Self

UsWest1

Source

pub const US_EAST_1: Self

UsEast1

Source

pub const AP_SOUTH_EAST_1: Self

ApSouthEast1

Source§

impl<'a> EndPoint

Source

pub fn from_static(url: &'a str) -> Self

通过字符串字面值初始化 endpoint

例如

EndPoint::from_static("qingdao");
Source

pub const unsafe fn from_static2(url: &'static str) -> Self

§Safety

用于静态定义其他可用区

Source

pub fn new(url: &'a str) -> Result<Self, InvalidEndPoint>

初始化 endpoint enum

assert!(matches!(
    EndPoint::new("shanghai"),
    Ok(EndPoint::SHANGHAI)
));

assert!(EndPoint::new("abc-").is_err());
assert!(EndPoint::new("-abc").is_err());
assert!(EndPoint::new("abc-def234ab").is_ok());
assert!(EndPoint::new("abc-def*#$%^ab").is_err());
assert!(EndPoint::new("cn-jinan").is_ok());
assert!(EndPoint::new("cn-jinan").is_ok());
assert!(EndPoint::new("oss-cn-jinan").is_err());
Source

pub fn from_env() -> Result<Self, InvalidEndPoint>

use env init Endpoint

Source

pub fn set_internal(&mut self, is_internal: bool)

§调整 API 指向是否为内网

当在 Aliyun ECS 上执行时,设为 true 会更高效,默认是 false

Source

pub fn is_internal(&self) -> bool

返回当前的 endpoint 是否为内网

Source

pub fn to_url(&self) -> Url

转化成 Url

use reqwest::Url;
let mut endpoint = EndPoint::new("shanghai").unwrap();
assert_eq!(
    endpoint.to_url(),
    Url::parse("https://oss-cn-shanghai.aliyuncs.com").unwrap()
);

endpoint.set_internal(true);
assert_eq!(
    endpoint.to_url(),
    Url::parse("https://oss-cn-shanghai-internal.aliyuncs.com").unwrap()
);

Trait Implementations§

Source§

impl AsMut<EndPoint> for BucketBase

Source§

fn as_mut(&mut self) -> &mut EndPoint

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

impl<T: PointerFamily> AsRef<EndPoint> for Bucket<T>

Source§

fn as_ref(&self) -> &EndPoint

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

impl AsRef<EndPoint> for BucketBase

Source§

fn as_ref(&self) -> &EndPoint

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

impl<M> AsRef<EndPoint> for Client<M>

Source§

fn as_ref(&self) -> &EndPoint

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

impl AsRef<EndPoint> for Config

Source§

fn as_ref(&self) -> &EndPoint

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

impl<T: PointerFamily, Item> AsRef<EndPoint> for ObjectList<T, Item>

Source§

fn as_ref(&self) -> &EndPoint

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

impl AsRef<str> for EndPoint

Source§

fn as_ref(&self) -> &str


assert_eq!(EndPoint::HANGZHOU.as_ref(), "cn-hangzhou");
assert_eq!(EndPoint::SHANGHAI.as_ref(), "cn-shanghai");
assert_eq!(EndPoint::QINGDAO.as_ref(), "cn-qingdao");
assert_eq!(EndPoint::BEIJING.as_ref(), "cn-beijing");
assert_eq!(EndPoint::ZHANGJIAKOU.as_ref(), "cn-zhangjiakou");
assert_eq!(EndPoint::HONGKONG.as_ref(), "cn-hongkong");
assert_eq!(EndPoint::SHENZHEN.as_ref(), "cn-shenzhen");
assert_eq!(EndPoint::US_WEST_1.as_ref(), "us-west-1");
assert_eq!(EndPoint::US_EAST_1.as_ref(), "us-east-1");
assert_eq!(EndPoint::AP_SOUTH_EAST_1.as_ref(), "ap-southeast-1");
Source§

impl Clone for EndPoint

Source§

fn clone(&self) -> EndPoint

Returns a copy 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 EndPoint

Source§

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

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

impl Default for EndPoint

Source§

fn default() -> EndPoint

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

impl Display for EndPoint

Source§

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

let mut endpoint = EndPoint::HANGZHOU;
assert_eq!(format!("{}", endpoint), "cn-hangzhou");
endpoint.set_internal(true);
assert_eq!(format!("{}", endpoint), "cn-hangzhou-internal");
Source§

impl FromStr for EndPoint

Source§

type Err = InvalidEndPoint

The associated error which can be returned from parsing.
Source§

fn from_str(url: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for EndPoint

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<&str> for EndPoint

Source§

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

§相等比较
let e: EndPoint = String::from("qingdao").try_into().unwrap();
assert!(e == "cn-qingdao");
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<EndPoint> for &str

Source§

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

§相等比较
let e: EndPoint = String::from("qingdao").try_into().unwrap();
assert!("cn-qingdao" == e);
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<Url> for EndPoint

Source§

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

§相等比较
use reqwest::Url;
let endpoint = EndPoint::new("shanghai").unwrap();
assert!(endpoint == Url::parse("https://oss-cn-shanghai.aliyuncs.com").unwrap());
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 EndPoint

Source§

fn eq(&self, other: &EndPoint) -> 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<'a> TryFrom<&'a str> for EndPoint

Source§

fn try_from(url: &'a str) -> Result<Self, Self::Error>

字符串字面量转 endpoint

举例

let e: EndPoint = "qingdao".try_into().unwrap();
assert_eq!(e, EndPoint::QINGDAO);
Source§

type Error = InvalidEndPoint

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

impl TryFrom<String> for EndPoint

Source§

fn try_from(url: String) -> Result<Self, Self::Error>

字符串转 endpoint

举例

let e: EndPoint = String::from("qingdao").try_into().unwrap();
assert_eq!(e, EndPoint::QINGDAO);
Source§

type Error = InvalidEndPoint

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

impl TryFrom<Url> for EndPoint

Source§

type Error = InvalidEndPoint

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

fn try_from(url: Url) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for EndPoint

Source§

impl StructuralPartialEq for EndPoint

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

impl<T> ErasedDestructor for T
where T: 'static,