Enum qiniu_http_client::Authorization
source · pub enum Authorization<'a> {
Owned(Box<dyn AuthorizationProvider + 'a>),
Borrowed(&'a dyn AuthorizationProvider),
}
Expand description
七牛鉴权签名
该类型是个枚举类型,引用或拥有七牛鉴权签名接口的实例
Variants§
Owned(Box<dyn AuthorizationProvider + 'a>)
拥有七牛鉴权签名接口的实例
Borrowed(&'a dyn AuthorizationProvider)
引用七牛鉴权签名接口的实例
Implementations§
source§impl<'a> Authorization<'a>
impl<'a> Authorization<'a>
sourcepub fn from_owned<T: AuthorizationProvider + 'a>(provider: T) -> Self
pub fn from_owned<T: AuthorizationProvider + 'a>(provider: T) -> Self
根据一个拥有的七牛鉴权签名接口的实例创建一个鉴权签名
Examples found in repository?
src/client/authorization.rs (line 424)
423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
pub fn uptoken(provider: impl UploadTokenProvider + Clone + 'a) -> Self {
Self::from_owned(UploadTokenAuthorization::from(provider))
}
/// 根据认证信息获取接口创建一个使用七牛鉴权 v1 签名算法的签名
#[inline]
pub fn v1(provider: impl CredentialProvider + Clone + 'a) -> Self {
Self::from_owned(CredentialAuthorizationV1::from(provider))
}
/// 根据认证信息获取接口创建一个使用七牛鉴权 v2 签名算法的签名
#[inline]
pub fn v2(provider: impl CredentialProvider + Clone + 'a) -> Self {
Self::from_owned(CredentialAuthorizationV2::from(provider))
}
/// 根据认证信息获取接口创建一个使用七牛鉴权 v2 签名算法的签名,并且禁用时间戳签名
#[inline]
pub fn v2_without_timestamp_signature(provider: impl CredentialProvider + Clone + 'a) -> Self {
let mut auth = CredentialAuthorizationV2::from(provider);
auth.disable_timestamp_signature();
Self::from_owned(auth)
}
/// 根据认证信息获取接口创建一个下载凭证签名算法的签名
#[inline]
pub fn download(provider: impl CredentialProvider + Clone + 'a) -> Self {
Self::from_owned(DownloadUrlCredentialAuthorization::from(provider))
}
sourcepub fn from_referenced(provider: &'a dyn AuthorizationProvider) -> Self
pub fn from_referenced(provider: &'a dyn AuthorizationProvider) -> Self
根据一个引用的七牛鉴权签名接口的实例创建一个鉴权签名
sourcepub fn uptoken(provider: impl UploadTokenProvider + Clone + 'a) -> Self
pub fn uptoken(provider: impl UploadTokenProvider + Clone + 'a) -> Self
根据上传凭证获取接口创建一个上传凭证签名算法的签名
sourcepub fn v1(provider: impl CredentialProvider + Clone + 'a) -> Self
pub fn v1(provider: impl CredentialProvider + Clone + 'a) -> Self
根据认证信息获取接口创建一个使用七牛鉴权 v1 签名算法的签名
sourcepub fn v2(provider: impl CredentialProvider + Clone + 'a) -> Self
pub fn v2(provider: impl CredentialProvider + Clone + 'a) -> Self
根据认证信息获取接口创建一个使用七牛鉴权 v2 签名算法的签名
Examples found in repository?
src/regions/regions_provider/all_regions_provider.rs (line 262)
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
fn do_sync_query(&self) -> ApiResult<GotRegions> {
handle_response_body(
self.http_client
.get(&[ServiceName::Uc], &self.uc_endpoints)
.path("/regions")
.authorization(Authorization::v2(&self.credential_provider))
.accept_json()
.call()?
.parse_json::<ResponseBody>()?,
)
}
#[cfg(feature = "async")]
async fn do_async_query(&self) -> ApiResult<GotRegions> {
handle_response_body(
self.http_client
.async_get(&[ServiceName::Uc], &self.uc_endpoints)
.path("/regions")
.authorization(Authorization::v2(&self.credential_provider))
.accept_json()
.call()
.await?
.parse_json::<ResponseBody>()
.await?,
)
}
More examples
src/regions/endpoints_provider/bucket_domains_provider.rs (line 278)
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
fn do_sync_query(&self) -> ApiResult<Endpoints> {
let endpoints: Endpoints = self
.queryer
.http_client
.get(&[ServiceName::Uc], &self.queryer.uc_endpoints)
.path("/v2/domains")
.authorization(Authorization::v2(&self.credential))
.append_query_pair("tbl", self.bucket_name.as_str())
.accept_json()
.call()?
.parse_json::<Vec<String>>()?
.into_body()
.into_iter()
.map(Endpoint::from)
.collect();
Ok(endpoints)
}
#[cfg(feature = "async")]
async fn do_async_query(&self) -> ApiResult<Endpoints> {
let endpoints: Endpoints = self
.queryer
.http_client
.async_get(&[ServiceName::Uc], &self.queryer.uc_endpoints)
.path("/v2/domains")
.authorization(Authorization::v2(&self.credential))
.append_query_pair("tbl", self.bucket_name.as_str())
.accept_json()
.call()
.await?
.parse_json::<Vec<String>>()
.await?
.into_body()
.into_iter()
.map(Endpoint::from)
.collect();
Ok(endpoints)
}
sourcepub fn v2_without_timestamp_signature(
provider: impl CredentialProvider + Clone + 'a
) -> Self
pub fn v2_without_timestamp_signature(
provider: impl CredentialProvider + Clone + 'a
) -> Self
根据认证信息获取接口创建一个使用七牛鉴权 v2 签名算法的签名,并且禁用时间戳签名
sourcepub fn download(provider: impl CredentialProvider + Clone + 'a) -> Self
pub fn download(provider: impl CredentialProvider + Clone + 'a) -> Self
根据认证信息获取接口创建一个下载凭证签名算法的签名
Trait Implementations§
source§impl<'a> AsRef<dyn AuthorizationProvider + 'a> for Authorization<'a>
impl<'a> AsRef<dyn AuthorizationProvider + 'a> for Authorization<'a>
source§fn as_ref(&self) -> &(dyn AuthorizationProvider + 'a)
fn as_ref(&self) -> &(dyn AuthorizationProvider + 'a)
Converts this type into a shared reference of the (usually inferred) input type.
source§impl AuthorizationProvider for Authorization<'_>
impl AuthorizationProvider for Authorization<'_>
source§fn sign(&self, request: &mut SyncRequest<'_>) -> AuthorizationResult<()>
fn sign(&self, request: &mut SyncRequest<'_>) -> AuthorizationResult<()>
使用指定的鉴权方式对 HTTP 请求进行签名 Read more
source§fn async_sign<'a>(
&'a self,
request: &'a mut AsyncRequest<'_>
) -> BoxFuture<'a, AuthorizationResult<()>>
fn async_sign<'a>(
&'a self,
request: &'a mut AsyncRequest<'_>
) -> BoxFuture<'a, AuthorizationResult<()>>
Available on crate feature
async
only.使用指定的鉴权方式对异步 HTTP 请求进行签名
source§impl<'a> Clone for Authorization<'a>
impl<'a> Clone for Authorization<'a>
source§fn clone(&self) -> Authorization<'a>
fn clone(&self) -> Authorization<'a>
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 moreAuto Trait Implementations§
impl<'a> !RefUnwindSafe for Authorization<'a>
impl<'a> Send for Authorization<'a>
impl<'a> Sync for Authorization<'a>
impl<'a> Unpin for Authorization<'a>
impl<'a> !UnwindSafe for Authorization<'a>
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.