Skip to content

Commit 9b4fa8b

Browse files
committed
Add RecoveryId getter
The `RecoveryId` is an enum but is typically serialized as an integer. We used to provide a `to_i32` function before #743. Add a `to_u8` getter to the `RecoveryId`
1 parent 2038b5e commit 9b4fa8b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/ecdsa/recovery.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ impl RecoveryId {
3636
_ => RecoveryId::Three,
3737
}
3838
}
39+
40+
/// Returns the `RecoveryId` as an integer.
41+
pub const fn to_u8(self) -> u8 {
42+
match self {
43+
RecoveryId::Zero => 0,
44+
RecoveryId::One => 1,
45+
RecoveryId::Two => 2,
46+
RecoveryId::Three => 3,
47+
}
48+
}
3949
}
4050

4151
impl TryFrom<i32> for RecoveryId {

0 commit comments

Comments
 (0)