brk_types/
p2wshbytes.rs

1use std::fmt;
2
3use derive_more::Deref;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use vecdb::{Bytes, Formattable};
7
8use crate::U8x32;
9
10#[derive(
11    Debug,
12    Clone,
13    Deref,
14    PartialEq,
15    Eq,
16    PartialOrd,
17    Ord,
18    Serialize,
19    Deserialize,
20    Bytes,
21    Hash,
22    JsonSchema,
23)]
24pub struct P2WSHBytes(U8x32);
25
26impl From<&[u8]> for P2WSHBytes {
27    #[inline]
28    fn from(value: &[u8]) -> Self {
29        Self(U8x32::from(value))
30    }
31}
32
33impl From<U8x32> for P2WSHBytes {
34    #[inline]
35    fn from(value: U8x32) -> Self {
36        Self(value)
37    }
38}
39
40impl fmt::Display for P2WSHBytes {
41    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42        write!(f, "{:?}", self.0)
43    }
44}
45
46impl Formattable for P2WSHBytes {
47    #[inline(always)]
48    fn may_need_escaping() -> bool {
49        true
50    }
51}