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 {
|
||||
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() {
|
||||
[0, 0, 0, 0] => Ok(()),
|
||||
[0, 0, 0, bytes @ ..] | [0, 0, bytes @ ..] | [0, bytes @ ..] | [bytes @ ..] => f
|
||||
.write_str(
|
||||
std::str::from_utf8(&bytes[..]).expect("slug constructed from non-utf8"),
|
||||
std::str::from_utf8(bytes).expect("slug constructed from non-utf8"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ pub enum MnemonicSubcommands {
|
|||
/// * cards_per_shard: the amount of OpenPGP smartcards to provision per shardholder.
|
||||
///
|
||||
/// * cert_output: the file to write all generated OpenPGP certificates to; if not
|
||||
/// provided, files will be automatically generated for each certificate.
|
||||
/// provided, files will be automatically generated for each certificate.
|
||||
#[arg(long)]
|
||||
shard_to_self: Option<ValueWithOptions<PathBuf>>,
|
||||
|
||||
|
@ -456,7 +456,7 @@ fn do_shard(
|
|||
// if only one is set: true
|
||||
|
||||
if threshold.is_some() ^ max.is_some() {
|
||||
return Err(MissingThresholdOrMax)?;
|
||||
return Err(MissingThresholdOrMax.into());
|
||||
}
|
||||
|
||||
let (threshold, max) = match threshold.zip(max) {
|
||||
|
@ -611,7 +611,6 @@ fn do_shard_to_self(
|
|||
.parse()?;
|
||||
let cards_per_shard = options
|
||||
.get("cards_per_shard")
|
||||
.as_deref()
|
||||
.map(|cps| u8::from_str(cps))
|
||||
.transpose()?;
|
||||
|
||||
|
@ -884,7 +883,7 @@ impl MnemonicSubcommands {
|
|||
!indices.is_empty(),
|
||||
"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 {
|
||||
|
|
|
@ -20,6 +20,7 @@ pub struct Keyfork {
|
|||
pub command: KeyforkCommands,
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Subcommand, Clone, Debug)]
|
||||
pub enum KeyforkCommands {
|
||||
/// 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")]
|
||||
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![];
|
||||
for backend in PcscBackend::cards(None)? {
|
||||
let backend = backend?;
|
||||
|
@ -100,7 +102,7 @@ fn provision_card(
|
|||
}
|
||||
|
||||
if !has_provisioned {
|
||||
return Err(NoMatchingSmartcard)?;
|
||||
return Err(NoMatchingSmartcard.into());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
|
||||
use keyfork_zbar::{image::Image, image_scanner::ImageScanner};
|
||||
|
||||
use image::io::Reader as ImageReader;
|
||||
use image::ImageReader;
|
||||
use v4l::{
|
||||
buffer::Type,
|
||||
io::{traits::CaptureStream, userptr::Stream},
|
||||
|
|
|
@ -41,7 +41,7 @@ fn ensure_offline() {
|
|||
.to_str()
|
||||
.expect(bug!("Unable to decode UTF-8 filepath"))
|
||||
.split('/')
|
||||
.last()
|
||||
.next_back()
|
||||
.expect(bug!("No data in file path"))
|
||||
== "lo"
|
||||
{
|
||||
|
|
|
@ -269,7 +269,7 @@ pub fn prompt_validated_passphrase<V>(
|
|||
/// * `KEYFORK_PROMPT_TYPE=headless`: [`Headless`]
|
||||
///
|
||||
/// Otherwise, the following heuristics are followed:
|
||||
/// * [`std::io::IsTerminal::is_terminal`]: [`DefaultTerminal`]
|
||||
/// * [`std::io::IsTerminal::is_terminal`][]: [`DefaultTerminal`]
|
||||
/// * default: [`Headless`]
|
||||
///
|
||||
/// # Errors
|
||||
|
|
|
@ -455,7 +455,7 @@ where
|
|||
KeyCode::Char(c) => {
|
||||
input.push(c);
|
||||
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);
|
||||
if let Some(steel_word) = word {
|
||||
if steel_word.len() >= 4 {
|
||||
|
|
Loading…
Reference in New Issue