mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 00:34:40 +01:00
Use derive default where possible
This commit is contained in:
parent
64b4995030
commit
07043dc272
2 changed files with 6 additions and 21 deletions
|
@ -3,8 +3,9 @@ use std::{fmt, path::Path};
|
|||
use url::Url;
|
||||
|
||||
/// Supported image formats.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||
#[derive(Debug, Default, PartialEq, Eq, Clone, Copy, PartialOrd, Ord)]
|
||||
pub enum Format {
|
||||
#[default]
|
||||
Png,
|
||||
Svg,
|
||||
Ico,
|
||||
|
@ -79,9 +80,3 @@ impl fmt::Display for Format {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Format {
|
||||
fn default() -> Self {
|
||||
Self::Png
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,23 +6,18 @@ use ring::hmac;
|
|||
use serde::{de::Deserializer, ser::Serializer, Deserialize, Serialize};
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, glib::Enum)]
|
||||
#[derive(Debug, Default, Eq, PartialEq, Clone, Copy, glib::Enum)]
|
||||
#[repr(u32)]
|
||||
#[enum_type(name = "OTPMethod")]
|
||||
pub enum OTPMethod {
|
||||
#[enum_value(name = "TOTP")]
|
||||
#[default]
|
||||
TOTP = 0,
|
||||
#[enum_value(name = "HOTP")]
|
||||
HOTP = 1,
|
||||
Steam = 2,
|
||||
}
|
||||
|
||||
impl Default for OTPMethod {
|
||||
fn default() -> Self {
|
||||
Self::TOTP
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for OTPMethod {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
@ -90,11 +85,12 @@ impl ToString for OTPMethod {
|
|||
}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(Debug, Eq, PartialEq, Clone, Copy, glib::Enum)]
|
||||
#[derive(Debug, Default, Eq, PartialEq, Clone, Copy, glib::Enum)]
|
||||
#[repr(u32)]
|
||||
#[enum_type(name = "Algorithm")]
|
||||
pub enum Algorithm {
|
||||
#[enum_value(name = "SHA1")]
|
||||
#[default]
|
||||
SHA1 = 0,
|
||||
#[enum_value(name = "SHA256")]
|
||||
SHA256 = 1,
|
||||
|
@ -102,12 +98,6 @@ pub enum Algorithm {
|
|||
SHA512 = 2,
|
||||
}
|
||||
|
||||
impl Default for Algorithm {
|
||||
fn default() -> Self {
|
||||
Self::SHA1
|
||||
}
|
||||
}
|
||||
|
||||
impl Serialize for Algorithm {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
|
|
Loading…
Add table
Reference in a new issue