Struct GameShell

Source
pub struct GameShell<'a, C, R: Read, W: Write> { /* private fields */ }
Expand description

The main virtual machine wrapper for a game shell

This wrapper consumes an input and output stream through which it writes messages.

Implementations§

Source§

impl<'a, C, R: Read, W: Write> GameShell<'a, C, R, W>

Source

pub fn new(context: C, reader: R, writer: W) -> Self

Spawn a new gameshell with a given context and readers/writers.

Source

pub fn evaluator(&mut self) -> &mut Evaluator<'a, C>

Get a reference to the current evaluator.

Source

pub fn context(&self) -> &C

Get a reference to the current context.

Source

pub fn context_mut(&mut self) -> &mut C

Get a mutable reference to the current context.

Source

pub fn register( &mut self, spec: Spec<'_, 'a, Type, String, C>, ) -> Result<(), RegError>

Register a command specificator to this gameshell instance.

Source

pub fn register_many( &mut self, spec: &[Spec<'_, 'a, Type, String, C>], ) -> Result<(), RegError>

Register multiple command specifications to this gameshell instance.

Trait Implementations§

Source§

impl<'a, C, R: Read, W: Write> IncConsumer for GameShell<'a, C, R, W>

Source§

fn consume(&mut self, output: &mut [u8]) -> Consumption

Consume bytes and place them on an output stack
Source§

fn validate(&mut self, input: u8) -> Validation

Validate part of the bytestream, as soon as we return Validation::Ready, process will be run on the current accumulated bytes, after which these bytes will be deleted.
Source§

fn process(&mut self, input: &[u8]) -> Process

Process do actual stuff with the bytes to affect the system. Read more
Source§

fn run(&mut self, buf: &mut [u8])

Runs the incremental consumer until it is signalled to quit

Auto Trait Implementations§

§

impl<'a, C, R, W> Freeze for GameShell<'a, C, R, W>
where R: Freeze, W: Freeze, C: Freeze,

§

impl<'a, C, R, W> RefUnwindSafe for GameShell<'a, C, R, W>

§

impl<'a, C, R, W> Send for GameShell<'a, C, R, W>
where R: Send, W: Send, C: Send,

§

impl<'a, C, R, W> Sync for GameShell<'a, C, R, W>
where R: Sync, W: Sync, C: Sync,

§

impl<'a, C, R, W> Unpin for GameShell<'a, C, R, W>
where R: Unpin, W: Unpin, C: Unpin,

§

impl<'a, C, R, W> UnwindSafe for GameShell<'a, C, R, W>
where R: UnwindSafe, W: UnwindSafe, C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.