radicle-heartwood-lfs/radicle-node/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
..
runtime node: Have multiple fetch queues 2024-07-16 17:11:46 +02:00
service Update `rust-toolchain` to 1.80 2024-08-06 14:37:21 +02:00
test Include new `rad/root` in signed refs 2024-10-21 16:32:49 +02:00
tests node: test multiple offline inits 2024-07-22 10:48:10 +02:00
wire node: Don't panic on connection logic error 2024-06-26 11:31:07 +02:00
worker Include new `rad/root` in signed refs 2024-10-21 16:32:49 +02:00
bounded.rs node: Use inventory cache for checking missing 2024-05-13 16:37:02 +02:00
control.rs node: Rename certain functions for clarity 2024-06-12 15:36:34 +02:00
deserializer.rs node: Use `BoundedVec` for inbox 2024-05-07 14:49:02 +02:00
lib.rs build: Update env vars for build process 2024-06-20 10:47:50 +02:00
main.rs node: Fix `main` to print early errors 2024-07-22 12:37:57 -07:00
runtime.rs Update `rust-toolchain` to 1.80 2024-08-06 14:37:21 +02:00
service.rs radicle: refactor doc 2024-10-22 14:58:12 +01:00
test.rs radicle: expose shared logger 2023-12-20 15:11:10 +01:00
tests.rs radicle: refactor doc 2024-10-22 14:58:12 +01:00
wire.rs node: Add agent and version to node announcement 2024-06-13 11:28:09 +02:00
worker.rs radicle: refactor doc 2024-10-22 14:58:12 +01:00