MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / guard

Function guard

crates/sql-parser/src/parser/recursion.rs:20–26  ·  view source on GitHub ↗

A utility for guarding against stack overflows in the SQL parser. Usage: ``` use spacetimedb_sql_parser::parser::recursion; let mut depth = 0; assert!(recursion::guard(depth, 10, "test").is_ok()); ```

(depth: usize, limit: usize, source: &'static str)

Source from the content-addressed store, hash-verified

18/// assert!(recursion::guard(depth, 10, "test").is_ok());
19/// ```
20pub fn guard(depth: usize, limit: usize, source: &'static str) -> Result<(), SqlParseError> {
21 if depth > limit {
22 Err(RecursionError { source_: source }.into())
23 } else {
24 Ok(())
25 }
26}

Callers 15

_type_exprFunction · 0.85
run_innerFunction · 0.85
call_identity_connectedFunction · 0.85
guard_txMethod · 0.85
guard_mut_txMethod · 0.85
ws_client_actorFunction · 0.85
create_segmentMethod · 0.85
closeMethod · 0.85

Calls 2

ErrFunction · 0.50
OkFunction · 0.50

Tested by 2

mountFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…