MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse

Method parse

atomic-repository/src/remote.rs:293–316  ·  view source on GitHub ↗

Parse remote configuration from TOML content.

(content: &str, path: &Path)

Source from the content-addressed store, hash-verified

291
292 /// Parse remote configuration from TOML content.
293 fn parse(content: &str, path: &Path) -> RemoteResult<Self> {
294 // Parse the full config file as a table
295 let full_config: toml::map::Map<String, toml::Value> =
296 toml::from_str(content).map_err(|e| RemoteError::ParseError {
297 path: path.display().to_string(),
298 message: e.to_string(),
299 })?;
300
301 // Extract the remotes section
302 let remotes = if let Some(remotes_value) = full_config.get("remotes") {
303 // Convert the Value directly to the expected type
304 remotes_value
305 .clone()
306 .try_into::<BTreeMap<String, RemoteEntry>>()
307 .map_err(|e| RemoteError::ParseError {
308 path: path.display().to_string(),
309 message: format!("invalid remotes section: {}", e),
310 })?
311 } else {
312 BTreeMap::new()
313 };
314
315 Ok(Self { remotes })
316 }
317
318 /// Save remote configuration to a config file.
319 ///

Callers

nothing calls this directly

Calls 3

displayMethod · 0.80
getMethod · 0.65
cloneMethod · 0.45

Tested by

no test coverage detected