Struct gameshell::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> RefUnwindSafe for GameShell<'a, C, R, W>where C: RefUnwindSafe, R: RefUnwindSafe, W: RefUnwindSafe,

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.