summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-05 17:02:23 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-09 11:52:38 +0100
commit7546d5bdee68f3484211808e8e66002b56d29ac7 (patch)
tree3eba039bc98f7e82c4f396bec86dbe4eb9706818 /tool
parenta206235113bdb10e0d971c83f070dcf83875c47e (diff)
Reduce use of explicit failure::Fallible.
Diffstat (limited to 'tool')
-rw-r--r--tool/src/commands/key.rs5
-rw-r--r--tool/src/sq.rs13
2 files changed, 10 insertions, 8 deletions
diff --git a/tool/src/commands/key.rs b/tool/src/commands/key.rs
index b463214e..bbde9ceb 100644
--- a/tool/src/commands/key.rs
+++ b/tool/src/commands/key.rs
@@ -4,6 +4,7 @@ use clap::ArgMatches;
use itertools::Itertools;
use std::time::{SystemTime, Duration};
+use crate::openpgp::Result;
use crate::openpgp::Packet;
use crate::openpgp::cert::prelude::*;
use crate::openpgp::types::KeyFlags;
@@ -17,7 +18,7 @@ const SECONDS_IN_YEAR : u64 =
// Average number of days in a year.
(365.2422222 * SECONDS_IN_DAY as f64) as u64;
-pub fn generate(m: &ArgMatches, force: bool) -> failure::Fallible<()> {
+pub fn generate(m: &ArgMatches, force: bool) -> Result<()> {
let mut builder = CertBuilder::new();
// User ID
@@ -184,7 +185,7 @@ pub fn generate(m: &ArgMatches, force: bool) -> failure::Fallible<()> {
Ok(())
}
-fn parse_duration(expiry: &str) -> failure::Fallible<Duration> {
+fn parse_duration(expiry: &str) -> Result<Duration> {
let mut expiry = expiry.chars().peekable();
let _ = expiry.by_ref()
diff --git a/tool/src/sq.rs b/tool/src/sq.rs
index 10b3f33d..6b188e0e 100644
--- a/tool/src/sq.rs
+++ b/tool/src/sq.rs
@@ -25,6 +25,7 @@ extern crate sequoia_core;
extern crate sequoia_net;
extern crate sequoia_store as store;
+use crate::openpgp::Result;
use crate::openpgp::{armor, Fingerprint, Cert};
use sequoia_autocrypt as autocrypt;
use crate::openpgp::fmt::hex;
@@ -41,7 +42,7 @@ mod sq_cli;
mod commands;
use commands::dump::Convert;
-fn open_or_stdin(f: Option<&str>) -> Result<Box<dyn io::Read>, failure::Error> {
+fn open_or_stdin(f: Option<&str>) -> Result<Box<dyn io::Read>> {
match f {
Some(f) => Ok(Box::new(File::open(f)
.context("Failed to open input file")?)),
@@ -50,7 +51,7 @@ fn open_or_stdin(f: Option<&str>) -> Result<Box<dyn io::Read>, failure::Error> {
}
fn create_or_stdout(f: Option<&str>, force: bool)
- -> Result<Box<dyn io::Write>, failure::Error> {
+ -> Result<Box<dyn io::Write>> {
match f {
None => Ok(Box::new(io::stdout())),
Some(p) if p == "-" => Ok(Box::new(io::stdout())),
@@ -132,7 +133,7 @@ impl<T: Write> Write for Writer<T> {
fn create_or_stdout_pgp(f: Option<&str>, force: bool,
binary: bool, kind: armor::Kind)
- -> Result<Writer<Box<dyn Write>>, failure::Error>
+ -> Result<Writer<Box<dyn Write>>>
{
let sink = create_or_stdout(f, force)?;
let mut sink = Writer::from(sink);
@@ -212,7 +213,7 @@ fn help_warning(arg: &str) {
}
}
-fn real_main() -> Result<(), failure::Error> {
+fn real_main() -> Result<()> {
let policy = &P::new();
let matches = sq_cli::build().get_matches();
@@ -681,7 +682,7 @@ fn real_main() -> Result<(), failure::Error> {
}
fn list_bindings(mapping: &Mapping, realm: &str, name: &str)
- -> Result<(), failure::Error> {
+ -> Result<()> {
if mapping.iter()?.count() == 0 {
println!("No label-key bindings in the \"{}/{}\" mapping.",
realm, name);
@@ -725,7 +726,7 @@ fn print_log(iter: LogIter, with_slug: bool) {
/// Parses the given string depicting a ISO 8601 timestamp.
fn parse_iso8601(s: &str, pad_date_with: chrono::NaiveTime)
- -> failure::Fallible<DateTime<Utc>>
+ -> Result<DateTime<Utc>>
{
// If you modify this function this function, synchronize the
// changes with the copy in sqv.rs!