MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / parse_config

Method parse_config

crates/cli/src/config.rs:614–624  ·  view source on GitHub ↗

Parse [`RawConfig`] from a TOML file at the given path, returning `None` if the file does not exist. NOTE**: Comments and formatting in the file will be preserved.

(path: &Path)

Source from the content-addressed store, hash-verified

612 ///
613 /// **NOTE**: Comments and formatting in the file will be preserved.
614 fn parse_config(path: &Path) -> anyhow::Result<Option<(toml_edit::DocumentMut, RawConfig)>> {
615 match std::fs::read_to_string(path) {
616 Ok(contents) => {
617 let doc = contents.parse::<toml_edit::DocumentMut>()?;
618 let config = RawConfig::try_from(&doc)?;
619 Ok(Some((doc, config)))
620 }
621 Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(None),
622 Err(e) => Err(e.into()),
623 }
624 }
625
626 pub fn load(home_path: CliTomlPath) -> anyhow::Result<Self> {
627 let home = Self::parse_config(home_path.as_ref())

Callers

nothing calls this directly

Calls 3

OkFunction · 0.50
ErrFunction · 0.50
kindMethod · 0.45

Tested by

no test coverage detected