Expand description
§Atom Publishing
This module provides the types and logic necessary to efficiently publish atoms to store implementations. The publishing system is designed to be safe, atomic, and provide detailed feedback about the publishing process.
§Architecture
The publishing system is built around two main traits:
Builder- Constructs and validates publishers before publishingPublish- Handles the actual publishing of atoms to stores
§Publishing Process
- Validation - All atoms in the workspace are validated for consistency
- Deduplication - Duplicate atoms are detected and skipped
- Publishing - Valid atoms are published to the target store
- Reporting - Detailed statistics and results are provided
§Key Types
Record- Contains the result of publishing a single atomStats- Aggregated statistics for a publishing operationPublishOutcome- Result type for individual atom publishing attempts (internal)Content- Backend-specific content information
§Backends
The architecture is designed to support multiple backends.
- Git - Publishes atoms as Git objects in repositories (when
gitfeature is enabled)
§Safety Features
- Atomic operations - Failed publishes don’t leave partial state
- Duplicate detection - Prevents accidental overwrites
- Comprehensive validation - Ensures atom consistency before publishing
- Detailed error reporting - Clear feedback on what succeeded or failed
§Example Usage
use std::path::PathBuf;
use atom::publish::git::GitPublisher;
use atom::publish::{Builder, Publish, Stats};
use atom::store::QueryVersion;
use atom::store::git::Root;
let repo = gix::open(".")?;
// Create a publisher for a Git repository
let progress_span = tracing::info_span!("test");
let publisher = GitPublisher::new(&repo, "origin", "main", &progress_span)?;
// Build and validate the publisher
let (valid_atoms, publisher) = publisher.build()?;
// query upstream store for remote atom refs to compare against
let remote = publisher.remote();
let remote_atoms = remote.remote_atoms(None);
// Publish all atoms
let results = publisher.publish(vec![PathBuf::from("/path/to/atom")], remote_atoms);
// Check results
let stats = Stats::default();
for result in results {
match result {
Ok(outcome) => todo!(), // e.g. log `outcome`
Err(e) => println!("Failed: {:?}", e),
}
}Modules§
Structs§
- Record
- Represents the result of publishing a single atom, for reporting to the user.
- Stats
- Basic statistics collected during a publishing request.
Enums§
- Content
- Contains backend-specific content information for reporting results to the user.
Constants§
- ATOM_
FORMAT_ 🔒VERSION - ATOM_
MANIFEST 🔒 - ATOM_
META_ 🔒REF - ATOM_
ORIGIN 🔒 - ATOM_
REF 🔒 - EMPTY_
SIG 🔒 - STORE_
ROOT 🔒
Statics§
Traits§
- Builder
- A builder for a
Publishimplementation. - Publish
- The primary trait for exposing atom publishing logic for a given store.
- State
Validator 🔒 - Validates the state of the atom source.
Type Aliases§
- Maybe
Skipped 🔒 - A
Resultindicating that an atom may have been skipped. - Publish
Outcome 🔒 - The outcome of an attempt to publish a single atom.
- Valid
Atoms 🔒 - A
HashMapcontaining all valid atoms in the current workspace.