bitcoin_primitives/script/
error.rs1use core::convert::Infallible;
6use core::fmt;
7
8use encoding::ByteVecDecoderError;
9use internals::write_err;
10
11#[rustfmt::skip] #[doc(inline)]
13pub use crate::hash_types::{RedeemScriptSizeError, WitnessScriptSizeError};
14#[doc(inline)]
15pub use super::push_bytes::PushBytesError;
16
17#[derive(Debug, Clone, PartialEq, Eq)]
19pub struct ScriptBufDecoderError(pub(super) ByteVecDecoderError);
20
21impl From<Infallible> for ScriptBufDecoderError {
22 fn from(never: Infallible) -> Self { match never {} }
23}
24
25impl fmt::Display for ScriptBufDecoderError {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write_err!(f, "decoder error"; self.0) }
27}
28
29#[cfg(feature = "std")]
30impl std::error::Error for ScriptBufDecoderError {
31 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.0) }
32}