pub trait Robot:
Send
+ Sync
+ 'static {
// Required method
fn new(peripherals: Peripherals) -> Self;
// Provided methods
fn initialize(&mut self, _ctx: Context) { ... }
fn autonomous(&mut self, _ctx: Context) { ... }
fn opcontrol(&mut self, _ctx: Context) { ... }
fn disabled(&mut self, _ctx: Context) { ... }
}Expand description
A trait representing a competition-ready VEX Robot.
Required Methods§
Sourcefn new(peripherals: Peripherals) -> Self
fn new(peripherals: Peripherals) -> Self
Runs at startup, constructing your robot. This should be non-blocking, since the FreeRTOS scheduler doesn’t start until it returns.
Provided Methods§
Sourcefn initialize(&mut self, _ctx: Context)
fn initialize(&mut self, _ctx: Context)
Runs immediately after Robot::new. The FreeRTOS scheduler is running
by this point.
The purpose of this method is to provide a hook to run things on startup
which require a reference to all or part of the robot structure; since
it takes &'static self as its parameter, the lifetime of the robot
object is guaranteed to be static (i.e., forever), and so the
implementation may pass references around (e.g., to new tasks) at will
without issue.
Sourcefn autonomous(&mut self, _ctx: Context)
fn autonomous(&mut self, _ctx: Context)
Runs during the autonomous period.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.