(
backend: &RedbFtsBackend,
tid: u64,
collection: &str,
segment_id: &str,
)
| 34 | } |
| 35 | |
| 36 | pub(super) fn read( |
| 37 | backend: &RedbFtsBackend, |
| 38 | tid: u64, |
| 39 | collection: &str, |
| 40 | segment_id: &str, |
| 41 | ) -> crate::Result<Option<Vec<u8>>> { |
| 42 | let read_txn = backend |
| 43 | .db |
| 44 | .begin_read() |
| 45 | .map_err(|e| redb_err("read txn", e))?; |
| 46 | let table = read_txn |
| 47 | .open_table(SEGMENTS) |
| 48 | .map_err(|e| redb_err("open segments", e))?; |
| 49 | let bytes = match table.get((tid, collection, segment_id)) { |
| 50 | Ok(Some(val)) => val.value().to_vec(), |
| 51 | Ok(None) => return Ok(None), |
| 52 | Err(e) => return Err(redb_err("get segment", e)), |
| 53 | }; |
| 54 | |
| 55 | if let Some(reg) = &backend.quarantine_registry { |
| 56 | let validated = |
| 57 | validate_fts_segment_bytes(reg, bytes, collection, segment_id).map_err(|e| { |
| 58 | crate::Error::SegmentCorrupted { |
| 59 | detail: e.to_string(), |
| 60 | } |
| 61 | })?; |
| 62 | Ok(Some(validated)) |
| 63 | } else { |
| 64 | Ok(Some(bytes)) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | pub(super) fn list( |
| 69 | backend: &RedbFtsBackend, |
nothing calls this directly
no test coverage detected