MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / list_insert

Function list_insert

nodedb-crdt/src/list_ops.rs:19–32  ·  view source on GitHub ↗

Insert a value into a block list at the specified index.

(
    doc: &LoroDoc,
    collection: &str,
    row_id: &str,
    list_path: &str,
    index: usize,
    value: LoroValue,
)

Source from the content-addressed store, hash-verified

17
18/// Insert a value into a block list at the specified index.
19pub fn list_insert(
20 doc: &LoroDoc,
21 collection: &str,
22 row_id: &str,
23 list_path: &str,
24 index: usize,
25 value: LoroValue,
26) -> Result<()> {
27 let list = get_movable_list(doc, collection, row_id, list_path)?;
28 let idx = index.min(list.len());
29 list.insert(idx, value)
30 .map_err(|e| CrdtError::Loro(format!("list insert at {idx}: {e}")))?;
31 Ok(())
32}
33
34/// Insert a LoroMap container into a block list at the specified index.
35///

Callers 1

list_insert_and_getFunction · 0.85

Calls 3

get_movable_listFunction · 0.85
lenMethod · 0.45
insertMethod · 0.45

Tested by 1

list_insert_and_getFunction · 0.68