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

Function has_content

atomic-core/src/record/workflow/retrieve.rs:277–295  ·  view source on GitHub ↗

Check if a position has any content. This is a lighter-weight check than full retrieval, useful for quickly determining if a file exists in the graph. # Arguments `txn` - Transaction providing graph access `changes` - Change store for content retrieval `position` - Position to check # Returns `true` if the position has content vertices.

(txn: &T, changes: &C, position: Position<NodeId>)

Source from the content-addressed store, hash-verified

275///
276/// `true` if the position has content vertices.
277pub fn has_content<T, C>(txn: &T, changes: &C, position: Position<NodeId>) -> RecordResult<bool>
278where
279 T: GraphTxnT,
280 C: ChangeStore,
281{
282 if position == Position::ROOT {
283 return Ok(false);
284 }
285
286 // Try to retrieve content - if we get anything, it has content
287 let opts = RetrieveContentOptions::new().max_vertices(1);
288 match retrieve_content_with_options(txn, changes, position, opts) {
289 Ok(result) => Ok(!result.is_empty()),
290 Err(RecordError::Pristine(e)) if matches!(*e, PristineError::BlockNotFound { .. }) => {
291 Ok(false)
292 }
293 Err(e) => Err(e),
294 }
295}
296
297// STATE-BASED CONTENT RETRIEVAL
298

Callers 4

test_has_content_rootFunction · 0.85
has_recorded_contentMethod · 0.85

Calls 3

max_verticesMethod · 0.45
is_emptyMethod · 0.45

Tested by 3

test_has_content_rootFunction · 0.68