Struct nimble_rust::Rectify

source ·
pub struct Rectify<Game, StepT>
where Game: AssentCallback<StepT> + SeerCallback<StepT> + RectifyCallback, StepT: Clone,
{ /* private fields */ }
Expand description

The Rectify struct coordinates between the Assent and Seer components, managing authoritative and predicted game states.

Implementations§

source§

impl<Game, StepT> Rectify<Game, StepT>
where Game: AssentCallback<StepT> + SeerCallback<StepT> + RectifyCallback, StepT: Clone,

source

pub fn new() -> Rectify<Game, StepT>

Creates a new Rectify instance, initializing both Assent and Seer components.

§Returns

A new Rectify instance.

source

pub fn seer(&self) -> &Seer<Game, StepT>

source

pub fn assent(&self) -> &Assent<Game, StepT>

source

pub fn push_predicted(&mut self, step: StepT)

Pushes a predicted step into the Seer component.

§Arguments
  • step - The predicted step to be pushed.
source

pub fn waiting_for_authoritative_tick_id(&self) -> Option<TickId>

source

pub fn push_authoritative(&mut self, step: StepT)

Pushes an authoritative step into the Assent component. This method is used to add new steps that have been determined by the authoritative host.

§Arguments
  • step - The authoritative step to be pushed.
source

pub fn push_authoritative_with_check( &mut self, step_for_tick_id: TickId, step: StepT, ) -> Result<(), String>

Pushes an authoritative step into the Assent component. This method is used to add new steps that have been determined by the authoritative host.

§Arguments
  • step - The authoritative step to be pushed.
source

pub fn update(&mut self, game: &mut Game)

Updates the authoritative state. If all the authoritative state has been calculated it predicts from the last authoritative state.

§Arguments
  • game - A mutable reference to the game implementing the necessary callback traits.

Trait Implementations§

source§

impl<Game, StepT> Debug for Rectify<Game, StepT>
where Game: Debug + AssentCallback<StepT> + SeerCallback<StepT> + RectifyCallback, StepT: Debug + Clone,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<Game, StepT> Default for Rectify<Game, StepT>
where Game: AssentCallback<StepT> + SeerCallback<StepT> + RectifyCallback, StepT: Clone,

source§

fn default() -> Rectify<Game, StepT>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Game, StepT> Freeze for Rectify<Game, StepT>

§

impl<Game, StepT> RefUnwindSafe for Rectify<Game, StepT>
where Game: RefUnwindSafe, StepT: RefUnwindSafe,

§

impl<Game, StepT> Send for Rectify<Game, StepT>
where Game: Send, StepT: Send,

§

impl<Game, StepT> Sync for Rectify<Game, StepT>
where Game: Sync, StepT: Sync,

§

impl<Game, StepT> Unpin for Rectify<Game, StepT>
where Game: Unpin, StepT: Unpin,

§

impl<Game, StepT> UnwindSafe for Rectify<Game, StepT>
where Game: UnwindSafe, StepT: 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.