protocol/service: introduce Result synonym

Create a type synonym for `Result<T, Error>`, to simplify result types
being returned by commands in a later change.
This commit is contained in:
Fintan Halpenny 2026-02-13 08:35:01 +00:00 committed by Lorenz Leutgeb
parent 2c1972151d
commit 61a9b2140f
1 changed files with 7 additions and 2 deletions

View File

@ -13,7 +13,12 @@ use thiserror::Error;
use super::ServiceState; use super::ServiceState;
/// Function used to query internal service state. /// Function used to query internal service state.
pub type QueryState = dyn Fn(&dyn ServiceState) -> Result<(), Error> + Send + Sync; pub type QueryState = dyn Fn(&dyn ServiceState) -> Result<()> + Send + Sync;
/// A result returned from processing a [`Command`].
///
/// It is a type synonym for a [`std::result::Result`]
pub type Result<T> = std::result::Result<T, Error>;
/// Commands sent to the service by the operator. /// Commands sent to the service by the operator.
pub enum Command { pub enum Command {
@ -45,7 +50,7 @@ pub enum Command {
/// Unfollow the given node. /// Unfollow the given node.
Unfollow(NodeId, Sender<bool>), Unfollow(NodeId, Sender<bool>),
/// Query the internal service state. /// Query the internal service state.
QueryState(Arc<QueryState>, Sender<Result<(), Error>>), QueryState(Arc<QueryState>, Sender<Result<()>>),
} }
impl fmt::Debug for Command { impl fmt::Debug for Command {