Skip to content

Commit 1e5dfd3

Browse files
committed
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>`.
1 parent b4a854e commit 1e5dfd3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lightning/src/util/persist.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use bitcoin::hashes::hex::{FromHex, ToHex};
1313
use bitcoin::{BlockHash, Txid};
1414

1515
use crate::io;
16-
use crate::prelude::{Vec, String};
16+
use crate::prelude::*;
1717
use crate::routing::scoring::WriteableScore;
1818

1919
use crate::chain;
@@ -87,11 +87,11 @@ pub trait KVStore {
8787
/// `namespace` and `sub_namespace`.
8888
///
8989
/// [`ErrorKind::NotFound`]: io::ErrorKind::NotFound
90-
fn read(&self, namespace: &str, sub_namespace: &str, key: &str) -> io::Result<Vec<u8>>;
90+
fn read(&self, namespace: &str, sub_namespace: &str, key: &str) -> Result<Vec<u8>, io::Error>;
9191
/// Persists the given data under the given `key`.
9292
///
9393
/// Will create the given `namespace` and `sub_namespace` if not already present in the store.
94-
fn write(&self, namespace: &str, sub_namespace: &str, key: &str, buf: &[u8]) -> io::Result<()>;
94+
fn write(&self, namespace: &str, sub_namespace: &str, key: &str, buf: &[u8]) -> Result<(), io::Error>;
9595
/// Removes any data that had previously been persisted under the given `key`.
9696
///
9797
/// If the `lazy` flag is set to `true`, the backend implementation might choose to lazily
@@ -106,12 +106,12 @@ pub trait KVStore {
106106
///
107107
/// Returns successfully if no data will be stored for the given `namespace`, `sub_namespace`, and
108108
/// `key`, independently of whether it was present before its invokation or not.
109-
fn remove(&self, namespace: &str, sub_namespace: &str, key: &str, lazy: bool) -> io::Result<()>;
109+
fn remove(&self, namespace: &str, sub_namespace: &str, key: &str, lazy: bool) -> Result<(), io::Error>;
110110
/// Returns a list of keys that are stored under the given `sub_namespace` in `namespace`.
111111
///
112112
/// Returns the keys in arbitrary order, so users requiring a particular order need to sort the
113113
/// returned keys. Returns an empty list if `namespace` or `sub_namespace` is unknown.
114-
fn list(&self, namespace: &str, sub_namespace: &str) -> io::Result<Vec<String>>;
114+
fn list(&self, namespace: &str, sub_namespace: &str) -> Result<Vec<String>, io::Error>;
115115
}
116116

117117
/// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
@@ -205,7 +205,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner, K: KVStore> Persist<ChannelSign
205205
/// Read previously persisted [`ChannelMonitor`]s from the store.
206206
pub fn read_channel_monitors<K: Deref, ES: Deref, SP: Deref>(
207207
kv_store: K, entropy_source: ES, signer_provider: SP,
208-
) -> io::Result<Vec<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::Signer>)>>
208+
) -> Result<Vec<(BlockHash, ChannelMonitor<<SP::Target as SignerProvider>::Signer>)>, io::Error>
209209
where
210210
K::Target: KVStore,
211211
ES::Target: EntropySource + Sized,

0 commit comments

Comments
 (0)