radicle: canonical reference rules
Introduce the `rules` module beneath `canonical`. The implementation follows
the Canonical References RIP[^0].
A `Rule` defines the DIDs and threshold required to get the canonical tip
for a reference (or set of references). Since a `Rule` has some specific
validation rules, there can be two versions of a `Rule`. The `RawRule` is one
that can be easily constructed, serialized, and deserialized. It must then be
validated into a `ValidRule`, which validates any constraints, and can be used
in the computing of a canonical tip.
For convenience, a set of `ValidRule`s is wrapped into the `Rules` type, which
also has a further constraint that each rule refers to a specific `refspec`.
[0]: 1d1ce874f7
This commit is contained in:
parent
fb8681f5bc
commit
af6cf03acd
|
|
@ -845,6 +845,12 @@ dependencies = [
|
|||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fast-glob"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3afcf4effa2c44390b9912544582d5af29e10dc4c816c5dbebf748e1c7416faa"
|
||||
|
||||
[[package]]
|
||||
name = "faster-hex"
|
||||
version = "0.9.0"
|
||||
|
|
@ -2464,6 +2470,7 @@ dependencies = [
|
|||
"crossbeam-channel",
|
||||
"cyphernet",
|
||||
"emojis",
|
||||
"fast-glob",
|
||||
"fastrand",
|
||||
"git2",
|
||||
"jsonschema",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ chrono = { workspace = true, features = ["clock"], optional = true }
|
|||
colored = { workspace = true, optional = true }
|
||||
crossbeam-channel = { workspace = true }
|
||||
cyphernet = { workspace = true, features = ["tor", "dns", "p2p-ed25519"] }
|
||||
fast-glob = { version = "0.3.2" }
|
||||
fastrand = { workspace = true }
|
||||
git2 = { workspace = true, features = ["vendored-libgit2"] }
|
||||
libc = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
pub mod rules;
|
||||
pub use rules::{MatchedRule, RawRule, Rules, ValidRule};
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -477,6 +477,12 @@ impl AsRef<NonEmpty<Did>> for Delegates {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Did> for Delegates {
|
||||
fn from(did: Did) -> Self {
|
||||
Self(NonEmpty::new(did))
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Vec<Did>> for Delegates {
|
||||
type Error = DelegatesError;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue