#[non_exhaustive]pub struct EndPoint { /* private fields */ }
Expand description
§OSS 的可用区
Implementations§
Source§impl EndPoint
impl EndPoint
Sourcepub const CN_HANGZHOU: Self
pub const CN_HANGZHOU: Self
杭州
Sourcepub const CN_SHANGHAI: Self
pub const CN_SHANGHAI: Self
上海
Sourcepub const CN_QINGDAO: Self
pub const CN_QINGDAO: Self
青岛
Sourcepub const CN_BEIJING: Self
pub const CN_BEIJING: Self
北京
Sourcepub const CN_ZHANGJIAKOU: Self = Self::ZHANGJIAKOU
pub const CN_ZHANGJIAKOU: Self = Self::ZHANGJIAKOU
张家口
Sourcepub const ZHANGJIAKOU: Self
pub const ZHANGJIAKOU: Self
张家口
Sourcepub const CN_HONGKONG: Self
pub const CN_HONGKONG: Self
香港
Sourcepub const CN_SHENZHEN: Self
pub const CN_SHENZHEN: Self
深圳
Sourcepub const AP_SOUTH_EAST_1: Self
pub const AP_SOUTH_EAST_1: Self
ApSouthEast1
Source§impl<'a> EndPoint
impl<'a> EndPoint
Sourcepub fn from_static(url: &'a str) -> Self
pub fn from_static(url: &'a str) -> Self
通过字符串字面值初始化 endpoint
例如
EndPoint::from_static("qingdao");
Sourcepub const unsafe fn from_static2(url: &'static str) -> Self
pub const unsafe fn from_static2(url: &'static str) -> Self
§Safety
用于静态定义其他可用区
Sourcepub fn new(url: &'a str) -> Result<Self, InvalidEndPoint>
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());
Sourcepub fn from_env() -> Result<Self, InvalidEndPoint>
pub fn from_env() -> Result<Self, InvalidEndPoint>
use env init Endpoint
Sourcepub fn set_internal(&mut self, is_internal: bool)
pub fn set_internal(&mut self, is_internal: bool)
§调整 API 指向是否为内网
当在 Aliyun ECS 上执行时,设为 true 会更高效,默认是 false
Sourcepub fn is_internal(&self) -> bool
pub fn is_internal(&self) -> bool
返回当前的 endpoint 是否为内网
Sourcepub fn to_url(&self) -> Url
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
impl AsMut<EndPoint> for BucketBase
Source§impl AsRef<EndPoint> for BucketBase
impl AsRef<EndPoint> for BucketBase
Source§impl<T: PointerFamily, Item> AsRef<EndPoint> for ObjectList<T, Item>
impl<T: PointerFamily, Item> AsRef<EndPoint> for ObjectList<T, Item>
Source§impl AsRef<str> for EndPoint
impl AsRef<str> for EndPoint
Source§fn as_ref(&self) -> &str
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 PartialEq<&str> for EndPoint
impl PartialEq<&str> for EndPoint
Source§impl PartialEq<EndPoint> for &str
impl PartialEq<EndPoint> for &str
Source§impl PartialEq<Url> for EndPoint
impl PartialEq<Url> for EndPoint
impl Eq for EndPoint
impl StructuralPartialEq for EndPoint
Auto Trait Implementations§
impl Freeze for EndPoint
impl RefUnwindSafe for EndPoint
impl Send for EndPoint
impl Sync for EndPoint
impl Unpin for EndPoint
impl UnwindSafe for EndPoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.