Skip to content

Commit

Permalink
Refactor: RaftError: serde derive
Browse files Browse the repository at this point in the history
The problem is not the bound on the `E` generic, but rather, the fact
that `NID` is receiving two different `Serialize/Deserialize` bounds;
one from the derive annotation, and one from the `NID: NodeId` trait
bound.

This modification is from suggestions by @tvsfx about the serde bound:
databendlabs#991 (comment)
  • Loading branch information
drmingdrmer committed Jan 17, 2024
1 parent 55d9525 commit e09803c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions openraft/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ use crate::Vote;
/// It is either a Fatal error indicating that `Raft` is no longer running, such as underlying IO
/// error, or an API error `E`.
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(
feature = "serde",
derive(serde::Deserialize, serde::Serialize),
serde(bound(serialize = "E: serde::Serialize")),
serde(bound(deserialize = "E: for <'d> serde::Deserialize<'d>"))
)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum RaftError<NID, E = Infallible>
where NID: NodeId
{
#[error(transparent)]
APIError(E),

#[cfg_attr(feature = "serde", serde(bound = ""))]
#[error(transparent)]
Fatal(#[from] Fatal<NID>),
}
Expand Down

0 comments on commit e09803c

Please sign in to comment.