MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / find

Function find

crates/bindings/src/table.rs:434–449  ·  view source on GitHub ↗
(col_val: &Col::ColType)

Source from the content-addressed store, hash-verified

432
433#[inline]
434fn find<Tbl: Table, Col: Index + Column<Table = Tbl>>(col_val: &Col::ColType) -> Option<Tbl::Row> {
435 // Find the row with a match.
436 let index_id = Col::index_id();
437 let point = IterBuf::serialize(col_val).unwrap();
438
439 let iter = datastore_index_scan_point_bsatn(index_id, &point);
440 let mut iter = TableIter::new_with_buf(iter, point);
441
442 // We will always find either 0 or 1 rows here due to the unique constraint.
443 let row = iter.next();
444 assert!(
445 iter.is_exhausted(),
446 "`datastore_index_scan_point_bsatn` on unique field cannot return >1 rows"
447 );
448 row
449}
450
451/// See `sys::datastore_index_scan_point_bsatn`.
452/// Panics when the aforementioned errors.

Callers 7

findMethod · 0.85
labelsMethod · 0.85
try_getMethod · 0.85
updateMethod · 0.85
try_insert_or_updateMethod · 0.85
delete_by_valueMethod · 0.85
updateMethod · 0.85

Calls 4

serializeFunction · 0.50
unwrapMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…