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

Method open

atomic-identity/src/store.rs:369–391  ·  view source on GitHub ↗

Open or create an identity store at the specified path.

(root: &Path)

Source from the content-addressed store, hash-verified

367
368 /// Open or create an identity store at the specified path.
369 pub fn open(root: &Path) -> Result<Self, IdentityError> {
370 // Create the directory if it doesn't exist
371 if !root.exists() {
372 fs::create_dir_all(root)?;
373 }
374
375 // Load or create configuration
376 let config_path = root.join(Self::CONFIG_FILE);
377 let config = if config_path.exists() {
378 let content = fs::read_to_string(&config_path)?;
379 toml::from_str(&content)?
380 } else {
381 let config = StoreConfig::new();
382 let content = toml::to_string_pretty(&config)?;
383 fs::write(&config_path, content)?;
384 config
385 };
386
387 Ok(Self {
388 root: root.to_path_buf(),
389 config,
390 })
391 }
392
393 /// Get the default store path.
394 ///

Callers 4

try_append_agent_traceFunction · 0.45
try_turn_end_lockMethod · 0.45
with_accumulatorMethod · 0.45
save_accumulatorMethod · 0.45

Calls 2

writeFunction · 0.85
existsMethod · 0.45

Tested by

no test coverage detected