Struct qiniu_http_client::EndpointsBuilder
source · pub struct EndpointsBuilder { /* private fields */ }
Expand description
终端地址列表构建器
Implementations§
source§impl EndpointsBuilder
impl EndpointsBuilder
sourcepub fn add_preferred_endpoint(&mut self, endpoint: Endpoint) -> &mut Self
pub fn add_preferred_endpoint(&mut self, endpoint: Endpoint) -> &mut Self
添加一个主要终端地址
sourcepub fn add_alternative_endpoint(&mut self, endpoint: Endpoint) -> &mut Self
pub fn add_alternative_endpoint(&mut self, endpoint: Endpoint) -> &mut Self
添加一个备选终端地址
sourcepub fn add_preferred_endpoints(
&mut self,
endpoints: impl IntoIterator<Item = Endpoint>
) -> &mut Self
pub fn add_preferred_endpoints(
&mut self,
endpoints: impl IntoIterator<Item = Endpoint>
) -> &mut Self
添加多个主要终端地址
sourcepub fn add_alternative_endpoints(
&mut self,
endpoints: impl IntoIterator<Item = Endpoint>
) -> &mut Self
pub fn add_alternative_endpoints(
&mut self,
endpoints: impl IntoIterator<Item = Endpoint>
) -> &mut Self
添加多个备选终端地址
sourcepub fn build(&mut self) -> Endpoints
pub fn build(&mut self) -> Endpoints
构建终端地址列表
Examples found in repository?
More examples
src/regions/endpoints_provider/endpoints.rs (line 46)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
static DEFAULT_UC_ENDPOINTS: Lazy<Endpoints> = Lazy::new(|| {
Endpoints::builder(Endpoint::new_from_domain("uc.qbox.me"))
.add_preferred_endpoint(Endpoint::new_from_domain("kodo-config.qiniuapi.com"))
.add_preferred_endpoint(Endpoint::new_from_domain("api.qiniu.com"))
.build()
});
&DEFAULT_UC_ENDPOINTS
}
/// 创建只包含一个主要终端地址的终端地址列表
#[inline]
pub fn new(endpoint: Endpoint) -> Self {
Self::builder(endpoint).build()
}
/// 返回主要终端地址列表
#[inline]
pub fn preferred(&self) -> &[Endpoint] {
&self.preferred
}
/// 返回备选终端地址列表
#[inline]
pub fn alternative(&self) -> &[Endpoint] {
&self.alternative
}
/// 对比两组终端地址列表是否相似
///
/// 相似指的是,两个终端地址列表内主要终端地址列表中的域名相同,备选终端地址列表中的域名也相同,但顺序可能不同
#[inline]
pub fn similar(&self, other: &Self) -> bool {
self.md5() == other.md5()
}
fn from_region(region: &Region, services: &[ServiceName]) -> Self {
let mut builder = EndpointsBuilder {
preferred: vec![],
alternative: vec![],
};
for service in services {
let e = match service {
ServiceName::Up => region.up(),
ServiceName::Io => region.io(),
ServiceName::Uc => region.uc(),
ServiceName::Rs => region.rs(),
ServiceName::Rsf => region.rsf(),
ServiceName::Api => region.api(),
ServiceName::S3 => region.s3(),
};
builder.preferred.extend_from_slice(e.preferred());
builder.alternative.extend_from_slice(e.alternative());
}
builder.build()
}
Trait Implementations§
source§impl Clone for EndpointsBuilder
impl Clone for EndpointsBuilder
source§fn clone(&self) -> EndpointsBuilder
fn clone(&self) -> EndpointsBuilder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for EndpointsBuilder
impl Debug for EndpointsBuilder
source§impl Default for EndpointsBuilder
impl Default for EndpointsBuilder
source§fn default() -> EndpointsBuilder
fn default() -> EndpointsBuilder
Returns the “default value” for a type. Read more
source§impl Extend<Endpoint> for EndpointsBuilder
impl Extend<Endpoint> for EndpointsBuilder
source§fn extend<T: IntoIterator<Item = Endpoint>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Endpoint>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one
)Extends a collection with exactly one element.
source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
source§impl FromIterator<Endpoint> for EndpointsBuilder
impl FromIterator<Endpoint> for EndpointsBuilder
Auto Trait Implementations§
impl RefUnwindSafe for EndpointsBuilder
impl Send for EndpointsBuilder
impl Sync for EndpointsBuilder
impl Unpin for EndpointsBuilder
impl UnwindSafe for EndpointsBuilder
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Immutable access to the
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Immutable access to the
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Mutable access to the
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.