diff --git a/primitives/src/coding.rs b/primitives/src/coding.rs index 9ab60026..676a61e6 100644 --- a/primitives/src/coding.rs +++ b/primitives/src/coding.rs @@ -85,8 +85,17 @@ impl LenVarInt for VarIntArray { #[strict_type(lib = LIB_NAME_BITCOIN)] #[wrapper(Deref, Index, RangeOps, BorrowSlice)] #[wrapper_mut(DerefMut, IndexMut, RangeMut, BorrowSliceMut)] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", transparent) +)] pub struct ByteStr(VarIntArray); +impl AsRef<[u8]> for ByteStr { + fn as_ref(&self) -> &[u8] { self.0.as_slice() } +} + impl From> for ByteStr { fn from(value: Vec) -> Self { Self(Confined::try_from(value).expect("u64 >= usize")) } }