#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Status {
Running,
Success,
Failure,
}
pub trait Bhv {
type Context;
fn update(&mut self, ctx: &mut Self::Context) -> Status;
fn reset(&mut self, _status: Status) {}
fn execute(mut self, ctx: &mut Self::Context) -> bool
where
Self: Sized,
{
loop {
match self.update(ctx) {
Status::Running => continue,
Status::Success => return true,
Status::Failure => return false,
}
}
}
}