Impl From trait for Responses from generic Error impls
Also include new Response::Error variant.
This commit is contained in:
parent
9cdef4acf0
commit
efd37300b9
|
@ -4,6 +4,8 @@
|
||||||
//! responses, so that we have unified types to pass around. No serialization
|
//! responses, so that we have unified types to pass around. No serialization
|
||||||
//! is performed as these are only internal types.
|
//! is performed as these are only internal types.
|
||||||
|
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
use zebra_chain::transaction::Transaction;
|
use zebra_chain::transaction::Transaction;
|
||||||
|
|
||||||
use crate::meta_addr::MetaAddr;
|
use crate::meta_addr::MetaAddr;
|
||||||
|
@ -32,8 +34,19 @@ pub enum Request {
|
||||||
pub enum Response {
|
pub enum Response {
|
||||||
/// Generic success.
|
/// Generic success.
|
||||||
Ok,
|
Ok,
|
||||||
|
/// Generic error.
|
||||||
|
Error,
|
||||||
/// A list of peers, used to respond to `GetPeers`.
|
/// A list of peers, used to respond to `GetPeers`.
|
||||||
Peers(Vec<MetaAddr>),
|
Peers(Vec<MetaAddr>),
|
||||||
/// A list of transactions, such as in response to `GetMempool`.
|
/// A list of transactions, such as in response to `GetMempool`.
|
||||||
Transactions(Vec<Transaction>),
|
Transactions(Vec<Transaction>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E> From<E> for Response
|
||||||
|
where
|
||||||
|
E: Error,
|
||||||
|
{
|
||||||
|
fn from(e: E) -> Self {
|
||||||
|
Self::Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue