Struct oauth1_request::Builder
source · [−]pub struct Builder<'a, SM, C = String, T = C> { /* private fields */ }
Expand description
A builder for OAuth Authorization
header string.
Implementations
sourceimpl<'a, SM: SignatureMethod, C: AsRef<str>, T: AsRef<str>> Builder<'a, SM, C, T>
impl<'a, SM: SignatureMethod, C: AsRef<str>, T: AsRef<str>> Builder<'a, SM, C, T>
sourcepub fn new(client: Credentials<C>, signature_method: SM) -> Self
pub fn new(client: Credentials<C>, signature_method: SM) -> Self
Creates a Builder
that signs requests using the specified client credentials
and signature method.
sourcepub fn with_token(token: Token<C, T>, signature_method: SM) -> Self
pub fn with_token(token: Token<C, T>, signature_method: SM) -> Self
Creates a Builder
that uses the token credentials from token
.
sourcepub fn token(&mut self, token: impl Into<Option<Credentials<T>>>) -> &mut Self
pub fn token(&mut self, token: impl Into<Option<Credentials<T>>>) -> &mut Self
Sets/unsets the token credentials pair to sign requests with.
sourcepub fn callback(&mut self, callback: impl Into<Option<&'a str>>) -> &mut Self
pub fn callback(&mut self, callback: impl Into<Option<&'a str>>) -> &mut Self
Sets/unsets the oauth_callback
URI.
sourcepub fn verifier(&mut self, verifier: impl Into<Option<&'a str>>) -> &mut Self
pub fn verifier(&mut self, verifier: impl Into<Option<&'a str>>) -> &mut Self
Sets/unsets the oauth_verifier
value.
sourcepub fn nonce(&mut self, nonce: impl Into<Option<&'a str>>) -> &mut Self
pub fn nonce(&mut self, nonce: impl Into<Option<&'a str>>) -> &mut Self
Sets/unsets the oauth_nonce
value.
By default, Builder
generates a random nonce for each request.
This method overrides that behavior and forces the Builder
to use the specified nonce.
This method is for debugging/testing purpose only and should not be used in production.
sourcepub fn timestamp(
&mut self,
timestamp: impl Into<Option<NonZeroU64>>
) -> &mut Self
pub fn timestamp(
&mut self,
timestamp: impl Into<Option<NonZeroU64>>
) -> &mut Self
Sets/unsets the oauth_timestamp
value.
By default, Builder
uses the timestamp of the time when authorize
-like method is called.
This method overrides that behavior and forces the Builder
to use the specified timestamp.
This method is for debugging/testing purpose only and should not be used in production.
sourcepub fn version(&mut self, version: bool) -> &mut Self
pub fn version(&mut self, version: bool) -> &mut Self
Sets whether to include the oauth_version
value in requests.
sourcepub fn get<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn get<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a GET
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn put<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn put<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a PUT
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn post<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn post<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a POST
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn delete<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn delete<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a DELETE
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn options<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn options<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a OPTIONS
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn head<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn head<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a HEAD
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn connect<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn connect<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a CONNECT
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn patch<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn patch<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a PATCH
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn trace<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn trace<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a TRACE
request to uri
,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn put_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn put_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a PUT
request to uri
,
writing the OAuth protocol parameters to an x-www-form-urlencoded
string
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn post_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn post_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a POST
request to uri
,
writing the OAuth protocol parameters to an x-www-form-urlencoded
string
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn options_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn options_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a OPTIONS
request to uri
,
writing the OAuth protocol parameters to an x-www-form-urlencoded
string
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn patch_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn patch_form<U, R>(&self, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a PATCH
request to uri
,
writing the OAuth protocol parameters to an x-www-form-urlencoded
string
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn get_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn get_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a GET
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn put_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn put_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a PUT
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn post_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn post_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a POST
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn delete_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn delete_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a DELETE
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn options_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn options_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a OPTIONS
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn head_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn head_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a HEAD
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn connect_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn connect_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a CONNECT
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn patch_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn patch_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a PATCH
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn trace_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn trace_query<W, R>(&self, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a TRACE
request to uri
, appending
the OAuth protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
Available on crate feature alloc
only.
alloc
only.Authorizes a request to uri
with a custom HTTP request method,
returning an HTTP Authorization
header value.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn to_form<U, R>(&self, method: &str, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn to_form<U, R>(&self, method: &str, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Authorizes a request to uri
with a custom HTTP request method, writing the OAuth protocol
parameters to an x-www-form-urlencoded
string along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
sourcepub fn to_query<W, R>(&self, method: &str, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
pub fn to_query<W, R>(&self, method: &str, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
SM: Clone,
Authorizes a request to uri
with a custom HTTP request method, appending the OAuth
protocol parameters to uri
along with the other request parameters.
uri
must not contain a query part, which would result in a wrong signature.
Same as authorize
except that this writes the resulting Authorization
header value
into buf
.
sourcepub fn to_form_with_buf<W, U, R>(
&self,
buf: W,
method: &str,
uri: U,
request: &R
) -> W where
W: Write,
U: Display,
R: Request + ?Sized,
SM: Clone,
Available on crate feature alloc
only.
pub fn to_form_with_buf<W, U, R>(
&self,
buf: W,
method: &str,
uri: U,
request: &R
) -> W where
W: Write,
U: Display,
R: Request + ?Sized,
SM: Clone,
alloc
only.Same as to_form
except that this writes the resulting x-www-form-urlencoded
string
into buf
.
Available on crate feature alloc
only.
alloc
only.Authorizes a request and consumes self
, returning an HTTP Authorization
header value.
Unlike authorize
, this does not clone the signature method and may be more efficient for
non-Copy
signature methods like RsaSha1
.
For HmacSha1
, &RsaSha1
and Plaintext
, cloning is no-op or very cheap so you should
use authorize
instead.
sourcepub fn into_form<U, R>(self, method: &str, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
Available on crate feature alloc
only.
pub fn into_form<U, R>(self, method: &str, uri: U, request: &R) -> String where
U: Display,
R: Request + ?Sized,
alloc
only.Authorizes a request and consumes self
, writing the OAuth protocol parameters to
an x-www-form-urlencoded
string along with the other request parameters.
Unlike to_form
, this does not clone the signature method and may be more efficient for
non-Copy
signature methods like RsaSha1
.
For HmacSha1
, &RsaSha1
and Plaintext
, cloning is no-op or very cheap so you should
use to_form
instead.
sourcepub fn into_query<W, R>(self, method: &str, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
pub fn into_query<W, R>(self, method: &str, uri: W, request: &R) -> W where
W: Display + Write,
R: Request + ?Sized,
Authorizes a request and consumes self
, appending the OAuth protocol parameters to
uri
along with the other request parameters.
Unlike to_query
, this does not clone the signature method and may be more efficient for
non-Copy
signature methods like RsaSha1
.
For HmacSha1
, &RsaSha1
and Plaintext
, cloning is no-op or very cheap so you should
use to_query
instead.
Same as into_authorization
except that this writes the resulting Authorization
header
value into buf
.
Trait Implementations
Auto Trait Implementations
impl<'a, SM, C, T> RefUnwindSafe for Builder<'a, SM, C, T> where
C: RefUnwindSafe,
SM: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, SM, C, T> Send for Builder<'a, SM, C, T> where
C: Send,
SM: Send,
T: Send,
impl<'a, SM, C, T> Sync for Builder<'a, SM, C, T> where
C: Sync,
SM: Sync,
T: Sync,
impl<'a, SM, C, T> Unpin for Builder<'a, SM, C, T> where
C: Unpin,
SM: Unpin,
T: Unpin,
impl<'a, SM, C, T> UnwindSafe for Builder<'a, SM, C, T> where
C: UnwindSafe,
SM: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more