prototype
This commit is contained in:
parent
8911968a7c
commit
91b90675c4
27
src/bot.rs
27
src/bot.rs
@ -1,4 +1,6 @@
|
|||||||
use binrw::{BinReaderExt, binrw};
|
use binrw::{binrw,BinReaderExt,BinWriterExt};
|
||||||
|
use crate::newtypes::instruction::TimedInstruction;
|
||||||
|
use crate::newtypes::physics::PhysicsInputInstruction;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error{
|
pub enum Error{
|
||||||
@ -8,6 +10,29 @@ pub enum Error{
|
|||||||
File(crate::file::Error),
|
File(crate::file::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct BotDebug{
|
||||||
|
name:String,
|
||||||
|
file:std::fs::File,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BotDebug{
|
||||||
|
pub fn new()->std::io::Result<Self>{
|
||||||
|
let rng:u128=rand::random();
|
||||||
|
let name=format!("{rng:x}");
|
||||||
|
Ok(Self{
|
||||||
|
file:std::fs::File::create(name.as_str())?,
|
||||||
|
name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pub fn delete(self)->std::io::Result<()>{
|
||||||
|
std::mem::drop(self.file);
|
||||||
|
std::fs::remove_file(self.name)
|
||||||
|
}
|
||||||
|
pub fn push(&self,ins:TimedInstruction<PhysicsInputInstruction>)->Result<(),binrw::Error>{
|
||||||
|
self.file.write_le(ins)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* block types
|
/* block types
|
||||||
|
|
||||||
BLOCK_BOT_HEADER:
|
BLOCK_BOT_HEADER:
|
||||||
|
Loading…
Reference in New Issue
Block a user