Hide relative locktime error internals

As part of the 1.0 effort and forward maintainability hide the internals
of the two error types in the `relative` locktime module. Doing so
allows us to remove the `non_exhaustive` attribute. Add getters to get
at the error innards.
This commit is contained in:
Tobin C. Harding 2025-02-21 09:32:35 +11:00
parent e487618503
commit 2d8227f091
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 20 additions and 6 deletions

View File

@ -401,12 +401,19 @@ impl std::error::Error for DisabledLockTimeError {}
/// Tried to satisfy a lock-by-blocktime lock using a height value.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct IncompatibleHeightError {
/// Attempted to satisfy a lock-by-blocktime lock with this height.
pub height: Height,
height: Height,
/// The inner time value of the lock-by-blocktime lock.
pub time: Time,
time: Time,
}
impl IncompatibleHeightError {
/// Returns the height that was erroneously used to try and satisfy a lock-by-blocktime lock.
pub fn incompatible(&self) -> Height { self.height }
/// Returns the time value of the lock-by-blocktime lock.
pub fn expected(&self) -> Time { self.time }
}
impl fmt::Display for IncompatibleHeightError {
@ -424,12 +431,19 @@ impl std::error::Error for IncompatibleHeightError {}
/// Tried to satisfy a lock-by-blockheight lock using a time value.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct IncompatibleTimeError {
/// Attempted to satisfy a lock-by-blockheight lock with this time.
pub time: Time,
time: Time,
/// The inner height value of the lock-by-blockheight lock.
pub height: Height,
height: Height,
}
impl IncompatibleTimeError {
/// Returns the time that was erroneously used to try and satisfy a lock-by-blockheight lock.
pub fn incompatible(&self) -> Time { self.time }
/// Returns the height value of the lock-by-blockheight lock.
pub fn expected(&self) -> Height { self.height }
}
impl fmt::Display for IncompatibleTimeError {