Struct nimble_rust::pending_steps::PendingSteps

source ·
pub struct PendingSteps<T>
where T: Clone,
{ /* private fields */ }
Expand description

Manages a sequence of pending steps that are queued to be executed at specific ticks in a game loop.

This struct contains a buffer (DiscoidBuffer) of PendingStepInfo elements, designed to handle multiple steps that are pending execution across different ticks.

§Type Parameters

  • T - Represents the type of steps stored within the buffer. As a generic parameter, it allows the PendingSteps struct to be flexible and applicable to various types of games or simulations where different actions are defined as steps.

§Fields

  • steps - A circular buffer (implemented via DiscoidBuffer) optimized for storing and retrieving pending steps efficiently.

  • front_tick_id - The tick ID of the first step in the buffer.

  • capacity - The maximum number of steps that can be stored in the buffer. This parameter helps control memory usage and maintain performance.

§Examples

use discoid::discoid::DiscoidBuffer;
use tick_id::TickId;
use nimble_steps::pending_steps::PendingSteps;

let pending_steps = PendingSteps::<i32>::new(10, TickId::new(1));

Implementations§

source§

impl<T> PendingSteps<T>
where T: Clone,

source

pub fn new(window_size: usize, tick_id: TickId) -> PendingSteps<T>

source

pub fn set(&mut self, tick_id: TickId, step: T) -> Result<(), String>

source

pub fn discard_up_to(&mut self, tick_id: TickId)

source

pub fn is_empty(&self) -> bool

source

pub fn pop(&mut self) -> PendingStepInfo<T>

source

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

Auto Trait Implementations§

§

impl<T> Freeze for PendingSteps<T>

§

impl<T> RefUnwindSafe for PendingSteps<T>
where T: RefUnwindSafe,

§

impl<T> Send for PendingSteps<T>
where T: Send,

§

impl<T> Sync for PendingSteps<T>
where T: Sync,

§

impl<T> Unpin for PendingSteps<T>
where T: Unpin,

§

impl<T> UnwindSafe for PendingSteps<T>
where T: 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.