mirror of
https://github.com/lune-org/lune.git
synced 2025-04-15 09:23:49 +01:00
refactor: shorten trait bound declarations
This commit is contained in:
parent
40f63c9bb0
commit
897c48b55f
1 changed files with 7 additions and 16 deletions
|
@ -28,10 +28,7 @@ pub enum CryptoAlgo {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Crypto {
|
impl Crypto {
|
||||||
pub fn sha1<T>(content: Option<T>) -> CryptoResult<String, RingDigest>
|
pub fn sha1<T: ToString>(content: Option<T>) -> CryptoResult<String, RingDigest> {
|
||||||
where
|
|
||||||
T: ToString,
|
|
||||||
{
|
|
||||||
let content = content.map(|data| data.to_string());
|
let content = content.map(|data| data.to_string());
|
||||||
|
|
||||||
CryptoResult {
|
CryptoResult {
|
||||||
|
@ -41,10 +38,7 @@ impl Crypto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sha256<T>(content: Option<T>) -> CryptoResult<String, RingDigest>
|
pub fn sha256<T: ToString>(content: Option<T>) -> CryptoResult<String, RingDigest> {
|
||||||
where
|
|
||||||
T: ToString,
|
|
||||||
{
|
|
||||||
let content = content.map(|data| data.to_string());
|
let content = content.map(|data| data.to_string());
|
||||||
|
|
||||||
CryptoResult {
|
CryptoResult {
|
||||||
|
@ -54,10 +48,7 @@ impl Crypto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sha512<T>(content: Option<T>) -> CryptoResult<String, RingDigest>
|
pub fn sha512<T: ToString>(content: Option<T>) -> CryptoResult<String, RingDigest> {
|
||||||
where
|
|
||||||
T: ToString,
|
|
||||||
{
|
|
||||||
let content = content.map(|data| data.to_string());
|
let content = content.map(|data| data.to_string());
|
||||||
|
|
||||||
CryptoResult {
|
CryptoResult {
|
||||||
|
@ -67,10 +58,10 @@ impl Crypto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hmac<T>(content: Option<T>, algo: CryptoAlgo) -> CryptoResult<String, ring::hmac::Tag>
|
pub fn hmac<T: ToString>(
|
||||||
where
|
content: Option<T>,
|
||||||
T: ToString,
|
algo: CryptoAlgo,
|
||||||
{
|
) -> CryptoResult<String, ring::hmac::Tag> {
|
||||||
let content = content.map(|data| data.to_string());
|
let content = content.map(|data| data.to_string());
|
||||||
|
|
||||||
CryptoResult {
|
CryptoResult {
|
||||||
|
|
Loading…
Add table
Reference in a new issue