Struct Authorizer

Source
pub struct Authorizer<'a, SM: SignatureMethod, W = String> { /* private fields */ }
Expand description

A Serializer that signs a request and produces OAuth 1.0 oauth_* parameter values.

The resulting parameter values are either written to an HTTP Authorization header value or URI query/x-www-form-urlencoded string (along with the other request parameters) depending on the constructor you use.

Implementations§

Source§

impl<'a, SM: SignatureMethod> Authorizer<'a, SM>

Source

pub fn authorization<T: Display>( method: &str, uri: T, client: Credentials<&'a str>, token: Option<Credentials<&'a str>>, options: &'a Options<'a>, signature_method: SM, ) -> Self

Available on crate feature alloc only.

Creates an Authorizer that produces an HTTP `Authorization header value.

uri must not contain a query part. Otherwise, the serializer will produce a wrong signature.

§Panics

In debug builds, panics if uri contains a '?' character.

Source

pub fn form<T: Display>( method: &str, uri: T, client: Credentials<&'a str>, token: Option<Credentials<&'a str>>, options: &'a Options<'a>, signature_method: SM, ) -> Self

Available on crate feature alloc only.

Creates an Authorizer that produces an x-www-form-urlencoded string.

uri must not contain a query part. Otherwise, the serializer will produce a wrong signature.

§Panics

In debug builds, panics if uri contains a '?' character.

Source§

impl<'a, SM: SignatureMethod, W: Write> Authorizer<'a, SM, W>

Source

pub fn query( method: &str, uri: W, client: Credentials<&'a str>, token: Option<Credentials<&'a str>>, options: &'a Options<'a>, signature_method: SM, ) -> Self
where W: Display,

Creates an Authorizer that appends a query part to uri.

uri must not contain a query part. Otherwise, the serializer will produce a wrong signature.

§Panics

In debug builds, panics if uri contains a '?' character.

Source

pub fn authorization_with_buf<T: Display>( buf: W, method: &str, uri: T, client: Credentials<&'a str>, token: Option<Credentials<&'a str>>, options: &'a Options<'a>, signature_method: SM, ) -> Self

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

Source

pub fn form_with_buf<T: Display>( buf: W, method: &str, uri: T, client: Credentials<&'a str>, token: Option<Credentials<&'a str>>, options: &'a Options<'a>, signature_method: SM, ) -> Self

Same with form except that this writes the resulting form string into buf.

Trait Implementations§

Source§

impl<'a, SM: Clone + SignatureMethod, W: Clone> Clone for Authorizer<'a, SM, W>
where SM::Sign: Clone,

Source§

fn clone(&self) -> Authorizer<'a, SM, W>

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 + SignatureMethod, W: Debug> Debug for Authorizer<'a, SM, W>
where SM::Sign: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, SM: SignatureMethod, W: Write> Serializer for Authorizer<'a, SM, W>

Source§

type Output = W

The type of the value produced by this serializer.
Source§

fn serialize_parameter<V: Display>(&mut self, key: &str, value: V)

Serializes a key-value pair. Read more
Source§

fn serialize_parameter_encoded<V: Display>(&mut self, key: &str, value: V)

Serializes a key-value pair. Read more
Source§

fn serialize_oauth_callback(&mut self)

Appends oauth_callback parameter to the Authorization header. Read more
Source§

fn serialize_oauth_consumer_key(&mut self)

Appends oauth_consumer_key parameter to the Authorization header. Read more
Source§

fn serialize_oauth_nonce(&mut self)

Appends oauth_nonce parameter to the Authorization header. Read more
Source§

fn serialize_oauth_signature_method(&mut self)

Appends oauth_signature_method parameter to the Authorization header. Read more
Source§

fn serialize_oauth_timestamp(&mut self)

Appends oauth_timestamp parameter to the Authorization header. Read more
Source§

fn serialize_oauth_token(&mut self)

Appends oauth_token parameter to the Authorization header. Read more
Source§

fn serialize_oauth_verifier(&mut self)

Appends oauth_verifier parameter to the Authorization header. Read more
Source§

fn serialize_oauth_version(&mut self)

Appends oauth_version parameter to the Authorization header. Read more
Source§

fn end(self) -> W

Finalizes the serialization and returns the serialized value.

Auto Trait Implementations§

§

impl<'a, SM, W> Freeze for Authorizer<'a, SM, W>
where <SM as SignatureMethod>::Sign: Freeze, W: Freeze,

§

impl<'a, SM, W> RefUnwindSafe for Authorizer<'a, SM, W>

§

impl<'a, SM, W> Send for Authorizer<'a, SM, W>
where <SM as SignatureMethod>::Sign: Send, W: Send,

§

impl<'a, SM, W> Sync for Authorizer<'a, SM, W>
where <SM as SignatureMethod>::Sign: Sync, W: Sync,

§

impl<'a, SM, W> Unpin for Authorizer<'a, SM, W>
where <SM as SignatureMethod>::Sign: Unpin, W: Unpin,

§

impl<'a, SM, W> UnwindSafe for Authorizer<'a, SM, W>

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<S> SerializerExt for S
where S: Serializer,

Source§

fn serialize_oauth_parameters(&mut self)

Appends all oauth_* parameter to the Authorization header.
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