Auto-update offsets in Rust
Request the current dataset with reqwest, validate the HTTP response, and read the values through serde_json.
Request
Use JSON for runtime loading. Change the dataset to fflags when you need the flag registry instead of property offsets.
GET
https://api.decamp.dev/v1/latest?game=roblox&dataset=offsets&format=json- game
- roblox
- dataset
- offsets / fflags
- format
- json / hpp
Before you start
01
A Rust project using the 2021 or 2024 edition.
02
Add reqwest and serde_json to
Cargo.toml:[dependencies]
reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] }
serde_json = "1"Create the API request helper
use serde_json::Value;
use std::error::Error;
fn fetch_offsets() -> Result<Value, Box<dyn Error>> {
let url = "https://api.decamp.dev/v1/latest ?game=roblox&dataset=offsets&format=json";
let response = reqwest::blocking::get(url)?
.error_for_status()?
.json()?;
Ok(response)
}Find an offset by name
Read the class and field directly from the nested Offsets object and parse its hexadecimal value.
fn find_offset(
data: &Value,
class_name: &str,
property_name: &str,
) -> Option<u64> {
let value = data["Offsets"][class_name][property_name].as_str()?;
let value = value.strip_prefix("0x")?;
u64::from_str_radix(value, 16).ok()
}Putting it together
Fetch the current dataset, read the values your project needs, and keep the parsed result in memory.
fn main() -> Result<(), Box<dyn std::error::Error>> {
let data = fetch_offsets()?;
let Some(balance_speed) = find_offset(
&data,
"ClimbController",
"BalanceSpeed",
) else {
eprintln!("[-] offset is unavailable");
return Ok(());
};
let generated = data["Dumped At"]
.as_str()
.unwrap_or("unknown");
let resolved = data["Total Offsets"]
.as_u64()
.unwrap_or(0);
println!("[+] generated: {generated}");
println!("[+] resolved: {resolved}");
println!("[+] ClimbController::BalanceSpeed: {balance_speed:#X}");
Ok(())
}Responses
200The selected file was returned.304No update. The cached file is still current.400The dataset or format is invalid.404The game or route does not exist.405The endpoint only accepts GET, HEAD, and OPTIONS.409The selected game is known but not available yet.500The service encountered an unexpected error.503The generated file is temporarily unavailable.