Read-only graph operations This is the base trait that provides read access to the repository graph. All other transaction traits extend this one. # Graph Structure The graph consists of: - **Vertices**: Ranges of content within changes, identified by (change_id, start, end) - **Edges**: Connections between vertices with flags indicating relationship type # ID System Atomic uses two ID system
| 28 | /// |
| 29 | /// This trait provides methods to translate between these two systems. |
| 30 | pub trait GraphTxnT { |
| 31 | /// Iterator type for adjacency lists |
| 32 | /// |
| 33 | /// This returns edges from a span. The iterator yields `Result` to handle |
| 34 | /// potential storage errors during iteration. |
| 35 | type Adj: Iterator<Item = Result<SerializedGraphEdge, PristineError>>; |
| 36 | |
| 37 | /// Get the external hash for an internal node ID. |
| 38 | /// |
| 39 | /// Translates a repository-local NodeId to the globally-unique content hash. |
| 40 | /// |
| 41 | /// # Returns |
| 42 | /// |
| 43 | /// * `Ok(Some(hash))` - The corresponding hash |
| 44 | /// * `Ok(None)` - The NodeId is not registered |
| 45 | /// * `Err(_)` - Database error |
| 46 | fn get_external(&self, id: NodeId) -> Result<Option<Hash>, PristineError>; |
| 47 | |
| 48 | /// Get the internal node ID for an external hash. |
| 49 | /// |
| 50 | /// Translates a globally-unique content hash to a repository-local NodeId. |
| 51 | /// This is the inverse of `get_external`. |
| 52 | fn get_internal(&self, hash: &Hash) -> Result<Option<NodeId>, PristineError>; |
| 53 | |
| 54 | /// List registered normal changes as `(NodeId, Hash)` pairs. |
| 55 | /// |
| 56 | /// Implementations backed by pristine should filter out tags, |
| 57 | /// attestations, and provenance nodes. The default is empty for tests and |
| 58 | /// lightweight mocks that do not model registration tables. |
| 59 | fn list_registered_changes(&self) -> Result<Vec<(NodeId, Hash)>, PristineError> { |
| 60 | Ok(Vec::new()) |
| 61 | } |
| 62 | |
| 63 | /// Initialize an adjacency iterator for a span. |
| 64 | /// |
| 65 | /// Returns an iterator over edges from the given span that have flags |
| 66 | /// within the specified range. This allows filtering edges by type. |
| 67 | /// |
| 68 | /// # Arguments |
| 69 | /// |
| 70 | /// * `node` - The source span |
| 71 | /// * `min_flag` - Minimum edge flags (inclusive) |
| 72 | /// * `max_flag` - Maximum edge flags (inclusive) |
| 73 | /// |
| 74 | /// # Example |
| 75 | /// |
| 76 | /// ```ignore |
| 77 | /// // Get all non-deleted block edges |
| 78 | /// let edges = txn.iter_adjacent( |
| 79 | /// span, |
| 80 | /// EdgeFlags::BLOCK, |
| 81 | /// EdgeFlags::BLOCK | EdgeFlags::PSEUDO, |
| 82 | /// )?; |
| 83 | /// |
| 84 | /// for result in edges { |
| 85 | /// let edge = result?; |
| 86 | /// println!("Edge to {:?}", edge.dest()); |
| 87 | /// } |
no outgoing calls
no test coverage detected