fix clippy warnings

This commit is contained in:
Fabrice Bellamy
2026-01-25 19:21:30 +05:30
committed by Suyog Tandel
parent ad46af4f95
commit 417aac34b4
5 changed files with 16 additions and 18 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ pub enum VendorConfigCommand {
}
impl VendorConfigCommand {
pub fn to_u64(&self) -> u64 {
pub fn to_u64(self) -> u64 {
match self {
Self::AuthEncryptionEnable => 0x03e43f56b34285e2,
Self::AuthEncryptionDisable => 0x1831a40f04a25ed9,
+2 -2
View File
@@ -222,7 +222,7 @@ pub fn read_device_details() -> Result<FullDeviceStatus, PFError> {
config,
secure_boot: false,
secure_lock: false,
method: DeviceMethod::FIDO,
method: DeviceMethod::Fido,
})
}
@@ -394,7 +394,7 @@ pub fn write_config(config: AppConfigInput, pin: Option<String>) -> Result<Strin
// 1. Obtain PIN token using the library handle
let pin_token = {
let device = get_device().map_err(|e| PFError::Device(e))?;
let device = get_device().map_err(PFError::Device)?;
// Try to obtain a token with AuthenticatorConfiguration permission (CTAP 2.1)
match device
+1 -1
View File
@@ -18,7 +18,7 @@ pub fn write_config(
method: DeviceMethod,
pin: Option<String>,
) -> Result<String, PFError> {
if method == DeviceMethod::FIDO {
if method == DeviceMethod::Fido {
fido::write_config(config, pin)
} else {
rescue::write_config(config)
+10 -13
View File
@@ -6,7 +6,6 @@ pub mod constants;
use crate::{error::PFError, rescue::constants::*, types::*};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use log;
use pcsc::{Context, Protocols, Scope, ShareMode};
use std::io::Cursor;
@@ -322,19 +321,17 @@ pub fn write_config(config: AppConfigInput) -> Result<String, PFError> {
}
// Product Name (Tag 0x09)
if let Some(name) = config.product_name {
if !name.is_empty() {
let name_bytes = name.as_bytes();
let len = name_bytes.len() + 1;
if len > 32 {
return Err(PFError::Io("Product name too long".into()));
}
tlv.push(PhyTag::UsbProduct as u8);
tlv.push(len as u8);
tlv.extend_from_slice(name_bytes);
tlv.push(0x00); // Null terminator
if let Some(name) = config.product_name.filter(|n| !n.is_empty()) {
let name_bytes = name.as_bytes();
let len = name_bytes.len() + 1;
if len > 32 {
return Err(PFError::Io("Product name too long".into()));
}
tlv.push(PhyTag::UsbProduct as u8);
tlv.push(len as u8);
tlv.extend_from_slice(name_bytes);
tlv.push(0x00); // Null terminator
}
// 2. Connect and Send
+2 -1
View File
@@ -60,7 +60,8 @@ pub struct FullDeviceStatus {
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum DeviceMethod {
FIDO,
#[serde(rename = "FIDO")]
Fido,
Rescue,
}