Enum EncodeSigningDataResult
pub enum EncodeSigningDataResult<E> {
SighashSingleBug,
WriteResult(Result<(), E>),
}Expand description
Result of SighashCache::legacy_encode_signing_data_to.
This type forces the caller to handle SIGHASH_SINGLE bug case.
This corner case can’t be expressed using standard Result,
in a way that is both convenient and not-prone to accidental
mistakes (like calling .expect("writer never fails")).
Variants§
SighashSingleBug
Input data is an instance of SIGHASH_SINGLE bug
WriteResult(Result<(), E>)
Operation performed normally.
Implementations§
§impl<E> EncodeSigningDataResult<E>
impl<E> EncodeSigningDataResult<E>
pub fn is_sighash_single_bug(self) -> Result<bool, E>
pub fn is_sighash_single_bug(self) -> Result<bool, E>
Checks for SIGHASH_SINGLE bug returning error if the writer failed.
This method is provided for easy and correct handling of the result because SIGHASH_SINGLE bug is a special case that must not be ignored nor cause panicking. Since the data is usually written directly into a hasher which never fails, the recommended pattern to handle this is:
let cache = SighashCache::new(&tx);
if cache.legacy_encode_signing_data_to(&mut writer, input_index, &script_pubkey, sighash_u32)
.is_sighash_single_bug()
.expect("writer can't fail") {
// use a hash value of "1", instead of computing the actual hash due to SIGHASH_SINGLE bug
}pub fn map_err<E2, F>(self, f: F) -> EncodeSigningDataResult<E2>where
F: FnOnce(E) -> E2,
pub fn map_err<E2, F>(self, f: F) -> EncodeSigningDataResult<E2>where
F: FnOnce(E) -> E2,
Maps a Result<T, E> to Result<T, F> by applying a function to a
contained Err value, leaving an Ok value untouched.
Like Result::map_err.
Auto Trait Implementations§
impl<E> Freeze for EncodeSigningDataResult<E>where
E: Freeze,
impl<E> RefUnwindSafe for EncodeSigningDataResult<E>where
E: RefUnwindSafe,
impl<E> Send for EncodeSigningDataResult<E>where
E: Send,
impl<E> Sync for EncodeSigningDataResult<E>where
E: Sync,
impl<E> Unpin for EncodeSigningDataResult<E>where
E: Unpin,
impl<E> UnwindSafe for EncodeSigningDataResult<E>where
E: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request