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,
)
| 17 | |
| 18 | /// Insert a value into a block list at the specified index. |
| 19 | pub 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 | /// |