Skip to content

Commit b00cd3d

Browse files
committed
docs(gctx): how and why for CV->types deserilzation workflow
1 parent f917444 commit b00cd3d

File tree

1 file changed

+22
-1
lines changed
  • src/cargo/util/context

1 file changed

+22
-1
lines changed

src/cargo/util/context/de.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
//! Support for deserializing configuration via `serde`
1+
//! Deserialization for converting [`ConfigValue`] instances to target types.
2+
//!
3+
//! The [`Deserializer`] type is the main driver of deserialization.
4+
//! The workflow is roughly:
5+
//!
6+
//! 1. [`GlobalContext::get<T>()`] creates [`Deserializer`] and calls `T::deserialize()`
7+
//! 2. Then call type-specific deserialize methods as in normal serde deserialization.
8+
//! - For primitives, `deserialize_*` methods look up [`ConfigValue`] instances
9+
//! in [`GlobalContext`] and convert.
10+
//! - Structs and maps are handled by [`ConfigMapAccess`].
11+
//! - Sequences are handled by [`ConfigSeqAccess`],
12+
//! which later uses [`ArrayItemDeserializer`] for each array item.
13+
//! - [`Value<T>`] is delegated to [`ValueDeserializer`] in `deserialize_struct`.
14+
//!
15+
//! The purpose of this workflow is to:
16+
//!
17+
//! - Retrieve the correct config value based on source location precedence
18+
//! - Provide richer error context showing where a config is defined
19+
//! - Provide a richer internal API to map to concrete config types
20+
//! without touching underlying [`ConfigValue`] directly
21+
//!
22+
//! [`ConfigValue`]: CV
223
324
use crate::util::context::value;
425
use crate::util::context::{ConfigError, ConfigKey, GlobalContext};

0 commit comments

Comments
 (0)