Reformat code.

This commit is contained in:
Kiyomichi Kosaka
2022-12-03 20:37:41 +00:00
parent 474d0cd4e5
commit 47243330a9
6 changed files with 638 additions and 383 deletions
+40 -35
View File
@@ -1,51 +1,56 @@
use std::{cell::RefCell, rc::Rc};
use crate::password::Password;
use std::{cell::RefCell, rc::Rc};
#[derive(thiserror::Error, Debug, PartialEq)]
pub enum LKErr<'a> {
#[error("Error: {0}")]
Error(&'a str),
#[error("Failed to read the line: {0}")]
ReadError(String),
#[error("Failed to parse: {0}")]
ParseError(peg::error::ParseError<peg::str::LineCol>),
#[error("Error: {0}")]
Error(&'a str),
#[error("Failed to read the line: {0}")]
ReadError(String),
#[error("Failed to parse: {0}")]
ParseError(peg::error::ParseError<peg::str::LineCol>),
}
#[derive(PartialEq, Debug)]
pub enum Command<'a> {
Add(Rc<RefCell<Password>>),
Ls,
Mv(String, String),
Error(LKErr<'a>),
Help,
Quit
Add(Rc<RefCell<Password>>),
Ls,
Mv(String, String),
Error(LKErr<'a>),
Help,
Quit,
}
#[derive(PartialEq, Debug)]
pub enum Mode {
Regular,
RegularUpcase,
NoSpace,
NoSpaceUpcase,
Hex,
HexUpcase,
Base64,
Base64Upcase,
Decimal,
Regular,
RegularUpcase,
NoSpace,
NoSpaceUpcase,
Hex,
HexUpcase,
Base64,
Base64Upcase,
Decimal,
}
impl std::fmt::Display for Mode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Mode::Regular => "R",
Mode::RegularUpcase => "UR",
Mode::NoSpace => "N",
Mode::NoSpaceUpcase => "UN",
Mode::Hex => "H",
Mode::HexUpcase => "UH",
Mode::Base64 => "B",
Mode::Base64Upcase => "UB",
Mode::Decimal => "D",
}.to_string())
}
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Mode::Regular => "R",
Mode::RegularUpcase => "UR",
Mode::NoSpace => "N",
Mode::NoSpaceUpcase => "UN",
Mode::Hex => "H",
Mode::HexUpcase => "UH",
Mode::Base64 => "B",
Mode::Base64Upcase => "UB",
Mode::Decimal => "D",
}
.to_string()
)
}
}