Unverified Commit 639e5248 authored by Alexandru Vasile's avatar Alexandru Vasile
Browse files

Remove `PipeFromStreamResult`


Signed-off-by: default avatarAlexandru Vasile <alexandru.vasile@parity.io>
parent 1d983c77
Pipeline #200610 canceled with stages
in 4 minutes and 11 seconds
......@@ -775,55 +775,6 @@ impl<Context: Send + Sync + 'static> RpcModule<Context> {
}
}
/// The result obtain from calling [`PendingSubscription::pipe_from_try_stream`] that
/// can be utilized to execute specific operations depending on the result.
#[derive(Debug)]
pub enum PipeFromStreamResult {
/// The connection was accepted and the pipe returned [`SubscriptionClosed::Success`].
Success(Option<SubscriptionSink>),
/// The connection was accepted and the pipe returned [`SubscriptionClosed::Failed`]
/// with the provided error.
Failure(Option<(SubscriptionSink, ErrorObjectOwned)>),
/// The remote peer closed the connection or called the unsubscribe method.
RemotePeerAborted,
}
impl PipeFromStreamResult {
/// Callback that will run the provided function if the result is [`PipeFromStreamResult::Success(Some(_))`].
/// After the function runs a new [`PipeFromStreamResult::Success(None)`] is returned.
///
/// Otherwise, it leaves the object untouched.
pub fn on_success<F>(self, func: F) -> PipeFromStreamResult
where
F: FnOnce(SubscriptionSink) -> (),
{
match self {
PipeFromStreamResult::Success(Some(sink)) => {
func(sink);
PipeFromStreamResult::Success(None)
}
_ => self
}
}
/// Callback that will run the provided function if the result is [`PipeFromStreamResult::Failure(Some(_))`].
/// After the function runs a new [`PipeFromStreamResult::Failure(None)`] is returned.
///
/// Otherwise, it leaves the object untouched.
pub fn on_failure<F>(self, func: F) -> PipeFromStreamResult
where
F: FnOnce(SubscriptionSink, ErrorObjectOwned) -> (),
{
match self {
PipeFromStreamResult::Failure(Some((sink, error))) => {
func(sink, error);
PipeFromStreamResult::Failure(None)
}
_ => self
}
}
}
/// The state of the [`SubscriptionSink`].
#[derive(Debug)]
enum SubscriptionSinkState {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment