all crates: update code to make clippy::all happy
This commit is contained in:
parent
c6e274c4da
commit
625e8e490b
|
@ -138,11 +138,12 @@ impl std::str::FromStr for Slug {
|
||||||
|
|
||||||
impl Display for Slug {
|
impl Display for Slug {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
#[allow(clippy::redundant_at_rest_pattern)]
|
||||||
match (self.0.inner() & (0b1 << 31)).to_be_bytes().as_slice() {
|
match (self.0.inner() & (0b1 << 31)).to_be_bytes().as_slice() {
|
||||||
[0, 0, 0, 0] => Ok(()),
|
[0, 0, 0, 0] => Ok(()),
|
||||||
[0, 0, 0, bytes @ ..] | [0, 0, bytes @ ..] | [0, bytes @ ..] | [bytes @ ..] => f
|
[0, 0, 0, bytes @ ..] | [0, 0, bytes @ ..] | [0, bytes @ ..] | [bytes @ ..] => f
|
||||||
.write_str(
|
.write_str(
|
||||||
std::str::from_utf8(&bytes[..]).expect("slug constructed from non-utf8"),
|
std::str::from_utf8(bytes).expect("slug constructed from non-utf8"),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,7 +456,7 @@ fn do_shard(
|
||||||
// if only one is set: true
|
// if only one is set: true
|
||||||
|
|
||||||
if threshold.is_some() ^ max.is_some() {
|
if threshold.is_some() ^ max.is_some() {
|
||||||
return Err(MissingThresholdOrMax)?;
|
return Err(MissingThresholdOrMax.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let (threshold, max) = match threshold.zip(max) {
|
let (threshold, max) = match threshold.zip(max) {
|
||||||
|
@ -611,7 +611,6 @@ fn do_shard_to_self(
|
||||||
.parse()?;
|
.parse()?;
|
||||||
let cards_per_shard = options
|
let cards_per_shard = options
|
||||||
.get("cards_per_shard")
|
.get("cards_per_shard")
|
||||||
.as_deref()
|
|
||||||
.map(|cps| u8::from_str(cps))
|
.map(|cps| u8::from_str(cps))
|
||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
|
@ -884,7 +883,7 @@ impl MnemonicSubcommands {
|
||||||
!indices.is_empty(),
|
!indices.is_empty(),
|
||||||
"neither derived nor provisioned accounts were found"
|
"neither derived nor provisioned accounts were found"
|
||||||
);
|
);
|
||||||
do_encrypt_to_self(&mnemonic, &encrypt_to_self, &indices)?;
|
do_encrypt_to_self(&mnemonic, encrypt_to_self, &indices)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(shard_to_self) = shard_to_self {
|
if let Some(shard_to_self) = shard_to_self {
|
||||||
|
|
|
@ -20,6 +20,7 @@ pub struct Keyfork {
|
||||||
pub command: KeyforkCommands,
|
pub command: KeyforkCommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::large_enum_variant)]
|
||||||
#[derive(Subcommand, Clone, Debug)]
|
#[derive(Subcommand, Clone, Debug)]
|
||||||
pub enum KeyforkCommands {
|
pub enum KeyforkCommands {
|
||||||
/// Derive keys of various formats. These commands require that the Keyfork server is running,
|
/// Derive keys of various formats. These commands require that the Keyfork server is running,
|
||||||
|
|
|
@ -22,7 +22,9 @@ use std::path::PathBuf;
|
||||||
#[error("Provisioner was unable to find a matching smartcard")]
|
#[error("Provisioner was unable to find a matching smartcard")]
|
||||||
struct NoMatchingSmartcard;
|
struct NoMatchingSmartcard;
|
||||||
|
|
||||||
fn discover_cards() -> Result<Vec<(String, Option<String>)>, Box<dyn std::error::Error>> {
|
pub type CardList = Vec<(String, Option<String>)>;
|
||||||
|
|
||||||
|
fn discover_cards() -> Result<CardList, Box<dyn std::error::Error>> {
|
||||||
let mut idents = vec![];
|
let mut idents = vec![];
|
||||||
for backend in PcscBackend::cards(None)? {
|
for backend in PcscBackend::cards(None)? {
|
||||||
let backend = backend?;
|
let backend = backend?;
|
||||||
|
@ -100,7 +102,7 @@ fn provision_card(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !has_provisioned {
|
if !has_provisioned {
|
||||||
return Err(NoMatchingSmartcard)?;
|
return Err(NoMatchingSmartcard.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
||||||
|
|
||||||
use keyfork_zbar::{image::Image, image_scanner::ImageScanner};
|
use keyfork_zbar::{image::Image, image_scanner::ImageScanner};
|
||||||
|
|
||||||
use image::io::Reader as ImageReader;
|
use image::ImageReader;
|
||||||
use v4l::{
|
use v4l::{
|
||||||
buffer::Type,
|
buffer::Type,
|
||||||
io::{traits::CaptureStream, userptr::Stream},
|
io::{traits::CaptureStream, userptr::Stream},
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn ensure_offline() {
|
||||||
.to_str()
|
.to_str()
|
||||||
.expect(bug!("Unable to decode UTF-8 filepath"))
|
.expect(bug!("Unable to decode UTF-8 filepath"))
|
||||||
.split('/')
|
.split('/')
|
||||||
.last()
|
.next_back()
|
||||||
.expect(bug!("No data in file path"))
|
.expect(bug!("No data in file path"))
|
||||||
== "lo"
|
== "lo"
|
||||||
{
|
{
|
||||||
|
|
|
@ -269,7 +269,7 @@ pub fn prompt_validated_passphrase<V>(
|
||||||
/// * `KEYFORK_PROMPT_TYPE=headless`: [`Headless`]
|
/// * `KEYFORK_PROMPT_TYPE=headless`: [`Headless`]
|
||||||
///
|
///
|
||||||
/// Otherwise, the following heuristics are followed:
|
/// Otherwise, the following heuristics are followed:
|
||||||
/// * [`std::io::IsTerminal::is_terminal`]: [`DefaultTerminal`]
|
/// * [`std::io::IsTerminal::is_terminal`][]: [`DefaultTerminal`]
|
||||||
/// * default: [`Headless`]
|
/// * default: [`Headless`]
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
|
|
@ -455,7 +455,7 @@ where
|
||||||
KeyCode::Char(c) => {
|
KeyCode::Char(c) => {
|
||||||
input.push(c);
|
input.push(c);
|
||||||
let entry_mode = std::env::var("KEYFORK_PROMPT_MNEMONIC_MODE");
|
let entry_mode = std::env::var("KEYFORK_PROMPT_MNEMONIC_MODE");
|
||||||
if entry_mode.is_ok_and(|mode| mode.to_ascii_lowercase() == "steel") {
|
if entry_mode.is_ok_and(|mode| mode.eq_ignore_ascii_case("steel")) {
|
||||||
let word = input.split_whitespace().next_back().map(ToOwned::to_owned);
|
let word = input.split_whitespace().next_back().map(ToOwned::to_owned);
|
||||||
if let Some(steel_word) = word {
|
if let Some(steel_word) = word {
|
||||||
if steel_word.len() >= 4 {
|
if steel_word.len() >= 4 {
|
||||||
|
|
Loading…
Reference in New Issue