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

Function extract_string

nodedb-sql/src/planner/select/entry_ann.rs:210–226  ·  view source on GitHub ↗

Extract a string literal from a function argument expression.

(expr: &ast::Expr, option: &str)

Source from the content-addressed store, hash-verified

208
209/// Extract a string literal from a function argument expression.
210fn extract_string(expr: &ast::Expr, option: &str) -> Result<String> {
211 match expr {
212 ast::Expr::Value(v) => match &v.value {
213 ast::Value::SingleQuotedString(s) => Ok(s.clone()),
214 _ => Err(SqlError::Unsupported {
215 detail: format!(
216 "ANN option '{option}' expects a string literal (e.g. => 'rabitq'), got: {expr}"
217 ),
218 }),
219 },
220 _ => Err(SqlError::Unsupported {
221 detail: format!(
222 "ANN option '{option}' expects a string literal (e.g. => 'rabitq'), got: {expr}"
223 ),
224 }),
225 }
226}
227
228/// Extract a non-negative integer from a function argument expression.
229fn extract_u64(expr: &ast::Expr, option: &str) -> Result<u64> {

Callers 1

parse_ann_optionsFunction · 0.70

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected