radicle-heartwood-lfs/radicle-fetch/src
Fintan Halpenny de1958fab0 radicle: refactor doc
The aim of this change is to make the `Doc` type more safe to use by approaching
the design via [Parse don't validate][[0]] approach.

The problem with the previous approach was that all field were `pub` and thus a
`Doc<Verified>` could easily be mutated and serialized. Granted, the code that
used the serialization would tend to verify the `Doc` first, however, this
approach *ensures* that only a verified `Doc` can be serialized. It also meant
that trying to add new data that would follow the parse approach would require
more generic parameters on top of the existing `PhantomData` parameter, i.e. we
need to do something like: `Doc<RawField, V> -> Doc<ValidField, V>`.

The new approach splits the type into two separate types: `RawDoc` and `Doc`.
The former is allowed to be mutated at will, and uses types that are less
strict. The latter is the valid type that can only be constructed by validating
a `RawDoc` (or the `initial` constructor). The `Doc` type's fields can then only
be accessed by read-only methods.

Solves the problems above by only allowing mutations to `RawDoc`, as well as,
new fields being added to `RawDoc` which are then validated via
`RawDoc::verified`.

[0]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
2024-10-22 14:58:12 +01:00
..
git fetch: remove `.keep` files 2024-05-16 15:47:14 +02:00
transport Update `rust-toolchain` to 1.80 2024-08-06 14:37:21 +02:00
git.rs fetch: upgrade gix crates 2024-05-17 13:27:18 +02:00
handle.rs radicle: refactor doc 2024-10-22 14:58:12 +01:00
lib.rs node: Don't depend on `gix` directly 2024-07-16 15:57:27 +02:00
policy.rs node: Simplify configuration 2024-06-04 14:08:15 +02:00
refs.rs Update toolchain to Rust 1.77 2024-03-26 10:03:11 +01:00
sigrefs.rs radicle: fault tolerant thresholds 2024-04-03 14:30:05 +02:00
stage.rs radicle: refactor doc 2024-10-22 14:58:12 +01:00
state.rs radicle: refactor doc 2024-10-22 14:58:12 +01:00
transport.rs fetch: upgrade gix crates 2024-05-17 13:27:18 +02:00