Skip to content

Commit c4d6ee6

Browse files
committed
feat: add serde Serialize support for Cost and NodeBounds
This is useful for downstream users to determine if annex padding is needed
1 parent 050f9bd commit c4d6ee6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/analysis.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use std::{cmp, fmt};
66
use crate::value::Word;
77
#[cfg(feature = "elements")]
88
use elements::encode::Encodable;
9+
#[cfg(feature = "serde")]
10+
use serde::Serialize;
911
#[cfg(feature = "elements")]
1012
use std::{convert::TryFrom, io};
1113

@@ -65,6 +67,7 @@ impl From<U32Weight> for bitcoin::Weight {
6567
/// Programs that are CPU-heavy need to be padded
6668
/// so that the witness stack provides a large-enough budget.
6769
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
70+
#[cfg_attr(feature = "serde", derive(Serialize))]
6871
pub struct Cost(u32);
6972

7073
impl Cost {
@@ -234,6 +237,7 @@ impl From<Cost> for bitcoin::Weight {
234237

235238
/// Bounds on the resources required by a node during execution on the Bit Machine
236239
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
240+
#[cfg_attr(feature = "serde", derive(Serialize))]
237241
pub struct NodeBounds {
238242
/// Upper bound on the required number of cells (bits).
239243
/// The root additionally requires the bit width of its source and target type (input, output)

0 commit comments

Comments
 (0)