Extract a display string from `field`, or evaluate `expr` if provided. Returns `None` when the field is absent.
(doc: &[u8], field: &str, expr: Option<&SqlExpr>)
| 39 | /// Extract a display string from `field`, or evaluate `expr` if provided. |
| 40 | /// Returns `None` when the field is absent. |
| 41 | pub fn extract_str(doc: &[u8], field: &str, expr: Option<&SqlExpr>) -> Option<String> { |
| 42 | if let Some(expr) = expr { |
| 43 | return Some(value_ops::value_to_display_string(&eval_expr(doc, expr)?)); |
| 44 | } |
| 45 | let (start, _end) = extract_field(doc, 0, field)?; |
| 46 | read_str(doc, start).map(|s| s.to_string()) |
| 47 | } |
| 48 | |
| 49 | /// Extract a field as `Value`. Uses direct msgpack→Value for scalars; |
| 50 | /// falls back to full document decode only for complex types. |
no test coverage detected