weavatrix-rust 2.1.0

Protocol-independent Rust repository intelligence: typed evidence graphs for impact, architecture, APIs, Git, search, and memory
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use blazingly_json::Value;

pub(super) fn page_offset(args: &Value) -> Result<usize, String> {
    let Some(cursor) = args.get("cursor").and_then(Value::as_str) else {
        return Ok(0);
    };
    let Some(offset) = cursor.strip_prefix("v1:") else {
        return Err("cursor format is invalid; expected v1:<offset>".to_owned());
    };
    offset
        .parse::<usize>()
        .map_err(|_| "cursor offset is invalid".to_owned())
}