Compare commits

3 Commits
master ... peq

Author SHA1 Message Date
c8fccfc398 slight buffer 2025-12-14 19:04:24 -08:00
1253777d3d round trip test 2025-12-14 19:03:42 -08:00
f30302f0bf update roblox_bot_file to prerelease version 2025-12-14 18:59:34 -08:00
3 changed files with 23 additions and 5 deletions

5
Cargo.lock generated
View File

@@ -42,6 +42,7 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
name = "bot-cruncher"
version = "0.1.0"
dependencies = [
"binrw",
"futures",
"strafesnet_roblox_bot_file",
"tokio",
@@ -208,9 +209,9 @@ checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589"
[[package]]
name = "strafesnet_roblox_bot_file"
version = "0.7.0"
version = "0.7.1-pre1"
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
checksum = "d06e3ded397bd8088ff7d3d3a94afedae798eee8b386601ba13b745858b53f94"
checksum = "c308e2ddb87eb19dc1e888b5cd957e3979c47126d2c531b39caa851d709b50cd"
dependencies = [
"binrw",
"bitflags",

View File

@@ -4,7 +4,8 @@ version = "0.1.0"
edition = "2024"
[dependencies]
binrw = "0.15.0"
futures = "0.3.31"
strafesnet_roblox_bot_file = { version = "0.7.0", registry = "strafesnet" }
strafesnet_roblox_bot_file = { version = "0.7.1-pre1", registry = "strafesnet" }
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread", "fs"] }
tokio-stream = { version = "0.1.17", features = ["fs"] }

View File

@@ -10,7 +10,7 @@ enum Error{
Io(std::io::Error),
BotFile{
path:PathBuf,
err:v0::Error
err:RoundTripError,
},
Join(tokio::task::JoinError),
}
@@ -24,6 +24,13 @@ impl From<tokio::task::JoinError> for Error{
Self::Join(value)
}
}
#[derive(Debug)]
enum RoundTripError{
Decode(v0::Error),
Encode(binrw::Error),
RoundTripDecode(v0::Error),
NotEqual,
}
#[tokio::main]
async fn main()->Result<(),Error>{
const PREFETCH_QUEUE:usize=64;
@@ -82,7 +89,16 @@ async fn main()->Result<(),Error>{
.buffer_unordered(PREFETCH_QUEUE)
.map(|result:Result<_,Error>|async move{
let (path,file)=result?;
let result=tokio::task::spawn_blocking(||v0::read_all_to_block(std::io::Cursor::new(file))).await?;
let result=tokio::task::spawn_blocking(move||{
let block=v0::read_all_to_block(std::io::Cursor::new(file.as_slice())).map_err(RoundTripError::Decode)?;
let mut data=Vec::with_capacity(file.len()+1024);
v0::serialize(&block,&mut std::io::Cursor::new(&mut data)).map_err(RoundTripError::Encode)?;
let block_rt=v0::read_all_to_block(std::io::Cursor::new(data)).map_err(RoundTripError::RoundTripDecode)?;
if block_rt!=block{
return Err(RoundTripError::NotEqual);
}
Ok(block)
}).await?;
match result{
Err(err)=>Err(Error::BotFile{path,err}),
Ok(block)=>Ok((path,block)),