Struct Builder

Source
pub struct Builder<'a, SM, C = String, T = C> { /* private fields */ }
Expand description

A builder for OAuth Authorization header string.

Implementations§

Source§

impl<'a, SM: SignatureMethod, C: AsRef<str>, T: AsRef<str>> Builder<'a, SM, C, T>

Source

pub fn new(client: Credentials<C>, signature_method: SM) -> Self

Creates a Builder that signs requests using the specified client credentials and signature method.

Source

pub fn with_token(token: Token<C, T>, signature_method: SM) -> Self

Creates a Builder that uses the token credentials from token.

Source

pub fn token(&mut self, token: impl Into<Option<Credentials<T>>>) -> &mut Self

Sets/unsets the token credentials pair to sign requests with.

Source

pub fn callback(&mut self, callback: impl Into<Option<&'a str>>) -> &mut Self

Sets/unsets the oauth_callback URI.

Source

pub fn verifier(&mut self, verifier: impl Into<Option<&'a str>>) -> &mut Self

Sets/unsets the oauth_verifier value.

Source

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.

Source

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.

Source

pub fn version(&mut self, version: bool) -> &mut Self

Sets whether to include the oauth_version value in requests.

Source

pub fn get<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn put<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn post<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn delete<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn options<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn head<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn connect<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn patch<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub fn trace<U, R>(&self, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub 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.

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.

Source

pub 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.

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.

Source

pub 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.

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.

Source

pub 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.

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn authorize<U, R>(&self, method: &str, uri: U, request: &R) -> String
where U: Display, R: Request + ?Sized, SM: Clone,

Available on crate feature 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.

Source

pub 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.

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.

Source

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.

Source

pub fn authorize_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,

Same as authorize except that this writes the resulting Authorization header value into buf.

Source

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,

Available on crate feature alloc only.

Same as to_form except that this writes the resulting x-www-form-urlencoded string into buf.

Source

pub fn into_authorization<U, R>( self, method: &str, uri: U, request: &R, ) -> String
where U: Display, R: Request + ?Sized,

Available on crate feature 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.

Source

pub 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.

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.

Source

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.

Source

pub fn into_authorization_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,

Same as into_authorization except that this writes the resulting Authorization header value into buf.

Source

pub fn into_form_with_buf<W, U, R>( self, buf: W, method: &str, uri: U, request: &R, ) -> W
where W: Write, U: Display, R: Request + ?Sized,

Same as into_form except that this writes the resulting x-www-form-urlencoded string into buf.

Trait Implementations§

Source§

impl<'a, SM: Clone, C: Clone, T: Clone> Clone for Builder<'a, SM, C, T>

Source§

fn clone(&self) -> Builder<'a, SM, C, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, SM: Debug, C: Debug, T: Debug> Debug for Builder<'a, SM, C, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, SM, C, T> Freeze for Builder<'a, SM, C, T>
where SM: Freeze, C: Freeze, T: Freeze,

§

impl<'a, SM, C, T> RefUnwindSafe for Builder<'a, SM, C, T>

§

impl<'a, SM, C, T> Send for Builder<'a, SM, C, T>
where SM: Send, C: Send, T: Send,

§

impl<'a, SM, C, T> Sync for Builder<'a, SM, C, T>
where SM: Sync, C: Sync, T: Sync,

§

impl<'a, SM, C, T> Unpin for Builder<'a, SM, C, T>
where SM: Unpin, C: Unpin, T: Unpin,

§

impl<'a, SM, C, T> UnwindSafe for Builder<'a, SM, C, T>
where SM: UnwindSafe, C: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V