Trait oauth1_request::signature_method::Sign
source · pub trait Sign {
type Signature: Display;
Show 16 methods
fn get_signature_method_name(&self) -> &'static str;
fn request_method(&mut self, method: &str);
fn uri(&mut self, uri: impl Display);
fn parameter(&mut self, key: &str, value: impl Display);
fn delimiter(&mut self);
fn finish(self) -> Self::Signature;
fn callback(&mut self, default_key: &'static str, value: impl Display) { ... }
fn consumer_key(&mut self, default_key: &'static str, value: impl Display) { ... }
fn nonce(&mut self, default_key: &'static str, value: impl Display) { ... }
fn use_nonce(&self) -> bool { ... }
fn signature_method(
&mut self,
default_key: &'static str,
default_value: &'static str
) { ... }
fn timestamp(&mut self, default_key: &'static str, value: u64) { ... }
fn use_timestamp(&self) -> bool { ... }
fn token(&mut self, default_key: &'static str, value: impl Display) { ... }
fn verifier(&mut self, default_key: &'static str, value: impl Display) { ... }
fn version(&mut self, default_key: &'static str, default_value: &'static str) { ... }
}
Expand description
Algorithms to sign a signature base string (RFC 5849 section 3.4.1.).
The type will be incrementally passed a signature base string by a Signer
. For example,
a signature base string like the following (line breaks are for display purposes only):
POST&
http%3A%2F%2Fexample.com%2Frequest&
a%3Dr%2520b
%26
a2%3Da
%26
oauth_consumer_key%3D9djdj82h48djs9d2
%26
oauth_nonce%3D7d8f3e4a
%26
oauth_signature_method%3DHMAC-SHA1
%26
oauth_timestamp%3D137131201
%26
oauth_token%3Dkkk9d7dh3k39sjv7
%26
z%3D
…is represented by a series of method calls like the following (sign
is the Sign
object):
sign.request_method("POST");
sign.uri("http%3A%2F%2Fexample.com%2Frequest");
sign.parameter("a", "r%2520b");
sign.delimiter();
sign.parameter("a2", "a");
sign.delimiter();
sign.consumer_key("oauth_consumer_key", "9djdj82h48djs9d2");
sign.delimiter();
sign.nonce("oauth_nonce", "7d8f3e4a");
sign.delimiter();
sign.signature_method("oauth_signature_method", "HMAC-SHA1");
sign.delimiter();
sign.timestamp("oauth_timestamp", 137131201);
sign.delimiter();
sign.token("oauth_token", "kkk9d7dh3k39sjv7");
sign.delimiter();
sign.parameter("z", "");
let _ = sign.finish();
Required Associated Types
Required Methods
sourcefn get_signature_method_name(&self) -> &'static str
fn get_signature_method_name(&self) -> &'static str
Returns the oauth_signature_method
string for the signature method associated with the
algorithm.
sourcefn request_method(&mut self, method: &str)
fn request_method(&mut self, method: &str)
Feeds self
with the HTTP request method part of the signature base string.
sourcefn uri(&mut self, uri: impl Display)
fn uri(&mut self, uri: impl Display)
Feeds self
with the base string URI part of the signature base string.
Provided Methods
sourcefn callback(&mut self, default_key: &'static str, value: impl Display)
fn callback(&mut self, default_key: &'static str, value: impl Display)
Feeds self
with the oauth_callback
parameter part of the signature base string.
default_key
argument is passed just for the convenience of implementors and is always "oauth_callback"
.
The default implementation forwards to the parameter
method.
sourcefn consumer_key(&mut self, default_key: &'static str, value: impl Display)
fn consumer_key(&mut self, default_key: &'static str, value: impl Display)
Feeds self
with the oauth_consumer_key
parameter part of the signature base string.
default_key
argument is passed just for the convenience of implementors and is always "oauth_consumer_key"
.
The default implementation forwards to the parameter
method.
sourcefn nonce(&mut self, default_key: &'static str, value: impl Display)
fn nonce(&mut self, default_key: &'static str, value: impl Display)
Feeds self
with the oauth_nonce
parameter part of the signature base string.
default_key
argument is passed just for the convenience of implementors and is always "oauth_nonce"
.
The default implementation forwards to the parameter
method.
sourcefn use_nonce(&self) -> bool
fn use_nonce(&self) -> bool
If this method returns false
, Signer
will not emit the oauth_nonce
part of the
signature base string.
The default implementation returns true
.
sourcefn signature_method(
&mut self,
default_key: &'static str,
default_value: &'static str
)
fn signature_method(
&mut self,
default_key: &'static str,
default_value: &'static str
)
Feeds self
with the oauth_signature_method
parameter part of the
signature base string.
default_key
and default_value
arguments are passed just for the convenience of
implementors and are always "oauth_signature_method"
and
self.get_signature_method().name()
respectively.
The default implementation forwards to the parameter
method.
sourcefn timestamp(&mut self, default_key: &'static str, value: u64)
fn timestamp(&mut self, default_key: &'static str, value: u64)
Feeds self
with the oauth_timestamp
parameter part of the
signature base string.
default_key
argument is passed just for the convenience of implementors and is always
"oauth_timestamp"
.
The default implementation forwards to the parameter
method.
sourcefn use_timestamp(&self) -> bool
fn use_timestamp(&self) -> bool
If this method returns false
, Signer
will not emit the oauth_nonce
part of the
signature base string.
The default implementation returns true
.
sourcefn token(&mut self, default_key: &'static str, value: impl Display)
fn token(&mut self, default_key: &'static str, value: impl Display)
Feeds self
with the oauth_token
parameter part of the signature base string.
default_key
argument is passed just for the convenience of implementors and is always "oauth_token"
.
The default implementation forwards to the parameter
method.
sourcefn verifier(&mut self, default_key: &'static str, value: impl Display)
fn verifier(&mut self, default_key: &'static str, value: impl Display)
Feeds self
with the oauth_verifier
parameter part of the signature base string.
default_key
argument is passed just for the convenience of implementors and is always "oauth_verifier"
.
The default implementation forwards to the parameter
method.
sourcefn version(&mut self, default_key: &'static str, default_value: &'static str)
fn version(&mut self, default_key: &'static str, default_value: &'static str)
Feeds self
with the oauth_version
parameter part of the signature base string.
default_key
and default_value
arguments are passed just for the convenience of
implementors and are always "oauth_version"
and "1.0"
respectively.
The default implementation forwards to the parameter
method.