pub struct Region { /* private fields */ }
Expand description

七牛存储区域

提供七牛不同服务的终端地址列表

use qiniu_http_client::Region;

let region = Region::builder("z0")
    .add_uc_preferred_endpoint("uc.qbox.me".parse()?)
    .add_up_preferred_endpoint("upload.qiniup.com".parse()?)
    .add_up_preferred_endpoint("up.qiniup.com".parse()?)
    .add_up_alternative_endpoint("up.qbox.me".parse()?)
    .add_rs_preferred_endpoint("rs.qbox.me".parse()?)
    .add_rsf_preferred_endpoint("rsf.qbox.me".parse()?)
    .add_api_preferred_endpoint("api.qiniu.com".parse()?)
    .build();

Implementations§

获取区域 ID

获取 S3 区域 ID

获取上传服务主要终端列表

up().preferred() 等效

获取上传服务备选终端列表

up().alternative() 等效

获取下载服务主要终端列表

io().preferred() 等效

获取下载服务备选终端列表

io().alternative() 等效

获取存储空间管理服务主要终端列表

uc().preferred() 等效

获取存储空间管理服务备选终端列表

uc().alternative() 等效

获取元数据管理服务主要终端列表

rs().preferred() 等效

获取元数据管理服务备选终端列表

rs().alternative() 等效

获取元数据列举服务主要终端列表

rsf().preferred() 等效

获取元数据列举服务备选终端列表

rsf().alternative() 等效

获取 API 入口服务主要终端列表

api().preferred() 等效

获取 API 入口服务备选终端列表

api().alternative() 等效

获取 S3 入口服务主要终端列表

s3().preferred() 等效

获取 S3 入口服务备选终端列表

s3().alternative() 等效

获取上传服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 63)
62
63
64
65
66
67
68
69
70
71
72
    pub fn up_preferred_endpoints(&self) -> &[Endpoint] {
        self.up().preferred()
    }

    /// 获取上传服务备选终端列表
    ///
    /// 与 `up().alternative()` 等效
    #[inline]
    pub fn up_alternative_endpoints(&self) -> &[Endpoint] {
        self.up().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 85)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

获取下载服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 79)
78
79
80
81
82
83
84
85
86
87
88
    pub fn io_preferred_endpoints(&self) -> &[Endpoint] {
        self.io().preferred()
    }

    /// 获取下载服务备选终端列表
    ///
    /// 与 `io().alternative()` 等效
    #[inline]
    pub fn io_alternative_endpoints(&self) -> &[Endpoint] {
        self.io().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 86)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

获取存储空间管理服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 95)
94
95
96
97
98
99
100
101
102
103
104
    pub fn uc_preferred_endpoints(&self) -> &[Endpoint] {
        self.uc().preferred()
    }

    /// 获取存储空间管理服务备选终端列表
    ///
    /// 与 `uc().alternative()` 等效
    #[inline]
    pub fn uc_alternative_endpoints(&self) -> &[Endpoint] {
        self.uc().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 87)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

获取元数据管理服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 111)
110
111
112
113
114
115
116
117
118
119
120
    pub fn rs_preferred_endpoints(&self) -> &[Endpoint] {
        self.rs().preferred()
    }

    /// 获取元数据管理服务备选终端列表
    ///
    /// 与 `rs().alternative()` 等效
    #[inline]
    pub fn rs_alternative_endpoints(&self) -> &[Endpoint] {
        self.rs().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 88)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

获取元数据列举服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 127)
126
127
128
129
130
131
132
133
134
135
136
    pub fn rsf_preferred_endpoints(&self) -> &[Endpoint] {
        self.rsf().preferred()
    }

    /// 获取元数据列举服务备选终端列表
    ///
    /// 与 `rsf().alternative()` 等效
    #[inline]
    pub fn rsf_alternative_endpoints(&self) -> &[Endpoint] {
        self.rsf().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 89)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

获取 API 入口服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 143)
142
143
144
145
146
147
148
149
150
151
152
    pub fn api_preferred_endpoints(&self) -> &[Endpoint] {
        self.api().preferred()
    }

    /// 获取 API 入口服务备选终端列表
    ///
    /// 与 `api().alternative()` 等效
    #[inline]
    pub fn api_alternative_endpoints(&self) -> &[Endpoint] {
        self.api().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 90)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

获取 S3 入口服务终端地址列表

Examples found in repository?
src/regions/region.rs (line 159)
158
159
160
161
162
163
164
165
166
167
168
    pub fn s3_preferred_endpoints(&self) -> &[Endpoint] {
        self.s3().preferred()
    }

    /// 获取 S3 入口服务备选终端列表
    ///
    /// 与 `s3().alternative()` 等效
    #[inline]
    pub fn s3_alternative_endpoints(&self) -> &[Endpoint] {
        self.s3().alternative()
    }
More examples
Hide additional examples
src/regions/endpoints_provider/endpoints.rs (line 91)
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    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()
    }

创建区域构建器

Examples found in repository?
src/regions/regions_provider/structs.rs (line 71)
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
98
99
    fn try_from(body: RegionResponseBody) -> Result<Self, Self::Error> {
        let RegionResponseBody {
            region,
            io,
            up,
            uc,
            rs,
            rsf,
            api,
            s3,
            ..
        } = body;
        let mut builder = Self::builder(region);

        macro_rules! push_to_builder {
            ($service_name:expr, $add_to_preferred_endpoint:ident, $add_to_alternative_endpoint:ident) => {
                for preferred_domain in $service_name.preferred.iter() {
                    let endpoint: Endpoint = preferred_domain.as_ref().parse()?;
                    builder.$add_to_preferred_endpoint(endpoint);
                }
                if let Some(alternative_domains) = &$service_name.alternative {
                    for alternative_domain in alternative_domains.iter() {
                        let endpoint: Endpoint = alternative_domain.as_ref().parse()?;
                        builder.$add_to_alternative_endpoint(endpoint);
                    }
                }
            };
        }
        push_to_builder!(io, add_io_preferred_endpoint, add_io_alternative_endpoint);
        push_to_builder!(up, add_up_preferred_endpoint, add_up_alternative_endpoint);
        push_to_builder!(uc, add_uc_preferred_endpoint, add_uc_alternative_endpoint);
        push_to_builder!(rs, add_rs_preferred_endpoint, add_rs_alternative_endpoint);
        push_to_builder!(rsf, add_rsf_preferred_endpoint, add_rsf_alternative_endpoint);
        push_to_builder!(api, add_api_preferred_endpoint, add_api_alternative_endpoint);
        push_to_builder!(s3, add_s3_preferred_endpoint, add_s3_alternative_endpoint);
        if let Some(s3_region_id) = s3.s3_region_id {
            builder.s3_region_id(s3_region_id);
        }

        Ok(builder.build())
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
返回七牛区域信息 Read more
返回多个七牛区域信息 Read more
Available on crate feature async only.
异步返回七牛区域信息
Available on crate feature async only.
异步返回多个七牛区域信息
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function.
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function.
Should always be Self
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds.
Calls .tap_borrow() only in debug builds, and is erased in release builds.
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Calls .tap_ref() only in debug builds, and is erased in release builds.
Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Calls .tap_deref() only in debug builds, and is erased in release builds.
Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more