From: Matt Corallo Date: Wed, 27 Sep 2023 22:26:57 +0000 (+0000) Subject: Use `Result<_, io::Error>` over `io::Result<_>` X-Git-Tag: v0.0.117-rc1~14^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=910a00e3d0cfb8aa21b83c9876f0f0137b14bba0;p=rust-lightning Use `Result<_, io::Error>` over `io::Result<_>` Personally I've always found the overload of a prelude enum to be confusing, and never bothered to handle it properly in bindings as a result. To avoid needing to do so now, we simply move the newly-introduced `io::Result` usages over to `Result<_, io::Error>`. --- diff --git a/lightning/src/util/persist.rs b/lightning/src/util/persist.rs index dbe3ee816..4335a124d 100644 --- a/lightning/src/util/persist.rs +++ b/lightning/src/util/persist.rs @@ -16,7 +16,7 @@ use bitcoin::{BlockHash, Txid}; use crate::{io, log_error}; use crate::alloc::string::ToString; -use crate::prelude::{Vec, String}; +use crate::prelude::*; use crate::chain; use crate::chain::chaininterface::{BroadcasterInterface, FeeEstimator}; @@ -98,11 +98,11 @@ pub trait KVStore { /// `namespace` and `sub_namespace`. /// /// [`ErrorKind::NotFound`]: io::ErrorKind::NotFound - fn read(&self, namespace: &str, sub_namespace: &str, key: &str) -> io::Result>; + fn read(&self, namespace: &str, sub_namespace: &str, key: &str) -> Result, io::Error>; /// Persists the given data under the given `key`. /// /// Will create the given `namespace` and `sub_namespace` if not already present in the store. - fn write(&self, namespace: &str, sub_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()>; + fn write(&self, namespace: &str, sub_namespace: &str, key: &str, buf: &[u8]) -> Result<(), io::Error>; /// Removes any data that had previously been persisted under the given `key`. /// /// If the `lazy` flag is set to `true`, the backend implementation might choose to lazily @@ -117,12 +117,12 @@ pub trait KVStore { /// /// Returns successfully if no data will be stored for the given `namespace`, `sub_namespace`, and /// `key`, independently of whether it was present before its invokation or not. - fn remove(&self, namespace: &str, sub_namespace: &str, key: &str, lazy: bool) -> io::Result<()>; + fn remove(&self, namespace: &str, sub_namespace: &str, key: &str, lazy: bool) -> Result<(), io::Error>; /// Returns a list of keys that are stored under the given `sub_namespace` in `namespace`. /// /// Returns the keys in arbitrary order, so users requiring a particular order need to sort the /// returned keys. Returns an empty list if `namespace` or `sub_namespace` is unknown. - fn list(&self, namespace: &str, sub_namespace: &str) -> io::Result>; + fn list(&self, namespace: &str, sub_namespace: &str) -> Result, io::Error>; } /// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.