Skip to content

Commit 35d3fca

Browse files
committed
policy: Remove FromStr implementation
I would like to keep an implementation of FromStr, but I don't want to copy all of the expression parsing from Miniscript. We don't need FromStr right now, and Miniscript can implement a parser using <Tree as FromStr> and FromTree<Policy>. We might want to implement a parser on the Simplicity side, which might use ideas from the dag module or simplang. Removing FromStr also means removing the associated fuzz test.
1 parent 039c569 commit 35d3fca

File tree

6 files changed

+0
-393
lines changed

6 files changed

+0
-393
lines changed

.github/workflows/fuzz.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
c_rust_merkle,
2020
decode_natural,
2121
decode_program,
22-
parse_compile,
2322
]
2423
steps:
2524
- name: Install test dependencies

fuzz/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,3 @@ path = "fuzz_targets/decode_natural.rs"
2727
[[bin]]
2828
name = "decode_program"
2929
path = "fuzz_targets/decode_program.rs"
30-
31-
#[[bin]]
32-
#name = "parse_compile"
33-
#path = "fuzz_targets/parse_compile.rs"

fuzz/fuzz_targets/parse_compile.rs

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/macros.rs

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -14,105 +14,3 @@ macro_rules! decode_bits {
1414
}
1515
};
1616
}
17-
18-
/// Copied from rust-miniscript
19-
///
20-
/// A macro that implements serde serialization and deserialization using the
21-
/// `fmt::Display` and `str::FromStr` traits.
22-
#[cfg(feature = "elements")]
23-
macro_rules! serde_string_impl_pk {
24-
($name:ident, $expecting:expr $(, $gen:ident; $gen_con:ident)*) => {
25-
#[cfg(feature = "serde")]
26-
impl<'de, Pk $(, $gen)*> $crate::serde::Deserialize<'de> for $name<Pk $(, $gen)*>
27-
where
28-
Pk: crate::miniscript::ToPublicKey + core::str::FromStr,
29-
Pk::Sha256: core::str::FromStr,
30-
Pk::Hash256: core::str::FromStr,
31-
Pk::Ripemd160: core::str::FromStr,
32-
Pk::Hash160: core::str::FromStr,
33-
<Pk as core::str::FromStr>::Err: core::fmt::Display,
34-
<<Pk as crate::miniscript::MiniscriptKey>::Sha256 as core::str::FromStr>::Err:
35-
core::fmt::Display,
36-
<<Pk as crate::miniscript::MiniscriptKey>::Hash256 as core::str::FromStr>::Err:
37-
core::fmt::Display,
38-
<<Pk as crate::miniscript::MiniscriptKey>::Ripemd160 as core::str::FromStr>::Err:
39-
core::fmt::Display,
40-
<<Pk as crate::miniscript::MiniscriptKey>::Hash160 as core::str::FromStr>::Err:
41-
core::fmt::Display,
42-
$($gen : $gen_con,)*
43-
{
44-
fn deserialize<D>(deserializer: D) -> Result<$name<Pk $(, $gen)*>, D::Error>
45-
where
46-
D: $crate::serde::de::Deserializer<'de>,
47-
{
48-
use core::fmt::{self, Formatter};
49-
use core::marker::PhantomData;
50-
use core::str::FromStr;
51-
52-
#[allow(unused_parens)]
53-
struct Visitor<Pk $(, $gen)*>(PhantomData<(Pk $(, $gen)*)>);
54-
impl<'de, Pk $(, $gen)*> $crate::serde::de::Visitor<'de> for Visitor<Pk $(, $gen)*>
55-
where
56-
Pk: crate::miniscript::ToPublicKey + core::str::FromStr,
57-
Pk::Sha256: core::str::FromStr,
58-
Pk::Hash256: core::str::FromStr,
59-
Pk::Ripemd160: core::str::FromStr,
60-
Pk::Hash160: core::str::FromStr,
61-
<Pk as core::str::FromStr>::Err: core::fmt::Display,
62-
<<Pk as crate::miniscript::MiniscriptKey>::Sha256 as core::str::FromStr>::Err:
63-
core::fmt::Display,
64-
<<Pk as crate::miniscript::MiniscriptKey>::Hash256 as core::str::FromStr>::Err:
65-
core::fmt::Display,
66-
<<Pk as crate::miniscript::MiniscriptKey>::Ripemd160 as core::str::FromStr>::Err:
67-
core::fmt::Display,
68-
<<Pk as crate::miniscript::MiniscriptKey>::Hash160 as core::str::FromStr>::Err:
69-
core::fmt::Display,
70-
$($gen: $gen_con,)*
71-
{
72-
type Value = $name<Pk $(, $gen)*>;
73-
74-
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
75-
formatter.write_str($expecting)
76-
}
77-
78-
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
79-
where
80-
E: $crate::serde::de::Error,
81-
{
82-
$name::from_str(v).map_err(E::custom)
83-
}
84-
85-
fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E>
86-
where
87-
E: $crate::serde::de::Error,
88-
{
89-
self.visit_str(v)
90-
}
91-
92-
fn visit_string<E>(self, v: String) -> Result<Self::Value, E>
93-
where
94-
E: $crate::serde::de::Error,
95-
{
96-
self.visit_str(&v)
97-
}
98-
}
99-
100-
deserializer.deserialize_str(Visitor(PhantomData))
101-
}
102-
}
103-
104-
#[cfg(feature = "serde")]
105-
impl<'de, Pk $(, $gen)*> $crate::serde::Serialize for $name<Pk $(, $gen)*>
106-
where
107-
Pk: crate::miniscript::ToPublicKey,
108-
$($gen: $gen_con,)*
109-
{
110-
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
111-
where
112-
S: $crate::serde::Serializer,
113-
{
114-
serializer.collect_str(&self)
115-
}
116-
}
117-
};
118-
}

0 commit comments

Comments
 (0)