Module
marksy/limits
src/marksy/limits.pookaA document may ask for more time than its reader can spare. Checked parsing uses an isolated, monitored BEAM process with byte, reduction, heap, and elapsed-time budgets. The ordinary parser stays a direct, pure operation.
let budget = limits.defaults()
assert limits.run("owl", budget, fn() { 42 }) == Ok(42)
API reference
class Budget(
max_bytes: Int,
max_reductions: Int,
max_heap_words: Int,
timeout_ms: Int
)
Heap size is in BEAM words, not bytes. Reductions measure runtime work rather than source characters; limits are resource guards, not nesting heuristics.
max_bytes: Int
INFERRED
Intmax_reductions: Int
INFERRED
Intmax_heap_words: Int
INFERRED
Inttimeout_ms: Int
INFERRED
Int
INFERRED
fn(Int, Int, Int, Int) -> marksy/limits.Budgetenum Reason
Reason.InvalidBudget
Reason.InputTooLarge
Reason.WorkExceeded
Reason.HeapExceeded
Reason.TimedOut
Reason.WorkerFailed
class LimitError(reason: Reason, message: String)
reason: Reason
INFERRED
marksy/limits.Reasonmessage: String
INFERRED
String
INFERRED
fn(marksy/limits.Reason, String) -> marksy/limits.LimitErrordefaults() -> Budget
INFERRED
fn() -> marksy/limits.BudgetOne MiB of source, twenty million reductions, four million heap words, and five seconds. Applications may choose a different budget for their workload.
run(source: String, budget: Budget, work: fn() -> a) -> Result(a, LimitError)
INFERRED
fn(String, marksy/limits.Budget, fn() -> a) -> Result(a, marksy/limits.LimitError)Reject oversized source before spawning. A cancelled worker is killed and joined before this function returns; its private reply cannot leak later.